* a-coinho.adb, a-coinho-shared.adb, a-coinho-shared.ads: Minor
reformatting.
2014-07-16 Ed Schonberg <schonberg@adacore.com>
* a-cohase.ads: Type Iterator must be controlled, so that the
tampering bit is properly set through an iteration.
* a-cohase.adb: Add Finalize operation for type Iterator.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@212643
138bc75d-0d04-0410-961f-
82ee72b054a4
+2014-07-16 Robert Dewar <dewar@adacore.com>
+
+ * a-coinho.adb, a-coinho-shared.adb, a-coinho-shared.ads: Minor
+ reformatting.
+
+2014-07-16 Ed Schonberg <schonberg@adacore.com>
+
+ * a-cohase.ads: Type Iterator must be controlled, so that the
+ tampering bit is properly set through an iteration.
+ * a-cohase.adb: Add Finalize operation for type Iterator.
+
2014-07-16 Ed Schonberg <schonberg@adacore.com>
* a-coinho-shared.adb, a-coinho-shared.ads: Proper structures for
-- --
-- B o d y --
-- --
--- Copyright (C) 2004-2013, Free Software Foundation, Inc. --
+-- Copyright (C) 2004-2014, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
end if;
end Finalize;
+ procedure Finalize (Object : in out Iterator) is
+ begin
+ if Object.Container /= null then
+ declare
+ B : Natural renames Object.Container.HT.Busy;
+ begin
+ B := B - 1;
+ end;
+ end if;
+ end Finalize;
+
----------
-- Find --
----------
function Iterate
(Container : Set) return Set_Iterator_Interfaces.Forward_Iterator'Class
is
+ B : Natural renames Container'Unrestricted_Access.all.HT.Busy;
begin
- return Iterator'(Container => Container'Unrestricted_Access);
+ B := B + 1;
+ return It : constant Iterator :=
+ Iterator'(Limited_Controlled with
+ Container => Container'Unrestricted_Access);
end Iterate;
------------
-- --
-- S p e c --
-- --
--- Copyright (C) 2004-2013, Free Software Foundation, Inc. --
+-- Copyright (C) 2004-2014, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
No_Element : constant Cursor := (Container => null, Node => null);
- type Iterator is limited new
- Set_Iterator_Interfaces.Forward_Iterator with record
+ type Iterator is new Limited_Controlled
+ and Set_Iterator_Interfaces.Forward_Iterator with record
Container : Set_Access;
end record;
overriding function Next
(Object : Iterator;
Position : Cursor) return Cursor;
+ overriding procedure Finalize (Object : in out Iterator);
end Ada.Containers.Hashed_Sets;
function "=" (Left, Right : Holder) return Boolean is
begin
- if Left.Reference = null and Right.Reference = null then
+ if Left.Reference = Right.Reference then
+ -- Covers both null and not null but the same shared object cases.
+
return True;
elsif Left.Reference /= null and Right.Reference /= null then
return Left.Reference.Element.all = Right.Reference.Element.all;
-
else
return False;
end if;
begin
if Control.Container /= null then
Reference (Control.Container.Reference);
+
declare
B : Natural renames Control.Container.Busy;
begin
(Element => Container.Reference.Element.all'Access,
Control => (Controlled with Container'Unrestricted_Access));
B : Natural renames Ref.Control.Container.Busy;
-
begin
Reference (Ref.Control.Container.Reference);
- B := B + 1;
+ B := B + 1;
return Ref;
end Constant_Reference;
overriding procedure Adjust (Container : in out Holder);
overriding procedure Finalize (Container : in out Holder);
- type Reference_Control_Type is new Controlled with
- record
+ type Reference_Control_Type is new Controlled with record
Container : Holder_Access;
end record;
begin
if Left.Element = null and Right.Element = null then
return True;
-
elsif Left.Element /= null and Right.Element /= null then
return Left.Element.all = Right.Element.all;
-
else
return False;
end if;