Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

Data Structures | Macros | Functions
pack.c File Reference
`#include "ruby/encoding.h"`
`#include "internal.h"`
`#include <sys/types.h>`
`#include <ctype.h>`
`#include <errno.h>`
`#include <float.h>`
`#include "builtin.h"`
`#include "pack.rbinc"`

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 917 of file pack.c.

## ◆ BIGENDIAN_P

#define BIGENDIAN_P | ( |  | ) | 0

Definition at line 65 of file pack.c.

## ◆ castchar

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

## ◆ DOUBLE_CONVWITH

#define DOUBLE_CONVWITH | ( |  | x | ) | DOUBLE_SWAPPER x;

Definition at line 102 of file pack.c.

## ◆ FLOAT_CONVWITH

#define FLOAT_CONVWITH | ( |  | x | ) | FLOAT_SWAPPER x;

Definition at line 96 of file pack.c.

## ◆ hexdigits

#define hexdigits ruby_hexdigits

## ◆ HTOND

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

Definition at line 103 of file pack.c.

## ◆ HTONF

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

Definition at line 97 of file pack.c.

## ◆ HTOVD

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

Definition at line 104 of file pack.c.

## ◆ HTOVF

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

Definition at line 98 of file pack.c.

## ◆ MAX_INTEGER_PACK_SIZE

#define MAX_INTEGER_PACK_SIZE 8

Definition at line 108 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 69 of file pack.c.

## ◆ NATINT_LEN_Q

#define NATINT_LEN_Q 8

Definition at line 39 of file pack.c.

## ◆ NATINT_PACK

#define NATINT_PACK

Definition at line 43 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 105 of file pack.c.

## ◆ NTOHF

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

Definition at line 99 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)

Definition at line 905 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)

Definition at line 895 of file pack.c.

## ◆ rb_htond

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

Definition at line 90 of file pack.c.

## ◆ rb_htonf

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

Definition at line 89 of file pack.c.

## ◆ rb_htovd

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

Definition at line 92 of file pack.c.

## ◆ rb_htovf

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

Definition at line 91 of file pack.c.

## ◆ rb_ntohd

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

Definition at line 88 of file pack.c.

## ◆ rb_ntohf

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

Definition at line 87 of file pack.c.

## ◆ rb_vtohd

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

Definition at line 94 of file pack.c.

## ◆ rb_vtohf

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

Definition at line 93 of file pack.c.

## ◆ swapd

#define swapd | ( |  | x | ) | swap64(x)

Definition at line 85 of file pack.c.

## ◆ swapf

#define swapf | ( |  | x | ) | swap32(x)

Definition at line 84 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 923 of file pack.c.

## ◆ UNPACK_ARRAY

#define UNPACK_ARRAY 0

Definition at line 921 of file pack.c.

## ◆ UNPACK_BLOCK

#define UNPACK_BLOCK 1

Definition at line 922 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)

## ◆ VTOHD

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

Definition at line 106 of file pack.c.

## ◆ VTOHF

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

Definition at line 100 of file pack.c.

## Function Documentation

## ◆ Init_pack()

void Init_pack | ( | void |  | ) |

Definition at line 1760 of file pack.c.

## ◆ rb_uv_to_utf8()

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

Definition at line 1651 of file pack.c.

References buf, castchar, char, Qnil, rb_eRangeError, rb_raise(), and UNREACHABLE_RETURN.

UNPACK_ARRAY
#define UNPACK_ARRAY
Definition: pack.c:921
UNPACK_BLOCK
#define UNPACK_BLOCK
Definition: pack.c:922
RARRAY_LEN
#define RARRAY_LEN(a)
Definition: ruby.h:1070
len
uint8_t len
Definition: escape.c:17
Qnil
#define Qnil
Definition: ruby.h:469