Ruby  2.5.0dev(2017-10-22revision60238)
Data Structures | Macros | Functions
pack.c File Reference
#include "internal.h"
#include <sys/types.h>
#include <ctype.h>
#include <errno.h>

Go to the source code of this file.

Data Structures

union  FLOAT_SWAPPER
 
union  DOUBLE_SWAPPER
 

Macros

#define NATINT_LEN_Q   8
 
#define NATINT_PACK
 
#define BIGENDIAN_P()   0
 
#define NATINT_LEN(type, len)   (natint?(int)sizeof(type):(int)(len))
 
#define swapf(x)   swap32(x)
 
#define swapd(x)   swap64(x)
 
#define rb_ntohf(x)   (BIGENDIAN_P()?(x):swapf(x))
 
#define rb_ntohd(x)   (BIGENDIAN_P()?(x):swapd(x))
 
#define rb_htonf(x)   (BIGENDIAN_P()?(x):swapf(x))
 
#define rb_htond(x)   (BIGENDIAN_P()?(x):swapd(x))
 
#define rb_htovf(x)   (BIGENDIAN_P()?swapf(x):(x))
 
#define rb_htovd(x)   (BIGENDIAN_P()?swapd(x):(x))
 
#define rb_vtohf(x)   (BIGENDIAN_P()?swapf(x):(x))
 
#define rb_vtohd(x)   (BIGENDIAN_P()?swapd(x):(x))
 
#define FLOAT_CONVWITH(x)   FLOAT_SWAPPER x;
 
#define HTONF(x)   ((x).u = rb_htonf((x).u))
 
#define HTOVF(x)   ((x).u = rb_htovf((x).u))
 
#define NTOHF(x)   ((x).u = rb_ntohf((x).u))
 
#define VTOHF(x)   ((x).u = rb_vtohf((x).u))
 
#define DOUBLE_CONVWITH(x)   DOUBLE_SWAPPER x;
 
#define HTOND(x)   ((x).u = rb_htond((x).u))
 
#define HTOVD(x)   ((x).u = rb_htovd((x).u))
 
#define NTOHD(x)   ((x).u = rb_ntohd((x).u))
 
#define VTOHD(x)   ((x).u = rb_vtohd((x).u))
 
#define MAX_INTEGER_PACK_SIZE   8
 
#define TOO_FEW   (rb_raise(rb_eArgError, toofew), 0)
 
#define MORE_ITEM   (idx < RARRAY_LEN(ary))
 
#define THISFROM   (MORE_ITEM ? RARRAY_AREF(ary, idx) : TOO_FEW)
 
#define NEXTFROM   (MORE_ITEM ? RARRAY_AREF(ary, idx++) : TOO_FEW)
 
#define castchar(from)   (char)((from) & 0xff)
 
#define PACK_LENGTH_ADJUST_SIZE(sz)
 
#define PACK_ITEM_ADJUST()
 
#define AVOID_CC_BUG
 
#define UNPACK_ARRAY   0
 
#define UNPACK_BLOCK   1
 
#define UNPACK_1   2
 
#define hexdigits   ruby_hexdigits
 
#define UNPACK_PUSH(item)
 

Functions

int rb_uv_to_utf8 (char buf[6], unsigned long uv)
 
void Init_pack (void)
 

Macro Definition Documentation

◆ AVOID_CC_BUG

#define AVOID_CC_BUG

Definition at line 1020 of file pack.c.

◆ BIGENDIAN_P

#define BIGENDIAN_P ( )    0

Definition at line 62 of file pack.c.

◆ castchar

#define castchar (   from)    (char)((from) & 0xff)

Referenced by rb_uv_to_utf8().

◆ DOUBLE_CONVWITH

#define DOUBLE_CONVWITH (   x)    DOUBLE_SWAPPER x;

Definition at line 99 of file pack.c.

◆ FLOAT_CONVWITH

#define FLOAT_CONVWITH (   x)    FLOAT_SWAPPER x;

Definition at line 93 of file pack.c.

◆ hexdigits

#define hexdigits   ruby_hexdigits

◆ HTOND

#define HTOND (   x)    ((x).u = rb_htond((x).u))

Definition at line 100 of file pack.c.

◆ HTONF

#define HTONF (   x)    ((x).u = rb_htonf((x).u))

Definition at line 94 of file pack.c.

◆ HTOVD

#define HTOVD (   x)    ((x).u = rb_htovd((x).u))

Definition at line 101 of file pack.c.

◆ HTOVF

#define HTOVF (   x)    ((x).u = rb_htovf((x).u))

Definition at line 95 of file pack.c.

◆ MAX_INTEGER_PACK_SIZE

#define MAX_INTEGER_PACK_SIZE   8

Definition at line 105 of file pack.c.

◆ MORE_ITEM

#define MORE_ITEM   (idx < RARRAY_LEN(ary))

◆ NATINT_LEN

#define NATINT_LEN (   type,
  len 
)    (natint?(int)sizeof(type):(int)(len))

