Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Kirill Smelkov
cython
Commits
482e38c4
Commit
482e38c4
authored
5 years ago
by
Kirill Smelkov
Browse files
Options
Download
Email Patches
Plain Diff
X on ctuple <- std::pair
parent
14acda8e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
1 deletion
+39
-1
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+1
-1
Cython/Compiler/Pipeline.py
Cython/Compiler/Pipeline.py
+5
-0
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+17
-0
tests/run/cpp_ctuple.pyx
tests/run/cpp_ctuple.pyx
+16
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
482e38c4
...
...
@@ -855,7 +855,7 @@ class ExprNode(Node):
for node in self.subexpr_nodes():
node.annotate(code)
# ----------------- Coercion ----------------------
# ----------------- Coercion ----------------------
NOTE here
def coerce_to(self, dst_type, env):
# Coerce the result so that it can be assigned to
...
...
This diff is collapsed.
Click to expand it.
Cython/Compiler/Pipeline.py
View file @
482e38c4
...
...
@@ -179,6 +179,7 @@ def create_pipeline(context, mode, exclude_classes=()):
# code in pxd files. So it will be run multiple times in a
# compilation stage.
stages
=
[
#PrintTree(),
NormalizeTree
(
context
),
PostParse
(
context
),
_specific_post_parse
,
...
...
@@ -209,7 +210,11 @@ def create_pipeline(context, mode, exclude_classes=()):
IntroduceBufferAuxiliaryVars
(
context
),
_check_c_declarations
,
InlineDefNodeCalls
(
context
),
#PrintTree(),
AnalyseExpressionsTransform
(
context
),
#PrintTree(),
FindInvalidUseOfFusedTypes
(
context
),
ExpandInplaceOperators
(
context
),
IterationTransform
(
context
),
...
...
This diff is collapsed.
Click to expand it.
Cython/Compiler/PyrexTypes.py
View file @
482e38c4
...
...
@@ -4062,6 +4062,23 @@ class CTupleType(CType):
env
.
use_utility_code
(
self
.
_convert_from_py_code
)
return
True
def
assignable_from_resolved_type
(
self
,
src_type
):
if
src_type
.
is_cpp_class
and
src_type
.
cname
==
"std::pair"
and
len
(
src_type
.
templates
)
==
2
:
# XXX len self.xxx == len src_type.templates
# XXX types are assignable
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 match
return
super
(
CTupleType
,
self
).
assignable_from_resolved_type
(
src_type
)
def
c_tuple_type
(
components
):
components
=
tuple
(
components
)
...
...
This diff is collapsed.
Click to expand it.
tests/run/cpp_ctuple.pyx
0 → 100644
View file @
482e38c4
# mode: run
# tag: cpp
from
libcpp.utility
cimport
pair
cdef
(
int
,
double
)
_coerce_from_pair
(
pair
[
int
,
double
]
pxy
)
nogil
:
cdef
(
int
,
double
)
txy
=
pxy
return
txy
def
coerce_from_pair
(
int
x
,
double
y
):
"""
>>> coerce_from_pair(1, 3.14)
(1, 3.14)
"""
cdef
pair
[
int
,
double
]
pxy
=
(
x
,
y
)
return
_coerce_from_pair
(
pxy
)
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment