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
buildsupport
Commits
991ebcff
Commit
991ebcff
authored
Mar 30, 2017
by
Maxime Perrotin
Browse files
Add option type
parent
d3b05461
Changes
4
Show whitespace changes
Inline
Side-by-side
ada/buildsupport_utils.adb
View file @
991ebcff
...
...
@@ -397,9 +397,16 @@ package body Buildsupport_Utils is
Inst
:
Node_Id
)
return
Taste_Terminal_Function
is
Result
:
Taste_Terminal_Function
;
pragma
Unreferenced
(
Inst
);
-- To get the optional zip filename where user code is stored:
Source_Text
:
constant
Name_Array
:=
Get_Source_Text
(
Inst
);
Zip_Id
:
Name_Id
:=
No_Name
;
begin
Result
.
Name
:=
US
(
Name
);
Result
.
Language
:=
Get_Source_Language
(
Inst
);
if
Source_Text
'
Length
/=
0
then
Zip_Id
:=
Source_Text
(
1
);
Result
.
Zip_File
:=
Just
(
US
(
Get_Name_String
(
Zip_Id
)));
end
if
;
return
Result
;
end
Parse_Function
;
...
...
ada/buildsupport_utils.ads
View file @
991ebcff
...
...
@@ -12,7 +12,8 @@ with Ocarina,
Ada
.
Containers
.
Indefinite_Vectors
,
Ocarina
.
ME_AADL
.
AADL_Tree
.
Nodes
,
Ocarina
.
ME_AADL
.
AADL_Instances
.
Nodes
,
Ada
.
Strings
.
Unbounded
;
Ada
.
Strings
.
Unbounded
,
Option_Type
;
use
Ocarina
,
Types
,
...
...
@@ -142,12 +143,14 @@ package Buildsupport_Utils is
end
record
;
package
Ctxt_Params
is
new
Indefinite_Vectors
(
Natural
,
Context_Parameter
);
package
Option_Zip
is
new
Option_Type
(
Unbounded_String
);
use
Option_Zip
;
type
Taste_Terminal_Function
is
record
Name
:
Unbounded_String
;
Language
:
Supported_Source_Language
;
Zip_File
:
Unbounded_Str
ing
;
Zip_File
:
Option_Zip
.
Option
(
False
)
:=
Noth
ing
;
Context_Params
:
Ctxt_Params
.
Vector
;
User_Properties
:
Property_Maps
.
Map
;
Timers
:
String_Vectors
.
Vector
;
...
...
ada/option_type.ads
0 → 100644
View file @
991ebcff
-- *************************** buildsupport **************************** --
-- (c) 2008-2017 European Space Agency - maxime.perrotin@esa.int
-- LGPL license, see LICENSE file
-- Define a generic Option type
generic
type
T
is
private
;
package
Option_Type
is
pragma
Assertion_Policy
(
check
);
type
Option
(
Present
:
Boolean
)
is
tagged
private
;
function
Just
(
I
:
T
)
return
Option
;
function
Nothing
return
Option
;
function
Just
(
O
:
Option
)
return
T
with
Pre
=>
O
.
Present
;
function
Value
(
O
:
Option
)
return
T
renames
Just
;
function
Value_Or
(
O
:
Option
;
Default
:
T
)
return
T
;
function
Has_Value
(
O
:
Option
)
return
Boolean
is
(
O
.
Present
);
private
type
Option
(
Present
:
Boolean
)
is
tagged
record
case
Present
is
when
True
=>
Value
:
T
;
when
False
=>
null
;
end
case
;
end
record
;
function
Just
(
I
:
T
)
return
Option
is
(
Present
=>
True
,
Value
=>
I
);
function
Nothing
return
Option
is
(
Present
=>
False
);
function
Just
(
O
:
Option
)
return
T
is
(
O
.
Value
);
function
Value_Or
(
O
:
Option
;
Default
:
T
)
return
T
is
(
if
O
.
Present
then
O
.
Value
else
Default
);
end
Option_Type
;
buildsupport.gpr
View file @
991ebcff
...
...
@@ -14,6 +14,7 @@ project BuildSupport is
"buildsupport.adb"
,
"buildsupport_utils.ads"
,
"buildsupport_utils.adb"
,
"option_type.ads"
,
"buildsupport_version.ads"
);
package
Builder
is
...
...
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