Commit 583c6a3a authored by Kevin Modzelewski's avatar Kevin Modzelewski Committed by Kevin Modzelewski

Get some internal iterator logic working

parent 4db15e2a
......@@ -541,7 +541,16 @@ public:
BoxIteratorImpl* impl;
BoxIterator(BoxIteratorImpl* impl) : impl(impl) {}
~BoxIterator() = default;
BoxIterator(const BoxIterator& rhs) = default;
BoxIterator(BoxIterator&& rhs) {
impl = rhs.impl;
rhs.impl = NULL;
}
~BoxIterator() {
if (impl)
impl->~BoxIteratorImpl();
}
static llvm::iterator_range<BoxIterator> getRange(Box* container);
bool operator==(BoxIterator const& rhs) const { return impl->isSame(rhs.impl); }
......
......@@ -135,7 +135,10 @@ public:
static void dealloc(Box* b) noexcept {
BoxedXrangeIterator* self = static_cast<BoxedXrangeIterator*>(b);
_PyObject_GC_UNTRACK(self);
Py_DECREF(self->xrange);
self->cls->tp_free(self);
}
static int traverse(Box* s, visitproc visit, void *arg) noexcept {
BoxedXrangeIterator* self = static_cast<BoxedXrangeIterator*>(s);
......
......@@ -38,14 +38,21 @@ public:
}
}
~BoxIteratorGeneric() {
assert(!value);
Py_XDECREF(iterator);
}
void next() override {
STAT_TIMER(t0, "us_timer_iteratorgeneric_next", 0);
assert(!value);
Box* next = PyIter_Next(iterator);
if (next) {
value = next;
} else {
checkAndThrowCAPIException();
Py_CLEAR(iterator);
*this = *end();
}
}
......
......@@ -809,7 +809,7 @@ Box* listIAdd(BoxedList* self, Box* _rhs) {
RELEASE_ASSERT(_rhs != self, "unsupported");
for (auto* b : _rhs->pyElements())
listAppendInternal(self, b);
listAppendInternalStolen(self, b);
Py_INCREF(self);
return self;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment