Skip to content

Commit

Permalink
Allow setting empty sequence field
Browse files Browse the repository at this point in the history
Ref. #353
  • Loading branch information
treiher committed Jul 18, 2020
1 parent 9a34251 commit a652916
Show file tree
Hide file tree
Showing 26 changed files with 496 additions and 131 deletions.
10 changes: 10 additions & 0 deletions generated/rflx-arrays-generic_inner_message.adb
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,16 @@ is
Ctx.Cursors (Successor (Ctx, F_Length)) := (State => S_Invalid, Predecessor => F_Length);
end Set_Length;

procedure Set_Payload_Empty (Ctx : in out Context) is
First : constant Types.Bit_Index := Field_First (Ctx, F_Payload);
Last : constant Types.Bit_Index := Field_Last (Ctx, F_Payload);
begin
Reset_Dependent_Fields (Ctx, F_Payload);
Ctx := (Ctx.Buffer_First, Ctx.Buffer_Last, Ctx.First, Last, Ctx.Buffer, Ctx.Cursors);
Ctx.Cursors (F_Payload) := (State => S_Valid, First => First, Last => Last, Value => (Fld => F_Payload), Predecessor => Ctx.Cursors (F_Payload).Predecessor);
Ctx.Cursors (Successor (Ctx, F_Payload)) := (State => S_Invalid, Predecessor => F_Payload);
end Set_Payload_Empty;

procedure Set_Payload (Ctx : in out Context) is
First : constant Types.Bit_Index := Field_First (Ctx, F_Payload);
Last : constant Types.Bit_Index := Field_Last (Ctx, F_Payload);
Expand Down
21 changes: 21 additions & 0 deletions generated/rflx-arrays-generic_inner_message.ads
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,27 @@ is
and Predecessor (Ctx, F_Length) = Predecessor (Ctx, F_Length)'Old
and Valid_Next (Ctx, F_Length) = Valid_Next (Ctx, F_Length)'Old;

procedure Set_Payload_Empty (Ctx : in out Context) with
Pre =>
not Ctx'Constrained
and then Has_Buffer (Ctx)
and then Valid_Next (Ctx, F_Payload)
and then Field_Last (Ctx, F_Payload) <= Types.Bit_Index'Last / 2
and then Field_Condition (Ctx, (Fld => F_Payload))
and then Available_Space (Ctx, F_Payload) >= Field_Length (Ctx, F_Payload)
and then Field_First (Ctx, F_Payload) mod Types.Byte'Size = 1
and then Field_Length (Ctx, F_Payload) mod Types.Byte'Size = 0
and then Field_Length (Ctx, F_Payload) = 0,
Post =>
Has_Buffer (Ctx)
and Ctx.Buffer_First = Ctx.Buffer_First'Old
and Ctx.Buffer_Last = Ctx.Buffer_Last'Old
and Ctx.First = Ctx.First'Old
and Predecessor (Ctx, F_Payload) = Predecessor (Ctx, F_Payload)'Old
and Valid_Next (Ctx, F_Payload) = Valid_Next (Ctx, F_Payload)'Old
and Get_Length (Ctx) = Get_Length (Ctx)'Old
and Structural_Valid (Ctx, F_Payload);

generic
with procedure Process_Payload (Payload : out Types.Bytes);
with function Valid_Length (Length : Types.Length) return Boolean;
Expand Down
10 changes: 10 additions & 0 deletions generated/rflx-arrays-generic_message.adb
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,16 @@ is
Ctx.Cursors (Successor (Ctx, F_Length)) := (State => S_Invalid, Predecessor => F_Length);
end Set_Length;

procedure Set_Modular_Vector_Empty (Ctx : in out Context) is
First : constant Types.Bit_Index := Field_First (Ctx, F_Modular_Vector);
Last : constant Types.Bit_Index := Field_Last (Ctx, F_Modular_Vector);
begin
Reset_Dependent_Fields (Ctx, F_Modular_Vector);
Ctx := (Ctx.Buffer_First, Ctx.Buffer_Last, Ctx.First, Last, Ctx.Buffer, Ctx.Cursors);
Ctx.Cursors (F_Modular_Vector) := (State => S_Valid, First => First, Last => Last, Value => (Fld => F_Modular_Vector), Predecessor => Ctx.Cursors (F_Modular_Vector).Predecessor);
Ctx.Cursors (Successor (Ctx, F_Modular_Vector)) := (State => S_Invalid, Predecessor => F_Modular_Vector);
end Set_Modular_Vector_Empty;

