Project

General

Profile

Feature #13904 ยป poc.diff

znz (Kazuhiro NISHIYAMA), 09/15/2017 03:27 PM

View differences:

enumerator.c
1140 1140
    return e->size;
1141 1141
}
1142 1142

  
1143
static VALUE
1144
enumerator_receiver(VALUE obj)
1145
{
1146
    struct enumerator *e;
1147
    VALUE eobj;
1148
    TypedData_Get_Struct(obj, struct enumerator, &enumerator_data_type, e);
1149
    eobj = rb_attr_get(obj, id_receiver);
1150
    if (NIL_P(eobj)) {
1151
       eobj = e->obj;
1152
    }
1153
    return eobj;
1154
}
1155

  
1156
static VALUE
1157
enumerator_method_name(VALUE obj)
1158
{
1159
    struct enumerator *e;
1160
    TypedData_Get_Struct(obj, struct enumerator, &enumerator_data_type, e);
1161
    return ID2SYM(e->meth);
1162
}
1163

  
1164
static VALUE
1165
enumerator_arguments(VALUE obj)
1166
{
1167
    struct enumerator *e;
1168
    TypedData_Get_Struct(obj, struct enumerator, &enumerator_data_type, e);
1169
    return e->args;
1170
}
1171

  
1143 1172
/*
1144 1173
 * Yielder
1145 1174
 */
......
2357 2386
    rb_define_method(rb_cEnumerator, "rewind", enumerator_rewind, 0);
2358 2387
    rb_define_method(rb_cEnumerator, "inspect", enumerator_inspect, 0);
2359 2388
    rb_define_method(rb_cEnumerator, "size", enumerator_size, 0);
2389
    rb_define_method(rb_cEnumerator, "receiver", enumerator_receiver, 0);
2390
    rb_define_method(rb_cEnumerator, "method_name", enumerator_method_name, 0);
2391
    rb_define_method(rb_cEnumerator, "arguments", enumerator_arguments, 0);
2360 2392

  
2361 2393
    /* Lazy */
2362 2394
    rb_cLazy = rb_define_class_under(rb_cEnumerator, "Lazy", rb_cEnumerator);