method
marshal_load
Ruby latest stable (v2_5_5)
-
0 notes -
Class: Random
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378
- 1_9_2_180 (0)
- 1_9_3_125 (0)
- 1_9_3_392 (0)
- 2_1_10 (0)
- 2_2_9 (0)
- 2_4_6 (0)
- 2_5_5 (0)
- 2_6_3 (0)
- What's this?
marshal_load(p1)
private
Hide source
static VALUE random_load(VALUE obj, VALUE dump) { rb_random_t *rnd = get_rnd(obj); struct MT *mt = &rnd->mt; VALUE state, left = INT2FIX(1), seed = INT2FIX(0); const VALUE *ary; unsigned long x; rb_check_copyable(obj, dump); Check_Type(dump, T_ARRAY); ary = RARRAY_CONST_PTR(dump); switch (RARRAY_LEN(dump)) { case 3: seed = ary[2]; case 2: left = ary[1]; case 1: state = ary[0]; break; default: rb_raise(rb_eArgError, "wrong dump data"); } rb_integer_pack(state, mt->state, numberof(mt->state), sizeof(*mt->state), 0, INTEGER_PACK_LSWORD_FIRST|INTEGER_PACK_NATIVE_BYTE_ORDER); x = NUM2ULONG(left); if (x > numberof(mt->state)) { rb_raise(rb_eArgError, "wrong value"); } mt->left = (unsigned int)x; mt->next = mt->state + numberof(mt->state) - x + 1; rnd->seed = rb_to_int(seed); return obj; }