Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify setting of opaque fields #557

Closed
treiher opened this issue Jan 22, 2021 · 0 comments · Fixed by #558
Closed

Simplify setting of opaque fields #557

treiher opened this issue Jan 22, 2021 · 0 comments · Fixed by #558
Assignees
Labels
generator Related to generator package (SPARK code generation)

Comments

@treiher
Copy link
Collaborator

treiher commented Jan 22, 2021

Setting an opaque field is unnecessary complicated:

   Data : RFLX.RFLX_Builtin_Types.Bytes (RFLX.RFLX_Builtin_Types.Index'First .. RFLX.RFLX_Builtin_Types.Index'First + 2**14);

   function Valid_Data_Length (Length : RFLX.RFLX_Builtin_Types.Length) return Boolean is
      (Length <= Data'Length);

   procedure Write_Data (Buffer : out RFLX.RFLX_Builtin_Types.Bytes) with
      Pre => Valid_Data_Length (Buffer'Length)
   is
   begin
      Buffer := Data (Data'First .. Data'First + Buffer'Length - 1);
   end Write_Data;

   procedure Set_Value is new RFLX.TLV.Message.Set_Value (Write_Data, Valid_Data_Length);
begin
   [...]
   Data := (1, 2, 3, 4, others => 0);
   Set_Value (Context);

In simple cases it should be as simple as:

   RFLX.TLV.Message.Set_Value (Context, (1, 2, 3, 4));
@treiher treiher added the generator Related to generator package (SPARK code generation) label Jan 22, 2021
@treiher treiher self-assigned this Jan 22, 2021
@treiher treiher added this to To do in RecordFlux 0.5 via automation Jan 22, 2021
@treiher treiher moved this from To do to In progress in RecordFlux 0.5 Jan 22, 2021
treiher added a commit that referenced this issue Jan 22, 2021
treiher added a commit that referenced this issue Jan 22, 2021
treiher added a commit that referenced this issue Jan 22, 2021
treiher added a commit that referenced this issue Jan 22, 2021
@treiher treiher moved this from In progress to Done in RecordFlux 0.5 Jan 22, 2021
RecordFlux 0.5 automation moved this from Done to Merged Jan 25, 2021
treiher added a commit that referenced this issue Jan 25, 2021
treiher added a commit that referenced this issue Jan 25, 2021
@treiher treiher mentioned this issue Aug 4, 2021
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
generator Related to generator package (SPARK code generation)
Projects
No open projects
RecordFlux 0.5
  
Merged
Development

Successfully merging a pull request may close this issue.

1 participant