Commit 41d0069f authored by Xavier Thompson's avatar Xavier Thompson

Make operator [] work for cypclasses

parent 903f11a5
......@@ -4172,7 +4172,10 @@ class IndexNode(_IndexingBaseNode):
if (self.type.is_ptr or self.type.is_array) and self.type == self.base.type:
error(self.pos, "Invalid use of pointer slice")
return
index_code = "(%s[%s])"
if self.base.type.is_cyp_class:
index_code = "((*%s)[%s])"
else:
index_code = "(%s[%s])"
return index_code % (self.base.result(), self.index.result())
def extra_index_params(self, code):
......@@ -4245,8 +4248,11 @@ class IndexNode(_IndexingBaseNode):
index_code = self.index.py_result()
if self.base.type.is_cpp_class and self.exception_check:
base_result = self.base.result()
if self.base.type.is_cyp_class:
base_result = "(*%s)" % base_result
translate_cpp_exception(code, self.pos,
"%s = %s[%s];" % (self.result(), self.base.result(),
"%s = %s[%s];" % (self.result(), base_result,
self.index.result()),
self.result() if self.type.is_pyobject else None,
self.exception_value, self.in_nogil_context)
......
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