8000 remove msgpack_pack* macros · peter80/msgpack-python@c91131f · GitHub
[go: up one dir, main page]

Skip to content

Commit c91131f

Browse files
committed
remove msgpack_pack* macros
1 parent 944b41e commit c91131f

File tree

2 files changed

+25
-103
lines changed

2 files changed

+25
-103
lines changed

msgpack/pack.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,6 @@ static inline int msgpack_pack_write(msgpack_packer* pk, const char *data, size_
9090
return 0;
9191
}
9292

93-
#define msgpack_pack_inline_func(name) \
94-
static inline int msgpack_pack ## name
95-
96-
#define msgpack_pack_inline_func_cint(name) \
97-
static inline int msgpack_pack ## name
98-
99-
#define msgpack_pack_user msgpack_packer*
100-
10193
#define msgpack_pack_append_buffer(user, buf, len) \
10294
return msgpack_pack_write(user, (const char*)buf, len)
10395

msgpack/pack_template.h

Lines changed: 25 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,6 @@
2828
#define TAKE8_64(d) ((uint8_t*)&d)[7]
2929
#endif
3030

31-
#ifndef msgpack_pack_inline_func
32-
#error msgpack_pack_inline_func template is not defined
33-
#endif
34-
35-
#ifndef msgpack_pack_user
36-
#error msgpack_pack_user type is not defined
37-
#endif
38-
3931
#ifndef msgpack_pack_append_buffer
4032
#error msgpack_pack_append_buffer callback is not defined
4133
#endif
@@ -272,110 +264,50 @@ do { \
272264
} while(0)
273265

274266

275-
#ifdef msgpack_pack_inline_func_fixint
276-
277-
msgpack_pack_inline_func_fixint(_uint8)(msgpack_pack_user x, uint8_t d)
278-
{
279-
unsigned char buf[2] = {0xcc, TAKE8_8(d)};
280-
msgpack_pack_append_buffer(x, buf, 2);
281-
}
282-
283-
msgpack_pack_inline_func_fixint(_uint16)(msgpack_pack_user x, uint16_t d)
284-
{
285-
unsigned char buf[3];
286-
buf[0] = 0xcd; _msgpack_store16(&buf[1], d);
287-
msgpack_pack_append_buffer(x, buf, 3);
288-
}
289-
290-
msgpack_pack_inline_func_fixint(_uint32)(msgpack_pack_user x, uint32_t d)
291-
{
292-
unsigned char buf[5];
293-
buf[0] = 0xce; _msgpack_store32(&buf[1], d);
294-
msgpack_pack_append_buffer(x, buf, 5);
295-
}
296-
297-
msgpack_pack_inline_func_fixint(_uint64)(msgpack_pack_user x, uint64_t d)
298-
{
299-
unsigned char buf[9];
300-
buf[0] = 0xcf; _msgpack_store64(&buf[1], d);
301-
msgpack_pack_append_buffer(x, buf, 9);
302-
}
303-
304-
msgpack_pack_inline_func_fixint(_int8)(msgpack_pack_user x, int8_t d)
305-
{
306-
unsigned char buf[2] = {0xd0, TAKE8_8(d)};
307-
msgpack_pack_append_buffer(x, buf, 2);
308-
}
309-
310-
msgpack_pack_inline_func_fixint(_int16)(msgpack_pack_user x, int16_t d)
311-
{
312-
unsigned char buf[3];
313-
buf[0] = 0xd1; _msgpack_store16(&buf[1], d);
314-
msgpack_pack_append_buffer(x, buf, 3);
315-
}
316-
317-
msgpack_pack_inline_func_fixint(_int32)(msgpack_pack_user x, int32_t d)
318-
{
319-
unsigned char buf[5];
320-
buf[0] = 0xd2; _msgpack_store32(&buf[1], d);
321-
msgpack_pack_append_buffer(x, buf, 5);
322-
}
323-
324-
msgpack_pack_inline_func_fixint(_int64)(msgpack_pack_user x, int64_t d)
325-
{
326-
unsigned char buf[9];
327-
buf[0] = 0xd3; _msgpack_store64(&buf[1], d);
328-
msgpack_pack_append_buffer(x, buf, 9);
329-
}
330-
331-
#undef msgpack_pack_inline_func_fixint
332-
#endif
333-
334-
335-
msgpack_pack_inline_func(_uint8)(msgpack_pack_user x, uint8_t d)
267+
static inline int msgpack_pack_uint8(msgpack_packer* x, uint8_t d)
336268
{
337269
msgpack_pack_real_uint8(x, d);
338270
}
339271

