messagepack implementation for embedded systems (mbed / arduino)

Dependents:   hello_message_pack

msgpack-c & msgpack-c++ https://github.com/msgpack/msgpack-c implementation for embedded systems (mbed / Arduino)

Committer:
hideakitai
Date:
Sat Feb 13 01:53:11 2016 +0000
Revision:
0:3f9dbf1e2cb0
first commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hideakitai 0:3f9dbf1e2cb0 1 /*
hideakitai 0:3f9dbf1e2cb0 2 * MessagePack packing routine template
hideakitai 0:3f9dbf1e2cb0 3 *
hideakitai 0:3f9dbf1e2cb0 4 * Copyright (C) 2008-2010 FURUHASHI Sadayuki
hideakitai 0:3f9dbf1e2cb0 5 *
hideakitai 0:3f9dbf1e2cb0 6 * Distributed under the Boost Software License, Version 1.0.
hideakitai 0:3f9dbf1e2cb0 7 * (See accompanying file LICENSE_1_0.txt or copy at
hideakitai 0:3f9dbf1e2cb0 8 * http://www.boost.org/LICENSE_1_0.txt)
hideakitai 0:3f9dbf1e2cb0 9 */
hideakitai 0:3f9dbf1e2cb0 10
hideakitai 0:3f9dbf1e2cb0 11 #if MSGPACK_ENDIAN_LITTLE_BYTE
hideakitai 0:3f9dbf1e2cb0 12 #define TAKE8_8(d) ((uint8_t*)&d)[0]
hideakitai 0:3f9dbf1e2cb0 13 #define TAKE8_16(d) ((uint8_t*)&d)[0]
hideakitai 0:3f9dbf1e2cb0 14 #define TAKE8_32(d) ((uint8_t*)&d)[0]
hideakitai 0:3f9dbf1e2cb0 15 #define TAKE8_64(d) ((uint8_t*)&d)[0]
hideakitai 0:3f9dbf1e2cb0 16 #elif MSGPACK_ENDIAN_BIG_BYTE
hideakitai 0:3f9dbf1e2cb0 17 #define TAKE8_8(d) ((uint8_t*)&d)[0]
hideakitai 0:3f9dbf1e2cb0 18 #define TAKE8_16(d) ((uint8_t*)&d)[1]
hideakitai 0:3f9dbf1e2cb0 19 #define TAKE8_32(d) ((uint8_t*)&d)[3]
hideakitai 0:3f9dbf1e2cb0 20 #define TAKE8_64(d) ((uint8_t*)&d)[7]
hideakitai 0:3f9dbf1e2cb0 21 #else
hideakitai 0:3f9dbf1e2cb0 22 #error msgpack-c supports only big endian and little endian
hideakitai 0:3f9dbf1e2cb0 23 #endif
hideakitai 0:3f9dbf1e2cb0 24
hideakitai 0:3f9dbf1e2cb0 25 #ifndef msgpack_pack_inline_func
hideakitai 0:3f9dbf1e2cb0 26 #error msgpack_pack_inline_func template is not defined
hideakitai 0:3f9dbf1e2cb0 27 #endif
hideakitai 0:3f9dbf1e2cb0 28
hideakitai 0:3f9dbf1e2cb0 29 #ifndef msgpack_pack_user
hideakitai 0:3f9dbf1e2cb0 30 #error msgpack_pack_user type is not defined
hideakitai 0:3f9dbf1e2cb0 31 #endif
hideakitai 0:3f9dbf1e2cb0 32
hideakitai 0:3f9dbf1e2cb0 33 #ifndef msgpack_pack_append_buffer
hideakitai 0:3f9dbf1e2cb0 34 #error msgpack_pack_append_buffer callback is not defined
hideakitai 0:3f9dbf1e2cb0 35 #endif
hideakitai 0:3f9dbf1e2cb0 36
hideakitai 0:3f9dbf1e2cb0 37
hideakitai 0:3f9dbf1e2cb0 38 /*
hideakitai 0:3f9dbf1e2cb0 39 * Integer
hideakitai 0:3f9dbf1e2cb0 40 */
hideakitai 0:3f9dbf1e2cb0 41
hideakitai 0:3f9dbf1e2cb0 42 #define msgpack_pack_real_uint8(x, d) \
hideakitai 0:3f9dbf1e2cb0 43 do { \
hideakitai 0:3f9dbf1e2cb0 44 if(d < (1<<7)) { \
hideakitai 0:3f9dbf1e2cb0 45 /* fixnum */ \
hideakitai 0:3f9dbf1e2cb0 46 msgpack_pack_append_buffer(x, &TAKE8_8(d), 1); \
hideakitai 0:3f9dbf1e2cb0 47 } else { \
hideakitai 0:3f9dbf1e2cb0 48 /* unsigned 8 */ \
hideakitai 0:3f9dbf1e2cb0 49 unsigned char buf[2] = {0xcc, TAKE8_8(d)}; \
hideakitai 0:3f9dbf1e2cb0 50 msgpack_pack_append_buffer(x, buf, 2); \
hideakitai 0:3f9dbf1e2cb0 51 } \
hideakitai 0:3f9dbf1e2cb0 52 } while(0)
hideakitai 0:3f9dbf1e2cb0 53
hideakitai 0:3f9dbf1e2cb0 54 #define msgpack_pack_real_uint16(x, d) \
hideakitai 0:3f9dbf1e2cb0 55 do { \
hideakitai 0:3f9dbf1e2cb0 56 if(d < (1<<7)) { \
hideakitai 0:3f9dbf1e2cb0 57 /* fixnum */ \
hideakitai 0:3f9dbf1e2cb0 58 msgpack_pack_append_buffer(x, &TAKE8_16(d), 1); \
hideakitai 0:3f9dbf1e2cb0 59 } else if(d < (1<<8)) { \
hideakitai 0:3f9dbf1e2cb0 60 /* unsigned 8 */ \
hideakitai 0:3f9dbf1e2cb0 61 unsigned char buf[2] = {0xcc, TAKE8_16(d)}; \
hideakitai 0:3f9dbf1e2cb0 62 msgpack_pack_append_buffer(x, buf, 2); \
hideakitai 0:3f9dbf1e2cb0 63 } else { \
hideakitai 0:3f9dbf1e2cb0 64 /* unsigned 16 */ \
hideakitai 0:3f9dbf1e2cb0 65 unsigned char buf[3]; \
hideakitai 0:3f9dbf1e2cb0 66 buf[0] = 0xcd; _msgpack_store16(&buf[1], (uint16_t)d); \
hideakitai 0:3f9dbf1e2cb0 67 msgpack_pack_append_buffer(x, buf, 3); \
hideakitai 0:3f9dbf1e2cb0 68 } \
hideakitai 0:3f9dbf1e2cb0 69 } while(0)
hideakitai 0:3f9dbf1e2cb0 70
hideakitai 0:3f9dbf1e2cb0 71 #define msgpack_pack_real_uint32(x, d) \
hideakitai 0:3f9dbf1e2cb0 72 do { \
hideakitai 0:3f9dbf1e2cb0 73 if(d < (1<<8)) { \
hideakitai 0:3f9dbf1e2cb0 74 if(d < (1<<7)) { \
hideakitai 0:3f9dbf1e2cb0 75 /* fixnum */ \
hideakitai 0:3f9dbf1e2cb0 76 msgpack_pack_append_buffer(x, &TAKE8_32(d), 1); \
hideakitai 0:3f9dbf1e2cb0 77 } else { \
hideakitai 0:3f9dbf1e2cb0 78 /* unsigned 8 */ \
hideakitai 0:3f9dbf1e2cb0 79 unsigned char buf[2] = {0xcc, TAKE8_32(d)}; \
hideakitai 0:3f9dbf1e2cb0 80 msgpack_pack_append_buffer(x, buf, 2); \
hideakitai 0:3f9dbf1e2cb0 81 } \
hideakitai 0:3f9dbf1e2cb0 82 } else { \
hideakitai 0:3f9dbf1e2cb0 83 if(d < (1<<16)) { \
hideakitai 0:3f9dbf1e2cb0 84 /* unsigned 16 */ \
hideakitai 0:3f9dbf1e2cb0 85 unsigned char buf[3]; \
hideakitai 0:3f9dbf1e2cb0 86 buf[0] = 0xcd; _msgpack_store16(&buf[1], (uint16_t)d); \
hideakitai 0:3f9dbf1e2cb0 87 msgpack_pack_append_buffer(x, buf, 3); \
hideakitai 0:3f9dbf1e2cb0 88 } else { \
hideakitai 0:3f9dbf1e2cb0 89 /* unsigned 32 */ \
hideakitai 0:3f9dbf1e2cb0 90 unsigned char buf[5]; \
hideakitai 0:3f9dbf1e2cb0 91 buf[0] = 0xce; _msgpack_store32(&buf[1], (uint32_t)d); \
hideakitai 0:3f9dbf1e2cb0 92 msgpack_pack_append_buffer(x, buf, 5); \
hideakitai 0:3f9dbf1e2cb0 93 } \
hideakitai 0:3f9dbf1e2cb0 94 } \
hideakitai 0:3f9dbf1e2cb0 95 } while(0)
hideakitai 0:3f9dbf1e2cb0 96
hideakitai 0:3f9dbf1e2cb0 97 #define msgpack_pack_real_uint64(x, d) \
hideakitai 0:3f9dbf1e2cb0 98 do { \
hideakitai 0:3f9dbf1e2cb0 99 if(d < (1ULL<<8)) { \
hideakitai 0:3f9dbf1e2cb0 100 if(d < (1ULL<<7)) { \
hideakitai 0:3f9dbf1e2cb0 101 /* fixnum */ \
hideakitai 0:3f9dbf1e2cb0 102 msgpack_pack_append_buffer(x, &TAKE8_64(d), 1); \
hideakitai 0:3f9dbf1e2cb0 103 } else { \
hideakitai 0:3f9dbf1e2cb0 104 /* unsigned 8 */ \
hideakitai 0:3f9dbf1e2cb0 105 unsigned char buf[2] = {0xcc, TAKE8_64(d)}; \
hideakitai 0:3f9dbf1e2cb0 106 msgpack_pack_append_buffer(x, buf, 2); \
hideakitai 0:3f9dbf1e2cb0 107 } \
hideakitai 0:3f9dbf1e2cb0 108 } else { \
hideakitai 0:3f9dbf1e2cb0 109 if(d < (1ULL<<16)) { \
hideakitai 0:3f9dbf1e2cb0 110 /* unsigned 16 */ \
hideakitai 0:3f9dbf1e2cb0 111 unsigned char buf[3]; \
hideakitai 0:3f9dbf1e2cb0 112 buf[0] = 0xcd; _msgpack_store16(&buf[1], (uint16_t)d); \
hideakitai 0:3f9dbf1e2cb0 113 msgpack_pack_append_buffer(x, buf, 3); \
hideakitai 0:3f9dbf1e2cb0 114 } else if(d < (1ULL<<32)) { \
hideakitai 0:3f9dbf1e2cb0 115 /* unsigned 32 */ \
hideakitai 0:3f9dbf1e2cb0 116 unsigned char buf[5]; \
hideakitai 0:3f9dbf1e2cb0 117 buf[0] = 0xce; _msgpack_store32(&buf[1], (uint32_t)d); \
hideakitai 0:3f9dbf1e2cb0 118 msgpack_pack_append_buffer(x, buf, 5); \
hideakitai 0:3f9dbf1e2cb0 119 } else { \
hideakitai 0:3f9dbf1e2cb0 120 /* unsigned 64 */ \
hideakitai 0:3f9dbf1e2cb0 121 unsigned char buf[9]; \
hideakitai 0:3f9dbf1e2cb0 122 buf[0] = 0xcf; _msgpack_store64(&buf[1], d); \
hideakitai 0:3f9dbf1e2cb0 123 msgpack_pack_append_buffer(x, buf, 9); \
hideakitai 0:3f9dbf1e2cb0 124 } \
hideakitai 0:3f9dbf1e2cb0 125 } \
hideakitai 0:3f9dbf1e2cb0 126 } while(0)
hideakitai 0:3f9dbf1e2cb0 127
hideakitai 0:3f9dbf1e2cb0 128 #define msgpack_pack_real_int8(x, d) \
hideakitai 0:3f9dbf1e2cb0 129 do { \
hideakitai 0:3f9dbf1e2cb0 130 if(d < -(1<<5)) { \
hideakitai 0:3f9dbf1e2cb0 131 /* signed 8 */ \
hideakitai 0:3f9dbf1e2cb0 132 unsigned char buf[2] = {0xd0, TAKE8_8(d)}; \
hideakitai 0:3f9dbf1e2cb0 133 msgpack_pack_append_buffer(x, buf, 2); \
hideakitai 0:3f9dbf1e2cb0 134 } else { \
hideakitai 0:3f9dbf1e2cb0 135 /* fixnum */ \
hideakitai 0:3f9dbf1e2cb0 136 msgpack_pack_append_buffer(x, &TAKE8_8(d), 1); \
hideakitai 0:3f9dbf1e2cb0 137 } \
hideakitai 0:3f9dbf1e2cb0 138 } while(0)
hideakitai 0:3f9dbf1e2cb0 139
hideakitai 0:3f9dbf1e2cb0 140 #define msgpack_pack_real_int16(x, d) \
hideakitai 0:3f9dbf1e2cb0 141 do { \
hideakitai 0:3f9dbf1e2cb0 142 if(d < -(1<<5)) { \
hideakitai 0:3f9dbf1e2cb0 143 if(d < -(1<<7)) { \
hideakitai 0:3f9dbf1e2cb0 144 /* signed 16 */ \
hideakitai 0:3f9dbf1e2cb0 145 unsigned char buf[3]; \
hideakitai 0:3f9dbf1e2cb0 146 buf[0] = 0xd1; _msgpack_store16(&buf[1], (int16_t)d); \
hideakitai 0:3f9dbf1e2cb0 147 msgpack_pack_append_buffer(x, buf, 3); \
hideakitai 0:3f9dbf1e2cb0 148 } else { \
hideakitai 0:3f9dbf1e2cb0 149 /* signed 8 */ \
hideakitai 0:3f9dbf1e2cb0 150 unsigned char buf[2] = {0xd0, TAKE8_16(d)}; \
hideakitai 0:3f9dbf1e2cb0 151 msgpack_pack_append_buffer(x, buf, 2); \
hideakitai 0:3f9dbf1e2cb0 152 } \
hideakitai 0:3f9dbf1e2cb0 153 } else if(d < (1<<7)) { \
hideakitai 0:3f9dbf1e2cb0 154 /* fixnum */ \
hideakitai 0:3f9dbf1e2cb0 155 msgpack_pack_append_buffer(x, &TAKE8_16(d), 1); \
hideakitai 0:3f9dbf1e2cb0 156 } else { \
hideakitai 0:3f9dbf1e2cb0 157 if(d < (1<<8)) { \
hideakitai 0:3f9dbf1e2cb0 158 /* unsigned 8 */ \
hideakitai 0:3f9dbf1e2cb0 159 unsigned char buf[2] = {0xcc, TAKE8_16(d)}; \
hideakitai 0:3f9dbf1e2cb0 160 msgpack_pack_append_buffer(x, buf, 2); \
hideakitai 0:3f9dbf1e2cb0 161 } else { \
hideakitai 0:3f9dbf1e2cb0 162 /* unsigned 16 */ \
hideakitai 0:3f9dbf1e2cb0 163 unsigned char buf[3]; \
hideakitai 0:3f9dbf1e2cb0 164 buf[0] = 0xcd; _msgpack_store16(&buf[1], (uint16_t)d); \
hideakitai 0:3f9dbf1e2cb0 165 msgpack_pack_append_buffer(x, buf, 3); \
hideakitai 0:3f9dbf1e2cb0 166 } \
hideakitai 0:3f9dbf1e2cb0 167 } \
hideakitai 0:3f9dbf1e2cb0 168 } while(0)
hideakitai 0:3f9dbf1e2cb0 169
hideakitai 0:3f9dbf1e2cb0 170 #define msgpack_pack_real_int32(x, d) \
hideakitai 0:3f9dbf1e2cb0 171 do { \
hideakitai 0:3f9dbf1e2cb0 172 if(d < -(1<<5)) { \
hideakitai 0:3f9dbf1e2cb0 173 if(d < -(1<<15)) { \
hideakitai 0:3f9dbf1e2cb0 174 /* signed 32 */ \
hideakitai 0:3f9dbf1e2cb0 175 unsigned char buf[5]; \
hideakitai 0:3f9dbf1e2cb0 176 buf[0] = 0xd2; _msgpack_store32(&buf[1], (int32_t)d); \
hideakitai 0:3f9dbf1e2cb0 177 msgpack_pack_append_buffer(x, buf, 5); \
hideakitai 0:3f9dbf1e2cb0 178 } else if(d < -(1<<7)) { \
hideakitai 0:3f9dbf1e2cb0 179 /* signed 16 */ \
hideakitai 0:3f9dbf1e2cb0 180 unsigned char buf[3]; \
hideakitai 0:3f9dbf1e2cb0 181 buf[0] = 0xd1; _msgpack_store16(&buf[1], (int16_t)d); \
hideakitai 0:3f9dbf1e2cb0 182 msgpack_pack_append_buffer(x, buf, 3); \
hideakitai 0:3f9dbf1e2cb0 183 } else { \
hideakitai 0:3f9dbf1e2cb0 184 /* signed 8 */ \
hideakitai 0:3f9dbf1e2cb0 185 unsigned char buf[2] = {0xd0, TAKE8_32(d)}; \
hideakitai 0:3f9dbf1e2cb0 186 msgpack_pack_append_buffer(x, buf, 2); \
hideakitai 0:3f9dbf1e2cb0 187 } \
hideakitai 0:3f9dbf1e2cb0 188 } else if(d < (1<<7)) { \
hideakitai 0:3f9dbf1e2cb0 189 /* fixnum */ \
hideakitai 0:3f9dbf1e2cb0 190 msgpack_pack_append_buffer(x, &TAKE8_32(d), 1); \
hideakitai 0:3f9dbf1e2cb0 191 } else { \
hideakitai 0:3f9dbf1e2cb0 192 if(d < (1<<8)) { \
hideakitai 0:3f9dbf1e2cb0 193 /* unsigned 8 */ \
hideakitai 0:3f9dbf1e2cb0 194 unsigned char buf[2] = {0xcc, TAKE8_32(d)}; \
hideakitai 0:3f9dbf1e2cb0 195 msgpack_pack_append_buffer(x, buf, 2); \
hideakitai 0:3f9dbf1e2cb0 196 } else if(d < (1<<16)) { \
hideakitai 0:3f9dbf1e2cb0 197 /* unsigned 16 */ \
hideakitai 0:3f9dbf1e2cb0 198 unsigned char buf[3]; \
hideakitai 0:3f9dbf1e2cb0 199 buf[0] = 0xcd; _msgpack_store16(&buf[1], (uint16_t)d); \
hideakitai 0:3f9dbf1e2cb0 200 msgpack_pack_append_buffer(x, buf, 3); \
hideakitai 0:3f9dbf1e2cb0 201 } else { \
hideakitai 0:3f9dbf1e2cb0 202 /* unsigned 32 */ \
hideakitai 0:3f9dbf1e2cb0 203 unsigned char buf[5]; \
hideakitai 0:3f9dbf1e2cb0 204 buf[0] = 0xce; _msgpack_store32(&buf[1], (uint32_t)d); \
hideakitai 0:3f9dbf1e2cb0 205 msgpack_pack_append_buffer(x, buf, 5); \
hideakitai 0:3f9dbf1e2cb0 206 } \
hideakitai 0:3f9dbf1e2cb0 207 } \
hideakitai 0:3f9dbf1e2cb0 208 } while(0)
hideakitai 0:3f9dbf1e2cb0 209
hideakitai 0:3f9dbf1e2cb0 210 #define msgpack_pack_real_int64(x, d) \
hideakitai 0:3f9dbf1e2cb0 211 do { \
hideakitai 0:3f9dbf1e2cb0 212 if(d < -(1LL<<5)) { \
hideakitai 0:3f9dbf1e2cb0 213 if(d < -(1LL<<15)) { \
hideakitai 0:3f9dbf1e2cb0 214 if(d < -(1LL<<31)) { \
hideakitai 0:3f9dbf1e2cb0 215 /* signed 64 */ \
hideakitai 0:3f9dbf1e2cb0 216 unsigned char buf[9]; \
hideakitai 0:3f9dbf1e2cb0 217 buf[0] = 0xd3; _msgpack_store64(&buf[1], d); \
hideakitai 0:3f9dbf1e2cb0 218 msgpack_pack_append_buffer(x, buf, 9); \
hideakitai 0:3f9dbf1e2cb0 219 } else { \
hideakitai 0:3f9dbf1e2cb0 220 /* signed 32 */ \
hideakitai 0:3f9dbf1e2cb0 221 unsigned char buf[5]; \
hideakitai 0:3f9dbf1e2cb0 222 buf[0] = 0xd2; _msgpack_store32(&buf[1], (int32_t)d); \
hideakitai 0:3f9dbf1e2cb0 223 msgpack_pack_append_buffer(x, buf, 5); \
hideakitai 0:3f9dbf1e2cb0 224 } \
hideakitai 0:3f9dbf1e2cb0 225 } else { \
hideakitai 0:3f9dbf1e2cb0 226 if(d < -(1<<7)) { \
hideakitai 0:3f9dbf1e2cb0 227 /* signed 16 */ \
hideakitai 0:3f9dbf1e2cb0 228 unsigned char buf[3]; \
hideakitai 0:3f9dbf1e2cb0 229 buf[0] = 0xd1; _msgpack_store16(&buf[1], (int16_t)d); \
hideakitai 0:3f9dbf1e2cb0 230 msgpack_pack_append_buffer(x, buf, 3); \
hideakitai 0:3f9dbf1e2cb0 231 } else { \
hideakitai 0:3f9dbf1e2cb0 232 /* signed 8 */ \
hideakitai 0:3f9dbf1e2cb0 233 unsigned char buf[2] = {0xd0, TAKE8_64(d)}; \
hideakitai 0:3f9dbf1e2cb0 234 msgpack_pack_append_buffer(x, buf, 2); \
hideakitai 0:3f9dbf1e2cb0 235 } \
hideakitai 0:3f9dbf1e2cb0 236 } \
hideakitai 0:3f9dbf1e2cb0 237 } else if(d < (1<<7)) { \
hideakitai 0:3f9dbf1e2cb0 238 /* fixnum */ \
hideakitai 0:3f9dbf1e2cb0 239 msgpack_pack_append_buffer(x, &TAKE8_64(d), 1); \
hideakitai 0:3f9dbf1e2cb0 240 } else { \
hideakitai 0:3f9dbf1e2cb0 241 if(d < (1LL<<16)) { \
hideakitai 0:3f9dbf1e2cb0 242 if(d < (1<<8)) { \
hideakitai 0:3f9dbf1e2cb0 243 /* unsigned 8 */ \
hideakitai 0:3f9dbf1e2cb0 244 unsigned char buf[2] = {0xcc, TAKE8_64(d)}; \
hideakitai 0:3f9dbf1e2cb0 245 msgpack_pack_append_buffer(x, buf, 2); \
hideakitai 0:3f9dbf1e2cb0 246 } else { \
hideakitai 0:3f9dbf1e2cb0 247 /* unsigned 16 */ \
hideakitai 0:3f9dbf1e2cb0 248 unsigned char buf[3]; \
hideakitai 0:3f9dbf1e2cb0 249 buf[0] = 0xcd; _msgpack_store16(&buf[1], (uint16_t)d); \
hideakitai 0:3f9dbf1e2cb0 250 msgpack_pack_append_buffer(x, buf, 3); \
hideakitai 0:3f9dbf1e2cb0 251 } \
hideakitai 0:3f9dbf1e2cb0 252 } else { \
hideakitai 0:3f9dbf1e2cb0 253 if(d < (1LL<<32)) { \
hideakitai 0:3f9dbf1e2cb0 254 /* unsigned 32 */ \
hideakitai 0:3f9dbf1e2cb0 255 unsigned char buf[5]; \
hideakitai 0:3f9dbf1e2cb0 256 buf[0] = 0xce; _msgpack_store32(&buf[1], (uint32_t)d); \
hideakitai 0:3f9dbf1e2cb0 257 msgpack_pack_append_buffer(x, buf, 5); \
hideakitai 0:3f9dbf1e2cb0 258 } else { \
hideakitai 0:3f9dbf1e2cb0 259 /* unsigned 64 */ \
hideakitai 0:3f9dbf1e2cb0 260 unsigned char buf[9]; \
hideakitai 0:3f9dbf1e2cb0 261 buf[0] = 0xcf; _msgpack_store64(&buf[1], d); \
hideakitai 0:3f9dbf1e2cb0 262 msgpack_pack_append_buffer(x, buf, 9); \
hideakitai 0:3f9dbf1e2cb0 263 } \
hideakitai 0:3f9dbf1e2cb0 264 } \
hideakitai 0:3f9dbf1e2cb0 265 } \
hideakitai 0:3f9dbf1e2cb0 266 } while(0)
hideakitai 0:3f9dbf1e2cb0 267
hideakitai 0:3f9dbf1e2cb0 268
hideakitai 0:3f9dbf1e2cb0 269 #ifdef msgpack_pack_inline_func_fixint
hideakitai 0:3f9dbf1e2cb0 270
hideakitai 0:3f9dbf1e2cb0 271 msgpack_pack_inline_func_fixint(_uint8)(msgpack_pack_user x, uint8_t d)
hideakitai 0:3f9dbf1e2cb0 272 {
hideakitai 0:3f9dbf1e2cb0 273 unsigned char buf[2] = {0xcc, TAKE8_8(d)};
hideakitai 0:3f9dbf1e2cb0 274 msgpack_pack_append_buffer(x, buf, 2);
hideakitai 0:3f9dbf1e2cb0 275 }
hideakitai 0:3f9dbf1e2cb0 276
hideakitai 0:3f9dbf1e2cb0 277 msgpack_pack_inline_func_fixint(_uint16)(msgpack_pack_user x, uint16_t d)
hideakitai 0:3f9dbf1e2cb0 278 {
hideakitai 0:3f9dbf1e2cb0 279 unsigned char buf[3];
hideakitai 0:3f9dbf1e2cb0 280 buf[0] = 0xcd; _msgpack_store16(&buf[1], d);
hideakitai 0:3f9dbf1e2cb0 281 msgpack_pack_append_buffer(x, buf, 3);
hideakitai 0:3f9dbf1e2cb0 282 }
hideakitai 0:3f9dbf1e2cb0 283
hideakitai 0:3f9dbf1e2cb0 284 msgpack_pack_inline_func_fixint(_uint32)(msgpack_pack_user x, uint32_t d)
hideakitai 0:3f9dbf1e2cb0 285 {
hideakitai 0:3f9dbf1e2cb0 286 unsigned char buf[5];
hideakitai 0:3f9dbf1e2cb0 287 buf[0] = 0xce; _msgpack_store32(&buf[1], d);
hideakitai 0:3f9dbf1e2cb0 288 msgpack_pack_append_buffer(x, buf, 5);
hideakitai 0:3f9dbf1e2cb0 289 }
hideakitai 0:3f9dbf1e2cb0 290
hideakitai 0:3f9dbf1e2cb0 291 msgpack_pack_inline_func_fixint(_uint64)(msgpack_pack_user x, uint64_t d)
hideakitai 0:3f9dbf1e2cb0 292 {
hideakitai 0:3f9dbf1e2cb0 293 unsigned char buf[9];
hideakitai 0:3f9dbf1e2cb0 294 buf[0] = 0xcf; _msgpack_store64(&buf[1], d);
hideakitai 0:3f9dbf1e2cb0 295 msgpack_pack_append_buffer(x, buf, 9);
hideakitai 0:3f9dbf1e2cb0 296 }
hideakitai 0:3f9dbf1e2cb0 297
hideakitai 0:3f9dbf1e2cb0 298 msgpack_pack_inline_func_fixint(_int8)(msgpack_pack_user x, int8_t d)
hideakitai 0:3f9dbf1e2cb0 299 {
hideakitai 0:3f9dbf1e2cb0 300 unsigned char buf[2] = {0xd0, TAKE8_8(d)};
hideakitai 0:3f9dbf1e2cb0 301 msgpack_pack_append_buffer(x, buf, 2);
hideakitai 0:3f9dbf1e2cb0 302 }
hideakitai 0:3f9dbf1e2cb0 303
hideakitai 0:3f9dbf1e2cb0 304 msgpack_pack_inline_func_fixint(_int16)(msgpack_pack_user x, int16_t d)
hideakitai 0:3f9dbf1e2cb0 305 {
hideakitai 0:3f9dbf1e2cb0 306 unsigned char buf[3];
hideakitai 0:3f9dbf1e2cb0 307 buf[0] = 0xd1; _msgpack_store16(&buf[1], d);
hideakitai 0:3f9dbf1e2cb0 308 msgpack_pack_append_buffer(x, buf, 3);
hideakitai 0:3f9dbf1e2cb0 309 }
hideakitai 0:3f9dbf1e2cb0 310
hideakitai 0:3f9dbf1e2cb0 311 msgpack_pack_inline_func_fixint(_int32)(msgpack_pack_user x, int32_t d)
hideakitai 0:3f9dbf1e2cb0 312 {
hideakitai 0:3f9dbf1e2cb0 313 unsigned char buf[5];
hideakitai 0:3f9dbf1e2cb0 314 buf[0] = 0xd2; _msgpack_store32(&buf[1], d);
hideakitai 0:3f9dbf1e2cb0 315 msgpack_pack_append_buffer(x, buf, 5);
hideakitai 0:3f9dbf1e2cb0 316 }
hideakitai 0:3f9dbf1e2cb0 317
hideakitai 0:3f9dbf1e2cb0 318 msgpack_pack_inline_func_fixint(_int64)(msgpack_pack_user x, int64_t d)
hideakitai 0:3f9dbf1e2cb0 319 {
hideakitai 0:3f9dbf1e2cb0 320 unsigned char buf[9];
hideakitai 0:3f9dbf1e2cb0 321 buf[0] = 0xd3; _msgpack_store64(&buf[1], d);
hideakitai 0:3f9dbf1e2cb0 322 msgpack_pack_append_buffer(x, buf, 9);
hideakitai 0:3f9dbf1e2cb0 323 }
hideakitai 0:3f9dbf1e2cb0 324
hideakitai 0:3f9dbf1e2cb0 325 #undef msgpack_pack_inline_func_fixint
hideakitai 0:3f9dbf1e2cb0 326 #endif
hideakitai 0:3f9dbf1e2cb0 327
hideakitai 0:3f9dbf1e2cb0 328
hideakitai 0:3f9dbf1e2cb0 329 msgpack_pack_inline_func(_uint8)(msgpack_pack_user x, uint8_t d)
hideakitai 0:3f9dbf1e2cb0 330 {
hideakitai 0:3f9dbf1e2cb0 331 msgpack_pack_real_uint8(x, d);
hideakitai 0:3f9dbf1e2cb0 332 }
hideakitai 0:3f9dbf1e2cb0 333
hideakitai 0:3f9dbf1e2cb0 334 msgpack_pack_inline_func(_uint16)(msgpack_pack_user x, uint16_t d)
hideakitai 0:3f9dbf1e2cb0 335 {
hideakitai 0:3f9dbf1e2cb0 336 msgpack_pack_real_uint16(x, d);
hideakitai 0:3f9dbf1e2cb0 337 }
hideakitai 0:3f9dbf1e2cb0 338
hideakitai 0:3f9dbf1e2cb0 339 msgpack_pack_inline_func(_uint32)(msgpack_pack_user x, uint32_t d)
hideakitai 0:3f9dbf1e2cb0 340 {
hideakitai 0:3f9dbf1e2cb0 341 msgpack_pack_real_uint32(x, d);
hideakitai 0:3f9dbf1e2cb0 342 }
hideakitai 0:3f9dbf1e2cb0 343
hideakitai 0:3f9dbf1e2cb0 344 msgpack_pack_inline_func(_uint64)(msgpack_pack_user x, uint64_t d)
hideakitai 0:3f9dbf1e2cb0 345 {
hideakitai 0:3f9dbf1e2cb0 346 msgpack_pack_real_uint64(x, d);
hideakitai 0:3f9dbf1e2cb0 347 }
hideakitai 0:3f9dbf1e2cb0 348
hideakitai 0:3f9dbf1e2cb0 349 msgpack_pack_inline_func(_int8)(msgpack_pack_user x, int8_t d)
hideakitai 0:3f9dbf1e2cb0 350 {
hideakitai 0:3f9dbf1e2cb0 351 msgpack_pack_real_int8(x, d);
hideakitai 0:3f9dbf1e2cb0 352 }
hideakitai 0:3f9dbf1e2cb0 353
hideakitai 0:3f9dbf1e2cb0 354 msgpack_pack_inline_func(_int16)(msgpack_pack_user x, int16_t d)
hideakitai 0:3f9dbf1e2cb0 355 {
hideakitai 0:3f9dbf1e2cb0 356 msgpack_pack_real_int16(x, d);
hideakitai 0:3f9dbf1e2cb0 357 }
hideakitai 0:3f9dbf1e2cb0 358
hideakitai 0:3f9dbf1e2cb0 359 msgpack_pack_inline_func(_int32)(msgpack_pack_user x, int32_t d)
hideakitai 0:3f9dbf1e2cb0 360 {
hideakitai 0:3f9dbf1e2cb0 361 msgpack_pack_real_int32(x, d);
hideakitai 0:3f9dbf1e2cb0 362 }
hideakitai 0:3f9dbf1e2cb0 363
hideakitai 0:3f9dbf1e2cb0 364 msgpack_pack_inline_func(_int64)(msgpack_pack_user x, int64_t d)
hideakitai 0:3f9dbf1e2cb0 365 {
hideakitai 0:3f9dbf1e2cb0 366 msgpack_pack_real_int64(x, d);
hideakitai 0:3f9dbf1e2cb0 367 }
hideakitai 0:3f9dbf1e2cb0 368
hideakitai 0:3f9dbf1e2cb0 369 msgpack_pack_inline_func(_char)(msgpack_pack_user x, char d)
hideakitai 0:3f9dbf1e2cb0 370 {
hideakitai 0:3f9dbf1e2cb0 371 #if defined(CHAR_MIN)
hideakitai 0:3f9dbf1e2cb0 372 #if CHAR_MIN < 0
hideakitai 0:3f9dbf1e2cb0 373 msgpack_pack_real_int8(x, d);
hideakitai 0:3f9dbf1e2cb0 374 #else
hideakitai 0:3f9dbf1e2cb0 375 msgpack_pack_real_uint8(x, d);
hideakitai 0:3f9dbf1e2cb0 376 #endif
hideakitai 0:3f9dbf1e2cb0 377 #else
hideakitai 0:3f9dbf1e2cb0 378 #error CHAR_MIN is not defined
hideakitai 0:3f9dbf1e2cb0 379 #endif
hideakitai 0:3f9dbf1e2cb0 380 }
hideakitai 0:3f9dbf1e2cb0 381
hideakitai 0:3f9dbf1e2cb0 382 msgpack_pack_inline_func(_signed_char)(msgpack_pack_user x, signed char d)
hideakitai 0:3f9dbf1e2cb0 383 {
hideakitai 0:3f9dbf1e2cb0 384 msgpack_pack_real_int8(x, d);
hideakitai 0:3f9dbf1e2cb0 385 }
hideakitai 0:3f9dbf1e2cb0 386
hideakitai 0:3f9dbf1e2cb0 387 msgpack_pack_inline_func(_unsigned_char)(msgpack_pack_user x, unsigned char d)
hideakitai 0:3f9dbf1e2cb0 388 {
hideakitai 0:3f9dbf1e2cb0 389 msgpack_pack_real_uint8(x, d);
hideakitai 0:3f9dbf1e2cb0 390 }
hideakitai 0:3f9dbf1e2cb0 391
hideakitai 0:3f9dbf1e2cb0 392 #ifdef msgpack_pack_inline_func_cint
hideakitai 0:3f9dbf1e2cb0 393
hideakitai 0:3f9dbf1e2cb0 394 msgpack_pack_inline_func_cint(_short)(msgpack_pack_user x, short d)
hideakitai 0:3f9dbf1e2cb0 395 {
hideakitai 0:3f9dbf1e2cb0 396 #if defined(SIZEOF_SHORT)
hideakitai 0:3f9dbf1e2cb0 397 #if SIZEOF_SHORT == 2
hideakitai 0:3f9dbf1e2cb0 398 msgpack_pack_real_int16(x, d);
hideakitai 0:3f9dbf1e2cb0 399 #elif SIZEOF_SHORT == 4
hideakitai 0:3f9dbf1e2cb0 400 msgpack_pack_real_int32(x, d);
hideakitai 0:3f9dbf1e2cb0 401 #else
hideakitai 0:3f9dbf1e2cb0 402 msgpack_pack_real_int64(x, d);
hideakitai 0:3f9dbf1e2cb0 403 #endif
hideakitai 0:3f9dbf1e2cb0 404
hideakitai 0:3f9dbf1e2cb0 405 #elif defined(SHRT_MAX)
hideakitai 0:3f9dbf1e2cb0 406 #if SHRT_MAX == 0x7fff
hideakitai 0:3f9dbf1e2cb0 407 msgpack_pack_real_int16(x, d);
hideakitai 0:3f9dbf1e2cb0 408 #elif SHRT_MAX == 0x7fffffff
hideakitai 0:3f9dbf1e2cb0 409 msgpack_pack_real_int32(x, d);
hideakitai 0:3f9dbf1e2cb0 410 #else
hideakitai 0:3f9dbf1e2cb0 411 msgpack_pack_real_int64(x, d);
hideakitai 0:3f9dbf1e2cb0 412 #endif
hideakitai 0:3f9dbf1e2cb0 413
hideakitai 0:3f9dbf1e2cb0 414 #else
hideakitai 0:3f9dbf1e2cb0 415 if(sizeof(short) == 2) {
hideakitai 0:3f9dbf1e2cb0 416 msgpack_pack_real_int16(x, d);
hideakitai 0:3f9dbf1e2cb0 417 } else if(sizeof(short) == 4) {
hideakitai 0:3f9dbf1e2cb0 418 msgpack_pack_real_int32(x, d);
hideakitai 0:3f9dbf1e2cb0 419 } else {
hideakitai 0:3f9dbf1e2cb0 420 msgpack_pack_real_int64(x, d);
hideakitai 0:3f9dbf1e2cb0 421 }
hideakitai 0:3f9dbf1e2cb0 422 #endif
hideakitai 0:3f9dbf1e2cb0 423 }
hideakitai 0:3f9dbf1e2cb0 424
hideakitai 0:3f9dbf1e2cb0 425 msgpack_pack_inline_func_cint(_int)(msgpack_pack_user x, int d)
hideakitai 0:3f9dbf1e2cb0 426 {
hideakitai 0:3f9dbf1e2cb0 427 #if defined(SIZEOF_INT)
hideakitai 0:3f9dbf1e2cb0 428 #if SIZEOF_INT == 2
hideakitai 0:3f9dbf1e2cb0 429 msgpack_pack_real_int16(x, d);
hideakitai 0:3f9dbf1e2cb0 430 #elif SIZEOF_INT == 4
hideakitai 0:3f9dbf1e2cb0 431 msgpack_pack_real_int32(x, d);
hideakitai 0:3f9dbf1e2cb0 432 #else
hideakitai 0:3f9dbf1e2cb0 433 msgpack_pack_real_int64(x, d);
hideakitai 0:3f9dbf1e2cb0 434 #endif
hideakitai 0:3f9dbf1e2cb0 435
hideakitai 0:3f9dbf1e2cb0 436 #elif defined(INT_MAX)
hideakitai 0:3f9dbf1e2cb0 437 #if INT_MAX == 0x7fff
hideakitai 0:3f9dbf1e2cb0 438 msgpack_pack_real_int16(x, d);
hideakitai 0:3f9dbf1e2cb0 439 #elif INT_MAX == 0x7fffffff
hideakitai 0:3f9dbf1e2cb0 440 msgpack_pack_real_int32(x, d);
hideakitai 0:3f9dbf1e2cb0 441 #else
hideakitai 0:3f9dbf1e2cb0 442 msgpack_pack_real_int64(x, d);
hideakitai 0:3f9dbf1e2cb0 443 #endif
hideakitai 0:3f9dbf1e2cb0 444
hideakitai 0:3f9dbf1e2cb0 445 #else
hideakitai 0:3f9dbf1e2cb0 446 if(sizeof(int) == 2) {
hideakitai 0:3f9dbf1e2cb0 447 msgpack_pack_real_int16(x, d);
hideakitai 0:3f9dbf1e2cb0 448 } else if(sizeof(int) == 4) {
hideakitai 0:3f9dbf1e2cb0 449 msgpack_pack_real_int32(x, d);
hideakitai 0:3f9dbf1e2cb0 450 } else {
hideakitai 0:3f9dbf1e2cb0 451 msgpack_pack_real_int64(x, d);
hideakitai 0:3f9dbf1e2cb0 452 }
hideakitai 0:3f9dbf1e2cb0 453 #endif
hideakitai 0:3f9dbf1e2cb0 454 }
hideakitai 0:3f9dbf1e2cb0 455
hideakitai 0:3f9dbf1e2cb0 456 msgpack_pack_inline_func_cint(_long)(msgpack_pack_user x, long d)
hideakitai 0:3f9dbf1e2cb0 457 {
hideakitai 0:3f9dbf1e2cb0 458 #if defined(SIZEOF_LONG)
hideakitai 0:3f9dbf1e2cb0 459 #if SIZEOF_LONG == 2
hideakitai 0:3f9dbf1e2cb0 460 msgpack_pack_real_int16(x, d);
hideakitai 0:3f9dbf1e2cb0 461 #elif SIZEOF_LONG == 4
hideakitai 0:3f9dbf1e2cb0 462 msgpack_pack_real_int32(x, d);
hideakitai 0:3f9dbf1e2cb0 463 #else
hideakitai 0:3f9dbf1e2cb0 464 msgpack_pack_real_int64(x, d);
hideakitai 0:3f9dbf1e2cb0 465 #endif
hideakitai 0:3f9dbf1e2cb0 466
hideakitai 0:3f9dbf1e2cb0 467 #elif defined(LONG_MAX)
hideakitai 0:3f9dbf1e2cb0 468 #if LONG_MAX == 0x7fffL
hideakitai 0:3f9dbf1e2cb0 469 msgpack_pack_real_int16(x, d);
hideakitai 0:3f9dbf1e2cb0 470 #elif LONG_MAX == 0x7fffffffL
hideakitai 0:3f9dbf1e2cb0 471 msgpack_pack_real_int32(x, d);
hideakitai 0:3f9dbf1e2cb0 472 #else
hideakitai 0:3f9dbf1e2cb0 473 msgpack_pack_real_int64(x, d);
hideakitai 0:3f9dbf1e2cb0 474 #endif
hideakitai 0:3f9dbf1e2cb0 475
hideakitai 0:3f9dbf1e2cb0 476 #else
hideakitai 0:3f9dbf1e2cb0 477 if(sizeof(long) == 2) {
hideakitai 0:3f9dbf1e2cb0 478 msgpack_pack_real_int16(x, d);
hideakitai 0:3f9dbf1e2cb0 479 } else if(sizeof(long) == 4) {
hideakitai 0:3f9dbf1e2cb0 480 msgpack_pack_real_int32(x, d);
hideakitai 0:3f9dbf1e2cb0 481 } else {
hideakitai 0:3f9dbf1e2cb0 482 msgpack_pack_real_int64(x, d);
hideakitai 0:3f9dbf1e2cb0 483 }
hideakitai 0:3f9dbf1e2cb0 484 #endif
hideakitai 0:3f9dbf1e2cb0 485 }
hideakitai 0:3f9dbf1e2cb0 486
hideakitai 0:3f9dbf1e2cb0 487 msgpack_pack_inline_func_cint(_long_long)(msgpack_pack_user x, long long d)
hideakitai 0:3f9dbf1e2cb0 488 {
hideakitai 0:3f9dbf1e2cb0 489 #if defined(SIZEOF_LONG_LONG)
hideakitai 0:3f9dbf1e2cb0 490 #if SIZEOF_LONG_LONG == 2
hideakitai 0:3f9dbf1e2cb0 491 msgpack_pack_real_int16(x, d);
hideakitai 0:3f9dbf1e2cb0 492 #elif SIZEOF_LONG_LONG == 4
hideakitai 0:3f9dbf1e2cb0 493 msgpack_pack_real_int32(x, d);
hideakitai 0:3f9dbf1e2cb0 494 #else
hideakitai 0:3f9dbf1e2cb0 495 msgpack_pack_real_int64(x, d);
hideakitai 0:3f9dbf1e2cb0 496 #endif
hideakitai 0:3f9dbf1e2cb0 497
hideakitai 0:3f9dbf1e2cb0 498 #elif defined(LLONG_MAX)
hideakitai 0:3f9dbf1e2cb0 499 #if LLONG_MAX == 0x7fffL
hideakitai 0:3f9dbf1e2cb0 500 msgpack_pack_real_int16(x, d);
hideakitai 0:3f9dbf1e2cb0 501 #elif LLONG_MAX == 0x7fffffffL
hideakitai 0:3f9dbf1e2cb0 502 msgpack_pack_real_int32(x, d);
hideakitai 0:3f9dbf1e2cb0 503 #else
hideakitai 0:3f9dbf1e2cb0 504 msgpack_pack_real_int64(x, d);
hideakitai 0:3f9dbf1e2cb0 505 #endif
hideakitai 0:3f9dbf1e2cb0 506
hideakitai 0:3f9dbf1e2cb0 507 #else
hideakitai 0:3f9dbf1e2cb0 508 if(sizeof(long long) == 2) {
hideakitai 0:3f9dbf1e2cb0 509 msgpack_pack_real_int16(x, d);
hideakitai 0:3f9dbf1e2cb0 510 } else if(sizeof(long long) == 4) {
hideakitai 0:3f9dbf1e2cb0 511 msgpack_pack_real_int32(x, d);
hideakitai 0:3f9dbf1e2cb0 512 } else {
hideakitai 0:3f9dbf1e2cb0 513 msgpack_pack_real_int64(x, d);
hideakitai 0:3f9dbf1e2cb0 514 }
hideakitai 0:3f9dbf1e2cb0 515 #endif
hideakitai 0:3f9dbf1e2cb0 516 }
hideakitai 0:3f9dbf1e2cb0 517
hideakitai 0:3f9dbf1e2cb0 518 msgpack_pack_inline_func_cint(_unsigned_short)(msgpack_pack_user x, unsigned short d)
hideakitai 0:3f9dbf1e2cb0 519 {
hideakitai 0:3f9dbf1e2cb0 520 #if defined(SIZEOF_SHORT)
hideakitai 0:3f9dbf1e2cb0 521 #if SIZEOF_SHORT == 2
hideakitai 0:3f9dbf1e2cb0 522 msgpack_pack_real_uint16(x, d);
hideakitai 0:3f9dbf1e2cb0 523 #elif SIZEOF_SHORT == 4
hideakitai 0:3f9dbf1e2cb0 524 msgpack_pack_real_uint32(x, d);
hideakitai 0:3f9dbf1e2cb0 525 #else
hideakitai 0:3f9dbf1e2cb0 526 msgpack_pack_real_uint64(x, d);
hideakitai 0:3f9dbf1e2cb0 527 #endif
hideakitai 0:3f9dbf1e2cb0 528
hideakitai 0:3f9dbf1e2cb0 529 #elif defined(USHRT_MAX)
hideakitai 0:3f9dbf1e2cb0 530 #if USHRT_MAX == 0xffffU
hideakitai 0:3f9dbf1e2cb0 531 msgpack_pack_real_uint16(x, d);
hideakitai 0:3f9dbf1e2cb0 532 #elif USHRT_MAX == 0xffffffffU
hideakitai 0:3f9dbf1e2cb0 533 msgpack_pack_real_uint32(x, d);
hideakitai 0:3f9dbf1e2cb0 534 #else
hideakitai 0:3f9dbf1e2cb0 535 msgpack_pack_real_uint64(x, d);
hideakitai 0:3f9dbf1e2cb0 536 #endif
hideakitai 0:3f9dbf1e2cb0 537
hideakitai 0:3f9dbf1e2cb0 538 #else
hideakitai 0:3f9dbf1e2cb0 539 if(sizeof(unsigned short) == 2) {
hideakitai 0:3f9dbf1e2cb0 540 msgpack_pack_real_uint16(x, d);
hideakitai 0:3f9dbf1e2cb0 541 } else if(sizeof(unsigned short) == 4) {
hideakitai 0:3f9dbf1e2cb0 542 msgpack_pack_real_uint32(x, d);
hideakitai 0:3f9dbf1e2cb0 543 } else {
hideakitai 0:3f9dbf1e2cb0 544 msgpack_pack_real_uint64(x, d);
hideakitai 0:3f9dbf1e2cb0 545 }
hideakitai 0:3f9dbf1e2cb0 546 #endif
hideakitai 0:3f9dbf1e2cb0 547 }
hideakitai 0:3f9dbf1e2cb0 548
hideakitai 0:3f9dbf1e2cb0 549 msgpack_pack_inline_func_cint(_unsigned_int)(msgpack_pack_user x, unsigned int d)
hideakitai 0:3f9dbf1e2cb0 550 {
hideakitai 0:3f9dbf1e2cb0 551 #if defined(SIZEOF_INT)
hideakitai 0:3f9dbf1e2cb0 552 #if SIZEOF_INT == 2
hideakitai 0:3f9dbf1e2cb0 553 msgpack_pack_real_uint16(x, d);
hideakitai 0:3f9dbf1e2cb0 554 #elif SIZEOF_INT == 4
hideakitai 0:3f9dbf1e2cb0 555 msgpack_pack_real_uint32(x, d);
hideakitai 0:3f9dbf1e2cb0 556 #else
hideakitai 0:3f9dbf1e2cb0 557 msgpack_pack_real_uint64(x, d);
hideakitai 0:3f9dbf1e2cb0 558 #endif
hideakitai 0:3f9dbf1e2cb0 559
hideakitai 0:3f9dbf1e2cb0 560 #elif defined(UINT_MAX)
hideakitai 0:3f9dbf1e2cb0 561 #if UINT_MAX == 0xffffU
hideakitai 0:3f9dbf1e2cb0 562 msgpack_pack_real_uint16(x, d);
hideakitai 0:3f9dbf1e2cb0 563 #elif UINT_MAX == 0xffffffffU
hideakitai 0:3f9dbf1e2cb0 564 msgpack_pack_real_uint32(x, d);
hideakitai 0:3f9dbf1e2cb0 565 #else
hideakitai 0:3f9dbf1e2cb0 566 msgpack_pack_real_uint64(x, d);
hideakitai 0:3f9dbf1e2cb0 567 #endif
hideakitai 0:3f9dbf1e2cb0 568
hideakitai 0:3f9dbf1e2cb0 569 #else
hideakitai 0:3f9dbf1e2cb0 570 if(sizeof(unsigned int) == 2) {
hideakitai 0:3f9dbf1e2cb0 571 msgpack_pack_real_uint16(x, d);
hideakitai 0:3f9dbf1e2cb0 572 } else if(sizeof(unsigned int) == 4) {
hideakitai 0:3f9dbf1e2cb0 573 msgpack_pack_real_uint32(x, d);
hideakitai 0:3f9dbf1e2cb0 574 } else {
hideakitai 0:3f9dbf1e2cb0 575 msgpack_pack_real_uint64(x, d);
hideakitai 0:3f9dbf1e2cb0 576 }
hideakitai 0:3f9dbf1e2cb0 577 #endif
hideakitai 0:3f9dbf1e2cb0 578 }
hideakitai 0:3f9dbf1e2cb0 579
hideakitai 0:3f9dbf1e2cb0 580 msgpack_pack_inline_func_cint(_unsigned_long)(msgpack_pack_user x, unsigned long d)
hideakitai 0:3f9dbf1e2cb0 581 {
hideakitai 0:3f9dbf1e2cb0 582 #if defined(SIZEOF_LONG)
hideakitai 0:3f9dbf1e2cb0 583 #if SIZEOF_LONG == 2
hideakitai 0:3f9dbf1e2cb0 584 msgpack_pack_real_uint16(x, d);
hideakitai 0:3f9dbf1e2cb0 585 #elif SIZEOF_LONG == 4
hideakitai 0:3f9dbf1e2cb0 586 msgpack_pack_real_uint32(x, d);
hideakitai 0:3f9dbf1e2cb0 587 #else
hideakitai 0:3f9dbf1e2cb0 588 msgpack_pack_real_uint64(x, d);
hideakitai 0:3f9dbf1e2cb0 589 #endif
hideakitai 0:3f9dbf1e2cb0 590
hideakitai 0:3f9dbf1e2cb0 591 #elif defined(ULONG_MAX)
hideakitai 0:3f9dbf1e2cb0 592 #if ULONG_MAX == 0xffffUL
hideakitai 0:3f9dbf1e2cb0 593 msgpack_pack_real_uint16(x, d);
hideakitai 0:3f9dbf1e2cb0 594 #elif ULONG_MAX == 0xffffffffUL
hideakitai 0:3f9dbf1e2cb0 595 msgpack_pack_real_uint32(x, d);
hideakitai 0:3f9dbf1e2cb0 596 #else
hideakitai 0:3f9dbf1e2cb0 597 msgpack_pack_real_uint64(x, d);
hideakitai 0:3f9dbf1e2cb0 598 #endif
hideakitai 0:3f9dbf1e2cb0 599
hideakitai 0:3f9dbf1e2cb0 600 #else
hideakitai 0:3f9dbf1e2cb0 601 if(sizeof(unsigned long) == 2) {
hideakitai 0:3f9dbf1e2cb0 602 msgpack_pack_real_uint16(x, d);
hideakitai 0:3f9dbf1e2cb0 603 } else if(sizeof(unsigned long) == 4) {
hideakitai 0:3f9dbf1e2cb0 604 msgpack_pack_real_uint32(x, d);
hideakitai 0:3f9dbf1e2cb0 605 } else {
hideakitai 0:3f9dbf1e2cb0 606 msgpack_pack_real_uint64(x, d);
hideakitai 0:3f9dbf1e2cb0 607 }
hideakitai 0:3f9dbf1e2cb0 608 #endif
hideakitai 0:3f9dbf1e2cb0 609 }
hideakitai 0:3f9dbf1e2cb0 610
hideakitai 0:3f9dbf1e2cb0 611 msgpack_pack_inline_func_cint(_unsigned_long_long)(msgpack_pack_user x, unsigned long long d)
hideakitai 0:3f9dbf1e2cb0 612 {
hideakitai 0:3f9dbf1e2cb0 613 #if defined(SIZEOF_LONG_LONG)
hideakitai 0:3f9dbf1e2cb0 614 #if SIZEOF_LONG_LONG == 2
hideakitai 0:3f9dbf1e2cb0 615 msgpack_pack_real_uint16(x, d);
hideakitai 0:3f9dbf1e2cb0 616 #elif SIZEOF_LONG_LONG == 4
hideakitai 0:3f9dbf1e2cb0 617 msgpack_pack_real_uint32(x, d);
hideakitai 0:3f9dbf1e2cb0 618 #else
hideakitai 0:3f9dbf1e2cb0 619 msgpack_pack_real_uint64(x, d);
hideakitai 0:3f9dbf1e2cb0 620 #endif
hideakitai 0:3f9dbf1e2cb0 621
hideakitai 0:3f9dbf1e2cb0 622 #elif defined(ULLONG_MAX)
hideakitai 0:3f9dbf1e2cb0 623 #if ULLONG_MAX == 0xffffUL
hideakitai 0:3f9dbf1e2cb0 624 msgpack_pack_real_uint16(x, d);
hideakitai 0:3f9dbf1e2cb0 625 #elif ULLONG_MAX == 0xffffffffUL
hideakitai 0:3f9dbf1e2cb0 626 msgpack_pack_real_uint32(x, d);
hideakitai 0:3f9dbf1e2cb0 627 #else
hideakitai 0:3f9dbf1e2cb0 628 msgpack_pack_real_uint64(x, d);
hideakitai 0:3f9dbf1e2cb0 629 #endif
hideakitai 0:3f9dbf1e2cb0 630
hideakitai 0:3f9dbf1e2cb0 631 #else
hideakitai 0:3f9dbf1e2cb0 632 if(sizeof(unsigned long long) == 2) {
hideakitai 0:3f9dbf1e2cb0 633 msgpack_pack_real_uint16(x, d);
hideakitai 0:3f9dbf1e2cb0 634 } else if(sizeof(unsigned long long) == 4) {
hideakitai 0:3f9dbf1e2cb0 635 msgpack_pack_real_uint32(x, d);
hideakitai 0:3f9dbf1e2cb0 636 } else {
hideakitai 0:3f9dbf1e2cb0 637 msgpack_pack_real_uint64(x, d);
hideakitai 0:3f9dbf1e2cb0 638 }
hideakitai 0:3f9dbf1e2cb0 639 #endif
hideakitai 0:3f9dbf1e2cb0 640 }
hideakitai 0:3f9dbf1e2cb0 641
hideakitai 0:3f9dbf1e2cb0 642 #undef msgpack_pack_inline_func_cint
hideakitai 0:3f9dbf1e2cb0 643 #endif
hideakitai 0:3f9dbf1e2cb0 644
hideakitai 0:3f9dbf1e2cb0 645
hideakitai 0:3f9dbf1e2cb0 646
hideakitai 0:3f9dbf1e2cb0 647 /*
hideakitai 0:3f9dbf1e2cb0 648 * Float
hideakitai 0:3f9dbf1e2cb0 649 */
hideakitai 0:3f9dbf1e2cb0 650
hideakitai 0:3f9dbf1e2cb0 651 msgpack_pack_inline_func(_float)(msgpack_pack_user x, float d)
hideakitai 0:3f9dbf1e2cb0 652 {
hideakitai 0:3f9dbf1e2cb0 653 unsigned char buf[5];
hideakitai 0:3f9dbf1e2cb0 654 union { float f; uint32_t i; } mem;
hideakitai 0:3f9dbf1e2cb0 655 mem.f = d;
hideakitai 0:3f9dbf1e2cb0 656 buf[0] = 0xca; _msgpack_store32(&buf[1], mem.i);
hideakitai 0:3f9dbf1e2cb0 657 msgpack_pack_append_buffer(x, buf, 5);
hideakitai 0:3f9dbf1e2cb0 658 }
hideakitai 0:3f9dbf1e2cb0 659
hideakitai 0:3f9dbf1e2cb0 660 msgpack_pack_inline_func(_double)(msgpack_pack_user x, double d)
hideakitai 0:3f9dbf1e2cb0 661 {
hideakitai 0:3f9dbf1e2cb0 662 unsigned char buf[9];
hideakitai 0:3f9dbf1e2cb0 663 union { double f; uint64_t i; } mem;
hideakitai 0:3f9dbf1e2cb0 664 mem.f = d;
hideakitai 0:3f9dbf1e2cb0 665 buf[0] = 0xcb;
hideakitai 0:3f9dbf1e2cb0 666 #if defined(TARGET_OS_IPHONE)
hideakitai 0:3f9dbf1e2cb0 667 // ok
hideakitai 0:3f9dbf1e2cb0 668 #elif defined(__arm__) && !(__ARM_EABI__) // arm-oabi
hideakitai 0:3f9dbf1e2cb0 669 // https://github.com/msgpack/msgpack-perl/pull/1
hideakitai 0:3f9dbf1e2cb0 670 mem.i = (mem.i & 0xFFFFFFFFUL) << 32UL | (mem.i >> 32UL);
hideakitai 0:3f9dbf1e2cb0 671 #endif
hideakitai 0:3f9dbf1e2cb0 672 _msgpack_store64(&buf[1], mem.i);
hideakitai 0:3f9dbf1e2cb0 673 msgpack_pack_append_buffer(x, buf, 9);
hideakitai 0:3f9dbf1e2cb0 674 }
hideakitai 0:3f9dbf1e2cb0 675
hideakitai 0:3f9dbf1e2cb0 676
hideakitai 0:3f9dbf1e2cb0 677 /*
hideakitai 0:3f9dbf1e2cb0 678 * Nil
hideakitai 0:3f9dbf1e2cb0 679 */
hideakitai 0:3f9dbf1e2cb0 680
hideakitai 0:3f9dbf1e2cb0 681 msgpack_pack_inline_func(_nil)(msgpack_pack_user x)
hideakitai 0:3f9dbf1e2cb0 682 {
hideakitai 0:3f9dbf1e2cb0 683 static const unsigned char d = 0xc0;
hideakitai 0:3f9dbf1e2cb0 684 msgpack_pack_append_buffer(x, &d, 1);
hideakitai 0:3f9dbf1e2cb0 685 }
hideakitai 0:3f9dbf1e2cb0 686
hideakitai 0:3f9dbf1e2cb0 687
hideakitai 0:3f9dbf1e2cb0 688 /*
hideakitai 0:3f9dbf1e2cb0 689 * Boolean
hideakitai 0:3f9dbf1e2cb0 690 */
hideakitai 0:3f9dbf1e2cb0 691
hideakitai 0:3f9dbf1e2cb0 692 msgpack_pack_inline_func(_true)(msgpack_pack_user x)
hideakitai 0:3f9dbf1e2cb0 693 {
hideakitai 0:3f9dbf1e2cb0 694 static const unsigned char d = 0xc3;
hideakitai 0:3f9dbf1e2cb0 695 msgpack_pack_append_buffer(x, &d, 1);
hideakitai 0:3f9dbf1e2cb0 696 }
hideakitai 0:3f9dbf1e2cb0 697
hideakitai 0:3f9dbf1e2cb0 698 msgpack_pack_inline_func(_false)(msgpack_pack_user x)
hideakitai 0:3f9dbf1e2cb0 699 {
hideakitai 0:3f9dbf1e2cb0 700 static const unsigned char d = 0xc2;
hideakitai 0:3f9dbf1e2cb0 701 msgpack_pack_append_buffer(x, &d, 1);
hideakitai 0:3f9dbf1e2cb0 702 }
hideakitai 0:3f9dbf1e2cb0 703
hideakitai 0:3f9dbf1e2cb0 704
hideakitai 0:3f9dbf1e2cb0 705 /*
hideakitai 0:3f9dbf1e2cb0 706 * Array
hideakitai 0:3f9dbf1e2cb0 707 */
hideakitai 0:3f9dbf1e2cb0 708
hideakitai 0:3f9dbf1e2cb0 709 msgpack_pack_inline_func(_array)(msgpack_pack_user x, size_t n)
hideakitai 0:3f9dbf1e2cb0 710 {
hideakitai 0:3f9dbf1e2cb0 711 if(n < 16) {
hideakitai 0:3f9dbf1e2cb0 712 unsigned char d = 0x90 | (uint8_t)n;
hideakitai 0:3f9dbf1e2cb0 713 msgpack_pack_append_buffer(x, &d, 1);
hideakitai 0:3f9dbf1e2cb0 714 } else if(n < 65536) {
hideakitai 0:3f9dbf1e2cb0 715 unsigned char buf[3];
hideakitai 0:3f9dbf1e2cb0 716 buf[0] = 0xdc; _msgpack_store16(&buf[1], (uint16_t)n);
hideakitai 0:3f9dbf1e2cb0 717 msgpack_pack_append_buffer(x, buf, 3);
hideakitai 0:3f9dbf1e2cb0 718 } else {
hideakitai 0:3f9dbf1e2cb0 719 unsigned char buf[5];
hideakitai 0:3f9dbf1e2cb0 720 buf[0] = 0xdd; _msgpack_store32(&buf[1], (uint32_t)n);
hideakitai 0:3f9dbf1e2cb0 721 msgpack_pack_append_buffer(x, buf, 5);
hideakitai 0:3f9dbf1e2cb0 722 }
hideakitai 0:3f9dbf1e2cb0 723 }
hideakitai 0:3f9dbf1e2cb0 724
hideakitai 0:3f9dbf1e2cb0 725
hideakitai 0:3f9dbf1e2cb0 726 /*
hideakitai 0:3f9dbf1e2cb0 727 * Map
hideakitai 0:3f9dbf1e2cb0 728 */
hideakitai 0:3f9dbf1e2cb0 729
hideakitai 0:3f9dbf1e2cb0 730 msgpack_pack_inline_func(_map)(msgpack_pack_user x, size_t n)
hideakitai 0:3f9dbf1e2cb0 731 {
hideakitai 0:3f9dbf1e2cb0 732 if(n < 16) {
hideakitai 0:3f9dbf1e2cb0 733 unsigned char d = 0x80 | (uint8_t)n;
hideakitai 0:3f9dbf1e2cb0 734 msgpack_pack_append_buffer(x, &TAKE8_8(d), 1);
hideakitai 0:3f9dbf1e2cb0 735 } else if(n < 65536) {
hideakitai 0:3f9dbf1e2cb0 736 unsigned char buf[3];
hideakitai 0:3f9dbf1e2cb0 737 buf[0] = 0xde; _msgpack_store16(&buf[1], (uint16_t)n);
hideakitai 0:3f9dbf1e2cb0 738 msgpack_pack_append_buffer(x, buf, 3);
hideakitai 0:3f9dbf1e2cb0 739 } else {
hideakitai 0:3f9dbf1e2cb0 740 unsigned char buf[5];
hideakitai 0:3f9dbf1e2cb0 741 buf[0] = 0xdf; _msgpack_store32(&buf[1], (uint32_t)n);
hideakitai 0:3f9dbf1e2cb0 742 msgpack_pack_append_buffer(x, buf, 5);
hideakitai 0:3f9dbf1e2cb0 743 }
hideakitai 0:3f9dbf1e2cb0 744 }
hideakitai 0:3f9dbf1e2cb0 745
hideakitai 0:3f9dbf1e2cb0 746
hideakitai 0:3f9dbf1e2cb0 747 /*
hideakitai 0:3f9dbf1e2cb0 748 * Str
hideakitai 0:3f9dbf1e2cb0 749 */
hideakitai 0:3f9dbf1e2cb0 750
hideakitai 0:3f9dbf1e2cb0 751 msgpack_pack_inline_func(_str)(msgpack_pack_user x, size_t l)
hideakitai 0:3f9dbf1e2cb0 752 {
hideakitai 0:3f9dbf1e2cb0 753 if(l < 32) {
hideakitai 0:3f9dbf1e2cb0 754 unsigned char d = 0xa0 | (uint8_t)l;
hideakitai 0:3f9dbf1e2cb0 755 msgpack_pack_append_buffer(x, &TAKE8_8(d), 1);
hideakitai 0:3f9dbf1e2cb0 756 } else if(l < 256) {
hideakitai 0:3f9dbf1e2cb0 757 unsigned char buf[2];
hideakitai 0:3f9dbf1e2cb0 758 buf[0] = 0xd9; buf[1] = (uint8_t)l;
hideakitai 0:3f9dbf1e2cb0 759 msgpack_pack_append_buffer(x, buf, 2);
hideakitai 0:3f9dbf1e2cb0 760 } else if(l < 65536) {
hideakitai 0:3f9dbf1e2cb0 761 unsigned char buf[3];
hideakitai 0:3f9dbf1e2cb0 762 buf[0] = 0xda; _msgpack_store16(&buf[1], (uint16_t)l);
hideakitai 0:3f9dbf1e2cb0 763 msgpack_pack_append_buffer(x, buf, 3);
hideakitai 0:3f9dbf1e2cb0 764 } else {
hideakitai 0:3f9dbf1e2cb0 765 unsigned char buf[5];
hideakitai 0:3f9dbf1e2cb0 766 buf[0] = 0xdb; _msgpack_store32(&buf[1], (uint32_t)l);
hideakitai 0:3f9dbf1e2cb0 767 msgpack_pack_append_buffer(x, buf, 5);
hideakitai 0:3f9dbf1e2cb0 768 }
hideakitai 0:3f9dbf1e2cb0 769 }
hideakitai 0:3f9dbf1e2cb0 770
hideakitai 0:3f9dbf1e2cb0 771 msgpack_pack_inline_func(_str_body)(msgpack_pack_user x, const void* b, size_t l)
hideakitai 0:3f9dbf1e2cb0 772 {
hideakitai 0:3f9dbf1e2cb0 773 msgpack_pack_append_buffer(x, (const unsigned char*)b, l);
hideakitai 0:3f9dbf1e2cb0 774 }
hideakitai 0:3f9dbf1e2cb0 775
hideakitai 0:3f9dbf1e2cb0 776 /*
hideakitai 0:3f9dbf1e2cb0 777 * Raw (V4)
hideakitai 0:3f9dbf1e2cb0 778 */
hideakitai 0:3f9dbf1e2cb0 779
hideakitai 0:3f9dbf1e2cb0 780 msgpack_pack_inline_func(_v4raw)(msgpack_pack_user x, size_t l)
hideakitai 0:3f9dbf1e2cb0 781 {
hideakitai 0:3f9dbf1e2cb0 782 if(l < 32) {
hideakitai 0:3f9dbf1e2cb0 783 unsigned char d = 0xa0 | (uint8_t)l;
hideakitai 0:3f9dbf1e2cb0 784 msgpack_pack_append_buffer(x, &TAKE8_8(d), 1);
hideakitai 0:3f9dbf1e2cb0 785 } else if(l < 65536) {
hideakitai 0:3f9dbf1e2cb0 786 unsigned char buf[3];
hideakitai 0:3f9dbf1e2cb0 787 buf[0] = 0xda; _msgpack_store16(&buf[1], (uint16_t)l);
hideakitai 0:3f9dbf1e2cb0 788 msgpack_pack_append_buffer(x, buf, 3);
hideakitai 0:3f9dbf1e2cb0 789 } else {
hideakitai 0:3f9dbf1e2cb0 790 unsigned char buf[5];
hideakitai 0:3f9dbf1e2cb0 791 buf[0] = 0xdb; _msgpack_store32(&buf[1], (uint32_t)l);
hideakitai 0:3f9dbf1e2cb0 792 msgpack_pack_append_buffer(x, buf, 5);
hideakitai 0:3f9dbf1e2cb0 793 }
hideakitai 0:3f9dbf1e2cb0 794 }
hideakitai 0:3f9dbf1e2cb0 795
hideakitai 0:3f9dbf1e2cb0 796 msgpack_pack_inline_func(_v4raw_body)(msgpack_pack_user x, const void* b, size_t l)
hideakitai 0:3f9dbf1e2cb0 797 {
hideakitai 0:3f9dbf1e2cb0 798 msgpack_pack_append_buffer(x, (const unsigned char*)b, l);
hideakitai 0:3f9dbf1e2cb0 799 }
hideakitai 0:3f9dbf1e2cb0 800
hideakitai 0:3f9dbf1e2cb0 801 /*
hideakitai 0:3f9dbf1e2cb0 802 * Bin
hideakitai 0:3f9dbf1e2cb0 803 */
hideakitai 0:3f9dbf1e2cb0 804
hideakitai 0:3f9dbf1e2cb0 805 msgpack_pack_inline_func(_bin)(msgpack_pack_user x, size_t l)
hideakitai 0:3f9dbf1e2cb0 806 {
hideakitai 0:3f9dbf1e2cb0 807 if(l < 256) {
hideakitai 0:3f9dbf1e2cb0 808 unsigned char buf[2];
hideakitai 0:3f9dbf1e2cb0 809 buf[0] = 0xc4; buf[1] = (uint8_t)l;
hideakitai 0:3f9dbf1e2cb0 810 msgpack_pack_append_buffer(x, buf, 2);
hideakitai 0:3f9dbf1e2cb0 811 } else if(l < 65536) {
hideakitai 0:3f9dbf1e2cb0 812 unsigned char buf[3];
hideakitai 0:3f9dbf1e2cb0 813 buf[0] = 0xc5; _msgpack_store16(&buf[1], (uint16_t)l);
hideakitai 0:3f9dbf1e2cb0 814 msgpack_pack_append_buffer(x, buf, 3);
hideakitai 0:3f9dbf1e2cb0 815 } else {
hideakitai 0:3f9dbf1e2cb0 816 unsigned char buf[5];
hideakitai 0:3f9dbf1e2cb0 817 buf[0] = 0xc6; _msgpack_store32(&buf[1], (uint32_t)l);
hideakitai 0:3f9dbf1e2cb0 818 msgpack_pack_append_buffer(x, buf, 5);
hideakitai 0:3f9dbf1e2cb0 819 }
hideakitai 0:3f9dbf1e2cb0 820 }
hideakitai 0:3f9dbf1e2cb0 821
hideakitai 0:3f9dbf1e2cb0 822 msgpack_pack_inline_func(_bin_body)(msgpack_pack_user x, const void* b, size_t l)
hideakitai 0:3f9dbf1e2cb0 823 {
hideakitai 0:3f9dbf1e2cb0 824 msgpack_pack_append_buffer(x, (const unsigned char*)b, l);
hideakitai 0:3f9dbf1e2cb0 825 }
hideakitai 0:3f9dbf1e2cb0 826
hideakitai 0:3f9dbf1e2cb0 827 /*
hideakitai 0:3f9dbf1e2cb0 828 * Ext
hideakitai 0:3f9dbf1e2cb0 829 */
hideakitai 0:3f9dbf1e2cb0 830
hideakitai 0:3f9dbf1e2cb0 831 msgpack_pack_inline_func(_ext)(msgpack_pack_user x, size_t l, int8_t type)
hideakitai 0:3f9dbf1e2cb0 832 {
hideakitai 0:3f9dbf1e2cb0 833 switch(l) {
hideakitai 0:3f9dbf1e2cb0 834 case 1: {
hideakitai 0:3f9dbf1e2cb0 835 unsigned char buf[2];
hideakitai 0:3f9dbf1e2cb0 836 buf[0] = 0xd4;
hideakitai 0:3f9dbf1e2cb0 837 buf[1] = type;
hideakitai 0:3f9dbf1e2cb0 838 msgpack_pack_append_buffer(x, buf, 2);
hideakitai 0:3f9dbf1e2cb0 839 } break;
hideakitai 0:3f9dbf1e2cb0 840 case 2: {
hideakitai 0:3f9dbf1e2cb0 841 unsigned char buf[2];
hideakitai 0:3f9dbf1e2cb0 842 buf[0] = 0xd5;
hideakitai 0:3f9dbf1e2cb0 843 buf[1] = type;
hideakitai 0:3f9dbf1e2cb0 844 msgpack_pack_append_buffer(x, buf, 2);
hideakitai 0:3f9dbf1e2cb0 845 } break;
hideakitai 0:3f9dbf1e2cb0 846 case 4: {
hideakitai 0:3f9dbf1e2cb0 847 unsigned char buf[2];
hideakitai 0:3f9dbf1e2cb0 848 buf[0] = 0xd6;
hideakitai 0:3f9dbf1e2cb0 849 buf[1] = type;
hideakitai 0:3f9dbf1e2cb0 850 msgpack_pack_append_buffer(x, buf, 2);
hideakitai 0:3f9dbf1e2cb0 851 } break;
hideakitai 0:3f9dbf1e2cb0 852 case 8: {
hideakitai 0:3f9dbf1e2cb0 853 unsigned char buf[2];
hideakitai 0:3f9dbf1e2cb0 854 buf[0] = 0xd7;
hideakitai 0:3f9dbf1e2cb0 855 buf[1] = type;
hideakitai 0:3f9dbf1e2cb0 856 msgpack_pack_append_buffer(x, buf, 2);
hideakitai 0:3f9dbf1e2cb0 857 } break;
hideakitai 0:3f9dbf1e2cb0 858 case 16: {
hideakitai 0:3f9dbf1e2cb0 859 unsigned char buf[2];
hideakitai 0:3f9dbf1e2cb0 860 buf[0] = 0xd8;
hideakitai 0:3f9dbf1e2cb0 861 buf[1] = type;
hideakitai 0:3f9dbf1e2cb0 862 msgpack_pack_append_buffer(x, buf, 2);
hideakitai 0:3f9dbf1e2cb0 863 } break;
hideakitai 0:3f9dbf1e2cb0 864 default:
hideakitai 0:3f9dbf1e2cb0 865 if(l < 256) {
hideakitai 0:3f9dbf1e2cb0 866 unsigned char buf[3];
hideakitai 0:3f9dbf1e2cb0 867 buf[0] = 0xc7;
hideakitai 0:3f9dbf1e2cb0 868 buf[1] = (unsigned char)l;
hideakitai 0:3f9dbf1e2cb0 869 buf[2] = type;
hideakitai 0:3f9dbf1e2cb0 870 msgpack_pack_append_buffer(x, buf, 3);
hideakitai 0:3f9dbf1e2cb0 871 } else if(l < 65536) {
hideakitai 0:3f9dbf1e2cb0 872 unsigned char buf[4];
hideakitai 0:3f9dbf1e2cb0 873 buf[0] = 0xc8;
hideakitai 0:3f9dbf1e2cb0 874 _msgpack_store16(&buf[1], l);
hideakitai 0:3f9dbf1e2cb0 875 buf[3] = type;
hideakitai 0:3f9dbf1e2cb0 876 msgpack_pack_append_buffer(x, buf, 4);
hideakitai 0:3f9dbf1e2cb0 877 } else {
hideakitai 0:3f9dbf1e2cb0 878 unsigned char buf[6];
hideakitai 0:3f9dbf1e2cb0 879 buf[0] = 0xc9;
hideakitai 0:3f9dbf1e2cb0 880 _msgpack_store32(&buf[1], l);
hideakitai 0:3f9dbf1e2cb0 881 buf[5] = type;
hideakitai 0:3f9dbf1e2cb0 882 msgpack_pack_append_buffer(x, buf, 6);
hideakitai 0:3f9dbf1e2cb0 883 }
hideakitai 0:3f9dbf1e2cb0 884 break;
hideakitai 0:3f9dbf1e2cb0 885 }
hideakitai 0:3f9dbf1e2cb0 886 }
hideakitai 0:3f9dbf1e2cb0 887
hideakitai 0:3f9dbf1e2cb0 888 msgpack_pack_inline_func(_ext_body)(msgpack_pack_user x, const void* b, size_t l)
hideakitai 0:3f9dbf1e2cb0 889 {
hideakitai 0:3f9dbf1e2cb0 890 msgpack_pack_append_buffer(x, (const unsigned char*)b, l);
hideakitai 0:3f9dbf1e2cb0 891 }
hideakitai 0:3f9dbf1e2cb0 892
hideakitai 0:3f9dbf1e2cb0 893 #undef msgpack_pack_inline_func
hideakitai 0:3f9dbf1e2cb0 894 #undef msgpack_pack_user
hideakitai 0:3f9dbf1e2cb0 895 #undef msgpack_pack_append_buffer
hideakitai 0:3f9dbf1e2cb0 896
hideakitai 0:3f9dbf1e2cb0 897 #undef TAKE8_8
hideakitai 0:3f9dbf1e2cb0 898 #undef TAKE8_16
hideakitai 0:3f9dbf1e2cb0 899 #undef TAKE8_32
hideakitai 0:3f9dbf1e2cb0 900 #undef TAKE8_64
hideakitai 0:3f9dbf1e2cb0 901
hideakitai 0:3f9dbf1e2cb0 902 #undef msgpack_pack_real_uint8
hideakitai 0:3f9dbf1e2cb0 903 #undef msgpack_pack_real_uint16
hideakitai 0:3f9dbf1e2cb0 904 #undef msgpack_pack_real_uint32
hideakitai 0:3f9dbf1e2cb0 905 #undef msgpack_pack_real_uint64
hideakitai 0:3f9dbf1e2cb0 906 #undef msgpack_pack_real_int8
hideakitai 0:3f9dbf1e2cb0 907 #undef msgpack_pack_real_int16
hideakitai 0:3f9dbf1e2cb0 908 #undef msgpack_pack_real_int32
hideakitai 0:3f9dbf1e2cb0 909 #undef msgpack_pack_real_int64
hideakitai 0:3f9dbf1e2cb0 910