Skip to content

Commit

Permalink
Moving discriminant parameters to component base
Browse files Browse the repository at this point in the history
By moving the discriminant to the base type we ensure that the component
model always matches the implementation. When the discriminant is
reflected in the implementation, it was up to the user to keep the model
in sync with the code, which is far from ideal. This commit fixes that
issue.
  • Loading branch information
dinkelk committed Jun 27, 2024
1 parent deeca6e commit 6e76397
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions gen/templates/component/component-name-implementation.ads
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ package Component.{{ name }}.Implementation is
{% endfor %}
--
{% endif %}
type Instance{% if discriminant.parameters %} ({{ discriminant.parameter_declaration_string(include_mode=False) }}){% endif %} is new {{ name }}.Base_Instance with private;
type Instance is new {{ name }}.Base_Instance with private;

{% if init %}
--------------------------------------------------
Expand Down Expand Up @@ -63,7 +63,7 @@ private
{% endfor %}
--
{% endif %}
type Instance{% if discriminant.parameters %} ({{ discriminant.parameter_declaration_string(include_mode=False) }}){% endif %} is new {{ name }}.Base_Instance with record
type Instance is new {{ name }}.Base_Instance with record
null; -- TODO
end record;

Expand Down
4 changes: 2 additions & 2 deletions gen/templates/component/component-name.ads
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ package Component.{{ name }} is
{% endif %}

-- Base class instance:
type Base_Instance is abstract new Component.Core_Instance with private;
type Base_Instance{% if discriminant.parameters %} ({{ discriminant.parameter_declaration_string(include_mode=False) }}){% endif %} is abstract new Component.Core_Instance with private;
type Base_Class_Access is access all Base_Instance'Class;

{% if connectors.requires_queue() %}
Expand Down Expand Up @@ -655,7 +655,7 @@ private
-------------------------------------------
-- The base class instance record:
-------------------------------------------
type Base_Instance is abstract new Component.Core_Instance with record
type Base_Instance {% if discriminant.parameters %} ({{ discriminant.parameter_declaration_string(include_mode=False) }}){% endif %} is abstract new Component.Core_Instance with record
{% if connectors.requires_queue() or connectors.invoker() or connectors.invokee().n_arrayed() or data_products or commands or events or packets or parameters or faults %}
{% if connectors.requires_queue() %}
-- Internal asynchronous connector queue:
Expand Down

0 comments on commit 6e76397

Please sign in to comment.