340-
msgpack_pack_inline_func(_uint16)(msgpack_pack_user x, uint16_t d)
272+
static inline int msgpack_pack_uint16(msgpack_packer* x, uint16_t d)
341273
{
342274
msgpack_pack_real_uint16(x, d);
343275
}
344276

345-
msgpack_pack_inline_func(_uint32)(msgpack_pack_user x, uint32_t d)
277+
static inline int msgpack_pack_uint32(msgpack_packer* x, uint32_t d)
346278
{
347279
msgpack_pack_real_uint32(x, d);
348280
}
349281

350-
msgpack_pack_inline_func(_uint64)(msgpack_pack_user x, uint64_t d)
282+
static inline int msgpack_pack_uint64(msgpack_packer* x, uint64_t d)
351283
{
352284
msgpack_pack_real_uint64(x, d);
353285
}
354286

355-
msgpack_pack_inline_func(_int8)(msgpack_pack_user x, int8_t d)
287+
static inline int msgpack_pack_int8(msgpack_packer* x, int8_t d)
356288
{
357289
msgpack_pack_real_int8(x, d);
358290
}
359291

360-
msgpack_pack_inline_func(_int16)(msgpack_pack_user x, int16_t d)
292+
static inline int msgpack_pack_int16(msgpack_packer* x, int16_t d)
361293
{
362294
msgpack_pack_real_int16(x, d);
363295
}
364296

365-
msgpack_pack_inline_func(_int32)(msgpack_pack_user x, int32_t d)
297+
static inline int msgpack_pack_int32(msgpack_packer* x, int32_t d)
366298
{
367299
msgpack_pack_real_int32(x, d);
368300
}
369301

370-
msgpack_pack_inline_func(_int64)(msgpack_pack_user x, int64_t d)
302+
static inline int msgpack_pack_int64(msgpack_packer* x, int64_t d)
371303
{
372304
msgpack_pack_real_int64(x, d);
373305
}
374306

375307

376308
#ifdef msgpack_pack_inline_func_cint
377309

