Commit bc4c5023 authored by Danilo Freitas's avatar Danilo Freitas

Creating default constructor if no constructor was declared

parent c35599ce
...@@ -1094,11 +1094,12 @@ class NewExprNode(AtomicExprNode): ...@@ -1094,11 +1094,12 @@ class NewExprNode(AtomicExprNode):
type = entry.type.specialize_here(self.pos, template_types) type = entry.type.specialize_here(self.pos, template_types)
else: else:
type = entry.type type = entry.type
constructor = type.scope.lookup(u'__init__') constructor = type.scope.lookup(u'__init__')
if constructor is None: if constructor is None:
print "no constructor declared" return_type = PyrexTypes.CFuncType(type, [])
# TODO(danilo): create one 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.class_type = type
self.entry = constructor self.entry = constructor
self.type = constructor.type self.type = constructor.type
...@@ -3812,12 +3813,12 @@ class UnopNode(ExprNode): ...@@ -3812,12 +3813,12 @@ class UnopNode(ExprNode):
function = entry.type.scope.lookup(self.operators[self.operator]) function = entry.type.scope.lookup(self.operators[self.operator])
if not function: if not function:
error(self.pos, "'%s' operator not defined for %s" error(self.pos, "'%s' operator not defined for %s"
% (self.operator, type1, type2, self.operator)) % (self.operator, type))
self.type_error() self.type_error()
return return
self.type = function.type.return_type self.type = function.type.return_type
operator = { operators = {
"++": u"__inc__", "++": u"__inc__",
"--": u"__dec__", "--": u"__dec__",
"*": u"__deref__", "*": u"__deref__",
......
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