Ruby  2.4.2p198(2017-09-14revision59899)
Data Structures | Macros | Functions | Variables
marshal.c File Reference
#include "internal.h"
#include "ruby/io.h"
#include "ruby/st.h"
#include "ruby/util.h"
#include "encindex.h"
#include "id_table.h"
#include <math.h>
Include dependency graph for marshal.c:

Go to the source code of this file.

Data Structures

struct  marshal_compat_t
 
struct  dump_arg
 
struct  dump_call_arg
 
struct  load_arg
 

Macros

#define BITSPERSHORT   (2*CHAR_BIT)
 
#define SHORTMASK   ((1<<BITSPERSHORT)-1)
 
#define SHORTDN(x)   RSHIFT((x),BITSPERSHORT)
 
#define SHORTLEN(x)   (x)
 
#define MARSHAL_MAJOR   4
 
#define MARSHAL_MINOR   8
 
#define TYPE_NIL   '0'
 
#define TYPE_TRUE   'T'
 
#define TYPE_FALSE   'F'
 
#define TYPE_FIXNUM   'i'
 
#define TYPE_EXTENDED   'e'
 
#define TYPE_UCLASS   'C'
 
#define TYPE_OBJECT   'o'
 
#define TYPE_DATA   'd'
 
#define TYPE_USERDEF   'u'
 
#define TYPE_USRMARSHAL   'U'
 
#define TYPE_FLOAT   'f'
 
#define TYPE_BIGNUM   'l'
 
#define TYPE_STRING   '"'
 
#define TYPE_REGEXP   '/'
 
#define TYPE_ARRAY   '['
 
#define TYPE_HASH   '{'
 
#define TYPE_HASH_DEF   '}'
 
#define TYPE_STRUCT   'S'
 
#define TYPE_MODULE_OLD   'M'
 
#define TYPE_CLASS   'c'
 
#define TYPE_MODULE   'm'
 
#define TYPE_SYMBOL   ':'
 
#define TYPE_SYMLINK   ';'
 
#define TYPE_IVAR   'I'
 
#define TYPE_LINK   '@'
 
#define name_s_dump   "_dump"
 
#define name_s_load   "_load"
 
#define name_s_mdump   "marshal_dump"
 
#define name_s_mload   "marshal_load"
 
#define name_s_dump_data   "_dump_data"
 
#define name_s_load_data   "_load_data"
 
#define name_s_alloc   "_alloc"
 
#define name_s_call   "call"
 
#define name_s_getbyte   "getbyte"
 
#define name_s_read   "read"
 
#define name_s_write   "write"
 
#define name_s_binmode   "binmode"
 
#define MARSHAL_INFECTION   FL_TAINT
 
#define dump_funcall(arg, obj, sym, argc, argv)   check_userdump_arg(obj, sym, argc, argv, arg, name_##sym)
 
#define dump_check_funcall(arg, obj, sym, argc, argv)   check_dump_arg(rb_check_funcall(obj, sym, argc, argv), arg, name_##sym)
 
#define w_cstr(s, arg)   w_bytes((s), strlen(s), (arg))
 
#define load_mantissa(d, buf, len)   (d)
 
#define FLOAT_DIG   17
 
#define SINGLETON_DUMP_UNABLE_P(klass)
 
#define to_be_skipped_id(id)   (id == rb_id_encoding() || id == rb_intern("E") || !rb_id2str(id))
 
#define load_funcall(arg, obj, sym, argc, argv)   check_load_arg(rb_funcallv(obj, sym, argc, argv), arg, name_##sym)
 
#define r_entry(v, arg)   r_entry0((v), (arg)->data->num_entries, (arg))
 
#define r_bytes(arg)   r_bytes0(r_long(arg), (arg))
 
#define path2module(path)   must_be_module(rb_path_to_class(path), path)
 
#define prohibit_ivar(type, str)
 
#define rb_intern(str)   rb_intern_const(str)
 
#define set_id(sym)   sym = rb_intern_const(name_##sym)
 
#define RUBY_UNTYPED_DATA_WARNING   0
 

Functions

static VALUE rb_marshal_dump_limited (VALUE obj, VALUE port, int limit)
 
static VALUE rb_marshal_load_with_proc (VALUE port, VALUE proc)
 
static int mark_marshal_compat_i (st_data_t key, st_data_t value)
 
static void mark_marshal_compat_t (void *tbl)
 
static st_tablecompat_allocator_table (void)
 
void rb_marshal_define_compat (VALUE newclass, VALUE oldclass, VALUE(*dumper)(VALUE), VALUE(*loader)(VALUE, VALUE))
 
 STATIC_ASSERT (marshal_infection_is_int, MARSHAL_INFECTION==(int) MARSHAL_INFECTION)
 
static VALUE check_dump_arg (VALUE ret, struct dump_arg *arg, const char *name)
 
static VALUE check_userdump_arg (VALUE obj, ID sym, int argc, const VALUE *argv, struct dump_arg *arg, const char *name)
 
static void clear_dump_arg (struct dump_arg *arg)
 
static void mark_dump_arg (void *ptr)
 
static void free_dump_arg (void *ptr)
 
static size_t memsize_dump_arg (const void *ptr)
 
static VALUE must_not_be_anonymous (const char *type, VALUE path)
 
static VALUE class2path (VALUE klass)
 
static void w_long (long, struct dump_arg *)
 
static void w_encoding (VALUE encname, struct dump_call_arg *arg)
 
