msgpack 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  /*
2
- * MessagePack unpacking routine for Ruby
2
+ * MessagePack for Ruby unpacking routine
3
3
  *
4
- * Copyright (C) 2008 FURUHASHI Sadayuki
4
+ * Copyright (C) 2008-2009 FURUHASHI Sadayuki
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * MessagePack unpacking routine template
3
3
  *
4
- * Copyright (C) 2008 FURUHASHI Sadayuki
4
+ * Copyright (C) 2008-2009 FURUHASHI Sadayuki
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * MessagePack packing routine template
3
3
  *
4
- * Copyright (C) 2008 FURUHASHI Sadayuki
4
+ * Copyright (C) 2008-2009 FURUHASHI Sadayuki
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -278,49 +278,49 @@ do { \
278
278
 
279
279
  #ifdef msgpack_pack_inline_func_fastint
280
280
 
281
- msgpack_pack_inline_func_fastint(uint8)(msgpack_pack_user x, uint8_t d)
281
+ msgpack_pack_inline_func_fastint(_uint8)(msgpack_pack_user x, uint8_t d)
282
282
  {
283
283
  const unsigned char buf[2] = {0xcc, d};
284
284
  msgpack_pack_append_buffer(x, buf, 2);
285
285
  }
286
286
 
287
- msgpack_pack_inline_func_fastint(uint16)(msgpack_pack_user x, uint16_t d)
287
+ msgpack_pack_inline_func_fastint(_uint16)(msgpack_pack_user x, uint16_t d)
288
288
  {
289
289
  const unsigned char buf[3] = {0xcd, STORE_BE16(d)};
290
290
  msgpack_pack_append_buffer(x, buf, 3);
291
291
  }
292
292
 
293
- msgpack_pack_inline_func_fastint(uint32)(msgpack_pack_user x, uint32_t d)
293
+ msgpack_pack_inline_func_fastint(_uint32)(msgpack_pack_user x, uint32_t d)
294
294
  {
295
295
  const unsigned char buf[5] = {0xce, STORE_BE32(d)};
296
296
  msgpack_pack_append_buffer(x, buf, 5);
297
297
  }
298
298
 
299
- msgpack_pack_inline_func_fastint(uint64)(msgpack_pack_user x, uint64_t d)
299
+ msgpack_pack_inline_func_fastint(_uint64)(msgpack_pack_user x, uint64_t d)
300
300
  {
301
301
  const unsigned char buf[9] = {0xcf, STORE_BE64(d)};
302
302
  msgpack_pack_append_buffer(x, buf, 9);
303
303
  }
304
304
 
305
- msgpack_pack_inline_func_fastint(int8)(msgpack_pack_user x, int8_t d)
305
+ msgpack_pack_inline_func_fastint(_int8)(msgpack_pack_user x, int8_t d)
306
306
  {
307
307
  const unsigned char buf[2] = {0xd0, d};
308
308
  msgpack_pack_append_buffer(x, buf, 2);
309
309
  }
310
310
 
311
- msgpack_pack_inline_func_fastint(int16)(msgpack_pack_user x, int16_t d)
311
+ msgpack_pack_inline_func_fastint(_int16)(msgpack_pack_user x, int16_t d)
312
312
  {
313
313
  const unsigned char buf[3] = {0xd1, STORE_BE16(d)};
314
314
  msgpack_pack_append_buffer(x, buf, 3);
315
315
  }
316
316
 
317
- msgpack_pack_inline_func_fastint(int32)(msgpack_pack_user x, int32_t d)
317
+ msgpack_pack_inline_func_fastint(_int32)(msgpack_pack_user x, int32_t d)
318
318
  {
319
319
  const unsigned char buf[5] = {0xd2, STORE_BE32(d)};
320
320
  msgpack_pack_append_buffer(x, buf, 5);
321
321
  }
322
322
 
323
- msgpack_pack_inline_func_fastint(int64)(msgpack_pack_user x, int64_t d)
323
+ msgpack_pack_inline_func_fastint(_int64)(msgpack_pack_user x, int64_t d)
324
324
  {
325
325
  const unsigned char buf[9] = {0xd3, STORE_BE64(d)};
326
326
  msgpack_pack_append_buffer(x, buf, 9);
@@ -330,42 +330,42 @@ msgpack_pack_inline_func_fastint(int64)(msgpack_pack_user x, int64_t d)
330
330
  #endif
331
331
 
332
332
 
333
- msgpack_pack_inline_func(uint8)(msgpack_pack_user x, uint8_t d)
333
+ msgpack_pack_inline_func(_uint8)(msgpack_pack_user x, uint8_t d)
334
334
  {
335
335
  msgpack_pack_real_uint8(x, d);
336
336
  }
337
337
 
338
- msgpack_pack_inline_func(uint16)(msgpack_pack_user x, uint16_t d)
338
+ msgpack_pack_inline_func(_uint16)(msgpack_pack_user x, uint16_t d)
339
339
  {
340
340
  msgpack_pack_real_uint16(x, d);
341
341
  }
342
342
 
343
- msgpack_pack_inline_func(uint32)(msgpack_pack_user x, uint32_t d)
343
+ msgpack_pack_inline_func(_uint32)(msgpack_pack_user x, uint32_t d)
344
344
  {
345
345
  msgpack_pack_real_uint32(x, d);
346
346
  }
347
347
 
348
- msgpack_pack_inline_func(uint64)(msgpack_pack_user x, uint64_t d)
348
+ msgpack_pack_inline_func(_uint64)(msgpack_pack_user x, uint64_t d)
349
349
  {
350
350
  msgpack_pack_real_uint64(x, d);
351
351
  }
352
352
 
353
- msgpack_pack_inline_func(int8)(msgpack_pack_user x, int8_t d)
353
+ msgpack_pack_inline_func(_int8)(msgpack_pack_user x, int8_t d)
354
354
  {
355
355
  msgpack_pack_real_int8(x, d);
356
356
  }
357
357
 
358
- msgpack_pack_inline_func(int16)(msgpack_pack_user x, int16_t d)
358
+ msgpack_pack_inline_func(_int16)(msgpack_pack_user x, int16_t d)
359
359
  {
360
360
  msgpack_pack_real_int16(x, d);
361
361
  }
362
362
 
363
- msgpack_pack_inline_func(int32)(msgpack_pack_user x, int32_t d)
363
+ msgpack_pack_inline_func(_int32)(msgpack_pack_user x, int32_t d)
364
364
  {
365
365
  msgpack_pack_real_int32(x, d);
366
366
  }
367
367
 
368
- msgpack_pack_inline_func(int64)(msgpack_pack_user x, int64_t d)
368
+ msgpack_pack_inline_func(_int64)(msgpack_pack_user x, int64_t d)
369
369
  {
370
370
  msgpack_pack_real_int64(x, d);
371
371
  }
@@ -373,7 +373,7 @@ msgpack_pack_inline_func(int64)(msgpack_pack_user x, int64_t d)
373
373
 
374
374
  #ifdef msgpack_pack_inline_func_cint
375
375
 
376
- msgpack_pack_inline_func_cint(short)(msgpack_pack_user x, short d)
376
+ msgpack_pack_inline_func_cint(_short)(msgpack_pack_user x, short d)
377
377
  {
378
378
  #if defined(SIZEOF_SHORT) || defined(SHRT_MAX)
379
379
  #if SIZEOF_SHORT == 2 || SHRT_MAX == 0x7fff
@@ -394,7 +394,7 @@ if(sizeof(short) == 2) {
394
394
  #endif
395
395
  }
396
396
 
397
- msgpack_pack_inline_func_cint(int)(msgpack_pack_user x, int d)
397
+ msgpack_pack_inline_func_cint(_int)(msgpack_pack_user x, int d)
398
398
  {
399
399
  #if defined(SIZEOF_INT) || defined(INT_MAX)
400
400
  #if SIZEOF_INT == 2 || INT_MAX == 0x7fff
@@ -415,7 +415,7 @@ if(sizeof(int) == 2) {
415
415
  #endif
416
416
  }
417
417
 
418
- msgpack_pack_inline_func_cint(long)(msgpack_pack_user x, long d)
418
+ msgpack_pack_inline_func_cint(_long)(msgpack_pack_user x, long d)
419
419
  {
420
420
  #if defined(SIZEOF_LONG) || defined(LONG_MAX)
421
421
  #if SIZEOF_LONG == 2 || LONG_MAX == 0x7fffL
@@ -436,7 +436,7 @@ if(sizeof(long) == 2) {
436
436
  #endif
437
437
  }
438
438
 
439
- msgpack_pack_inline_func_cint(long_long)(msgpack_pack_user x, long long d)
439
+ msgpack_pack_inline_func_cint(_long_long)(msgpack_pack_user x, long long d)
440
440
  {
441
441
  #if defined(SIZEOF_LONG_LONG) || defined(LLONG_MAX)
442
442
  #if SIZEOF_LONG_LONG == 2 || LLONG_MAX == 0x7fffL
@@ -457,7 +457,7 @@ if(sizeof(long long) == 2) {
457
457
  #endif
458
458
  }
459
459
 
460
- msgpack_pack_inline_func_cint(unsigned_short)(msgpack_pack_user x, unsigned short d)
460
+ msgpack_pack_inline_func_cint(_unsigned_short)(msgpack_pack_user x, unsigned short d)
461
461
  {
462
462
  #if defined(SIZEOF_SHORT) || defined(USHRT_MAX)
463
463
  #if SIZEOF_SHORT == 2 || USHRT_MAX == 0xffffU
@@ -478,7 +478,7 @@ if(sizeof(unsigned short) == 2) {
478
478
  #endif
479
479
  }
480
480
 
481
- msgpack_pack_inline_func_cint(unsigned_int)(msgpack_pack_user x, unsigned int d)
481
+ msgpack_pack_inline_func_cint(_unsigned_int)(msgpack_pack_user x, unsigned int d)
482
482
  {
483
483
  #if defined(SIZEOF_INT) || defined(UINT_MAX)
484
484
  #if SIZEOF_INT == 2 || UINT_MAX == 0xffffU
@@ -499,7 +499,7 @@ if(sizeof(unsigned int) == 2) {
499
499
  #endif
500
500
  }
501
501
 
502
- msgpack_pack_inline_func_cint(unsigned_long)(msgpack_pack_user x, unsigned long d)
502
+ msgpack_pack_inline_func_cint(_unsigned_long)(msgpack_pack_user x, unsigned long d)
503
503
  {
504
504
  #if defined(SIZEOF_LONG) || defined(ULONG_MAX)
505
505
  #if SIZEOF_LONG == 2 || ULONG_MAX == 0xffffUL
@@ -520,7 +520,7 @@ if(sizeof(unsigned int) == 2) {
520
520
  #endif
521
521
  }
522
522
 
523
- msgpack_pack_inline_func_cint(unsigned_long_long)(msgpack_pack_user x, unsigned long long d)
523
+ msgpack_pack_inline_func_cint(_unsigned_long_long)(msgpack_pack_user x, unsigned long long d)
524
524
  {
525
525
  #if defined(SIZEOF_LONG_LONG) || defined(ULLONG_MAX)
526
526
  #if SIZEOF_LONG_LONG == 2 || ULLONG_MAX == 0xffffUL
@@ -550,17 +550,19 @@ if(sizeof(unsigned long long) == 2) {
550
550
  * Float
551
551
  */
