diff options
author | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-16 10:21:23 +0000 |
---|---|---|
committer | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-09-16 10:21:23 +0000 |
commit | 7c3b57b5d15e3a9a1a82523478f1b4f7035d405d (patch) | |
tree | 7750c86ba090665963adb024be13d3a32a5488eb | |
parent | 73c8f0238448cfb401b1d2e7afec44763defd833 (diff) | |
download | ruby-7c3b57b5d15e3a9a1a82523478f1b4f7035d405d.tar.gz |
* complex.c (nucomp_marshal_{dump,load}): preserve instance
variables.
* rational.c (nurat_marshal_{dump,load}): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19382 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | complex.c | 7 | ||||
-rw-r--r-- | rational.c | 7 | ||||
-rw-r--r-- | test/ruby/test_complex.rb | 2 | ||||
-rw-r--r-- | test/ruby/test_rational.rb | 2 |
5 files changed, 24 insertions, 3 deletions
@@ -1,3 +1,10 @@ +Tue Sep 16 19:18:40 2008 Tadayoshi Funaba <tadf@dotrb.org> + + * complex.c (nucomp_marshal_{dump,load}): preserve instance + variables. + + * rational.c (nurat_marshal_{dump,load}): ditto. + Tue Sep 16 18:28:52 2008 Yukihiro Matsumoto <matz@ruby-lang.org> * io.c (rb_io_gets_m): rdoc updated. limit counts in bytes. @@ -251,7 +258,7 @@ Sun Sep 14 13:48:03 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp> Sun Sep 14 10:10:43 2008 Tadayoshi Funaba <tadf@dotrb.org> - * complex.c (f_{add,mul,sub}): omitted some shortcuts for preserve + * complex.c (f_{add,mul,sub}): omitted some shortcuts for preserving signed zero anyway. * complex.c (nucomp_negate): new. @@ -937,8 +937,12 @@ nucomp_inspect(VALUE self) static VALUE nucomp_marshal_dump(VALUE self) { + VALUE a; get_dat1(self); - return rb_assoc_new(dat->real, dat->image); + + a = rb_assoc_new(dat->real, dat->image); + rb_copy_generic_ivar(a, self); + return a; } static VALUE @@ -947,6 +951,7 @@ nucomp_marshal_load(VALUE self, VALUE a) get_dat1(self); dat->real = RARRAY_PTR(a)[0]; dat->image = RARRAY_PTR(a)[1]; + rb_copy_generic_ivar(self, a); return self; } diff --git a/rational.c b/rational.c index 5669a7beb6..a592ae31e9 100644 --- a/rational.c +++ b/rational.c @@ -1125,8 +1125,12 @@ nurat_inspect(VALUE self) static VALUE nurat_marshal_dump(VALUE self) { + VALUE a; get_dat1(self); - return rb_assoc_new(dat->num, dat->den); + + a = rb_assoc_new(dat->num, dat->den); + rb_copy_generic_ivar(a, self); + return a; } static VALUE @@ -1135,6 +1139,7 @@ nurat_marshal_load(VALUE self, VALUE a) get_dat1(self); dat->num = RARRAY_PTR(a)[0]; dat->den = RARRAY_PTR(a)[1]; + rb_copy_generic_ivar(self, a); if (f_zero_p(dat->den)) rb_raise_zerodiv(); diff --git a/test/ruby/test_complex.rb b/test/ruby/test_complex.rb index 493e2e2c39..af2311ca00 100644 --- a/test/ruby/test_complex.rb +++ b/test/ruby/test_complex.rb @@ -638,10 +638,12 @@ class Complex_Test < Test::Unit::TestCase def test_marshal c = Complex(1,2) + c.instance_eval{@ivar = 9} s = Marshal.dump(c) c2 = Marshal.load(s) assert_equal(c, c2) + assert_equal(9, c2.instance_variable_get(:@ivar)) assert_instance_of(Complex, c2) if defined?(Rational) diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb index 1d280e4361..de8c31dbc5 100644 --- a/test/ruby/test_rational.rb +++ b/test/ruby/test_rational.rb @@ -854,10 +854,12 @@ class Rational_Test < Test::Unit::TestCase def test_marshal c = Rational(1,2) + c.instance_eval{@ivar = 9} s = Marshal.dump(c) c2 = Marshal.load(s) assert_equal(c, c2) + assert_equal(9, c2.instance_variable_get(:@ivar)) assert_instance_of(Rational, c2) assert_raise(ZeroDivisionError){ |