Commit a6987893 authored by Boxiang Sun's avatar Boxiang Sun Committed by gsamain

Initial attempt to add cdef magic method to nogil extension

parent 0ee0b6eb
......@@ -1974,6 +1974,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))
......
......@@ -5974,6 +5974,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:
......@@ -6002,6 +6004,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):
......
......@@ -2256,6 +2256,7 @@ 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:
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:
......
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