procedure Switch_To_Modular_Vector (Ctx : in out Context; Seq_Ctx : out Modular_Vector_Sequence.Context) is
First : constant Types.Bit_Index := Field_First (Ctx, F_Modular_Vector);
Last : constant Types.Bit_Index := Field_Last (Ctx, F_Modular_Vector);
Expand Down
26 changes: 26 additions & 0 deletions generated/rflx-arrays-generic_message.ads
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,32 @@ is
and Predecessor (Ctx, F_Length) = Predecessor (Ctx, F_Length)'Old
and Valid_Next (Ctx, F_Length) = Valid_Next (Ctx, F_Length)'Old;

procedure Set_Modular_Vector_Empty (Ctx : in out Context) with
Pre =>
not Ctx'Constrained
and then Has_Buffer (Ctx)
and then Valid_Next (Ctx, F_Modular_Vector)
and then Field_Last (Ctx, F_Modular_Vector) <= Types.Bit_Index'Last / 2
and then Field_Condition (Ctx, (Fld => F_Modular_Vector))
and then Available_Space (Ctx, F_Modular_Vector) >= Field_Length (Ctx, F_Modular_Vector)
and then Field_First (Ctx, F_Modular_Vector) mod Types.Byte'Size = 1
and then Field_Length (Ctx, F_Modular_Vector) mod Types.Byte'Size = 0
and then Field_Length (Ctx, F_Modular_Vector) = 0,
Post =>
Has_Buffer (Ctx)
and Invalid (Ctx, F_Range_Vector)
and Invalid (Ctx, F_Enumeration_Vector)
and Invalid (Ctx, F_AV_Enumeration_Vector)
and (Predecessor (Ctx, F_Range_Vector) = F_Modular_Vector
and Valid_Next (Ctx, F_Range_Vector))
and Ctx.Buffer_First = Ctx.Buffer_First'Old
and Ctx.Buffer_Last = Ctx.Buffer_Last'Old
and Ctx.First = Ctx.First'Old
and Predecessor (Ctx, F_Modular_Vector) = Predecessor (Ctx, F_Modular_Vector)'Old
and Valid_Next (Ctx, F_Modular_Vector) = Valid_Next (Ctx, F_Modular_Vector)'Old
and Get_Length (Ctx) = Get_Length (Ctx)'Old
and Structural_Valid (Ctx, F_Modular_Vector);

procedure Switch_To_Modular_Vector (Ctx : in out Context; Seq_Ctx : out Modular_Vector_Sequence.Context) with
Pre =>
not Ctx'Constrained
Expand Down
10 changes: 10 additions & 0 deletions generated/rflx-arrays-generic_messages_message.adb
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,16 @@ is
Ctx.Cursors (Successor (Ctx, F_Length)) := (State => S_Invalid, Predecessor => F_Length);
end Set_Length;

procedure Set_Messages_Empty (Ctx : in out Context) is
First : constant Types.Bit_Index := Field_First (Ctx, F_Messages);
Last : constant Types.Bit_Index := Field_Last (Ctx, F_Messages);
begin
Reset_Dependent_Fields (Ctx, F_Messages);
Ctx := (Ctx.Buffer_First, Ctx.Buffer_Last, Ctx.First, Last, Ctx.Buffer, Ctx.Cursors);
Ctx.Cursors (F_Messages) := (State => S_Valid, First => First, Last => Last, Value => (Fld => F_Messages), Predecessor => Ctx.Cursors (F_Messages).Predecessor);
Ctx.Cursors (Successor (Ctx, F_Messages)) := (State => S_Invalid, Predecessor => F_Messages);
end Set_Messages_Empty;

procedure Switch_To_Messages (Ctx : in out Context; Seq_Ctx : out Inner_Messages_Sequence.Context) is
First : constant Types.Bit_Index := Field_First (Ctx, F_Messages);
Last : constant Types.Bit_Index := Field_Last (Ctx, F_Messages);
Expand Down
21 changes: 21 additions & 0 deletions generated/rflx-arrays-generic_messages_message.ads
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,27 @@ is
and Predecessor (Ctx, F_Length) = Predecessor (Ctx, F_Length)'Old
and Valid_Next (Ctx, F_Length) = Valid_Next (Ctx, F_Length)'Old;

