Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
Ocarina
Commits
9a77bee7
Commit
9a77bee7
authored
Jan 20, 2015
by
yoogx
Browse files
* Code clean-up
parent
d34317cd
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/python/ocarina-utils.adb
View file @
9a77bee7
...
...
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2013-201
4
ESA & ISAE. --
-- Copyright (C) 2013-201
5
ESA & ISAE. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
...
...
@@ -31,8 +31,6 @@
-- --
------------------------------------------------------------------------------
pragma
Warnings
(
Off
);
with
Ada
.
Command_Line
;
use
Ada
.
Command_Line
;
with
GNAT
.
Directory_Operations
;
use
GNAT
.
Directory_Operations
;
with
GNAT
.
OS_Lib
;
use
GNAT
.
OS_Lib
;
...
...
@@ -54,33 +52,12 @@ with Ocarina.Parser; use Ocarina.Parser;
with
Ocarina
.
Options
;
use
Ocarina
.
Options
;
with
Ocarina
.
Files
;
use
Ocarina
.
Files
;
with
Ocarina
.
Analyzer
.
AADL
.
Finder
;
use
Ocarina
.
Analyzer
.
AADL
.
Finder
;
with
Ocarina
.
ME_AADL
.
AADL_Tree
.
Entities
;
with
Ocarina
.
ME_AADL
.
AADL_Tree
.
Nutils
;
with
Ocarina
.
ME_AADL
.
AADL_Instances
.
Nodes
;
with
Ocarina
.
ME_AADL
.
AADL_Instances
.
Entities
;
with
Ocarina
.
ME_AADL
.
AADL_Instances
.
Nutils
;
with
Namet
;
with
Ocarina
.
Instances
.
Finder
;
with
Ada
.
Strings
.
Equal_Case_Insensitive
;
with
Ada
.
Text_IO
;
package
body
Ocarina
.
Utils
is
package
ATN
renames
Ocarina
.
ME_AADL
.
AADL_Tree
.
Nodes
;
package
ATE
renames
Ocarina
.
ME_AADL
.
AADL_Tree
.
Entities
;
package
ATNU
renames
Ocarina
.
ME_AADL
.
AADL_Tree
.
Nutils
;
package
AIN
renames
Ocarina
.
ME_AADL
.
AADL_Instances
.
Nodes
;
package
AIE
renames
Ocarina
.
ME_AADL
.
AADL_Instances
.
Entities
;
package
AINU
renames
Ocarina
.
ME_AADL
.
AADL_Instances
.
Nutils
;
AADL_Root
:
Node_Id
:=
No_Node
;
File_Name
:
Name_Id
:=
No_Name
;
Buffer
:
Location
;
Language
:
Name_Id
:=
No_Name
;
Components
:
Node_List
;
-----------
-- Reset --
...
...
tools/mknodes/parser.adb
View file @
9a77bee7
...
...
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2005-2009 Telecom ParisTech, 2010-201
4
ESA & ISAE. --
-- Copyright (C) 2005-2009 Telecom ParisTech, 2010-201
5
ESA & ISAE. --
-- --
-- Ocarina is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
...
...
@@ -45,8 +45,6 @@ use type Types.Byte, Types.Name_Id, Types.Node_Id, Types.Int;
with
Utils
;
with
Ada
.
Directories
;
with
Ada
.
Strings
.
Fixed
;
with
Ada
.
Strings
.
Maps
;
package
body
Parser
is
...
...
@@ -2054,9 +2052,11 @@ package body Parser is
Output
.
Set_Output
(
Output_File
);
end
if
;
W_Package_Body_Python
(
Ada
.
Directories
.
Base_Name
(
Namet
.
Get_Name_String
(
Utils
.
Replace_Char
(
Output_Name
,
'-'
,
'_'
))));
W_Package_Body_Python
(
Ada
.
Directories
.
Base_Name
(
Namet
.
Get_Name_String
(
Utils
.
Replace_Char
(
Output_Name
,
'-'
,
'_'
))));
-- If the output is not the standard output, compute the body
-- filename and redirect output.
...
...
@@ -2076,7 +2076,7 @@ package body Parser is
if
Output_Name
/=
Types
.
No_Name
then
Output_Name
:=
Utils
.
Remove_Suffix_From_Name
(
"-python.idl"
,
Output_Name
);
Output_Name
:=
Utils
.
Replace_Char
(
Output_Name
,
'-'
,
'_'
);
Output_Name
:=
Utils
.
Replace_Char
(
Output_Name
,
'-'
,
'_'
);
Output_Name
:=
Utils
.
Add_Suffix_To_Name
(
".py"
,
Output_Name
);
Output_File
:=
GNAT
.
OS_Lib
.
Create_File
...
...
@@ -2154,7 +2154,8 @@ package body Parser is
Output
.
Write_Str
(
"procedure return_List"
);
Output
.
Write_Eol
;
W_Indentation
(
2
);
Output
.
Write_Str
(
"(Data : in out Callback_Data'Class; List : List_Id) is"
);
Output
.
Write_Str
(
"(Data : in out Callback_Data'Class; List : List_Id) is"
);
Output
.
Write_Eol
;
W_Indentation
(
2
);
Output
.
Write_Str
(
"List_Node : Node_Id;"
);
...
...
@@ -2175,7 +2176,8 @@ package body Parser is
Output
.
Write_Str
(
"while Present (List_Node) loop"
);
Output
.
Write_Eol
;
W_Indentation
(
4
);
Output
.
Write_Str
(
"Set_Return_Value (Data, Integer'Image (Integer (List_Node)));"
);
Output
.
Write_Str
(
"Set_Return_Value (Data, Integer'Image (Integer (List_Node)));"
);
Output
.
Write_Eol
;
W_Indentation
(
4
);
Output
.
Write_Str
(
"List_Node := Next_Node (List_Node);"
);
...
...
@@ -2369,8 +2371,8 @@ package body Parser is
NS
:=
Type_Spec
(
NS
);
end
loop
;
--
o
utput setter
--
O
utput setter
W_Indentation
(
1
);
Output
.
Write_Str
(
"procedure On_"
);
Output
.
Write_Str
(
WS
(
GNS
(
Identifier
(
A
))));
...
...
@@ -2411,7 +2413,7 @@ package body Parser is
Output
.
Write_Str
(
"dummy;"
);
isDummy
:=
True
;
end
if
;
if
isDummy
=
False
then
if
isDummy
=
False
then
Output
.
Write_Eol
;
W_Indentation
(
3
);
if
GNS
(
Identifier
(
Type_Spec
(
A
)))
=
"Node_Id"
then
...
...
@@ -2475,7 +2477,7 @@ package body Parser is
Output
.
Write_Str
(
"begin"
);
Output
.
Write_Eol
;
W_Indentation
(
2
);
if
isDummy
=
False
then
if
isDummy
=
False
then
if
GNS
(
Identifier
(
Type_Spec
(
A
)))
=
"Node_Id"
then
Output
.
Write_Str
(
"Set_Return_Value (Data, Integer ("
);
elsif
GNS
(
Identifier
(
Type_Spec
(
A
)))
=
"List_Id"
then
...
...
@@ -2568,7 +2570,9 @@ package body Parser is
-- W_Attribute_Register_python --
---------------------------------
procedure
W_Attribute_Register_python
(
A
:
Types
.
Node_Id
;
prefix
:
String
)
is
procedure
W_Attribute_Register_python
(
A
:
Types
.
Node_Id
;
prefix
:
String
)
is
begin
W_Indentation
(
2
);
Output
.
Write_Str
(
"Register_Command "
);
...
...
@@ -2622,7 +2626,7 @@ package body Parser is
Namet
.
Write_Name
(
Module_Name
);
Output
.
Write_Str
(
".Python is"
);
Output
.
Write_Eol
;
W_Indentation
(
1
);
Output
.
Write_Str
(
"procedure return_List"
);
Output
.
Write_Eol
;
...
...
@@ -2636,7 +2640,8 @@ package body Parser is
Output
.
Write_Str
(
"procedure return_List"
);
Output
.
Write_Eol
;
W_Indentation
(
2
);
Output
.
Write_Str
(
"(Data : in out Callback_Data'Class; List : List_Id);"
);
Output
.
Write_Str
(
"(Data : in out Callback_Data'Class; List : List_Id);"
);
Output
.
Write_Eol
;
Output
.
Write_Eol
;
...
...
@@ -2666,7 +2671,7 @@ package body Parser is
Output
.
Write_Str
(
"#! /usr/bin/python"
);
Output
.
Write_Eol
;
Output
.
Write_Eol
;
Output
.
Write_Str
(
"import libocarina_python; # Ocarina bindings"
);
Output
.
Write_Eol
;
Output
.
Write_Eol
;
...
...
@@ -2718,8 +2723,8 @@ package body Parser is
Output
.
Write_Eol
;
W_Indentation
(
1
);
Output
.
Write_Str
(
"return libocarina_python."
);
Output
.
Write_Str
(
Ada
.
Directories
.
Base_Name
(
Namet
.
g
et_Name_String
(
Output_Name
)));
Output
.
Write_Str
(
Ada
.
Directories
.
Base_Name
(
Namet
.
G
et_Name_String
(
Output_Name
)));
Output
.
Write_Str
(
"_"
);
Output
.
Write_Str
(
A
);
Output
.
Write_Str
(
" (N);"
);
...
...
@@ -2735,8 +2740,8 @@ package body Parser is
Output
.
Write_Eol
;
W_Indentation
(
1
);
Output
.
Write_Str
(
"libocarina_python."
);
Output
.
Write_Str
(
Ada
.
Directories
.
Base_Name
(
Namet
.
g
et_Name_String
(
Output_Name
)));
Output
.
Write_Str
(
Ada
.
Directories
.
Base_Name
(
Namet
.
G
et_Name_String
(
Output_Name
)));
Output
.
Write_Str
(
"_"
);
Output
.
Write_Str
(
WS
(
A
));
Output
.
Write_Str
(
" (N, V);"
);
...
...
@@ -2767,7 +2772,7 @@ package body Parser is
W_Indentation
(
1
);
Output
.
Write_Str
(
"return libocarina_python."
);
Output
.
Write_Str
(
Ada
.
Directories
.
Base_Name
(
Namet
.
g
et_Name_String
(
Output_Name
))
&
"_python"
);
Namet
.
G
et_Name_String
(
Output_Name
))
&
"_python"
);
Output
.
Write_Str
(
"_"
);
Output
.
Write_Str
(
GNS
(
Identifier
(
A
)));
Output
.
Write_Str
(
" (N);"
);
...
...
@@ -2783,8 +2788,8 @@ package body Parser is
Output
.
Write_Eol
;
W_Indentation
(
1
);
Output
.
Write_Str
(
"libocarina_python."
);
Output
.
Write_Str
(
Ada
.
Directories
.
Base_Name
(
Namet
.
g
et_Name_String
(
Output_Name
))
&
"_python"
);
Output
.
Write_Str
(
Ada
.
Directories
.
Base_Name
(
Namet
.
G
et_Name_String
(
Output_Name
))
&
"_python"
);
Output
.
Write_Str
(
"_"
);
Output
.
Write_Str
(
WS
(
GNS
(
Identifier
(
A
))));
Output
.
Write_Str
(
" (N, V);"
);
...
...
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