diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-17 16:37:41 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-17 16:37:41 +0000 |
commit | e56d2c385aac51298b34edf3fe4fddde512aec1b (patch) | |
tree | 1fe3a1e04ba6de9c6e528f77cd4477c4ffe7c65e /ext | |
parent | fb8f7259c3435ac01ff9ac2718d325e7c309336b (diff) | |
download | ruby-e56d2c385aac51298b34edf3fe4fddde512aec1b.tar.gz |
* include/ruby/ruby.h: Hide Rational internal.
(RRational): Moved to internal.h
(RRATIONAL): Ditto.
(RRATIONAL_SET_NUM): Moved to rational.c.
(RRATIONAL_SET_DEN): Ditto.
* rational.c (rb_rational_num): New function.
(rb_rational_den): Ditto.
* include/ruby/intern.h (rb_rational_num): Declared.
(rb_rational_den): Ditto.
* ext/bigdecimal/bigdecimal.c: Follow the above change.
* ext/date/date_core.c: Ditto.
[ruby-core:60665] [Feature #9513]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/bigdecimal/bigdecimal.c | 20 | ||||
-rw-r--r-- | ext/date/date_core.c | 14 |
2 files changed, 17 insertions, 17 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index 31479d4edb..44e13a49d7 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -87,8 +87,8 @@ static ID id_eq; #endif #ifndef RRATIONAL_ZERO_P -# define RRATIONAL_ZERO_P(x) (FIXNUM_P(RRATIONAL(x)->num) && \ - FIX2LONG(RRATIONAL(x)->num) == 0) +# define RRATIONAL_ZERO_P(x) (FIXNUM_P(rb_rational_num(x)) && \ + FIX2LONG(rb_rational_num(x)) == 0) #endif #ifndef RRATIONAL_NEGATIVE_P @@ -235,11 +235,11 @@ again: if (prec < 0) goto unable_to_coerce_without_prec; if (orig == Qundef ? (orig = v, 1) : orig != v) { - num = RRATIONAL(v)->num; + num = rb_rational_num(v); pv = GetVpValueWithPrec(num, -1, must); if (pv == NULL) goto SomeOneMayDoIt; - v = BigDecimal_div2(ToValue(pv), RRATIONAL(v)->den, LONG2NUM(prec)); + v = BigDecimal_div2(ToValue(pv), rb_rational_den(v), LONG2NUM(prec)); goto again; } @@ -2114,7 +2114,7 @@ is_zero(VALUE x) return Qfalse; case T_RATIONAL: - num = RRATIONAL(x)->num; + num = rb_rational_num(x); return FIXNUM_P(num) && FIX2LONG(num) == 0; default: @@ -2137,8 +2137,8 @@ is_one(VALUE x) return Qfalse; case T_RATIONAL: - num = RRATIONAL(x)->num; - den = RRATIONAL(x)->den; + num = rb_rational_num(x); + den = rb_rational_den(x); return FIXNUM_P(den) && FIX2LONG(den) == 1 && FIXNUM_P(num) && FIX2LONG(num) == 1; @@ -2244,14 +2244,14 @@ BigDecimal_power(int argc, VALUE*argv, VALUE self) break; case T_RATIONAL: - if (is_zero(RRATIONAL(vexp)->num)) { + if (is_zero(rb_rational_num(vexp))) { if (is_positive(vexp)) { vexp = INT2FIX(0); goto retry; } } - else if (is_one(RRATIONAL(vexp)->den)) { - vexp = RRATIONAL(vexp)->num; + else if (is_one(rb_rational_den(vexp))) { + vexp = rb_rational_num(vexp); goto retry; } exp = GetVpValueWithPrec(vexp, n, 1); diff --git a/ext/date/date_core.c b/ext/date/date_core.c index ee360b4afb..0775fecbf2 100644 --- a/ext/date/date_core.c +++ b/ext/date/date_core.c @@ -114,7 +114,7 @@ f_zero_p(VALUE x) return Qfalse; case T_RATIONAL: { - VALUE num = RRATIONAL(x)->num; + VALUE num = rb_rational_num(x); return f_boolcast(FIXNUM_P(num) && FIX2LONG(num) == 0); } } @@ -305,9 +305,9 @@ inline static VALUE canon(VALUE x) { if (TYPE(x) == T_RATIONAL) { - VALUE den = RRATIONAL(x)->den; + VALUE den = rb_rational_den(x); if (FIXNUM_P(den) && FIX2LONG(den) == 1) - return RRATIONAL(x)->num; + return rb_rational_num(x); } return x; } @@ -2373,8 +2373,8 @@ offset_to_sec(VALUE vof, int *rof) return 1; } #endif - vn = RRATIONAL(vs)->num; - vd = RRATIONAL(vs)->den; + vn = rb_rational_num(vs); + vd = rb_rational_den(vs); if (FIXNUM_P(vn) && FIXNUM_P(vd) && (FIX2LONG(vd) == 1)) n = FIX2LONG(vn); @@ -3097,7 +3097,7 @@ wholenum_p(VALUE x) break; case T_RATIONAL: { - VALUE den = RRATIONAL(x)->den; + VALUE den = rb_rational_den(x); return FIXNUM_P(den) && FIX2LONG(den) == 1; } break; @@ -5707,7 +5707,7 @@ d_lite_plus(VALUE self, VALUE other) int jd, df, s; if (wholenum_p(other)) - return d_lite_plus(self, RRATIONAL(other)->num); + return d_lite_plus(self, rb_rational_num(other)); if (f_positive_p(other)) s = +1; |