static VALUE encoding_name (VALUE obj, struct dump_arg *arg)
 
static void w_nbyte (const char *s, long n, struct dump_arg *arg)
 
static void w_byte (char c, struct dump_arg *arg)
 
static void w_bytes (const char *s, long n, struct dump_arg *arg)
 
static void w_short (int x, struct dump_arg *arg)
 
static void w_float (double d, struct dump_arg *arg)
 
static void w_symbol (VALUE sym, struct dump_arg *arg)
 
static void w_unique (VALUE s, struct dump_arg *arg)
 
static void w_object (VALUE, struct dump_arg *, int)
 
static int hash_each (VALUE key, VALUE value, struct dump_call_arg *arg)
 
static void w_extended (VALUE klass, struct dump_arg *arg, int check)
 
static void w_class (char type, VALUE obj, struct dump_arg *arg, int check)
 
static void w_uclass (VALUE obj, VALUE super, struct dump_arg *arg)
 
static int w_obj_each (st_data_t key, st_data_t val, st_data_t a)
 
static int obj_count_ivars (st_data_t key, st_data_t val, st_data_t a)
 
static st_index_t has_ivars (VALUE obj, VALUE encname, VALUE *ivobj)
 
static void w_ivar (st_index_t num, VALUE ivobj, VALUE encname, struct dump_call_arg *arg)
 
static void w_objivar (VALUE obj, struct dump_call_arg *arg)
 
 NORETURN (static inline void io_needed(void))
 
static void io_needed (void)
 
static VALUE marshal_dump (int argc, VALUE *argv)
 
static VALUE check_load_arg (VALUE ret, struct load_arg *arg, const char *name)
 
static void clear_load_arg (struct load_arg *arg)
 
static void mark_load_arg (void *ptr)
 
static void free_load_arg (void *ptr)
 
static size_t memsize_load_arg (const void *ptr)
 
static VALUE r_entry0 (VALUE v, st_index_t num, struct load_arg *arg)
 
static VALUE r_object (struct load_arg *arg)
 
static VALUE r_symbol (struct load_arg *arg)
 
static VALUE path2class (VALUE path)
 
 NORETURN (static void too_short(void))
 
static void too_short (void)
 
static st_index_t r_prepare (struct load_arg *arg)
 
static unsigned char r_byte1_buffered (struct load_arg *arg)
 
static int r_byte (struct load_arg *arg)
 
static void long_toobig (int size)
 
static long r_long (struct load_arg *arg)
 
static VALUE r_bytes1 (long len, struct load_arg *arg)
 
static VALUE r_bytes1_buffered (long len, struct load_arg *arg)
 
static VALUE r_bytes0 (long len, struct load_arg *arg)
 
static int sym2encidx (VALUE sym, VALUE val)
 
static VALUE r_symlink (struct load_arg *arg)
 
static VALUE r_symreal (struct load_arg *arg, int ivar)
 
static VALUE r_unique (struct load_arg *arg)
 
static VALUE r_string (struct load_arg *arg)
 
static VALUE r_fixup_compat (VALUE v, struct load_arg *arg)
 
static VALUE r_post_proc (VALUE v, struct load_arg *arg)
 
static VALUE r_leave (VALUE v, struct load_arg *arg)
 
static int copy_ivar_i (st_data_t key, st_data_t val, st_data_t arg)
 
static VALUE r_copy_ivar (VALUE v, VALUE data)
 
static void r_ivar (VALUE obj, int *has_encoding, struct load_arg *arg)
 
static VALUE must_be_module (VALUE v, VALUE path)
 
static VALUE obj_alloc_by_klass (VALUE klass, struct load_arg *arg, VALUE *oldclass)
 
static VALUE obj_alloc_by_path (VALUE path, struct load_arg *arg)
 
static VALUE append_extmod (VALUE obj, VALUE extmod)
 
static VALUE r_object0 (struct load_arg *arg, int *ivp, VALUE extmod)
 
static VALUE marshal_load (int argc, VALUE *argv)
 
void Init_marshal (void)
 
VALUE rb_marshal_dump (VALUE obj, VALUE port)
 
VALUE rb_marshal_load (VALUE port)
 

Variables

static ID s_dump
 
static ID s_load
 
static ID s_mdump
 
static ID s_mload
 
static ID s_dump_data
 
static ID s_load_data
 
static ID s_alloc
 
static ID s_call
 
static ID s_getbyte
 
static ID s_read
 
static ID s_write
 
static ID s_binmode
 
static st_tablecompat_allocator_tbl
 
static VALUE compat_allocator_tbl_wrapper
 
static const rb_data_type_t dump_arg_data
 
static const rb_data_type_t load_arg_data
 

Macro Definition Documentation

◆ BITSPERSHORT

#define BITSPERSHORT   (2*CHAR_BIT)

Definition at line 31 of file marshal.c.

◆ dump_check_funcall

#define dump_check_funcall (   arg,
  obj,
  sym,
  argc,
  argv 
)    check_dump_arg(rb_check_funcall(obj, sym, argc, argv), arg, name_##sym)

Definition at line 197 of file marshal.c.

Referenced by rb_marshal_dump_limited().

◆ dump_funcall

#define dump_funcall (   arg,
  obj,
  sym,
  argc,
  argv 
)    check_userdump_arg(obj, sym, argc, argv, arg, name_##sym)

Definition at line 195 of file marshal.c.

Referenced by w_object().

◆ FLOAT_DIG

#define FLOAT_DIG   17

Definition at line 391 of file marshal.c.

Referenced by w_float().

◆ load_funcall

#define load_funcall (   arg,
  obj,
  sym,
  argc,
  argv 
)    check_load_arg(rb_funcallv(obj, sym, argc, argv), arg, name_##sym)

◆ load_mantissa

#define load_mantissa (   d,
  buf,
  len 
)    (d)

