Commit 9205e32b authored by Stefan Behnel's avatar Stefan Behnel

Refactor some duplicate code in TypeSlots.py.

parent 139bd745
......@@ -250,14 +250,17 @@ class SlotDescriptor(object):
def generate_dynamic_init_code(self, scope, code):
if self.is_initialised_dynamically:
value = self.slot_code(scope)
if value != "0":
code.putln("%s.%s = %s;" % (
scope.parent_type.typeobj_cname,
self.slot_name,
value
)
)
self.generate_set_slot_code(
self.slot_code(scope), scope, code)
def generate_set_slot_code(self, value, scope, code):
if value == "0":
return
code.putln("%s.%s = %s;" % (
scope.parent_type.typeobj_cname,
self.slot_name,
value,
))
class FixedSlot(SlotDescriptor):
......@@ -408,10 +411,7 @@ class ConstructorSlot(InternalMethodSlot):
else:
return
code.putln("%s.%s = %s;" % (
scope.parent_type.typeobj_cname,
self.slot_name,
src))
self.generate_set_slot_code(src, scope, code)
class SyntheticSlot(InternalMethodSlot):
......
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