Merge pull request #1841 from KLayout/bugfix/issue-1840

Fixed issue #1840: start is renamed to _start and finish is renamed t…
This commit is contained in:
Matthias Köfferlein 2024-09-08 22:23:14 +02:00 committed by GitHub
commit 445d8a49ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 38 additions and 38 deletions

View File

@ -314,14 +314,14 @@ module RBA
# Starts an operation - pushes the state on the state stack # Starts an operation - pushes the state on the state stack
def start def _start
@state_stack << [ @param_values, @param_states, @layers, @cell, @layout, @layer, @shape ] @state_stack << [ @param_values, @param_states, @layers, @cell, @layout, @layer, @shape ]
self._reset_state self._reset_state
end end
# Finishes an operation - pops the state from the state stack # Finishes an operation - pops the state from the state stack
def finish def _finish
if ! @state_stack.empty? if ! @state_stack.empty?
@param_values, @param_states, @layers, @cell, @layout, @layer, @shape = @state_stack.pop @param_values, @param_states, @layers, @cell, @layout, @layer, @shape = @state_stack.pop
else else
@ -455,13 +455,13 @@ module RBA
# implementation of display_text # implementation of display_text
def display_text(parameters) def display_text(parameters)
self.start self._start
@param_values = parameters @param_values = parameters
text = "" text = ""
begin begin
text = display_text_impl text = display_text_impl
ensure ensure
self.finish self._finish
end end
text text
end end
@ -478,33 +478,33 @@ module RBA
# coerce parameters (make consistent) # coerce parameters (make consistent)
def coerce_parameters(layout, parameters) def coerce_parameters(layout, parameters)
self.start self._start
@param_values = parameters @param_values = parameters
@layout = layout @layout = layout
begin begin
coerce_parameters_impl coerce_parameters_impl
ensure ensure
ret = @param_values ret = @param_values
self.finish self._finish
end end
ret ret
end end
# parameter change callback # parameter change callback
def callback(layout, name, states) def callback(layout, name, states)
self.start self._start
@param_states = states @param_states = states
@layout = layout @layout = layout
begin begin
callback_impl(name) callback_impl(name)
ensure ensure
self.finish self._finish
end end
end end
# produce the layout # produce the layout
def produce(layout, layers, parameters, cell) def produce(layout, layers, parameters, cell)
self.start self._start
@layers = layers @layers = layers
@cell = cell @cell = cell
@param_values = parameters @param_values = parameters
@ -512,13 +512,13 @@ module RBA
begin begin
produce_impl produce_impl
ensure ensure
self.finish self._finish
end end
end end
# produce a helper for can_create_from_shape # produce a helper for can_create_from_shape
def can_create_from_shape(layout, shape, layer) def can_create_from_shape(layout, shape, layer)
self.start self._start
ret = false ret = false
@layout = layout @layout = layout
@shape = shape @shape = shape
@ -526,14 +526,14 @@ module RBA
begin begin
ret = can_create_from_shape_impl ret = can_create_from_shape_impl
ensure ensure
self.finish self._finish
end end
ret ret
end end
# produce a helper for transformation_from_shape # produce a helper for transformation_from_shape
def transformation_from_shape(layout, shape, layer) def transformation_from_shape(layout, shape, layer)
self.start self._start
@layout = layout @layout = layout
@shape = shape @shape = shape
@layer = layer @layer = layer
@ -541,7 +541,7 @@ module RBA
begin begin
t = transformation_from_shape_impl t = transformation_from_shape_impl
ensure ensure
self.finish self._finish
end end
t t
end end
@ -549,7 +549,7 @@ module RBA
# produce a helper for parameters_from_shape # produce a helper for parameters_from_shape
# with this helper, the implementation can use the parameter setters # with this helper, the implementation can use the parameter setters
def parameters_from_shape(layout, shape, layer) def parameters_from_shape(layout, shape, layer)
self.start self._start
@param_values = @param_decls.map { |pd| pd.default } @param_values = @param_decls.map { |pd| pd.default }
@layout = layout @layout = layout
@shape = shape @shape = shape
@ -558,7 +558,7 @@ module RBA
parameters_from_shape_impl parameters_from_shape_impl
ensure ensure
ret = @param_values ret = @param_values
self.finish self._finish
end end
ret ret
end end

View File

