Commit 17f8f6ce authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Get skeleton filenames from template

parent 55863184
...@@ -9,6 +9,7 @@ begin ...@@ -9,6 +9,7 @@ begin
Model := Parse_Project; Model := Parse_Project;
Model.Dump; Model.Dump;
Model.Generate_Build_Script; Model.Generate_Build_Script;
Model.Generate_Skeletons;
exception exception
when TASTE.Quit_TASTE => when TASTE.Quit_TASTE =>
GNAT.OS_Lib.OS_Exit (1); GNAT.OS_Lib.OS_Exit (1);
......
...@@ -5,7 +5,7 @@ use Text_IO, ...@@ -5,7 +5,7 @@ use Text_IO,
package body TASTE.Backend.Skeletons.C is package body TASTE.Backend.Skeletons.C is
procedure Generate (Config : Taste_Configuration; procedure Generate (Config : Taste_Configuration;
Template : Translate_Set) is Template : IV_As_Template) is
dummy_Prefix : constant String := Config.Binary_Path.all dummy_Prefix : constant String := Config.Binary_Path.all
& "templates/skeletons/c"; & "templates/skeletons/c";
begin begin
......
with TASTE.Interface_View, with TASTE.Interface_View,
TASTE.Parser_Utils; TASTE.Parser_Utils;
use TASTE.Interface_View, use TASTE.Interface_View,
TASTE.Parser_Utils; TASTE.Parser_Utils;
package TASTE.Backend.Skeletons.C is package TASTE.Backend.Skeletons.C is
procedure Generate (Config : Taste_Configuration; procedure Generate (Config : Taste_Configuration;
Func : Taste_Terminal_Function); Template : IV_As_Template);
pragma Unreferenced (Generate); pragma Unreferenced (Generate);
end TASTE.Backend.Skeletons.C; end TASTE.Backend.Skeletons.C;
with Text_IO; use Text_IO; with Text_IO; use Text_IO;
with Ada.Strings.Unbounded,
Ada.Characters.Handling;
use Ada.Characters.Handling;
-- with TASTE.Backend.Skeletons.C; -- with TASTE.Backend.Skeletons.C;
...@@ -6,17 +10,26 @@ package body TASTE.Backend.Skeletons is ...@@ -6,17 +10,26 @@ package body TASTE.Backend.Skeletons is
procedure Generate (Model : TASTE_Model) is procedure Generate (Model : TASTE_Model) is
dummy_Template : constant IV_As_Template := dummy_Template : constant IV_As_Template :=
Interface_View_Template (Model.Interface_View); Interface_View_Template (Model.Interface_View);
Prefix : constant String := Model.Configuration.Binary_Path.all
& "templates/skeletons/";
use Ada.Strings.Unbounded;
begin begin
Put_Line ("=== Generate skeletons ==="); Put_Line ("=== Generate skeletons ===");
-- case Each.Language is for Each of Model.Interface_View.Flat_Functions loop
-- when Language_C => declare
-- TASTE.Backend.Skeletons.C.Generate (Model.Configuration, Language : constant String := Language_Spelling (Each);
-- Template); Path : constant String := Prefix & To_Lower (Language) & "/";
-- when others => Hdr_Tmpl : constant Translate_Set := +Assoc ("Name", Each.Name);
-- Put_Line (Each.Language'Img & "Not supported yet"); begin
-- end case; Put ("Generating ");
-- end; Put_Line (Parse (Path & "header-filename.tmplt", Hdr_Tmpl));
-- end loop; Put ("Generating ");
Put_Line (Parse (Path & "body-filename.tmplt", Hdr_Tmpl));
exception
when others =>
Put_Line ("no skeletons for language " & Language & " !");
end;
end loop;
end Generate; end Generate;
function Parameter_Template (Param : ASN1_Parameter) return Translate_Set is function Parameter_Template (Param : ASN1_Parameter) return Translate_Set is
...@@ -55,11 +68,13 @@ package body TASTE.Backend.Skeletons is ...@@ -55,11 +68,13 @@ package body TASTE.Backend.Skeletons is
function Interface_View_Template (IV : Complete_Interface_View) function Interface_View_Template (IV : Complete_Interface_View)
return IV_As_Template is return IV_As_Template is
use Func_Vectors; use Func_Maps;
use Ada.Strings.Unbounded;
Result : IV_As_Template; Result : IV_As_Template;
begin begin
for Each of IV.Flat_Functions loop for Each of IV.Flat_Functions loop
Result.Funcs := Result.Funcs & Func_Template (Each); Result.Funcs.Insert (Key => To_String (Each.Name),
New_Item => Func_Template (Each));
end loop; end loop;
return Result; return Result;
end Interface_View_Template; end Interface_View_Template;
......
with Ada.Containers.Indefinite_Vectors, with Ada.Containers.Indefinite_Vectors,
Ada.Containers.Indefinite_Ordered_Maps,
Templates_Parser, Templates_Parser,
TASTE.AADL_Parser; TASTE.AADL_Parser;
...@@ -27,11 +28,11 @@ private ...@@ -27,11 +28,11 @@ private
Required : Interface_Vectors.Vector; Required : Interface_Vectors.Vector;
end record; end record;
package Func_Vectors is new Indefinite_Vectors (Natural, Func_As_Template); package Func_Maps is new Indefinite_Ordered_Maps (String, Func_As_Template);
type IV_As_Template is type IV_As_Template is
record record
Funcs : Func_Vectors.Vector; Funcs : Func_Maps.Map;
end record; end record;
-- Set of functions translating the AST into Templates_Parser mappings -- Set of functions translating the AST into Templates_Parser mappings
......
Supports Markdown
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