pikapython/package/PikaStdLib/PikaStdLib_RangeObj.c

15 lines
326 B
C
Raw Normal View History

2021-12-28 01:21:47 +08:00
#include "PikaObj.h"
Arg* PikaStdLib_RangeObj___next__(PikaObj* self) {
2022-10-13 01:24:58 +08:00
RangeData* _ = (RangeData*)args_getStruct(self->list, "_");
int end = _->end;
int step = _->step;
2021-12-28 01:21:47 +08:00
/* exit */
2022-10-13 01:24:58 +08:00
if (_->i >= end) {
2022-07-20 10:32:01 +08:00
return arg_newNull();
2021-12-28 01:21:47 +08:00
}
2022-10-13 01:24:58 +08:00
Arg* res = arg_newInt(_->i);
_->i += step;
return res;
}