Definition at line 66 of file pack.c.

◆ NATINT_LEN_Q

#define NATINT_LEN_Q   8

Definition at line 36 of file pack.c.

◆ NATINT_PACK

#define NATINT_PACK

Definition at line 40 of file pack.c.

◆ NEXTFROM

#define NEXTFROM   (MORE_ITEM ? RARRAY_AREF(ary, idx++) : TOO_FEW)

◆ NTOHD

#define NTOHD (   x)    ((x).u = rb_ntohd((x).u))

Definition at line 102 of file pack.c.

◆ NTOHF

#define NTOHF (   x)    ((x).u = rb_ntohf((x).u))

Definition at line 96 of file pack.c.

◆ PACK_ITEM_ADJUST

#define PACK_ITEM_ADJUST ( )
Value:
do { \
if (tmp_len > 0 && mode == UNPACK_ARRAY) \
rb_ary_store(ary, RARRAY_LEN(ary)+tmp_len-1, Qnil); \
} while (0)
#define RARRAY_LEN(a)
Definition: ruby.h:1019
#define Qnil
Definition: ruby.h:438
#define UNPACK_ARRAY
Definition: pack.c:1033

Definition at line 1009 of file pack.c.

◆ PACK_LENGTH_ADJUST_SIZE

#define PACK_LENGTH_ADJUST_SIZE (   sz)
Value:
do { \
tmp_len = 0; \
if (len > (long)((send-s)/(sz))) { \
if (!star) { \
tmp_len = len-(send-s)/(sz); \
} \
len = (send-s)/(sz); \
} \
} while (0)
register unsigned int len
Definition: zonetab.h:51

Definition at line 999 of file pack.c.

◆ rb_htond

#define rb_htond (   x)    (BIGENDIAN_P()?(x):swapd(x))

Definition at line 87 of file pack.c.

◆ rb_htonf

#define rb_htonf (   x)    (BIGENDIAN_P()?(x):swapf(x))

Definition at line 86 of file pack.c.

◆ rb_htovd

#define rb_htovd (   x)    (BIGENDIAN_P()?swapd(x):(x))

Definition at line 89 of file pack.c.

◆ rb_htovf

#define rb_htovf (   x)    (BIGENDIAN_P()?swapf(x):(x))

Definition at line 88 of file pack.c.

◆ rb_ntohd

#define rb_ntohd (   x)    (BIGENDIAN_P()?(x):swapd(x))

Definition at line 85 of file pack.c.

◆ rb_ntohf

#define rb_ntohf (   x)    (BIGENDIAN_P()?(x):swapf(x))

Definition at line 84 of file pack.c.

◆ rb_vtohd

#define rb_vtohd (   x)    (BIGENDIAN_P()?swapd(x):(x))

Definition at line 91 of file pack.c.

◆ rb_vtohf

#define rb_vtohf (   x)    (BIGENDIAN_P()?swapf(x):(x))

Definition at line 90 of file pack.c.

◆ swapd

#define swapd (   x)    swap64(x)

Definition at line 82 of file pack.c.

◆ swapf

#define swapf (   x)    swap32(x)

Definition at line 81 of file pack.c.

◆ THISFROM

#define THISFROM   (MORE_ITEM ? RARRAY_AREF(ary, idx) : TOO_FEW)

◆ TOO_FEW

#define TOO_FEW   (rb_raise(rb_eArgError, toofew), 0)

◆ UNPACK_1

#define UNPACK_1   2

Definition at line 1035 of file pack.c.

◆ UNPACK_ARRAY

#define UNPACK_ARRAY   0

Definition at line 1033 of file pack.c.

◆ UNPACK_BLOCK

#define UNPACK_BLOCK   1

Definition at line 1034 of file pack.c.

◆ UNPACK_PUSH

#define UNPACK_PUSH (   item)
Value:
do {\
VALUE item_val = (item);\
if ((mode) == UNPACK_BLOCK) {\
rb_yield(item_val);\
}\
else if ((mode) == UNPACK_ARRAY) {\
rb_ary_push(ary, item_val);\
}\
else /* if ((mode) == UNPACK_1) { */ {\
return item_val; \
}\
} while (0)
#define UNPACK_ARRAY
Definition: pack.c:1033
#define UNPACK_BLOCK
Definition: pack.c:1034

◆ VTOHD

#define VTOHD (   x)    ((x).u = rb_vtohd((x).u))

Definition at line 103 of file pack.c.

◆ VTOHF

#define VTOHF (   x)    ((x).u = rb_vtohf((x).u))

Definition at line 97 of file pack.c.

Function Documentation

◆ Init_pack()

void Init_pack ( void  )

Definition at line 2000 of file pack.c.

References rb_cArray, and rb_define_method().

◆ rb_uv_to_utf8()

int rb_uv_to_utf8 ( char  buf[6],
unsigned long  uv 
)

Definition at line 1893 of file pack.c.

References castchar, rb_eRangeError, rb_raise(), and UNREACHABLE.