Commit 62769c9a authored by Xavier Thompson's avatar Xavier Thompson

Fix unary operators '+' '-' and '~' for cypclasses

parent c8bc8d32
......@@ -10511,6 +10511,12 @@ class UnopNode(ExprNode):
return
self.type = cpp_type
def calculate_operation_result_code(self, operator):
op = self.operand.result()
if self.operand.type.is_cyp_class:
op = "(*%s)" % op
return "(%s%s)" % (operator, op)
class NotNode(UnopNode):
# 'not' operator
......@@ -10560,7 +10566,7 @@ class UnaryPlusNode(UnopNode):
def calculate_result_code(self):
if self.is_cpp_operation():
return "(+%s)" % self.operand.result()
return self.calculate_operation_result_code(self.operator)
else:
return self.operand.result()
......@@ -10586,7 +10592,7 @@ class UnaryMinusNode(UnopNode):
def calculate_result_code(self):
if self.infix:
return "(-%s)" % self.operand.result()
return self.calculate_operation_result_code(self.operator)
else:
return "%s(%s)" % (self.operand.type.unary_op('-'), self.operand.result())
......@@ -10611,7 +10617,7 @@ class TildeNode(UnopNode):
return "PyNumber_Invert"
def calculate_result_code(self):
return "(~%s)" % self.operand.result()
return self.calculate_operation_result_code('~')
class CUnopNode(UnopNode):
......@@ -10675,6 +10681,8 @@ class AmpersandNode(CUnopNode):
self.operand = self.operand.analyse_types(env)
argtype = self.operand.type
if argtype.is_cpp_class:
if argtype.is_cyp_class:
self.error("Cannot take address of cypclass")
self.analyse_cpp_operation(env, overload_check=False)
if not (argtype.is_cfunction or argtype.is_reference or self.operand.is_addressable()):
if argtype.is_memoryviewslice:
......
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