mirror of
				https://github.com/msgpack/msgpack-python.git
				synced 2025-11-04 03:20:56 +00:00 
			
		
		
		
	Update new headers.
This commit is contained in:
		
							parent
							
								
									fecbeb6d07
								
							
						
					
					
						commit
						af7c4d2a60
					
				
					 6 changed files with 225 additions and 219 deletions
				
			
		| 
						 | 
				
			
			@ -18,6 +18,7 @@
 | 
			
		|||
 | 
			
		||||
#include <stddef.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include "sysdep.h"
 | 
			
		||||
#include "pack_define.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,8 +18,7 @@
 | 
			
		|||
#ifndef MSGPACK_PACK_DEFINE_H__
 | 
			
		||||
#define MSGPACK_PACK_DEFINE_H__
 | 
			
		||||
 | 
			
		||||
#include <stddef.h>
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include "sysdep.h"
 | 
			
		||||
#include <limits.h>
 | 
			
		||||
 | 
			
		||||
#endif /* msgpack/pack_define.h */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,88 +16,16 @@
 | 
			
		|||
 *    limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#if !defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
 | 
			
		||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
 | 
			
		||||
#define __LITTLE_ENDIAN__
 | 
			
		||||
#elif __BYTE_ORDER == __BIG_ENDIAN
 | 
			
		||||
#define __BIG_ENDIAN__
 | 
			
		||||
#endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef __LITTLE_ENDIAN__
 | 
			
		||||
 | 
			
		||||
#define STORE8_BE8(d) \
 | 
			
		||||
	((uint8_t*)&d)[0]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define STORE16_BE8(d) \
 | 
			
		||||
	((uint8_t*)&d)[0]
 | 
			
		||||
 | 
			
		||||
#define STORE16_BE16(d) \
 | 
			
		||||
	((uint8_t*)&d)[1], ((uint8_t*)&d)[0]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define STORE32_BE8(d) \
 | 
			
		||||
	((uint8_t*)&d)[0]
 | 
			
		||||
 | 
			
		||||
#define STORE32_BE16(d) \
 | 
			
		||||
	((uint8_t*)&d)[1], ((uint8_t*)&d)[0]
 | 
			
		||||
 | 
			
		||||
#define STORE32_BE32(d) \
 | 
			
		||||
	((uint8_t*)&d)[3], ((uint8_t*)&d)[2], ((uint8_t*)&d)[1], ((uint8_t*)&d)[0]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define STORE64_BE8(d) \
 | 
			
		||||
	((uint8_t*)&d)[0]
 | 
			
		||||
 | 
			
		||||
#define STORE64_BE16(d) \
 | 
			
		||||
	((uint8_t*)&d)[1], ((uint8_t*)&d)[0]
 | 
			
		||||
 | 
			
		||||
#define STORE64_BE32(d) \
 | 
			
		||||
	((uint8_t*)&d)[3], ((uint8_t*)&d)[2], ((uint8_t*)&d)[1], ((uint8_t*)&d)[0]
 | 
			
		||||
 | 
			
		||||
#define STORE64_BE64(d) \
 | 
			
		||||
	((uint8_t*)&d)[7], ((uint8_t*)&d)[6], ((uint8_t*)&d)[5], ((uint8_t*)&d)[4], \
 | 
			
		||||
	((uint8_t*)&d)[3], ((uint8_t*)&d)[2], ((uint8_t*)&d)[1], ((uint8_t*)&d)[0]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define TAKE8_8(d)  ((uint8_t*)&d)[0]
 | 
			
		||||
#define TAKE8_16(d) ((uint8_t*)&d)[0]
 | 
			
		||||
#define TAKE8_32(d) ((uint8_t*)&d)[0]
 | 
			
		||||
#define TAKE8_64(d) ((uint8_t*)&d)[0]
 | 
			
		||||
#elif __BIG_ENDIAN__
 | 
			
		||||
 | 
			
		||||
#define STORE8_BE8(d) \
 | 
			
		||||
	((uint8_t*)&d)[0]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define STORE16_BE8(d) \
 | 
			
		||||
	((uint8_t*)&d)[1]
 | 
			
		||||
 | 
			
		||||
#define STORE16_BE16(d) \
 | 
			
		||||
	((uint8_t*)&d)[0], ((uint8_t*)&d)[1]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define STORE32_BE8(d) \
 | 
			
		||||
	((uint8_t*)&d)[3]
 | 
			
		||||
 | 
			
		||||
#define STORE32_BE16(d) \
 | 
			
		||||
	((uint8_t*)&d)[2], ((uint8_t*)&d)[3]
 | 
			
		||||
 | 
			
		||||
#define STORE32_BE32(d) \
 | 
			
		||||
	((uint8_t*)&d)[0], ((uint8_t*)&d)[1], ((uint8_t*)&d)[2], ((uint8_t*)&d)[3]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define STORE64_BE8(d) \
 | 
			
		||||
	((uint8_t*)&d)[7]
 | 
			
		||||
 | 
			
		||||
#define STORE64_BE16(d) \
 | 
			
		||||
	((uint8_t*)&d)[6], ((uint8_t*)&d)[7]
 | 
			
		||||
 | 
			
		||||
#define STORE64_BE32(d) \
 | 
			
		||||
	((uint8_t*)&d)[4], ((uint8_t*)&d)[5], ((uint8_t*)&d)[6], ((uint8_t*)&d)[7]
 | 
			
		||||
 | 
			
		||||
#define STORE64_BE64(d) \
 | 
			
		||||
	((uint8_t*)&d)[0], ((uint8_t*)&d)[1], ((uint8_t*)&d)[2], ((uint8_t*)&d)[3], \
 | 
			
		||||
	((uint8_t*)&d)[4], ((uint8_t*)&d)[5], ((uint8_t*)&d)[6], ((uint8_t*)&d)[7]
 | 
			
		||||
 | 
			
		||||
#define TAKE8_8(d)  ((uint8_t*)&d)[0]
 | 
			
		||||
#define TAKE8_16(d) ((uint8_t*)&d)[1]
 | 
			
		||||
