Commit b7bf6c7a authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Give possibility to skip body or header file

e.g. body of SDL files is not needed if the function is an instance of
a function type.
parent 60ca3183
......@@ -123,7 +123,10 @@ package body TASTE.Backend.Skeletons is
Language : constant String := Language_Spelling (Each);
Path : constant String := Prefix & To_Lower (Language) & "/";
Proceed : constant Boolean := Is_Template_Present (Path);
Hdr_Tmpl : constant Translate_Set := +Assoc ("Name", Each.Name);
Hdr_Tmpl : constant Translate_Set :=
+Assoc ("Name", Each.Name)
& Assoc ("Is_Type", Each.Is_Type)
& Assoc ("Instance_Of", Each.Instance_Of.Value_Or (US ("")));
Make_Tmpl : constant Translate_Set := Function_Makefile_Template
(F => Each,
Modules => Get_Module_List,
......@@ -164,11 +167,11 @@ package body TASTE.Backend.Skeletons is
& "/" & Language
& "/" & "src" & "/";
-- Get header and body filenames from templates
Header_File : constant String :=
Header_File : constant String := Strip_String
(if Proceed then Parse
(Path & "header-filename.tmplt", Hdr_Tmpl)
else "");
Body_File : constant String :=
Body_File : constant String := Strip_String
(if Proceed then Parse
(Path & "body-filename.tmplt", Hdr_Tmpl)
else "");
......@@ -177,13 +180,19 @@ package body TASTE.Backend.Skeletons is
if Proceed then
-- Create directory tree (output/function/language/src)
Create_Path (Output_Src);
Put_Info ("Generating " & Header_File);
Create (File => Output_File,
Mode => Out_File,
Name => Output_Src & Header_File);
Put_Line (Output_File, Header_Text);
Close (Output_File);
if not Exists (Output_Src & Body_File) then
if Header_File /= "" then
Put_Info ("Generating " & Output_Src & Header_File);
Create (File => Output_File,
Mode => Out_File,
Name => Output_Src & Header_File);
Put_Line (Output_File, Header_Text);
Close (Output_File);
else
Put_Info ("No header file needed for function "
& To_String (Each.Name));
end if;
if Body_File /= "" and then not Exists (Output_Src & Body_File)
then
Put_Info ("Generating " & Body_File);
Create (File => Output_File,
Mode => Out_File,
......@@ -191,7 +200,8 @@ package body TASTE.Backend.Skeletons is
Put_Line (Output_File, Body_Text);
Close (Output_File);
else
Put_Info (Body_File & " already exists, ignoring");
Put_Info ("No body file generated for function "
& To_String (Each.Name));
end if;
Put_Info ("Generating " & Make_File & " for function "
& To_String (Each.Name));
......
......@@ -2,7 +2,11 @@
-- (c) 2008-2018 European Space Agency - maxime.perrotin@esa.int
-- LGPL license, see LICENSE file
with GNAT.OS_Lib,
with Ada.Characters.Latin_1,
Ada.Strings.Maps,
Ada.Strings.Fixed,
Ada.Strings,
GNAT.OS_Lib,
GNAT.Command_Line,
Templates_Parser,
Templates_Parser.Utils,
......@@ -44,6 +48,16 @@ package body TASTE.Parser_Utils is
New_Line;
end Banner;
-- Strip function as in Python
function Strip_String (Input_String : String) return String is
use Ada.Characters.Latin_1;
Strip_Set : constant Ada.Strings.Maps.Character_Set :=
Ada.Strings.Maps.To_Set
(" " & HT & VT & NUL & LF & CR & BS & EOT & FF);
begin
return Ada.Strings.Fixed.Trim (Input_String, Strip_Set, Strip_Set);
end Strip_String;
procedure Parse_Command_Line (Result : out Taste_Configuration) is
Config : Command_Line_Configuration;
begin
......
......@@ -53,6 +53,8 @@ package TASTE.Parser_Utils is
(if Is_Tty then ASCII.ESC & "[4m" else "");
function White_Bold return String is (if Is_Tty then White & Bold else "");
function Strip_String (Input_String : String) return String;
procedure Put_Info (Info : String);
procedure Put_Error (Error : String);
......
package TASTE.Parser_Version is
Parser_Release : constant String :=
"1ccf1b2 ; Commit Date: Sat Mar 3 21:28:23 2018 ";
"60ca318 ; Commit Date: Sat Mar 10 18:29:53 2018 ";
Ocarina_Version : constant String :=
"Ocarina 2017.x (Working Copy from rc50d394)";
end TASTE.Parser_Version;
\ No newline at end of file
@@-- The following tags are available in this template:
@@--
@@-- @_Name_@ : The name of the function
@@-- @_Is_Type_@ : True if function type
@@-- @_Instance_Of_@ : Name of instance or empty string
@_LOWER:Name_@.adb
@@-- The following tags are available in this template:
@@--
@@-- @_Name_@ : The name of the function
@@-- @_Is_Type_@ : True if function type
@@-- @_Instance_Of_@ : Name of instance or empty string
@_LOWER:Name_@.ads
@@-- The following tags are available in this template:
@@--
@@-- @_Name_@ : The name of the function
@@-- @_Is_Type_@ : True if function type
@@-- @_Instance_Of_@ : Name of instance or empty string
@_LOWER:Name_@.c
@@-- The following tags are available in this template:
@@--
@@-- @_Name_@ : The name of the function
@@-- @_Is_Type_@ : True if function type
@@-- @_Instance_Of_@ : Name of instance or empty string
@_LOWER:Name_@.h
@@-- The following tags are available in this template:
@@--
@@-- @_Name_@ : The name of the function
@@-- @_Is_Type_@ : True if function type
@@-- @_Instance_Of_@ : Name of instance or empty string
@@IF@@ @_Instance_Of_@ = ""
@_LOWER:Name_@.pr
@@ELSE@@
@@END_IF@@
@@-- The following tags are available in this template:
@@--
@@-- @_Name_@ : The name of the function
@@-- @_Is_Type_@ : True if function type
@@-- @_Instance_Of_@ : Name of instance or empty string
system_structure.pr
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