Commit d34317cd authored by yoogx's avatar yoogx

Merge branch 'master' of https://github.com/Ellidiss/ocarina into Ellidiss-master

parents 0e89cc28 29994629
......@@ -12,6 +12,8 @@ to load, parse, instantiate AADL models, and to invoke backends.
################################################################################
import libocarina_python; # Ocarina bindings
import ocarina_me_aadl_aadl_instances_nodes as AIN;
import ocarina_me_aadl_aadl_tree_nodes as ATN;
class Enum(tuple): __getattr__ = tuple.index
......@@ -81,3 +83,229 @@ def generate (generator):
################################################################################
def getPackages ():
'''Return the list of all the packages defined in the current AADL project
'''
return libocarina_python.getPackages();
################################################################################
def getImportDeclarations ():
'''Return the list of all the import declaration used in the current AADL project
'''
return libocarina_python.getImportDeclarations();
################################################################################
def getAliasDeclarations ():
'''Return the list of all the alias declaration defined in the current AADL project
'''
return libocarina_python.getAliasDeclarations ();
################################################################################
def getComponentTypes (category):
'''Return a list of component types defined in the current AADL project
:param category: one of the AADL category defined in the standard
For instance, to retrieve all the system types from the current project,
you may use the following
>>> getComponentTypes (System);
'''
return libocarina_python.getComponentTypes (category);
################################################################################
def getComponentImplementations (category):
'''Return a list of component implementations defined in the current AADL project
:param category: one of the AADL category defined in the standard
For instance, to retrieve all the system implementations from the current project,
you may use the following
>>> getComponentImplementations (System);
'''
return libocarina_python.getComponentImplementations (category);
################################################################################
def getAnnexes ():
'''Return the list of all the annexes defined in the current AADL project
'''
return libocarina_python.getAnnexes ();
################################################################################
def getPrototypes ():
'''Return the list of all the prototypes defined in the current AADL project
'''
return libocarina_python.getPrototypes ();
################################################################################
def getPrototypeBindings ():
'''Return the list of all the prototype bindings defined in the current AADL project
'''
return libocarina_python.getPrototypeBindings ();
################################################################################
def getFlowSpecifications ():
'''Return the list of all the flow specification defined in the current AADL project
'''
return libocarina_python.getFlowSpecifications ();
################################################################################
def getFlowImplementations ():
'''Return the list of all the flow implementation defined in the current AADL project
'''
return libocarina_python.getFlowImplementations ();
################################################################################
def getModes ():
'''Return the list of all the modes defined in the current AADL project
'''
return libocarina_python.getModes ();
################################################################################
def getModeTransitions ():
'''Return the list of all the mode transition defined in the current AADL project
'''
return libocarina_python.getModeTransitions ();
################################################################################
def getInModes ():
'''Return the list of all the in mode used in the current AADL project
'''
return libocarina_python.getInModes ();
################################################################################
def getPropertySets ():
'''Return the list of all the property set defined in the current AADL project
'''
return libocarina_python.getPropertySets ();
################################################################################
def getPropertyTypes (propertySetId):
'''Return the list of all the property types defined in the provided property set
:param propertySetId: the nodeId of the property set in the current AADL project
to serach in
For instance, to retrieve all the property types from property set propertySet,
retrieve its id (propertySetId) and use the following
>>> getPropertyTypes (propertySetId);
'''
return libocarina_python.getPropertyTypes (propertySetId);
################################################################################
def getPropertyDefinitions (propertySetId):
'''Return the list of all the property declaration defined in the provided property set
:param propertySetId: the nodeId of the property set in the current AADL project
to serach in
For instance, to retrieve all the property declaration from property set propertySet,
retrieve its id (propertySetId) and use the following
>>> getPropertyDefinitions (propertySetId);
'''
return libocarina_python.getPropertyDefinitions (propertySetId);
################################################################################
def getPropertyConstants (propertySetId):
'''Return the list of all the constant property defined in the provided property set
:param propertySetId: the nodeId of the property set in the current AADL project
to serach in
For instance, to retrieve all the constant property from property set propertySet,
retrieve its id (propertySetId) and use the following
>>> getPropertyConstants (propertySetId);
'''
return libocarina_python.getPropertyConstants (propertySetId);
################################################################################
def getInstances (category):
'''Return a list of instances defined in the current AADL project
:param category: one of the AADL category defined in the standard
For instance, to retrieve all the system instances from the current project,
you may use the following
>>> getInstances (System);
'''
return libocarina_python.getInstances (category);
################################################################################
def getComponentName (nodeId):
'''Get the name of an AADL component
:param nodeId: the id of the component whose name is searched
For instance, to retrieve the name of MyComponent,
retrieve its id (nodeId) and use the following
>>> getComponentName (nodeId);
'''
return libocarina_python.getComponentName (nodeId);
################################################################################
def getComponentFullname (nodeId):
'''Get the full qualified name of an AADL component
:param nodeId: the id of the component whose
full qualified name is searched
For instance, to retrieve the full qualified name of MyComponent,
retrieve its id (nodeId) and use the following
>>> getComponentFullname (nodeId);
'''
return libocarina_python.getComponentFullname (nodeId);
################################################################################
def getInstanceName (nodeId):
'''Get the name of an AADL instance
:param nodeId: the id of the instance whose name is searched
For instance, to retrieve the name of MyInstance,
retrieve its id (nodeId) and use the following
>>> getInstanceName (nodeId);
'''
return libocarina_python.getInstanceName (nodeId);
################################################################################
def getNodeId (name):
'''Get the Id of a component from its name
:param name: the AADL name of the node whose id is queried
For instance, to retrieve the id of MyHome, you may use the following
>>> getNodeId (MyHome);
'''
return libocarina_python.getNodeId (name);
This diff is collapsed.
------------------------------------------------------------------------------
-- --
-- OCARINA COMPONENTS --
-- --
-- O C A R I N A . L M P --
-- --
-- S p e c --
-- --
-- Copyright (C) 2013 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 --
-- Free Software Foundation; either version 2, or (at your option) any --
-- later version. Ocarina is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General --
-- Public License for more details. You should have received a copy of the --
-- GNU General Public License distributed with Ocarina; see file COPYING. --
-- If not, write to the Free Software Foundation, 51 Franklin Street, Fifth --
-- Floor, Boston, MA 02111-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- Ocarina is maintained by the TASTE project --
-- (taste-users@lists.tuxfamily.org) --
-- --
------------------------------------------------------------------------------
pragma Warnings (Off);
with Ocarina.Types; use Ocarina.Types;
with GNATCOLL.Scripts; use GNATCOLL.Scripts;
with Ocarina.ME_AADL;
with Ocarina.ME_AADL.AADL_Tree.Nodes;
package Ocarina.Lmp is
function Get_Packages return Node_List;
function Get_Import_Declarations return Node_List;
function Get_Alias_Declarations return Node_List;
function Get_Component_Types (kind : String) return Node_List;
function Get_Component_Implementations (kind : String) return Node_List;
function Get_Annexes return Node_List;
function Get_Prototype return Node_List;
function Get_Prototype_Binding return Node_List;
function Get_Flow_Specs return Node_List;
function Get_Flow_Implementations return Node_List;
function Get_Modes return Node_List;
function Get_Mode_Transitions return Node_List;
function Get_In_Modes return Node_List;
-- function Get_PropertyBinding return Node_List;
function Get_Property_Sets return Node_List;
function Get_Property_Types (PropertySet : Node_Id) return Node_List;
function Get_Property_Definitions (PropertySet : Node_Id) return Node_List;
function Get_Property_Constants (PropertySet : Node_Id) return Node_List;
function Get_Instances (kind : String) return Node_List;
function Filter_Component_By_Category (components : Node_List;
category : Ocarina.ME_AADL.Component_Category) return Node_List;
function Filter_Node_By_Kind (components : List_Id;
category : Ocarina.ME_AADL.AADL_Tree.Nodes.Node_Kind) return Node_List;
function Filter_Instance_By_Category (components : Node_List;
category : Ocarina.ME_AADL.Component_Category) return Node_List;
procedure Get_Component_Name (Data : in out Callback_Data'Class;
N : Node_Id);
procedure Get_Component_Fullname (Data : in out Callback_Data'Class;
N : Node_Id);
procedure Get_Instance_Name (Data : in out Callback_Data'Class;
N : Node_Id);
function Find_All_Component_Implementations
(Root : Node_Id;
Namespace : Node_Id := No_Node) return Node_List;
function Find_All_Component_Instances
(Root : Node_Id) return Node_List;
end Ocarina.Lmp;
This diff is collapsed.
......@@ -31,6 +31,8 @@
-- --
------------------------------------------------------------------------------
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;
......@@ -39,7 +41,6 @@ with Errors; use Errors;
with Locations; use Locations;
with Ocarina.Namet; use Ocarina.Namet;
with Ocarina.Output; use Ocarina.Output;
with Ocarina.Types; use Ocarina.Types;
with Utils; use Utils;
with Ocarina.Analyzer; use Ocarina.Analyzer;
......@@ -53,12 +54,33 @@ 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 --
......@@ -247,4 +269,93 @@ package body Ocarina.Utils is
Generate_Code (AADL_Root);
end Generate;
-------------------
-- Get_AADL_Root --
-------------------
function Get_AADL_Root return Node_Id is
begin
return AADL_Root;
end Get_AADL_Root;
-----------------
-- Get_Node_Id --
-----------------
procedure Get_Node_Id (Data : in out Callback_Data'Class;
N : String) is
begin
Set_Return_Value (Data, Integer'Image (Integer
(Namet.Get_String_Name (N))));
end Get_Node_Id;
-----------------------------
-- Get_Node_Id_From_String --
-----------------------------
function Get_Node_Id_From_String (Name : String) return Node_Id is
begin
return Node_Id (Integer'Value (Name));
end Get_Node_Id_From_String;
-----------------------------
-- Get_List_Id_From_String --
-----------------------------
function Get_List_Id_From_String (Name : String) return List_Id is
begin
return List_Id (Integer'Value (Name));
end Get_List_Id_From_String;
-----------------------------
-- Get_Boolean_From_String --
-----------------------------
function Get_Boolean_From_String (Name : String) return Boolean is
begin
return Boolean'Value (Name);
end Get_Boolean_From_String;
--------------------------
-- Get_Byte_From_String --
--------------------------
function Get_Byte_From_String (Name : String) return Byte is
begin
return Byte (Integer'Value (Name));
end Get_Byte_From_String;
-------------------------
-- Get_Int_From_String --
-------------------------
function Get_Int_From_String (Name : String) return Int is
begin
return Int (Integer'Value (Name));
end Get_Int_From_String;
------------------------------
-- Get_Value_Id_From_String --
------------------------------
function Get_Value_Id_From_String (Name : String) return Value_Id is
begin
return Value_Id (Integer'Value (Name));
end Get_Value_Id_From_String;
-----------------------------
-- Get_Name_Id_From_String --
-----------------------------
function Get_Name_Id_From_String (Name : String) return Name_Id is
val : Integer;
begin
val := Integer'Value (Name);
if val > 300_000_000 and then val < 399_999_999 then
return Name_Id (val);
else
return No_Name;
end if;
end Get_Name_Id_From_String;
end Ocarina.Utils;
......@@ -31,6 +31,12 @@
-- --
------------------------------------------------------------------------------
pragma Warnings (Off);
with Ocarina.Types; use Ocarina.Types;
with GNATCOLL.Scripts; use GNATCOLL.Scripts;
with Ocarina.ME_AADL;
with Ocarina.ME_AADL.AADL_Tree.Nodes;
package Ocarina.Utils is
procedure Version;
......@@ -48,4 +54,14 @@ package Ocarina.Utils is
procedure Generate (Backend_Name : String);
procedure Reset;
function Get_AADL_Root return Node_Id;
function Get_Node_Id_From_String (Name : String) return Node_Id;
function Get_Name_Id_From_String (Name : String) return Name_Id;
function Get_Boolean_From_String (Name : String) return Boolean;
function Get_Byte_From_String (Name : String) return Byte;
function Get_List_Id_From_String (Name : String) return List_Id;
function Get_Int_From_String (Name : String) return Int;
function Get_Value_Id_From_String (Name : String) return Value_Id;
procedure Get_Node_Id (Data : in out Callback_Data'Class; N : String);
end Ocarina.Utils;
This diff is collapsed.
......@@ -250,6 +250,16 @@ private
procedure W_Type_Attribute (A : String; T : String);
procedure W_With (P : String);
procedure W_Package_Body_Python (prefix : String);
procedure W_Attribute_Body_python (A : String);
procedure W_Attribute_Body_python (A : Types.Node_Id);
procedure W_Attribute_Register_python (A : String; prefix : String);
procedure W_Attribute_Register_python (A : Types.Node_Id; prefix : String);
procedure W_Package_Spec_Python;
procedure W_Python_Script;
procedure W_Attribute_Python_Script (A : String);
procedure W_Attribute_Python_Script (A : Types.Node_Id);
------------------------
-- General facilities --
------------------------
......
Markdown is supported
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