Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
kazoo
Commits
920c8759
Commit
920c8759
authored
Nov 28, 2018
by
Maxime Perrotin
Browse files
Use holder container rather than string access
parent
179f6689
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/aadl_parser.adb
View file @
920c8759
...
...
@@ -14,8 +14,8 @@ begin
if
Transformed
.
Configuration
.
Glue
then
Transformed
.
Add_Concurrency_View
;
Transformed
.
Concurrency_View
.
Generate_CV
(
Base_Template_Path
=>
Model
.
Configuration
.
Binary_Path
.
all
,
Base_Output_Path
=>
Model
.
Configuration
.
Output_Dir
.
all
);
(
Base_Template_Path
=>
Model
.
Configuration
.
Binary_Path
.
Element
,
Base_Output_Path
=>
Model
.
Configuration
.
Output_Dir
.
Element
);
end
if
;
Transformed
.
Dump
;
Transformed
.
Generate_Build_Script
;
...
...
src/taste-aadl_parser.adb
View file @
920c8759
...
...
@@ -35,6 +35,7 @@ package body TASTE.AADL_Parser is
File_Name
:
Name_Id
;
File_Descr
:
Location
;
Cfg
:
Taste_Configuration
;
use
String_Holders
;
begin
Banner
;
-- Parse arguments before initializing Ocarina, otherwise Ocarina eats
...
...
@@ -44,20 +45,22 @@ package body TASTE.AADL_Parser is
AADL_Language
:=
Get_String_Name
(
"aadl"
);
if
Cfg
.
Interface_View
.
all
'
Length
=
0
and
not
Cfg
.
Check_Data_View
then
if
Cfg
.
Interface_View
.
Is_Empty
and
not
Cfg
.
Check_Data_View
then
-- Use "InterfaceView.aadl" by default, if nothing else is specified
-- and if the tool is not only called to check the data view
Cfg
.
Interface_View
:=
Default_Interface_View
'
Access
;
-- Cfg.Interface_View := Default_Interface_View'Access;
Cfg
.
Interface_View
:=
To_Holder
(
Default_Interface_View
);
end
if
;
-- An interface view is expected, look for it and parse it
if
Cfg
.
Interface_View
.
all
'
Length
>
0
then
Set_Str_To_Name_Buffer
(
Cfg
.
Interface_View
.
all
);
if
not
Cfg
.
Interface_View
.
Is_Empty
then
Set_Str_To_Name_Buffer
(
Cfg
.
Interface_View
.
Element
);
File_Name
:=
Ocarina
.
Files
.
Search_File
(
Name_Find
);
if
File_Name
=
No_Name
then
raise
AADL_Parser_Error
with
"File not found : "
&
Cfg
.
Interface_View
.
all
;
with
"Interface View file not found : "
&
Cfg
.
Interface_View
.
Element
;
end
if
;
File_Descr
:=
Ocarina
.
Files
.
Load_File
(
File_Name
);
...
...
@@ -76,16 +79,17 @@ package body TASTE.AADL_Parser is
if
Cfg
.
Glue
then
-- Look for a deployment view (or DeploymentView.aadl by default)
-- if the glue generation is requested. Not needed for skeletons.
if
Cfg
.
Deployment_View
.
all
'
Length
=
0
then
Cfg
.
Deployment_View
:=
Default_Deployment_View
'
Access
;
if
Cfg
.
Deployment_View
.
Is_Empty
then
Cfg
.
Deployment_View
:=
To_Holder
(
Default_Deployment_View
)
;
end
if
;
Set_Str_To_Name_Buffer
(
Cfg
.
Deployment_View
.
all
);
Set_Str_To_Name_Buffer
(
Cfg
.
Deployment_View
.
Element
);
File_Name
:=
Ocarina
.
Files
.
Search_File
(
Name_Find
);
if
File_Name
=
No_Name
then
raise
AADL_Parser_Error
with
"File not found : "
&
Cfg
.
Deployment_View
.
all
;
with
"Deployment View file not found : "
&
Cfg
.
Deployment_View
.
Element
;
end
if
;
File_Descr
:=
Ocarina
.
Files
.
Load_File
(
File_Name
);
...
...
@@ -115,18 +119,19 @@ package body TASTE.AADL_Parser is
end
if
;
end
loop
;
if
Cfg
.
Data_View
.
all
'
Length
>
0
then
Set_Str_To_Name_Buffer
(
Cfg
.
Data_View
.
all
);
if
not
Cfg
.
Data_View
.
Is_Empty
then
Set_Str_To_Name_Buffer
(
Cfg
.
Data_View
.
Element
);
File_Name
:=
Ocarina
.
Files
.
Search_File
(
Name_Find
);
if
File_Name
=
No_Name
then
raise
AADL_Parser_Error
with
"Could not find "
&
Cfg
.
Data_View
.
all
;
raise
AADL_Parser_Error
with
"Could not find "
&
Cfg
.
Data_View
.
Element
;
end
if
;
else
-- Try with default name (DataView.aadl)
Set_Str_To_Name_Buffer
(
Default_Data_View
);
File_Name
:=
Ocarina
.
Files
.
Search_File
(
Name_Find
);
if
File_Name
/=
No_Name
then
Cfg
.
Data_View
:=
Default_Data_View
'
Access
;
Cfg
.
Data_View
:=
To_Holder
(
Default_Data_View
)
;
elsif
Cfg
.
Check_Data_View
then
-- No dataview found, while user asked explicitly for a check
raise
AADL_Parser_Error
with
"Could not find DataView.aadl"
;
...
...
@@ -134,7 +139,7 @@ package body TASTE.AADL_Parser is
end
if
;
if
File_Name
/=
No_Name
then
Put_Info
(
"Parsing "
&
Cfg
.
Data_View
.
all
);
Put_Info
(
"Parsing "
&
Cfg
.
Data_View
.
Element
);
File_Descr
:=
Ocarina
.
Files
.
Load_File
(
File_Name
);
...
...
@@ -171,13 +176,13 @@ package body TASTE.AADL_Parser is
raise
AADL_Parser_Error
with
"Interface view parsing error"
;
end
;
if
Result
.
Configuration
.
Deployment_View
.
all
'
Length
>
0
then
AADL_Lib
.
Append
(
Result
.
Configuration
.
Interface_View
.
all
);
if
not
Result
.
Configuration
.
Deployment_View
.
Is_Empty
then
AADL_Lib
.
Append
(
Result
.
Configuration
.
Interface_View
.
Element
);
Result
.
Deployment_View
:=
Parse_Deployment_View
(
Deployment_Root
);
end
if
;
end
if
;
if
Result
.
Configuration
.
Data_View
.
all
'
Length
>
0
then
if
not
Result
.
Configuration
.
Data_View
.
Is_Empty
then
begin
Result
.
Data_View
:=
Parse_Data_View
(
Dataview_root
);
Result
.
Data_View
.
Check_Files
;
...
...
@@ -421,8 +426,8 @@ package body TASTE.AADL_Parser is
end
Add_Concurrency_View
;
procedure
Dump
(
Model
:
TASTE_Model
)
is
Output_Path
:
constant
String
:=
Model
.
Configuration
.
Output_Dir
.
all
&
"/Debug"
;
Output_Path
:
constant
String
:=
Model
.
Configuration
.
Output_Dir
.
Element
&
"/Debug"
;
Output
:
File_Type
;
begin
if
Model
.
Configuration
.
Debug_Flag
then
...
...
@@ -434,7 +439,7 @@ package body TASTE.AADL_Parser is
Model
.
Interface_View
.
Debug_Dump
(
Output
);
Close
(
Output
);
if
Model
.
Configuration
.
Deployment_View
.
all
'
Length
>
0
then
if
not
Model
.
Configuration
.
Deployment_View
.
Is_Empty
then
Create
(
File
=>
Output
,
Mode
=>
Out_File
,
Name
=>
Output_Path
&
"/DeploymentView.dump"
);
...
...
src/taste-backend-build_script.adb
View file @
920c8759
...
...
@@ -13,8 +13,8 @@ use System.OS_Lib,
package
body
TASTE
.
Backend
.
Build_Script
is
procedure
Generate
(
Model
:
TASTE_Model
)
is
Prefix
:
constant
String
:=
Model
.
Configuration
.
Binary_Path
.
all
&
"templates/"
;
Prefix
:
constant
String
:=
Model
.
Configuration
.
Binary_Path
.
Element
&
"templates/"
;
Vec_Code
:
Tag
;
Vec_Zip
:
Tag
;
Vec_Func
:
Tag
;
...
...
@@ -46,15 +46,16 @@ package body TASTE.Backend.Build_Script is
declare
Template_Data
:
constant
Translate_Set
:=
+
Assoc
(
"Interface_View_Path"
,
Model
.
Configuration
.
Interface_View
.
all
)
&
Assoc
(
"Output_Path"
,
Model
.
Configuration
.
Output_Dir
.
all
)
Model
.
Configuration
.
Interface_View
.
Element
)
&
Assoc
(
"Output_Path"
,
Model
.
Configuration
.
Output_Dir
.
Element
)
&
Assoc
(
"Generate_Code"
,
Vec_Code
)
&
Assoc
(
"Zip_Code"
,
Vec_Zip
)
&
Assoc
(
"Functions"
,
Vec_Func
)
&
Assoc
(
"CodeCoverage"
,
"# TODO"
);
Result
:
constant
String
:=
Parse
(
Prefix
&
"build-script.tmplt"
,
Template_Data
);
Output_Path
:
constant
String
:=
Model
.
Configuration
.
Output_Dir
.
all
;
Output_Path
:
constant
String
:=
Model
.
Configuration
.
Output_Dir
.
Element
;
Filename
:
constant
String
:=
Output_Path
&
"/build-script.sh"
;
Output
:
File_Type
;
Success
:
Boolean
;
...
...
src/taste-backend-code_generators.adb
View file @
920c8759
...
...
@@ -23,8 +23,8 @@ package body TASTE.Backend.Code_Generators is
Interface_View_Template
(
Model
.
Interface_View
);
-- Path to the input templates files
Prefix
:
constant
String
:=
Model
.
Configuration
.
Binary_Path
.
all
&
"templates/"
;
Prefix
:
constant
String
:=
Model
.
Configuration
.
Binary_Path
.
Element
&
"
/
templates/"
;
Prefix_Skeletons
:
constant
String
:=
Prefix
&
"skeletons/"
;
Prefix_Wrappers
:
constant
String
:=
Prefix
&
"glue/language_wrappers"
;
...
...
@@ -89,8 +89,7 @@ package body TASTE.Backend.Code_Generators is
Put_Info
(
"Generating global Makefile"
);
Create
(
File
=>
Output_File
,
Mode
=>
Out_File
,
Name
=>
Model
.
Configuration
.
Output_Dir
.
all
&
"/"
&
"Makefile"
);
Name
=>
Model
.
Configuration
.
Output_Dir
.
Element
&
"/Makefile"
);
Put_Line
(
Output_File
,
Parse
(
Tmplt
,
Content_Set
));
Close
(
Output_File
);
end
Generate_Global_Makefile
;
...
...
@@ -331,17 +330,19 @@ package body TASTE.Backend.Code_Generators is
begin
Generate_From_Templates
(
Prefix
=>
Prefix_Skeletons
,
Output_Base
=>
Model
.
Configuration
.
Output_Dir
.
all
&
"/"
,
Model
.
Configuration
.
Output_Dir
.
Element
&
"/"
,
Output_Sub
=>
"src/"
);
Generate_Global_Makefile
;
if
Model
.
Configuration
.
Glue
then
Generate_From_Templates
(
Prefix
=>
Prefix_Wrappers
,
Output_Base
=>
Model
.
Configuration
.
Output_Dir
.
all
&
"/"
,
Model
.
Configuration
.
Output_Dir
.
Element
&
"/"
,
Output_Sub
=>
"wrappers/"
);
Generate_From_Templates
(
Prefix
=>
Prefix_Middleware
,
Output_Base
=>
Model
.
Configuration
.
Output_Dir
.
all
&
"/"
,
Model
.
Configuration
.
Output_Dir
.
Element
&
"/"
,
Output_Sub
=>
"middleware_glue/"
);
end
if
;
end
Generate
;
...
...
src/taste-data_view.adb
View file @
920c8759
...
...
@@ -128,7 +128,7 @@ package body TASTE.Data_View is
begin
for
Each
of
DV
.
ASN1_Files
loop
if
not
Ada
.
Directories
.
Exists
(
To_String
(
Each
.
Path
))
then
Put_Error
(
"File not found: "
&
To_String
(
Each
.
Path
));
Put_Error
(
"
ASN.1
File not found: "
&
To_String
(
Each
.
Path
));
Success
:=
False
;
end
if
;
end
loop
;
...
...
src/taste-parser_utils.adb
View file @
920c8759
...
...
@@ -7,6 +7,7 @@ with Ada.Characters.Latin_1,
Ada
.
Strings
.
Fixed
,
Ada
.
Strings
,
GNAT
.
OS_Lib
,
GNAT
.
Strings
,
GNAT
.
Command_Line
,
Templates_Parser
.
Utils
,
Ocarina
.
AADL_Values
,
...
...
@@ -57,19 +58,22 @@ package body TASTE.Parser_Utils is
procedure
Parse_Command_Line
(
Result
:
out
Taste_Configuration
)
is
Config
:
Command_Line_Configuration
;
use
String_Holders
;
IV
,
DeplV
,
DataV
,
OutDir
:
aliased
GNAT
.
Strings
.
String_Access
:=
null
;
begin
Result
.
Binary_Path
:=
new
String
'
(
Get_Program_Directory
);
Define_Switch
(
Config
,
Output
=>
Result
.
Interface_View
'
Access
,
Result
.
Binary_Path
:=
To_Holder
(
Get_Program_Directory
);
Define_Switch
(
Config
,
Output
=>
IV
'
Access
,
Switch
=>
"-i:"
,
Long_Switch
=>
"--interfaceview="
,
Help
=>
"Mandatory interface view (AADL model)"
,
Argument
=>
"InterfaceView.aadl"
);
Define_Switch
(
Config
,
Output
=>
Result
.
Deployment_View
'
Access
,
Define_Switch
(
Config
,
Output
=>
DeplV
'
Access
,
Switch
=>
"-c:"
,
Long_Switch
=>
"--deploymentview="
,
Help
=>
"Optional deployment view (AADL model)"
,
Argument
=>
"DeploymentView.aadl"
);
Define_Switch
(
Config
,
Output
=>
Result
.
Data_View
'
Access
,
Define_Switch
(
Config
,
Output
=>
DataV
'
Access
,
Switch
=>
"-d:"
,
Long_Switch
=>
"--dataview="
,
Help
=>
"Optional data view (AADL model)"
,
...
...
@@ -78,7 +82,7 @@ package body TASTE.Parser_Utils is
Switch
=>
"-y"
,
Long_Switch
=>
"--check-dataview"
,
Help
=>
"Check Data View"
);
Define_Switch
(
Config
,
Output
=>
Result
.
Output_
Dir
'
Access
,
Define_Switch
(
Config
,
Output
=>
Out
Dir
'
Access
,
Switch
=>
"-o:"
,
Long_Switch
=>
"--output="
,
Help
=>
"Output directory (created if absent)"
,
...
...
@@ -119,12 +123,28 @@ package body TASTE.Parser_Utils is
end
;
end
loop
;
-- We must set the values in the holders based on the parsed strings
Result
.
Interface_View
:=
(
if
IV
/=
null
and
then
IV
.
all
'
Length
>
0
then
To_Holder
(
IV
.
all
)
else
Empty_Holder
);
Result
.
Deployment_View
:=
(
if
DeplV
/=
null
and
then
DeplV
.
all
'
Length
>
0
then
To_Holder
(
DeplV
.
all
)
else
Empty_Holder
);
Result
.
Data_View
:=
(
if
DataV
/=
null
and
then
DataV
.
all
'
Length
>
0
then
To_Holder
(
DataV
.
all
)
else
Empty_Holder
);
Result
.
Output_Dir
:=
(
if
OutDir
/=
null
and
then
OutDir
.
all
'
Length
>
0
then
To_Holder
(
OutDir
.
all
)
else
To_Holder
(
"."
));
if
Result
.
Version
then
raise
Exit_From_Command_Line
;
end
if
;
if
Result
.
Output_Dir
=
null
or
else
Result
.
Output_Dir
.
all
'
Length
=
0
then
Result
.
Output_Dir
:=
new
String
'(
"."
);
end
if
;
end
Parse_Command_Line
;
function
To_Template_Tag
(
SS
:
String_Sets
.
Set
)
return
Tag
is
...
...
@@ -140,10 +160,12 @@ package body TASTE.Parser_Utils is
Vec
:
Tag
;
Template
:
Translate_Set
;
begin
Template
:=
+
Assoc
(
"Interface_View"
,
Config
.
Interface_View
.
all
)
&
Assoc
(
"Deployment_View"
,
Config
.
Deployment_View
.
all
)
&
Assoc
(
"Data_View"
,
Config
.
Data_View
.
all
)
&
Assoc
(
"Output_Dir"
,
Config
.
Output_Dir
.
all
)
Template
:=
+
Assoc
(
"Interface_View"
,
Config
.
Interface_View
.
Element
)
&
Assoc
(
"Deployment_View"
,
(
if
Config
.
Deployment_View
.
Is_Empty
then
"<none>"
else
Config
.
Deployment_View
.
Element
))
&
Assoc
(
"Data_View"
,
Config
.
Data_View
.
Element
)
&
Assoc
(
"Output_Dir"
,
Config
.
Output_Dir
.
Element
)
&
Assoc
(
"Skeletons"
,
Config
.
Skeletons
)
&
Assoc
(
"Glue"
,
Config
.
Glue
)
&
Assoc
(
"Use_POHIC"
,
Config
.
Use_POHIC
)
...
...
@@ -155,7 +177,7 @@ package body TASTE.Parser_Utils is
end
loop
;
Template
:=
Template
&
Assoc
(
"Other_Files"
,
Vec
);
Put_Line
(
Output
,
Parse
(
Config
.
Binary_Path
.
all
&
"templates/configuration.tmplt"
,
Parse
(
Config
.
Binary_Path
.
Element
&
"templates/configuration.tmplt"
,
Template
));
end
Debug_Dump
;
...
...
src/taste-parser_utils.ads
View file @
920c8759
...
...
@@ -11,7 +11,6 @@ with Ada.Containers.Indefinite_Ordered_Maps,
Ada
.
Strings
.
Equal_Case_Insensitive
,
Ada
.
Strings
.
Less_Case_Insensitive
,
Text_IO
,
GNAT
.
Strings
,
Interfaces
.
C_Streams
,
Templates_Parser
,
Ocarina
,
...
...
@@ -35,9 +34,9 @@ use Ocarina,
package
TASTE
.
Parser_Utils
is
AADL_Language
:
Name_Id
;
Default_Interface_View
:
aliased
String
:=
"InterfaceView.aadl"
;
Default_Deployment_View
:
aliased
String
:=
"DeploymentView.aadl"
;
Default_Data_View
:
aliased
String
:=
"DataView.aadl"
;
Default_Interface_View
:
constant
String
:=
"InterfaceView.aadl"
;
Default_Deployment_View
:
constant
String
:=
"DeploymentView.aadl"
;
Default_Data_View
:
constant
String
:=
"DataView.aadl"
;
-- Create a case insensitive string type, that can be used as keys for maps
subtype
Case_Insensitive_String
is
String
;
...
...
@@ -127,13 +126,15 @@ package TASTE.Parser_Utils is
procedure
Initialize_Ocarina
;
subtype
String_Holder
is
String_Holders
.
Holder
;
type
Taste_Configuration
is
tagged
record
Binary_Path
:
GNAT
.
Strings
.
String_Access
;
Interface_View
:
aliased
GNAT
.
Strings
.
String_Access
;
Deployment_View
:
aliased
GNAT
.
Strings
.
String_Access
;
Data_View
:
aliased
GNAT
.
Strings
.
String_Access
;
Output_Dir
:
aliased
GNAT
.
Strings
.
String_Access
;
Binary_Path
:
String_Holder
;
Interface_View
:
String_Holder
;
Deployment_View
:
String_Holder
;
Data_View
:
String_Holder
;
Output_Dir
:
String_Holder
;
-- aliased GNAT.Strings.String_Access;
Check_Data_View
:
aliased
Boolean
:=
False
;
Skeletons
:
aliased
Boolean
:=
True
;
Glue
:
aliased
Boolean
:=
False
;
...
...
test/test7/expected
View file @
920c8759
[ERROR] File not found: /Non/Existing/Path/Are/You/Detected?
[ERROR]
ASN.1
File not found: /Non/Existing/Path/Are/You/Detected?
[ERROR] ASN.1 files missing (wrong path in DataView.aadl). Run taste-update-data-view [list of ASN.1 files]
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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