---------------------------------------- ---------------------------------------- -- -- -- OCARINA COMPONENTS -- -- -- -- O C A R I N A . D I A . P A R S E R . C O R E -- -- -- -- S p e c -- -- -- -- Copyright (C) 2005-2006, GET-Telecom Paris. -- -- -- -- 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 Ocarina team -- -- (ocarina-users@listes.enst.fr) -- -- -- ------------------------------------------------------------------------------ -- This package implements the raw parsing of Dia files into a list -- of generic nodes containing all the information that is sound to -- Ocarina for generating the corresponding AADL tree. with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Unchecked_Deallocation; with DOM.Core; package Ocarina.Dia.Parser.Core is ----------------------------------------------------------- type connection_point is record Object_ID : Unbounded_String; Port : Natural; end record; type connection is tagged record Start_Point : connection_point; End_Point : connection_point; end record; -- These two types are used to represent connections type port_type is (access_provider, -- 9 access_requirer, -- 10 in_data_port, -- 11 in_event_port, -- 12 in_event_data_port, -- 13 out_data_port, -- 14 out_event_port, -- 15 out_event_data_port, -- 16 in_out_data_port, -- 17 in_out_event_port, -- 18 in_out_event_data_port, -- 19 port_group, -- 20 point); -- The different possible ports subtype real_port is port_type range access_provider .. port_group; -- A convenient subtype for actual ports ----------------------------------------------------------- type port_record (Port_Type_Arg : port_type) is record case Port_Type_Arg is when real_port => Declaration : Unbounded_String; when point => Position : Unbounded_String; end case; end record; type port is access all port_record; type port_list_record; type port_list is access port_list_record; type port_list_record is record Hd : port; Tl : port_list; end record; -- A simple ordered list of ports ------------------------------------------------------------ ----------- -- Nodes -- ----------- -- This is the base type for all Ocarina.Dia.Parser types. It is -- declared in this package for visibility reason. type node_type is (process, thread, data, processor, memory, bus, system, subprogram, thread_group, device, link, void); -- All different types of nodes subtype aadlobject_type is node_type range process .. device; -- A convenient subtype for "real" objects ----------------------------------------------------------- type node_record (Node_Type_Arg : node_type) is record ID : Unbounded_String; Version : Integer; case Node_Type_Arg is when aadlobject_type => Name : Unbounded_String; Declaration : Unbounded_String; Ports : port_list; Parent : Unbounded_String := To_Unbounded_String (""); -- if this node is not a child node when link => Conn : connection; Style : Natural; -- 0 for plain, > 0 for any dashed style Start_Head_Style : Natural; End_Head_Style : Natural; when void => null; end case; end record; -- The actual definition of the node tagged type type node is access node_record; ------------------------------------------------------------ type node_array is array (Integer range <>) of node; type node_array_access is access node_array; type node_list is record Items : node_array_access := null; Last : Integer := -1; end record; Null_List : constant node_list := (null, -1); procedure Free is new Unchecked_Deallocation (node_array, node_array_access); procedure Append (List : in out node_list; N : node); -- Insert N as the last element in List procedure Remove (List : in out node_list; N : node); -- Remove N from the list -- N must be an element of List, this is not checked. -- Implementation of lists of nodes function Count_Objects (NL : node_list) return Integer; -- Returns the number of objects in a list Missing_Attribute : exception; -- Exception raised when a required attribute is not found function Get_Required_Attribute (Attrs : DOM.Core.named_node_map; N : String) return String; -- Looks for a specific attribute and returns its value, or raises -- Missing_Attribute Missing_Child : exception; -- Raised when a required child element is not found procedure Get_Required_Child (Children : DOM.Core.node_list; S : String; Index : in out Natural; E : out DOM.Core.node); -- Looks for a specific child node and returns the first element -- with that name -- Generic Purpose functions, for retrieving a specific child or -- attribute in a Dia XML element end Ocarina.Dia.Parser.Core;