Commit 01529c0c authored by Robert Bradshaw's avatar Robert Bradshaw

Allow arrays of C++ classes.

parent b4aff54d
...@@ -12,6 +12,8 @@ Bugs fixed ...@@ -12,6 +12,8 @@ Bugs fixed
if the already created module was used later on (e.g. through a if the already created module was used later on (e.g. through a
stale reference in sys.modules or elsewhere). stale reference in sys.modules or elsewhere).
* Allow arrays of C++ classes.
0.21 (2014-09-10) 0.21 (2014-09-10)
================= =================
......
...@@ -531,7 +531,7 @@ class CArrayDeclaratorNode(CDeclaratorNode): ...@@ -531,7 +531,7 @@ class CArrayDeclaratorNode(CDeclaratorNode):
child_attrs = ["base", "dimension"] child_attrs = ["base", "dimension"]
def analyse(self, base_type, env, nonempty = 0): def analyse(self, base_type, env, nonempty = 0):
if base_type.is_cpp_class or base_type.is_cfunction: if (base_type.is_cpp_class and base_type.is_template_type()) or base_type.is_cfunction:
from .ExprNodes import TupleNode from .ExprNodes import TupleNode
if isinstance(self.dimension, TupleNode): if isinstance(self.dimension, TupleNode):
args = self.dimension.args args = self.dimension.args
...@@ -1090,7 +1090,7 @@ class TemplatedTypeNode(CBaseTypeNode): ...@@ -1090,7 +1090,7 @@ class TemplatedTypeNode(CBaseTypeNode):
base_type = self.base_type_node.analyse(env) base_type = self.base_type_node.analyse(env)
if base_type.is_error: return base_type if base_type.is_error: return base_type
if base_type.is_cpp_class: if base_type.is_cpp_class and base_type.is_template_type():
# Templated class # Templated class
if self.keyword_args and self.keyword_args.key_value_pairs: if self.keyword_args and self.keyword_args.key_value_pairs:
error(self.pos, "c++ templates cannot take keyword arguments") error(self.pos, "c++ templates cannot take keyword arguments")
......
...@@ -3106,8 +3106,11 @@ class CppClassType(CType): ...@@ -3106,8 +3106,11 @@ class CppClassType(CType):
self.to_py_function = cname self.to_py_function = cname
return True return True
def is_template_type(self):
return self.templates is not None and self.template_type is None
def specialize_here(self, pos, template_values = None): def specialize_here(self, pos, template_values = None):
if self.templates is None: if not self.is_template_type():
error(pos, "'%s' type is not a template" % self) error(pos, "'%s' type is not a template" % self)
return error_type return error_type
if len(self.templates) != len(template_values): if len(self.templates) != len(template_values):
......
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