Definition at line 385 of file marshal.c.

Referenced by r_object0(), and w_long().

◆ MARSHAL_INFECTION

#define MARSHAL_INFECTION   FL_TAINT

◆ MARSHAL_MAJOR

#define MARSHAL_MAJOR   4

Definition at line 54 of file marshal.c.

Referenced by Init_marshal(), rb_marshal_dump_limited(), and rb_marshal_load_with_proc().

◆ MARSHAL_MINOR

#define MARSHAL_MINOR   8

Definition at line 55 of file marshal.c.

Referenced by Init_marshal(), rb_marshal_dump_limited(), and rb_marshal_load_with_proc().

◆ name_s_alloc

#define name_s_alloc   "_alloc"

Definition at line 96 of file marshal.c.

◆ name_s_binmode

#define name_s_binmode   "binmode"

Definition at line 101 of file marshal.c.

◆ name_s_call

#define name_s_call   "call"

Definition at line 97 of file marshal.c.

◆ name_s_dump

#define name_s_dump   "_dump"

Definition at line 90 of file marshal.c.

◆ name_s_dump_data

#define name_s_dump_data   "_dump_data"

Definition at line 94 of file marshal.c.

◆ name_s_getbyte

#define name_s_getbyte   "getbyte"

Definition at line 98 of file marshal.c.

◆ name_s_load

#define name_s_load   "_load"

Definition at line 91 of file marshal.c.

◆ name_s_load_data

#define name_s_load_data   "_load_data"

Definition at line 95 of file marshal.c.

◆ name_s_mdump

#define name_s_mdump   "marshal_dump"

Definition at line 92 of file marshal.c.

◆ name_s_mload

#define name_s_mload   "marshal_load"

Definition at line 93 of file marshal.c.

◆ name_s_read

#define name_s_read   "read"

Definition at line 99 of file marshal.c.

◆ name_s_write

#define name_s_write   "write"

Definition at line 100 of file marshal.c.

◆ path2module

#define path2module (   path)    must_be_module(rb_path_to_class(path), path)

Definition at line 1507 of file marshal.c.

Referenced by r_object0().

◆ prohibit_ivar

#define prohibit_ivar (   type,
  str 
)
Value:
do { \
if (!ivp || !*ivp) break; \
rb_raise(rb_eTypeError, \
"can't override instance variable of "type" `%"PRIsVALUE"'", \
(str)); \
} while (0)
VALUE rb_eTypeError
Definition: error.c:762
#define PRIsVALUE
Definition: ruby.h:135

Definition at line 1558 of file marshal.c.

Referenced by r_object0().

◆ r_bytes

#define r_bytes (   arg)    r_bytes0(r_long(arg), (arg))

Definition at line 1285 of file marshal.c.

Referenced by r_object0(), r_string(), and r_symreal().

◆ r_entry

#define r_entry (   v,
  arg 
)    r_entry0((v), (arg)->data->num_entries, (arg))

Definition at line 1119 of file marshal.c.

Referenced by r_object0().

◆ rb_intern

#define rb_intern (   str)    rb_intern_const(str)

Referenced by w_encoding().

◆ RUBY_UNTYPED_DATA_WARNING

#define RUBY_UNTYPED_DATA_WARNING   0

◆ set_id

#define set_id (   sym)    sym = rb_intern_const(name_##sym)

Referenced by Init_marshal().

◆ SHORTDN

#define SHORTDN (   x)    RSHIFT((x),BITSPERSHORT)

Definition at line 33 of file marshal.c.

Referenced by w_object().

◆ SHORTLEN

#define SHORTLEN (   x)    (x)

Definition at line 36 of file marshal.c.

Referenced by w_object().

◆ SHORTMASK

#define SHORTMASK   ((1<<BITSPERSHORT)-1)

Definition at line 32 of file marshal.c.

Referenced by w_object().

◆ SINGLETON_DUMP_UNABLE_P

#define SINGLETON_DUMP_UNABLE_P (   klass)
Value:
(rb_id_table_size(RCLASS_M_TBL(klass)) > 0 || \
(RCLASS_IV_TBL(klass) && RCLASS_IV_TBL(klass)->num_entries > 1))
#define RCLASS_IV_TBL(c)
Definition: internal.h:688
size_t rb_id_table_size(const struct rb_id_table *tbl)
#define RCLASS_M_TBL(c)
Definition: internal.h:690

Definition at line 500 of file marshal.c.

Referenced by w_extended().

◆ to_be_skipped_id

#define to_be_skipped_id (   id)    (id == rb_id_encoding() || id == rb_intern("E") || !rb_id2str(id))

Definition at line 554 of file marshal.c.

Referenced by obj_count_ivars(), and w_obj_each().

◆ TYPE_ARRAY

#define TYPE_ARRAY   '['

Definition at line 72 of file marshal.c.

Referenced by r_object0(), and w_object().

◆ TYPE_BIGNUM

#define TYPE_BIGNUM   'l'

Definition at line 69 of file marshal.c.

Referenced by r_object0(), and w_object().

◆ TYPE_CLASS

