diff options
| author | dearblue <[email protected]> | 2020-01-19 09:48:14 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-10-12 16:21:44 +0900 |
| commit | 80fe9838d2fdab1bb819bbeea892ebe748837b99 (patch) | |
| tree | 848da66323175327b5950dc41868e85a3bd3611f /mrbgems | |
| parent | 40d0d8fe0efa6a34b54ef90a93f16b17fe3f3c7b (diff) | |
| download | mruby-80fe9838d2fdab1bb819bbeea892ebe748837b99.tar.gz mruby-80fe9838d2fdab1bb819bbeea892ebe748837b99.zip | |
Integrate `Fixnum` class into `Integer` class
* The `Fixnum` constant is now an alias for the `Integer` class.
* Remove `struct mrb_state::fixnum_class` member.
If necessary, use `struct mrb_state::integer_class` instead.
Diffstat (limited to 'mrbgems')
| -rw-r--r-- | mrbgems/mruby-complex/mrblib/complex.rb | 2 | ||||
| -rw-r--r-- | mrbgems/mruby-io/mrblib/file.rb | 2 | ||||
| -rw-r--r-- | mrbgems/mruby-io/mrblib/io.rb | 4 | ||||
| -rw-r--r-- | mrbgems/mruby-io/test/io.rb | 4 | ||||
| -rw-r--r-- | mrbgems/mruby-kernel-ext/src/kernel.c | 2 | ||||
| -rw-r--r-- | mrbgems/mruby-math/src/math.c | 2 | ||||
| -rw-r--r-- | mrbgems/mruby-metaprog/test/metaprog.rb | 8 | ||||
| -rw-r--r-- | mrbgems/mruby-method/test/method.rb | 8 | ||||
| -rw-r--r-- | mrbgems/mruby-pack/src/pack.c | 8 | ||||
| -rw-r--r-- | mrbgems/mruby-random/test/random.rb | 4 | ||||
| -rw-r--r-- | mrbgems/mruby-range-ext/mrblib/range.rb | 2 | ||||
| -rw-r--r-- | mrbgems/mruby-rational/mrblib/rational.rb | 2 | ||||
| -rw-r--r-- | mrbgems/mruby-rational/src/rational.c | 2 | ||||
| -rw-r--r-- | mrbgems/mruby-rational/test/rational.rb | 12 | ||||
| -rw-r--r-- | mrbgems/mruby-socket/src/socket.c | 2 | ||||
| -rw-r--r-- | mrbgems/mruby-struct/src/struct.c | 4 |
16 files changed, 34 insertions, 34 deletions
diff --git a/mrbgems/mruby-complex/mrblib/complex.rb b/mrbgems/mruby-complex/mrblib/complex.rb index 74c128a07..67f940865 100644 --- a/mrbgems/mruby-complex/mrblib/complex.rb +++ b/mrbgems/mruby-complex/mrblib/complex.rb @@ -104,7 +104,7 @@ class Complex < Numeric alias_method :imag, :imaginary - [Fixnum, Float].each do |cls| + [Integer, Float].each do |cls| [:+, :-, :*, :/, :==].each do |op| cls.instance_eval do original_operator_name = :"__original_operator_#{op}_complex" diff --git a/mrbgems/mruby-io/mrblib/file.rb b/mrbgems/mruby-io/mrblib/file.rb index aa73252e1..9398acef6 100644 --- a/mrbgems/mruby-io/mrblib/file.rb +++ b/mrbgems/mruby-io/mrblib/file.rb @@ -2,7 +2,7 @@ class File < IO attr_accessor :path def initialize(fd_or_path, mode = "r", perm = 0666) - if fd_or_path.kind_of? Fixnum + if fd_or_path.kind_of? Integer super(fd_or_path, mode) else @path = fd_or_path diff --git a/mrbgems/mruby-io/mrblib/io.rb b/mrbgems/mruby-io/mrblib/io.rb index e597db886..034f88529 100644 --- a/mrbgems/mruby-io/mrblib/io.rb +++ b/mrbgems/mruby-io/mrblib/io.rb @@ -186,7 +186,7 @@ class IO def read(length = nil, outbuf = "") unless length.nil? - unless length.is_a? Fixnum + unless length.is_a? Integer raise TypeError.new "can't convert #{length.class} into Integer" end if length < 0 @@ -229,7 +229,7 @@ class IO case arg when String rs = arg - when Fixnum + when Integer rs = "\n" limit = arg else diff --git a/mrbgems/mruby-io/test/io.rb b/mrbgems/mruby-io/test/io.rb index 2088a61e3..47c70cc60 100644 --- a/mrbgems/mruby-io/test/io.rb +++ b/mrbgems/mruby-io/test/io.rb @@ -7,7 +7,7 @@ $cr, $crlf, $cmd = MRubyIOTestUtil.win? ? [1, "\r\n", "cmd /c "] : [0, "\n", ""] def assert_io_open(meth) assert "assert_io_open" do fd = IO.sysopen($mrbtest_io_rfname) - assert_equal Fixnum, fd.class + assert_equal Integer, fd.class io1 = IO.__send__(meth, fd) begin assert_equal IO, io1.class @@ -433,7 +433,7 @@ assert('IO.popen') do $? = nil io = IO.popen("#{$cmd}echo mruby-io") assert_true io.close_on_exec? - assert_equal Fixnum, io.pid.class + assert_equal Integer, io.pid.class out = io.read assert_equal out.class, String diff --git a/mrbgems/mruby-kernel-ext/src/kernel.c b/mrbgems/mruby-kernel-ext/src/kernel.c index eaf8c6eb0..e738287db 100644 --- a/mrbgems/mruby-kernel-ext/src/kernel.c +++ b/mrbgems/mruby-kernel-ext/src/kernel.c @@ -84,7 +84,7 @@ mrb_f_method(mrb_state *mrb, mrb_value self) * call-seq: * Integer(arg,base=0) -> integer * - * Converts <i>arg</i> to a <code>Fixnum</code>. + * Converts <i>arg</i> to a <code>Integer</code>. * Numeric types are converted directly (with floating point numbers * being truncated). <i>base</i> (0, or between 2 and 36) is a base for * integer string representation. If <i>arg</i> is a <code>String</code>, diff --git a/mrbgems/mruby-math/src/math.c b/mrbgems/mruby-math/src/math.c index fcde7e700..f2622109d 100644 --- a/mrbgems/mruby-math/src/math.c +++ b/mrbgems/mruby-math/src/math.c @@ -629,7 +629,7 @@ math_cbrt(mrb_state *mrb, mrb_value obj) * Math.frexp(numeric) -> [ fraction, exponent ] * * Returns a two-element array containing the normalized fraction (a - * <code>Float</code>) and exponent (a <code>Fixnum</code>) of + * <code>Float</code>) and exponent (a <code>Integer</code>) of * <i>numeric</i>. * * fraction, exponent = Math.frexp(1234) #=> [0.6025390625, 11] diff --git a/mrbgems/mruby-metaprog/test/metaprog.rb b/mrbgems/mruby-metaprog/test/metaprog.rb index 82ba0a3a5..84f4e00a0 100644 --- a/mrbgems/mruby-metaprog/test/metaprog.rb +++ b/mrbgems/mruby-metaprog/test/metaprog.rb @@ -395,15 +395,15 @@ end assert('alias_method and remove_method') do begin - Fixnum.alias_method :to_s_, :to_s - Fixnum.remove_method :to_s + Integer.alias_method :to_s_, :to_s + Integer.remove_method :to_s assert_nothing_raised do # segfaults if mrb_cptr is used 1.to_s end ensure - Fixnum.alias_method :to_s, :to_s_ - Fixnum.remove_method :to_s_ + Integer.alias_method :to_s, :to_s_ + Integer.remove_method :to_s_ end end diff --git a/mrbgems/mruby-method/test/method.rb b/mrbgems/mruby-method/test/method.rb index 641979d71..123ae34be 100644 --- a/mrbgems/mruby-method/test/method.rb +++ b/mrbgems/mruby-method/test/method.rb @@ -77,7 +77,7 @@ end assert 'instance' do assert_kind_of Method, 1.method(:+) - assert_kind_of UnboundMethod, Fixnum.instance_method(:+) + assert_kind_of UnboundMethod, Integer.instance_method(:+) end assert 'Method#call' do @@ -404,9 +404,9 @@ assert 'UnboundMethod#arity' do end assert 'UnboundMethod#==' do - assert_false(Fixnum.instance_method(:+) == Fixnum.instance_method(:-)) - assert_true(Fixnum.instance_method(:+) == Fixnum.instance_method(:+)) - assert_false(Fixnum.instance_method(:+) == Float.instance_method(:+)) + assert_false(Integer.instance_method(:+) == Integer.instance_method(:-)) + assert_true(Integer.instance_method(:+) == Integer.instance_method(:+)) + assert_false(Integer.instance_method(:+) == Float.instance_method(:+)) assert_true(UnboundMethod.instance_method(:==) == UnboundMethod.instance_method(:eql?)) end diff --git a/mrbgems/mruby-pack/src/pack.c b/mrbgems/mruby-pack/src/pack.c index 45427afa0..f797b599b 100644 --- a/mrbgems/mruby-pack/src/pack.c +++ b/mrbgems/mruby-pack/src/pack.c @@ -290,7 +290,7 @@ unpack_l(mrb_state *mrb, const unsigned char *src, int srclen, mrb_value ary, un #ifndef MRB_INT64 if (!FIXABLE(sl)) { i32tostr(msg, sizeof(msg), sl); - mrb_raisef(mrb, E_RANGE_ERROR, "cannot unpack to Fixnum: %s", msg); + mrb_raisef(mrb, E_RANGE_ERROR, "cannot unpack to Integer: %s", msg); } #endif n = sl; @@ -298,7 +298,7 @@ unpack_l(mrb_state *mrb, const unsigned char *src, int srclen, mrb_value ary, un #ifndef MRB_INT64 if (!POSFIXABLE(ul)) { u32tostr(msg, sizeof(msg), ul); - mrb_raisef(mrb, E_RANGE_ERROR, "cannot unpack to Fixnum: %s", msg); + mrb_raisef(mrb, E_RANGE_ERROR, "cannot unpack to Integer: %s", msg); } #endif n = ul; @@ -411,13 +411,13 @@ unpack_q(mrb_state *mrb, const unsigned char *src, int srclen, mrb_value ary, un int64_t sll = ull; if (!FIXABLE(sll)) { i64tostr(msg, sizeof(msg), sll); - mrb_raisef(mrb, E_RANGE_ERROR, "cannot unpack to Fixnum: %s", msg); + mrb_raisef(mrb, E_RANGE_ERROR, "cannot unpack to Integer: %s", msg); } n = (mrb_int)sll; } else { if (!POSFIXABLE(ull)) { u64tostr(msg, sizeof(msg), ull); - mrb_raisef(mrb, E_RANGE_ERROR, "cannot unpack to Fixnum: %s", msg); + mrb_raisef(mrb, E_RANGE_ERROR, "cannot unpack to Integer: %s", msg); } n = (mrb_int)ull; } diff --git a/mrbgems/mruby-random/test/random.rb b/mrbgems/mruby-random/test/random.rb index cf4a55141..f3067748b 100644 --- a/mrbgems/mruby-random/test/random.rb +++ b/mrbgems/mruby-random/test/random.rb @@ -32,8 +32,8 @@ assert("Random.srand") do end assert("return class of Kernel.rand") do - assert_kind_of(Fixnum, rand(3)) - assert_kind_of(Fixnum, rand(1.5)) + assert_kind_of(Integer, rand(3)) + assert_kind_of(Integer, rand(1.5)) assert_kind_of(Float, rand) assert_kind_of(Float, rand(0.5)) end diff --git a/mrbgems/mruby-range-ext/mrblib/range.rb b/mrbgems/mruby-range-ext/mrblib/range.rb index a213beb57..fadddc343 100644 --- a/mrbgems/mruby-range-ext/mrblib/range.rb +++ b/mrbgems/mruby-range-ext/mrblib/range.rb @@ -33,7 +33,7 @@ class Range # fast path for numerics if val.kind_of?(Numeric) && last.kind_of?(Numeric) - raise TypeError if exclude_end? && !last.kind_of?(Fixnum) + raise TypeError if exclude_end? && !last.kind_of?(Integer) return nil if val > last return nil if val == last && exclude_end? diff --git a/mrbgems/mruby-rational/mrblib/rational.rb b/mrbgems/mruby-rational/mrblib/rational.rb index b65f77e2f..489d89ebd 100644 --- a/mrbgems/mruby-rational/mrblib/rational.rb +++ b/mrbgems/mruby-rational/mrblib/rational.rb @@ -92,7 +92,7 @@ module Kernel [:+, :-, :*, :/, :<=>, :==, :<, :<=, :>, :>=].each do |op| original_operator_name = :"__original_operator_#{op}_rational" - Fixnum.instance_eval do + Integer.instance_eval do alias_method original_operator_name, op define_method op do |rhs| if rhs.is_a? Rational diff --git a/mrbgems/mruby-rational/src/rational.c b/mrbgems/mruby-rational/src/rational.c index f9470de86..fcaba3df5 100644 --- a/mrbgems/mruby-rational/src/rational.c +++ b/mrbgems/mruby-rational/src/rational.c @@ -200,7 +200,7 @@ void mrb_mruby_rational_gem_init(mrb_state *mrb) mrb_define_method(mrb, rat, "to_i", rational_to_i, MRB_ARGS_NONE()); mrb_define_method(mrb, rat, "to_r", rational_to_r, MRB_ARGS_NONE()); mrb_define_method(mrb, rat, "negative?", rational_negative_p, MRB_ARGS_NONE()); - mrb_define_method(mrb, mrb->fixnum_class, "to_r", fix_to_r, MRB_ARGS_NONE()); + mrb_define_method(mrb, mrb->integer_class, "to_r", fix_to_r, MRB_ARGS_NONE()); } void diff --git a/mrbgems/mruby-rational/test/rational.rb b/mrbgems/mruby-rational/test/rational.rb index a8ebb8ea2..3fb4e4e82 100644 --- a/mrbgems/mruby-rational/test/rational.rb +++ b/mrbgems/mruby-rational/test/rational.rb @@ -143,7 +143,7 @@ assert 'Rational#==, Rational#!=' do assert_equal_rational(false, 1r, ComplexLikeNumeric.new(2)) end -assert 'Fixnum#==(Rational), Fixnum#!=(Rational)' do +assert 'Integer#==(Rational), Integer#!=(Rational)' do assert_equal_rational(true, 2, Rational(4,2)) assert_equal_rational(true, -2, Rational(-4,2)) assert_equal_rational(true, -2, Rational(4,-2)) @@ -186,7 +186,7 @@ assert 'Rational#<=>' do assert_raise(NoMethodError) { 1r <=> ComplexLikeNumeric.new(2) } end -assert 'Fixnum#<=>(Rational)' do +assert 'Integer#<=>(Rational)' do assert_cmp(-1, -2, Rational(-9,5)) assert_cmp(0, 5, 5r) assert_cmp(1, 3, Rational(8,3)) @@ -210,7 +210,7 @@ assert 'Rational#<' do assert_raise(ArgumentError) { 1r < "2" } end -assert 'Fixnum#<(Rational)' do +assert 'Integer#<(Rational)' do assert_not_operator(1, :<, Rational(2,3)) assert_not_operator(2, :<, 2r) assert_operator(-3, :<, Rational(2,3)) @@ -234,7 +234,7 @@ assert 'Rational#<=' do assert_raise(ArgumentError) { 1r <= "2" } end -assert 'Fixnum#<=(Rational)' do +assert 'Integer#<=(Rational)' do assert_not_operator(1, :<=, Rational(2,3)) assert_operator(2, :<=, 2r) assert_operator(-3, :<=, Rational(2,3)) @@ -258,7 +258,7 @@ assert 'Rational#>' do assert_raise(ArgumentError) { 1r > "2" } end -assert 'Fixnum#>(Rational)' do +assert 'Integer#>(Rational)' do assert_operator(1, :>, Rational(2,3)) assert_not_operator(2, :>, 2r) assert_not_operator(-3, :>, Rational(2,3)) @@ -282,7 +282,7 @@ assert 'Rational#>=' do assert_raise(ArgumentError) { 1r >= "2" } end -assert 'Fixnum#>=(Rational)' do +assert 'Integer#>=(Rational)' do assert_operator(1, :>=, Rational(2,3)) assert_operator(2, :>=, 2r) assert_not_operator(-3, :>=, Rational(2,3)) diff --git a/mrbgems/mruby-socket/src/socket.c b/mrbgems/mruby-socket/src/socket.c index 001021b81..6542c1603 100644 --- a/mrbgems/mruby-socket/src/socket.c +++ b/mrbgems/mruby-socket/src/socket.c @@ -145,7 +145,7 @@ mrb_addrinfo_getaddrinfo(mrb_state *mrb, mrb_value klass) } else if (mrb_nil_p(service)) { servname = NULL; } else { - mrb_raise(mrb, E_TYPE_ERROR, "service must be String, Fixnum, or nil"); + mrb_raise(mrb, E_TYPE_ERROR, "service must be String, Integer, or nil"); } memset(&hints, 0, sizeof(hints)); diff --git a/mrbgems/mruby-struct/src/struct.c b/mrbgems/mruby-struct/src/struct.c index 4f50fe5dd..423cf99a5 100644 --- a/mrbgems/mruby-struct/src/struct.c +++ b/mrbgems/mruby-struct/src/struct.c @@ -604,8 +604,8 @@ mrb_struct_eql(mrb_state *mrb, mrb_value s) /* * call-seq: - * struct.length -> Fixnum - * struct.size -> Fixnum + * struct.length -> Integer + * struct.size -> Integer * * Returns number of struct members. */ |
