Commit 9ea98cc7 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Extract the coordinates of functions

Needed for backends to allow applying a transformation
parent 82b449c5
-- *************************** kazoo *********************** --
-- (c) 2017-2020 European Space Agency - maxime.perrotin@esa.int
-- (c) 2017-2021 European Space Agency - maxime.perrotin@esa.int
-- LGPL license, see LICENSE file
-- Interface View parser
......@@ -8,6 +8,7 @@ with Ada.Exceptions,
Ada.Directories,
Ada.Strings.Fixed,
Ada.Characters.Handling,
GNAT.String_Split,
Ocarina.Instances.Queries,
Ocarina.Analyzer,
Ocarina.Options,
......@@ -27,6 +28,7 @@ package body TASTE.Interface_View is
use Ada.Exceptions,
Ada.Strings.Fixed,
Ada.Characters.Handling,
GNAT,
Ocarina.Instances.Queries,
Ocarina.Namet,
Ocarina.Options,
......@@ -1033,6 +1035,8 @@ package body TASTE.Interface_View is
PIs_Have_Params, -- True if at least one PI has an ASN.1 parameter
RIs_Have_Params : Boolean := False; -- Same for RI
Interface_Tmplt : Translate_Set;
-- Optional graphical coordinates of a function:
X1, X2, Y1, Y2 : Unbounded_String := US ("0");
begin
Result.Header := +Assoc ("Name", F.Name)
& Assoc ("Language", Language_Spelling (F))
......@@ -1138,6 +1142,29 @@ package body TASTE.Interface_View is
Timers := Timers & Each;
end loop;
-- If there is a Coordinate property, extract the 4 values
-- (Split the string)
for P of F.User_Properties loop
if P.Name = "Taste::coordinates" then
-- P.Value = x1 y1 x2 y2 (four numbers separated with space)
declare
Subs : String_Split.Slice_Set;
Seps : constant String := " ";
begin
String_Split.Create (S => Subs,
From => To_String (P.Value),
Separators => Seps,
Mode => String_Split.Multiple);
if Integer (String_Split.Slice_Count (Subs)) = 4 then
X1 := US (String_Split.Slice (Subs, 1));
Y1 := US (String_Split.Slice (Subs, 2));
X2 := US (String_Split.Slice (Subs, 3));
Y2 := US (String_Split.Slice (Subs, 4));
end if;
end;
end if;
end loop;
-- Setup the mapping for the template (processed by function.tmplt)
Result.Header :=
Join_Sets (Result.Header,
......@@ -1170,7 +1197,11 @@ package body TASTE.Interface_View is
& Assoc ("Instance_Of", F.Instance_Of.Value_Or (US ("")))
& Assoc ("Timers", Timers)
& Assoc ("PIs_Have_Params", PIs_Have_Params)
& Assoc ("RIs_Have_Params", RIs_Have_Params);
& Assoc ("RIs_Have_Params", RIs_Have_Params)
& Assoc ("Coord.X1", X1)
& Assoc ("Coord.Y1", Y1)
& Assoc ("Coord.X2", X2)
& Assoc ("Coord.Y2", Y2);
return Result;
end Function_To_Template;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment