[Ada] Ada2020: update Big_Numbers.* specs
authorBob Duff <duff@adacore.com>
Wed, 18 Mar 2020 21:17:58 +0000 (17:17 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Fri, 12 Jun 2020 08:29:09 +0000 (04:29 -0400)
2020-06-12  Bob Duff  <duff@adacore.com>

gcc/ada/

* libgnat/a-nbnbin.adb, libgnat/a-nbnbin.ads,
libgnat/a-nbnbin__gmp.adb, libgnat/a-nbnbre.adb,
libgnat/a-nbnbre.ads: Update Put_Image, and uncomment the aspect
specification.  Add pragmas Ada_2020.
* libgnat/a-stouut.ads, libgnat/a-stteou.ads: Add Preelaborate,
because the Big_Numbers packages have Preelaborate, and now
depend on these Text_Output packages.

gcc/ada/libgnat/a-nbnbin.adb
gcc/ada/libgnat/a-nbnbin.ads
gcc/ada/libgnat/a-nbnbin__gmp.adb
gcc/ada/libgnat/a-nbnbre.adb
gcc/ada/libgnat/a-nbnbre.ads
gcc/ada/libgnat/a-stouut.ads
gcc/ada/libgnat/a-stteou.ads

index 637e5fb..fa4ddf0 100644 (file)
 --                                                                          --
 ------------------------------------------------------------------------------
 
+pragma Ada_2020;
+
 with Ada.Unchecked_Deallocation;
-with Ada.Characters.Conversions; use Ada.Characters.Conversions;
+with Ada.Strings.Text_Output.Utils;
 
 with Interfaces; use Interfaces;
 
@@ -290,11 +292,12 @@ package body Ada.Numerics.Big_Numbers.Big_Integers is
    -- Put_Image --
    ---------------
 
-   procedure Put_Image
-     (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
-      Arg    : Big_Integer) is
+   procedure Put_Image (S : in out Sink'Class; V : Big_Integer) is
+      --  This is implemented in terms of To_String. It might be more elegant
+      --  and more efficient to do it the other way around, but this is the
+      --  most expedient implementation for now.
    begin
-      Wide_Wide_String'Write (Stream, To_Wide_Wide_String (To_String (Arg)));
+      Strings.Text_Output.Utils.Put_UTF_8 (S, To_String (V));
    end Put_Image;
 
    ---------
index 7d1d048..45a7b6e 100644 (file)
@@ -13,7 +13,9 @@
 --                                                                          --
 ------------------------------------------------------------------------------
 
-with Ada.Streams;
+pragma Ada_2020;
+
+with Ada.Strings.Text_Output; use Ada.Strings.Text_Output;
 
 private with Ada.Finalization;
 private with System;
@@ -24,9 +26,9 @@ private with System;
 package Ada.Numerics.Big_Numbers.Big_Integers
   with Preelaborate
 is
-   type Big_Integer is private;
-   --  with Integer_Literal => From_String,
-   --       Put_Image => Put_Image;
+   type Big_Integer is private with
+   --  Integer_Literal => From_String,
+     Put_Image => Put_Image;
 
    function Is_Valid (Arg : Big_Integer) return Boolean
      with Convention => Intrinsic;
@@ -95,9 +97,7 @@ is
 
    function From_String (Arg : String) return Big_Integer;
 
-   procedure Put_Image
-     (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
-      Arg    : Big_Integer);
+   procedure Put_Image (S : in out Sink'Class; V : Big_Integer);
 
    function "+" (L : Big_Integer) return Big_Integer;
 
index 5695bc1..c950389 100644 (file)
 
 --  This is the GMP version of this package
 
+pragma Ada_2020;
+
 with Ada.Unchecked_Conversion;
 with Ada.Unchecked_Deallocation;
 with Interfaces.C;               use Interfaces.C;
 with Interfaces.C.Strings;       use Interfaces.C.Strings;
-with Ada.Characters.Conversions; use Ada.Characters.Conversions;
+with Ada.Strings.Text_Output.Utils;
 with Ada.Characters.Handling;    use Ada.Characters.Handling;
 
 package body Ada.Numerics.Big_Numbers.Big_Integers is
@@ -403,11 +405,12 @@ package body Ada.Numerics.Big_Numbers.Big_Integers is
    -- Put_Image --
    ---------------
 
-   procedure Put_Image
-     (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
-      Arg    : Big_Integer) is
+   procedure Put_Image (S : in out Sink'Class; V : Big_Real) is
+      --  This is implemented in terms of To_String. It might be more elegant
+      --  and more efficient to do it the other way around, but this is the
+      --  most expedient implementation for now.
    begin
-      Wide_Wide_String'Write (Stream, To_Wide_Wide_String (To_String (Arg)));
+      Strings.Text_Output.Utils.Put_UTF_8 (S, To_String (V));
    end Put_Image;
 
    ---------
index 07a9442..11459ca 100644 (file)
@@ -31,7 +31,9 @@
 
 --  This is the default version of this package, based on Big_Integers only.
 
-with Ada.Characters.Conversions; use Ada.Characters.Conversions;
+pragma Ada_2020;
+
+with Ada.Strings.Text_Output.Utils;
 
 package body Ada.Numerics.Big_Numbers.Big_Reals is
 
@@ -399,11 +401,12 @@ package body Ada.Numerics.Big_Numbers.Big_Reals is
    -- Put_Image --
    ---------------
 
-   procedure Put_Image
-     (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
-      Arg    : Big_Real) is
+   procedure Put_Image (S : in out Sink'Class; V : Big_Real) is
+      --  This is implemented in terms of To_String. It might be more elegant
+      --  and more efficient to do it the other way around, but this is the
+      --  most expedient implementation for now.
    begin
-      Wide_Wide_String'Write (Stream, To_Wide_Wide_String (To_String (Arg)));
+      Strings.Text_Output.Utils.Put_UTF_8 (S, To_String (V));
    end Put_Image;
 
    ---------
index 2ffc356..ddfbd77 100644 (file)
 --                                                                          --
 ------------------------------------------------------------------------------
 
+pragma Ada_2020;
+
 with Ada.Numerics.Big_Numbers.Big_Integers;
-with Ada.Streams;
+
+with Ada.Strings.Text_Output; use Ada.Strings.Text_Output;
 
 --  Note that some Ada 2020 aspects are commented out since they are not
 --  supported yet.
@@ -22,9 +25,9 @@ with Ada.Streams;
 package Ada.Numerics.Big_Numbers.Big_Reals
   with Preelaborate
 is
-   type Big_Real is private;
---   with Real_Literal => From_String,
---        Put_Image    => Put_Image;
+   type Big_Real is private with
+--    Real_Literal => From_String,
+     Put_Image    => Put_Image;
 
    function Is_Valid (Arg : Big_Real) return Boolean
      with Convention => Intrinsic;
@@ -105,9 +108,7 @@ is
 
    function From_Quotient_String (Arg : String) return Big_Real;
 
-   procedure Put_Image
-     (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
-      Arg    : Big_Real);
+   procedure Put_Image (S : in out Sink'Class; V : Big_Real);
 
    function "+" (L : Big_Real) return Big_Real;
 
index c02885e..d781a06 100644 (file)
@@ -31,7 +31,7 @@
 
 pragma Ada_2020;
 
-package Ada.Strings.Text_Output.Utils is
+package Ada.Strings.Text_Output.Utils with Preelaborate is
 
    --  This package provides utility functions on Sink'Class. These are
    --  intended for use by Put_Image attributes, both the default versions
index 8aaee46..f4b8966 100644 (file)
@@ -33,7 +33,7 @@ pragma Ada_2020;
 
 with Ada.Strings.UTF_Encoding;
 with Ada.Strings.UTF_Encoding.Wide_Wide_Strings;
-package Ada.Strings.Text_Output is
+package Ada.Strings.Text_Output with Preelaborate is
 
    --  This package provides a "Sink" abstraction, to which characters of type
    --  Character, Wide_Character, and Wide_Wide_Character can be sent. This