Commit ab476638 by Arnaud Charlet

[multiple changes]

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.

From-SVN: r212643
parent 3a859cff
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> 2014-07-16 Ed Schonberg <schonberg@adacore.com>
* a-coinho-shared.adb, a-coinho-shared.ads: Proper structures for * a-coinho-shared.adb, a-coinho-shared.ads: Proper structures for
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- 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 -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -601,6 +601,17 @@ package body Ada.Containers.Hashed_Sets is ...@@ -601,6 +601,17 @@ package body Ada.Containers.Hashed_Sets is
end if; end if;
end Finalize; 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 -- -- Find --
---------- ----------
...@@ -1029,8 +1040,12 @@ package body Ada.Containers.Hashed_Sets is ...@@ -1029,8 +1040,12 @@ package body Ada.Containers.Hashed_Sets is
function Iterate function Iterate
(Container : Set) return Set_Iterator_Interfaces.Forward_Iterator'Class (Container : Set) return Set_Iterator_Interfaces.Forward_Iterator'Class
is is
B : Natural renames Container'Unrestricted_Access.all.HT.Busy;
begin begin
return Iterator'(Container => Container'Unrestricted_Access); B := B + 1;
return It : constant Iterator :=
Iterator'(Limited_Controlled with
Container => Container'Unrestricted_Access);
end Iterate; end Iterate;
------------ ------------
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- 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 -- -- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow -- -- GNAT. The copyright notice above, and the license provisions that follow --
...@@ -543,8 +543,8 @@ private ...@@ -543,8 +543,8 @@ private
No_Element : constant Cursor := (Container => null, Node => null); No_Element : constant Cursor := (Container => null, Node => null);
type Iterator is limited new type Iterator is new Limited_Controlled
Set_Iterator_Interfaces.Forward_Iterator with record and Set_Iterator_Interfaces.Forward_Iterator with record
Container : Set_Access; Container : Set_Access;
end record; end record;
...@@ -553,5 +553,6 @@ private ...@@ -553,5 +553,6 @@ private
overriding function Next overriding function Next
(Object : Iterator; (Object : Iterator;
Position : Cursor) return Cursor; Position : Cursor) return Cursor;
overriding procedure Finalize (Object : in out Iterator);
end Ada.Containers.Hashed_Sets; end Ada.Containers.Hashed_Sets;
...@@ -38,12 +38,13 @@ package body Ada.Containers.Indefinite_Holders is ...@@ -38,12 +38,13 @@ package body Ada.Containers.Indefinite_Holders is
function "=" (Left, Right : Holder) return Boolean is function "=" (Left, Right : Holder) return Boolean is
begin 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; return True;
elsif Left.Reference /= null and Right.Reference /= null then elsif Left.Reference /= null and Right.Reference /= null then
return Left.Reference.Element.all = Right.Reference.Element.all; return Left.Reference.Element.all = Right.Reference.Element.all;
else else
return False; return False;
end if; end if;
...@@ -66,6 +67,7 @@ package body Ada.Containers.Indefinite_Holders is ...@@ -66,6 +67,7 @@ package body Ada.Containers.Indefinite_Holders is
begin begin
if Control.Container /= null then if Control.Container /= null then
Reference (Control.Container.Reference); Reference (Control.Container.Reference);
declare declare
B : Natural renames Control.Container.Busy; B : Natural renames Control.Container.Busy;
begin begin
...@@ -122,10 +124,9 @@ package body Ada.Containers.Indefinite_Holders is ...@@ -122,10 +124,9 @@ package body Ada.Containers.Indefinite_Holders is
(Element => Container.Reference.Element.all'Access, (Element => Container.Reference.Element.all'Access,
Control => (Controlled with Container'Unrestricted_Access)); Control => (Controlled with Container'Unrestricted_Access));
B : Natural renames Ref.Control.Container.Busy; B : Natural renames Ref.Control.Container.Busy;
begin begin
Reference (Ref.Control.Container.Reference); Reference (Ref.Control.Container.Reference);
B := B + 1; B := B + 1;
return Ref; return Ref;
end Constant_Reference; end Constant_Reference;
......
...@@ -130,8 +130,7 @@ private ...@@ -130,8 +130,7 @@ private
overriding procedure Adjust (Container : in out Holder); overriding procedure Adjust (Container : in out Holder);
overriding procedure Finalize (Container : in out Holder); overriding procedure Finalize (Container : in out Holder);
type Reference_Control_Type is new Controlled with type Reference_Control_Type is new Controlled with record
record
Container : Holder_Access; Container : Holder_Access;
end record; end record;
......
...@@ -40,10 +40,8 @@ package body Ada.Containers.Indefinite_Holders is ...@@ -40,10 +40,8 @@ package body Ada.Containers.Indefinite_Holders is
begin begin
if Left.Element = null and Right.Element = null then if Left.Element = null and Right.Element = null then
return True; return True;
elsif Left.Element /= null and Right.Element /= null then elsif Left.Element /= null and Right.Element /= null then
return Left.Element.all = Right.Element.all; return Left.Element.all = Right.Element.all;
else else
return False; return False;
end if; end if;
......
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