diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-19 13:10:54 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-19 13:10:54 +0000 |
commit | 396650e0bd353e30b873683f008f92e2aa498971 (patch) | |
tree | e59bac107ba2db327ac8cb79d51ae9e9093ec80b | |
parent | e6ad87c3ba2956297166a6cfcf31e30644075929 (diff) |
* prec.c: removed. Precision will be redesigned and be back again.
c.f. [ruby-dev:36352].
* common.mk (COMMON_OBJS): removed prec.o.
* inits.c (rb_call_inits): removed Init_Precision.
* numeric.c (Init_Numeric): removed inclusion of Precision.
removed #induced_from from each class.
* rational.c: ditto.
* ext/bigdecimal/bigdecimal.c: ditto.
* lib/rdoc/knwon_classes.rb: removed the entry for Precision.
* test/ruby/test_prec.rb: removed.
* test/ruby/test_integer.rb: removed tests for Precision.
* test/ruby/test_fixnum.rb: ditto.
* test/ruby/test_float.rb: ditto.
* test/ruby/test_rational.rb: ditto.
* test/ruby/test_complex.rb: ditto.
* test/bigdecimal/test_bigdecimal.rb: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 32 | ||||
-rw-r--r-- | common.mk | 1 | ||||
-rw-r--r-- | ext/bigdecimal/bigdecimal.c | 8 | ||||
-rw-r--r-- | inits.c | 2 | ||||
-rw-r--r-- | lib/rdoc/known_classes.rb | 1 | ||||
-rw-r--r-- | numeric.c | 67 | ||||
-rw-r--r-- | prec.c | 138 | ||||
-rw-r--r-- | rational.c | 10 | ||||
-rw-r--r-- | test/bigdecimal/test_bigdecimal.rb | 7 | ||||
-rw-r--r-- | test/ruby/test_complex.rb | 4 | ||||
-rw-r--r-- | test/ruby/test_fixnum.rb | 9 | ||||
-rw-r--r-- | test/ruby/test_float.rb | 7 | ||||
-rw-r--r-- | test/ruby/test_integer.rb | 6 | ||||
-rw-r--r-- | test/ruby/test_prec.rb | 21 | ||||
-rw-r--r-- | test/ruby/test_rational.rb | 10 |
15 files changed, 32 insertions, 291 deletions
@@ -1,3 +1,35 @@ +Fri Sep 19 20:48:06 2008 Yuki Sonoda <[email protected]> + + * prec.c: removed. Precision will be redesigned and be back again. + c.f. [ruby-dev:36352]. + + * common.mk (COMMON_OBJS): removed prec.o. + + * inits.c (rb_call_inits): removed Init_Precision. + + * numeric.c (Init_Numeric): removed inclusion of Precision. + removed #induced_from from each class. + + * rational.c: ditto. + + * ext/bigdecimal/bigdecimal.c: ditto. + + * lib/rdoc/knwon_classes.rb: removed the entry for Precision. + + * test/ruby/test_prec.rb: removed. + + * test/ruby/test_integer.rb: removed tests for Precision. + + * test/ruby/test_fixnum.rb: ditto. + + * test/ruby/test_float.rb: ditto. + + * test/ruby/test_rational.rb: ditto. + + * test/ruby/test_complex.rb: ditto. + + * test/bigdecimal/test_bigdecimal.rb: ditto. + Fri Sep 19 19:43:40 2008 Yuki Sonoda <[email protected]> * common.mk : Reverts the changeset 18994. @@ -49,7 +49,6 @@ COMMONOBJS = array.$(OBJEXT) \ pack.$(OBJEXT) \ parse.$(OBJEXT) \ process.$(OBJEXT) \ - prec.$(OBJEXT) \ random.$(OBJEXT) \ range.$(OBJEXT) \ rational.$(OBJEXT) \ diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index 3051143b07..fbc2474edf 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -579,13 +579,6 @@ BigDecimal_to_i(VALUE self) return rb_cstr2inum(psz,10); } -static VALUE -BigDecimal_induced_from(VALUE self, VALUE x) -{ - Real *p = GetVpValue(x,1); - return p->obj; -} - /* Returns a new Float object having approximately the same value as the * BigDecimal number. Normal accuracy limits and built-in errors of binary * Float arithmetic apply. @@ -1807,7 +1800,6 @@ Init_bigdecimal(void) rb_define_singleton_method(rb_cBigDecimal, "mode", BigDecimal_mode, -1); rb_define_singleton_method(rb_cBigDecimal, "limit", BigDecimal_limit, -1); rb_define_singleton_method(rb_cBigDecimal, "double_fig", BigDecimal_double_fig, 0); - rb_define_singleton_method(rb_cBigDecimal, "induced_from",BigDecimal_induced_from, 1); rb_define_singleton_method(rb_cBigDecimal, "_load", BigDecimal_load, 1); rb_define_singleton_method(rb_cBigDecimal, "ver", BigDecimal_version, 0); @@ -34,7 +34,6 @@ void Init_marshal(void); void Init_Numeric(void); void Init_Object(void); void Init_pack(void); -void Init_Precision(void); void Init_sym(void); void Init_process(void); void Init_RandomSeed(void); @@ -66,7 +65,6 @@ rb_call_inits() Init_Encoding(); Init_Comparable(); Init_Enumerable(); - Init_Precision(); Init_String(); Init_Exception(); Init_eval(); diff --git a/lib/rdoc/known_classes.rb b/lib/rdoc/known_classes.rb index 4c52f58ad2..dbb1802f5a 100644 --- a/lib/rdoc/known_classes.rb +++ b/lib/rdoc/known_classes.rb @@ -62,7 +62,6 @@ module RDoc "rb_mGC" => "GC", "rb_mKernel" => "Kernel", "rb_mMath" => "Math", - "rb_mPrecision" => "Precision", "rb_mProcess" => "Process" } @@ -1951,66 +1951,6 @@ int_denominator(VALUE num) /* * call-seq: - * Fixnum.induced_from(obj) => fixnum - * - * Convert <code>obj</code> to a Fixnum. Works with numeric parameters. - * Also works with Symbols, but this is deprecated. - */ - -static VALUE -rb_fix_induced_from(VALUE klass, VALUE x) -{ - return rb_num2fix(x); -} - -/* - * call-seq: - * Integer.induced_from(obj) => fixnum, bignum - * - * Convert <code>obj</code> to an Integer. - */ - -static VALUE -rb_int_induced_from(VALUE klass, VALUE x) -{ - switch (TYPE(x)) { - case T_FIXNUM: - case T_BIGNUM: - return x; - case T_FLOAT: - case T_RATIONAL: - return rb_funcall(x, id_to_i, 0); - default: - rb_raise(rb_eTypeError, "failed to convert %s into Integer", - rb_obj_classname(x)); - } -} - -/* - * call-seq: - * Float.induced_from(obj) => float - * - * Convert <code>obj</code> to a float. - */ - -static VALUE -rb_flo_induced_from(VALUE klass, VALUE x) -{ - switch (TYPE(x)) { - case T_FIXNUM: - case T_BIGNUM: - case T_RATIONAL: - return rb_funcall(x, rb_intern("to_f"), 0); - case T_FLOAT: - return x; - default: - rb_raise(rb_eTypeError, "failed to convert %s into Float", - rb_obj_classname(x)); - } -} - -/* - * call-seq: * -fix => integer * * Negates <code>fix</code> (which might return a Bignum). @@ -3172,7 +3112,6 @@ Init_Numeric(void) rb_define_method(rb_cInteger, "upto", int_upto, 1); rb_define_method(rb_cInteger, "downto", int_downto, 1); rb_define_method(rb_cInteger, "times", int_dotimes, 0); - rb_include_module(rb_cInteger, rb_mPrecision); rb_define_method(rb_cInteger, "succ", int_succ, 0); rb_define_method(rb_cInteger, "next", int_succ, 0); rb_define_method(rb_cInteger, "pred", int_pred, 0); @@ -3185,9 +3124,6 @@ Init_Numeric(void) rb_define_method(rb_cInteger, "round", int_round, -1); rb_cFixnum = rb_define_class("Fixnum", rb_cInteger); - rb_include_module(rb_cFixnum, rb_mPrecision); - rb_define_singleton_method(rb_cFixnum, "induced_from", rb_fix_induced_from, 1); - rb_define_singleton_method(rb_cInteger, "induced_from", rb_int_induced_from, 1); rb_define_method(rb_cInteger, "numerator", int_numerator, 0); rb_define_method(rb_cInteger, "denominator", int_denominator, 0); @@ -3237,9 +3173,6 @@ Init_Numeric(void) rb_undef_alloc_func(rb_cFloat); rb_undef_method(CLASS_OF(rb_cFloat), "new"); - rb_define_singleton_method(rb_cFloat, "induced_from", rb_flo_induced_from, 1); - rb_include_module(rb_cFloat, rb_mPrecision); - rb_define_const(rb_cFloat, "ROUNDS", INT2FIX(FLT_ROUNDS)); rb_define_const(rb_cFloat, "RADIX", INT2FIX(FLT_RADIX)); rb_define_const(rb_cFloat, "MANT_DIG", INT2FIX(DBL_MANT_DIG)); diff --git a/prec.c b/prec.c deleted file mode 100644 index 84de958be8..0000000000 --- a/prec.c +++ /dev/null @@ -1,138 +0,0 @@ -/********************************************************************** - - prec.c - - - $Author$ - created at: Tue Jan 26 02:40:41 2000 - - Copyright (C) 1993-2007 Yukihiro Matsumoto - -**********************************************************************/ - -#include "ruby/ruby.h" - -VALUE rb_mPrecision; - -static ID prc_pr, prc_if; - - -/* - * call-seq: - * num.prec(klass) => a_class - * - * Converts _self_ into an instance of _klass_. By default, - * +prec+ invokes - * - * klass.induced_from(num) - * - * and returns its value. So, if <code>klass.induced_from</code> - * doesn't return an instance of _klass_, it will be necessary - * to reimplement +prec+. - */ - -static VALUE -prec_prec(VALUE x, VALUE klass) -{ - return rb_funcall(klass, prc_if, 1, x); -} - -/* - * call-seq: - * num.prec_i => Integer - * - * Returns an +Integer+ converted from _num_. It is equivalent - * to <code>prec(Integer)</code>. - */ - -static VALUE -prec_prec_i(VALUE x) -{ - VALUE klass = rb_cInteger; - - return rb_funcall(x, prc_pr, 1, klass); -} - -/* - * call-seq: - * num.prec_f => Float - * - * Returns a +Float+ converted from _num_. It is equivalent - * to <code>prec(Float)</code>. - */ - -static VALUE -prec_prec_f(VALUE x) -{ - VALUE klass = rb_cFloat; - - return rb_funcall(x, prc_pr, 1, klass); -} - -/* - * call-seq: - * Mod.induced_from(number) => a_mod - * - * Creates an instance of mod from. This method is overridden - * by concrete +Numeric+ classes, so that (for example) - * - * Fixnum.induced_from(9.9) #=> 9 - * - * Note that a use of +prec+ in a redefinition may cause - * an infinite loop. - */ - -static VALUE -prec_induced_from(VALUE module, VALUE x) -{ - rb_raise(rb_eTypeError, "undefined conversion from %s into %s", - rb_obj_classname(x), rb_class2name(module)); - return Qnil; /* not reached */ -} - -/* - * call_seq: - * included - * - * When the +Precision+ module is mixed-in to a class, this +included+ - * method is used to add our default +induced_from+ implementation - * to the host class. - */ - -static VALUE -prec_included(VALUE module, VALUE include) -{ - switch (TYPE(include)) { - case T_CLASS: - case T_MODULE: - break; - default: - Check_Type(include, T_CLASS); - break; - } - rb_define_singleton_method(include, "induced_from", prec_induced_from, 1); - return module; -} - -/* - * Precision is a mixin for concrete numeric classes with - * precision. Here, `precision' means the fineness of approximation - * of a real number, so, this module should not be included into - * anything which is not a subset of Real (so it should not be - * included in classes such as +Complex+ or +Matrix+). -*/ - -void -Init_Precision(void) -{ -#undef rb_intern -#define rb_intern(str) rb_intern_const(str) - - rb_mPrecision = rb_define_module("Precision"); - rb_define_singleton_method(rb_mPrecision, "included", prec_included, 1); - rb_define_method(rb_mPrecision, "prec", prec_prec, 1); - rb_define_method(rb_mPrecision, "prec_i", prec_prec_i, 0); - rb_define_method(rb_mPrecision, "prec_f", prec_prec_f, 0); - - prc_pr = rb_intern("prec"); - prc_if = rb_intern("induced_from"); -} diff --git a/rational.c b/rational.c index fb5b2912e1..c6c9b91ead 100644 --- a/rational.c +++ b/rational.c @@ -1470,12 +1470,6 @@ nurat_s_convert(int argc, VALUE *argv, VALUE klass) } } -static VALUE -nurat_s_induced_from(VALUE klass, VALUE n) -{ - return f_to_r(n); -} - void Init_Rational(void) { @@ -1592,10 +1586,6 @@ Init_Rational(void) rb_define_singleton_method(rb_cRational, "convert", nurat_s_convert, -1); rb_funcall(rb_cRational, rb_intern("private_class_method"), 1, ID2SYM(rb_intern("convert"))); - - rb_include_module(rb_cRational, rb_mPrecision); - rb_define_singleton_method(rb_cRational, "induced_from", - nurat_s_induced_from, 1); } /* diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb index e9d1d0bdb6..99ce108458 100644 --- a/test/bigdecimal/test_bigdecimal.rb +++ b/test/bigdecimal/test_bigdecimal.rb @@ -245,13 +245,6 @@ class TestBigDecimal < Test::Unit::TestCase assert_operator(BigDecimal.new((2**100).to_s), :==, d) end - def test_induced_from - assert_instance_of(BigDecimal, BigDecimal.induced_from(1)) - assert_raise(TypeError) do - BigDecimal.induced_from(Time.now) - end - end - def test_precs a = BigDecimal.new("1").precs assert_instance_of(Array, a) diff --git a/test/ruby/test_complex.rb b/test/ruby/test_complex.rb index 5aa741065a..7c29920b46 100644 --- a/test/ruby/test_complex.rb +++ b/test/ruby/test_complex.rb @@ -882,10 +882,6 @@ class Complex_Test < Test::Unit::TestCase assert_equal([1, 2], [c.real, c.image]) end - def test_prec - assert_equal(nil, Complex < Precision) - end - def test_supp assert_equal(true, 1.real?) assert_equal(true, 1.1.real?) diff --git a/test/ruby/test_fixnum.rb b/test/ruby/test_fixnum.rb index 8fa751ba98..e55e324bd1 100644 --- a/test/ruby/test_fixnum.rb +++ b/test/ruby/test_fixnum.rb @@ -119,15 +119,6 @@ class TestFixnum < Test::Unit::TestCase assert_equal(0x4000000000000000, (-0x4000000000000000).abs) end - def test_induced_from - assert_equal(1, Fixnum.induced_from(1)) - assert_raise(RangeError) do - Fixnum.induced_from(2**31-1) - Fixnum.induced_from(2**63-1) - end - assert_equal(1, Fixnum.induced_from((2**32).coerce(1).first)) - end - def test_to_s assert_equal("1010", 10.to_s(2)) assert_equal("a", 10.to_s(36)) diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb index d4bbd688d2..5d7bbb178b 100644 --- a/test/ruby/test_float.rb +++ b/test/ruby/test_float.rb @@ -275,13 +275,6 @@ class TestFloat < Test::Unit::TestCase assert_equal(11100.0, 11111.1.round(-2)) end - def test_induced_from - assert_equal(1.0, Float.induced_from(1)) - assert_equal(1.0, Float.induced_from(1.0)) - assert_raise(TypeError) { Float.induced_from(nil) } - end - - VS = [ 18446744073709551617.0, 18446744073709551616.0, diff --git a/test/ruby/test_integer.rb b/test/ruby/test_integer.rb index e31fb1880d..232a7fae30 100644 --- a/test/ruby/test_integer.rb +++ b/test/ruby/test_integer.rb @@ -122,12 +122,6 @@ class TestInteger < Test::Unit::TestCase assert_raise(RangeError) { 0x100.chr } end - def test_induced_from - assert_equal(1, Integer.induced_from(1)) - assert_equal(1, Integer.induced_from(1.0)) - assert_raise(TypeError) { Integer.induced_from(nil) } - end - def test_upto a = [] 1.upto(3) {|x| a << x } diff --git a/test/ruby/test_prec.rb b/test/ruby/test_prec.rb deleted file mode 100644 index d872242c11..0000000000 --- a/test/ruby/test_prec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'test/unit' - -class TestPrecision < Test::Unit::TestCase - def test_prec_i - assert_same(1, 1.0.prec(Integer)) - assert_same(1, 1.0.prec_i) - assert_same(1, Integer.induced_from(1.0)) - end - - def test_prec_f - assert_equal(1.0, 1.prec(Float)) - assert_equal(1.0, 1.prec_f) - assert_equal(1.0, Float.induced_from(1)) - end - - def test_induced_from - m = Module.new - m.instance_eval { include(Precision) } - assert_raise(TypeError) { m.induced_from(0) } - end -end diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb index a351575921..949098e5d7 100644 --- a/test/ruby/test_rational.rb +++ b/test/ruby/test_rational.rb @@ -1028,16 +1028,6 @@ class Rational_Test < Test::Unit::TestCase end end - def test_prec - assert_equal(true, Rational < Precision) - - c = Rational(3,2) - - assert_eql(1, c.prec(Integer)) - assert_eql(1.5, c.prec(Float)) - assert_eql(c, c.prec(Rational)) - end - def test_gcdlcm assert_equal(7, 91.gcd(-49)) assert_equal(5, 5.gcd(0)) |