Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
kazoo
Commits
17f8f6ce
Commit
17f8f6ce
authored
Jan 21, 2018
by
Maxime Perrotin
Browse files
Get skeleton filenames from template
parent
55863184
Changes
7
Show whitespace changes
Inline
Side-by-side
src/aadl_parser.adb
View file @
17f8f6ce
...
...
@@ -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
);
...
...
src/taste-backend-skeletons-c.adb
View file @
17f8f6ce
...
...
@@ -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
...
...
src/taste-backend-skeletons-c.ads
View file @
17f8f6ce
...
...
@@ -5,6 +5,6 @@ use TASTE.Interface_View,
package
TASTE
.
Backend
.
Skeletons
.
C
is
procedure
Generate
(
Config
:
Taste_Configuration
;
Func
:
Taste_Terminal_Function
);
Template
:
IV_As_Template
);
pragma
Unreferenced
(
Generate
);
end
TASTE
.
Backend
.
Skeletons
.
C
;
src/taste-backend-skeletons.adb
View file @
17f8f6ce
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
;
...
...
src/taste-backend-skeletons.ads
View file @
17f8f6ce
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_
Vector
s
is
new
Indefinite_
Vectors
(
Natural
,
Func_As_Template
);
package
Func_
Map
s
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
...
...
templates/skeletons/c/body-filename.tmplt
0 → 100644
View file @
17f8f6ce
@_LOWER:Name_@.c
templates/skeletons/c/header-filename.tmplt
0 → 100644
View file @
17f8f6ce
@_LOWER:Name_@.h
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment