diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-12-05 06:35:07 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-12-05 06:35:07 +0000 |
commit | fffd5a383355ad05b00f59fb7c442d632996af56 (patch) | |
tree | 41b62895491f6a5c88ef6ae5990f9d2c24e3c109 /marshal.c | |
parent | 47d01e35ae59c469666854ff80de7951e02b4296 (diff) | |
download | ruby-fffd5a383355ad05b00f59fb7c442d632996af56.tar.gz ruby-fffd5a383355ad05b00f59fb7c442d632996af56.tar.xz ruby-fffd5a383355ad05b00f59fb7c442d632996af56.zip |
* marshal.c (w_object): dump instance variables when using
marshal_dump. [ruby-core:24211]
* variable.c (rb_ivar_count): added.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@26007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'marshal.c')
-rw-r--r-- | marshal.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -643,14 +643,23 @@ w_object(VALUE obj, struct dump_arg *arg, int limit) if (rb_respond_to(obj, s_mdump)) { volatile VALUE v; + int hasiv2 = 0; st_add_direct(arg->data, obj, arg->data->num_entries); v = rb_funcall(obj, s_mdump, 0, 0); check_dump_arg(arg, s_mdump); + if (!hasiv && (hasiv2 = rb_ivar_count(obj) > 0)) { + w_byte(TYPE_IVAR, arg); + } w_class(TYPE_USRMARSHAL, obj, arg, FALSE); w_object(v, arg, limit); - if (hasiv) w_ivar(obj, 0, &c_arg); + if (hasiv) { + w_ivar(obj, ivtbl, &c_arg); + } + else if (hasiv2) { + w_objivar(obj, &c_arg); + } return; } if (rb_respond_to(obj, s_dump)) { |