06 Apr 2010
 
 
 
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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);
}