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

Get skeleton filenames from template

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