#define TAKE8_32(d) ((uint8_t*)&d)[3]
 | 
			
		||||
#define TAKE8_64(d) ((uint8_t*)&d)[7]
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef msgpack_pack_inline_func
 | 
			
		||||
| 
						 | 
				
			
			@ -121,10 +49,10 @@
 | 
			
		|||
do { \
 | 
			
		||||
	if(d < (1<<7)) { \
 | 
			
		||||
		/* fixnum */ \
 | 
			
		||||
		msgpack_pack_append_buffer(x, &STORE8_BE8(d), 1); \
 | 
			
		||||
		msgpack_pack_append_buffer(x, &TAKE8_8(d), 1); \
 | 
			
		||||
	} else { \
 | 
			
		||||
		/* unsigned 8 */ \
 | 
			
		||||
		const unsigned char buf[2] = {0xcc, STORE8_BE8(d)}; \
 | 
			
		||||
		unsigned char buf[2] = {0xcc, TAKE8_8(d)}; \
 | 
			
		||||
		msgpack_pack_append_buffer(x, buf, 2); \
 | 
			
		||||
	} \
 | 
			
		||||
} while(0)
 | 
			
		||||
| 
						 | 
				
			
			@ -133,14 +61,15 @@ do { \
 | 
			
		|||
do { \
 | 
			
		||||
	if(d < (1<<7)) { \
 | 
			
		||||
		/* fixnum */ \
 | 
			
		||||
		msgpack_pack_append_buffer(x, &STORE16_BE8(d), 1); \
 | 
			
		||||
		msgpack_pack_append_buffer(x, &TAKE8_16(d), 1); \
 | 
			
		||||
	} else if(d < (1<<8)) { \
 | 
			
		||||
		/* unsigned 8 */ \
 | 
			
		||||
		const unsigned char buf[2] = {0xcc, STORE16_BE8(d)}; \
 | 
			
		||||
		unsigned char buf[2] = {0xcc, TAKE8_16(d)}; \
 | 
			
		||||
		msgpack_pack_append_buffer(x, buf, 2); \
 | 
			
		||||
	} else { \
 | 
			
		||||
		/* unsigned 16 */ \
 | 
			
		||||
		const unsigned char buf[3] = {0xcd, STORE16_BE16(d)}; \
 | 
			
		||||
		unsigned char buf[3]; \
 | 
			
		||||
		buf[0] = 0xcd; *(uint16_t*)&buf[1] = _msgpack_be16(d); \
 | 
			
		||||
		msgpack_pack_append_buffer(x, buf, 3); \
 | 
			
		||||
	} \
 | 
			
		||||
} while(0)
 | 
			
		||||
| 
						 | 
				
			
			@ -150,20 +79,22 @@ do { \
 | 
			
		|||
	if(d < (1<<8)) { \
 | 
			
		||||
		if(d < (1<<7)) { \
 | 
			
		||||
			/* fixnum */ \
 | 
			
		||||
			msgpack_pack_append_buffer(x, &STORE32_BE8(d), 1); \
 | 
			
		||||
			msgpack_pack_append_buffer(x, &TAKE8_32(d), 1); \
 | 
			
		||||
		} else { \
 | 
			
		||||
			/* unsigned 8 */ \
 | 
			
		||||
			const unsigned char buf[2] = {0xcc, STORE32_BE8(d)}; \
 | 
			
		||||
			unsigned char buf[2] = {0xcc, TAKE8_32(d)}; \
 | 
			
		||||
			msgpack_pack_append_buffer(x, buf, 2); \
 | 
			
		||||
		} \
 | 
			
		||||
	} else { \
 | 
			
		||||
		if(d < (1<<16)) { \
 | 
			
		||||
			/* unsigned 16 */ \
 | 
			
		||||
			const unsigned char buf[3] = {0xcd, STORE32_BE16(d)}; \
 | 
			
		||||
			unsigned char buf[3]; \
 | 
			
		||||
			buf[0] = 0xcd; *(uint16_t*)&buf[1] = _msgpack_be16(d); \
 | 
			
		||||
			msgpack_pack_append_buffer(x, buf, 3); \
 | 
			
		||||
		} else { \
 | 
			
		||||
			/* unsigned 32 */ \
 | 
			
		||||
			const unsigned char buf[5] = {0xce, STORE32_BE32(d)}; \
 | 
			
		||||
			unsigned char buf[5]; \
 | 
			
		||||
			buf[0] = 0xce; *(uint32_t*)&buf[1] = _msgpack_be32(d); \
 | 
			
		||||
			msgpack_pack_append_buffer(x, buf, 5); \
 | 
			
		||||
		} \
 | 
			
		||||
	} \
 | 
			
		||||
| 
						 | 
				
			
			@ -174,24 +105,27 @@ do { \
 | 
			
		|||
	if(d < (1ULL<<8)) { \
 | 
			
		||||
		if(d < (1<<7)) { \
 | 
			
		||||
			/* fixnum */ \
 | 
			
		||||
			msgpack_pack_append_buffer(x, &STORE64_BE8(d), 1); \
 | 
			
		||||
			msgpack_pack_append_buffer(x, &TAKE8_64(d), 1); \
 | 
			
		||||
		} else { \
 | 
			
		||||
			/* unsigned 8 */ \
 | 
			
		||||
			const unsigned char buf[2] = {0xcc, STORE64_BE8(d)}; \
 | 
			
		||||
			unsigned char buf[2] = {0xcc, TAKE8_64(d)}; \
 | 
			
		||||
			msgpack_pack_append_buffer(x, buf, 2); \
 | 
			
		||||
		} \
 | 
			
		||||
	} else { \
 | 
			
		||||
		if(d < (1ULL<<16)) { \
 | 
			
		||||
			/* signed 16 */ \
 | 
			
		||||
			const unsigned char buf[3] = {0xcd, STORE64_BE16(d)}; \
 | 
			
		||||
			unsigned char buf[3]; \
 | 
			
		||||
			buf[0] = 0xcd; *(uint16_t*)&buf[1] = _msgpack_be16(d); \
 | 
			
		||||
			msgpack_pack_append_buffer(x, buf, 3); \
 | 
			
		||||
		} else if(d < (1ULL<<32)) { \
 | 
			
		||||
			/* signed 32 */ \
 | 
			
		||||
			const unsigned char buf[5] = {0xce, STORE64_BE32(d)}; \
 | 
			
		||||
			unsigned char buf[5]; \
 | 
			
		||||
			buf[0] = 0xce; *(uint32_t*)&buf[1] = _msgpack_be32(d); \
 | 
			
		||||
			msgpack_pack_append_buffer(x, buf, 5); \
 | 
			
		||||
		} else { \
 | 
			
		||||
			/* signed 64 */ \
 | 
			
		||||
			const unsigned char buf[9] = {0xcf, STORE64_BE64(d)}; \
 | 
			
		||||
			unsigned char buf[9]; \
 | 
			
		||||
			buf[0] = 0xcf; *(uint64_t*)&buf[1] = _msgpack_be64(d); \
 | 
			
		||||
			msgpack_pack_append_buffer(x, buf, 9); \
 | 
			
		||||
		} \
 | 
			
		||||
	} \
 | 
			
		||||
| 
						 | 
				
			
			@ -201,11 +135,11 @@ do { \
 | 
			
		|||
do { \
 | 
			
		||||
	if(d < -(1<<5)) { \
 | 
			
		||||
		/* signed 8 */ \
 | 
			
		||||
		const unsigned char buf[2] = {0xd0, STORE8_BE8(d)}; \
 | 
			
		||||
		unsigned char buf[2] = {0xd0, TAKE8_8(d)}; \
 | 
			
		||||
		msgpack_pack_append_buffer(x, buf, 2); \
 | 
			
		||||
	} else { \
 | 
			
		||||
		/* fixnum */ \
 | 
			
		||||
		msgpack_pack_append_buffer(x, &STORE8_BE8(d), 1); \
 | 
			
		||||
		msgpack_pack_append_buffer(x, &TAKE8_8(d), 1); \
 | 
			
		||||
	} \
 | 
			
		||||
} while(0)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -214,24 +148,26 @@ do { \
 | 
			
		|||
	if(d < -(1<<5)) { \
 | 
			
		||||
		if(d < -(1<<7)) { \
 | 
			
		||||
			/* signed 16 */ \
 | 
			
		||||
			const unsigned char buf[3] = {0xd1, STORE16_BE16(d)}; \
 | 
			
		||||
			unsigned char buf[3]; \
 | 
			
		||||
			buf[0] = 0xd1; *(uint16_t*)&buf[1] = _msgpack_be16(d); \
 | 
			
		||||
			msgpack_pack_append_buffer(x, buf, 3); \
 | 
			
		||||
		} else { \
 | 
			
		||||
			/* signed 8 */ \
 | 
			
		||||
			const unsigned char buf[2] = {0xd0, STORE16_BE8(d)}; \
 | 
			
		||||
			unsigned char buf[2] = {0xd0, TAKE8_16(d)}; \
 | 
			
		||||
			msgpack_pack_append_buffer(x, buf, 2); \
 | 
			
		||||
		} \
 | 
			
		||||
	} else if(d < (1<<7)) { \
 | 
			
		||||
		/* fixnum */ \
 | 
			
		||||
		msgpack_pack_append_buffer(x, &STORE16_BE8(d), 1); \
 | 
			
		||||
		msgpack_pack_append_buffer(x, &TAKE8_16(d), 1); \
 | 
			
		||||
	} else { \
 | 
			
		||||
		if(d < (1<<8)) { \
 | 
			
		||||
			/* unsigned 8 */ \
 | 
			
		||||
			const unsigned char buf[2] = {0xcc, STORE16_BE8(d)}; \
 | 
			
		||||
			unsigned char buf[2] = {0xcc, TAKE8_16(d)}; \
 | 
			
		||||
			msgpack_pack_append_buffer(x, buf, 2); \
 | 
			
		||||
		} else { \
 | 
			
		||||
			/* unsigned 16 */ \
 | 
			
		||||
			const unsigned char buf[3] = {0xcd, STORE16_BE16(d)}; \
 | 
			
		||||
			unsigned char buf[3]; \
 | 
			
		||||
			buf[0] = 0xcd; *(uint16_t*)&buf[1] = _msgpack_be16(d); \
 | 
			
		||||
			msgpack_pack_append_buffer(x, buf, 3); \
 | 
			
		||||
		} \
 | 
			
		||||
	} \
 | 
			
		||||
| 
						 | 
				
			
			@ -242,32 +178,36 @@ do { \
 | 
			
		|||
	if(d < -(1<<5)) { \
 | 
			
		||||
		if(d < -(1<<15)) { \
 | 
			
		||||
			/* signed 32 */ \
 | 
			
		||||
			const unsigned char buf[5] = {0xd2, STORE32_BE32(d)}; \
 | 
			
		||||
			unsigned char buf[5]; \
 | 
			
		||||
			buf[0] = 0xd2; *(uint32_t*)&buf[1] = _msgpack_be32(d); \
 | 
			
		||||
			msgpack_pack_append_buffer(x, buf, 5); \
 | 
			
		||||
		} else if(d < -(1<<7)) { \
 | 
			
		||||
			/* signed 16 */ \
 | 
			
		||||
			const unsigned char buf[3] = {0xd1, STORE32_BE16(d)}; \
 | 
			
		||||
			unsigned char buf[3]; \
 | 
			
		||||
			buf[0] = 0xd1; *(uint16_t*)&buf[1] = _msgpack_be16(d); \
 | 
			
		||||
			msgpack_pack_append_buffer(x, buf, 3); \
 | 
			
		||||
		} else { \
 | 
			
		||||
			/* signed 8 */ \
 | 
			
		||||
			const unsigned char buf[2] = {0xd0, STORE32_BE8(d)}; \
 | 
			
		||||
			unsigned char buf[2] = {0xd0, TAKE8_32(d)}; \
 | 
			
		||||
			msgpack_pack_append_buffer(x, buf, 2); \
 | 
			
		||||
		} \
 | 
			
		||||
	} else if(d < (1<<7)) { \
 | 
			
		||||
		/* fixnum */ \
 | 
			
		||||
		msgpack_pack_append_buffer(x, &STORE32_BE8(d), 1); \
 | 
			
		||||
		msgpack_pack_append_buffer(x, &TAKE8_32(d), 1); \
 | 
			
		||||
	} else { \
 | 
			
		||||
		if(d < (1<<8)) { \
 | 
			
		||||
			/* unsigned 8 */ \
 | 
			
		||||
			const unsigned char buf[2] = {0xcc, STORE32_BE8(d)}; \
 | 
			
		||||
			unsigned char buf[2] = {0xcc, TAKE8_32(d)}; \
 | 
			
		||||
			msgpack_pack_append_buffer(x, buf, 2); \
 | 
			
		||||
		} else if(d < (1<<16)) { \
 | 
			
		||||
			/* unsigned 16 */ \
 | 
			
		||||
			const unsigned char buf[3] = {0xcd, STORE32_BE16(d)}; \
 | 
			
		||||
			unsigned char buf[3]; \
 | 
			
		||||
			buf[0] = 0xcd; *(uint16_t*)&buf[1] = _msgpack_be16(d); \
 | 
			
		||||
			msgpack_pack_append_buffer(x, buf, 3); \
 | 
			
		||||
		} else { \
 | 
			
		||||
			/* unsigned 32 */ \
 | 
			
		||||
			const unsigned char buf[5] = {0xce, STORE32_BE32(d)}; \
 | 
			
		||||
			unsigned char buf[5]; \
 | 
			
		||||
			buf[0] = 0xce; *(uint32_t*)&buf[1] = _msgpack_be32(d); \
 | 
			
		||||
			msgpack_pack_append_buffer(x, buf, 5); \
 | 
			
		||||
		} \
 | 
			
		||||
	} \
 | 
			
		||||
| 
						 | 
				
			
			@ -279,46 +219,52 @@ do { \
 | 
			
		|||
		if(d < -(1LL<<15)) { \
 | 
			
		||||
			if(d < -(1LL<<31)) { \
 | 
			
		||||
				/* signed 64 */ \
 | 
			
		||||
				const unsigned char buf[9] = {0xd3, STORE64_BE64(d)}; \
 | 
			
		||||
				unsigned char buf[9]; \
 | 
			
		||||
				buf[0] = 0xd3; *(uint64_t*)&buf[1] = _msgpack_be64(d); \
 | 
			
		||||
				msgpack_pack_append_buffer(x, buf, 9); \
 | 
			
		||||
			} else { \
 | 
			
		||||
				/* signed 32 */ \
 | 
			
		||||
				const unsigned char buf[5] = {0xd2, STORE64_BE32(d)}; \
 | 
			
		||||
				unsigned char buf[5]; \
 | 
			
		||||
				buf[0] = 0xd2; *(uint32_t*)&buf[1] = _msgpack_be32(d); \
 | 
			
		||||
				msgpack_pack_append_buffer(x, buf, 5); \
 | 
			
		||||
			} \
 | 
			
		||||
		} else { \
 | 
			
		||||
			if(d < -(1<<7)) { \
 | 
			
		||||
				/* signed 16 */ \
 | 
			
		||||
				const unsigned char buf[3] = {0xd1, STORE64_BE16(d)}; \
 | 
			
		||||
				unsigned char buf[3]; \
 | 
			
		||||
				buf[0] = 0xd1; *(uint16_t*)&buf[1] = _msgpack_be16(d); \
 | 
			
		||||
				msgpack_pack_append_buffer(x, buf, 3); \
 | 
			
		||||
			} else { \
 | 
			
		||||
				/* signed 8 */ \
 | 
			
		||||
				const unsigned char buf[2] = {0xd0, STORE64_BE8(d)}; \
 | 
			
		||||
				unsigned char buf[2] = {0xd0, TAKE8_64(d)}; \
 | 
			
		||||
				msgpack_pack_append_buffer(x, buf, 2); \
 | 
			
		||||
			} \
 | 
			
		||||
		} \
 | 
			
		||||
	} else if(d < (1<<7)) { \
 | 
			
		||||
		/* fixnum */ \
 | 
			
		||||
		msgpack_pack_append_buffer(x, &STORE64_BE8(d), 1); \
 | 
			
		||||
		msgpack_pack_append_buffer(x, &TAKE8_64(d), 1); \
 | 
			
		||||
	} else { \
 | 
			
		||||
		if(d < (1LL<<16)) { \
 | 
			
		||||
			if(d < (1<<8)) { \
 | 
			
		||||
				/* unsigned 8 */ \
 | 
			
		||||
				const unsigned char buf[2] = {0xcc, STORE64_BE8(d)}; \
 | 
			
		||||
				unsigned char buf[2] = {0xcc, TAKE8_64(d)}; \
 | 
			
		||||
				msgpack_pack_append_buffer(x, buf, 2); \
 | 
			
		||||
			} else { \
 | 
			
		||||
				/* unsigned 16 */ \
 | 
			
		||||
				const unsigned char buf[3] = {0xcd, STORE64_BE16(d)}; \
 | 
			
		||||
				unsigned char buf[3]; \
 | 
			
		||||
				buf[0] = 0xcd; *(uint16_t*)&buf[1] = _msgpack_be16(d); \
 | 
			
		||||
				msgpack_pack_append_buffer(x, buf, 3); \
 | 
			
		||||
			} \
 | 
			
		||||
		} else { \
 | 
			
		||||
			if(d < (1LL<<32)) { \
 | 
			
		||||
				/* unsigned 32 */ \
 | 
			
		||||
				const unsigned char buf[5] = {0xce, STORE64_BE32(d)}; \
 | 
			
		||||
				unsigned char buf[5]; \
 | 
			
		||||
				buf[0] = 0xce; *(uint32_t*)&buf[1] = _msgpack_be32(d); \
 | 
			
		||||
				msgpack_pack_append_buffer(x, buf, 5); \
 | 
			
		||||
			} else { \
 | 
			
		||||
				/* unsigned 64 */ \
 | 
			
		||||
				const unsigned char buf[9] = {0xcf, STORE64_BE64(d)}; \
 | 
			
		||||
				unsigned char buf[9]; \
 | 
			
		||||
				buf[0] = 0xcf; *(uint64_t*)&buf[1] = _msgpack_be64(d); \
 | 
			
		||||
				msgpack_pack_append_buffer(x, buf, 9); \
 | 
			
		||||
			} \
 | 
			
		||||
		} \
 | 
			
		||||
| 
						 | 
				
			
			@ -330,49 +276,55 @@ do { \
 | 
			
		|||
 | 
			
		||||
msgpack_pack_inline_func_fastint(_uint8)(msgpack_pack_user x, uint8_t d)
 | 
			
		||||
{
 | 
			
		||||
	const unsigned char buf[2] = {0xcc, STORE8_BE8(d)};
 | 
			
		||||
	unsigned char buf[2] = {0xcc, TAKE8_8(d)};
 | 
			
		||||
	msgpack_pack_append_buffer(x, buf, 2);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
msgpack_pack_inline_func_fastint(_uint16)(msgpack_pack_user x, uint16_t d)
 | 
			
		||||
{
 | 
			
		||||
	const unsigned char buf[3] = {0xcd, STORE16_BE16(d)};
 | 
			
		||||
	unsigned char buf[3];
 | 
			
		||||
	buf[0] = 0xcd; *(uint16_t*)&buf[1] = _msgpack_be16(d);
 | 
			
		||||
	msgpack_pack_append_buffer(x, buf, 3);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
msgpack_pack_inline_func_fastint(_uint32)(msgpack_pack_user x, uint32_t d)
 | 
			
		||||
{
 | 
			
		||||
	const unsigned char buf[5] = {0xce, STORE32_BE32(d)};
 | 
			
		||||
	unsigned char buf[5];
 | 
			
		||||
	buf[0] = 0xce; *(uint32_t*)&buf[1] = _msgpack_be32(d);
 | 
			
		||||
	msgpack_pack_append_buffer(x, buf, 5);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
msgpack_pack_inline_func_fastint(_uint64)(msgpack_pack_user x, uint64_t d)
 | 
			
		||||
{
 | 
			
		||||
	const unsigned char buf[9] = {0xcf, STORE64_BE64(d)};
 | 
			
		||||
	unsigned char buf[9];
 | 
			
		||||
	buf[0] = 0xcf; *(uint64_t*)&buf[1] = _msgpack_be64(d);
 | 
			
		||||
	msgpack_pack_append_buffer(x, buf, 9);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
msgpack_pack_inline_func_fastint(_int8)(msgpack_pack_user x, int8_t d)
 | 
			
		||||
{
 | 
			
		||||
	const unsigned char buf[2] = {0xd0, STORE8_BE8(d)};
 | 
			
		||||
	unsigned char buf[2] = {0xd0, TAKE8_8(d)};
 | 
			
		||||
	msgpack_pack_append_buffer(x, buf, 2);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
msgpack_pack_inline_func_fastint(_int16)(msgpack_pack_user x, int16_t d)
 | 
			
		||||
{
 | 
			
		||||
	const unsigned char buf[3] = {0xd1, STORE16_BE16(d)};
 | 
			
		||||
	unsigned char buf[3];
 | 
			
		||||
	buf[0] = 0xd1; *(uint16_t*)&buf[1] = _msgpack_be16(d);
 | 
			
		||||
	msgpack_pack_append_buffer(x, buf, 3);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
msgpack_pack_inline_func_fastint(_int32)(msgpack_pack_user x, int32_t d)
 | 
			
		||||
{
 | 
			
		||||
	const unsigned char buf[5] = {0xd2, STORE32_BE32(d)};
 | 
			
		||||
	unsigned char buf[5];
 | 
			
		||||
	buf[0] = 0xd2; *(uint32_t*)&buf[1] = _msgpack_be32(d);
 | 
			
		||||
	msgpack_pack_append_buffer(x, buf, 5);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
msgpack_pack_inline_func_fastint(_int64)(msgpack_pack_user x, int64_t d)
 | 
			
		||||
{
 | 
			
		||||
	const unsigned char buf[9] = {0xd3, STORE64_BE64(d)};
 | 
			
		||||
	unsigned char buf[9];
 | 
			
		||||
	buf[0] = 0xd3; *(uint64_t*)&buf[1] = _msgpack_be64(d);
 | 
			
		||||
	msgpack_pack_append_buffer(x, buf, 9);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -604,7 +556,8 @@ msgpack_pack_inline_func(_float)(msgpack_pack_user x, float d)
 | 
			
		|||
{
 | 
			
		||||
	union { char buf[4]; uint32_t num; } f;
 | 
			
		||||
	*((float*)&f.buf) = d;  // FIXME
 | 
			
		||||
	const unsigned char buf[5] = {0xca, STORE32_BE32(f.num)};
 | 
			
		||||
	unsigned char buf[5];
 | 
			
		||||
	buf[0] = 0xca; *(uint32_t*)&buf[1] = _msgpack_be32(f.num);
 | 
			
		||||
	msgpack_pack_append_buffer(x, buf, 5);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -612,7 +565,8 @@ msgpack_pack_inline_func(_double)(msgpack_pack_user x, double d)
 | 
			
		|||
{
 | 
			
		||||
	union { char buf[8]; uint64_t num; } f;
 | 
			
		||||
	*((double*)&f.buf) = d;  // FIXME
 | 
			
		||||
	const unsigned char buf[9] = {0xcb, STORE64_BE64(f.num)};
 | 
			
		||||
	unsigned char buf[9];
 | 
			
		||||
	buf[0] = 0xcb; *(uint64_t*)&buf[1] = _msgpack_be64(f.num);
 | 
			
		||||
	msgpack_pack_append_buffer(x, buf, 9);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -655,12 +609,12 @@ msgpack_pack_inline_func(_array)(msgpack_pack_user x, unsigned int n)
 | 
			
		|||
		unsigned char d = 0x90 | n;
 | 
			
		||||
		msgpack_pack_append_buffer(x, &d, 1);
 | 
			
		||||
	} else if(n < 65536) {
 | 
			
		||||
		uint16_t d = (uint16_t)n;
 | 
			
		||||
		unsigned char buf[3] = {0xdc, STORE16_BE16(d)};
 | 
			
		||||
		unsigned char buf[3];
 | 
			
		||||
		buf[0] = 0xdc; *(uint16_t*)&buf[1] = _msgpack_be16(n);
 | 
			
		||||
		msgpack_pack_append_buffer(x, buf, 3);
 | 
			
		||||
	} else {
 | 
			
		||||
		uint32_t d = (uint32_t)n;
 | 
			
		||||
		unsigned char buf[5] = {0xdd, STORE32_BE32(d)};
 | 
			
		||||
		unsigned char buf[5];
 | 
			
		||||
		buf[0] = 0xdd; *(uint32_t*)&buf[1] = _msgpack_be32(n);
 | 
			
		||||
		msgpack_pack_append_buffer(x, buf, 5);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -674,14 +628,14 @@ msgpack_pack_inline_func(_map)(msgpack_pack_user x, unsigned int n)
 | 
			
		|||
{
 | 
			
		||||
	if(n < 16) {
 | 
			
		||||
		unsigned char d = 0x80 | n;
 | 
			
		||||
		msgpack_pack_append_buffer(x, &STORE8_BE8(d), 1);
 | 
			
		||||
		msgpack_pack_append_buffer(x, &TAKE8_8(d), 1);
 | 
			
		||||
	} else if(n < 65536) {
 | 
			
		||||
		uint16_t d = (uint16_t)n;
 | 
			
		||||
		unsigned char buf[3] = {0xde, STORE16_BE16(d)};
 | 
			
		||||
		unsigned char buf[3];
 | 
			
		||||
		buf[0] = 0xde; *(uint16_t*)&buf[1] = _msgpack_be16(n);
 | 
			
		||||
		msgpack_pack_append_buffer(x, buf, 3);
 | 
			
		||||
	} else {
 | 
			
		||||
		uint32_t d = (uint32_t)n;
 | 
			
		||||
		unsigned char buf[5] = {0xdf, STORE32_BE32(d)};
 | 
			
		||||
		unsigned char buf[5];
 | 
			
		||||
		buf[0] = 0xdf; *(uint32_t*)&buf[1] = _msgpack_be32(n);
 | 
			
		||||
		msgpack_pack_append_buffer(x, buf, 5);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -695,14 +649,14 @@ msgpack_pack_inline_func(_raw)(msgpack_pack_user x, size_t l)
 | 
			
		|||
{
 | 
			
		||||
	if(l < 32) {
 | 
			
		||||
		unsigned char d = 0xa0 | l;
 | 
			
		||||
		msgpack_pack_append_buffer(x, &STORE8_BE8(d), 1);
 | 
			
		||||
		msgpack_pack_append_buffer(x, &TAKE8_8(d), 1);
 | 
			
		||||
	} else if(l < 65536) {
 | 
			
		||||
		uint16_t d = (uint16_t)l;
 | 
			
		||||
		unsigned char buf[3] = {0xda, STORE16_BE16(d)};
 | 
			
		||||
		unsigned char buf[3];
 | 
			
		||||
		buf[0] = 0xda; *(uint16_t*)&buf[1] = _msgpack_be16(l);
 | 
			
		||||
		msgpack_pack_append_buffer(x, buf, 3);
 | 
			
		||||
	} else {
 | 
			
		||||
		uint32_t d = (uint32_t)l;
 | 
			
		||||
		unsigned char buf[5] = {0xdb, STORE32_BE32(d)};
 | 
			
		||||
		unsigned char buf[5];
 | 
			
		||||
		buf[0] = 0xdb; *(uint32_t*)&buf[1] = _msgpack_be32(l);
 | 
			
		||||
		msgpack_pack_append_buffer(x, buf, 5);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -716,19 +670,10 @@ msgpack_pack_inline_func(_raw_body)(msgpack_pack_user x, const void* b, size_t l
 | 
			
		|||
#undef msgpack_pack_user
 | 
			
		||||
#undef msgpack_pack_append_buffer
 | 
			
		||||
 | 
			
		||||
#undef STORE8_BE8
 | 
			
		||||
 | 
			
		||||
#undef STORE16_BE8
 | 
			
		||||
#undef STORE16_BE16
 | 
			
		||||
 | 
			
		||||
#undef STORE32_BE8
 | 
			
		||||
#undef STORE32_BE16
 | 
			
		||||
#undef STORE32_BE32
 | 
			
		||||
 | 
			
		||||
#undef STORE64_BE8
 | 
			
		||||
#undef STORE64_BE16
 | 
			
		||||
#undef STORE64_BE32
 | 
			
		||||
#undef STORE64_BE64
 | 
			
		||||
#undef TAKE8_8
 | 
			
		||||
#undef TAKE8_16
 | 
			
		||||
#undef TAKE8_32
 | 
			
		||||
#undef TAKE8_64
 | 
			
		||||
 | 
			
		||||
#undef msgpack_pack_real_uint8
 | 
			
		||||
#undef msgpack_pack_real_uint16
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										94
									
								
								msgpack/sysdep.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										94
									
								
								msgpack/sysdep.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,94 @@
 | 
			
		|||
/*
 | 
			
		||||
 * MessagePack system dependencies
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (C) 2008-2009 FURUHASHI Sadayuki
 | 
			
		||||
 *
 | 
			
		||||
 *    Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 *    you may not use this file except in compliance with the License.
 | 
			
		||||
 *    You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 *        http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 *    Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 *    distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 *    See the License for the specific language governing permissions and
 | 
			
		||||
 *    limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
#ifndef MSGPACK_SYSDEP_H__
 | 
			
		||||
#define MSGPACK_SYSDEP_H__
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef _MSC_VER
 | 
			
		||||
typedef __int8 int8_t;
 | 
			
		||||
typedef unsigned __int8 uint8_t;
 | 
			
		||||
typedef __int16 int16_t;
 | 
			
		||||
typedef unsigned __int16 uint16_t;
 | 
			
		||||
typedef __int32 int32_t;
 | 
			
		||||
typedef unsigned __int32 uint32_t;
 | 
			
		||||
typedef __int64 int64_t;
 | 
			
		||||
typedef unsigned __int64 uint64_t;
 | 
			
		||||
#else
 | 
			
		||||
#include <stddef.h>
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
typedef long _msgpack_atomic_counter_t;
 | 
			
		||||
#define _msgpack_sync_decr_and_fetch(ptr) InterlockedDecrement(ptr)
 | 
			
		||||
#define _msgpack_sync_incr_and_fetch(ptr) InterlockedIncrement(ptr)
 | 
			
		||||
#else
 | 
			
		||||
typedef unsigned int _msgpack_atomic_counter_t;
 | 
			
		||||
#define _msgpack_sync_decr_and_fetch(ptr) __sync_sub_and_fetch(ptr, 1)
 | 
			
		||||
#define _msgpack_sync_incr_and_fetch(ptr) __sync_add_and_fetch(ptr, 1)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
#include <winsock2.h>
 | 
			
		||||
#else
 | 
			
		||||
#include <arpa/inet.h>  /* __BYTE_ORDER */
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if !defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
 | 
			
		||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
 | 
			
		||||
#define __LITTLE_ENDIAN__
 | 
			
		||||
#elif __BYTE_ORDER == __BIG_ENDIAN
 | 
			
		||||
#define __BIG_ENDIAN__
 | 
			
		||||
#endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef __LITTLE_ENDIAN__
 | 
			
		||||
 | 
			
		||||
#define _msgpack_be16(x) ntohs(x)
 | 
			
		||||
#define _msgpack_be32(x) ntohl(x)
 | 
			
		||||
 | 
			
		||||
#if defined(_byteswap_uint64)
 | 
			
		||||
#  define _msgpack_be64(x) (_byteswap_uint64(x))
 | 
			
		||||
#elif defined(bswap_64)
 | 
			
		||||
#  define _msgpack_be64(x) bswap_64(x)
 | 
			
		||||
#elif defined(__DARWIN_OSSwapInt64)
 | 
			
		||||
#  define _msgpack_be64(x) __DARWIN_OSSwapInt64(x)
 | 
			
		||||
#else
 | 
			
		||||
#define _msgpack_be64(x) \
 | 
			
		||||
	( ((((uint64_t)x) << 56) & 0xff00000000000000ULL ) | \
 | 
			
		||||
	  ((((uint64_t)x) << 40) & 0x00ff000000000000ULL ) | \
 | 
			
		||||
	  ((((uint64_t)x) << 24) & 0x0000ff0000000000ULL ) | \
 | 
			
		||||
	  ((((uint64_t)x) <<  8) & 0x000000ff00000000ULL ) | \
 | 
			
		||||
	  ((((uint64_t)x) >>  8) & 0x00000000ff000000ULL ) | \
 | 
			
		||||
	  ((((uint64_t)x) >> 24) & 0x0000000000ff0000ULL ) | \
 | 
			
		||||
	  ((((uint64_t)x) >> 40) & 0x000000000000ff00ULL ) | \
 | 
			
		||||
	  ((((uint64_t)x) >> 56) & 0x00000000000000ffULL ) )
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#else
 | 
			
		||||
#define _msgpack_be16(x) (x)
 | 
			
		||||
#define _msgpack_be32(x) (x)
 | 
			
		||||
#define _msgpack_be64(x) (x)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif /* msgpack/sysdep.h */
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -18,14 +18,10 @@
 | 
			
		|||
#ifndef MSGPACK_UNPACK_DEFINE_H__
 | 
			
		||||
#define MSGPACK_UNPACK_DEFINE_H__
 | 
			
		||||
 | 
			
		||||
#include <stddef.h>
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include "sysdep.h"
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <assert.h>
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#ifndef __WIN32__
 | 
			
		||||
#include <arpa/inet.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
| 
						 | 
				
			
			@ -37,52 +33,6 @@ extern "C" {
 | 
			
		|||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if !defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
 | 
			
		||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
 | 
			
		||||
#define __LITTLE_ENDIAN__
 | 
			
		||||
#elif __BYTE_ORDER == __BIG_ENDIAN
 | 
			
		||||
#define __BIG_ENDIAN__
 | 
			
		||||
#endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef __WIN32__
 | 
			
		||||
static inline uint16_t msgpack_betoh16(uint16_t x) {
 | 
			
		||||
	return  ((x <<  8) & 0xff00U) |
 | 
			
		||||
			((x >>  8) & 0x00ffU);
 | 
			
		||||
}
 | 
			
		||||
static inline uint32_t msgpack_betoh32(uint32_t x) {
 | 
			
		||||
	return	((x << 24) & 0xff000000UL ) |
 | 
			
		||||
			((x <<  8) & 0x00ff0000UL ) |
 | 
			
		||||
			((x >>  8) & 0x0000ff00UL ) |
 | 
			
		||||
			((x >> 24) & 0x000000ffUL );
 | 
			
		||||
}
 | 
			
		||||
#else
 | 
			
		||||
#define msgpack_betoh16(x) ntohs(x)
 | 
			
		||||
#define msgpack_betoh32(x) ntohl(x)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef __LITTLE_ENDIAN__
 | 
			
		||||
#if defined(__bswap_64)
 | 
			
		||||
#  define msgpack_betoh64(x) __bswap_64(x)
 | 
			
		||||
#elif defined(__DARWIN_OSSwapInt64)
 | 
			
		||||
#  define msgpack_betoh64(x) __DARWIN_OSSwapInt64(x)
 | 
			
		||||
#else
 | 
			
		||||
static inline uint64_t msgpack_betoh64(uint64_t x) {
 | 
			
		||||
	return	((x << 56) & 0xff00000000000000ULL ) |
 | 
			
		||||
			((x << 40) & 0x00ff000000000000ULL ) |
 | 
			
		||||
			((x << 24) & 0x0000ff0000000000ULL ) |
 | 
			
		||||
			((x <<  8) & 0x000000ff00000000ULL ) |
 | 
			
		||||
			((x >>  8) & 0x00000000ff000000ULL ) |
 | 
			
		||||
			((x >> 24) & 0x0000000000ff0000ULL ) |
 | 
			
		||||
			((x >> 40) & 0x000000000000ff00ULL ) |
 | 
			
		||||
			((x >> 56) & 0x00000000000000ffULL ) ;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
#else
 | 
			
		||||
#define msgpack_betoh64(x) (x)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
typedef enum {
 | 
			
		||||
	CS_HEADER            = 0x00,  // nil
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -40,6 +40,11 @@
 | 
			
		|||
#error msgpack_unpack_user type is not defined
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef USE_CASE_RANGE
 | 
			
		||||
#if !defined(_MSC_VER)
 | 
			
		||||
#define USE_CASE_RANGE
 | 
			
		||||
#endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
msgpack_unpack_struct_decl(_stack) {
 | 
			
		||||
	msgpack_unpack_object obj;
 | 
			
		||||
| 
						 | 
				
			
			@ -131,20 +136,32 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
 | 
			
		|||
	((unsigned int)*p & 0x1f)
 | 
			
		||||
 | 
			
		||||
#define PTR_CAST_8(ptr)   (*(uint8_t*)ptr)
 | 
			
		||||
#define PTR_CAST_16(ptr)  msgpack_betoh16(*(uint16_t*)ptr)
 | 
			
		||||
#define PTR_CAST_32(ptr)  msgpack_betoh32(*(uint32_t*)ptr)
 | 
			
		||||
#define PTR_CAST_64(ptr)  msgpack_betoh64(*(uint64_t*)ptr)
 | 
			
		||||
#define PTR_CAST_16(ptr)  _msgpack_be16(*(uint16_t*)ptr)
 | 
			
		||||
#define PTR_CAST_32(ptr)  _msgpack_be32(*(uint32_t*)ptr)
 | 
			
		||||
#define PTR_CAST_64(ptr)  _msgpack_be64(*(uint64_t*)ptr)
 | 
			
		||||
 | 
			
		||||
#ifdef USE_CASE_RANGE
 | 
			
		||||
#define SWITCH_RANGE_BEGIN     switch(*p) {
 | 
			
		||||
#define SWITCH_RANGE(FROM, TO) case FROM ... TO:
 | 
			
		||||
#define SWITCH_RANGE_DEFAULT   default:
 | 
			
		||||
#define SWITCH_RANGE_END       }
 | 
			
		||||
#else
 | 
			
		||||
#define SWITCH_RANGE_BEGIN     { if(0) {
 | 
			
		||||
#define SWITCH_RANGE(FROM, TO) } else if(FROM <= *p && *p <= TO) {
 | 
			
		||||
#define SWITCH_RANGE_DEFAULT   } else {
 | 
			
		||||
#define SWITCH_RANGE_END       } }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
	if(p == pe) { goto _out; }
 | 
			
		||||
	do {
 | 
			
		||||
		switch(cs) {
 | 
			
		||||
		case CS_HEADER:
 | 
			
		||||
			switch(*p) {
 | 
			
		||||
			case 0x00 ... 0x7f:  // Positive Fixnum
 | 
			
		||||
			SWITCH_RANGE_BEGIN
 | 
			
		||||
			SWITCH_RANGE(0x00, 0x7f)  // Positive Fixnum
 | 
			
		||||
				push_fixed_value(_uint8, *(uint8_t*)p);
 | 
			
		||||
			case 0xe0 ... 0xff:  // Negative Fixnum
 | 
			
		||||
			SWITCH_RANGE(0xe0, 0xff)  // Negative Fixnum
 | 
			
		||||
				push_fixed_value(_int8, *(int8_t*)p);
 | 
			
		||||
			case 0xc0 ... 0xdf:  // Variable
 | 
			
		||||
			SWITCH_RANGE(0xc0, 0xdf)  // Variable
 | 
			
		||||
				switch(*p) {
 | 
			
		||||
				case 0xc0:  // nil
 | 
			
		||||
					push_simple_value(_nil);
 | 
			
		||||
| 
						 | 
				
			
			@ -187,16 +204,16 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
 | 
			
		|||
				default:
 | 
			
		||||
					goto _failed;
 | 
			
		||||
				}
 | 
			
		||||
			case 0xa0 ... 0xbf:  // FixRaw
 | 
			
		||||
			SWITCH_RANGE(0xa0, 0xbf)  // FixRaw
 | 
			
		||||
				again_fixed_trail_if_zero(ACS_RAW_VALUE, ((unsigned int)*p & 0x1f), _raw_zero);
 | 
			
		||||
			case 0x90 ... 0x9f:  // FixArray
 | 
			
		||||
			SWITCH_RANGE(0x90, 0x9f)  // FixArray
 | 
			
		||||
				start_container(_array, ((unsigned int)*p) & 0x0f, CT_ARRAY_ITEM);
 | 
			
		||||
			case 0x80 ... 0x8f:  // FixMap
 | 
			
		||||
			SWITCH_RANGE(0x80, 0x8f)  // FixMap
 | 
			
		||||
				start_container(_map, ((unsigned int)*p) & 0x0f, CT_MAP_KEY);
 | 
			
		||||
 | 
			
		||||
			default:
 | 
			
		||||
			SWITCH_RANGE_DEFAULT
 | 
			
		||||
				goto _failed;
 | 
			
		||||
			}
 | 
			
		||||
			SWITCH_RANGE_END
 | 
			
		||||
			// end CS_HEADER
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue