diff options
Diffstat (limited to 'struct.c')
-rw-r--r-- | struct.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -429,6 +429,9 @@ rb_struct_new(VALUE klass, ...) return rb_class_new_instance(size, mem, klass); } +static VALUE +rb_struct_size(VALUE s); + /* * call-seq: * struct.each {|obj| block } -> struct @@ -455,7 +458,7 @@ rb_struct_each(VALUE s) { long i; - RETURN_ENUMERATOR(s, 0, 0); + RETURN_SIZED_ENUMERATOR(s, 0, 0, rb_struct_size); for (i=0; i<RSTRUCT_LEN(s); i++) { rb_yield(RSTRUCT_PTR(s)[i]); } @@ -489,7 +492,7 @@ rb_struct_each_pair(VALUE s) VALUE members; long i; - RETURN_ENUMERATOR(s, 0, 0); + RETURN_SIZED_ENUMERATOR(s, 0, 0, rb_struct_size); members = rb_struct_members(s); for (i=0; i<RSTRUCT_LEN(s); i++) { rb_yield_values(2, rb_ary_entry(members, i), RSTRUCT_PTR(s)[i]); @@ -793,7 +796,7 @@ rb_struct_select(int argc, VALUE *argv, VALUE s) long i; rb_check_arity(argc, 0, 0); - RETURN_ENUMERATOR(s, 0, 0); + RETURN_SIZED_ENUMERATOR(s, 0, 0, rb_struct_size); result = rb_ary_new(); for (i = 0; i < RSTRUCT_LEN(s); i++) { if (RTEST(rb_yield(RSTRUCT_PTR(s)[i]))) { |