annotate gcc/ada/libgnat/s-diinio.ads @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT RUN-TIME COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- S Y S T E M . D I M . I N T E G E R _ I O --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
9 -- Copyright (C) 2011-2019, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
17 -- --
kono
parents:
diff changeset
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
19 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
20 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
23 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
25 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
26 -- --
kono
parents:
diff changeset
27 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
29 -- --
kono
parents:
diff changeset
30 ------------------------------------------------------------------------------
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 -- This package provides output routines for integer dimensioned types. All
kono
parents:
diff changeset
33 -- Put routines are modeled after those in package Ada.Text_IO.Integer_IO
kono
parents:
diff changeset
34 -- with the addition of an extra default parameter. All Put_Dim_Of routines
kono
parents:
diff changeset
35 -- output the dimension of Item in a symbolic manner.
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 -- Parameter Symbol may be used in the following manner (all the examples are
kono
parents:
diff changeset
38 -- based on the MKS system of units as defined in package System.Dim.Mks):
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 -- type Mks_Type is new Integer
kono
parents:
diff changeset
41 -- with
kono
parents:
diff changeset
42 -- Dimension_System => (
kono
parents:
diff changeset
43 -- (Unit_Name => Meter, Unit_Symbol => 'm', Dim_Symbol => 'L'),
kono
parents:
diff changeset
44 -- (Unit_Name => Kilogram, Unit_Symbol => "kg", Dim_Symbol => 'M'),
kono
parents:
diff changeset
45 -- (Unit_Name => Second, Unit_Symbol => 's', Dim_Symbol => 'T'),
kono
parents:
diff changeset
46 -- (Unit_Name => Ampere, Unit_Symbol => 'A', Dim_Symbol => 'I'),
kono
parents:
diff changeset
47 -- (Unit_Name => Kelvin, Unit_Symbol => 'K', Dim_Symbol => "Θ"),
kono
parents:
diff changeset
48 -- (Unit_Name => Mole, Unit_Symbol => "mol", Dim_Symbol => 'N'),
kono
parents:
diff changeset
49 -- (Unit_Name => Candela, Unit_Symbol => "cd", Dim_Symbol => 'J'));
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 -- Case 1. A value is supplied for Symbol
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 -- * Put : The string appears as a suffix of Item
kono
parents:
diff changeset
54
kono
parents:
diff changeset
55 -- * Put_Dim_Of : The string appears alone
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 -- Obj : Mks_Type := 2;
kono
parents:
diff changeset
58 -- Put (Obj, Symbols => "dimensionless");
kono
parents:
diff changeset
59 -- Put_Dim_Of (Obj, Symbols => "dimensionless");
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 -- The corresponding outputs are:
kono
parents:
diff changeset
62 -- $2 dimensionless
kono
parents:
diff changeset
63 -- $dimensionless
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 -- Case 2. No value is supplied for Symbol and Item is dimensionless
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 -- * Put : Item appears without a suffix
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 -- * Put_Dim_Of : the output is []
kono
parents:
diff changeset
70
kono
parents:
diff changeset
71 -- Obj : Mks_Type := 2;
kono
parents:
diff changeset
72 -- Put (Obj);
kono
parents:
diff changeset
73 -- Put_Dim_Of (Obj);
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 -- The corresponding outputs are:
kono
parents:
diff changeset
76 -- $2
kono
parents:
diff changeset
77 -- $[]
kono
parents:
diff changeset
78
kono
parents:
diff changeset
79 -- Case 3. No value is supplied for Symbol and Item has a dimension
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 -- * Put : If the type of Item is a dimensioned subtype whose
kono
parents:
diff changeset
82 -- symbol is not empty, then the symbol appears as a suffix.
kono
parents:
diff changeset
83 -- Otherwise, a new string is created and appears as a
kono
parents:
diff changeset
84 -- suffix of Item. This string results in the successive
kono
parents:
diff changeset
85 -- concatenations between each unit symbol raised by its
kono
parents:
diff changeset
86 -- corresponding dimension power from the dimensions of Item.
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 -- * Put_Dim_Of : The output is a new string resulting in the successive
kono
parents:
diff changeset
89 -- concatenations between each dimension symbol raised by its
kono
parents:
diff changeset
90 -- corresponding dimension power from the dimensions of Item.
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 -- subtype Length is Mks_Type
kono
parents:
diff changeset
93 -- with
kono
parents:
diff changeset
94 -- Dimension => ('m',
kono
parents:
diff changeset
95 -- Meter => 1,
kono
parents:
diff changeset
96 -- others => 0);
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 -- Obj : Length := 2;
kono
parents:
diff changeset
99 -- Put (Obj);
kono
parents:
diff changeset
100 -- Put_Dim_Of (Obj);
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 -- The corresponding outputs are:
kono
parents:
diff changeset
103 -- $2 m
kono
parents:
diff changeset
104 -- $[L]
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 -- subtype Random is Mks_Type
kono
parents:
diff changeset
107 -- with
kono
parents:
diff changeset
108 -- Dimension => ("",
kono
parents:
diff changeset
109 -- Meter => 3,
kono
parents:
diff changeset
110 -- Candela => 2,
kono
parents:
diff changeset
111 -- others => 0);
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 -- Obj : Random := 5;
kono
parents:
diff changeset
114 -- Put (Obj);
kono
parents:
diff changeset
115 -- Put_Dim_Of (Obj);
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 -- The corresponding outputs are:
kono
parents:
diff changeset
118 -- $5 m**3.cd**2
kono
parents:
diff changeset
119 -- $[L**3.J**2]
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121 with Ada.Text_IO; use Ada.Text_IO;
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 generic
kono
parents:
diff changeset
124 type Num_Dim_Integer is range <>;
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 package System.Dim.Integer_IO is
kono
parents:
diff changeset
127
kono
parents:
diff changeset
128 Default_Width : Field := Num_Dim_Integer'Width;
kono
parents:
diff changeset
129 Default_Base : Number_Base := 10;
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131 procedure Put
kono
parents:
diff changeset
132 (File : File_Type;
kono
parents:
diff changeset
133 Item : Num_Dim_Integer;
kono
parents:
diff changeset
134 Width : Field := Default_Width;
kono
parents:
diff changeset
135 Base : Number_Base := Default_Base;
kono
parents:
diff changeset
136 Symbol : String := "");
kono
parents:
diff changeset
137
kono
parents:
diff changeset
138 procedure Put
kono
parents:
diff changeset
139 (Item : Num_Dim_Integer;
kono
parents:
diff changeset
140 Width : Field := Default_Width;
kono
parents:
diff changeset
141 Base : Number_Base := Default_Base;
kono
parents:
diff changeset
142 Symbol : String := "");
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 procedure Put
kono
parents:
diff changeset
145 (To : out String;
kono
parents:
diff changeset
146 Item : Num_Dim_Integer;
kono
parents:
diff changeset
147 Base : Number_Base := Default_Base;
kono
parents:
diff changeset
148 Symbol : String := "");
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150 procedure Put_Dim_Of
kono
parents:
diff changeset
151 (File : File_Type;
kono
parents:
diff changeset
152 Item : Num_Dim_Integer;
kono
parents:
diff changeset
153 Symbol : String := "");
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 procedure Put_Dim_Of
kono
parents:
diff changeset
156 (Item : Num_Dim_Integer;
kono
parents:
diff changeset
157 Symbol : String := "");
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 procedure Put_Dim_Of
kono
parents:
diff changeset
160 (To : out String;
kono
parents:
diff changeset
161 Item : Num_Dim_Integer;
kono
parents:
diff changeset
162 Symbol : String := "");
kono
parents:
diff changeset
163
kono
parents:
diff changeset
164 pragma Inline (Put);
kono
parents:
diff changeset
165 pragma Inline (Put_Dim_Of);
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 end System.Dim.Integer_IO;