[前][次][番号順一覧][スレッド一覧]

ruby-changes:23826

From: tadf <ko1@a...>
Date: Sun, 3 Jun 2012 14:05:44 +0900 (JST)
Subject: [ruby-changes:23826] tadf:r35877 (trunk): * complex.c: wrote Complex#_dump and Complex::load. But now

tadf	2012-06-03 14:05:29 +0900 (Sun, 03 Jun 2012)

  New Revision: 35877

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35877

  Log:
    * complex.c: wrote Complex#_dump and Complex::load.  But now
      disabled (due to compatibility) [experimental].
    
    * rational.c: wrote Rational#_dump and Rational::load. ditto.

  Modified files:
    trunk/ChangeLog
    trunk/complex.c
    trunk/rational.c
    trunk/test/ruby/test_complex.rb
    trunk/test/ruby/test_rational.rb

Index: complex.c
===================================================================
--- complex.c	(revision 35876)
+++ complex.c	(revision 35877)
@@ -1254,8 +1254,21 @@
     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)
 {
     get_dat1(self);
@@ -1272,6 +1285,17 @@
     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 @@
     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
 
     /* --- */
 
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 35876)
+++ ChangeLog	(revision 35877)
@@ -1,3 +1,10 @@
+Sun Jun  3 14:00:51 2012  Tadayoshi Funaba  <tadf@d...>
+
+	* 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@d...>
 
 	* complex.c (nucomp_marshal_load): [ruby-core:45394]
Index: test/ruby/test_complex.rb
===================================================================
--- test/ruby/test_complex.rb	(revision 35876)
+++ test/ruby/test_complex.rb	(revision 35877)
@@ -657,6 +657,7 @@
       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 @@
     c.freeze
     assert(c.frozen?)
     assert_raise(RuntimeError){c.marshal_load([2,3])}
+=end
   end
 
   def test_parse
Index: test/ruby/test_rational.rb
===================================================================
--- test/ruby/test_rational.rb	(revision 35876)
+++ test/ruby/test_rational.rb	(revision 35877)
@@ -823,6 +823,7 @@
     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 @@
     c.freeze
     assert(c.frozen?)
     assert_raise(RuntimeError){c.marshal_load([2,3])}
+=end
   end
 
   def test_parse
Index: rational.c
===================================================================
--- rational.c	(revision 35876)
+++ rational.c	(revision 35877)
@@ -1600,8 +1600,21 @@
     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)
 {
     get_dat1(self);
@@ -1622,6 +1635,17 @@
     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 @@
     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
 
     /* --- */
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]