ruby-changes:23835
From: tadf <ko1@a...>
Date: Sun, 3 Jun 2012 21:21:29 +0900 (JST)
Subject: [ruby-changes:23835] tadf:r35886 (trunk): * marshal.c: calls directly rb_{Complex,Rational}_marshal_load().
tadf 2012-06-03 21:21:18 +0900 (Sun, 03 Jun 2012) New Revision: 35886 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=35886 Log: * marshal.c: calls directly rb_{Complex,Rational}_marshal_load(). But now disabled. [experimental] * complex.c: followed the above. * rational.c: ditto. * include/rub/intern.h: ditto. Modified files: trunk/ChangeLog trunk/complex.c trunk/include/ruby/intern.h trunk/marshal.c trunk/rational.c Index: complex.c =================================================================== --- complex.c (revision 35885) +++ complex.c (revision 35886) @@ -1283,6 +1283,21 @@ return self; } +#ifdef MARSHAL_LOAD_DIRECT +/* :nodoc: */ +static VALUE +nucomp_marshal_load_fake(VALUE self, VALUE a) +{ + rb_raise(rb_eNotImpError, "not implemented"); +} + +VALUE +rb_Complex_marshal_load(VALUE obj, VALUE a) +{ + return nucomp_marshal_load(obj, a); +} +#endif + #ifdef MARSHAL_OLD_STYLE /* :nodoc: */ static VALUE @@ -1970,6 +1985,7 @@ rb_define_method(rb_cComplex, "to_s", nucomp_to_s, 0); rb_define_method(rb_cComplex, "inspect", nucomp_inspect, 0); +#ifndef MARSHAL_LOAD_DIRECT #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); @@ -1977,6 +1993,10 @@ rb_define_method(rb_cComplex, "_dump", nucomp_marshal__dump, 1); rb_define_singleton_method(rb_cComplex, "_load", nucomp_marshal__load, 1); #endif +#else + rb_define_method(rb_cComplex, "marshal_dump", nucomp_marshal_dump, 0); + rb_define_method(rb_cComplex, "marshal_load", nucomp_marshal_load_fake, 1); +#endif /* --- */ Index: include/ruby/intern.h =================================================================== --- include/ruby/intern.h (revision 35885) +++ include/ruby/intern.h (revision 35886) @@ -147,6 +147,9 @@ VALUE rb_Rational(VALUE, VALUE); #define rb_Rational1(x) rb_Rational((x), INT2FIX(1)) #define rb_Rational2(x,y) rb_Rational((x), (y)) +#ifdef MARSHAL_LOAD_DIRECT +VALUE rb_Rational_marshal_load(VALUE, VALUE); +#endif /* complex.c */ VALUE rb_complex_raw(VALUE, VALUE); #define rb_complex_raw1(x) rb_complex_raw((x), INT2FIX(0)) @@ -158,6 +161,9 @@ VALUE rb_Complex(VALUE, VALUE); #define rb_Complex1(x) rb_Complex((x), INT2FIX(0)) #define rb_Complex2(x,y) rb_Complex((x), (y)) +#ifdef MARSHAL_LOAD_DIRECT +VALUE rb_Complex_marshal_load(VALUE, VALUE); +#endif /* class.c */ VALUE rb_class_boot(VALUE); VALUE rb_class_new(VALUE); Index: ChangeLog =================================================================== --- ChangeLog (revision 35885) +++ ChangeLog (revision 35886) @@ -1,3 +1,11 @@ +Sun Jun 3 21:14:26 2012 Tadayoshi Funaba <tadf@d...> + + * marshal.c: calls directly rb_{Complex,Rational}_marshal_load(). + But now disabled. [experimental] + * complex.c: followed the above. + * rational.c: ditto. + * include/rub/intern.h: ditto. + Sun Jun 3 21:18:17 2012 Tanaka Akira <akr@f...> * process.c (rb_check_argv): use rb_str_new_frozen instead of Index: marshal.c =================================================================== --- marshal.c (revision 35885) +++ marshal.c (revision 35886) @@ -1622,7 +1622,21 @@ } v = r_entry(v, arg); data = r_object(arg); +#ifndef MARSHAL_LOAD_DIRECT rb_funcall(v, s_mload, 1, data); +#else + switch (TYPE(v)) { + case T_COMPLEX: + rb_Complex_marshal_load(v, data); + break; + case T_RATIONAL: + rb_Rational_marshal_load(v, data); + break; + default: + rb_funcall(v, s_mload, 1, data); + break; + } +#endif check_load_arg(arg, s_mload); v = r_leave(v, arg); } Index: rational.c =================================================================== --- rational.c (revision 35885) +++ rational.c (revision 35886) @@ -1632,6 +1632,21 @@ return self; } +#ifdef MARSHAL_LOAD_DIRECT +/* :nodoc: */ +static VALUE +nurat_marshal_load_fake(VALUE self, VALUE a) +{ + rb_raise(rb_eNotImpError, "not implemented"); +} + + VALUE +rb_Rational_marshal_load(VALUE obj, VALUE a) +{ + return nurat_marshal_load(obj, a); +} +#endif + #ifdef MARSHAL_OLD_STYLE /* :nodoc: */ static VALUE @@ -2393,6 +2408,7 @@ rb_define_method(rb_cRational, "to_s", nurat_to_s, 0); rb_define_method(rb_cRational, "inspect", nurat_inspect, 0); +#ifndef MARSHAL_LOAD_DIRECT #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); @@ -2400,6 +2416,10 @@ rb_define_method(rb_cRational, "_dump", nurat_marshal__dump, 1); rb_define_singleton_method(rb_cRational, "_load", nurat_marshal__load, 1); #endif +#else + rb_define_method(rb_cRational, "marshal_dump", nurat_marshal_dump, 0); + rb_define_method(rb_cRational, "marshal_load", nurat_marshal_load_fake, 1); +#endif /* --- */ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/