* arm.c (FL_WBUF): Define.
[official-gcc.git] / gcc / ada / prj-util.ads
blob894acd82f07080ac2cfb4f06ce66768139e46cea
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-2005 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 2, 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 COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
21 -- --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
24 -- --
25 ------------------------------------------------------------------------------
27 -- Utilities for use in processing project files
29 with Types; use Types;
31 with GNAT.OS_Lib; use GNAT.OS_Lib;
33 package Prj.Util is
35 function Executable_Of
36 (Project : Project_Id;
37 In_Tree : Project_Tree_Ref;
38 Main : Name_Id;
39 Index : Int;
40 Ada_Main : Boolean := True) return Name_Id;
41 -- Return the value of the attribute Builder'Executable for file Main in
42 -- the project Project, if it exists. If there is no attribute Executable
43 -- for Main, remove the suffix from Main; then, if the attribute
44 -- Executable_Suffix is specified, add this suffix, otherwise add the
45 -- standard executable suffix for the platform.
47 function Value_Of
48 (Variable : Variable_Value;
49 Default : String) return String;
50 -- Get the value of a single string variable. If Variable is
51 -- Nil_Variable_Value, is a string list or is defaulted, return Default.
53 function Value_Of
54 (Index : Name_Id;
55 In_Array : Array_Element_Id;
56 In_Tree : Project_Tree_Ref) return Name_Id;
57 -- Get a single string array component. Returns No_Name if there is no
58 -- component Index, if In_Array is null, or if the component is a String
59 -- list. Depending on the attribute (only attributes may be associative
60 -- arrays) the index may or may not be case sensitive. If the index is not
61 -- case sensitive, it is first set to lower case before the search in the
62 -- associative array.
64 function Value_Of
65 (Index : Name_Id;
66 Src_Index : Int := 0;
67 In_Array : Array_Element_Id;
68 In_Tree : Project_Tree_Ref) return Variable_Value;
69 -- Get a string array component (single String or String list).
70 -- Returns Nil_Variable_Value if there is no component Index
71 -- or if In_Array is null.
73 -- Depending on the attribute (only attributes may be associative arrays)
74 -- the index may or may not be case sensitive. If the index is not
75 -- case sensitive, it is first set to lower case before the search
76 -- in the associative array.
78 function Value_Of
79 (Name : Name_Id;
80 Index : Int := 0;
81 Attribute_Or_Array_Name : Name_Id;
82 In_Package : Package_Id;
83 In_Tree : Project_Tree_Ref) return Variable_Value;
84 -- In a specific package,
85 -- - if there exists an array Attribute_Or_Array_Name with an index
86 -- Name, returns the corresponding component (depending on the
87 -- attribute, the index may or may not be case sensitive, see previous
88 -- function),
89 -- - otherwise if there is a single attribute Attribute_Or_Array_Name,
90 -- returns this attribute,
91 -- - otherwise, returns Nil_Variable_Value.
92 -- If In_Package is null, returns Nil_Variable_Value.
94 function Value_Of
95 (Index : Name_Id;
96 In_Array : Name_Id;
97 In_Arrays : Array_Id;
98 In_Tree : Project_Tree_Ref) return Name_Id;
99 -- Get a string array component in an array of an array list.
100 -- Returns No_Name if there is no component Index, if In_Arrays is null, if
101 -- In_Array is not found in In_Arrays or if the component is a String list.
103 function Value_Of
104 (Name : Name_Id;
105 In_Arrays : Array_Id;
106 In_Tree : Project_Tree_Ref) return Array_Element_Id;
107 -- Returns a specified array in an array list. Returns No_Array_Element
108 -- if In_Arrays is null or if Name is not the name of an array in
109 -- In_Arrays. The caller must ensure that Name is in lower case.
111 function Value_Of
112 (Name : Name_Id;
113 In_Packages : Package_Id;
114 In_Tree : Project_Tree_Ref) return Package_Id;
115 -- Returns a specified package in a package list. Returns No_Package
116 -- if In_Packages is null or if Name is not the name of a package in
117 -- Package_List. The caller must ensure that Name is in lower case.
119 function Value_Of
120 (Variable_Name : Name_Id;
121 In_Variables : Variable_Id;
122 In_Tree : Project_Tree_Ref) return Variable_Value;
123 -- Returns a specified variable in a variable list. Returns null if
124 -- In_Variables is null or if Variable_Name is not the name of a
125 -- variable in In_Variables. Caller must ensure that Name is lower case.
127 procedure Write_Str
128 (S : String;
129 Max_Length : Positive;
130 Separator : Character);
131 -- Output string S using Output.Write_Str. If S is too long to fit in
132 -- one line of Max_Length, cut it in several lines, using Separator as
133 -- the last character of each line, if possible.
135 type Text_File is limited private;
136 -- Represents a text file. Default is invalid text file.
138 function Is_Valid (File : Text_File) return Boolean;
139 -- Returns True if File designates an open text file that
140 -- has not yet been closed.
142 procedure Open (File : out Text_File; Name : String);
143 -- Open a text file. If this procedure fails, File is invalid.
145 function End_Of_File (File : Text_File) return Boolean;
146 -- Returns True if the end of the text file File has been
147 -- reached. Fails if File is invalid.
149 procedure Get_Line
150 (File : Text_File;
151 Line : out String;
152 Last : out Natural);
153 -- Reads a line from an open text file. Fails if File is invalid.
155 procedure Close (File : in out Text_File);
156 -- Close an open text file. File becomes invalid.
157 -- Fails if File is already invalid.
159 private
161 type Text_File_Data is record
162 FD : File_Descriptor := Invalid_FD;
163 Buffer : String (1 .. 1_000);
164 Buffer_Len : Natural;
165 Cursor : Natural := 0;
166 End_Of_File_Reached : Boolean := False;
167 end record;
169 type Text_File is access Text_File_Data;
171 end Prj.Util;