Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/OpenAADL/ocarina
Browse files Browse the repository at this point in the history
  • Loading branch information
jjhugues committed Sep 5, 2021
2 parents 44990f6 + cbaf9eb commit eecc533
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 49 deletions.
7 changes: 7 additions & 0 deletions resources/runtime/aadl_xml/aadl.xsd
Expand Up @@ -81,6 +81,7 @@

<xs:element name='classifier'>
<xs:complexType mixed='true'>
<xs:attribute name='namespace' type="xs:string" use='required'/>
</xs:complexType>
</xs:element>

Expand Down Expand Up @@ -223,6 +224,7 @@
<xs:element name="number" type="unit_prop"/>
<xs:element name="range" type="range_prop"/>
<xs:element name="string" type="string_prop"/>
<xs:element name="boolean" type="boolean_prop"/>
<xs:element ref="record"/>
<xs:element ref="list"/>
</xs:choice>
Expand All @@ -237,6 +239,7 @@
<xs:element name="number" type="unit_prop"/>
<xs:element name="range" type="range_prop"/>
<xs:element name="string" type="string_prop"/>
<xs:element name="boolean" type="boolean_prop"/>
<xs:element ref="record"/>
<xs:element ref="list"/>
</xs:choice>
Expand Down Expand Up @@ -278,6 +281,10 @@
<xs:attribute name='value' type="xs:string" use='required'/>
</xs:complexType>

<xs:complexType name='boolean_prop'>
<xs:attribute name='value' type="xs:boolean" use='required'/>
</xs:complexType>

<xs:complexType name='reference_prop'>
<xs:attribute name='value' type="xs:string" use='required'/>
</xs:complexType>
Expand Down
56 changes: 45 additions & 11 deletions src/backends/aadl_xml/ocarina-backends-aadl_xml-main.adb
Expand Up @@ -134,6 +134,15 @@ package body Ocarina.Backends.AADL_XML.Main is
Append_Node_To_List
(Make_Defining_Identifier (Display_Name (Identifier (E))),
XTN.Subitems (Classifier_Node));

-- Add namespace attribute to the classifier node
Append_Node_To_List
(Make_Assignement
(Make_Defining_Identifier (Get_String_Name ("namespace")),
Make_Defining_Identifier
(Display_Name (Identifier (Namespace (E))))),
XTN.Items (Classifier_Node));

Append_Node_To_List (Classifier_Node, XTN.Subitems (N));

return N;
Expand Down Expand Up @@ -645,18 +654,43 @@ package body Ocarina.Backends.AADL_XML.Main is
then
-- This property value denotes a reference term

Value_Node := Make_XML_Node ("reference");
declare
Full_Reference_Name : Name_Id;
Is_First_Node : Boolean := TRUE;
begin
Value_Node := Make_XML_Node ("reference");

Append_Node_To_List
(Make_Assignement
(Make_Defining_Identifier (Get_String_Name ("value")),
Make_Defining_Identifier
(ATN.Display_Name
(ATN.First_Node -- XXX must iterate
(ATN.List_Items
(ATN.Reference_Term
(AADL_Property_Value)))))),
XTN.Items (Value_Node));
List_Node :=
ATN.First_Node
(ATN.List_Items
(ATN.Reference_Term
(AADL_Property_Value)));

while Present (List_Node) loop
if Is_First_Node then
Full_Reference_Name := ATN.Display_Name (List_Node);
Is_First_Node := FALSE;

else
Full_Reference_Name :=
Add_Suffix_To_Name
(".", Full_Reference_Name);

Full_Reference_Name :=
Add_Suffix_To_Name
(Get_Name_String (ATN.Display_Name (List_Node)),
Full_Reference_Name);
end if;

List_Node := ATN.Next_Node (List_Node);
end loop;

Append_Node_To_List
(Make_Assignement
(Make_Defining_Identifier (Get_String_Name ("value")),
Make_Defining_Identifier (Full_Reference_Name)),
XTN.Items (Value_Node));
end;

