* enumerator.c (struct enumerator, enumerator_init)
(enumerator_init_copy, enumerator_each): Eliminate iter. (enumerator_ptr): Do not hardcode the class name. (enumerator_with_index): Delay variable initialization after RETURN_ENUMERATOR(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
224efac340
commit
71b059e070
@ -1,3 +1,11 @@
|
|||||||
|
Mon May 26 17:48:42 2008 Akinori MUSHA <knu@iDaemons.org>
|
||||||
|
|
||||||
|
* enumerator.c (struct enumerator, enumerator_init)
|
||||||
|
(enumerator_init_copy, enumerator_each): Eliminate iter.
|
||||||
|
(enumerator_ptr): Do not hardcode the class name.
|
||||||
|
(enumerator_with_index): Delay variable initialization after
|
||||||
|
RETURN_ENUMERATOR().
|
||||||
|
|
||||||
Mon May 26 17:23:49 2008 NAKAMURA Usaku <usa@ruby-lang.org>
|
Mon May 26 17:23:49 2008 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
* file.c (file_expand_path): add more space for '/'.
|
* file.c (file_expand_path): add more space for '/'.
|
||||||
|
13
enumerator.c
13
enumerator.c
@ -30,7 +30,6 @@ struct enumerator {
|
|||||||
VALUE obj;
|
VALUE obj;
|
||||||
ID meth;
|
ID meth;
|
||||||
VALUE args;
|
VALUE args;
|
||||||
rb_block_call_func *iter;
|
|
||||||
VALUE fib;
|
VALUE fib;
|
||||||
VALUE dst;
|
VALUE dst;
|
||||||
VALUE no_next;
|
VALUE no_next;
|
||||||
@ -54,8 +53,8 @@ enumerator_ptr(VALUE obj)
|
|||||||
Data_Get_Struct(obj, struct enumerator, ptr);
|
Data_Get_Struct(obj, struct enumerator, ptr);
|
||||||
if (RDATA(obj)->dmark != enumerator_mark) {
|
if (RDATA(obj)->dmark != enumerator_mark) {
|
||||||
rb_raise(rb_eTypeError,
|
rb_raise(rb_eTypeError,
|
||||||
"wrong argument type %s (expected Enumerable::Enumerator)",
|
"wrong argument type %s (expected %s)",
|
||||||
rb_obj_classname(obj));
|
rb_obj_classname(obj), rb_class2name(rb_cEnumerator));
|
||||||
}
|
}
|
||||||
if (!ptr) {
|
if (!ptr) {
|
||||||
rb_raise(rb_eArgError, "uninitialized enumerator");
|
rb_raise(rb_eArgError, "uninitialized enumerator");
|
||||||
@ -222,7 +221,6 @@ enumerator_init(VALUE enum_obj, VALUE obj, VALUE meth, int argc, VALUE *argv)
|
|||||||
|
|
||||||
ptr->obj = obj;
|
ptr->obj = obj;
|
||||||
ptr->meth = rb_to_id(meth);
|
ptr->meth = rb_to_id(meth);
|
||||||
ptr->iter = enumerator_each_i;
|
|
||||||
if (argc) ptr->args = rb_ary_new4(argc, argv);
|
if (argc) ptr->args = rb_ary_new4(argc, argv);
|
||||||
ptr->fib = 0;
|
ptr->fib = 0;
|
||||||
ptr->dst = Qnil;
|
ptr->dst = Qnil;
|
||||||
@ -272,7 +270,6 @@ enumerator_init_copy(VALUE obj, VALUE orig)
|
|||||||
|
|
||||||
ptr1->obj = ptr0->obj;
|
ptr1->obj = ptr0->obj;
|
||||||
ptr1->meth = ptr0->meth;
|
ptr1->meth = ptr0->meth;
|
||||||
ptr1->iter = ptr0->iter;
|
|
||||||
ptr1->args = ptr0->args;
|
ptr1->args = ptr0->args;
|
||||||
ptr1->fib = 0;
|
ptr1->fib = 0;
|
||||||
|
|
||||||
@ -306,7 +303,8 @@ enumerator_each(VALUE obj)
|
|||||||
argc = RARRAY_LEN(e->args);
|
argc = RARRAY_LEN(e->args);
|
||||||
argv = RARRAY_PTR(e->args);
|
argv = RARRAY_PTR(e->args);
|
||||||
}
|
}
|
||||||
return rb_block_call(e->obj, e->meth, argc, argv, e->iter, (VALUE)e);
|
return rb_block_call(e->obj, e->meth, argc, argv,
|
||||||
|
enumerator_each_i, (VALUE)e);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -329,12 +327,13 @@ enumerator_with_index_i(VALUE val, VALUE *memo)
|
|||||||
static VALUE
|
static VALUE
|
||||||
enumerator_with_index(VALUE obj)
|
enumerator_with_index(VALUE obj)
|
||||||
{
|
{
|
||||||
struct enumerator *e = enumerator_ptr(obj);
|
struct enumerator *e;
|
||||||
VALUE memo = 0;
|
VALUE memo = 0;
|
||||||
int argc = 0;
|
int argc = 0;
|
||||||
VALUE *argv = 0;
|
VALUE *argv = 0;
|
||||||
|
|
||||||
RETURN_ENUMERATOR(obj, 0, 0);
|
RETURN_ENUMERATOR(obj, 0, 0);
|
||||||
|
e = enumerator_ptr(obj);
|
||||||
if (e->args) {
|
if (e->args) {
|
||||||
argc = RARRAY_LEN(e->args);
|
argc = RARRAY_LEN(e->args);
|
||||||
argv = RARRAY_PTR(e->args);
|
argv = RARRAY_PTR(e->args);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user