#define TYPE_CLASS   'c'

Definition at line 77 of file marshal.c.

Referenced by r_object0(), and w_object().

◆ TYPE_DATA

#define TYPE_DATA   'd'

Definition at line 65 of file marshal.c.

Referenced by r_object0(), and w_object().

◆ TYPE_EXTENDED

#define TYPE_EXTENDED   'e'

Definition at line 62 of file marshal.c.

Referenced by r_object0(), and w_extended().

◆ TYPE_FALSE

#define TYPE_FALSE   'F'

Definition at line 59 of file marshal.c.

Referenced by r_object0(), and w_object().

◆ TYPE_FIXNUM

#define TYPE_FIXNUM   'i'

Definition at line 60 of file marshal.c.

Referenced by r_object0(), and w_object().

◆ TYPE_FLOAT

#define TYPE_FLOAT   'f'

Definition at line 68 of file marshal.c.

Referenced by r_object0(), and w_object().

◆ TYPE_HASH

#define TYPE_HASH   '{'

Definition at line 73 of file marshal.c.

Referenced by r_object0(), and w_object().

◆ TYPE_HASH_DEF

#define TYPE_HASH_DEF   '}'

Definition at line 74 of file marshal.c.

Referenced by r_object0(), and w_object().

◆ TYPE_IVAR

#define TYPE_IVAR   'I'

Definition at line 83 of file marshal.c.

Referenced by r_object0(), r_symbol(), w_object(), and w_symbol().

◆ TYPE_LINK

#define TYPE_LINK   '@'

Definition at line 84 of file marshal.c.

Referenced by r_object0(), and w_object().

◆ TYPE_MODULE

#define TYPE_MODULE   'm'

Definition at line 78 of file marshal.c.

Referenced by r_object0(), and w_object().

◆ TYPE_MODULE_OLD

#define TYPE_MODULE_OLD   'M'

Definition at line 76 of file marshal.c.

Referenced by r_object0().

◆ TYPE_NIL

#define TYPE_NIL   '0'

Definition at line 57 of file marshal.c.

Referenced by r_object0(), and w_object().

◆ TYPE_OBJECT

#define TYPE_OBJECT   'o'

Definition at line 64 of file marshal.c.

Referenced by r_object0(), and w_object().

◆ TYPE_REGEXP

#define TYPE_REGEXP   '/'

Definition at line 71 of file marshal.c.

Referenced by r_object0(), and w_object().

◆ TYPE_STRING

#define TYPE_STRING   '"'

Definition at line 70 of file marshal.c.

Referenced by r_object0(), and w_object().

◆ TYPE_STRUCT

#define TYPE_STRUCT   'S'

Definition at line 75 of file marshal.c.

Referenced by r_object0(), and w_object().

◆ TYPE_SYMBOL

#define TYPE_SYMBOL   ':'

Definition at line 80 of file marshal.c.

Referenced by r_object0(), r_symbol(), and w_symbol().

◆ TYPE_SYMLINK

#define TYPE_SYMLINK   ';'

Definition at line 81 of file marshal.c.

Referenced by r_object0(), r_symbol(), and w_symbol().

◆ TYPE_TRUE

#define TYPE_TRUE   'T'

Definition at line 58 of file marshal.c.

Referenced by r_object0(), and w_object().

◆ TYPE_UCLASS

#define TYPE_UCLASS   'C'

Definition at line 63 of file marshal.c.

Referenced by r_object0(), and w_uclass().

◆ TYPE_USERDEF

#define TYPE_USERDEF   'u'

Definition at line 66 of file marshal.c.

Referenced by r_object0(), and w_object().

◆ TYPE_USRMARSHAL

#define TYPE_USRMARSHAL   'U'

Definition at line 67 of file marshal.c.

Referenced by r_object0(), and w_object().

◆ w_cstr

#define w_cstr (   s,
  arg 
)    w_bytes((s), strlen(s), (arg))

Definition at line 291 of file marshal.c.

Referenced by w_float().

Function Documentation

◆ append_extmod()

static VALUE append_extmod ( VALUE  obj,
VALUE  extmod 
)
static

Definition at line 1548 of file marshal.c.

References dump_call_arg::obj, RARRAY_AREF, RARRAY_LEN, and rb_extend_object().

Referenced by r_object0().

◆ check_dump_arg()

static VALUE check_dump_arg ( VALUE  ret,
struct dump_arg arg,
const char *  name 
)
static

Definition at line 173 of file marshal.c.

References rb_eRuntimeError, rb_raise(), and dump_arg::symbols.

Referenced by check_userdump_arg().

◆ check_load_arg()

static VALUE check_load_arg ( VALUE  ret,
struct load_arg arg,
const char *  name 
)
static

Definition at line 1076 of file marshal.c.

References rb_eRuntimeError, rb_raise(), and load_arg::symbols.

◆ check_userdump_arg()

static VALUE check_userdump_arg ( VALUE  obj,
ID  sym,
int  argc,
const VALUE argv,
struct dump_arg arg,
const char *  name 
)
static

Definition at line 183 of file marshal.c.

References check_dump_arg(), CLASS_OF, PRIsVALUE, rb_eRuntimeError, rb_funcallv, and rb_raise().

◆ class2path()

static VALUE class2path ( VALUE  klass)
static

◆ clear_dump_arg()

static void clear_dump_arg ( struct dump_arg arg)
static

◆ clear_load_arg()

static void clear_load_arg ( struct load_arg arg)
static

