Commit 736b910d authored by Robert Bradshaw's avatar Robert Bradshaw

Fixes for nested templates.

parent ca6c6743
......@@ -1048,7 +1048,7 @@ class NewExprNode(AtomicExprNode):
# cppclass string c++ class to create
# template_parameters None or [ExprNode] temlate parameters, if any
def analyse_types(self, env):
def infer_type(self, env):
entry = env.lookup(self.cppclass)
if entry is None or not entry.is_cpp_class:
error(self.pos, "new operator can only be applied to a C++ class")
......@@ -1068,6 +1068,10 @@ class NewExprNode(AtomicExprNode):
self.class_type = type
self.entry = constructor
self.type = constructor.type
return self.type
def analyse_types(self, env):
self.infer_type(env)
def generate_result_code(self, code):
pass
......@@ -1803,7 +1807,7 @@ class IndexNode(ExprNode):
base_type = self.base.analyse_as_type(env)
if base_type and not base_type.is_pyobject:
if base_type.is_cpp_class:
if isinstance(self.index, TupleExprNode):
if isinstance(self.index, TupleNode):
template_values = self.index.args
else:
template_values = [self.index]
......
......@@ -792,7 +792,7 @@ class TemplatedTypeNode(CBaseTypeNode):
if base_type.is_cpp_class:
# Templated class
if len(self.keyword_args.key_value_pairs) != 0:
if self.keyword_args and self.keyword_args.key_value_pairs:
error(self.pos, "c++ templates cannot take keyword arguments");
self.type = PyrexTypes.error_type
else:
......
......@@ -9,6 +9,5 @@ missing_baseclass_in_predecl_T262
cfunc_call_tuple_args_T408
cascaded_list_unpacking_T467
compile.cpp_operators
cpp_nested_templates
cppwrap
cpp_overload_wrapper
from cython import dereference as deref
from cython.operator cimport dereference as deref
cdef extern from "cpp_templates_helper.h":
cdef cppclass Wrap[T]:
......@@ -17,15 +17,15 @@ cdef extern from "cpp_templates_helper.h":
def test_wrap_pair(int i, double x):
"""
>>> test_wrap_pair(1, 1.5)
(1, 1.5, True, False)
(1, 1.5, True)
>>> test_wrap_pair(2, 2.25)
(2, 2.25, True, False)
(2, 2.25, True)
"""
cdef Pair[int, double] *pair
cdef Wrap[Pair[int, double]] *wrap
try:
pair = new Pair[int, double](i, x)
warp = new Wrap[Pair[int, double]](deref(pair))
wrap = new Wrap[Pair[int, double]](deref(pair))
return wrap.get().first(), wrap.get().second(), deref(wrap) == deref(wrap)
finally:
del pair, wrap
......@@ -2,7 +2,7 @@ template <class T>
class Wrap {
T value;
public:
Wrap(T v) { value = v; }
Wrap(T v) : value(v) { }
void set(T v) { value = v; }
T get(void) { return value; }
bool operator==(Wrap<T> other) { return value == other.value; }
......
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