procedure Set_Messages_Empty (Ctx : in out Context) with
Pre =>
not Ctx'Constrained
and then Has_Buffer (Ctx)
and then Valid_Next (Ctx, F_Messages)
and then Field_Last (Ctx, F_Messages) <= Types.Bit_Index'Last / 2
and then Field_Condition (Ctx, (Fld => F_Messages))
and then Available_Space (Ctx, F_Messages) >= Field_Length (Ctx, F_Messages)
and then Field_First (Ctx, F_Messages) mod Types.Byte'Size = 1
and then Field_Length (Ctx, F_Messages) mod Types.Byte'Size = 0
and then Field_Length (Ctx, F_Messages) = 0,
Post =>
Has_Buffer (Ctx)
and Ctx.Buffer_First = Ctx.Buffer_First'Old
and Ctx.Buffer_Last = Ctx.Buffer_Last'Old
and Ctx.First = Ctx.First'Old
and Predecessor (Ctx, F_Messages) = Predecessor (Ctx, F_Messages)'Old
and Valid_Next (Ctx, F_Messages) = Valid_Next (Ctx, F_Messages)'Old
and Get_Length (Ctx) = Get_Length (Ctx)'Old
and Structural_Valid (Ctx, F_Messages);

procedure Switch_To_Messages (Ctx : in out Context; Seq_Ctx : out Inner_Messages_Sequence.Context) with
Pre =>
not Ctx'Constrained
Expand Down
10 changes: 10 additions & 0 deletions generated/rflx-ethernet-generic_frame.adb
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,16 @@ is
Ctx.Cursors (Successor (Ctx, F_Type_Length)) := (State => S_Invalid, Predecessor => F_Type_Length);
end Set_Type_Length;

procedure Set_Payload_Empty (Ctx : in out Context) is
First : constant Types.Bit_Index := Field_First (Ctx, F_Payload);
Last : constant Types.Bit_Index := Field_Last (Ctx, F_Payload);
begin
Reset_Dependent_Fields (Ctx, F_Payload);
Ctx := (Ctx.Buffer_First, Ctx.Buffer_Last, Ctx.First, Last, Ctx.Buffer, Ctx.Cursors);
Ctx.Cursors (F_Payload) := (State => S_Valid, First => First, Last => Last, Value => (Fld => F_Payload), Predecessor => Ctx.Cursors (F_Payload).Predecessor);
Ctx.Cursors (Successor (Ctx, F_Payload)) := (State => S_Invalid, Predecessor => F_Payload);
end Set_Payload_Empty;

procedure Set_Payload (Ctx : in out Context) is
First : constant Types.Bit_Index := Field_First (Ctx, F_Payload);
Last : constant Types.Bit_Index := Field_Last (Ctx, F_Payload);
Expand Down
24 changes: 24 additions & 0 deletions generated/rflx-ethernet-generic_frame.ads
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,30 @@ is
and Context_Cursor (Ctx, F_TPID) = Context_Cursor (Ctx, F_TPID)'Old
and Context_Cursor (Ctx, F_TCI) = Context_Cursor (Ctx, F_TCI)'Old;

procedure Set_Payload_Empty (Ctx : in out Context) with
Pre =>
not Ctx'Constrained
and then Has_Buffer (Ctx)
and then Valid_Next (Ctx, F_Payload)
and then Field_Last (Ctx, F_Payload) <= Types.Bit_Index'Last / 2
and then Field_Condition (Ctx, (Fld => F_Payload), Field_Length (Ctx, F_Payload))
and then Available_Space (Ctx, F_Payload) >= Field_Length (Ctx, F_Payload)
and then Field_First (Ctx, F_Payload) mod Types.Byte'Size = 1
and then Field_Length (Ctx, F_Payload) mod Types.Byte'Size = 0
and then Field_Length (Ctx, F_Payload) = 0,
Post =>
Has_Buffer (Ctx)
and Ctx.Buffer_First = Ctx.Buffer_First'Old
and Ctx.Buffer_Last = Ctx.Buffer_Last'Old
and Ctx.First = Ctx.First'Old
and Predecessor (Ctx, F_Payload) = Predecessor (Ctx, F_Payload)'Old
and Valid_Next (Ctx, F_Payload) = Valid_Next (Ctx, F_Payload)'Old
and Get_Destination (Ctx) = Get_Destination (Ctx)'Old
and Get_Source (Ctx) = Get_Source (Ctx)'Old
and Get_Type_Length_TPID (Ctx) = Get_Type_Length_TPID (Ctx)'Old
and Get_Type_Length (Ctx) = Get_Type_Length (Ctx)'Old
and Structural_Valid (Ctx, F_Payload);

