Commit ca525fde authored by Boxiang Sun's avatar Boxiang Sun

Initial attempt to add cdef magic method to nogil extension

parent 1f183ba5
......@@ -1977,6 +1977,8 @@ class CCodeWriter(object):
elif type.is_memoryviewslice:
from . import MemoryView
self.putln("%s = %s;" % (decl, MemoryView.memslice_entry_init))
elif type.is_struct and type.is_extension_type and type.nogil:
self.putln("%s;" % decl)
else:
self.putln("%s%s;" % (static and "static " or "", decl))
......
......@@ -5827,6 +5827,8 @@ class DelStatNode(StatNode):
error(arg.pos, "Deletion of global C variable")
elif arg.type.is_ptr and arg.type.base_type.is_cpp_class:
self.cpp_check(env)
elif arg.type.is_struct_or_union and arg.type.nogil:
pass # del nogil extension
elif arg.type.is_cpp_class:
error(arg.pos, "Deletion of non-heap C++ object")
elif arg.is_subscript and arg.base.type is Builtin.bytearray_type:
......@@ -5855,6 +5857,8 @@ class DelStatNode(StatNode):
arg.generate_evaluation_code(code)
code.putln("delete %s;" % arg.result())
arg.generate_disposal_code(code)
elif arg.type.is_struct_or_union and hasattr(arg.type, "nogil") and arg.type.nogil:
code.putln("free(&%s);" % arg.result())
# else error reported earlier
def annotate(self, code):
......
......@@ -2223,7 +2223,8 @@ class CClassScope(ClassScope):
cname=None, visibility='private', api=0, in_pxd=0,
defining=0, modifiers=(), utility_code=None, overridable=False):
if get_special_method_signature(name) and not self.parent_type.is_builtin_type:
error(pos, "Special methods must be declared with 'def', not 'cdef'")
if not(hasattr(self.parent_type, "nogil") and self.parent_type.nogil and self.parent_type.is_struct_or_union):
error(pos, "Special methods must be declared with 'def', not 'cdef'")
args = type.args
if not type.is_static_method:
if not args:
......
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