◆ compat_allocator_table()

static st_table * compat_allocator_table ( void  )
static

◆ copy_ivar_i()

static int copy_ivar_i ( st_data_t  key,
st_data_t  val,
st_data_t  arg 
)
static

Definition at line 1457 of file marshal.c.

References rb_ivar_defined(), rb_ivar_set(), ST_CONTINUE, and val.

Referenced by r_copy_ivar().

◆ encoding_name()

static VALUE encoding_name ( VALUE  obj,
struct dump_arg arg 
)
static

◆ free_dump_arg()

static void free_dump_arg ( void *  ptr)
static

Definition at line 215 of file marshal.c.

References clear_dump_arg(), and xfree().

◆ free_load_arg()

static void free_load_arg ( void *  ptr)
static

Definition at line 1101 of file marshal.c.

References clear_load_arg(), and xfree().

◆ has_ivars()

static st_index_t has_ivars ( VALUE  obj,
VALUE  encname,
VALUE ivobj 
)
static

◆ hash_each()

static int hash_each ( VALUE  key,
VALUE  value,
struct dump_call_arg arg 
)
static

Definition at line 493 of file marshal.c.

References dump_call_arg::arg, dump_call_arg::limit, ST_CONTINUE, and w_object().

Referenced by w_object().

◆ Init_marshal()

void Init_marshal ( void  )

◆ io_needed()

static void io_needed ( void  )
inlinestatic

◆ long_toobig()

static void long_toobig ( int  size)
static

Definition at line 1187 of file marshal.c.

References rb_eTypeError, rb_raise(), and STRINGIZE.

Referenced by r_long().

◆ mark_dump_arg()

static void mark_dump_arg ( void *  ptr)
static

◆ mark_load_arg()

static void mark_load_arg ( void *  ptr)
static

◆ mark_marshal_compat_i()

static int mark_marshal_compat_i ( st_data_t  key,
st_data_t  value 
)
static

◆ mark_marshal_compat_t()

static void mark_marshal_compat_t ( void *  tbl)
static

Definition at line 125 of file marshal.c.

References compat_allocator_table(), mark_marshal_compat_i(), and st_foreach.

Referenced by compat_allocator_table().

◆ marshal_dump()

static VALUE marshal_dump ( int  argc,
VALUE argv 
)
static

◆ marshal_load()

static VALUE marshal_load ( int  argc,
VALUE argv 
)
static

Definition at line 2026 of file marshal.c.

References Qnil, rb_check_arity, and rb_marshal_load_with_proc().

Referenced by Init_marshal().

◆ memsize_dump_arg()

static size_t memsize_dump_arg ( const void *  ptr)
static

Definition at line 222 of file marshal.c.

◆ memsize_load_arg()

static size_t memsize_load_arg ( const void *  ptr)
static

Definition at line 1108 of file marshal.c.

◆ must_be_module()

static VALUE must_be_module ( VALUE  v,
VALUE  path 
)
static

Definition at line 1510 of file marshal.c.

References PRIsVALUE, rb_eArgError, rb_raise(), RB_TYPE_P, and T_MODULE.

Referenced by r_object0().

◆ must_not_be_anonymous()

static VALUE must_not_be_anonymous ( const char *  type,
VALUE  path 
)
static

Definition at line 234 of file marshal.c.

References PRIsVALUE, rb_enc_asciicompat, rb_enc_get(), rb_eTypeError, rb_raise(), and RSTRING_PTR.

Referenced by class2path(), and w_unique().

◆ NORETURN() [1/2]

NORETURN ( static inline void   io_neededvoid)

Referenced by clear_dump_arg().

◆ NORETURN() [2/2]

NORETURN ( static void   too_shortvoid)

◆ obj_alloc_by_klass()

static VALUE obj_alloc_by_klass ( VALUE  klass,
struct load_arg arg,
VALUE oldclass 
)
static

◆ obj_alloc_by_path()

static VALUE obj_alloc_by_path ( VALUE  path,
struct load_arg arg 
)
static

Definition at line 1542 of file marshal.c.

References obj_alloc_by_klass(), and path2class().

Referenced by r_object0().

◆ obj_count_ivars()

static int obj_count_ivars ( st_data_t  key,
st_data_t  val,
st_data_t  a 
)
static

Definition at line 570 of file marshal.c.

References ST_CONTINUE, and to_be_skipped_id.

Referenced by has_ivars(), and w_objivar().

◆ path2class()

static VALUE path2class ( VALUE  path)
static

Definition at line 1497 of file marshal.c.

References PRIsVALUE, rb_eArgError, rb_path_to_class(), rb_raise(), RB_TYPE_P, and T_CLASS.

Referenced by obj_alloc_by_path(), and r_object0().

◆ r_byte()

static int r_byte ( struct load_arg arg)
static

◆ r_byte1_buffered()

static unsigned char r_byte1_buffered ( struct load_arg arg)
static

◆ r_bytes0()

static VALUE r_bytes0 ( long  len,
struct load_arg arg 
)
static

◆ r_bytes1()

static VALUE r_bytes1 ( long  len,
struct load_arg arg 
)
static

◆ r_bytes1_buffered()

static VALUE r_bytes1_buffered ( long  len,
struct load_arg arg 
)
static

◆ r_copy_ivar()

static VALUE r_copy_ivar ( VALUE  v,
VALUE  data 
)
static

Definition at line 1468 of file marshal.c.

References copy_ivar_i(), rb_ivar_foreach(), and st_data_t.