elsif Present (AADL_Property_Value)
and then ATN.Kind (AADL_Property_Value) =
Expand Down
2 changes: 1 addition & 1 deletion tests/github/issue_287/test_aadl_xml.aadl.out
@@ -1,7 +1,7 @@
<aadl_xml root_system="main.impl">
<components>
<component category="system" identifier="main.impl">
<classifier>
<classifier namespace="Test_Aadl_Xml_Output">
main.impl </classifier>
<features/>
<subcomponents/>
Expand Down
44 changes: 22 additions & 22 deletions tests/github/issue_287/test_aadl_xml_connections.aadl.out
@@ -1,27 +1,27 @@
<aadl_xml root_system="main.impl">
<components>
<component category="system" identifier="main.impl">
<classifier>
<classifier namespace="Test_Aadl_Xml_Connections">
main.impl </classifier>
<features/>
<subcomponents>
<component category="bus" identifier="b1">
<classifier>
<classifier namespace="Test_Aadl_Xml_Connections">
dummy_bus.impl </classifier>
<features/>
<subcomponents/>
<properties/>
</component>
<component category="process" identifier="p1">
<classifier>
<classifier namespace="Test_Aadl_Xml_Connections">
dummy_process.impl </classifier>
<features>
<feature identifier="in_port">
<direction kind="in"/>
<type kind="data"/>
<corresponding_instance>
<component category="data" identifier="dummy_data">
<classifier>
<classifier namespace="Test_Aadl_Xml_Connections">
dummy_data </classifier>
<features/>
<subcomponents/>
Expand All @@ -34,7 +34,7 @@
<type kind="data"/>
<corresponding_instance>
<component category="data" identifier="dummy_data">
<classifier>
<classifier namespace="Test_Aadl_Xml_Connections">
dummy_data </classifier>
<features/>
<subcomponents/>
Expand All @@ -45,15 +45,15 @@
</features>
<subcomponents>
<component category="thread" identifier="t1">
<classifier>
<classifier namespace="Test_Aadl_Xml_Connections">
dummy_thread.impl </classifier>
<features>
<feature identifier="in_port">
<direction kind="in"/>
<type kind="data"/>
<corresponding_instance>
<component category="data" identifier="dummy_data">
<classifier>
<classifier namespace="Test_Aadl_Xml_Connections">
dummy_data </classifier>
<features/>
<subcomponents/>
Expand All @@ -66,7 +66,7 @@
<type kind="data"/>
<corresponding_instance>
<component category="data" identifier="dummy_data">
<classifier>
<classifier namespace="Test_Aadl_Xml_Connections">
dummy_data </classifier>
<features/>
<subcomponents/>
Expand All @@ -79,15 +79,15 @@
<properties/>
</component>
<component category="thread" identifier="t2">
<classifier>
<classifier namespace="Test_Aadl_Xml_Connections">
dummy_thread.impl </classifier>
<features>
<feature identifier="in_port">
<direction kind="in"/>
<type kind="data"/>
<corresponding_instance>
<component category="data" identifier="dummy_data">
<classifier>
<classifier namespace="Test_Aadl_Xml_Connections">
dummy_data </classifier>
<features/>
<subcomponents/>
Expand All @@ -100,7 +100,7 @@
<type kind="data"/>
<corresponding_instance>
<component category="data" identifier="dummy_data">
<classifier>
<classifier namespace="Test_Aadl_Xml_Connections">
dummy_data </classifier>
<features/>
<subcomponents/>
Expand Down Expand Up @@ -139,15 +139,15 @@
</connections>
</component>
<component category="process" identifier="p2">
<classifier>
<classifier namespace="Test_Aadl_Xml_Connections">
dummy_process.impl </classifier>
<features>
<feature identifier="in_port">
<direction kind="in"/>
<type kind="data"/>
<corresponding_instance>
<component category="data" identifier="dummy_data">
<classifier>
<classifier namespace="Test_Aadl_Xml_Connections">
dummy_data </classifier>
<features/>
<subcomponents/>
Expand All @@ -160,7 +160,7 @@
<type kind="data"/>
<corresponding_instance>
<component category="data" identifier="dummy_data">
<classifier>
<classifier namespace="Test_Aadl_Xml_Connections">
dummy_data </classifier>
<features/>
<subcomponents/>
Expand All @@ -171,15 +171,15 @@
</features>
<subcomponents>
<component category="thread" identifier="t1">
<classifier>
<classifier namespace="Test_Aadl_Xml_Connections">
dummy_thread.impl </classifier>
<features>
<feature identifier="in_port">
<direction kind="in"/>
<type kind="data"/>
<corresponding_instance>
<component category="data" identifier="dummy_data">
<classifier>
<classifier namespace="Test_Aadl_Xml_Connections">
dummy_data </classifier>
<features/>
<subcomponents/>
Expand All @@ -192,7 +192,7 @@
<type kind="data"/>
<corresponding_instance>
<component category="data" identifier="dummy_data">
<classifier>
<classifier namespace="Test_Aadl_Xml_Connections">
dummy_data </classifier>
<features/>
<subcomponents/>
Expand All @@ -205,15 +205,15 @@
<properties/>
</component>
<component category="thread" identifier="t2">
<classifier>
<classifier namespace="Test_Aadl_Xml_Connections">
dummy_thread.impl </classifier>
<features>
<feature identifier="in_port">
<direction kind="in"/>
<type kind="data"/>
<corresponding_instance>
<component category="data" identifier="dummy_data">
<classifier>
<classifier namespace="Test_Aadl_Xml_Connections">
dummy_data </classifier>
<features/>
<subcomponents/>
Expand All @@ -226,7 +226,7 @@
<type kind="data"/>
<corresponding_instance>
<component category="data" identifier="dummy_data">
<classifier>
<classifier namespace="Test_Aadl_Xml_Connections">
dummy_data </classifier>
<features/>
<subcomponents/>
Expand Down Expand Up @@ -265,15 +265,15 @@
</connections>
</component>
<component category="device" identifier="d1">
<classifier>
<classifier namespace="Test_Aadl_Xml_Connections">
dummy_device.impl </classifier>
<features>
<feature identifier="b1">
<direction kind="none"/>
<type kind="access"/>
<corresponding_instance>
<component category="bus" identifier="dummy_bus">
<classifier>
<classifier namespace="Test_Aadl_Xml_Connections">
dummy_bus </classifier>
<features/>
<subcomponents/>
Expand Down
2 changes: 1 addition & 1 deletion tests/github/issue_287/test_lists.aadl.out
@@ -1,7 +1,7 @@
<aadl_xml root_system="main.impl">
<components>
<component category="system" identifier="main.impl">
<classifier>
<classifier namespace="Test_List_of_List">
main.impl </classifier>
<features/>
<subcomponents/>
Expand Down
22 changes: 15 additions & 7 deletions tests/github/issue_287/test_property_terms.aadl
Expand Up @@ -39,7 +39,7 @@ public

system implementation main.impl
subcomponents
subcomp_subdevice: device subdevice.impl;
subcomp_process: process dummy_process.impl;
properties

Test_Properties::an_integer_property => 10;
Expand All @@ -58,20 +58,28 @@ public

Test_Properties::a_list_of_list_property => ((1,2), (3,4));

Test_Properties::a_reference_property => reference (subcomp_subdevice);
Test_Properties::a_reference_property => reference (subcomp_process.subcomp_thread);

Test_Properties::a_classifier_property => classifier (subdevice);
Test_Properties::a_classifier_property => classifier (dummy_process.impl);

Test_Properties::an_enumeration_property => enum2;

Test_Properties::a_record_property => [an_integer_field => 10; a_string_field => "test string"; a_real_range_field => 5.0 .. 10.0];

end main.impl;

device subdevice
end subdevice;
process dummy_process
end dummy_process;

device implementation subdevice.impl
end subdevice.impl;
process implementation dummy_process.impl
subcomponents
subcomp_thread: thread dummy_thread.impl;
end dummy_process.impl;

thread dummy_thread
end dummy_thread;

thread implementation dummy_thread.impl
end dummy_thread.impl;

end Test;

0 comments on commit eecc533

Please sign in to comment.