Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
482e38c4
Commit
482e38c4
authored
Aug 16, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
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
...
...
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
),
...
...
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
)
...
...
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
)
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