552
552
 
553
- msgpack_pack_inline_func(float)(msgpack_pack_user x, float d)
553
+ msgpack_pack_inline_func(_float)(msgpack_pack_user x, float d)
554
554
  {
555
- uint32_t n = *((uint32_t*)&d); // FIXME
556
- const unsigned char buf[5] = {0xca, STORE_BE32(n)};
555
+ union { char buf[4]; uint32_t num; } f;
556
+ *((float*)&f.buf) = d; // FIXME
557
+ const unsigned char buf[5] = {0xca, STORE_BE32(f.num)};
557
558
  msgpack_pack_append_buffer(x, buf, 5);
558
559
  }
559
560
 
560
- msgpack_pack_inline_func(double)(msgpack_pack_user x, double d)
561
+ msgpack_pack_inline_func(_double)(msgpack_pack_user x, double d)
561
562
  {
562
- uint64_t n = *((uint64_t*)&d); // FIXME
563
- const unsigned char buf[9] = {0xcb, STORE_BE64(n)};
563
+ union { char buf[8]; uint64_t num; } f;
564
+ *((double*)&f.buf) = d; // FIXME
565
+ const unsigned char buf[9] = {0xcb, STORE_BE64(f.num)};
564
566
  msgpack_pack_append_buffer(x, buf, 9);
565
567
  }
