method
marshal_load
Ruby latest stable (v2_5_5)
-
0 notes -
Class: Date
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378 (0)
- 1_9_2_180 (-38)
- 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)
public
Hide source
static VALUE d_lite_marshal_load(VALUE self, VALUE a) { get_d1(self); rb_check_frozen(self); rb_check_trusted(self); if (!RB_TYPE_P(a, T_ARRAY)) rb_raise(rb_eTypeError, "expected an array"); switch (RARRAY_LEN(a)) { case 2: /* 1.6.x */ case 3: /* 1.8.x, 1.9.2 */ { VALUE ajd, of, sg, nth, sf; int jd, df, rof; double rsg; if (RARRAY_LEN(a) == 2) { ajd = f_sub(RARRAY_AREF(a, 0), half_days_in_day); of = INT2FIX(0); sg = RARRAY_AREF(a, 1); if (!k_numeric_p(sg)) sg = DBL2NUM(RTEST(sg) ? GREGORIAN : JULIAN); } else { ajd = RARRAY_AREF(a, 0); of = RARRAY_AREF(a, 1); sg = RARRAY_AREF(a, 2); } old_to_new(ajd, of, sg, &nth, &jd, &df, &sf, &rof, &rsg); if (!df && f_zero_p(sf) && !rof) { set_to_simple(self, &dat->s, nth, jd, rsg, 0, 0, 0, HAVE_JD); } else { if (!complex_dat_p(dat)) rb_raise(rb_eArgError, "cannot load complex into simple"); set_to_complex(self, &dat->c, nth, jd, df, sf, rof, rsg, 0, 0, 0, 0, 0, 0, HAVE_JD | HAVE_DF | COMPLEX_DAT); } } break; case 6: { VALUE nth, sf; int jd, df, of; double sg; nth = RARRAY_AREF(a, 0); jd = NUM2INT(RARRAY_AREF(a, 1)); df = NUM2INT(RARRAY_AREF(a, 2)); sf = RARRAY_AREF(a, 3); of = NUM2INT(RARRAY_AREF(a, 4)); sg = NUM2DBL(RARRAY_AREF(a, 5)); if (!df && f_zero_p(sf) && !of) { set_to_simple(self, &dat->s, nth, jd, sg, 0, 0, 0, HAVE_JD); } else { if (!complex_dat_p(dat)) rb_raise(rb_eArgError, "cannot load complex into simple"); set_to_complex(self, &dat->c, nth, jd, df, sf, of, sg, 0, 0, 0, 0, 0, 0, HAVE_JD | HAVE_DF | COMPLEX_DAT); } } break; default: rb_raise(rb_eTypeError, "invalid size"); break; } if (FL_TEST(a, FL_EXIVAR)) { rb_copy_generic_ivar(self, a); FL_SET(self, FL_EXIVAR); } return self; }