Commit c4a21c58 authored by Mark Florisson's avatar Mark Florisson

Fix C++ template fused type specialization

parent a099ddbe
......@@ -439,6 +439,10 @@ class CNameDeclaratorNode(CDeclaratorNode):
else:
self.name = base_type.declaration_code("", for_display=1, pyrex=1)
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
return self, base_type
......@@ -963,8 +967,6 @@ class TemplatedTypeNode(CBaseTypeNode):
for name, value in options.items() ])
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:
# Array
......@@ -984,6 +986,9 @@ class TemplatedTypeNode(CBaseTypeNode):
dimension = dimension)
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
class CComplexBaseTypeNode(CBaseTypeNode):
......
# 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
......@@ -272,17 +272,3 @@ def test_fused_memslice_dtype(cython.floating[:] array):
cdef cython.floating[:] otherarray = array[0:100:1]
print cython.typeof(array), cython.typeof(otherarray), \
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)
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