IoObject *IoRange_next(IoRange *self, IoObject *locals, IoMessage *m)
{
/*doc Range next
Sets the current item in the range to the next item in the range,
and returns a boolean value indicating whether it is not at the end of the range.
*/
IoRangeData *rd = DATA(self);
IoObject *context;
IoObject *v = IoObject_rawGetSlot_context_(rd->curr, IOSYMBOL("nextInSequence"), &context);
IoObject *lt = IoObject_rawGetSlot_context_(rd->curr, IOSYMBOL("compare"), &context);
if (v && lt)
{
IoMessage *newMessage = IoMessage_new(IOSTATE);
IoMessage *anotherMessage = IoMessage_new(IOSTATE);
IoObject *r_lt, *ret;
IoMessage_setCachedArg_to_(newMessage, 0, rd->increment);
ret = IoObject_activate(v, rd->curr, locals, newMessage, context);
IoMessage_addCachedArg_(anotherMessage, rd->end);
r_lt = IoObject_activate(lt, ret, locals, anotherMessage, context);
IoNumber_print(ret); IoNumber_print(rd->end); IoNumber_print(r_lt);
if (rd->end > rd->start ? IoNumber_asInt(r_lt) <= 0 : IoNumber_asInt(r_lt) >= 0)
{
IoRange_setCurrent(self, ret);
IoRange_setIndex(self, IONUMBER(CNUMBER(rd->index) + 1));
return self;
}
}
return IONIL(self);
}