Commit eefa0d92 authored by hugues.jerome's avatar hugues.jerome

* Add DTD to files generated for Cheddar



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/ocarina@1966 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent ede003eb
......@@ -387,6 +387,7 @@ AC_OUTPUT([
resources/Makefile
resources/behavioural_properties/Makefile
resources/runtime/Makefile
resources/runtime/cheddar/Makefile
projects/ocarina.gpr
src/main/Makefile
src/main/ocarina-configuration.adb
......
SUBDIRS =
SUBDIRS = cheddar
@DEBUG_FALSE@DEBUG_FLAG = --disable-debug
@DEBUG_TRUE@DEBUG_FLAG = --enable-debug
......
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2010, GET-Telecom Paris. --
-- Copyright (C) 2010-2011, European Space Agency (ESA). --
-- --
-- Ocarina is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
......@@ -228,7 +228,7 @@ package body Ocarina.Backends.Cheddar.Main is
-- >
if Cheddar_Node = No_Node then
Cheddar_Node := Make_Xml_Node ("cheddar");
Cheddar_Node := Make_XML_Node ("cheddar");
Append_Node_To_List
(Cheddar_Node, XTN.Subitems (XTN.Root_Node (XTN.XML_File (U))));
end if;
......
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2010, GET-Telecom Paris. --
-- Copyright (C) 2010-2011, European Space Agency (ESA). --
-- --
-- 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,6 +31,7 @@
-- --
------------------------------------------------------------------------------
with GNAT.OS_Lib; use GNAT.OS_Lib;
with Namet; use Namet;
with Utils; use Utils;
......@@ -38,6 +39,7 @@ with Ocarina.ME_AADL.AADL_Instances.Nodes;
with Ocarina.ME_AADL.AADL_Instances.Nutils;
with Ocarina.ME_AADL.AADL_Instances.Entities;
with Ocarina.Backends.Build_Utils;
with Ocarina.Backends.Properties;
with Ocarina.Backends.Utils;
with Ocarina.Backends.XML_Common.Mapping;
......@@ -51,6 +53,7 @@ package body Ocarina.Backends.Cheddar.Mapping is
use Ocarina.ME_AADL.AADL_Instances.Nodes;
use Ocarina.ME_AADL.AADL_Instances.Entities;
use Ocarina.Backends.Build_Utils;
use Ocarina.Backends.Properties;
use Ocarina.Backends.Utils;
use Ocarina.Backends.XML_Common.Mapping;
......@@ -118,6 +121,7 @@ package body Ocarina.Backends.Cheddar.Mapping is
N : Node_Id;
P : Node_Id;
Root : Node_Id;
DTD : Node_Id;
begin
pragma Assert (AINU.Is_System (E)
or else AINU.Is_Process (E)
......@@ -138,7 +142,13 @@ package body Ocarina.Backends.Cheddar.Mapping is
Add_Str_To_Name_Buffer ("_cheddar");
N := Make_Defining_Identifier (Name_Find);
P := Make_XML_File (N);
Set_Str_To_Name_Buffer
(Get_Runtime_Path ("cheddar")
& Directory_Separator & "cheddar.dtd");
DTD := Make_Defining_Identifier (Name_Find);
P := Make_XML_File (N, DTD);
Set_Distributed_Application_Unit (P, U);
XTN.Set_XML_File (U, P);
......
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2008-2010, European Space Agency (ESA). --
-- Copyright (C) 2008-2011, European Space Agency (ESA). --
-- --
-- Ocarina is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
......@@ -35,6 +35,7 @@ with Namet; use Namet;
with Output; use Output;
with Utils; use Utils;
with Ada.Directories;
with GNAT.OS_Lib; use GNAT.OS_Lib;
with Ocarina.Backends.Utils;
......@@ -84,10 +85,7 @@ package body Ocarina.Backends.XML_Tree.Generator is
-- The File name corresponding is the lowerd name of N
Get_Name_String
(Conventional_Base_Name
(Name
(Defining_Identifier
(N))));
(Conventional_Base_Name (Name (Defining_Identifier (N))));
-- Adding file suffix
......@@ -104,17 +102,26 @@ package body Ocarina.Backends.XML_Tree.Generator is
begin
if not Print_On_Stdout then
declare
File_Name : constant Name_Id
:= Get_File_Name (N);
File_Name : constant Name_Id := Get_File_Name (N);
File_Name_String : constant String := Get_Name_String (File_Name);
Fd : File_Descriptor;
begin
Get_Name_String (File_Name);
-- Create a new file and overwrites existing file with
-- the same name
Fd := Create_File
(Name_Buffer (1 .. Name_Len), Text);
begin
if Present (XML_DTD (N)) then
-- If a DTD has been specified, copy it as target
-- file, then move at the end of the file to add
-- output.
Ada.Directories.Copy_File
(Source_Name => Get_Name_String (Name (XML_DTD (N))),
Target_Name => File_Name_String);
Fd := Open_Read_Write (File_Name_String, Text);
Lseek (Fd, 0, Seek_End);
else
-- Else, create a new file, overwrite existing file
Fd := Create_File (File_Name_String, Text);
end if;
if Fd = Invalid_FD then
raise Program_Error;
......@@ -470,11 +477,9 @@ package body Ocarina.Backends.XML_Tree.Generator is
-----------------------
procedure Generate_XML_File (N : Node_Id) is
pragma Assert (Present (N));
Fd : File_Descriptor;
begin
if No (N) then
return;
end if;
Fd := Set_Output (N);
Generate (Root_Node (N));
......
......@@ -77,6 +77,7 @@ module Ocarina::Backends::XML_Tree::Nodes {
interface XML_File : Definition {
Node_Id Distributed_Application_Unit;
Node_Id Root_Node;
Node_Id XML_DTD; // Identifier referring to XML file DTD
};
interface XML_Node : Definition
......
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2008-2009, GET-Telecom Paris. --
-- Copyright (C) 2008-2011, European Space Agency (ESA). --
-- --
-- Ocarina is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
......@@ -566,14 +566,24 @@ package body Ocarina.Backends.XML_Tree.Nutils is
-- Make_XML_File --
-------------------
function Make_XML_File (Identifier : Node_Id) return Node_Id is
function Make_XML_File
(Identifier : Node_Id; DTD : Node_Id := No_Node)
return Node_Id
is
File : Node_Id;
The_XML_Node : Node_Id;
begin
File := New_Node (K_XML_File);
The_XML_Node := New_Node (XTN.K_XML_Node);
Set_Defining_Identifier (File, Identifier);
Set_Corresponding_Node (Identifier, File);
XTN.Set_Root_Node (File, New_Node (XTN.K_XML_Node));
XTN.Set_Root_Node (File, The_XML_Node);
if Present (DTD) then
XTN.Set_XML_DTD (File, DTD);
end if;
return File;
end Make_XML_File;
......
......@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
-- Copyright (C) 2008-2009, GET-Telecom Paris. --
-- Copyright (C) 2008-2011, European Space Agency (ESA). --
-- --
-- Ocarina is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
......@@ -185,7 +185,9 @@ package Ocarina.Backends.XML_Tree.Nutils is
function Conventional_Base_Name (N : Name_Id) return Name_Id;
-- Return a lower case name of N
function Make_XML_File (Identifier : Node_Id) return Node_Id;
function Make_XML_File
(Identifier : Node_Id; DTD : Node_Id := No_Node)
return Node_Id;
function Make_Literal (Value : Value_Id) return Node_Id;
......
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