Commit 3cf53d8b authored by Xavier Thompson's avatar Xavier Thompson

Make operator [] work for cypclasses

parent 45ce500e
...@@ -4223,7 +4223,10 @@ class IndexNode(_IndexingBaseNode): ...@@ -4223,7 +4223,10 @@ class IndexNode(_IndexingBaseNode):
if (self.type.is_ptr or self.type.is_array) and self.type == self.base.type: if (self.type.is_ptr or self.type.is_array) and self.type == self.base.type:
error(self.pos, "Invalid use of pointer slice") error(self.pos, "Invalid use of pointer slice")
return 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()) return index_code % (self.base.result(), self.index.result())
def extra_index_params(self, code): def extra_index_params(self, code):
...@@ -4296,8 +4299,11 @@ class IndexNode(_IndexingBaseNode): ...@@ -4296,8 +4299,11 @@ class IndexNode(_IndexingBaseNode):
index_code = self.index.py_result() index_code = self.index.py_result()
if self.base.type.is_cpp_class and self.exception_check: 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, 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.index.result()),
self.result() if self.type.is_pyobject else None, self.result() if self.type.is_pyobject else None,
self.exception_value, self.in_nogil_context) 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