Commit 4a10a97c authored by gsamain's avatar gsamain

Don't generate default cypclass __alloc__ when user provides it

parent 1a19cd13
...@@ -1046,7 +1046,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1046,7 +1046,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln("%s(){}" % type.cname) code.putln("%s(){}" % type.cname)
code.putln("// Generating __alloc__ function (used for __new__ calls)") code.putln("// Generating __alloc__ function (used for __new__ calls)")
alloc_entry = scope.lookup_here("<alloc>") alloc_entry = scope.lookup_here("<alloc>")
code.putln("static %s { return new %s(); }" % (alloc_entry.type.declaration_code(alloc_entry.cname), type.declaration_code("", deref=1))) if alloc_entry.is_builtin_cmethod:
code.putln("static %s { return new %s(); }" % (alloc_entry.type.declaration_code(alloc_entry.cname), type.declaration_code("", deref=1)))
code.putln("};") code.putln("};")
if type.is_cyp_class: if type.is_cyp_class:
......
...@@ -671,7 +671,11 @@ class Scope(object): ...@@ -671,7 +671,11 @@ class Scope(object):
alloc_name = "<alloc>" alloc_name = "<alloc>"
alloc_entry = scope.declare(alloc_name, alloc_cname, alloc_type, pos, visibility) alloc_entry = scope.declare(alloc_name, alloc_cname, alloc_type, pos, visibility)
alloc_type.entry = alloc_entry alloc_type.entry = alloc_entry
alloc_entry.is_inherited = 1
alloc_entry.is_cfunction = 1 alloc_entry.is_cfunction = 1
# is_builtin_cmethod is currently only used in cclass, so it should be safe
# to use it here to distinguish between implicit default __alloc__ and user-defined one
alloc_entry.is_builtin_cmethod = 1
alloc_entry.func_cname = "%s::%s" % (entry.type.empty_declaration_code(), alloc_cname) alloc_entry.func_cname = "%s::%s" % (entry.type.empty_declaration_code(), alloc_cname)
if self.is_cpp_class_scope: if self.is_cpp_class_scope:
......
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