21 lines
573 B
C
Raw Normal View History

2022-06-24 00:21:00 +08:00
#include "PikaObj.h"
Arg* PikaStdLib_RangeObj___next__(PikaObj* self) {
2022-09-16 21:01:18 +08:00
int start = args_getInt(self->list, "_start");
int end = args_getInt(self->list, "_end");
int step = args_getInt(self->list, "_step");
2022-06-24 00:21:00 +08:00
/* only start and end */
/* start */
int iter_i = args_getInt(self->list, "iter_i");
/* iter_i is not inited */
if (-999999999 == iter_i) {
iter_i = start;
}
/* exit */
if (iter_i >= end) {
return arg_newNull();
2022-06-24 00:21:00 +08:00
}
2022-09-16 21:01:18 +08:00
args_setInt(self->list, "iter_i", iter_i + step);
return arg_newInt(iter_i);
2022-06-24 00:21:00 +08:00
}