Commit 128eb184 authored by Vitja Makarov's avatar Vitja Makarov

Move final type flag from directives to PyrexType.is_final_type

parent 38e9cde5
......@@ -3504,7 +3504,7 @@ class CClassDefNode(ClassDefNode):
error(self.pos, "Base class '%s' of type '%s' is incomplete" % (
self.base_class_name, self.class_name))
elif base_class_entry.type.scope and base_class_entry.type.scope.directives and \
base_class_entry.type.scope.directives['final']:
base_class_entry.type.is_final_type:
error(self.pos, "Base class '%s' of type '%s' is final" % (
self.base_class_name, self.class_name))
elif base_class_entry.type.is_builtin_type and \
......
......@@ -1944,9 +1944,9 @@ class CreateClosureClasses(CythonTransform):
objstruct_cname='__pyx_Generator_object',
typeobj_cname='__pyx_Generator_type',
pos=pos, defining=True, implementing=True)
entry.type.is_final_type = True
klass = entry.type.scope
klass.is_internal = True
klass.directives = {'final': True}
body_type = PyrexTypes.create_typedef_type('generator_body',
PyrexTypes.c_void_ptr_type,
......@@ -2042,11 +2042,11 @@ class CreateClosureClasses(CythonTransform):
entry = target_module_scope.declare_c_class(
name=as_name, pos=node.pos, defining=True,
implementing=True, base_type=base_type)
entry.type.is_final_type = True
func_scope.scope_class = entry
class_scope = entry.type.scope
class_scope.is_internal = True
class_scope.directives = {'final': True}
if from_closure:
assert cscope.is_closure_scope
......
......@@ -39,6 +39,7 @@ class PyrexType(BaseType):
#
# is_pyobject boolean Is a Python object type
# is_extension_type boolean Is a Python extension type
# is_final_type boolean Is a final extension type
# is_numeric boolean Is a C numeric type
# is_int boolean Is a C integer type
# is_float boolean Is a C floating point type
......@@ -90,6 +91,7 @@ class PyrexType(BaseType):
is_pyobject = 0
is_unspecified = 0
is_extension_type = 0
is_final_type = 0
is_builtin_type = 0
is_numeric = 0
is_int = 0
......
......@@ -834,7 +834,7 @@ class BuiltinScope(Scope):
scope = CClassScope(name, outer_scope=None, visibility='extern')
scope.directives = {}
if name == 'bool':
scope.directives['final'] = True
type.is_final_type = True
type.set_scope(scope)
self.type_names[name] = 1
entry = self.declare_type(name, type, None, visibility='extern')
......@@ -1250,6 +1250,9 @@ class ModuleScope(Scope):
error(pos, "Type object name differs from previous declaration")
type.typeobj_cname = typeobj_cname
if self.directives.get('final'):
entry.type.is_final_type = True
# cdef classes are always exported, but we need to set it to
# distinguish between unused Cython utility code extension classes
entry.used = True
......@@ -1780,7 +1783,7 @@ class CClassScope(ClassScope):
# Otherwise, subtypes may choose to override the
# method, but the optimisation would prevent the
# subtype method from being called.
if not self.directives['final']:
if not self.parent_type.is_final_type:
return None
return entry
......@@ -1825,7 +1828,8 @@ class CClassScope(ClassScope):
entry.utility_code = utility_code
if u'inline' in modifiers:
entry.is_inline_cmethod = True
if self.directives.get('final') or entry.is_inline_cmethod:
if (self.parent_type.is_final_type or entry.is_inline_cmethod or
self.directives.get('final')):
entry.is_final_cmethod = True
entry.final_func_cname = entry.func_cname
return entry
......
......@@ -343,7 +343,7 @@ class TypeFlagsSlot(SlotDescriptor):
def slot_code(self, scope):
value = "Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER"
if not scope.directives['final']:
if not scope.parent_type.is_final_type:
value += "|Py_TPFLAGS_BASETYPE"
if scope.needs_gc():
value += "|Py_TPFLAGS_HAVE_GC"
......
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