Skip to content

Commit

Permalink
Merge pull request #1841 from KLayout/bugfix/issue-1840
Browse files Browse the repository at this point in the history
Fixed issue #1840: start is renamed to _start and finish is renamed t…
  • Loading branch information
klayoutmatthias authored Sep 8, 2024
2 parents 4ce5a98 + 7dd7a96 commit 445d8a4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 38 deletions.
32 changes: 16 additions & 16 deletions src/db/db/built-in-macros/pcell_declaration_helper.lym
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,14 @@ module RBA

# 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 ]
self._reset_state
end

# Finishes an operation - pops the state from the state stack

def finish
def _finish
if ! @state_stack.empty?
@param_values, @param_states, @layers, @cell, @layout, @layer, @shape = @state_stack.pop
else
Expand Down Expand Up @@ -455,13 +455,13 @@ module RBA

# implementation of display_text
def display_text(parameters)
self.start
self._start
@param_values = parameters
text = ""
begin
text = display_text_impl
ensure
self.finish
self._finish
end
text
end
Expand All @@ -478,78 +478,78 @@ module RBA

# coerce parameters (make consistent)
def coerce_parameters(layout, parameters)
self.start
self._start
@param_values = parameters
@layout = layout
begin
coerce_parameters_impl
ensure
ret = @param_values
self.finish
self._finish
end
ret
end

# parameter change callback
def callback(layout, name, states)
self.start
self._start
@param_states = states
@layout = layout
begin
callback_impl(name)
ensure
self.finish
self._finish
end
end

# produce the layout
def produce(layout, layers, parameters, cell)
self.start
self._start
@layers = layers
@cell = cell
@param_values = parameters
@layout = layout
begin
produce_impl
ensure
self.finish
self._finish
end
end

# produce a helper for can_create_from_shape
def can_create_from_shape(layout, shape, layer)
self.start
self._start
ret = false
@layout = layout
@shape = shape
@layer = layer
begin
ret = can_create_from_shape_impl
ensure
self.finish
self._finish
end
ret
end

# produce a helper for transformation_from_shape
def transformation_from_shape(layout, shape, layer)
self.start
self._start
@layout = layout
@shape = shape
@layer = layer
t = nil
begin
t = transformation_from_shape_impl
ensure
self.finish
self._finish
end
t
end

# produce a helper for parameters_from_shape
# with this helper, the implementation can use the parameter setters
def parameters_from_shape(layout, shape, layer)
self.start
self._start
@param_values = @param_decls.map { |pd| pd.default }
@layout = layout
@shape = shape
Expand All @@ -558,7 +558,7 @@ module RBA
parameters_from_shape_impl
ensure
ret = @param_values
self.finish
self._finish
end
ret
end
Expand Down
44 changes: 22 additions & 22 deletions src/pymod/distutils_src/klayout/db/pcell_declaration_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ def display_text(self, parameters):
This function delegates the implementation to self.display_text_impl
after configuring the PCellDeclaration object.
"""
self.start()
self._start()
self._param_values = parameters
try:
text = self.display_text_impl()
finally:
self.finish()
self._finish()
return text

def get_parameters(self):
Expand All @@ -147,7 +147,7 @@ def get_parameters(self):
"""
return self._param_decls

def get_values(self):
def _get_values(self):
"""
Gets the temporary parameter values used for the current evaluation
Expand All @@ -158,7 +158,7 @@ def get_values(self):
self._param_values = None
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
Expand All @@ -167,7 +167,7 @@ def init_values(self, values = None, layers = None, states = None):
"layers" are the layer indexes corresponding to the layer
parameters.
"""
self.start()
self._start()
self._param_values = None
self._param_states = None
if states:
Expand All @@ -180,17 +180,17 @@ def init_values(self, values = None, layers = None, states = None):
self._param_values = values
self._layers = layers

def start(self):
def _start(self):
"""
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
reentrant implementation methods.
"""
self._state_stack.append( (self._param_values, self._param_states, self._layers, self.cell, self.layout, self.layer, self.shape) )
self._reset_state()

def finish(self):
def _finish(self):
"""
Is called at the end of an implementation of a PCellDeclaration method
"""
Expand Down Expand Up @@ -235,12 +235,12 @@ def callback(self, layout, name, states):
The function delegates the implementation to callback_impl
after updating the state of this object with the current parameters.
"""
self.init_values(states = states)
self._init_values(states = states)
self.layout = layout
try:
self.callback_impl(name)
finally:
self.finish()
self._finish()

def coerce_parameters(self, layout, parameters):
"""
Expand All @@ -249,13 +249,13 @@ def coerce_parameters(self, layout, parameters):
The function delegates the implementation to coerce_parameters_impl
after updating the state of this object with the current parameters.
"""
self.init_values(parameters)
self._init_values(parameters)
self.layout = layout
try:
self.coerce_parameters_impl()
parameters = self.get_values()
parameters = self._get_values()
finally:
self.finish()
self._finish()
return parameters

def produce(self, layout, layers, parameters, cell):
Expand All @@ -265,13 +265,13 @@ def produce(self, layout, layers, parameters, cell):
The function delegates the implementation to produce_impl
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.layout = layout
try:
self.produce_impl()
finally:
self.finish()
self._finish()

def can_create_from_shape(self, layout, shape, layer):
"""
Expand All @@ -280,14 +280,14 @@ def can_create_from_shape(self, layout, shape, layer):
The function delegates the implementation to can_create_from_shape_impl
after updating the state of this object with the current parameters.
"""
self.start()
self._start()
self.layout = layout
self.shape = shape
self.layer = layer
try:
ret = self.can_create_from_shape_impl()
finally:
self.finish()
self._finish()
return ret

def transformation_from_shape(self, layout, shape, layer):
Expand All @@ -297,7 +297,7 @@ def transformation_from_shape(self, layout, shape, layer):
The function delegates the implementation to transformation_from_shape_impl
after updating the state of this object with the current parameters.
"""
self.start()
self._start()
self.layout = layout
self.shape = shape
self.layer = layer
Expand All @@ -306,7 +306,7 @@ def transformation_from_shape(self, layout, shape, layer):
if t is None:
t = self._make_default_trans()
finally:
self.finish()
self._finish()
return t

def parameters_from_shape(self, layout, shape, layer):
Expand All @@ -316,15 +316,15 @@ def parameters_from_shape(self, layout, shape, layer):
The function delegates the implementation to parameters_from_shape_impl
after updating the state of this object with the current parameters.
"""
self.init_values()
self._init_values()
self.layout = layout
self.shape = shape
self.layer = layer
try:
self.parameters_from_shape_impl()
param = self.get_values()
param = self._get_values()
finally:
self.finish()
self._finish()
return param

def display_text_impl(self):
Expand Down

0 comments on commit 445d8a4

Please sign in to comment.