generic
with procedure Process_Payload (Payload : out Types.Bytes);
with function Valid_Length (Length : Types.Length) return Boolean;
Expand Down
10 changes: 10 additions & 0 deletions generated/rflx-ipv4-generic_option.adb
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,16 @@ is
Ctx.Cursors (Successor (Ctx, F_Option_Length)) := (State => S_Invalid, Predecessor => F_Option_Length);
end Set_Option_Length;

procedure Set_Option_Data_Empty (Ctx : in out Context) is
First : constant Types.Bit_Index := Field_First (Ctx, F_Option_Data);
Last : constant Types.Bit_Index := Field_Last (Ctx, F_Option_Data);
begin
Reset_Dependent_Fields (Ctx, F_Option_Data);
Ctx := (Ctx.Buffer_First, Ctx.Buffer_Last, Ctx.First, Last, Ctx.Buffer, Ctx.Cursors);
Ctx.Cursors (F_Option_Data) := (State => S_Valid, First => First, Last => Last, Value => (Fld => F_Option_Data), Predecessor => Ctx.Cursors (F_Option_Data).Predecessor);
Ctx.Cursors (Successor (Ctx, F_Option_Data)) := (State => S_Invalid, Predecessor => F_Option_Data);
end Set_Option_Data_Empty;

procedure Set_Option_Data (Ctx : in out Context) is
First : constant Types.Bit_Index := Field_First (Ctx, F_Option_Data);
Last : constant Types.Bit_Index := Field_Last (Ctx, F_Option_Data);
Expand Down
24 changes: 24 additions & 0 deletions generated/rflx-ipv4-generic_option.ads
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,30 @@ is
and Context_Cursor (Ctx, F_Option_Class) = Context_Cursor (Ctx, F_Option_Class)'Old
and Context_Cursor (Ctx, F_Option_Number) = Context_Cursor (Ctx, F_Option_Number)'Old;

procedure Set_Option_Data_Empty (Ctx : in out Context) with
Pre =>
not Ctx'Constrained
and then Has_Buffer (Ctx)
and then Valid_Next (Ctx, F_Option_Data)
and then Field_Last (Ctx, F_Option_Data) <= Types.Bit_Index'Last / 2
and then Field_Condition (Ctx, (Fld => F_Option_Data))
and then Available_Space (Ctx, F_Option_Data) >= Field_Length (Ctx, F_Option_Data)
and then Field_First (Ctx, F_Option_Data) mod Types.Byte'Size = 1
and then Field_Length (Ctx, F_Option_Data) mod Types.Byte'Size = 0
and then Field_Length (Ctx, F_Option_Data) = 0,
Post =>
Has_Buffer (Ctx)
and Ctx.Buffer_First = Ctx.Buffer_First'Old
and Ctx.Buffer_Last = Ctx.Buffer_Last'Old
and Ctx.First = Ctx.First'Old
and Predecessor (Ctx, F_Option_Data) = Predecessor (Ctx, F_Option_Data)'Old
and Valid_Next (Ctx, F_Option_Data) = Valid_Next (Ctx, F_Option_Data)'Old
and Get_Copied (Ctx) = Get_Copied (Ctx)'Old
and Get_Option_Class (Ctx) = Get_Option_Class (Ctx)'Old
and Get_Option_Number (Ctx) = Get_Option_Number (Ctx)'Old
and Get_Option_Length (Ctx) = Get_Option_Length (Ctx)'Old
and Structural_Valid (Ctx, F_Option_Data);

generic
with procedure Process_Option_Data (Option_Data : out Types.Bytes);
with function Valid_Length (Length : Types.Length) return Boolean;
Expand Down
Loading

0 comments on commit a652916

Please sign in to comment.