566
568
 
@@ -569,7 +571,7 @@ msgpack_pack_inline_func(double)(msgpack_pack_user x, double d)
569
571
  * Nil
570
572
  */
571
573
 
572
- msgpack_pack_inline_func(nil)(msgpack_pack_user x)
574
+ msgpack_pack_inline_func(_nil)(msgpack_pack_user x)
573
575
  {
574
576
  static const unsigned char d = 0xc0;
575
577
  msgpack_pack_append_buffer(x, &d, 1);
@@ -580,13 +582,13 @@ msgpack_pack_inline_func(nil)(msgpack_pack_user x)
580
582
  * Boolean
581
583
  */
582
584
 
583
- msgpack_pack_inline_func(true)(msgpack_pack_user x)
585
+ msgpack_pack_inline_func(_true)(msgpack_pack_user x)
584
586
  {
585
587
  static const unsigned char d = 0xc3;
586
588
  msgpack_pack_append_buffer(x, &d, 1);
587
589
  }
588
590
 
589
- msgpack_pack_inline_func(false)(msgpack_pack_user x)
591
+ msgpack_pack_inline_func(_false)(msgpack_pack_user x)
590
592
  {
591
593
  static const unsigned char d = 0xc2;
592
594
  msgpack_pack_append_buffer(x, &d, 1);
@@ -597,7 +599,7 @@ msgpack_pack_inline_func(false)(msgpack_pack_user x)
597
599
  * Array
598
600
  */
599
601
 
600
- msgpack_pack_inline_func(array)(msgpack_pack_user x, unsigned int n)
602
+ msgpack_pack_inline_func(_array)(msgpack_pack_user x, unsigned int n)
601
603
  {
602
604
  if(n < 16) {
603
605
  unsigned char d = 0x90 | n;
@@ -618,7 +620,7 @@ msgpack_pack_inline_func(array)(msgpack_pack_user x, unsigned int n)
618
620
  * Map
619
621
  */
620
622
 
621
- msgpack_pack_inline_func(map)(msgpack_pack_user x, unsigned int n)
623
+ msgpack_pack_inline_func(_map)(msgpack_pack_user x, unsigned int n)
622
624
  {
623
625
  if(n < 16) {
624
626
  unsigned char d = 0x80 | n;
@@ -639,7 +641,7 @@ msgpack_pack_inline_func(map)(msgpack_pack_user x, unsigned int n)
639
641
  * Raw
640
642
  */
641
643
 
642
- msgpack_pack_inline_func(raw)(msgpack_pack_user x, size_t l)
644
+ msgpack_pack_inline_func(_raw)(msgpack_pack_user x, size_t l)
643
645
  {
644
646
  if(l < 32) {
645
647
  unsigned char d = 0xa0 | l;
@@ -655,7 +657,7 @@ msgpack_pack_inline_func(raw)(msgpack_pack_user x, size_t l)
655
657
  }
656
658
  }
657
659
 
658
- msgpack_pack_inline_func(raw_body)(msgpack_pack_user x, const void* b, size_t l)
660
+ msgpack_pack_inline_func(_raw_body)(msgpack_pack_user x, const void* b, size_t l)
659
661
  {
660
662
  msgpack_pack_append_buffer(x, (const unsigned char*)b, l);
661
663
  }
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * MessagePack unpacking routine template
3
3
  *
4
- * Copyright (C) 2008 FURUHASHI Sadayuki
4
+ * Copyright (C) 2008-2009 FURUHASHI Sadayuki
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * MessagePack unpacking routine template
3
3
  *
4
- * Copyright (C) 2008 FURUHASHI Sadayuki
4
+ * Copyright (C) 2008-2009 FURUHASHI Sadayuki
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -41,38 +41,37 @@
41
41
  #endif
42
42
 
43
43
 
44
- msgpack_unpack_struct_decl(stack) {
44
+ msgpack_unpack_struct_decl(_stack) {
45
45
  msgpack_unpack_object obj;
46
46
  size_t count;
47
47
  unsigned int ct;
48
48
  msgpack_unpack_object map_key;
49
49
  };
50
50
 
51
- msgpack_unpack_struct_decl(context) {
52
- msgpack_unpack_user user; // must be first
51
+ msgpack_unpack_struct_decl(_context) {
52
+ msgpack_unpack_user user;
53
53
  unsigned int cs;
54
54
  unsigned int trail;
55
55
  unsigned int top;
56
- msgpack_unpack_struct(stack) stack[MSGPACK_MAX_STACK_SIZE];
56
+ msgpack_unpack_struct(_stack) stack[MSGPACK_MAX_STACK_SIZE];
57
57
  };
58
58
 
59
59
 
60
- msgpack_unpack_func(void, init)(msgpack_unpack_struct(context)* ctx)
60
+ msgpack_unpack_func(void, _init)(msgpack_unpack_struct(_context)* ctx)
61
61
  {
62
- /*memset(ctx, 0, sizeof( msgpack_unpack_struct(context) )); FIXME needed? */
63
62
  ctx->cs = CS_HEADER;
64
63
  ctx->trail = 0;
65
64
  ctx->top = 0;
66
- ctx->stack[0].obj = msgpack_unpack_callback(init)(&ctx->user);
65
+ ctx->stack[0].obj = msgpack_unpack_callback(_root)(&ctx->user);
67
66
  }
68
67
 
69
- msgpack_unpack_func(msgpack_unpack_object, data)(msgpack_unpack_struct(context)* unpacker)
68
+ msgpack_unpack_func(msgpack_unpack_object, _data)(msgpack_unpack_struct(_context)* ctx)
70
69
  {
71
- return (unpacker)->stack[0].obj;
70
+ return (ctx)->stack[0].obj;
72
71
  }
73
72
 
74
73
 
75
- msgpack_unpack_func(int, execute)(msgpack_unpack_struct(context)* ctx, const char* data, size_t len, size_t* off)
74
+ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const char* data, size_t len, size_t* off)
76
75
  {
77
76
  assert(len >= *off);
78
77
 
@@ -83,25 +82,23 @@ msgpack_unpack_func(int, execute)(msgpack_unpack_struct(context)* ctx, const cha
83
82
  unsigned int trail = ctx->trail;
84
83
  unsigned int cs = ctx->cs;
85
84
  unsigned int top = ctx->top;
86
- msgpack_unpack_struct(stack)* stack = ctx->stack;
85
+ msgpack_unpack_struct(_stack)* stack = ctx->stack;
87
86
  msgpack_unpack_user* user = &ctx->user;
88
87
 
89
88
  msgpack_unpack_object obj;
90
- msgpack_unpack_struct(stack)* c = NULL;
89
+ msgpack_unpack_struct(_stack)* c = NULL;
91
90
 
92
91
  int ret;
93
92
 
94
93
  #define push_simple_value(func) \
95
- obj = msgpack_unpack_callback(func)(user); \
96
- /*printf("obj %d\n",obj);*/ \
94
+ if(msgpack_unpack_callback(func)(user, &obj) < 0) { goto _failed; } \
97
95
  goto _push
98
96
  #define push_fixed_value(func, arg) \
99
- obj = msgpack_unpack_callback(func)(user, arg); \
100
- /*printf("obj %d\n",obj);*/ \
97
+ if(msgpack_unpack_callback(func)(user, arg, &obj) < 0) { goto _failed; } \
101
98
  goto _push
102
99
  #define push_variable_value(func, base, pos, len) \
103
- obj = msgpack_unpack_callback(func)(user, (const char*)base, (const char*)pos, len); \
104
- /*printf("obj %d\n",obj);*/ \
100
+ if(msgpack_unpack_callback(func)(user, \
101
+ (const char*)base, (const char*)pos, len, &obj) < 0) { goto _failed; } \
105
102
  goto _push
106
103
 
107
104
  #define again_fixed_trail(_cs, trail_len) \
@@ -115,7 +112,7 @@ msgpack_unpack_func(int, execute)(msgpack_unpack_struct(context)* ctx, const cha
115
112
  goto _fixed_trail_again
116
113
 
117
114
  #define start_container(func, count_, ct_) \
118
- stack[top].obj = msgpack_unpack_callback(func)(user, count_); \
115
+ if(msgpack_unpack_callback(func)(user, count_, &stack[top].obj) < 0) { goto _failed; } \
119
116
  if((count_) == 0) { obj = stack[top].obj; goto _push; } \
120
117
  if(top >= MSGPACK_MAX_STACK_SIZE) { goto _failed; } \
121
118
  stack[top].ct = ct_; \
@@ -139,19 +136,19 @@ msgpack_unpack_func(int, execute)(msgpack_unpack_struct(context)* ctx, const cha
139
136
  case CS_HEADER:
140
137
  switch(*p) {
141
138
  case 0x00 ... 0x7f: // Positive Fixnum
142
- push_fixed_value(uint8, *(uint8_t*)p);
139
+ push_fixed_value(_uint8, *(uint8_t*)p);
143
140
  case 0xe0 ... 0xff: // Negative Fixnum
144
- push_fixed_value(int8, *(int8_t*)p);
141
+ push_fixed_value(_int8, *(int8_t*)p);
145
142
  case 0xc0 ... 0xdf: // Variable
146
143
  switch(*p) {
147
144
  case 0xc0: // nil
148
- push_simple_value(nil);
145
+ push_simple_value(_nil);
149
146
  //case 0xc1: // string
150
147
  // again_terminal_trail(NEXT_CS(p), p+1);
151
148
  case 0xc2: // false
152
- push_simple_value(false);
149
+ push_simple_value(_false);
153
150
  case 0xc3: // true
154
- push_simple_value(true);
151
+ push_simple_value(_true);
155
152
  //case 0xc4:
156
153
  //case 0xc5:
157
154
  //case 0xc6:
@@ -188,9 +185,9 @@ msgpack_unpack_func(int, execute)(msgpack_unpack_struct(context)* ctx, const cha
188
185
  case 0xa0 ... 0xbf: // FixRaw
189
186
  again_fixed_trail_if_zero(ACS_RAW_VALUE, ((unsigned int)*p & 0x1f), _raw_zero);
190
187
  case 0x90 ... 0x9f: // FixArray
191
- start_container(array, ((unsigned int)*p) & 0x0f, CT_ARRAY_ITEM);
188
+ start_container(_array, ((unsigned int)*p) & 0x0f, CT_ARRAY_ITEM);
192
189
  case 0x80 ... 0x8f: // FixMap
193
- start_container(map, ((unsigned int)*p) & 0x0f, CT_MAP_KEY);
190
+ start_container(_map, ((unsigned int)*p) & 0x0f, CT_MAP_KEY);
194
191
 
195
192
  default:
196
193
  goto _failed;
@@ -208,28 +205,30 @@ msgpack_unpack_func(int, execute)(msgpack_unpack_struct(context)* ctx, const cha
208
205
  //case CS_
209
206
  //case CS_
210
207
  case CS_FLOAT: {
211
- uint32_t x = PTR_CAST_32(n); // FIXME
212
- push_fixed_value(float, *((float*)&x)); }
208
+ union { uint32_t num; char buf[4]; } f;
209
+ f.num = PTR_CAST_32(n); // FIXME
210
+ push_fixed_value(_float, *((float*)f.buf)); }
213
211
  case CS_DOUBLE: {
214
- uint64_t x = PTR_CAST_64(n); // FIXME
215
- push_fixed_value(double, *((double*)&x)); }
212
+ union { uint64_t num; char buf[8]; } f;
213
+ f.num = PTR_CAST_64(n); // FIXME
214
+ push_fixed_value(_double, *((double*)f.buf)); }
216
215
  case CS_UINT_8:
217
- push_fixed_value(uint8, (uint8_t)PTR_CAST_8(n));
216
+ push_fixed_value(_uint8, (uint8_t)PTR_CAST_8(n));
218
217
  case CS_UINT_16:
219
- push_fixed_value(uint16, (uint16_t)PTR_CAST_16(n));
218
+ push_fixed_value(_uint16, (uint16_t)PTR_CAST_16(n));
220
219
  case CS_UINT_32:
221
- push_fixed_value(uint32, (uint32_t)PTR_CAST_32(n));
220
+ push_fixed_value(_uint32, (uint32_t)PTR_CAST_32(n));
222
221
  case CS_UINT_64:
223
- push_fixed_value(uint64, (uint64_t)PTR_CAST_64(n));
222
+ push_fixed_value(_uint64, (uint64_t)PTR_CAST_64(n));
224
223
 
225
224
  case CS_INT_8:
226
- push_fixed_value(int8, (int8_t)PTR_CAST_8(n));
225
+ push_fixed_value(_int8, (int8_t)PTR_CAST_8(n));
227
226
  case CS_INT_16:
228
- push_fixed_value(int16, (int16_t)PTR_CAST_16(n));
227
+ push_fixed_value(_int16, (int16_t)PTR_CAST_16(n));
229
228
  case CS_INT_32:
230
- push_fixed_value(int32, (int32_t)PTR_CAST_32(n));
229
+ push_fixed_value(_int32, (int32_t)PTR_CAST_32(n));
231
230
  case CS_INT_64:
232
- push_fixed_value(int64, (int64_t)PTR_CAST_64(n));
231
+ push_fixed_value(_int64, (int64_t)PTR_CAST_64(n));
233
232
 
234
233
  //case CS_
235
234
  //case CS_
@@ -240,7 +239,7 @@ msgpack_unpack_func(int, execute)(msgpack_unpack_struct(context)* ctx, const cha
240
239
  //case ACS_BIG_INT_VALUE:
241
240
  //_big_int_zero:
242
241
  // // FIXME
243
- // push_variable_value(big_int, data, n, trail);
242
+ // push_variable_value(_big_int, data, n, trail);
244
243
 
245
244
  //case CS_BIG_FLOAT_16:
246
245
  // again_fixed_trail_if_zero(ACS_BIG_FLOAT_VALUE, (uint16_t)PTR_CAST_16(n), _big_float_zero);
@@ -249,7 +248,7 @@ msgpack_unpack_func(int, execute)(msgpack_unpack_struct(context)* ctx, const cha
249
248
  //case ACS_BIG_FLOAT_VALUE:
250
249
  //_big_float_zero:
251
250
  // // FIXME
252
- // push_variable_value(big_float, data, n, trail);
251
+ // push_variable_value(_big_float, data, n, trail);
253
252
 
254
253
  case CS_RAW_16:
255
254
  again_fixed_trail_if_zero(ACS_RAW_VALUE, (uint16_t)PTR_CAST_16(n), _raw_zero);
@@ -257,17 +256,19 @@ msgpack_unpack_func(int, execute)(msgpack_unpack_struct(context)* ctx, const cha
257
256
  again_fixed_trail_if_zero(ACS_RAW_VALUE, (uint32_t)PTR_CAST_32(n), _raw_zero);
258
257
  case ACS_RAW_VALUE:
259
258
  _raw_zero:
260
- push_variable_value(raw, data, n, trail);
259
+ push_variable_value(_raw, data, n, trail);
261
260
 
262
261
  case CS_ARRAY_16:
263
- start_container(array, (uint16_t)PTR_CAST_16(n), CT_ARRAY_ITEM);
262
+ start_container(_array, (uint16_t)PTR_CAST_16(n), CT_ARRAY_ITEM);
264
263
  case CS_ARRAY_32:
265
- start_container(array, (uint32_t)PTR_CAST_32(n), CT_ARRAY_ITEM);
264
+ /* FIXME security guard */
265
+ start_container(_array, (uint32_t)PTR_CAST_32(n), CT_ARRAY_ITEM);
266
266
 
267
267
  case CS_MAP_16:
268
- start_container(map, (uint16_t)PTR_CAST_16(n), CT_MAP_KEY);
268
+ start_container(_map, (uint16_t)PTR_CAST_16(n), CT_MAP_KEY);
269
269
  case CS_MAP_32:
270
- start_container(map, (uint32_t)PTR_CAST_32(n), CT_MAP_KEY);
270
+ /* FIXME security guard */
271
+ start_container(_map, (uint32_t)PTR_CAST_32(n), CT_MAP_KEY);
271
272
 
272
273
  default:
273
274
  goto _failed;
@@ -279,7 +280,7 @@ _push:
279
280
  c = &stack[top-1];
280
281
  switch(c->ct) {
281
282
  case CT_ARRAY_ITEM:
282
- msgpack_unpack_callback(array_item)(user, &c->obj, obj);
283
+ if(msgpack_unpack_callback(_array_item)(user, &c->obj, obj) < 0) { goto _failed; }
283
284
  if(--c->count == 0) {
284
285
  obj = c->obj;
285
286
  --top;
@@ -292,7 +293,7 @@ _push:
292
293
  c->ct = CT_MAP_VALUE;
293
294
  goto _header_again;
294
295
  case CT_MAP_VALUE:
295
- msgpack_unpack_callback(map_item)(user, &c->obj, c->map_key, obj);
296
+ if(msgpack_unpack_callback(_map_item)(user, &c->obj, c->map_key, obj) < 0) { goto _failed; }
296
297
  if(--c->count == 0) {
297
298
  obj = c->obj;
298
299
  --top;