Referenced by r_object0().

◆ r_entry0()

static VALUE r_entry0 ( VALUE  v,
st_index_t  num,
struct load_arg arg 
)
static

◆ r_fixup_compat()

static VALUE r_fixup_compat ( VALUE  v,
struct load_arg arg 
)
static

◆ r_ivar()

static void r_ivar ( VALUE  obj,
int *  has_encoding,
struct load_arg arg 
)
static

◆ r_leave()

static VALUE r_leave ( VALUE  v,
struct load_arg arg 
)
static

Definition at line 1449 of file marshal.c.

References r_fixup_compat(), and r_post_proc().

Referenced by r_object0().

◆ r_long()

static long r_long ( struct load_arg arg)
static

Definition at line 1194 of file marshal.c.

References long_toobig(), and r_byte().

Referenced by r_ivar(), r_object0(), r_symlink(), and r_symreal().

◆ r_object()

static VALUE r_object ( struct load_arg arg)
static

Definition at line 1985 of file marshal.c.

References Qnil, and r_object0().

Referenced by r_ivar(), r_object0(), r_symreal(), and rb_marshal_load_with_proc().

◆ r_object0()

static VALUE r_object0 ( struct load_arg arg,
int *  ivp,
VALUE  extmod 
)
static

Definition at line 1566 of file marshal.c.

References append_extmod(), CLASS_OF, load_arg::data, DBL2NUM, FALSE, FL_SINGLETON, FL_TEST, id, INFINITY, INTEGER_PACK_LITTLE_ENDIAN, INTEGER_PACK_NEGATIVE, key, L, RString::len, link(), load_funcall, load_mantissa, marshal_compat_t::loader, LONG2FIX, must_be_module(), name, NAN, NIL_P, NULL, obj_alloc_by_klass(), obj_alloc_by_path(), options(), path2class(), path2module, PRIsVALUE, prohibit_ivar, RString::ptr, Qfalse, Qnil, Qtrue, Qundef, r_byte(), r_bytes, r_bytes0(), r_copy_ivar(), r_entry, r_entry0(), r_fixup_compat(), r_ivar(), r_leave(), r_long(), r_object(), r_post_proc(), r_prepare(), r_string(), r_symbol(), r_symlink(), r_symreal(), r_unique(), RARRAY_AREF, RARRAY_LEN, rb_ary_clear(), rb_ary_new2, rb_ary_pop(), rb_ary_push(), rb_ary_tmp_new(), rb_class_inherited_p(), rb_class_name(), rb_eArgError, rb_eTypeError, rb_extend_object(), rb_get_alloc_func(), rb_hash_aset(), rb_hash_new(), rb_integer_unpack(), rb_obj_alloc(), rb_obj_respond_to(), rb_path_to_class(), rb_prepend_module(), rb_raise(), rb_reg_new_str(), rb_singleton_class(), rb_special_const_p(), rb_str_equal(), rb_str_intern(), rb_str_resize(), rb_str_set_len(), rb_struct_initialize(), rb_struct_s_members(), rb_sym2str, RB_TYPE_P, RBASIC, RBASIC_SET_CLASS, load_arg::readable, RHASH_SET_IFNONE, RSTRING_LEN, RSTRING_PTR, RTEST, s_load, s_load_data, s_mload, st_data_t, st_lookup, strtod, T_CLASS, T_DATA, T_MODULE, T_OBJECT, T_STRUCT, TRUE, TYPE, TYPE_ARRAY, TYPE_BIGNUM, TYPE_CLASS, TYPE_DATA, TYPE_EXTENDED, TYPE_FALSE, TYPE_FIXNUM, TYPE_FLOAT, TYPE_HASH, TYPE_HASH_DEF, TYPE_IVAR, TYPE_LINK, TYPE_MODULE, TYPE_MODULE_OLD, TYPE_NIL, TYPE_OBJECT, TYPE_REGEXP, TYPE_STRING, TYPE_STRUCT, TYPE_SYMBOL, TYPE_SYMLINK, TYPE_TRUE, TYPE_UCLASS, TYPE_USERDEF, and TYPE_USRMARSHAL.

Referenced by r_object().

◆ r_post_proc()

static VALUE r_post_proc ( VALUE  v,
struct load_arg arg 
)
static

Definition at line 1440 of file marshal.c.

References load_funcall, load_arg::proc, and s_call.

Referenced by r_leave(), and r_object0().

◆ r_prepare()

static st_index_t r_prepare ( struct load_arg arg)
static

Definition at line 1133 of file marshal.c.

References load_arg::data, st_table::num_entries, Qundef, st_data_t, and st_insert.

Referenced by r_object0().

◆ r_string()

static VALUE r_string ( struct load_arg arg)
static

Definition at line 1398 of file marshal.c.

References r_bytes.

Referenced by r_object0().

◆ r_symbol()

static VALUE r_symbol ( struct load_arg arg)
static

◆ r_symlink()

static VALUE r_symlink ( struct load_arg arg)
static

Definition at line 1336 of file marshal.c.

References r_long(), rb_eArgError, rb_raise(), st_data_t, st_lookup, sym, and load_arg::symbols.

Referenced by r_object0(), and r_symbol().

◆ r_symreal()

static VALUE r_symreal ( struct load_arg arg,
int  ivar 
)
static

◆ r_unique()

static VALUE r_unique ( struct load_arg arg)
static

Definition at line 1392 of file marshal.c.

References r_symbol().