@ -130,12 +130,12 @@ class _PCellDeclarationHelperMixin:
This function delegates the implementation to self.display_text_impl This function delegates the implementation to self.display_text_impl
after configuring the PCellDeclaration object. after configuring the PCellDeclaration object.
""" """
self.start() self._start()
self._param_values = parameters self._param_values = parameters
try: try:
text = self.display_text_impl() text = self.display_text_impl()
finally: finally:
self.finish() self._finish()
return text return text
def get_parameters(self): def get_parameters(self):
@ -147,7 +147,7 @@ class _PCellDeclarationHelperMixin:
""" """
return self._param_decls return self._param_decls
def get_values(self): def _get_values(self):
""" """
Gets the temporary parameter values used for the current evaluation Gets the temporary parameter values used for the current evaluation
@ -158,7 +158,7 @@ class _PCellDeclarationHelperMixin:
self._param_values = None self._param_values = None
return v return v
def init_values(self, values = None, layers = None, states = None): def _init_values(self, values = None, layers = None, states = None):
""" """
initializes the temporary parameter values for the current evaluation initializes the temporary parameter values for the current evaluation
@ -167,7 +167,7 @@ class _PCellDeclarationHelperMixin:
"layers" are the layer indexes corresponding to the layer "layers" are the layer indexes corresponding to the layer
parameters. parameters.
""" """
self.start() self._start()
self._param_values = None self._param_values = None
self._param_states = None self._param_states = None
if states: if states:
@ -180,17 +180,17 @@ class _PCellDeclarationHelperMixin:
self._param_values = values self._param_values = values
self._layers = layers self._layers = layers
def start(self): def _start(self):
""" """
Is called to prepare the environment for an operation Is called to prepare the environment for an operation
After the operation, "finish" must be called. After the operation, "_finish" must be called.
This method will push the state onto a stack, hence implementing This method will push the state onto a stack, hence implementing
reentrant implementation methods. reentrant implementation methods.
""" """
self._state_stack.append( (self._param_values, self._param_states, self._layers, self.cell, self.layout, self.layer, self.shape) ) self._state_stack.append( (self._param_values, self._param_states, self._layers, self.cell, self.layout, self.layer, self.shape) )
self._reset_state() self._reset_state()
def finish(self): def _finish(self):
""" """
Is called at the end of an implementation of a PCellDeclaration method Is called at the end of an implementation of a PCellDeclaration method
""" """
@ -235,12 +235,12 @@ class _PCellDeclarationHelperMixin:
The function delegates the implementation to callback_impl The function delegates the implementation to callback_impl
after updating the state of this object with the current parameters. after updating the state of this object with the current parameters.
""" """
self.init_values(states = states) self._init_values(states = states)
self.layout = layout self.layout = layout
try: try:
self.callback_impl(name) self.callback_impl(name)
finally: finally:
self.finish() self._finish()
def coerce_parameters(self, layout, parameters): def coerce_parameters(self, layout, parameters):
""" """
@ -249,13 +249,13 @@ class _PCellDeclarationHelperMixin:
The function delegates the implementation to coerce_parameters_impl The function delegates the implementation to coerce_parameters_impl
after updating the state of this object with the current parameters. after updating the state of this object with the current parameters.
""" """
self.init_values(parameters) self._init_values(parameters)
self.layout = layout self.layout = layout
try: try:
self.coerce_parameters_impl() self.coerce_parameters_impl()
parameters = self.get_values() parameters = self._get_values()
finally: finally:
self.finish() self._finish()
return parameters return parameters
def produce(self, layout, layers, parameters, cell): def produce(self, layout, layers, parameters, cell):
@ -265,13 +265,13 @@ class _PCellDeclarationHelperMixin:
The function delegates the implementation to produce_impl The function delegates the implementation to produce_impl
after updating the state of this object with the current parameters. after updating the state of this object with the current parameters.
""" """
self.init_values(parameters, layers) self._init_values(parameters, layers)
self.cell = cell self.cell = cell
self.layout = layout self.layout = layout
try: try:
self.produce_impl() self.produce_impl()
finally: finally:
self.finish() self._finish()
def can_create_from_shape(self, layout, shape, layer): def can_create_from_shape(self, layout, shape, layer):
""" """
@ -280,14 +280,14 @@ class _PCellDeclarationHelperMixin:
The function delegates the implementation to can_create_from_shape_impl The function delegates the implementation to can_create_from_shape_impl
after updating the state of this object with the current parameters. after updating the state of this object with the current parameters.
""" """
self.start() self._start()
self.layout = layout self.layout = layout
self.shape = shape self.shape = shape
self.layer = layer self.layer = layer
try: try:
ret = self.can_create_from_shape_impl() ret = self.can_create_from_shape_impl()
finally: finally:
self.finish() self._finish()
return ret return ret
def transformation_from_shape(self, layout, shape, layer): def transformation_from_shape(self, layout, shape, layer):
@ -297,7 +297,7 @@ class _PCellDeclarationHelperMixin:
The function delegates the implementation to transformation_from_shape_impl The function delegates the implementation to transformation_from_shape_impl
after updating the state of this object with the current parameters. after updating the state of this object with the current parameters.
""" """
self.start() self._start()
self.layout = layout self.layout = layout
self.shape = shape self.shape = shape
self.layer = layer self.layer = layer
@ -306,7 +306,7 @@ class _PCellDeclarationHelperMixin:
if t is None: if t is None:
t = self._make_default_trans() t = self._make_default_trans()
finally: finally:
self.finish() self._finish()
return t return t
def parameters_from_shape(self, layout, shape, layer): def parameters_from_shape(self, layout, shape, layer):
@ -316,15 +316,15 @@ class _PCellDeclarationHelperMixin:
The function delegates the implementation to parameters_from_shape_impl The function delegates the implementation to parameters_from_shape_impl
after updating the state of this object with the current parameters. after updating the state of this object with the current parameters.
""" """
self.init_values() self._init_values()
self.layout = layout self.layout = layout
self.shape = shape self.shape = shape
self.layer = layer self.layer = layer
try: try:
self.parameters_from_shape_impl() self.parameters_from_shape_impl()
param = self.get_values() param = self._get_values()
finally: finally:
self.finish() self._finish()
return param return param
def display_text_impl(self): def display_text_impl(self):