summaryrefslogtreecommitdiff
path: root/rational.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-17 16:37:41 (GMT)
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-17 16:37:41 (GMT)
commite56d2c385aac51298b34edf3fe4fddde512aec1b (patch)
tree1fe3a1e04ba6de9c6e528f77cd4477c4ffe7c65e /rational.c
parentfb8f7259c3435ac01ff9ac2718d325e7c309336b (diff)
* 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 'rational.c')
-rw-r--r--rational.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/rational.c b/rational.c
index 517a797..e504979 100644
--- a/rational.c
+++ b/rational.c
@@ -404,6 +404,9 @@ f_lcm(VALUE x, VALUE y)
adat = ((struct RRational *)(x));\
bdat = ((struct RRational *)(y))
+#define RRATIONAL_SET_NUM(rat, n) RB_OBJ_WRITE((rat), &((struct RRational *)(rat))->num,(n))
+#define RRATIONAL_SET_DEN(rat, d) RB_OBJ_WRITE((rat), &((struct RRational *)(rat))->den,(d))
+
inline static VALUE
nurat_s_new_internal(VALUE klass, VALUE num, VALUE den)
{
@@ -1775,6 +1778,18 @@ rb_Rational(VALUE x, VALUE y)
return nurat_s_convert(2, a, rb_cRational);
}
+VALUE
+rb_rational_num(VALUE rat)
+{
+ return nurat_numerator(rat);
+}
+
+VALUE
+rb_rational_den(VALUE rat)
+{
+ return nurat_denominator(rat);
+}
+
#define id_numerator rb_intern("numerator")
#define f_numerator(x) rb_funcall((x), id_numerator, 0)