1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- I N T E R F A C E S . F O R T R A N --
9 -- Copyright (C) 1992-2009, Free Software Foundation, Inc. --
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. --
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. --
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/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 package body Interfaces
.Fortran
is
38 -- Single character case
40 function To_Ada
(Item
: Character_Set
) return Character is
42 return Character (Item
);
45 -- String case (function returning converted result)
47 function To_Ada
(Item
: Fortran_Character
) return String is
48 T
: String (1 .. Item
'Length);
52 T
(J
) := Character (Item
(J
- 1 + Item
'First));
58 -- String case (procedure copying converted string to given buffer)
61 (Item
: Fortran_Character
;
66 if Item
'Length = 0 then
70 elsif Target
'Length = 0 then
71 raise Constraint_Error
;
74 Last
:= Target
'First - 1;
76 for J
in Item
'Range loop
79 if Last
> Target
'Last then
80 raise Constraint_Error
;
82 Target
(Last
) := Character (Item
(J
));
94 function To_Fortran
(Item
: Character) return Character_Set
is
96 return Character_Set
(Item
);
99 -- String case (function returning converted result)
101 function To_Fortran
(Item
: String) return Fortran_Character
is
102 T
: Fortran_Character
(1 .. Item
'Length);
105 for J
in T
'Range loop
106 T
(J
) := Character_Set
(Item
(J
- 1 + Item
'First));
112 -- String case (procedure copying converted string to given buffer)
116 Target
: out Fortran_Character
;
120 if Item
'Length = 0 then
124 elsif Target
'Length = 0 then
125 raise Constraint_Error
;
128 Last
:= Target
'First - 1;
130 for J
in Item
'Range loop
133 if Last
> Target
'Last then
134 raise Constraint_Error
;
136 Target
(Last
) := Character_Set
(Item
(J
));
142 end Interfaces
.Fortran
;