From: Robert Bradshaw Date: Fri, 19 Feb 2010 19:32:43 +0000 (-0800) Subject: More cimported type fixes. X-Git-Tag: 0.13.beta0~344 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=15577be10c16539ce02be30b42160bb72a6f1f81;p=cython.git More cimported type fixes. --- diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 37ccce03..8da22cd9 100755 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -1045,21 +1045,17 @@ class NewExprNode(AtomicExprNode): # C++ new statement # - # cppclass string c++ class to create - # template_parameters None or [ExprNode] temlate parameters, if any + # cppclass node c++ class to create + + type = None def infer_type(self, env): - cppclass = self.cppclass.analyse_as_type(env) - entry = env.lookup(cppclass.name) - if entry is None or not entry.is_cpp_class: + type = self.cppclass.analyse_as_type(env) + if type is None or not type.is_cpp_class: error(self.pos, "new operator can only be applied to a C++ class") + self.type = error_type return self.cpp_check(env) - if self.template_parameters is not None: - template_types = [v.analyse_as_type(env) for v in self.template_parameters] - type = entry.type.specialize_here(self.pos, template_types) - else: - type = entry.type constructor = type.scope.lookup(u'') if constructor is None: return_type = PyrexTypes.CFuncType(type, []) @@ -1072,7 +1068,8 @@ class NewExprNode(AtomicExprNode): return self.type def analyse_types(self, env): - self.infer_type(env) + if self.type is None: + self.infer_type(env) def generate_result_code(self, code): pass @@ -2582,6 +2579,9 @@ class SimpleCallNode(CallNode): return func_type def analyse_c_function_call(self, env): + if self.function.type is error_type: + self.type = self.function.type + return if self.function.type.is_cpp_class: function = self.function.type.scope.lookup("operator()") if function is None: diff --git a/Cython/Compiler/Parsing.py b/Cython/Compiler/Parsing.py index 984b156b..919699ed 100644 --- a/Cython/Compiler/Parsing.py +++ b/Cython/Compiler/Parsing.py @@ -316,18 +316,8 @@ def p_new_expr(s): # s.systring == 'new'. pos = s.position() s.next() - node = p_atom(s) - if s.sy == '.': - name = p_trailer(s, node) - else: - name = node - if s.sy == '[': - s.next() - template_parameters = p_simple_expr_list(s) - s.expect(']') - else: - template_parameters = None - return p_call(s, ExprNodes.NewExprNode(pos, cppclass = name, template_parameters = template_parameters)) + cppclass = p_c_base_type(s) + return p_call(s, ExprNodes.NewExprNode(pos, cppclass = cppclass)) #trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME