From bc4c5023b68ea25effa4c7060a89a6ea100765ff Mon Sep 17 00:00:00 2001 From: Danilo Freitas Date: Mon, 17 Aug 2009 00:42:35 -0300 Subject: [PATCH] Creating default constructor if no constructor was declared --- Cython/Compiler/ExprNodes.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index d3e12786..79858e84 100755 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -1094,11 +1094,12 @@ class NewExprNode(AtomicExprNode): type = entry.type.specialize_here(self.pos, template_types) else: type = entry.type - constructor = type.scope.lookup(u'__init__') if constructor is None: - print "no constructor declared" - # TODO(danilo): create one + return_type = PyrexTypes.CFuncType(type, []) + return_type = PyrexTypes.CPtrType(return_type) + type.scope.declare_cfunction(u'__init__', return_type, self.pos) + constructor = type.scope.lookup(u'__init__') self.class_type = type self.entry = constructor self.type = constructor.type @@ -3812,12 +3813,12 @@ class UnopNode(ExprNode): function = entry.type.scope.lookup(self.operators[self.operator]) if not function: error(self.pos, "'%s' operator not defined for %s" - % (self.operator, type1, type2, self.operator)) + % (self.operator, type)) self.type_error() return self.type = function.type.return_type - operator = { + operators = { "++": u"__inc__", "--": u"__dec__", "*": u"__deref__", -- 2.26.2