2021-12-27 21:41:17 +08:00
|
|
|
#include "PikaObj.h"
|
|
|
|
|
|
|
|
Arg* PikaStdLib_RangeObj___next__(PikaObj* self) {
|
2022-09-12 20:01:30 +08:00
|
|
|
int start = args_getInt(self->list, "_start");
|
|
|
|
int end = args_getInt(self->list, "_end");
|
|
|
|
int step = args_getInt(self->list, "_step");
|
2021-12-28 01:04:10 +08:00
|
|
|
/* only start and end */
|
|
|
|
/* start */
|
2022-01-04 15:55:46 +08:00
|
|
|
int iter_i = args_getInt(self->list, "iter_i");
|
2021-12-28 01:04:10 +08:00
|
|
|
/* iter_i is not inited */
|
|
|
|
if (-999999999 == iter_i) {
|
|
|
|
iter_i = start;
|
|
|
|
}
|
|
|
|
/* exit */
|
|
|
|
if (iter_i >= end) {
|
2022-07-20 10:32:01 +08:00
|
|
|
return arg_newNull();
|
2021-12-28 01:04:10 +08:00
|
|
|
}
|
2022-09-12 20:01:30 +08:00
|
|
|
args_setInt(self->list, "iter_i", iter_i + step);
|
2022-07-20 10:32:01 +08:00
|
|
|
return arg_newInt(iter_i);
|
2022-01-13 16:31:30 +08:00
|
|
|
}
|