diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | complex.c | 29 | ||||
-rw-r--r-- | rational.c | 29 | ||||
-rw-r--r-- | test/ruby/test_complex.rb | 2 | ||||
-rw-r--r-- | test/ruby/test_rational.rb | 2 |
5 files changed, 69 insertions, 0 deletions
@@ -1,3 +1,10 @@ +Sun Jun 3 14:00:51 2012 Tadayoshi Funaba <tadf@dotrb.org> + + * complex.c: wrote Complex#_dump and Complex::load. But now + disabled (due to compatibility) [experimental]. + + * rational.c: wrote Rational#_dump and Rational::load. ditto. + Sun Jun 3 10:23:32 2012 Tadayoshi Funaba <tadf@dotrb.org> * complex.c (nucomp_marshal_load): [ruby-core:45394] @@ -1254,6 +1254,19 @@ nucomp_marshal_dump(VALUE self) return a; } +#ifdef MARSHAL_OLD_STYLE +VALUE marshal_dump(int, VALUE *); + +/* :nodoc: */ +static VALUE +nucomp_marshal__dump(VALUE self, VALUE limit) +{ + VALUE argv[1]; + argv[0] = nucomp_marshal_dump(self); + return marshal_dump(1, argv); +} +#endif + /* :nodoc: */ static VALUE nucomp_marshal_load(VALUE self, VALUE a) @@ -1272,6 +1285,17 @@ nucomp_marshal_load(VALUE self, VALUE a) return self; } +#ifdef MARSHAL_OLD_STYLE +VALUE marshal_load(int, VALUE *); + +/* :nodoc: */ +static VALUE +nucomp_marshal__load(VALUE klass, VALUE s) +{ + return nucomp_marshal_load(nucomp_s_alloc(klass), marshal_load(1, &s)); +} +#endif + /* --- */ VALUE @@ -1950,8 +1974,13 @@ Init_Complex(void) rb_define_method(rb_cComplex, "to_s", nucomp_to_s, 0); rb_define_method(rb_cComplex, "inspect", nucomp_inspect, 0); +#ifndef MARSHAL_OLD_STYLE rb_define_method(rb_cComplex, "marshal_dump", nucomp_marshal_dump, 0); rb_define_method(rb_cComplex, "marshal_load", nucomp_marshal_load, 1); +#else + rb_define_method(rb_cComplex, "_dump", nucomp_marshal__dump, 1); + rb_define_singleton_method(rb_cComplex, "_load", nucomp_marshal__load, 1); +#endif /* --- */ diff --git a/rational.c b/rational.c index c4469c8092..258f901d39 100644 --- a/rational.c +++ b/rational.c @@ -1600,6 +1600,19 @@ nurat_marshal_dump(VALUE self) return a; } +#ifdef MARSHAL_OLD_STYLE +VALUE marshal_dump(int, VALUE *); + +/* :nodoc: */ +static VALUE +nurat_marshal__dump(VALUE self, VALUE limit) +{ + VALUE argv[1]; + argv[0] = nurat_marshal_dump(self); + return marshal_dump(1, argv); +} +#endif + /* :nodoc: */ static VALUE nurat_marshal_load(VALUE self, VALUE a) @@ -1622,6 +1635,17 @@ nurat_marshal_load(VALUE self, VALUE a) return self; } +#ifdef MARSHAL_OLD_STYLE +VALUE marshal_load(int, VALUE *); + +/* :nodoc: */ +static VALUE +nurat_marshal__load(VALUE klass, VALUE s) +{ + return nurat_marshal_load(nurat_s_alloc(klass), marshal_load(1, &s)); +} +#endif + /* --- */ VALUE @@ -2374,8 +2398,13 @@ Init_Rational(void) rb_define_method(rb_cRational, "to_s", nurat_to_s, 0); rb_define_method(rb_cRational, "inspect", nurat_inspect, 0); +#ifndef MARSHAL_OLD_STYLE rb_define_method(rb_cRational, "marshal_dump", nurat_marshal_dump, 0); rb_define_method(rb_cRational, "marshal_load", nurat_marshal_load, 1); +#else + rb_define_method(rb_cRational, "_dump", nurat_marshal__dump, 1); + rb_define_singleton_method(rb_cRational, "_load", nurat_marshal__load, 1); +#endif /* --- */ diff --git a/test/ruby/test_complex.rb b/test/ruby/test_complex.rb index aa6d6a77fe..2ee97a0ad8 100644 --- a/test/ruby/test_complex.rb +++ b/test/ruby/test_complex.rb @@ -657,6 +657,7 @@ class Complex_Test < Test::Unit::TestCase assert_instance_of(Complex, c2) end +=begin bug3656 = '[ruby-core:31622]' assert_raise(TypeError, bug3656) { Complex(1,2).marshal_load(0) @@ -666,6 +667,7 @@ class Complex_Test < Test::Unit::TestCase c.freeze assert(c.frozen?) assert_raise(RuntimeError){c.marshal_load([2,3])} +=end end def test_parse diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb index e1aafb5a0a..497c476b1b 100644 --- a/test/ruby/test_rational.rb +++ b/test/ruby/test_rational.rb @@ -823,6 +823,7 @@ class Rational_Test < Test::Unit::TestCase assert_equal(9, c2.instance_variable_get(:@ivar)) assert_instance_of(Rational, c2) +=begin assert_raise(ZeroDivisionError){ Marshal.load("\x04\bU:\rRational[\ai\x06i\x05") } @@ -836,6 +837,7 @@ class Rational_Test < Test::Unit::TestCase c.freeze assert(c.frozen?) assert_raise(RuntimeError){c.marshal_load([2,3])} +=end end def test_parse |