378-
msgpack_pack_inline_func_cint(_short)(msgpack_pack_user x, short d)
310+
static inline int msgpack_pack_short(msgpack_packer* x, short d)
379311
{
380312
#if defined(SIZEOF_SHORT)
381313
#if SIZEOF_SHORT == 2
@@ -406,7 +338,7 @@ if(sizeof(short) == 2) {
406338
#endif
407339
}
408340

409-
msgpack_pack_inline_func_cint(_int)(msgpack_pack_user x, int d)
341+
static inline int msgpack_pack_int(msgpack_packer* x, int d)
410342
{
411343
#if defined(SIZEOF_INT)
412344
#if SIZEOF_INT == 2
@@ -437,7 +369,7 @@ if(sizeof(int) == 2) {
437369
#endif
438370
}
439371

440-
msgpack_pack_inline_func_cint(_long)(msgpack_pack_user x, long d)
372+
static inline int msgpack_pack_long(msgpack_packer* x, long d)
441373
{
442374
#if defined(SIZEOF_LONG)
443375
#if SIZEOF_LONG == 2
@@ -468,7 +400,7 @@ if(sizeof(long) == 2) {
468400
#endif
469401
}
470402

471-
msgpack_pack_inline_func_cint(_long_long)(msgpack_pack_user x, long long d)
403+
static inline int msgpack_pack_long_long(msgpack_packer* x, long long d)
472404
{
473405
#if defined(SIZEOF_LONG_LONG)
474406
#if SIZEOF_LONG_LONG == 2
@@ -499,7 +431,7 @@ if(sizeof(long long) == 2) {
499431
#endif
500432
}
501433

502-
msgpack_pack_inline_func_cint(_unsigned_short)(msgpack_pack_user x, unsigned short d)
434+
static inline int msgpack_pack_unsigned_short(msgpack_packer* x, unsigned short d)
503435
{
504436
#if defined(SIZEOF_SHORT)
505437
#if SIZEOF_SHORT == 2
@@ -530,7 +462,7 @@ if(sizeof(unsigned short) == 2) {
530462
#endif
531463
}
532464

533-
msgpack_pack_inline_func_cint(_unsigned_int)(msgpack_pack_user x, unsigned int d)
465+
static inline int msgpack_pack_unsigned_int(msgpack_packer* x, unsigned int d)
534466
{
535467
#if defined(SIZEOF_INT)
536468
#if SIZEOF_INT == 2
@@ -561,7 +493,7 @@ if(sizeof(unsigned int) == 2) {
561493
#endif
562494
}
563495

564-
msgpack_pack_inline_func_cint(_unsigned_long)(msgpack_pack_user x, unsigned long d)
496+
static inline int msgpack_pack_unsigned_long(msgpack_packer* x, unsigned long d)
565497
{
566498
#if defined(SIZEOF_LONG)
567499
#if SIZEOF_LONG == 2
@@ -592,7 +524,7 @@ if(sizeof(unsigned long) == 2) {
592524
#endif
593525
}
594526

595-
msgpack_pack_inline_func_cint(_unsigned_long_long)(msgpack_pack_user x, unsigned long long d)
527+
static inline int msgpack_pack_unsigned_long_long(msgpack_packer* x, unsigned long long d)
596528
{
597529
#if defined(SIZEOF_LONG_LONG)
598530
#if SIZEOF_LONG_LONG == 2
@@ -632,7 +564,7 @@ if(sizeof(unsigned long long) == 2) {
632564
* Float
633565
*/
634566

635-
msgpack_pack_inline_func(_float)(msgpack_pack_user x, float d)
567+
static inline int msgpack_pack_float(msgpack_packer* x, float d)
636568
{
637569
union { float f; uint32_t i; } mem;
638570
mem.f = d;
@@ -641,7 +573,7 @@ msgpack_pack_inline_func(_float)(msgpack_pack_user x, float d)
641573
msgpack_pack_append_buffer(x, buf, 5);
642574
}
643575

644-
msgpack_pack_inline_func(_double)(msgpack_pack_user x, double d)
576+
static inline int msgpack_pack_double(msgpack_packer* x, double d)
645577
{
646578
union { double f; uint64_t i; } mem;
647579
mem.f = d;
@@ -660,7 +592,7 @@ msgpack_pack_inline_func(_double)(msgpack_pack_user x, double d)
660592
* Nil
661593
*/
662594

663-
msgpack_pack_inline_func(_nil)(msgpack_pack_user x)
595+
static inline int msgpack_pack_nil(msgpack_packer* x)
664596
{
665597
static const unsigned char d = 0xc0;
666598
msgpack_pack_append_buffer(x, &d, 1);
@@ -671,13 +603,13 @@ msgpack_pack_inline_func(_nil)(msgpack_pack_user x)
671603
* Boolean
672604
*/
673605

674-
msgpack_pack_inline_func(_true)(msgpack_pack_user x)
606+
static inline int msgpack_pack_true(msgpack_packer* x)
675607
{
676608
static const unsigned char d = 0xc3;
677609
msgpack_pack_append_buffer(x, &d, 1);
678610
}
679611

680-
msgpack_pack_inline_func(_false)(msgpack_pack_user x)
612+
static inline int msgpack_pack_false(msgpack_packer* x)
681613
{
682614
static const unsigned char d = 0xc2;
683615
msgpack_pack_append_buffer(x, &d, 1);
@@ -688,7 +620,7 @@ msgpack_pack_inline_func(_false)(msgpack_pack_user x)
688620
* Array
689621
*/
690622

691-
msgpack_pack_inline_func(_array)(msgpack_pack_user x, unsigned int n)
623+
static inline int msgpack_pack_array(msgpack_packer* x, unsigned int n)
692624
{
693625
if(n < 16) {
694626
unsigned char d = 0x90 | n;
@@ -709,7 +641,7 @@ msgpack_pack_inline_func(_array)(msgpack_pack_user x, unsigned int n)
709641
* Map
710642
*/
711643

712-
msgpack_pack_inline_func(_map)(msgpack_pack_user x, unsigned int n)
644+
static inline int msgpack_pack_map(msgpack_packer* x, unsigned int n)
713645
{
714646
if(n < 16) {
715647
unsigned char d = 0x80 | n;
@@ -730,7 +662,7 @@ msgpack_pack_inline_func(_map)(msgpack_pack_user x, unsigned int n)
730662
* Raw
731663
*/
732664

733-
msgpack_pack_inline_func(_raw)(msgpack_pack_user x, size_t l)
665+
static inline int msgpack_pack_raw(msgpack_packer* x, size_t l)
734666
{
735667
if(l < 32) {
736668
unsigned char d = 0xa0 | (uint8_t)l;
@@ -746,13 +678,11 @@ msgpack_pack_inline_func(_raw)(msgpack_pack_user x, size_t l)
746678
}
747679
}
748680

749-
msgpack_pack_inline_func(_raw_body)(msgpack_pack_user x, const void* b, size_t l)
681+
static inline int msgpack_pack_raw_body(msgpack_packer* x, const void* b, size_t l)
750682
{
751683
msgpack_pack_append_buffer(x, (const unsigned char*)b, l);
752684
}
753685

754-
#undef msgpack_pack_inline_func
755-
#undef msgpack_pack_user
756686
#undef msgpack_pack_append_buffer
757687

758688
#undef TAKE8_8

0 commit comments

Comments
 (0)
0