text
stringlengths
0
234
File_Contents := new File_String;
File_String'Read (IO.Stream (File), File_Contents.all);
IO.Close (File);
end Allocate_Space_For_Wayland_XML_Contents;
Root_Node : Aida.Deepend.XML_DOM_Parser.Node_Ptr;
procedure Parse_Contents (File_Contents : Aida.Deepend.String_Ptr) is
Call_Result : Aida.Call_Result;
begin
Aida.Deepend.XML_DOM_Parser.Parse
(File_Contents.all, Call_Result, Root_Node);
if Call_Result.Has_Failed then
raise XML_Exception with Call_Result.Message;
else
Identify_Protocol_Tag;
Identify_Protocol_Children;
end if;
end Parse_Contents;
procedure Identify_Protocol_Tag is
begin
if Root_Node.Id /= Node_Kind_Tag or else Name (Root_Node.Tag) /= "protocol" then
raise XML_Exception with "Root node is not <protocol>";
end if;
if
Attributes (Root_Node.Tag).Length /= 1 or else
Name (Attributes (Root_Node.Tag) (1).all) /= "name"
then
raise XML_Exception with "<protocol> node has no name attribute";
end if;
Protocol_Tag := new Wayland_XML.Protocol_Tag;
Set_Name (Protocol_Tag.all, Value (Attributes (Root_Node.Tag) (1).all));
end Identify_Protocol_Tag;
procedure Identify_Protocol_Children is
function Identify_Copyright
(Node : not null Aida.Deepend.XML_DOM_Parser.Node_Ptr)
return not null Wayland_XML.Copyright_Ptr
is
Copyright_Tag : constant not null Wayland_XML.Copyright_Ptr
:= new Wayland_XML.Copyright_Tag;
begin
if Child_Nodes (Node.Tag).Length = 1 then
if Child_Nodes (Node.Tag) (1).Id = Node_Kind_Text then
Set_Text
(Copyright_Tag.all,
Trim (Child_Nodes (Node.Tag) (1).Text.all));
else
raise XML_Exception;
end if;
else
raise XML_Exception;
end if;
return Copyright_Tag;
end Identify_Copyright;
function Identify_Description
(Node : not null Aida.Deepend.XML_DOM_Parser.Node_Ptr)
return not null Wayland_XML.Description_Tag_Ptr
is
Description_Tag : constant not null Wayland_XML.Description_Tag_Ptr
:= new Wayland_XML.Description_Tag;
Text : SU.Unbounded_String;
begin
if Attributes (Node.Tag).Length = 1 and then
Name (Attributes (Node.Tag) (1).all) = "summary"
then
Set_Summary (Description_Tag.all, Value (Attributes (Node.Tag) (1).all));
else
raise XML_Exception with "Expected tag 'description' to have 1 attribute 'summary'";
end if;
for Child of Child_Nodes (Node.Tag) loop
if Child.Id = Node_Kind_Text then
SU.Append (Text, Trim (Child.Text.all));
elsif Child.Id /= Node_Kind_Comment then
raise XML_Exception with
"Tag 'description' has unexpected child " & Child.Id'Image;
end if;
end loop;
Set_Text (Description_Tag.all, +Text);
return Description_Tag;
end Identify_Description;
function Identify_Arg
(Node : not null Aida.Deepend.XML_DOM_Parser.Node_Ptr)
return not null Wayland_XML.Arg_Tag_Ptr
is
Arg_Tag : constant not null Wayland_XML.Arg_Tag_Ptr
:= new Wayland_XML.Arg_Tag;
procedure Iterate