From 19971e5eceb8fd744e798aca161da999abf7f37c Mon Sep 17 00:00:00 2001 From: Maxime Perrotin Date: Wed, 28 Aug 2019 10:31:28 +0200 Subject: [PATCH] Get the list of ACN files in DataView.aadl --- src/taste-data_view.adb | 25 +++++++++++++++-- src/taste-data_view.ads | 5 ++-- test/Demo_ACN/DataView.aadl | 54 +++++++++++++++++++++++++++++++++++++ test/Demo_ACN/OtherDV.acn | 3 +++ test/Demo_ACN/OtherDV.asn | 4 +++ 5 files changed, 87 insertions(+), 4 deletions(-) create mode 100644 test/Demo_ACN/OtherDV.acn create mode 100644 test/Demo_ACN/OtherDV.asn diff --git a/src/taste-data_view.adb b/src/taste-data_view.adb index 957758d..89a4727 100644 --- a/src/taste-data_view.adb +++ b/src/taste-data_view.adb @@ -40,6 +40,7 @@ package body TASTE.Data_View is use ASN1_File_Maps; System : Node_Id; Files : ASN1_File_Maps.Map; + ACN_Files : String_Sets.Set; Current_Type : Node_Id; F : Name_Id; Loc : Location; @@ -94,10 +95,26 @@ package body TASTE.Data_View is Module : constant String := Get_Name_String (Get_String_Property (Asntype, Get_String_Name ("taste::ada_package_name"))); + ACN_Ref : constant Node_Id := Get_Classifier_Property + (Asntype, "taste::encodingdefinitionfile"); Filename : constant String := Get_Name_String (Get_Source_Text (Asntype) (1)); File_Ref : constant ASN1_File_Maps.Cursor := Files.Find (Filename); begin + -- If there are ACN files, add them to the list + if ACN_Ref /= No_Node then + declare + ACN : constant Name_Array := Get_Source_Text (ACN_Ref); + use String_Sets; + begin + for F of ACN loop + ACN_Files.Union + (To_Set (Get_Name_String (F))); + end loop; + end; + + end if; + if File_Ref = ASN1_File_Maps.No_Element then declare New_File : ASN1_File; @@ -111,7 +128,7 @@ package body TASTE.Data_View is end if; New_File.Path := Relative_Path; New_File.Modules.Insert (Module, New_Module); - Files.Insert (Filename, New_File); + Files.Insert (Filename, New_File); end; else declare @@ -133,7 +150,8 @@ package body TASTE.Data_View is end; Current_Type := AIN.Next_Node (Current_Type); end loop; - return Data_AST : constant Taste_Data_View := (ASN1_Files => Files); + return Data_AST : constant Taste_Data_View := (ASN1_Files => Files, + ACN_Files => ACN_Files); end Parse_Data_View; -- Function checking the actual file presence of the ASN.1 models that @@ -168,6 +186,9 @@ package body TASTE.Data_View is end loop; end loop; end loop; + for Each of DV.ACN_Files loop + Put_Line (Output, "ACN File : " & Each); + end loop; end Debug_Dump; procedure Export_ASN1_Files (DV : Taste_Data_View; Output_Path : String) is diff --git a/src/taste-data_view.ads b/src/taste-data_view.ads index 7521323..8c26930 100644 --- a/src/taste-data_view.ads +++ b/src/taste-data_view.ads @@ -48,14 +48,15 @@ package TASTE.Data_View is type ASN1_File is record - Path : Unbounded_String; - Modules : ASN1_Module_Maps.Map; + Path : Unbounded_String; + Modules : ASN1_Module_Maps.Map; end record; package ASN1_File_Maps is new Indefinite_Ordered_Maps (String, ASN1_File); type Taste_Data_View is tagged record ASN1_Files : ASN1_File_Maps.Map; + ACN_Files : String_Sets.Set; end record; function Parse_Data_View (Dataview_Root : Node_Id) return Taste_Data_View diff --git a/test/Demo_ACN/DataView.aadl b/test/Demo_ACN/DataView.aadl index c6f5a2d..f7dd208 100644 --- a/test/Demo_ACN/DataView.aadl +++ b/test/Demo_ACN/DataView.aadl @@ -2,6 +2,7 @@ --! File generated by asn2aadl v2.1.39: DO NOT EDIT ! -------------------------------------------------------- --! InputASN1FileChecksum:ea2bc8085f96189ce53191fc48545a34:/home/taste/tool-src/kazoo/test/Demo_ACN/DataView.asn: +--! InputASN1FileChecksum:93fd79217d8801a03cc8aa8ad4a5170a:/home/taste/tool-src/kazoo/test/Demo_ACN/OtherDV.asn: --! InputASN1FileChecksum:ee8a7e01f29874c0d50f437d5abb9599:/home/taste/tool-inst/share/taste-types/taste-types.asn: -------------------------------------------------------- @@ -40,6 +41,52 @@ data Stream_Element_Buffer properties Data_Model::Data_Representation => Character; end Stream_Element_Buffer; +DATA FooBar +PROPERTIES + -- name of the ASN.1 source file: + Source_Text => ("/home/taste/tool-src/kazoo/test/Demo_ACN/OtherDV.asn"); + TASTE::EncodingDefinitionFile => classifier(DataView::ACN_OtherDV); + TASTE::Ada_Package_Name => "Other"; + Deployment::ASN1_Module_Name => "Other"; + Source_Language => (ASN1); + -- Size of a buffer to cover all forms of message representation: + -- Real message size is 1; suggested aligned message buffer is... + Source_Data_Size => 8 Bytes; + -- name of the corresponding data type in the source file: + Type_Source_Name => "FooBar"; + TASTE::Position_In_File => [ line => 3 ; column => 1 ; ]; + -- what kind of type is this? + TASTE::ASN1_Basic_Type =>aBOOLEAN; +END FooBar; + +DATA IMPLEMENTATION FooBar.impl +END FooBar.impl; + +DATA FooBar_Buffer_Max +END FooBar_Buffer_Max; + +DATA IMPLEMENTATION FooBar_Buffer_Max.impl + -- Buffer to hold a marshalled data of type FooBar +PROPERTIES + Data_Model::Data_Representation => array; + Data_Model::Dimension => (8); -- Size of the buffer + Source_Data_Size => 8 Bytes; -- Size of the buffer in bytes + Data_Model::Base_Type => (classifier (DataView::Stream_Element_Buffer)); +END FooBar_Buffer_Max.impl; + +DATA FooBar_Buffer +END FooBar_Buffer; + +DATA IMPLEMENTATION FooBar_Buffer.impl + -- Buffer to hold a marshalled data of type FooBar +SUBCOMPONENTS + Buffer : data FooBar_Buffer_Max.impl; + Length : data Base_Types::Unsigned_32; +PROPERTIES + Data_Model::Data_Representation => Struct; + Source_Data_Size => 24 Bytes; -- Size of the buffer in bytes +END FooBar_Buffer.impl; + DATA T_Boolean PROPERTIES -- name of the ASN.1 source file: @@ -316,6 +363,7 @@ END Taste_DataView; SYSTEM IMPLEMENTATION Taste_DataView.others SUBCOMPONENTS + FooBar : DATA FooBar.impl; T_Boolean : DATA T_Boolean.impl; T_Int32 : DATA T_Int32.impl; T_Int8 : DATA T_Int8.impl; @@ -329,4 +377,10 @@ PROPERTIES Source_Language => (ACN); END ACN_DataView; +DATA ACN_OtherDV +PROPERTIES + Source_Text => ("/home/taste/tool-src/kazoo/test/Demo_ACN/OtherDV.acn"); + Source_Language => (ACN); +END ACN_OtherDV; + end DataView; diff --git a/test/Demo_ACN/OtherDV.acn b/test/Demo_ACN/OtherDV.acn new file mode 100644 index 0000000..9e2e88d --- /dev/null +++ b/test/Demo_ACN/OtherDV.acn @@ -0,0 +1,3 @@ +Other DEFINITIONS ::= BEGIN + FooBar[size 4, true-value '0101'B] +END diff --git a/test/Demo_ACN/OtherDV.asn b/test/Demo_ACN/OtherDV.asn new file mode 100644 index 0000000..b8ae76f --- /dev/null +++ b/test/Demo_ACN/OtherDV.asn @@ -0,0 +1,4 @@ +Other DEFINITIONS ::= +BEGIN + FooBar ::= BOOLEAN +END -- GitLab