In gcc/testsuite/: 2010-09-30 Nicola Pero <nicola.pero@meta-innovation.com>
[official-gcc.git] / gcc / ada / prj-util.ads
blob3c1ac0a741dcc66576a21b2b219bb7b069119d27
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- P R J . U T I L --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2001-2010, 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. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
20 -- --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
23 -- --
24 ------------------------------------------------------------------------------
26 -- Utilities for use in processing project files
28 package Prj.Util is
30 function Executable_Of
31 (Project : Project_Id;
32 In_Tree : Project_Tree_Ref;
33 Main : File_Name_Type;
34 Index : Int;
35 Ada_Main : Boolean := True;
36 Language : String := "";
37 Include_Suffix : Boolean := True) return File_Name_Type;
38 -- Return the value of the attribute Builder'Executable for file Main in
39 -- the project Project, if it exists. If there is no attribute Executable
40 -- for Main, remove the suffix from Main; then, if the attribute
41 -- Executable_Suffix is specified, add this suffix, otherwise add the
42 -- standard executable suffix for the platform.
44 -- If Include_Suffix is true, then the ".exe" suffix (or any suffix defined
45 -- in the config) will be added. The suffix defined by the user in his own
46 -- project file is always taken into account. Otherwise, such a suffix is
47 -- not added. In particular, the prefix should not be added if you are
48 -- potentially testing for cross-platforms, since the suffix might not be
49 -- known (its default value comes from the ...-gnatmake prefix).
51 -- What is Ada_Main???
52 -- What is Language???
54 procedure Put
55 (Into_List : in out Name_List_Index;
56 From_List : String_List_Id;
57 In_Tree : Project_Tree_Ref;
58 Lower_Case : Boolean := False);
59 -- Append a name list to a string list
60 -- Describe parameters???
62 procedure Duplicate
63 (This : in out Name_List_Index;
64 In_Tree : Project_Tree_Ref);
65 -- Duplicate a name list
67 function Value_Of
68 (Variable : Variable_Value;
69 Default : String) return String;
70 -- Get the value of a single string variable. If Variable is a string list,
71 -- is Nil_Variable_Value,or is defaulted, return Default.
73 function Value_Of
74 (Index : Name_Id;
75 In_Array : Array_Element_Id;
76 In_Tree : Project_Tree_Ref) return Name_Id;
77 -- Get a single string array component. Returns No_Name if there is no
78 -- component Index, if In_Array is null, or if the component is a String
79 -- list. Depending on the attribute (only attributes may be associative
80 -- arrays) the index may or may not be case sensitive. If the index is not
81 -- case sensitive, it is first set to lower case before the search in the
82 -- associative array.
84 function Value_Of
85 (Index : Name_Id;
86 Src_Index : Int := 0;
87 In_Array : Array_Element_Id;
88 In_Tree : Project_Tree_Ref;
89 Force_Lower_Case_Index : Boolean := False) return Variable_Value;
90 -- Get a string array component (single String or String list). Returns
91 -- Nil_Variable_Value if no component Index or if In_Array is null.
93 -- Depending on the attribute (only attributes may be associative arrays)
94 -- the index may or may not be case sensitive. If the index is not case
95 -- sensitive, it is first set to lower case before the search in the
96 -- associative array.
98 function Value_Of
99 (Name : Name_Id;
100 Index : Int := 0;
101 Attribute_Or_Array_Name : Name_Id;
102 In_Package : Package_Id;
103 In_Tree : Project_Tree_Ref;
104 Force_Lower_Case_Index : Boolean := False) return Variable_Value;
105 -- In a specific package,
106 -- - if there exists an array Attribute_Or_Array_Name with an index Name,
107 -- returns the corresponding component (depending on the attribute, the
108 -- index may or may not be case sensitive, see previous function),
109 -- - otherwise if there is a single attribute Attribute_Or_Array_Name,
110 -- returns this attribute,
111 -- - otherwise, returns Nil_Variable_Value.
112 -- If In_Package is null, returns Nil_Variable_Value.
114 function Value_Of
115 (Index : Name_Id;
116 In_Array : Name_Id;
117 In_Arrays : Array_Id;
118 In_Tree : Project_Tree_Ref) return Name_Id;
119 -- Get a string array component in an array of an array list. Returns
120 -- No_Name if there is no component Index, if In_Arrays is null, if
121 -- In_Array is not found in In_Arrays or if the component is a String list.
123 function Value_Of
124 (Name : Name_Id;
125 In_Arrays : Array_Id;
126 In_Tree : Project_Tree_Ref) return Array_Element_Id;
127 -- Returns a specified array in an array list. Returns No_Array_Element
128 -- if In_Arrays is null or if Name is not the name of an array in
129 -- In_Arrays. The caller must ensure that Name is in lower case.
131 function Value_Of
132 (Name : Name_Id;
133 In_Packages : Package_Id;
134 In_Tree : Project_Tree_Ref) return Package_Id;
135 -- Returns a specified package in a package list. Returns No_Package if
136 -- In_Packages is null or if Name is not the name of a package in
137 -- Package_List. The caller must ensure that Name is in lower case.
139 function Value_Of
140 (Variable_Name : Name_Id;
141 In_Variables : Variable_Id;
142 In_Tree : Project_Tree_Ref) return Variable_Value;
143 -- Returns a specified variable in a variable list. Returns null if
144 -- In_Variables is null or if Variable_Name is not the name of a
145 -- variable in In_Variables. Caller must ensure that Name is lower case.
147 procedure Write_Str
148 (S : String;
149 Max_Length : Positive;
150 Separator : Character);
151 -- Output string S using Output.Write_Str. If S is too long to fit in
152 -- one line of Max_Length, cut it in several lines, using Separator as
153 -- the last character of each line, if possible.
155 type Text_File is limited private;
156 -- Represents a text file (default is invalid text file)
158 function Is_Valid (File : Text_File) return Boolean;
159 -- Returns True if File designates an open text file that has not yet been
160 -- closed.
162 procedure Open (File : out Text_File; Name : String);
163 -- Open a text file to read (file is invalid if text file cannot be opened)
165 function End_Of_File (File : Text_File) return Boolean;
166 -- Returns True if the end of the text file File has been reached. Fails if
167 -- File is invalid.
169 procedure Get_Line
170 (File : Text_File;
171 Line : out String;
172 Last : out Natural);
173 -- Reads a line from an open text file (fails if file is invalid)
175 procedure Close (File : in out Text_File);
176 -- Close an open text file. File becomes invalid. Fails if File is already
177 -- invalid.
179 private
181 type Text_File_Data is record
182 FD : File_Descriptor := Invalid_FD;
183 Buffer : String (1 .. 1_000);
184 Buffer_Len : Natural;
185 Cursor : Natural := 0;
186 End_Of_File_Reached : Boolean := False;
187 end record;
189 type Text_File is access Text_File_Data;
191 end Prj.Util;