Referenced by r_object0().

◆ rb_marshal_define_compat()

void rb_marshal_define_compat ( VALUE  newclass,
VALUE  oldclass,
VALUE(*)(VALUE dumper,
VALUE(*)(VALUE, VALUE loader 
)

◆ rb_marshal_dump()

VALUE rb_marshal_dump ( VALUE  obj,
VALUE  port 
)

Definition at line 2249 of file marshal.c.

References rb_marshal_dump_limited().

◆ rb_marshal_dump_limited()

VALUE rb_marshal_dump_limited ( VALUE  obj,
VALUE  port,
int  limit 
)
static

◆ rb_marshal_load()

VALUE rb_marshal_load ( VALUE  port)

Definition at line 2255 of file marshal.c.

References Qnil, and rb_marshal_load_with_proc().

Referenced by date_s__load().

◆ rb_marshal_load_with_proc()

VALUE rb_marshal_load_with_proc ( VALUE  port,
VALUE  proc 
)
static

◆ STATIC_ASSERT()

STATIC_ASSERT ( marshal_infection_is_int  ,
MARSHAL_INFECTION  = =(int) MARSHAL_INFECTION 
)

◆ sym2encidx()

static int sym2encidx ( VALUE  sym,
VALUE  val 
)
static

◆ too_short()

static void too_short ( void  )
static

Definition at line 1127 of file marshal.c.

References rb_eArgError, and rb_raise().

Referenced by r_byte(), r_byte1_buffered(), r_bytes0(), r_bytes1(), and r_bytes1_buffered().

◆ w_byte()

static void w_byte ( char  c,
struct dump_arg arg 
)
static

Definition at line 279 of file marshal.c.

References w_nbyte().

Referenced by rb_marshal_dump_limited(), w_class(), w_extended(), w_long(), w_object(), w_short(), w_symbol(), and w_uclass().

◆ w_bytes()

static void w_bytes ( const char *  s,
long  n,
struct dump_arg arg 
)
static

Definition at line 285 of file marshal.c.

References w_long(), and w_nbyte().

Referenced by w_float(), w_object(), and w_symbol().

◆ w_class()

static void w_class ( char  type,
VALUE  obj,
struct dump_arg arg,
int  check 
)
static

◆ w_encoding()

static void w_encoding ( VALUE  encname,
struct dump_call_arg arg 
)
static

◆ w_extended()

static void w_extended ( VALUE  klass,
struct dump_arg arg,
int  check 
)
static

◆ w_float()

static void w_float ( double  d,
struct dump_arg arg 
)
static

Definition at line 395 of file marshal.c.

References FLOAT_DIG, isinf(), isnan, memcpy, ruby_dtoa(), snprintf, w_bytes(), w_cstr, and xfree().

Referenced by w_object().

◆ w_ivar()

static void w_ivar ( st_index_t  num,
VALUE  ivobj,
VALUE  encname,
struct dump_call_arg arg 
)
static

Definition at line 644 of file marshal.c.

References dump_call_arg::arg, Qundef, rb_ivar_foreach(), st_data_t, w_encoding(), w_long(), and w_obj_each().

Referenced by w_object().

◆ w_long()

static void w_long ( long  x,
struct dump_arg arg 
)
static

◆ w_nbyte()

static void w_nbyte ( const char *  s,
long  n,
struct dump_arg arg 
)
static

◆ w_obj_each()

static int w_obj_each ( st_data_t  key,
st_data_t  val,
st_data_t  a 
)
static

Definition at line 557 of file marshal.c.

References dump_call_arg::arg, ID2SYM, dump_call_arg::limit, ST_CONTINUE, to_be_skipped_id, w_object(), and w_symbol().

Referenced by w_ivar(), and w_objivar().

◆ w_object()

static void w_object ( VALUE  obj,
struct dump_arg arg,
int  limit 
)
static

Definition at line 666 of file marshal.c.

References dump_call_arg::arg, BDIGIT, BIGNUM_DIGITS, BIGNUM_LEN, BIGNUM_SIGN, BUILTIN_TYPE, class2path(), dump_arg::compat_tbl, dump_arg::data, dump_funcall, marshal_compat_t::dumper, encoding_name(), FALSE, FIX2INT, FIX2LONG, FIXNUM_P, FL_SINGLETON, FL_TEST, FLONUM_P, has_ivars(), hash_each(), HASH_PROC_DEFAULT, dump_arg::infection, INT2NUM, RString::len, dump_call_arg::limit, LONG_MAX, MARSHAL_INFECTION, NIL_P, st_table::num_entries, dump_call_arg::obj, PRIsVALUE, Qfalse, Qnil, Qtrue, Qundef, RARRAY_AREF, RARRAY_LEN, rb_builtin_type_name(), rb_cArray, rb_cHash, rb_cRegexp, rb_cString, rb_eArgError, rb_eRuntimeError, rb_eTypeError, RB_GC_GUARD, rb_get_alloc_func(), rb_hash_foreach(), rb_init_identtable(), rb_int2big(), rb_obj_class(), rb_obj_respond_to(), rb_raise(), rb_reg_options(), rb_struct_members(), RB_TYPE_P, RBASIC, RBASIC_CLASS, RFLOAT_VALUE, RHASH_IFNONE, RHASH_SIZE, RREGEXP_SRC_LEN, RREGEXP_SRC_PTR, RSTRING_LEN, RSTRING_PTR, RSTRUCT_GET, RSTRUCT_LEN, s_dump, s_dump_data, s_mdump, SHORTDN, SHORTLEN, SHORTMASK, SIZEOF_BDIGIT, st_add_direct, st_data_t, st_insert, st_lookup, SYMBOL_P, T_ARRAY, T_BIGNUM, T_CLASS, T_DATA, T_FLOAT, T_HASH, T_MODULE, T_OBJECT, T_REGEXP, T_STRING, T_STRUCT, TRUE, TYPE_ARRAY, TYPE_BIGNUM, TYPE_CLASS, TYPE_DATA, TYPE_FALSE, TYPE_FIXNUM, TYPE_FLOAT, TYPE_HASH, TYPE_HASH_DEF, TYPE_IVAR, TYPE_LINK, TYPE_MODULE, TYPE_NIL, TYPE_OBJECT, TYPE_REGEXP, TYPE_STRING, TYPE_STRUCT, TYPE_TRUE, TYPE_USERDEF, TYPE_USRMARSHAL, w_byte(), w_bytes(), w_class(), w_float(), w_ivar(), w_long(), w_objivar(), w_short(), w_symbol(), and w_uclass().

Referenced by hash_each(), rb_marshal_dump_limited(), w_encoding(), w_obj_each(), and w_unique().

◆ w_objivar()

static void w_objivar ( VALUE  obj,
struct dump_call_arg arg 
)
static

Definition at line 654 of file marshal.c.

References dump_call_arg::arg, obj_count_ivars(), rb_ivar_foreach(), st_data_t, w_long(), and w_obj_each().

Referenced by w_object().

◆ w_short()

static void w_short ( int  x,
struct dump_arg arg 
)
static

Definition at line 294 of file marshal.c.

References w_byte().

Referenced by w_object().

◆ w_symbol()

static void w_symbol ( VALUE  sym,
struct dump_arg arg 
)
static

◆ w_uclass()

static void w_uclass ( VALUE  obj,
VALUE  super,
struct dump_arg arg 
)
static

Definition at line 542 of file marshal.c.

References class2path(), CLASS_OF, rb_class_real(), TRUE, TYPE_UCLASS, w_byte(), w_extended(), and w_unique().

Referenced by w_object().

◆ w_unique()

static void w_unique ( VALUE  s,
struct dump_arg arg 
)
static

Definition at line 484 of file marshal.c.

References must_not_be_anonymous(), rb_str_intern(), w_object(), and w_symbol().

Referenced by w_class(), w_extended(), and w_uclass().

Variable Documentation

◆ compat_allocator_tbl

st_table* compat_allocator_tbl
static

Definition at line 110 of file marshal.c.

Referenced by compat_allocator_table().

◆ compat_allocator_tbl_wrapper

VALUE compat_allocator_tbl_wrapper
static

Definition at line 111 of file marshal.c.

Referenced by compat_allocator_table().

◆ dump_arg_data

const rb_data_type_t dump_arg_data
static
Initial value:
= {
"dump_arg",
}
#define RUBY_TYPED_FREE_IMMEDIATELY
Definition: ruby.h:1145
static size_t memsize_dump_arg(const void *ptr)
Definition: marshal.c:222
static void mark_dump_arg(void *ptr)
Definition: marshal.c:203
static void free_dump_arg(void *ptr)
Definition: marshal.c:215

Definition at line 227 of file marshal.c.

◆ load_arg_data

const rb_data_type_t load_arg_data
static
Initial value:
= {
"load_arg",
}
#define RUBY_TYPED_FREE_IMMEDIATELY
Definition: ruby.h:1145
static size_t memsize_load_arg(const void *ptr)
Definition: marshal.c:1108
static void free_load_arg(void *ptr)
Definition: marshal.c:1101
static void mark_load_arg(void *ptr)
Definition: marshal.c:1090

Definition at line 1113 of file marshal.c.

◆ s_alloc

ID s_alloc
static

Definition at line 87 of file marshal.c.

Referenced by Init_marshal().

◆ s_binmode

ID s_binmode
static

Definition at line 88 of file marshal.c.

Referenced by Init_marshal(), rb_marshal_dump_limited(), and rb_marshal_load_with_proc().

◆ s_call

ID s_call
static

Definition at line 87 of file marshal.c.

Referenced by Init_marshal(), and r_post_proc().

◆ s_dump

ID s_dump
static

Definition at line 86 of file marshal.c.

Referenced by Init_marshal(), and w_object().

◆ s_dump_data

ID s_dump_data
static

Definition at line 87 of file marshal.c.

Referenced by Init_marshal(), and w_object().

◆ s_getbyte

ID s_getbyte
static

Definition at line 88 of file marshal.c.

Referenced by Init_marshal(), r_byte(), and rb_marshal_load_with_proc().

◆ s_load

ID s_load
static

Definition at line 86 of file marshal.c.

Referenced by Init_marshal(), and r_object0().

◆ s_load_data

ID s_load_data
static

Definition at line 87 of file marshal.c.

Referenced by Init_marshal(), and r_object0().

◆ s_mdump

ID s_mdump
static

Definition at line 86 of file marshal.c.

Referenced by Init_marshal(), and w_object().

◆ s_mload

ID s_mload
static

Definition at line 86 of file marshal.c.

Referenced by Init_marshal(), and r_object0().

◆ s_read

ID s_read
static

◆ s_write

ID s_write
static

Definition at line 88 of file marshal.c.

Referenced by Init_marshal(), and rb_marshal_dump_limited().