Commit 4d2a3233 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent fd728734
...@@ -7462,7 +7462,7 @@ class SequenceNode(ExprNode): ...@@ -7462,7 +7462,7 @@ class SequenceNode(ExprNode):
', '.join(arg.py_result() for arg in self.args), ', '.join(arg.py_result() for arg in self.args),
code.error_goto_if_null(target, self.pos))) code.error_goto_if_null(target, self.pos)))
code.put_gotref(target) code.put_gotref(target)
elif self.type.is_ctuple: elif self.type.is_ctuple: # NOTE
for i, arg in enumerate(self.args): for i, arg in enumerate(self.args):
code.putln("%s.f%s = %s;" % ( code.putln("%s.f%s = %s;" % (
target, i, arg.result())) target, i, arg.result()))
......
...@@ -213,7 +213,7 @@ def create_pipeline(context, mode, exclude_classes=()): ...@@ -213,7 +213,7 @@ def create_pipeline(context, mode, exclude_classes=()):
#PrintTree(), #PrintTree(),
AnalyseExpressionsTransform(context), AnalyseExpressionsTransform(context),
#PrintTree(), PrintTree(),
FindInvalidUseOfFusedTypes(context), FindInvalidUseOfFusedTypes(context),
ExpandInplaceOperators(context), ExpandInplaceOperators(context),
......
...@@ -3579,6 +3579,25 @@ class CppClassType(CType): ...@@ -3579,6 +3579,25 @@ class CppClassType(CType):
return True return True
return False return False
# FIXME wrong place: for coercion not only type is needed - but note (e.g.
# actual variable name)
def coerce_to(self, dst_type, env):
if self.cname == "std::pair" and dst_type.is_ctuple:
node = self._coerce_pair_to_ctuple(dst_type, env)
if node is not None:
return node
return super(CppClassType, self).coerce_to(dst_type, env)
# std::pair[X,Y] -> ctuple(X,Y)
def _coerce_pair_to_ctuple(self, dst_type, env): # -> node | None
if not (len(self.templates) == len(dst_type.components) == 2):
return None
for (c_src, c_dst) in zip(self.templates, dst_type.components):
if not c_src.same_as(c_dst):
return None
# can be converted
def create_from_py_utility_code(self, env): def create_from_py_utility_code(self, env):
if self.from_py_function is not None: if self.from_py_function is not None:
return True return True
...@@ -4062,6 +4081,8 @@ class CTupleType(CType): ...@@ -4062,6 +4081,8 @@ class CTupleType(CType):
env.use_utility_code(self._convert_from_py_code) env.use_utility_code(self._convert_from_py_code)
return True return True
# XXX kill
"""
def assignable_from_resolved_type(self, src_type): def assignable_from_resolved_type(self, src_type):
# (X,Y) can be assigned from std::pair[X,Y] # (X,Y) can be assigned from std::pair[X,Y]
if src_type.is_cpp_class and src_type.cname == "std::pair": if src_type.is_cpp_class and src_type.cname == "std::pair":
...@@ -4070,21 +4091,11 @@ class CTupleType(CType): ...@@ -4070,21 +4091,11 @@ class CTupleType(CType):
for (c_dst, c_src) in zip(self.components, src_type.templates): for (c_dst, c_src) in zip(self.components, src_type.templates):
if not c_dst.same_as(c_src): if not c_dst.same_as(c_src):
return False return False
return True #return True
return False
"""
print
#from Cython.Compiler.Pipeline import dumptree
#dumptree(src_type)
print src_type
print src_type.name
print src_type.cname
print src_type.templates
print
return 1 # XXX check types are the same
"""
return super(CTupleType, self).assignable_from_resolved_type(src_type) return super(CTupleType, self).assignable_from_resolved_type(src_type)
"""
def c_tuple_type(components): def c_tuple_type(components):
......
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