Commit 915cc5d9 authored by Xavier Thompson's avatar Xavier Thompson

Fix iteration over cypclass containers

parent 8c755a42
......@@ -2884,7 +2884,11 @@ class IteratorNode(ExprNode):
def generate_result_code(self, code):
sequence_type = self.sequence.type
if sequence_type.is_cpp_class:
if sequence_type.is_cyp_class:
begin_func = "%s->begin" % self.sequence.result()
code.putln("%s = %s();" % (self.result(), begin_func))
return
elif sequence_type.is_cpp_class:
if self.sequence.is_name:
# safe: C++ won't allow you to reassign to class references
begin_func = "%s.begin" % self.sequence.result()
......@@ -2991,7 +2995,17 @@ class IteratorNode(ExprNode):
sequence_type = self.sequence.type
if self.reversed:
code.putln("if (%s < 0) break;" % self.counter_cname)
if sequence_type.is_cpp_class:
if sequence_type.is_cyp_class:
end_func = "%s->end" % self.sequence.result()
code.putln("if (!(%s != %s())) break;" % (
self.result(),
end_func))
code.putln("%s = *%s;" % (
result_name,
self.result()))
code.putln("++%s;" % self.result())
return
elif sequence_type.is_cpp_class:
if self.cpp_iterator_cname:
end_func = "%s->end" % self.cpp_iterator_cname
else:
......
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