Commit b2a071a1 authored by Robert Bradshaw's avatar Robert Bradshaw Committed by Stefan Behnel

Generate custom deallocation code when there are C++ members to destruct.

parent fe08775d
...@@ -1856,6 +1856,7 @@ class CClassScope(ClassScope): ...@@ -1856,6 +1856,7 @@ class CClassScope(ClassScope):
# getset_table_cname string # getset_table_cname string
# has_pyobject_attrs boolean Any PyObject attributes? # has_pyobject_attrs boolean Any PyObject attributes?
# has_memoryview_attrs boolean Any memory view attributes? # has_memoryview_attrs boolean Any memory view attributes?
# has_cpp_class_attrs boolean Any (non-pointer) C++ attributes?
# has_cyclic_pyobject_attrs boolean Any PyObject attributes that may need GC? # has_cyclic_pyobject_attrs boolean Any PyObject attributes that may need GC?
# property_entries [Entry] # property_entries [Entry]
# defined boolean Defined in .pxd file # defined boolean Defined in .pxd file
...@@ -1866,6 +1867,7 @@ class CClassScope(ClassScope): ...@@ -1866,6 +1867,7 @@ class CClassScope(ClassScope):
has_pyobject_attrs = False has_pyobject_attrs = False
has_memoryview_attrs = False has_memoryview_attrs = False
has_cpp_class_attrs = False
has_cyclic_pyobject_attrs = False has_cyclic_pyobject_attrs = False
defined = False defined = False
implemented = False implemented = False
...@@ -1941,6 +1943,8 @@ class CClassScope(ClassScope): ...@@ -1941,6 +1943,8 @@ class CClassScope(ClassScope):
self.var_entries.append(entry) self.var_entries.append(entry)
if type.is_memoryviewslice: if type.is_memoryviewslice:
self.has_memoryview_attrs = True self.has_memoryview_attrs = True
elif type.is_cpp_class:
self.has_cpp_class_attrs = True
elif type.is_pyobject and name != '__weakref__': elif type.is_pyobject and name != '__weakref__':
self.has_pyobject_attrs = True self.has_pyobject_attrs = True
if (not type.is_builtin_type if (not type.is_builtin_type
......
...@@ -361,6 +361,7 @@ class ConstructorSlot(InternalMethodSlot): ...@@ -361,6 +361,7 @@ class ConstructorSlot(InternalMethodSlot):
and scope.parent_type.base_type and scope.parent_type.base_type
and not scope.has_pyobject_attrs and not scope.has_pyobject_attrs
and not scope.has_memoryview_attrs and not scope.has_memoryview_attrs
and not scope.has_cpp_class_attrs
and not scope.lookup_here(self.method)): and not scope.lookup_here(self.method)):
# if the type does not have object attributes, it can # if the type does not have object attributes, it can
# delegate GC methods to its parent - iff the parent # delegate GC methods to its parent - iff the parent
......
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