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
c4a21c58
Commit
c4a21c58
authored
Mar 15, 2012
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix C++ template fused type specialization
parent
a099ddbe
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
16 deletions
+23
-16
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+7
-2
tests/run/fused_cpp.pyx
tests/run/fused_cpp.pyx
+16
-0
tests/run/fused_types.pyx
tests/run/fused_types.pyx
+0
-14
No files found.
Cython/Compiler/Nodes.py
View file @
c4a21c58
...
@@ -439,6 +439,10 @@ class CNameDeclaratorNode(CDeclaratorNode):
...
@@ -439,6 +439,10 @@ class CNameDeclaratorNode(CDeclaratorNode):
else
:
else
:
self
.
name
=
base_type
.
declaration_code
(
""
,
for_display
=
1
,
pyrex
=
1
)
self
.
name
=
base_type
.
declaration_code
(
""
,
for_display
=
1
,
pyrex
=
1
)
base_type
=
py_object_type
base_type
=
py_object_type
if
base_type
.
is_fused
and
env
.
fused_to_specific
:
base_type
=
base_type
.
specialize
(
env
.
fused_to_specific
)
self
.
type
=
base_type
self
.
type
=
base_type
return
self
,
base_type
return
self
,
base_type
...
@@ -963,8 +967,6 @@ class TemplatedTypeNode(CBaseTypeNode):
...
@@ -963,8 +967,6 @@ class TemplatedTypeNode(CBaseTypeNode):
for
name
,
value
in
options
.
items
()
])
for
name
,
value
in
options
.
items
()
])
self
.
type
=
PyrexTypes
.
BufferType
(
base_type
,
**
options
)
self
.
type
=
PyrexTypes
.
BufferType
(
base_type
,
**
options
)
if
self
.
type
.
is_fused
and
env
.
fused_to_specific
:
self
.
type
=
self
.
type
.
specialize
(
env
.
fused_to_specific
)
else
:
else
:
# Array
# Array
...
@@ -984,6 +986,9 @@ class TemplatedTypeNode(CBaseTypeNode):
...
@@ -984,6 +986,9 @@ class TemplatedTypeNode(CBaseTypeNode):
dimension
=
dimension
)
dimension
=
dimension
)
self
.
type
=
self
.
array_declarator
.
analyse
(
base_type
,
env
)[
1
]
self
.
type
=
self
.
array_declarator
.
analyse
(
base_type
,
env
)[
1
]
if
self
.
type
.
is_fused
and
env
.
fused_to_specific
:
self
.
type
=
self
.
type
.
specialize
(
env
.
fused_to_specific
)
return
self
.
type
return
self
.
type
class
CComplexBaseTypeNode
(
CBaseTypeNode
):
class
CComplexBaseTypeNode
(
CBaseTypeNode
):
...
...
tests/run/fused_cpp.pyx
0 → 100644
View file @
c4a21c58
# tag: cpp
cimport
cython
from
libcpp.vector
cimport
vector
def
test_cpp_specialization
(
cython
.
floating
element
):
"""
>>> import cython
>>> test_cpp_specialization[cython.float](10.0)
vector<float> * float 10.0
>>> test_cpp_specialization[cython.double](10.0)
vector<double> * double 10.0
"""
cdef
vector
[
cython
.
floating
]
*
v
=
new
vector
[
cython
.
floating
]()
v
.
push_back
(
element
)
print
cython
.
typeof
(
v
),
cython
.
typeof
(
element
),
v
.
at
(
0
)
\ No newline at end of file
tests/run/fused_types.pyx
View file @
c4a21c58
...
@@ -272,17 +272,3 @@ def test_fused_memslice_dtype(cython.floating[:] array):
...
@@ -272,17 +272,3 @@ def test_fused_memslice_dtype(cython.floating[:] array):
cdef
cython
.
floating
[:]
otherarray
=
array
[
0
:
100
:
1
]
cdef
cython
.
floating
[:]
otherarray
=
array
[
0
:
100
:
1
]
print
cython
.
typeof
(
array
),
cython
.
typeof
(
otherarray
),
\
print
cython
.
typeof
(
array
),
cython
.
typeof
(
otherarray
),
\
array
[
5
],
otherarray
[
6
]
array
[
5
],
otherarray
[
6
]
# FIXME: broken
#from libcpp.vector cimport vector
#def test_cpp_specialization(cython.floating element):
# """
# >>> import cython
# >>> test_cpp_specialization[cython.float](10.0)
# vector<float> * float 10.0
# >>> test_cpp_specialization[cython.double](10.0)
# vector<double> * double 10.0
# """
# cdef vector[cython.floating] *v = new vector[cython.floating]()
# v.push_back(element)
# print cython.typeof(v), cython.typeof(element), v.at(0)
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