summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJed Barber <jjbarber@y7mail.com>2020-04-30 17:54:18 +1000
committerJed Barber <jjbarber@y7mail.com>2020-04-30 17:54:18 +1000
commitb6ae7a1084ea1350c26fff18e8aa6c181a3507c8 (patch)
treeb06065700adebf52a6285f32c0dd4c90ad419557 /src
parent5ecc9ae9efb62461d3d88d029515671c1118271e (diff)
Helpers warning suppressed, Tamper checks revised
Diffstat (limited to 'src')
-rw-r--r--src/directed_graphs.adb59
-rw-r--r--src/directed_graphs.ads7
2 files changed, 55 insertions, 11 deletions
diff --git a/src/directed_graphs.adb b/src/directed_graphs.adb
index 0a9ce4d..3b4caee 100644
--- a/src/directed_graphs.adb
+++ b/src/directed_graphs.adb
@@ -3,6 +3,9 @@
-- This source is licensed under the Sunset License v1.0
+with System;
+
+
package body Directed_Graphs is
@@ -60,6 +63,19 @@ package body Directed_Graphs is
------------
+ -- Adjust --
+ ------------
+
+ procedure Adjust
+ (Container : in out Graph) is
+ begin
+ Impl.Zero_Counts (Container.Tamper_Info);
+ end Adjust;
+
+
+
+
+ ------------
-- Append --
------------
@@ -76,6 +92,7 @@ package body Directed_Graphs is
end if;
Node := Node_Type'Succ (Node);
end loop;
+ Impl.TC_Check (Container.Tamper_Info);
Container.Connections.Insert
(Node, Node_Vectors.Empty_Vector, Position.Place, Insert_Success);
if Impl.Checks and then not Insert_Success then
@@ -155,9 +172,15 @@ package body Directed_Graphs is
procedure Assign
(Target : in out Graph;
- Source : in Graph) is
+ Source : in Graph)
+ is
+ use type System.Address;
begin
- Target := Source;
+ if Target'Address = Source'Address then
+ return;
+ else
+ Target := Source;
+ end if;
end Assign;
@@ -222,7 +245,6 @@ package body Directed_Graphs is
procedure Clear_Labels
(Container : in out Graph) is
begin
- Impl.TC_Check (Container.Tamper_Info);
Container.Node_Labels.Clear;
Container.Edge_Labels.Clear;
end Clear_Labels;
@@ -553,9 +575,7 @@ package body Directed_Graphs is
return Graph is
begin
return G : Graph do
- G.Connections := Source.Connections;
- G.Node_Labels := Source.Node_Labels;
- G.Edge_Labels := Source.Edge_Labels;
+ G.Assign (Source);
end return;
end Copy;
@@ -603,6 +623,7 @@ package body Directed_Graphs is
if Impl.Checks and then not Container.Contains (Node) then
raise Constraint_Error with "Graph does not contain node";
end if;
+ Impl.TC_Check (Container.Tamper_Info);
for N of Container.Connections.Constant_Reference (Node) loop
Container.Edge_Labels.Exclude ((From => Node, To => N));
end loop;
@@ -728,9 +749,15 @@ package body Directed_Graphs is
if Impl.Checks and then Position.Container = null then
raise Constraint_Error with "Graph does not exist";
end if;
- for C in Position.Container.Iterate_Subgraph (Position) loop
- Nodes.Append (Element (C));
- end loop;
+ Impl.TC_Check (Position.Container.Tamper_Info);
+ declare
+ It : Graph_Iterator_Interfaces.Reversible_Iterator'Class :=
+ Position.Container.Iterate_Subgraph (Position);
+ begin
+ Nodes := Subgraph_Iterator (It).Nodes;
+ end;
+ -- Have to wait for the Iterator to go out of scope
+ -- before deleting Nodes due to busy check rules
for N of Nodes loop
Position.Container.Delete (N);
end loop;
@@ -1287,6 +1314,7 @@ package body Directed_Graphs is
if Impl.Checks and then Container.Contains (Node) then
raise Constraint_Error with "Graph already contains node";
end if;
+ Impl.TC_Check (Container.Tamper_Info);
Container.Connections.Insert (Node, Node_Vectors.Empty_Vector);
end Insert;
@@ -1368,6 +1396,7 @@ package body Directed_Graphs is
begin
return It : Iterator do
It.Container := Container'Unrestricted_Access;
+ Impl.Busy (Container.Tamper_Info'Unrestricted_Access.all);
end return;
end Iterate;
@@ -1414,6 +1443,7 @@ package body Directed_Graphs is
return It : Subgraph_Iterator do
It.Container := Container'Unrestricted_Access;
It.Nodes := Visited;
+ Impl.Busy (Container.Tamper_Info'Unrestricted_Access.all);
end return;
end Iterate_Subgraph;
@@ -1627,12 +1657,18 @@ package body Directed_Graphs is
----------
procedure Move
- (Target, Source : in out Graph) is
+ (Target, Source : in out Graph)
+ is
+ use type System.Address;
begin
+ if Target'Address = Source'Address then
+ return;
+ end if;
+ Impl.TC_Check (Target.Tamper_Info);
+ Impl.TC_Check (Source.Tamper_Info);
Node_Maps.Move (Target.Connections, Source.Connections);
Node_Label_Maps.Move (Target.Node_Labels, Source.Node_Labels);
Edge_Label_Maps.Move (Target.Edge_Labels, Source.Edge_Labels);
- -- does anything have to be done with tamper checks here?
end Move;
@@ -2161,6 +2197,7 @@ package body Directed_Graphs is
raise Constraint_Error with "Graph does not contain right operand";
end if;
end if;
+ Impl.TE_Check (Container.Tamper_Info);
-- Switch the nodes themselves around
Temp_Vector := Container.Connections.Element (Left);
Container.Connections.Replace (Left, Container.Connections.Element (Right));
diff --git a/src/directed_graphs.ads b/src/directed_graphs.ads
index 94c67d3..17a0239 100644
--- a/src/directed_graphs.ads
+++ b/src/directed_graphs.ads
@@ -3,6 +3,10 @@
-- This source is licensed under the Sunset License v1.0
+pragma Warnings (Off, """Ada.Containers.Helpers"" is an internat GNAT unit");
+pragma Warnings (Off, "use of this unit is non-portable and version-dependent");
+
+
with
Ada.Iterator_Interfaces;
@@ -673,6 +677,9 @@ private
Tamper_Info : aliased Help.Tamper_Counts;
end record;
+ overriding procedure Adjust
+ (Container : in out Graph);
+
overriding procedure Finalize
(Container : in out Graph);