| 1 |
------------------------------------------------------------------------------ |
| 2 |
-- -- |
| 3 |
-- GNAT RUN-TIME COMPONENTS -- |
| 4 |
-- -- |
| 5 |
-- S Y S T E M . S T R E A M _ A T T R I B U T E S -- |
| 6 |
-- -- |
| 7 |
-- B o d y -- |
| 8 |
-- -- |
| 9 |
-- Copyright (C) 1992-2025, Free Software Foundation, Inc. -- |
| 10 |
-- -- |
| 11 |
-- GNAT is free software; you can redistribute it and/or modify it under -- |
| 12 |
-- terms of the GNU General Public License as published by the Free Soft- -- |
| 13 |
-- ware Foundation; either version 3, or (at your option) any later ver- -- |
| 14 |
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- |
| 15 |
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- |
| 16 |
-- or FITNESS FOR A PARTICULAR PURPOSE. -- |
| 17 |
-- -- |
| 18 |
-- As a special exception under Section 7 of GPL version 3, you are granted -- |
| 19 |
-- additional permissions described in the GCC Runtime Library Exception, -- |
| 20 |
-- version 3.1, as published by the Free Software Foundation. -- |
| 21 |
-- -- |
| 22 |
-- You should have received a copy of the GNU General Public License and -- |
| 23 |
-- a copy of the GCC Runtime Library Exception along with this program; -- |
| 24 |
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- |
| 25 |
-- <http://www.gnu.org/licenses/>. -- |
| 26 |
-- -- |
| 27 |
-- GNAT was originally developed by the GNAT team at New York University. -- |
| 28 |
-- Extensive contributions were provided by Ada Core Technologies Inc. -- |
| 29 |
-- -- |
| 30 |
------------------------------------------------------------------------------ |
| 31 |
|
| 32 |
with Ada.IO_Exceptions; |
| 33 |
with Ada.Streams; use Ada.Streams; |
| 34 |
with Ada.Unchecked_Conversion; |
| 35 |
with System.Stream_Attributes.XDR; |
| 36 |
|
| 37 |
package body System.Stream_Attributes is |
| 38 |
|
| 39 |
XDR_Stream : constant Integer; |
| 40 |
pragma Import (C, XDR_Stream, "__gl_xdr_stream"); |
| 41 |
-- This imported value is used to determine whether the build had the |
| 42 |
-- binder switch "-xdr" present which enables XDR streaming and sets this |
| 43 |
-- flag to 1. |
| 44 |
|
| 45 |
function XDR_Support return Boolean is (XDR_Stream = 1); |
| 46 |
pragma Inline (XDR_Support); |
| 47 |
-- Return True if XDR streaming should be used. Note that 128-bit integers |
| 48 |
-- are not supported by the XDR protocol and will raise Device_Error. |
| 49 |
|
| 50 |
Err : exception renames Ada.IO_Exceptions.End_Error; |
| 51 |
-- Exception raised if insufficient data read (note that the RM implies |
| 52 |
-- that Data_Error might be the appropriate choice, but AI95-00132 |
| 53 |
-- decides with a binding interpretation that End_Error is preferred). |
| 54 |
|
| 55 |
SU : constant := System.Storage_Unit; |
| 56 |
|
| 57 |
subtype SEA is Ada.Streams.Stream_Element_Array; |
| 58 |
subtype SEO is Ada.Streams.Stream_Element_Offset; |
| 59 |
|
| 60 |
generic function UC renames Ada.Unchecked_Conversion; |
| 61 |
|
| 62 |
-- Subtypes used to define Stream_Element_Array values that map |
| 63 |
-- into the elementary types, using unchecked conversion. |
| 64 |
|
| 65 |
Thin_Pointer_Size : constant := System.Address'Size; |
| 66 |
Fat_Pointer_Size : constant := System.Address'Size * 2; |
| 67 |
|
| 68 |
subtype S_AD is SEA (1 .. (Fat_Pointer_Size + SU - 1) / SU); |
| 69 |
subtype S_AS is SEA (1 .. (Thin_Pointer_Size + SU - 1) / SU); |
| 70 |
subtype S_B is SEA (1 .. (Boolean'Size + SU - 1) / SU); |
| 71 |
subtype S_C is SEA (1 .. (Character'Size + SU - 1) / SU); |
| 72 |
subtype S_F is SEA (1 .. (Float'Size + SU - 1) / SU); |
| 73 |
subtype S_I is SEA (1 .. (Integer'Size + SU - 1) / SU); |
| 74 |
subtype S_I24 is SEA (1 .. (Integer_24'Size + SU - 1) / SU); |
| 75 |
subtype S_LF is SEA (1 .. (Long_Float'Size + SU - 1) / SU); |
| 76 |
subtype S_LI is SEA (1 .. (Long_Integer'Size + SU - 1) / SU); |
| 77 |
subtype S_LLF is SEA (1 .. (Long_Long_Float'Size + SU - 1) / SU); |
| 78 |
subtype S_LLI is SEA (1 .. (Long_Long_Integer'Size + SU - 1) / SU); |
| 79 |
subtype S_LLLI is SEA (1 .. (Long_Long_Long_Integer'Size + SU - 1) / SU); |
| 80 |
subtype S_LLLU is |
| 81 |
SEA (1 .. (UST.Long_Long_Long_Unsigned'Size + SU - 1) / SU); |
| 82 |
subtype S_LLU is SEA (1 .. (UST.Long_Long_Unsigned'Size + SU - 1) / SU); |
| 83 |
subtype S_LU is SEA (1 .. (UST.Long_Unsigned'Size + SU - 1) / SU); |
| 84 |
subtype S_SF is SEA (1 .. (Short_Float'Size + SU - 1) / SU); |
| 85 |
subtype S_SI is SEA (1 .. (Short_Integer'Size + SU - 1) / SU); |
| 86 |
subtype S_SSI is SEA (1 .. (Short_Short_Integer'Size + SU - 1) / SU); |
| 87 |
subtype S_SSU is SEA (1 .. (UST.Short_Short_Unsigned'Size + SU - 1) / SU); |
| 88 |
subtype S_SU is SEA (1 .. (UST.Short_Unsigned'Size + SU - 1) / SU); |
| 89 |
subtype S_U is SEA (1 .. (UST.Unsigned'Size + SU - 1) / SU); |
| 90 |
subtype S_U24 is SEA (1 .. (Unsigned_24'Size + SU - 1) / SU); |
| 91 |
subtype S_WC is SEA (1 .. (Wide_Character'Size + SU - 1) / SU); |
| 92 |
subtype S_WWC is SEA (1 .. (Wide_Wide_Character'Size + SU - 1) / SU); |
| 93 |
|
| 94 |
-- Unchecked conversions from the elementary type to the stream type |
| 95 |
|
| 96 |
function From_AD is new UC (Fat_Pointer, S_AD); |
| 97 |
function From_AS is new UC (Thin_Pointer, S_AS); |
| 98 |
function From_F is new UC (Float, S_F); |
| 99 |
function From_I is new UC (Integer, S_I); |
| 100 |
function From_I24 is new UC (Integer_24, S_I24); |
| 101 |
function From_LF is new UC (Long_Float, S_LF); |
| 102 |
function From_LI is new UC (Long_Integer, S_LI); |
| 103 |
function From_LLF is new UC (Long_Long_Float, S_LLF); |
| 104 |
function From_LLI is new UC (Long_Long_Integer, S_LLI); |
| 105 |
function From_LLLI is new UC (Long_Long_Long_Integer, S_LLLI); |
| 106 |
function From_LLLU is new UC (UST.Long_Long_Long_Unsigned, S_LLLU); |
| 107 |
function From_LLU is new UC (UST.Long_Long_Unsigned, S_LLU); |
| 108 |
function From_LU is new UC (UST.Long_Unsigned, S_LU); |
| 109 |
function From_SF is new UC (Short_Float, S_SF); |
| 110 |
function From_SI is new UC (Short_Integer, S_SI); |
| 111 |
function From_SSI is new UC (Short_Short_Integer, S_SSI); |
| 112 |
function From_SSU is new UC (UST.Short_Short_Unsigned, S_SSU); |
| 113 |
function From_SU is new UC (UST.Short_Unsigned, S_SU); |
| 114 |
function From_U is new UC (UST.Unsigned, S_U); |
| 115 |
function From_U24 is new UC (Unsigned_24, S_U24); |
| 116 |
function From_WC is new UC (Wide_Character, S_WC); |
| 117 |
function From_WWC is new UC (Wide_Wide_Character, S_WWC); |
| 118 |
|
| 119 |
-- Unchecked conversions from the stream type to elementary type |
| 120 |
|
| 121 |
function To_AD is new UC (S_AD, Fat_Pointer); |
| 122 |
function To_AS is new UC (S_AS, Thin_Pointer); |
| 123 |
function To_F is new UC (S_F, Float); |
| 124 |
function To_I is new UC (S_I, Integer); |
| 125 |
function To_I24 is new UC (S_I24, Integer_24); |
| 126 |
function To_LF is new UC (S_LF, Long_Float); |
| 127 |
function To_LI is new UC (S_LI, Long_Integer); |
| 128 |
function To_LLF is new UC (S_LLF, Long_Long_Float); |
| 129 |
function To_LLI is new UC (S_LLI, Long_Long_Integer); |
| 130 |
function To_LLLI is new UC (S_LLLI, Long_Long_Long_Integer); |
| 131 |
function To_LLLU is new UC (S_LLLU, UST.Long_Long_Long_Unsigned); |
| 132 |
function To_LLU is new UC (S_LLU, UST.Long_Long_Unsigned); |
| 133 |
function To_LU is new UC (S_LU, UST.Long_Unsigned); |
| 134 |
function To_SF is new UC (S_SF, Short_Float); |
| 135 |
function To_SI is new UC (S_SI, Short_Integer); |
| 136 |
function To_SSI is new UC (S_SSI, Short_Short_Integer); |
| 137 |
function To_SSU is new UC (S_SSU, UST.Short_Short_Unsigned); |
| 138 |
function To_SU is new UC (S_SU, UST.Short_Unsigned); |
| 139 |
function To_U is new UC (S_U, UST.Unsigned); |
| 140 |
function To_U24 is new UC (S_U24, Unsigned_24); |
| 141 |
function To_WC is new UC (S_WC, Wide_Character); |
| 142 |
function To_WWC is new UC (S_WWC, Wide_Wide_Character); |
| 143 |
|
| 144 |
----------------- |
| 145 |
-- Block_IO_OK -- |
| 146 |
----------------- |
| 147 |
|
| 148 |
function Block_IO_OK return Boolean is |
| 149 |
begin |
| 150 |
return not XDR_Support; |
| 151 |
end Block_IO_OK; |
| 152 |
|
| 153 |
---------- |
| 154 |
-- I_AD -- |
| 155 |
---------- |
| 156 |
|
| 157 |
function I_AD (Stream : not null access RST) return Fat_Pointer is |
| 158 |
T : S_AD; |
| 159 |
L : SEO; |
| 160 |
|
| 161 |
begin |
| 162 |
if XDR_Support then |
| 163 |
return XDR.I_AD (Stream); |
| 164 |
end if; |
| 165 |
|
| 166 |
Ada.Streams.Read (Stream.all, T, L); |
| 167 |
|
| 168 |
if L < T'Last then |
| 169 |
raise Err; |
| 170 |
else |
| 171 |
return To_AD (T); |
| 172 |
end if; |
| 173 |
end I_AD; |
| 174 |
|
| 175 |
---------- |
| 176 |
-- I_AS -- |
| 177 |
---------- |
| 178 |
|
| 179 |
function I_AS (Stream : not null access RST) return Thin_Pointer is |
| 180 |
T : S_AS; |
| 181 |
L : SEO; |
| 182 |
|
| 183 |
begin |
| 184 |
if XDR_Support then |
| 185 |
return XDR.I_AS (Stream); |
| 186 |
end if; |
| 187 |
|
| 188 |
Ada.Streams.Read (Stream.all, T, L); |
| 189 |
|
| 190 |
if L < T'Last then |
| 191 |
raise Err; |
| 192 |
else |
| 193 |
return To_AS (T); |
| 194 |
end if; |
| 195 |
end I_AS; |
| 196 |
|
| 197 |
--------- |
| 198 |
-- I_B -- |
| 199 |
--------- |
| 200 |
|
| 201 |
function I_B (Stream : not null access RST) return Boolean is |
| 202 |
T : S_B; |
| 203 |
L : SEO; |
| 204 |
|
| 205 |
begin |
| 206 |
if XDR_Support then |
| 207 |
return XDR.I_B (Stream); |
| 208 |
end if; |
| 209 |
|
| 210 |
Ada.Streams.Read (Stream.all, T, L); |
| 211 |
|
| 212 |
if L < T'Last then |
| 213 |
raise Err; |
| 214 |
else |
| 215 |
return Boolean'Val (T (1)); |
| 216 |
end if; |
| 217 |
end I_B; |
| 218 |
|
| 219 |
--------- |
| 220 |
-- I_C -- |
| 221 |
--------- |
| 222 |
|
| 223 |
function I_C (Stream : not null access RST) return Character is |
| 224 |
T : S_C; |
| 225 |
L : SEO; |
| 226 |
|
| 227 |
begin |
| 228 |
if XDR_Support then |
| 229 |
return XDR.I_C (Stream); |
| 230 |
end if; |
| 231 |
|
| 232 |
Ada.Streams.Read (Stream.all, T, L); |
| 233 |
|
| 234 |
if L < T'Last then |
| 235 |
raise Err; |
| 236 |
else |
| 237 |
return Character'Val (T (1)); |
| 238 |
end if; |
| 239 |
end I_C; |
| 240 |
|
| 241 |
--------- |
| 242 |
-- I_F -- |
| 243 |
--------- |
| 244 |
|
| 245 |
function I_F (Stream : not null access RST) return Float is |
| 246 |
T : S_F; |
| 247 |
L : SEO; |
| 248 |
|
| 249 |
begin |
| 250 |
if XDR_Support then |
| 251 |
return XDR.I_F (Stream); |
| 252 |
end if; |
| 253 |
|
| 254 |
Ada.Streams.Read (Stream.all, T, L); |
| 255 |
|
| 256 |
if L < T'Last then |
| 257 |
raise Err; |
| 258 |
else |
| 259 |
return To_F (T); |
| 260 |
end if; |
| 261 |
end I_F; |
| 262 |
|
| 263 |
--------- |
| 264 |
-- I_I -- |
| 265 |
--------- |
| 266 |
|
| 267 |
function I_I (Stream : not null access RST) return Integer is |
| 268 |
T : S_I; |
| 269 |
L : SEO; |
| 270 |
|
| 271 |
begin |
| 272 |
if XDR_Support then |
| 273 |
return XDR.I_I (Stream); |
| 274 |
end if; |
| 275 |
|
| 276 |
Ada.Streams.Read (Stream.all, T, L); |
| 277 |
|
| 278 |
if L < T'Last then |
| 279 |
raise Err; |
| 280 |
else |
| 281 |
return To_I (T); |
| 282 |
end if; |
| 283 |
end I_I; |
| 284 |
|
| 285 |
----------- |
| 286 |
-- I_I24 -- |
| 287 |
----------- |
| 288 |
|
| 289 |
function I_I24 (Stream : not null access RST) return Integer_24 is |
| 290 |
T : S_I24; |
| 291 |
L : SEO; |
| 292 |
|
| 293 |
begin |
| 294 |
if XDR_Support then |
| 295 |
return XDR.I_I24 (Stream); |
| 296 |
end if; |
| 297 |
|
| 298 |
Ada.Streams.Read (Stream.all, T, L); |
| 299 |
|
| 300 |
if L < T'Last then |
| 301 |
raise Err; |
| 302 |
else |
| 303 |
return To_I24 (T); |
| 304 |
end if; |
| 305 |
end I_I24; |
| 306 |
|
| 307 |
---------- |
| 308 |
-- I_LF -- |
| 309 |
---------- |
| 310 |
|
| 311 |
function I_LF (Stream : not null access RST) return Long_Float is |
| 312 |
T : S_LF; |
| 313 |
L : SEO; |
| 314 |
|
| 315 |
begin |
| 316 |
if XDR_Support then |
| 317 |
return XDR.I_LF (Stream); |
| 318 |
end if; |
| 319 |
|
| 320 |
Ada.Streams.Read (Stream.all, T, L); |
| 321 |
|
| 322 |
if L < T'Last then |
| 323 |
raise Err; |
| 324 |
else |
| 325 |
return To_LF (T); |
| 326 |
end if; |
| 327 |
end I_LF; |
| 328 |
|
| 329 |
---------- |
| 330 |
-- I_LI -- |
| 331 |
---------- |
| 332 |
|
| 333 |
function I_LI (Stream : not null access RST) return Long_Integer is |
| 334 |
T : S_LI; |
| 335 |
L : SEO; |
| 336 |
|
| 337 |
begin |
| 338 |
if XDR_Support then |
| 339 |
return XDR.I_LI (Stream); |
| 340 |
end if; |
| 341 |
|
| 342 |
Ada.Streams.Read (Stream.all, T, L); |
| 343 |
|
| 344 |
if L < T'Last then |
| 345 |
raise Err; |
| 346 |
else |
| 347 |
return To_LI (T); |
| 348 |
end if; |
| 349 |
end I_LI; |
| 350 |
|
| 351 |
----------- |
| 352 |
-- I_LLF -- |
| 353 |
----------- |
| 354 |
|
| 355 |
function I_LLF (Stream : not null access RST) return Long_Long_Float is |
| 356 |
T : S_LLF; |
| 357 |
L : SEO; |
| 358 |
|
| 359 |
begin |
| 360 |
if XDR_Support then |
| 361 |
return XDR.I_LLF (Stream); |
| 362 |
end if; |
| 363 |
|
| 364 |
Ada.Streams.Read (Stream.all, T, L); |
| 365 |
|
| 366 |
if L < T'Last then |
| 367 |
raise Err; |
| 368 |
else |
| 369 |
return To_LLF (T); |
| 370 |
end if; |
| 371 |
end I_LLF; |
| 372 |
|
| 373 |
----------- |
| 374 |
-- I_LLI -- |
| 375 |
----------- |
| 376 |
|
| 377 |
function I_LLI (Stream : not null access RST) return Long_Long_Integer is |
| 378 |
T : S_LLI; |
| 379 |
L : SEO; |
| 380 |
|
| 381 |
begin |
| 382 |
if XDR_Support then |
| 383 |
return XDR.I_LLI (Stream); |
| 384 |
end if; |
| 385 |
|
| 386 |
Ada.Streams.Read (Stream.all, T, L); |
| 387 |
|
| 388 |
if L < T'Last then |
| 389 |
raise Err; |
| 390 |
else |
| 391 |
return To_LLI (T); |
| 392 |
end if; |
| 393 |
end I_LLI; |
| 394 |
|
| 395 |
------------ |
| 396 |
-- I_LLLI -- |
| 397 |
------------ |
| 398 |
|
| 399 |
function I_LLLI (Stream : not null access RST) return Long_Long_Long_Integer |
| 400 |
is |
| 401 |
T : S_LLLI; |
| 402 |
L : SEO; |
| 403 |
|
| 404 |
begin |
| 405 |
if XDR_Support then |
| 406 |
raise Ada.IO_Exceptions.Device_Error; |
| 407 |
end if; |
| 408 |
|
| 409 |
Ada.Streams.Read (Stream.all, T, L); |
| 410 |
|
| 411 |
if L < T'Last then |
| 412 |
raise Err; |
| 413 |
else |
| 414 |
return To_LLLI (T); |
| 415 |
end if; |
| 416 |
end I_LLLI; |
| 417 |
|
| 418 |
------------ |
| 419 |
-- I_LLLU -- |
| 420 |
------------ |
| 421 |
|
| 422 |
function I_LLLU |
| 423 |
(Stream : not null access RST) return UST.Long_Long_Long_Unsigned |
| 424 |
is |
| 425 |
T : S_LLLU; |
| 426 |
L : SEO; |
| 427 |
|
| 428 |
begin |
| 429 |
if XDR_Support then |
| 430 |
raise Ada.IO_Exceptions.Device_Error; |
| 431 |
end if; |
| 432 |
|
| 433 |
Ada.Streams.Read (Stream.all, T, L); |
| 434 |
|
| 435 |
if L < T'Last then |
| 436 |
raise Err; |
| 437 |
else |
| 438 |
return To_LLLU (T); |
| 439 |
end if; |
| 440 |
end I_LLLU; |
| 441 |
|
| 442 |
----------- |
| 443 |
-- I_LLU -- |
| 444 |
----------- |
| 445 |
|
| 446 |
function I_LLU |
| 447 |
(Stream : not null access RST) return UST.Long_Long_Unsigned |
| 448 |
is |
| 449 |
T : S_LLU; |
| 450 |
L : SEO; |
| 451 |
|
| 452 |
begin |
| 453 |
if XDR_Support then |
| 454 |
return XDR.I_LLU (Stream); |
| 455 |
end if; |
| 456 |
|
| 457 |
Ada.Streams.Read (Stream.all, T, L); |
| 458 |
|
| 459 |
if L < T'Last then |
| 460 |
raise Err; |
| 461 |
else |
| 462 |
return To_LLU (T); |
| 463 |
end if; |
| 464 |
end I_LLU; |
| 465 |
|
| 466 |
---------- |
| 467 |
-- I_LU -- |
| 468 |
---------- |
| 469 |
|
| 470 |
function I_LU (Stream : not null access RST) return UST.Long_Unsigned is |
| 471 |
T : S_LU; |
| 472 |
L : SEO; |
| 473 |
|
| 474 |
begin |
| 475 |
if XDR_Support then |
| 476 |
return XDR.I_LU (Stream); |
| 477 |
end if; |
| 478 |
|
| 479 |
Ada.Streams.Read (Stream.all, T, L); |
| 480 |
|
| 481 |
if L < T'Last then |
| 482 |
raise Err; |
| 483 |
else |
| 484 |
return To_LU (T); |
| 485 |
end if; |
| 486 |
end I_LU; |
| 487 |
|
| 488 |
---------- |
| 489 |
-- I_SF -- |
| 490 |
---------- |
| 491 |
|
| 492 |
function I_SF (Stream : not null access RST) return Short_Float is |
| 493 |
T : S_SF; |
| 494 |
L : SEO; |
| 495 |
|
| 496 |
begin |
| 497 |
if XDR_Support then |
| 498 |
return XDR.I_SF (Stream); |
| 499 |
end if; |
| 500 |
|
| 501 |
Ada.Streams.Read (Stream.all, T, L); |
| 502 |
|
| 503 |
if L < T'Last then |
| 504 |
raise Err; |
| 505 |
else |
| 506 |
return To_SF (T); |
| 507 |
end if; |
| 508 |
end I_SF; |
| 509 |
|
| 510 |
---------- |
| 511 |
-- I_SI -- |
| 512 |
---------- |
| 513 |
|
| 514 |
function I_SI (Stream : not null access RST) return Short_Integer is |
| 515 |
T : S_SI; |
| 516 |
L : SEO; |
| 517 |
|
| 518 |
begin |
| 519 |
if XDR_Support then |
| 520 |
return XDR.I_SI (Stream); |
| 521 |
end if; |
| 522 |
|
| 523 |
Ada.Streams.Read (Stream.all, T, L); |
| 524 |
|
| 525 |
if L < T'Last then |
| 526 |
raise Err; |
| 527 |
else |
| 528 |
return To_SI (T); |
| 529 |
end if; |
| 530 |
end I_SI; |
| 531 |
|
| 532 |
----------- |
| 533 |
-- I_SSI -- |
| 534 |
----------- |
| 535 |
|
| 536 |
function I_SSI (Stream : not null access RST) return Short_Short_Integer is |
| 537 |
T : S_SSI; |
| 538 |
L : SEO; |
| 539 |
|
| 540 |
begin |
| 541 |
if XDR_Support then |
| 542 |
return XDR.I_SSI (Stream); |
| 543 |
end if; |
| 544 |
|
| 545 |
Ada.Streams.Read (Stream.all, T, L); |
| 546 |
|
| 547 |
if L < T'Last then |
| 548 |
raise Err; |
| 549 |
else |
| 550 |
return To_SSI (T); |
| 551 |
end if; |
| 552 |
end I_SSI; |
| 553 |
|
| 554 |
----------- |
| 555 |
-- I_SSU -- |
| 556 |
----------- |
| 557 |
|
| 558 |
function I_SSU |
| 559 |
(Stream : not null access RST) return UST.Short_Short_Unsigned |
| 560 |
is |
| 561 |
T : S_SSU; |
| 562 |
L : SEO; |
| 563 |
|
| 564 |
begin |
| 565 |
if XDR_Support then |
| 566 |
return XDR.I_SSU (Stream); |
| 567 |
end if; |
| 568 |
|
| 569 |
Ada.Streams.Read (Stream.all, T, L); |
| 570 |
|
| 571 |
if L < T'Last then |
| 572 |
raise Err; |
| 573 |
else |
| 574 |
return To_SSU (T); |
| 575 |
end if; |
| 576 |
end I_SSU; |
| 577 |
|
| 578 |
---------- |
| 579 |
-- I_SU -- |
| 580 |
---------- |
| 581 |
|
| 582 |
function I_SU (Stream : not null access RST) return UST.Short_Unsigned is |
| 583 |
T : S_SU; |
| 584 |
L : SEO; |
| 585 |
|
| 586 |
begin |
| 587 |
if XDR_Support then |
| 588 |
return XDR.I_SU (Stream); |
| 589 |
end if; |
| 590 |
|
| 591 |
Ada.Streams.Read (Stream.all, T, L); |
| 592 |
|
| 593 |
if L < T'Last then |
| 594 |
raise Err; |
| 595 |
else |
| 596 |
return To_SU (T); |
| 597 |
end if; |
| 598 |
end I_SU; |
| 599 |
|
| 600 |
--------- |
| 601 |
-- I_U -- |
| 602 |
--------- |
| 603 |
|
| 604 |
function I_U (Stream : not null access RST) return UST.Unsigned is |
| 605 |
T : S_U; |
| 606 |
L : SEO; |
| 607 |
|
| 608 |
begin |
| 609 |
if XDR_Support then |
| 610 |
return XDR.I_U (Stream); |
| 611 |
end if; |
| 612 |
|
| 613 |
Ada.Streams.Read (Stream.all, T, L); |
| 614 |
|
| 615 |
if L < T'Last then |
| 616 |
raise Err; |
| 617 |
else |
| 618 |
return To_U (T); |
| 619 |
end if; |
| 620 |
end I_U; |
| 621 |
|
| 622 |
----------- |
| 623 |
-- I_U24 -- |
| 624 |
----------- |
| 625 |
|
| 626 |
function I_U24 (Stream : not null access RST) return Unsigned_24 is |
| 627 |
T : S_U24; |
| 628 |
L : SEO; |
| 629 |
|
| 630 |
begin |
| 631 |
if XDR_Support then |
| 632 |
return XDR.I_U24 (Stream); |
| 633 |
end if; |
| 634 |
|
| 635 |
Ada.Streams.Read (Stream.all, T, L); |
| 636 |
|
| 637 |
if L < T'Last then |
| 638 |
raise Err; |
| 639 |
else |
| 640 |
return To_U24 (T); |
| 641 |
end if; |
| 642 |
end I_U24; |
| 643 |
|
| 644 |
---------- |
| 645 |
-- I_WC -- |
| 646 |
---------- |
| 647 |
|
| 648 |
function I_WC (Stream : not null access RST) return Wide_Character is |
| 649 |
T : S_WC; |
| 650 |
L : SEO; |
| 651 |
|
| 652 |
begin |
| 653 |
if XDR_Support then |
| 654 |
return XDR.I_WC (Stream); |
| 655 |
end if; |
| 656 |
|
| 657 |
Ada.Streams.Read (Stream.all, T, L); |
| 658 |
|
| 659 |
if L < T'Last then |
| 660 |
raise Err; |
| 661 |
else |
| 662 |
return To_WC (T); |
| 663 |
end if; |
| 664 |
end I_WC; |
| 665 |
|
| 666 |
----------- |
| 667 |
-- I_WWC -- |
| 668 |
----------- |
| 669 |
|
| 670 |
function I_WWC (Stream : not null access RST) return Wide_Wide_Character is |
| 671 |
T : S_WWC; |
| 672 |
L : SEO; |
| 673 |
|
| 674 |
begin |
| 675 |
if XDR_Support then |
| 676 |
return XDR.I_WWC (Stream); |
| 677 |
end if; |
| 678 |
|
| 679 |
Ada.Streams.Read (Stream.all, T, L); |
| 680 |
|
| 681 |
if L < T'Last then |
| 682 |
raise Err; |
| 683 |
else |
| 684 |
return To_WWC (T); |
| 685 |
end if; |
| 686 |
end I_WWC; |
| 687 |
|
| 688 |
---------- |
| 689 |
-- W_AD -- |
| 690 |
---------- |
| 691 |
|
| 692 |
procedure W_AD (Stream : not null access RST; Item : Fat_Pointer) is |
| 693 |
T : constant S_AD := From_AD (Item); |
| 694 |
begin |
| 695 |
if XDR_Support then |
| 696 |
XDR.W_AD (Stream, Item); |
| 697 |
return; |
| 698 |
end if; |
| 699 |
|
| 700 |
Ada.Streams.Write (Stream.all, T); |
| 701 |
end W_AD; |
| 702 |
|
| 703 |
---------- |
| 704 |
-- W_AS -- |
| 705 |
---------- |
| 706 |
|
| 707 |
procedure W_AS (Stream : not null access RST; Item : Thin_Pointer) is |
| 708 |
T : constant S_AS := From_AS (Item); |
| 709 |
begin |
| 710 |
if XDR_Support then |
| 711 |
XDR.W_AS (Stream, Item); |
| 712 |
return; |
| 713 |
end if; |
| 714 |
|
| 715 |
Ada.Streams.Write (Stream.all, T); |
| 716 |
end W_AS; |
| 717 |
|
| 718 |
--------- |
| 719 |
-- W_B -- |
| 720 |
--------- |
| 721 |
|
| 722 |
procedure W_B (Stream : not null access RST; Item : Boolean) is |
| 723 |
T : S_B; |
| 724 |
begin |
| 725 |
if XDR_Support then |
| 726 |
XDR.W_B (Stream, Item); |
| 727 |
return; |
| 728 |
end if; |
| 729 |
|
| 730 |
T (1) := Boolean'Pos (Item); |
| 731 |
Ada.Streams.Write (Stream.all, T); |
| 732 |
end W_B; |
| 733 |
|
| 734 |
--------- |
| 735 |
-- W_C -- |
| 736 |
--------- |
| 737 |
|
| 738 |
procedure W_C (Stream : not null access RST; Item : Character) is |
| 739 |
T : S_C; |
| 740 |
begin |
| 741 |
if XDR_Support then |
| 742 |
XDR.W_C (Stream, Item); |
| 743 |
return; |
| 744 |
end if; |
| 745 |
|
| 746 |
T (1) := Character'Pos (Item); |
| 747 |
Ada.Streams.Write (Stream.all, T); |
| 748 |
end W_C; |
| 749 |
|
| 750 |
--------- |
| 751 |
-- W_F -- |
| 752 |
--------- |
| 753 |
|
| 754 |
procedure W_F (Stream : not null access RST; Item : Float) is |
| 755 |
begin |
| 756 |
if XDR_Support then |
| 757 |
XDR.W_F (Stream, Item); |
| 758 |
return; |
| 759 |
end if; |
| 760 |
|
| 761 |
Ada.Streams.Write (Stream.all, From_F (Item)); |
| 762 |
end W_F; |
| 763 |
|
| 764 |
--------- |
| 765 |
-- W_I -- |
| 766 |
--------- |
| 767 |
|
| 768 |
procedure W_I (Stream : not null access RST; Item : Integer) is |
| 769 |
begin |
| 770 |
if XDR_Support then |
| 771 |
XDR.W_I (Stream, Item); |
| 772 |
return; |
| 773 |
end if; |
| 774 |
|
| 775 |
Ada.Streams.Write (Stream.all, From_I (Item)); |
| 776 |
end W_I; |
| 777 |
|
| 778 |
----------- |
| 779 |
-- W_I24 -- |
| 780 |
----------- |
| 781 |
|
| 782 |
procedure W_I24 (Stream : not null access RST; Item : Integer_24) is |
| 783 |
begin |
| 784 |
if XDR_Support then |
| 785 |
XDR.W_I24 (Stream, Item); |
| 786 |
return; |
| 787 |
end if; |
| 788 |
|
| 789 |
Ada.Streams.Write (Stream.all, From_I24 (Item)); |
| 790 |
end W_I24; |
| 791 |
|
| 792 |
---------- |
| 793 |
-- W_LF -- |
| 794 |
---------- |
| 795 |
|
| 796 |
procedure W_LF (Stream : not null access RST; Item : Long_Float) is |
| 797 |
begin |
| 798 |
if XDR_Support then |
| 799 |
XDR.W_LF (Stream, Item); |
| 800 |
return; |
| 801 |
end if; |
| 802 |
|
| 803 |
Ada.Streams.Write (Stream.all, From_LF (Item)); |
| 804 |
end W_LF; |
| 805 |
|
| 806 |
---------- |
| 807 |
-- W_LI -- |
| 808 |
---------- |
| 809 |
|
| 810 |
procedure W_LI (Stream : not null access RST; Item : Long_Integer) is |
| 811 |
begin |
| 812 |
if XDR_Support then |
| 813 |
XDR.W_LI (Stream, Item); |
| 814 |
return; |
| 815 |
end if; |
| 816 |
|
| 817 |
Ada.Streams.Write (Stream.all, From_LI (Item)); |
| 818 |
end W_LI; |
| 819 |
|
| 820 |
----------- |
| 821 |
-- W_LLF -- |
| 822 |
----------- |
| 823 |
|
| 824 |
procedure W_LLF (Stream : not null access RST; Item : Long_Long_Float) is |
| 825 |
begin |
| 826 |
if XDR_Support then |
| 827 |
XDR.W_LLF (Stream, Item); |
| 828 |
return; |
| 829 |
end if; |
| 830 |
|
| 831 |
Ada.Streams.Write (Stream.all, From_LLF (Item)); |
| 832 |
end W_LLF; |
| 833 |
|
| 834 |
----------- |
| 835 |
-- W_LLI -- |
| 836 |
----------- |
| 837 |
|
| 838 |
procedure W_LLI (Stream : not null access RST; Item : Long_Long_Integer) is |
| 839 |
begin |
| 840 |
if XDR_Support then |
| 841 |
XDR.W_LLI (Stream, Item); |
| 842 |
return; |
| 843 |
end if; |
| 844 |
|
| 845 |
Ada.Streams.Write (Stream.all, From_LLI (Item)); |
| 846 |
end W_LLI; |
| 847 |
|
| 848 |
------------ |
| 849 |
-- W_LLLI -- |
| 850 |
------------ |
| 851 |
|
| 852 |
procedure W_LLLI |
| 853 |
(Stream : not null access RST; Item : Long_Long_Long_Integer) is |
| 854 |
begin |
| 855 |
if XDR_Support then |
| 856 |
raise Ada.IO_Exceptions.Device_Error; |
| 857 |
end if; |
| 858 |
|
| 859 |
Ada.Streams.Write (Stream.all, From_LLLI (Item)); |
| 860 |
end W_LLLI; |
| 861 |
|
| 862 |
------------ |
| 863 |
-- W_LLLU -- |
| 864 |
------------ |
| 865 |
|
| 866 |
procedure W_LLLU |
| 867 |
(Stream : not null access RST; Item : UST.Long_Long_Long_Unsigned) |
| 868 |
is |
| 869 |
begin |
| 870 |
if XDR_Support then |
| 871 |
raise Ada.IO_Exceptions.Device_Error; |
| 872 |
end if; |
| 873 |
|
| 874 |
Ada.Streams.Write (Stream.all, From_LLLU (Item)); |
| 875 |
end W_LLLU; |
| 876 |
|
| 877 |
----------- |
| 878 |
-- W_LLU -- |
| 879 |
----------- |
| 880 |
|
| 881 |
procedure W_LLU |
| 882 |
(Stream : not null access RST; Item : UST.Long_Long_Unsigned) |
| 883 |
is |
| 884 |
begin |
| 885 |
if XDR_Support then |
| 886 |
XDR.W_LLU (Stream, Item); |
| 887 |
return; |
| 888 |
end if; |
| 889 |
|
| 890 |
Ada.Streams.Write (Stream.all, From_LLU (Item)); |
| 891 |
end W_LLU; |
| 892 |
|
| 893 |
---------- |
| 894 |
-- W_LU -- |
| 895 |
---------- |
| 896 |
|
| 897 |
procedure W_LU (Stream : not null access RST; Item : UST.Long_Unsigned) is |
| 898 |
begin |
| 899 |
if XDR_Support then |
| 900 |
XDR.W_LU (Stream, Item); |
| 901 |
return; |
| 902 |
end if; |
| 903 |
|
| 904 |
Ada.Streams.Write (Stream.all, From_LU (Item)); |
| 905 |
end W_LU; |
| 906 |
|
| 907 |
---------- |
| 908 |
-- W_SF -- |
| 909 |
---------- |
| 910 |
|
| 911 |
procedure W_SF (Stream : not null access RST; Item : Short_Float) is |
| 912 |
begin |
| 913 |
if XDR_Support then |
| 914 |
XDR.W_SF (Stream, Item); |
| 915 |
return; |
| 916 |
end if; |
| 917 |
|
| 918 |
Ada.Streams.Write (Stream.all, From_SF (Item)); |
| 919 |
end W_SF; |
| 920 |
|
| 921 |
---------- |
| 922 |
-- W_SI -- |
| 923 |
---------- |
| 924 |
|
| 925 |
procedure W_SI (Stream : not null access RST; Item : Short_Integer) is |
| 926 |
begin |
| 927 |
if XDR_Support then |
| 928 |
XDR.W_SI (Stream, Item); |
| 929 |
return; |
| 930 |
end if; |
| 931 |
|
| 932 |
Ada.Streams.Write (Stream.all, From_SI (Item)); |
| 933 |
end W_SI; |
| 934 |
|
| 935 |
----------- |
| 936 |
-- W_SSI -- |
| 937 |
----------- |
| 938 |
|
| 939 |
procedure W_SSI |
| 940 |
(Stream : not null access RST; Item : Short_Short_Integer) |
| 941 |
is |
| 942 |
begin |
| 943 |
if XDR_Support then |
| 944 |
XDR.W_SSI (Stream, Item); |
| 945 |
return; |
| 946 |
end if; |
| 947 |
|
| 948 |
Ada.Streams.Write (Stream.all, From_SSI (Item)); |
| 949 |
end W_SSI; |
| 950 |
|
| 951 |
----------- |
| 952 |
-- W_SSU -- |
| 953 |
----------- |
| 954 |
|
| 955 |
procedure W_SSU |
| 956 |
(Stream : not null access RST; Item : UST.Short_Short_Unsigned) |
| 957 |
is |
| 958 |
begin |
| 959 |
if XDR_Support then |
| 960 |
XDR.W_SSU (Stream, Item); |
| 961 |
return; |
| 962 |
end if; |
| 963 |
|
| 964 |
Ada.Streams.Write (Stream.all, From_SSU (Item)); |
| 965 |
end W_SSU; |
| 966 |
|
| 967 |
---------- |
| 968 |
-- W_SU -- |
| 969 |
---------- |
| 970 |
|
| 971 |
procedure W_SU (Stream : not null access RST; Item : UST.Short_Unsigned) is |
| 972 |
begin |
| 973 |
if XDR_Support then |
| 974 |
XDR.W_SU (Stream, Item); |
| 975 |
return; |
| 976 |
end if; |
| 977 |
|
| 978 |
Ada.Streams.Write (Stream.all, From_SU (Item)); |
| 979 |
end W_SU; |
| 980 |
|
| 981 |
--------- |
| 982 |
-- W_U -- |
| 983 |
--------- |
| 984 |
|
| 985 |
procedure W_U (Stream : not null access RST; Item : UST.Unsigned) is |
| 986 |
begin |
| 987 |
if XDR_Support then |
| 988 |
XDR.W_U (Stream, Item); |
| 989 |
return; |
| 990 |
end if; |
| 991 |
|
| 992 |
Ada.Streams.Write (Stream.all, From_U (Item)); |
| 993 |
end W_U; |
| 994 |
|
| 995 |
----------- |
| 996 |
-- W_U24 -- |
| 997 |
----------- |
| 998 |
|
| 999 |
procedure W_U24 (Stream : not null access RST; Item : Unsigned_24) is |
| 1000 |
begin |
| 1001 |
if XDR_Support then |
| 1002 |
XDR.W_U24 (Stream, Item); |
| 1003 |
return; |
| 1004 |
end if; |
| 1005 |
|
| 1006 |
Ada.Streams.Write (Stream.all, From_U24 (Item)); |
| 1007 |
end W_U24; |
| 1008 |
|
| 1009 |
---------- |
| 1010 |
-- W_WC -- |
| 1011 |
---------- |
| 1012 |
|
| 1013 |
procedure W_WC (Stream : not null access RST; Item : Wide_Character) is |
| 1014 |
begin |
| 1015 |
if XDR_Support then |
| 1016 |
XDR.W_WC (Stream, Item); |
| 1017 |
return; |
| 1018 |
end if; |
| 1019 |
|
| 1020 |
Ada.Streams.Write (Stream.all, From_WC (Item)); |
| 1021 |
end W_WC; |
| 1022 |
|
| 1023 |
----------- |
| 1024 |
-- W_WWC -- |
| 1025 |
----------- |
| 1026 |
|
| 1027 |
procedure W_WWC |
| 1028 |
(Stream : not null access RST; Item : Wide_Wide_Character) |
| 1029 |
is |
| 1030 |
begin |
| 1031 |
if XDR_Support then |
| 1032 |
XDR.W_WWC (Stream, Item); |
| 1033 |
return; |
| 1034 |
end if; |
| 1035 |
|
| 1036 |
Ada.Streams.Write (Stream.all, From_WWC (Item)); |
| 1037 |
end W_WWC; |
| 1038 |
|
| 1039 |
end System.Stream_Attributes; |