id
int64
0
30.9k
extension
stringclasses
1 value
max_stars_count
int64
0
17k
max_stars_repo_name
stringlengths
7
106
max_stars_repo_path
stringlengths
5
136
text
stringlengths
9
1M
30,600
ada
9
ajnavarro/language-dataset
data/github.com/onox/orka/328954163d9b0502f35c3d1ec8d868a545e8e205/src/tools/orka_info.adb
<reponame>ajnavarro/language-dataset -- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2013 <NAME> <<EMAIL>> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with Ada.Strings.Unbounded; with Ada.Text_IO; with GL.Context; with GL.Types; with Orka.Contexts; with Orka.Loggers.Terminal; with Orka.Logging; with Orka.Windows.GLFW; procedure Orka_Info is Context : constant Orka.Contexts.Context'Class := Orka.Windows.GLFW.Initialize (Major => 4, Minor => 2); pragma Unreferenced (Context); procedure Display_Context_Information is use Ada.Strings.Unbounded; use Ada.Text_IO; begin Put_Line ("Major version: " & GL.Types.Int'Image (GL.Context.Major_Version)); Put_Line ("Minor version: " & GL.Types.Int'Image (GL.Context.Minor_Version)); Put_Line (" Vendor: " & GL.Context.Vendor); Put_Line ("Renderer: " & GL.Context.Renderer); Put_Line ("OpenGL version: " & GL.Context.Version_String); Put_Line (" GLSL version: " & GL.Context.Primary_Shading_Language_Version); Put_Line ("Extensions: "); for US_Name of GL.Context.Extensions loop declare Name : constant String := To_String (US_Name); begin Put_Line (" " & Name); pragma Assert (GL.Context.Has_Extension (Name)); end; end loop; Put_Line ("Supported shading language versions:"); begin for US_Version of GL.Context.Supported_Shading_Language_Versions loop declare Version : constant String := To_String (US_Version); begin Put_Line (" " & Version); pragma Assert (GL.Context.Supports_Shading_Language_Version (Version)); end; end loop; exception when others => Put_Line ("OpenGL version too old for querying supported versions"); end; end Display_Context_Information; begin Orka.Logging.Set_Logger (Orka.Loggers.Terminal.Create_Logger (Level => Orka.Loggers.Info)); declare W : aliased Orka.Windows.Window'Class := Orka.Windows.GLFW.Create_Window (1, 1, Visible => False); pragma Unreferenced (W); begin Display_Context_Information; end; end Orka_Info;
30,601
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/dynamic_elab_pkg.ads
package Dynamic_Elab_Pkg is type R is record Code : Integer; Val : Boolean; end record; function Get_R return R; end Dynamic_Elab_Pkg;
30,602
ada
20
charlie5/lace
3-mid/opengl/source/lean/opengl-texture-coordinates.adb
<gh_stars>10-100 package body openGL.Texture.Coordinates is overriding function to_Coordinates (Self : in xz_Generator; the_Vertices : access Sites) return Coordinates_2D is the_Coords : Coordinates_2D (1 .. the_Vertices'Length); begin for Each in the_Coords'Range loop declare the_Vertex : Site renames the_Vertices (Each); S, T : Real; begin -- Normalise. -- S := ( the_Vertex (1) + Self.Normalise.S.Offset) * Self.Normalise.S.Scale; T := 1.0 - ( the_Vertex (3) + Self.Normalise.T.Offset) * Self.Normalise.T.Scale; -- Tile. -- S := (S + Self.Tile.S.Offset) * Self.Tile.S.Scale; T := (T + Self.Tile.T.Offset) * Self.Tile.T.Scale; the_Coords (Each).S := S; the_Coords (Each).T := T; end; end loop; return the_Coords; end to_Coordinates; overriding function to_Coordinates (Self : in xy_Generator; the_Vertices : access Sites) return Coordinates_2D is the_Coords : Coordinates_2D (1 .. the_Vertices'Length); begin for Each in the_Coords'Range loop declare the_Vertex : Site renames the_Vertices (Index_t (Each)); S, T : Real; begin -- Normalise. -- S := (the_Vertex (1) + Self.Normalise.S.Offset) * Self.Normalise.S.Scale; T := 1.0 - ( the_Vertex (2) + Self.Normalise.T.Offset) * Self.Normalise.T.Scale; -- Tile. -- S := (S + Self.Tile.S.Offset) * Self.Tile.S.Scale; T := (T + Self.Tile.T.Offset) * Self.Tile.T.Scale; the_Coords (Each).S := S; the_Coords (Each).T := T; end; end loop; return the_Coords; end to_Coordinates; overriding function to_Coordinates (Self : in zy_Generator; the_Vertices : access Sites) return Coordinates_2D is the_Coords : Coordinates_2D (1 .. the_Vertices'Length); begin for Each in the_Coords'Range loop declare the_Vertex : Site renames the_Vertices (Index_t (Each)); S, T : Real; begin -- Normalise. -- S := (the_Vertex (3) + Self.Normalise.S.Offset) * Self.Normalise.S.Scale; T := 1.0 - ( the_Vertex (2) + Self.Normalise.T.Offset) * Self.Normalise.T.Scale; -- Tile. -- S := (S + Self.Tile.S.Offset) * Self.Tile.S.Scale; T := (T + Self.Tile.T.Offset) * Self.Tile.T.Scale; the_Coords (Each).S := S; the_Coords (Each).T := T; end; end loop; return the_Coords; end to_Coordinates; -- TODO: - Below does not cater for 'right edge' case where 's' should be -- 1.0 rather than 0.0 -- -- - Would be possible given a known set of vertices -- ie - First vertex is North Pole, -- - Last vertex is South Pole, -- - Middle vertices are a set of latitude rings. -- - Each rings first vertex site should map s => 0.0 -- - Each rings last vertex is a duplicate of the first and -- will be mapped to s => 1.0 -- overriding function to_Coordinates (Self : in mercator_Generator; the_Vertices : access Sites) return Coordinates_2D is pragma Unreferenced (Self); the_Coords : Coordinates_2D (1 .. the_Vertices'Length); begin for Each in the_Coords'Range loop declare use real_Functions; the_Vertex : Site renames the_Vertices (Index_t (Each)); x : Real renames the_Vertex (1); y : Real renames the_Vertex (2); z : Real renames the_Vertex (3); Degrees_90 : constant := Pi / 2.0; Degrees_180 : constant := Pi; Radius : constant Real := SqRt (x * x + y * y + z * z); Latitude : constant Real := arcSin (y / Radius); Longitude : Real; begin if z = 0.0 and then x = 0.0 then the_Coords (Each).S := 0.5; else Longitude := arcTan (-z, x); the_Coords (Each).S := (Longitude / Degrees_180 + 1.0) / 2.0; end if; the_Coords (Each).T := (Latitude / Degrees_90 + 1.0) / 2.0; end; end loop; return the_Coords; end to_Coordinates; end openGL.Texture.Coordinates;
30,603
ada
4
faelys/gela-asis
contrib/ayacc/src/lexical_analyzer.adb
-- Copyright (c) 1990 Regents of the University of California. -- All rights reserved. -- -- The primary authors of ayacc were <NAME> and <NAME>. -- Enhancements were made by <NAME>. -- -- Send requests for ayacc information to <EMAIL> -- Send bug reports for ayacc to <EMAIL> -- -- Redistribution and use in source and binary forms are permitted -- provided that the above copyright notice and this paragraph are -- duplicated in all such forms and that any documentation, -- advertising materials, and other materials related to such -- distribution and use acknowledge that the software was developed -- by the University of California, Irvine. The name of the -- University may not be used to endorse or promote products derived -- from this software without specific prior written permission. -- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR -- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. -- Module : lexical_analyzer_body.ada -- Component of : ayacc -- Version : 1.2 -- Date : 11/21/86 12:30:42 -- SCCS File : disk21~/rschm/hasee/sccs/ayacc/sccs/sxlexical_analyzer_body.ada -- $Header: lexical_analyzer_body.a,v 0.1 86/04/01 15:05:27 ada Exp $ -- $Log: lexical_analyzer_body.a,v $ -- Revision 0.1 86/04/01 15:05:27 ada -- This version fixes some minor bugs with empty grammars -- and $$ expansion. It also uses vads5.1b enhancements -- such as pragma inline. -- -- -- Revision 0.0 86/02/19 18:37:05 ada -- -- These files comprise the initial version of Ayacc -- designed and implemented by <NAME> and <NAME>. -- Ayacc has been compiled and tested under the Verdix Ada compiler -- version 4.06 on a vax 11/750 running Unix 4.2BSD. -- with Actions_File, Source_File, STR_Pack, Tokens_File, Text_IO; use Actions_File, Source_File, STR_Pack, Tokens_File, Text_IO; package body Lexical_Analyzer is SCCS_ID : constant String := "@(#) lexical_analyzer_body.adadisk21~/rschm/hasee/sccs/ayacc, Version 1.2"; Rcs_ID : constant String := "$Header: lexical_analyzer_body.a,v 0.1 86/04/01 15:05:27 ada Exp $"; Max_Lexeme_Length : constant := 80; Current_Line_Number: Natural := 1; Lexeme_Text : STR(Max_Lexeme_Length); function Get_Lexeme_Text return String is begin return Value_of(Lexeme_Text); end Get_Lexeme_Text; function Line_Number return Natural is begin return Source_Line_Number; end Line_Number; procedure Skip_Comment is Ch: Character; begin loop Get_Char(Ch); if Ch = Eof then Unget_Char(Ch); exit; elsif Ch = Eoln then Current_Line_Number := Current_Line_Number + 1; exit; end if; end loop; end Skip_Comment; function Get_Token return Ayacc_Token is Ch: Character; begin loop Assign("", To => Lexeme_Text); loop Get_Char(Ch); if Ch = Eoln then Current_Line_Number := Current_Line_Number + 1; end if; exit when Ch /= ' ' and then Ch /= Eoln and then Ch /= Ascii.Ht; end loop; case Ch is when '-' => Get_Char(Ch); if Ch = '-' then Skip_Comment; else raise Illegal_Token; end if; when ':' => Append(Ch, To => Lexeme_Text); return Colon; when ';' => Append(Ch, To => Lexeme_Text); return Semicolon; when ',' => Append(Ch, To => Lexeme_Text); return Comma; when '%' => Append(Ch, To => Lexeme_Text); if Peek_Next_Char = '%' then Get_Char(Ch); Append(Ch, To => Lexeme_Text); return Mark; else loop Get_Char(Ch); if Ch not in 'A'..'Z' and then Ch not in 'a'..'z' then Unget_Char(Ch); exit; end if; Append(Ch, To => Lexeme_Text); end loop; Upper_Case(Lexeme_Text); if Value_of(Lexeme_Text) = "%TOKEN" then return Token; elsif Value_of(Lexeme_Text) = "%START" then return Start; elsif Value_of(Lexeme_Text) = "%LEFT" then return Left; elsif Value_of(Lexeme_Text) = "%RIGHT" then return Right; elsif Value_of(Lexeme_Text) = "%NONASSOC" then return Nonassoc; elsif Value_of(Lexeme_Text) = "%PREC" then return Prec; elsif Value_of (Lexeme_Text) = "%WITH" then return With_Clause; elsif Value_of (Lexeme_Text) = "%USE" then return Use_Clause; else raise Illegal_Token; end if; end if; when '|' => Append(Ch, To => Lexeme_Text); return Vertical_Bar; when '{' => Append(Ch, To => Lexeme_Text); return Left_Brace; when Eof => return Eof_Token; when ''' => Append(Ch, To => Lexeme_Text); Get_Char(Ch); if Ch /= Eof and Ch /= Eoln then Append(Ch, To => Lexeme_Text); Get_Char(Ch); if Ch /= ''' then raise Illegal_Token; else Append(Ch, To => Lexeme_Text); end if; return Character_Literal; end if; when 'A'..'Z' | 'a'..'z' | '.' | '_' => Append(Ch, To => Lexeme_Text); loop Get_Char(Ch); if Ch in 'a'..'z' or else Ch in 'A'..'Z' or else Ch in '0'..'9' or else Ch = '.' or else Ch = '_' then Append(Ch, To => Lexeme_Text); else Unget_Char(Ch); exit; end if; end loop; Upper_Case(Lexeme_Text); return Identifier; when others => raise Illegal_Token; end case; end loop; end Get_Token; procedure Handle_Action(Rule, Rule_Length : Integer) is Char : Character; Base : Integer; begin Actions_File.Writeln; Actions_File.Write("when " & Integer'Image(Rule) & " =>"); Actions_File.Writeln; Actions_File.Write("--#line " & Integer'Image(Current_Line_Number)); Actions_File.Writeln; loop Get_Char(Char); if Char = '-' and then Peek_Next_Char = '-' then loop Actions_File.Write(Char); Get_Char(Char); exit when Char = Eoln; end loop; end if; case Char is when '"' => Actions_File.Write(Char); loop Get_Char(Char); Actions_File.Write(Char); exit when Char = '"'; end loop; -- handle special case '"' where there is no matching ". when ''' => Actions_File.Write(Char); if Peek_Next_Char= '"' then Get_Char(Char); if Peek_Next_Char = ''' then Actions_File.Write(Char); -- '"' Get_Char(Char); -- ''' Actions_File.Write(Char); else UnGet_Char(Char); -- '"' end if; end if; when '$' => Actions_File.Writeln; Get_Char(Char); if Char = '$' then Actions_File.Write("yyval"); elsif Char in '0'..'9' then Base := Character'Pos(Char) - Character'Pos('0'); while Peek_Next_Char in '0'..'9' loop Get_Char(Char); Base := Base * 10 + Character'Pos(Char) - Character'Pos('0'); end loop; if Base > Rule_Length then Put_Line("Ayacc: Illegal use of $"&Integer'Image(Base)); raise Illegal_Token; end if; Base := Base - Rule_Length; if Base = 0 then Actions_File.Write("yy.value_stack(yy.tos)"); else Actions_File.Write("yy.value_stack(yy.tos" & Integer'Image(Base) & ")"); end if; else Put_Line("Ayacc: Illegal symbol following $"); raise Illegal_Token; end if; when Eoln => Actions_File.Writeln; Current_Line_Number := Current_Line_Number + 1; when '}' => exit; when others => Actions_File.Write(Char); end case; end loop; Actions_File.Writeln; end Handle_Action; procedure Dump_Declarations is Ch : Character; Text : STR(Source_File.Maximum_Line_Length); begin Assign("", To => Text); loop Get_Char(Ch); exit when Ch = '}' ; case Ch is when '-' => Append(Ch, To => Text); if Peek_Next_Char = '-' then loop Get_Char(Ch); Append(Ch, To => Text); exit when Peek_Next_Char = Eoln or Peek_Next_Char = Eof; end loop; end if; when '"' => Append(Ch, To => Text); loop Get_Char(Ch); if Ch = Eoln or Ch = Eof then raise Illegal_Token; end if; Append(Ch, To => Text); exit when Ch = '"'; end loop; when Eoln => Tokens_File.Writeln(Value_of(Text)); Assign("", To => Text); Current_Line_Number := Current_Line_Number + 1; when Eof => exit; when others => Append(Ch, To => Text); end case; end loop; Tokens_File.Writeln(Value_of(Text)); end Dump_Declarations; end Lexical_Analyzer;
30,604
ada
30
Componolit/libsparkcrypto
tests/lsc_internal_test_bignum.adb
------------------------------------------------------------------------------- -- This file is part of libsparkcrypto. -- -- Copyright (C) 2011, <NAME> and <NAME> -- Copyright (C) 2011, secunet Security Networks AG -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- * Redistributions of source code must retain the above copyright notice, -- this list of conditions and the following disclaimer. -- -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- -- * Neither the name of the author nor the names of its contributors may be -- used to endorse or promote products derived from this software without -- specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS -- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------- with LSC.Internal.Types; with LSC.Internal.Bignum; with OpenSSL; with AUnit.Assertions; use AUnit.Assertions; pragma Style_Checks ("-s"); pragma Warnings (Off, "formal parameter ""T"" is not referenced"); use type LSC.Internal.Bignum.Big_Int; package body LSC_Internal_Test_Bignum is Window_Size : constant := 5; subtype Mod_Range_Small is Natural range 0 .. 63; subtype Mod_Range is Natural range 0 .. 127; subtype Pub_Exp_Range is Natural range 0 .. 0; subtype Window_Aux_Range is Natural range 0 .. 128 * (2 ** Window_Size) - 1; subtype LInt_Small is LSC.Internal.Bignum.Big_Int (Mod_Range_Small); subtype LInt is LSC.Internal.Bignum.Big_Int (Mod_Range); subtype SInt is LSC.Internal.Bignum.Big_Int (Pub_Exp_Range); subtype Window_Aux is LSC.Internal.Bignum.Big_Int (Window_Aux_Range); Pub_Exp : constant SInt := SInt'(0 => 16#00010001#); -- 2048 bit Modulus_Small : constant LInt_Small := LInt_Small' (16#e3855b7b#, 16#695e1d0c#, 16#2f3a389f#, 16#e4e8cfbc#, 16#366c3c0b#, 16#07f34b0d#, 16#a92ff519#, 16#566a909a#, 16#d79ecc36#, 16#e392c334#, 16#dbbb737f#, 16#80c97ddd#, 16#812a798c#, 16#0fdf31b2#, 16#c9c3978b#, 16#f526906b#, 16#cf23d190#, 16#ea1e08a2#, 16#08cf9c02#, 16#b3b794fb#, 16#7855c403#, 16#49b10dd8#, 16#6ca17d12#, 16#b069b1ab#, 16#b8d28b35#, 16#a08d0a13#, 16#1a1bf74d#, 16#30ca19b3#, 16#29e5abd7#, 16#4ccb0a06#, 16#7bae2533#, 16#fc040833#, 16#2c1c80c5#, 16#ea729a13#, 16#ac5ffd04#, 16#a2dcc2f9#, 16#c1f9c72c#, 16#f466adf6#, 16#ea152c47#, 16#42d76640#, 16#8b5c067a#, 16#8c870d16#, 16#d3dacf2f#, 16#df33c327#, 16#fdddf873#, 16#592c3110#, 16#a94e6415#, 16#6b0f63f4#, 16#84919783#, 16#da1672d1#, 16#6d2b736e#, 16#3c02711d#, 16#eba01b1d#, 16#04463ba8#, 16#a8f0f41b#, 16#d41c9a16#, 16#2e0a1c54#, 16#e8340e9b#, 16#0194cdee#, 16#4beacec6#, 16#e23ee4a4#, 16#ec602901#, 16#079751bd#, 16#Dad31766#); Priv_Exp_Small : constant LInt_Small := LInt_Small' (16#3fd9f299#, 16#64a02913#, 16#780db9d7#, 16#164c83cd#, 16#70ac88cc#, 16#14e9bfcc#, 16#bff4fa46#, 16#a2956db0#, 16#d5952d92#, 16#d8e23b1b#, 16#d252925c#, 16#f63f2570#, 16#1232a957#, 16#0ecdf6fc#, 16#23356dd5#, 16#6dfd8463#, 16#b88e9193#, 16#3e337443#, 16#c30bd004#, 16#f86471bc#, 16#26836b1f#, 16#36792ee7#, 16#fd7774c3#, 16#e947afe5#, 16#403e454e#, 16#60886c2f#, 16#7da04cab#, 16#0006c1c8#, 16#87bfa8cc#, 16#c644e026#, 16#8eea8cce#, 16#beca39f9#, 16#60c3808d#, 16#2faf499f#, 16#c81d0c50#, 16#ef2e6e1b#, 16#ae3dbc3f#, 16#54a6e7b8#, 16#efdc4e55#, 16#e0ed4e41#, 16#6ddee985#, 16#2c988959#, 16#2bdbffad#, 16#ec9c5635#, 16#a6ad3fef#, 16#5df1f2a6#, 16#e4ec57d3#, 16#1c823145#, 16#eecff08e#, 16#51b9f682#, 16#c8ec37a1#, 16#1212a615#, 16#9265aeed#, 16#4b4e2491#, 16#2b29d53a#, 16#2bd57be9#, 16#ffd21ce0#, 16#bccc6401#, 16#e2d6c019#, 16#c98b2771#, 16#4d4cde01#, 16#d507d875#, 16#886bab53#, 16#7cac4629#); -- 4096 bit Modulus : constant LInt := LInt' (16#27a3f371#, 16#f66dc29e#, 16#2c4cf251#, 16#0aa490b7#, 16#2eabfddb#, 16#4e6d1cc7#, 16#e67fc1bb#, 16#be3cc1e1#, 16#4338d3ae#, 16#372d809a#, 16#b9d33026#, 16#e3d05bff#, 16#886580b8#, 16#020b3b03#, 16#55c15179#, 16#a3c026b2#, 16#3e550dcb#, 16#821fcfee#, 16#4f44c3f9#, 16#25c8b0a5#, 16#30612a20#, 16#8c970432#, 16#32e395aa#, 16#1337a822#, 16#3db2c677#, 16#35a256d5#, 16#fcbf1cfc#, 16#6354fbe1#, 16#8d0874a2#, 16#a017fe19#, 16#07f415fc#, 16#e0a45678#, 16#c3e2f1c3#, 16#4b73d538#, 16#962f1c1c#, 16#448f15fb#, 16#d4ba9b05#, 16#9f6cc819#, 16#f36d2a06#, 16#d1c1d04a#, 16#efb31b76#, 16#c7cae1cf#, 16#e61520e4#, 16#984ec779#, 16#56f79b73#, 16#2f8ca314#, 16#a0c4e830#, 16#2e3eba5b#, 16#f739a437#, 16#7852b71e#, 16#aab09aa6#, 16#3d8dcdc3#, 16#f16ab197#, 16#8b3753d1#, 16#ec52c4e1#, 16#f70e4f7d#, 16#b4af5c60#, 16#82ae6ca4#, 16#fa6a8a1d#, 16#5655c33d#, 16#5096b17f#, 16#71c61b6a#, 16#28c84e83#, 16#07a0f985#, 16#b5523b0c#, 16#d31e75f6#, 16#c8139152#, 16#c94fb87f#, 16#d0d092c4#, 16#b5bae11d#, 16#3ebaa999#, 16#599cd667#, 16#a156c841#, 16#88a90d02#, 16#73e10c30#, 16#56b72050#, 16#1cb3c2d9#, 16#abef5973#, 16#8f42b61a#, 16#e54c7b3c#, 16#0b93bb83#, 16#5ca62bc2#, 16#1a9996a5#, 16#26b48d1b#, 16#98f932d1#, 16#3f56babe#, 16#dab5a0eb#, 16#4e0de31d#, 16#4bbe26d4#, 16#2812c4f8#, 16#f6d1866c#, 16#6800ef71#, 16#49cca290#, 16#aa1bbdee#, 16#ee8a75ea#, 16#4fc8516b#, 16#242c7f52#, 16#96df15ea#, 16#eaac1b33#, 16#c533d8fa#, 16#a649ef23#, 16#7d29eebb#, 16#8342ce68#, 16#36abe9c0#, 16#82adff4d#, 16#8fcc54b0#, 16#89144572#, 16#09dfcece#, 16#bcc22be3#, 16#b2184072#, 16#cf2cf6c3#, 16#dbb62eeb#, 16#9c44b29b#, 16#08dea7eb#, 16#8a92c57e#, 16#4ed90ea9#, 16#a73379d1#, 16#20767c8f#, 16#bcc1a56d#, 16#6fa7e726#, 16#d74d548d#, 16#ec21f388#, 16#a2344841#, 16#8b08a316#, 16#c99b8d76#, 16#d670befe#, 16#31a09763#, 16#d0055749#); Priv_Exp : constant LInt := LInt' (16#2e274601#, 16#8fab5c50#, 16#48b5239e#, 16#5a37865c#, 16#5670b41d#, 16#2da87796#, 16#3a82b988#, 16#7a7ce911#, 16#bd4e57b1#, 16#8f6d3da4#, 16#8669e6a0#, 16#3314c3e7#, 16#36248f99#, 16#4b3e25a7#, 16#600a6f7f#, 16#04eafed8#, 16#45050c07#, 16#f32daf96#, 16#6b6b4f21#, 16#cd177764#, 16#e4d13b46#, 16#80f34af3#, 16#1f601841#, 16#65bf67b8#, 16#33729106#, 16#56b14c9d#, 16#267c46be#, 16#d4acf88c#, 16#fc8ec97e#, 16#06d4df7e#, 16#198ec5fb#, 16#a098a033#, 16#c7dcc150#, 16#dc980d3f#, 16#29778f62#, 16#29f4cbca#, 16#e6d86584#, 16#9e366a7a#, 16#b39ab77a#, 16#1a956df3#, 16#da64c05b#, 16#6f4183a2#, 16#452ad7db#, 16#84d1f44e#, 16#88c4a697#, 16#d272546e#, 16#c0f5da10#, 16#dca7e68b#, 16#2316a1e5#, 16#93305fcd#, 16#10a0897b#, 16#e203fc89#, 16#163ef9fa#, 16#a3625c15#, 16#9719bace#, 16#c5bd6a66#, 16#466893e9#, 16#eb33cb36#, 16#ff6854e6#, 16#f8cf002f#, 16#5c84f1a6#, 16#f9d89029#, 16#a42c2f21#, 16#7c29e8b3#, 16#07188900#, 16#37a9da54#, 16#672715c3#, 16#ab9b69ac#, 16#2a32533c#, 16#592932ba#, 16#90843f00#, 16#4f540d7d#, 16#44f04b78#, 16#efeab1d4#, 16#bc5e76db#, 16#cd5bd78b#, 16#0eb2723f#, 16#bd633630#, 16#90bf30be#, 16#0023372e#, 16#5d50308b#, 16#4cbf539a#, 16#1abb5b44#, 16#30cc98de#, 16#869b24e0#, 16#78bda399#, 16#25e6f54c#, 16#96dac865#, 16#8db1dc73#, 16#770a4d97#, 16#31123fee#, 16#139ea6d0#, 16#786e32b2#, 16#f3998ab6#, 16#5fd4f43b#, 16#ae506344#, 16#797f633d#, 16#81682a87#, 16#9b5cb744#, 16#a40a97e5#, 16#e788eed8#, 16#5c2b1448#, 16#90780722#, 16#77af3218#, 16#66114d4f#, 16#8857c6c0#, 16#9899ef8a#, 16#dea4d612#, 16#f5986865#, 16#41b3caca#, 16#ebace112#, 16#1678338c#, 16#34e40889#, 16#3291e166#, 16#3f855200#, 16#e81eddcb#, 16#b08e2e77#, 16#238ac815#, 16#d2442787#, 16#bb20cea2#, 16#c4ae4e94#, 16#b575336a#, 16#cd55d286#, 16#e7387f77#, 16#a780f030#, 16#46526c31#, 16#0e4752a9#, 16#9b036fe1#); --------------------------------------------------------------------------- procedure Test_RSA2048 (T : in out Test_Cases.Test_Case'Class) is Aux1, Aux2, Aux3, R : LInt; M_Inv : LSC.Internal.Types.Word32; Aux4 : Window_Aux; Plain1_Small, OpenSSL_Plain1_Small : LInt_Small; Plain2_Small, Plain3_Small, OpenSSL_Plain2_Small : LInt_Small; Cipher1_Small, Cipher2_Small, OpenSSL_Cipher_Small : LInt_Small; OpenSSL_Modulus_Small, OpenSSL_Priv_Exp_Small : LInt_Small; OpenSSL_Pub_Exp : SInt; Success_Enc, Success_Dec : Boolean; begin LSC.Internal.Bignum.Native_To_BE (Pub_Exp, Pub_Exp'First, Pub_Exp'Last, OpenSSL_Pub_Exp, OpenSSL_Pub_Exp'First); -- Create original data for I in Natural range Modulus_Small'Range loop Plain1_Small (I) := LSC.Internal.Types.Word32 (I); end loop; -- Convert modulus, exponent and plaintext to format expected by OpenSSL LSC.Internal.Bignum.Native_To_BE (Priv_Exp_Small, Priv_Exp_Small'First, Priv_Exp_Small'Last, OpenSSL_Priv_Exp_Small, OpenSSL_Priv_Exp_Small'First); LSC.Internal.Bignum.Native_To_BE (Modulus_Small, Modulus_Small'First, Modulus_Small'Last, OpenSSL_Modulus_Small, OpenSSL_Modulus_Small'First); LSC.Internal.Bignum.Native_To_BE (Plain1_Small, Plain1_Small'First, Plain1_Small'Last, OpenSSL_Plain1_Small, OpenSSL_Plain1_Small'First); OpenSSL.RSA_Public_Encrypt (OpenSSL_Modulus_Small, OpenSSL_Pub_Exp, OpenSSL_Plain1_Small, OpenSSL_Cipher_Small, Success_Enc); OpenSSL.RSA_Private_Decrypt (OpenSSL_Modulus_Small, OpenSSL_Pub_Exp, OpenSSL_Priv_Exp_Small, OpenSSL_Cipher_Small, OpenSSL_Plain2_Small, Success_Dec); LSC.Internal.Bignum.Native_To_BE (OpenSSL_Cipher_Small, OpenSSL_Cipher_Small'First, OpenSSL_Cipher_Small'Last, Cipher2_Small, Cipher2_Small'First); LSC.Internal.Bignum.Native_To_BE (OpenSSL_Plain2_Small, OpenSSL_Plain2_Small'First, OpenSSL_Plain2_Small'Last, Plain3_Small, Plain3_Small'First); -- Precompute R^2 mod m LSC.Internal.Bignum.Size_Square_Mod (M => Modulus_Small, M_First => Modulus_Small'First, M_Last => Modulus_Small'Last, R => R, R_First => R'First); -- Precompute inverse M_Inv := LSC.Internal.Bignum.Word_Inverse (Modulus_Small (Modulus_Small'First)); -- Encrypt LSC.Internal.Bignum.Mont_Exp_Window (A => Cipher1_Small, A_First => Cipher1_Small'First, A_Last => Cipher1_Small'Last, X => Plain1_Small, X_First => Plain1_Small'First, E => Pub_Exp, E_First => Pub_Exp'First, E_Last => Pub_Exp'Last, M => Modulus_Small, M_First => Modulus_Small'First, K => Window_Size, Aux1 => Aux1, Aux1_First => Aux1'First, Aux2 => Aux2, Aux2_First => Aux2'First, Aux3 => Aux3, Aux3_First => Aux3'First, Aux4 => Aux4, Aux4_First => Aux4'First, R => R, R_First => R'First, M_Inv => M_Inv); -- Decrypt LSC.Internal.Bignum.Mont_Exp_Window (A => Plain2_Small, A_First => Plain2_Small'First, A_Last => Plain2_Small'Last, X => Cipher1_Small, X_First => Cipher1_Small'First, E => Priv_Exp_Small, E_First => Priv_Exp_Small'First, E_Last => Priv_Exp_Small'Last, M => Modulus_Small, M_First => Modulus_Small'First, K => Window_Size, Aux1 => Aux1, Aux1_First => Aux1'First, Aux2 => Aux2, Aux2_First => Aux2'First, Aux3 => Aux3, Aux3_First => Aux3'First, Aux4 => Aux4, Aux4_First => Aux4'First, R => R, R_First => R'First, M_Inv => M_Inv); Assert (Success_Enc, "encryption failed"); Assert (Success_Dec, "decryption failed"); Assert (Cipher1_Small = Cipher2_Small, "cipher texts differ"); Assert (Plain1_Small = Plain2_Small, "Plain1 /= Plain2"); Assert (Plain2_Small = Plain3_Small, "Plain2 /= Plain3"); end Test_RSA2048; --------------------------------------------------------------------------- procedure Test_RSA4096 (T : in out Test_Cases.Test_Case'Class) is Plain1, OpenSSL_Plain1 : LInt; Plain2, Plain3, OpenSSL_Plain2 : LInt; Cipher1, Cipher2, OpenSSL_Cipher : LInt; OpenSSL_Modulus, OpenSSL_Priv_Exp : LInt; OpenSSL_Pub_Exp : SInt; Aux1, Aux2, Aux3, R : LInt; Aux4 : Window_Aux; M_Inv : LSC.Internal.Types.Word32; Success_Enc, Success_Dec : Boolean; begin LSC.Internal.Bignum.Native_To_BE (Pub_Exp, Pub_Exp'First, Pub_Exp'Last, OpenSSL_Pub_Exp, OpenSSL_Pub_Exp'First); -- Create original data for I in Natural range Modulus'Range loop Plain1 (I) := LSC.Internal.Types.Word32 (I); end loop; -- Convert modulus, exponent and plaintext to format expected by OpenSSL LSC.Internal.Bignum.Native_To_BE (Priv_Exp, Priv_Exp'First, Priv_Exp'Last, OpenSSL_Priv_Exp, OpenSSL_Priv_Exp'First); LSC.Internal.Bignum.Native_To_BE (Modulus, Modulus'First, Modulus'Last, OpenSSL_Modulus, OpenSSL_Modulus'First); LSC.Internal.Bignum.Native_To_BE (Plain1, Plain1'First, Plain1'Last, OpenSSL_Plain1, OpenSSL_Plain1'First); OpenSSL.RSA_Public_Encrypt (OpenSSL_Modulus, OpenSSL_Pub_Exp, OpenSSL_Plain1, OpenSSL_Cipher, Success_Enc); OpenSSL.RSA_Private_Decrypt (OpenSSL_Modulus, OpenSSL_Pub_Exp, OpenSSL_Priv_Exp, OpenSSL_Cipher, OpenSSL_Plain2, Success_Dec); LSC.Internal.Bignum.Native_To_BE (OpenSSL_Cipher, OpenSSL_Cipher'First, OpenSSL_Cipher'Last, Cipher2, Cipher2'First); LSC.Internal.Bignum.Native_To_BE (OpenSSL_Plain2, OpenSSL_Plain2'First, OpenSSL_Plain2'Last, Plain3, Plain3'First); -- Precompute R^2 mod m LSC.Internal.Bignum.Size_Square_Mod (M => Modulus, M_First => Modulus'First, M_Last => Modulus'Last, R => R, R_First => R'First); -- Precompute inverse M_Inv := LSC.Internal.Bignum.Word_Inverse (Modulus (Modulus'First)); -- Encrypt LSC.Internal.Bignum.Mont_Exp_Window (A => Cipher1, A_First => Cipher1'First, A_Last => Cipher1'Last, X => Plain1, X_First => Plain1'First, E => Pub_Exp, E_First => Pub_Exp'First, E_Last => Pub_Exp'Last, M => Modulus, M_First => Modulus'First, K => Window_Size, Aux1 => Aux1, Aux1_First => Aux1'First, Aux2 => Aux2, Aux2_First => Aux2'First, Aux3 => Aux3, Aux3_First => Aux3'First, Aux4 => Aux4, Aux4_First => Aux4'First, R => R, R_First => R'First, M_Inv => M_Inv); -- Decrypt LSC.Internal.Bignum.Mont_Exp_Window (A => Plain2, A_First => Plain2'First, A_Last => Plain2'Last, X => Cipher1, X_First => Cipher1'First, E => Priv_Exp, E_First => Priv_Exp'First, E_Last => Priv_Exp'Last, M => Modulus, M_First => Modulus'First, K => Window_Size, Aux1 => Aux1, Aux1_First => Aux1'First, Aux2 => Aux2, Aux2_First => Aux2'First, Aux3 => Aux3, Aux3_First => Aux3'First, Aux4 => Aux4, Aux4_First => Aux4'First, R => R, R_First => R'First, M_Inv => M_Inv); Assert (Success_Enc, "encryption failed"); Assert (Success_Dec, "decryption failed"); Assert (Cipher1 = Cipher2, "cipher texts differ"); Assert (Plain1 = Plain2, "Plain1 /= Plain2"); Assert (Plain2 = Plain3, "Plain2 /= Plain3"); end Test_RSA4096; --------------------------------------------------------------------------- procedure Register_Tests (T : in out Test_Case) is use AUnit.Test_Cases.Registration; begin Register_Routine (T, Test_RSA2048'Access, "Insecure RSA 2048 (encrypt/decrypt)"); Register_Routine (T, Test_RSA4096'Access, "Insecure RSA 4096 (encrypt/decrypt)"); end Register_Tests; --------------------------------------------------------------------------- function Name (T : Test_Case) return Test_String is begin return Format ("Bignum"); end Name; end LSC_Internal_Test_Bignum;
30,605
ada
81
My-Colaborations/ada-awa
awa/plugins/awa-images/regtests/awa-images-modules-tests.adb
----------------------------------------------------------------------- -- awa-storages-modules-tests -- Unit tests for storage service -- Copyright (C) 2012, 2013, 2016, 2019, 2020 <NAME> -- Written by <NAME> (<EMAIL>) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; with Util.Test_Caller; with Security.Contexts; with ASF.Tests; with ASF.Requests.Mockup; with ASF.Responses.Mockup; with Servlet.Responses; with AWA.Services.Contexts; with AWA.Tests.Helpers.Users; with AWA.Images.Modules; with AWA.Storages.Beans; with AWA.Storages.Services; with AWA.Storages.Modules; package body AWA.Images.Modules.Tests is use type AWA.Storages.Services.Storage_Service_Access; package Caller is new Util.Test_Caller (Test, "Images.Modules"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test AWA.Images.Modules.Create_Image", Test_Create_Image'Access); Caller.Add_Test (Suite, "Test AWA.Images.Modules.Get_Sizes", Test_Get_Sizes'Access); Caller.Add_Test (Suite, "Test AWA.Images.Modules.Scale", Test_Scale'Access); Caller.Add_Test (Suite, "Test AWA.Images.Modules.On_Create", Test_Store_Image'Access); end Add_Tests; -- ------------------------------ -- Test creation of a storage object -- ------------------------------ procedure Test_Create_Image (T : in out Test) is Sec_Ctx : Security.Contexts.Security_Context; Context : AWA.Services.Contexts.Service_Context; Source : constant String := Util.Tests.Get_Path ("regtests/files/images/bast-12.jpg"); Thumb : constant String := Util.Tests.Get_Test_Path ("regtests/result/bast-12-thumb.jpg"); Width : Natural := 64; Height : Natural := 64; begin AWA.Tests.Helpers.Users.Login (Context, Sec_Ctx, "<EMAIL>"); T.Manager := AWA.Images.Modules.Get_Image_Module; T.Manager.Create_Thumbnail (Source, Thumb, Width, Height); Util.Tests.Assert_Equals (T, 1720, Width, "Invalid image width"); Util.Tests.Assert_Equals (T, 1098, Height, "Invalid image height"); end Test_Create_Image; -- ------------------------------ -- Test the Get_Sizes operation. -- ------------------------------ procedure Test_Get_Sizes (T : in out Test) is Width : Natural; Height : Natural; begin AWA.Images.Modules.Get_Sizes ("default", Width, Height); Util.Tests.Assert_Equals (T, 800, Width, "Default width should be 800"); Util.Tests.Assert_Equals (T, 0, Height, "Default height should be 0"); AWA.Images.Modules.Get_Sizes ("123x456", Width, Height); Util.Tests.Assert_Equals (T, 123, Width, "Invalid width"); Util.Tests.Assert_Equals (T, 456, Height, "Invalid height"); AWA.Images.Modules.Get_Sizes ("x56", Width, Height); Util.Tests.Assert_Equals (T, 0, Width, "Invalid width"); Util.Tests.Assert_Equals (T, 56, Height, "Invalid height"); AWA.Images.Modules.Get_Sizes ("123x", Width, Height); Util.Tests.Assert_Equals (T, 123, Width, "Invalid width"); Util.Tests.Assert_Equals (T, 0, Height, "Invalid height"); AWA.Images.Modules.Get_Sizes ("123xtoto", Width, Height); Util.Tests.Assert_Equals (T, 123, Width, "Invalid width"); Util.Tests.Assert_Equals (T, 0, Height, "Invalid height"); AWA.Images.Modules.Get_Sizes ("xtoto", Width, Height); Util.Tests.Assert_Equals (T, 0, Width, "Invalid width"); Util.Tests.Assert_Equals (T, 0, Height, "Invalid height"); AWA.Images.Modules.Get_Sizes ("original", Width, Height); Util.Tests.Assert_Equals (T, Natural'Last, Width, "Invalid width"); Util.Tests.Assert_Equals (T, Natural'Last, Height, "Invalid height"); end Test_Get_Sizes; -- ------------------------------ -- Test the Scale operation. -- ------------------------------ procedure Test_Scale (T : in out Test) is Width : Natural; Height : Natural; begin Width := 0; Height := 0; AWA.Images.Modules.Scale (123, 456, Width, Height); Util.Tests.Assert_Equals (T, 123, Width, "Invalid width"); Util.Tests.Assert_Equals (T, 456, Height, "Invalid height"); Width := 100; Height := 0; AWA.Images.Modules.Scale (10000, 2000, Width, Height); Util.Tests.Assert_Equals (T, 100, Width, "Invalid width"); Util.Tests.Assert_Equals (T, 20, Height, "Invalid height"); Width := 0; Height := 200; AWA.Images.Modules.Scale (10000, 2000, Width, Height); Util.Tests.Assert_Equals (T, 1000, Width, "Invalid width"); Util.Tests.Assert_Equals (T, 200, Height, "Invalid height"); end Test_Scale; -- ------------------------------ -- Test the creation of an image through the storage service. -- ------------------------------ procedure Test_Store_Image (T : in out Test) is Sec_Ctx : Security.Contexts.Security_Context; Context : AWA.Services.Contexts.Service_Context; Folder : AWA.Storages.Beans.Folder_Bean; Store : AWA.Storages.Models.Storage_Ref; Mgr : AWA.Storages.Services.Storage_Service_Access; Outcome : Ada.Strings.Unbounded.Unbounded_String; Path : constant String := Util.Tests.Get_Path ("regtests/files/images/Ada-Lovelace.jpg"); begin AWA.Tests.Helpers.Users.Login (Context, Sec_Ctx, "<EMAIL>"); Mgr := AWA.Storages.Modules.Get_Storage_Manager; T.Assert (Mgr /= null, "Null storage manager"); -- Make a storage folder. Folder.Module := AWA.Storages.Modules.Get_Storage_Module; Folder.Set_Name ("Image folder"); Folder.Save (Outcome); Store.Set_Folder (Folder); Store.Set_Mime_Type ("image/jpg"); Store.Set_Name ("Ada-Lovelace.jpg"); Mgr.Save (Store, Path, AWA.Storages.Models.FILE); declare Request : ASF.Requests.Mockup.Request; Reply : ASF.Responses.Mockup.Response; Id : constant String := ADO.Identifier'Image (Store.Get_Id); begin AWA.Tests.Helpers.Users.Login ("<EMAIL>", Request); ASF.Tests.Do_Get (Request, Reply, "/storages/images/" & Id (Id'First + 1 .. Id'Last) & "/view/Ada-Lovelace.jpg", "image-get-Ada-Lovelace.jpg"); ASF.Tests.Assert_Header (T, "Content-Type", "image/jpg", Reply); Util.Tests.Assert_Equals (T, Servlet.Responses.SC_OK, Reply.Get_Status, "Invalid response for image"); -- Try to get an invalid image ASF.Tests.Do_Get (Request, Reply, "/storages/images/plop" & "/view/Ada-Lovelace.jpg", "image-get-plop.jpg"); Util.Tests.Assert_Equals (T, Servlet.Responses.SC_NOT_FOUND, Reply.Get_Status, "Invalid response for image"); end; end Test_Store_Image; end AWA.Images.Modules.Tests;
30,606
ada
1
selroc/Renaissance-Ada
src/libraries/Rewriters_Lib/src/placeholder_relations.adb
with Ada.Text_IO; use Ada.Text_IO; with Libadalang.Analysis; use Libadalang.Analysis; with Libadalang.Common; use Libadalang.Common; with Rejuvenation; use Rejuvenation; with Rejuvenation.Finder; use Rejuvenation.Finder; with Rejuvenation.Utils; use Rejuvenation.Utils; package body Placeholder_Relations is function Is_Referenced_In (D_N : Defining_Name; Node : Ada_Node) return Boolean; function Is_Referenced_In (D_N : Defining_Name; Node : Ada_Node) return Boolean is Identifiers : constant Node_List.Vector := Find (Node, Ada_Identifier); begin return (for some Identifier of Identifiers => Identifier.As_Identifier.P_Referenced_Defining_Name = D_N); end Is_Referenced_In; function Is_Referenced_In (Match : Match_Pattern; Definition, Context : String) return Boolean is D_N : constant Defining_Name := Match.Get_Single_As_Node (Definition).As_Defining_Name; Context_Nodes : constant Node_List.Vector := Match.Get_Placeholder_As_Nodes (Context); begin return (for some Context_Node of Context_Nodes => Is_Referenced_In (D_N, Context_Node)); end Is_Referenced_In; function Is_Constant_Expression (E : Expr) return Boolean; function Is_Constant_Expression (E : Expr) return Boolean is begin case E.Kind is when Ada_String_Literal | Ada_Int_Literal | Ada_Real_Literal => return True; when Ada_Identifier => return False; when Ada_Bin_Op => declare B_O : constant Bin_Op := E.As_Bin_Op; begin return Is_Constant_Expression (B_O.F_Left) and then Is_Constant_Expression (B_O.F_Right); end; when Ada_Relation_Op => declare R_O : constant Relation_Op := E.As_Relation_Op; begin return Is_Constant_Expression (R_O.F_Left) and then Is_Constant_Expression (R_O.F_Right); end; when Ada_Paren_Expr => return Is_Constant_Expression (E.As_Paren_Expr.F_Expr); when others => Put_Line ("Is_Constant_Expression: Unhandled kind - " & E.Kind'Image); return False; end case; end Is_Constant_Expression; function Is_Constant_Expression (Match : Match_Pattern; Expression : String) return Boolean is E : constant Expr := Match.Get_Single_As_Node (Expression).As_Expr; begin return Is_Constant_Expression (E); end Is_Constant_Expression; function Is_Within_Base_Subp_Body (Match : Match_Pattern; Subp_Name : String) return Boolean is Nodes : constant Node_List.Vector := Get_Nodes (Match); begin -- Since Nodes are part of a sublist - checking a single node is enough return (for some Parent of Nodes.First_Element.Parents => Parent.Kind in Ada_Base_Subp_Body and then Subp_Name = Raw_Signature (Parent.As_Base_Subp_Body.F_Subp_Spec.F_Subp_Name)); end Is_Within_Base_Subp_Body; end Placeholder_Relations;
30,607
ada
0
antholuo/Blob_Traffic
Blob_Lib/assimp-5.2.3/assimp/contrib/zlib/contrib/ada/zlib-streams.adb
<filename>Blob_Lib/assimp-5.2.3/assimp/contrib/zlib/contrib/ada/zlib-streams.adb version https://git-lfs.github.com/spec/v1 oid sha256:f45988e2bac76eb25a0dc981f46576e7432c35dde1790bbc2b650f0090b7fa72 size 5996
30,608
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c7/c74402b.ada
<reponame>best08618/asylo -- C74402B.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- CHECK THAT INITIALIZATION OF IN PARAMETERS THAT ARE OF -- LIMITED PRIVATE TYPE IS PERMITTED. -- (SEE ALSO 6.4.2/T1 FOR TESTS OF OTHER LIMITED TYPES.) -- DAS 1/21/81 -- ABW 6/30/82 -- BHS 7/10/84 WITH REPORT; PROCEDURE C74402B IS USE REPORT; BEGIN TEST( "C74402B" , "CHECK THAT INITIALIZATION OF IN PARAMETERS " & "OF LIMITED PRIVATE TYPE IS PERMITTED" ); DECLARE PACKAGE PKG IS TYPE LPTYPE IS LIMITED PRIVATE; CLP : CONSTANT LPTYPE; XLP : CONSTANT LPTYPE; FUNCTION EQCLP (L : IN LPTYPE) RETURN BOOLEAN; FUNCTION EQXLP (L : IN LPTYPE) RETURN BOOLEAN; PRIVATE TYPE LPTYPE IS NEW INTEGER RANGE 0..127; CLP : CONSTANT LPTYPE := 127; XLP : CONSTANT LPTYPE := 0; END; PACKAGE BODY PKG IS FUNCTION EQCLP (L : IN LPTYPE) RETURN BOOLEAN IS BEGIN RETURN (L = CLP); END EQCLP; FUNCTION EQXLP (L : IN LPTYPE) RETURN BOOLEAN IS BEGIN RETURN (L = XLP); END EQXLP; END PKG; USE PKG; PROCEDURE PROC1 (Y : IN LPTYPE := CLP) IS BEGIN IF (EQCLP (Y)) THEN FAILED( "LIMITED PRIVATE NOT PASSED, " & "DEFAULT CLP EMPLOYED" ); ELSIF (NOT EQXLP (Y)) THEN FAILED( "NO LIMITED PRIVATE FOUND" ); END IF; END PROC1; PROCEDURE PROC2 (Y : IN LPTYPE := CLP) IS BEGIN IF (NOT EQCLP(Y)) THEN FAILED( "DEFAULT NOT EMPLOYED" ); END IF; END PROC2; BEGIN PROC1(XLP); PROC2; END; RESULT; END C74402B;
30,609
ada
22
FardaleM/metalang
out/euler39.adb
<filename>out/euler39.adb with ada.text_io, ada.Integer_text_IO, Ada.Text_IO.Text_Streams, Ada.Strings.Fixed, Interfaces.C; use ada.text_io, ada.Integer_text_IO, Ada.Strings, Ada.Strings.Fixed, Interfaces.C; with Ada.Numerics.Elementary_Functions; procedure euler39 is type stringptr is access all char_array; procedure PInt(i : in Integer) is begin String'Write (Text_Streams.Stream (Current_Output), Trim(Integer'Image(i), Left)); end; type d is Array (Integer range <>) of Integer; type d_PTR is access d; t : d_PTR; p : Integer; j : Integer; c2 : Integer; c : Integer; begin t := new d (0..1000); for i in integer range 0..1000 loop t(i) := 0; end loop; for a in integer range 1..1000 loop for b in integer range 1..1000 loop c2 := a * a + b * b; c := Integer(Float'Truncation(Ada.Numerics.Elementary_Functions.Sqrt(Float(c2)))); if c * c = c2 then p := a + b + c; if p < 1001 then t(p) := t(p) + 1; end if; end if; end loop; end loop; j := 0; for k in integer range 1..1000 loop if t(k) > t(j) then j := k; end if; end loop; PInt(j); end;
30,610
ada
1
BaderKashkash/Ada_Drivers_Library
arch/ARM/Nordic/drivers/nrf_common/nrf-gpio.adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2016-2020, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with NRF_SVD.GPIO; use NRF_SVD.GPIO; package body nRF.GPIO is overriding function Mode (This : GPIO_Point) return HAL.GPIO.GPIO_Mode is CNF_P0 : PIN_CNF_Register renames GPIO_Periph.PIN_CNF (This.Pin MOD 32); CNF_P1 : PIN_CNF_Register renames GPIO_Periph1.PIN_CNF (This.Pin MOD 32); begin if This.Pin > 31 then case CNF_P1.DIR is when Input => return HAL.GPIO.Input; when Output => return HAL.GPIO.Output; end case; else case CNF_P0.DIR is when Input => return HAL.GPIO.Input; when Output => return HAL.GPIO.Output; end case; end if; end Mode; -------------- -- Set_Mode -- -------------- overriding procedure Set_Mode (This : in out GPIO_Point; Mode : HAL.GPIO.GPIO_Config_Mode) is CNF_P0 : PIN_CNF_Register renames GPIO_Periph.PIN_CNF (This.Pin MOD 32); CNF_P1 : PIN_CNF_Register renames GPIO_Periph1.PIN_CNF (This.Pin MOD 32); begin if This.Pin > 31 then CNF_P1.DIR := (case Mode is when HAL.GPIO.Input => Input, when HAL.GPIO.Output => Output); CNF_P1.INPUT := (case Mode is when HAL.GPIO.Input => Connect, when HAL.GPIO.Output => Disconnect); else CNF_P0.DIR := (case Mode is when HAL.GPIO.Input => Input, when HAL.GPIO.Output => Output); CNF_P0.INPUT := (case Mode is when HAL.GPIO.Input => Connect, when HAL.GPIO.Output => Disconnect); end if; end Set_Mode; --------- -- Set -- --------- overriding function Set (This : GPIO_Point) return Boolean is begin if This.Pin > 31 then return GPIO_Periph1.IN_k.Arr (This.Pin MOD 32) = High; else return GPIO_Periph.IN_k.Arr (This.Pin MOD 32) = High; end if; end Set; ------------------- -- Pull_Resistor -- ------------------- overriding function Pull_Resistor (This : GPIO_Point) return HAL.GPIO.GPIO_Pull_Resistor is begin if This.Pin > 31 then case GPIO_Periph1.PIN_CNF (This.Pin MOD 32).PULL is when Disabled => return HAL.GPIO.Floating; when Pulldown => return HAL.GPIO.Pull_Down; when Pullup => return HAL.GPIO.Pull_Up; end case; else case GPIO_Periph.PIN_CNF (This.Pin MOD 32).PULL is when Disabled => return HAL.GPIO.Floating; when Pulldown => return HAL.GPIO.Pull_Down; when Pullup => return HAL.GPIO.Pull_Up; end case; end if; end Pull_Resistor; ----------------------- -- Set_Pull_Resistor -- ----------------------- overriding procedure Set_Pull_Resistor (This : in out GPIO_Point; Pull : HAL.GPIO.GPIO_Pull_Resistor) is begin if This.Pin > 31 then GPIO_Periph1.PIN_CNF (This.Pin MOD 32).PULL := (case Pull is when HAL.GPIO.Floating => Disabled, when HAL.GPIO.Pull_Down => Pulldown, when HAL.GPIO.Pull_Up => Pullup); else GPIO_Periph.PIN_CNF (This.Pin MOD 32).PULL := (case Pull is when HAL.GPIO.Floating => Disabled, when HAL.GPIO.Pull_Down => Pulldown, when HAL.GPIO.Pull_Up => Pullup); end if; end Set_Pull_Resistor; --------- -- Set -- --------- overriding procedure Set (This : in out GPIO_Point) is begin if This.Pin > 31 then GPIO_Periph1.OUT_k.Arr (This.Pin MOD 32) := High; else GPIO_Periph.OUT_k.Arr (This.Pin MOD 32) := High; end if; end Set; ----------- -- Clear -- ----------- overriding procedure Clear (This : in out GPIO_Point) is begin if This.Pin > 31 then GPIO_Periph1.OUT_k.Arr (This.Pin MOD 32) := Low; else GPIO_Periph.OUT_k.Arr (This.Pin MOD 32) := Low; end if; end Clear; ------------ -- Toggle -- ------------ overriding procedure Toggle (This : in out GPIO_Point) is begin if This.Set then This.Clear; else This.Set; end if; end Toggle; ------------------ -- Configure_IO -- ------------------ procedure Configure_IO (This : GPIO_Point; Config : GPIO_Configuration) is CNF_P0 : PIN_CNF_Register renames GPIO_Periph.PIN_CNF (This.Pin MOD 32); CNF_P1 : PIN_CNF_Register renames GPIO_Periph1.PIN_CNF (This.Pin MOD 32); begin if This.Pin > 31 then CNF_P1.DIR := (case Config.Mode is when Mode_In => Input, when Mode_Out => Output); CNF_P1.INPUT := (case Config.Input_Buffer is when Input_Buffer_Connect => Connect, when Input_Buffer_Disconnect => Disconnect); CNF_P1.PULL := (case Config.Resistors is when No_Pull => Disabled, when Pull_Up => Pullup, when Pull_Down => Pulldown); CNF_P1.DRIVE := (case Config.Drive is when Drive_S0S1 => S0S1, when Drive_H0S1 => H0S1, when Drive_S0H1 => S0H1, when Drive_H0H1 => H0H1, when Drive_D0S1 => D0S1, when Drive_D0H1 => D0H1, when Drive_S0D1 => S0D1, when Drive_H0D1 => H0D1); CNF_P1.SENSE := (case Config.Sense is when Sense_Disabled => Disabled, when Sense_For_High_Level => High, when Sense_For_Low_Level => Low); else CNF_P0.DIR := (case Config.Mode is when Mode_In => Input, when Mode_Out => Output); CNF_P0.INPUT := (case Config.Input_Buffer is when Input_Buffer_Connect => Connect, when Input_Buffer_Disconnect => Disconnect); CNF_P0.PULL := (case Config.Resistors is when No_Pull => Disabled, when Pull_Up => Pullup, when Pull_Down => Pulldown); CNF_P0.DRIVE := (case Config.Drive is when Drive_S0S1 => S0S1, when Drive_H0S1 => H0S1, when Drive_S0H1 => S0H1, when Drive_H0H1 => H0H1, when Drive_D0S1 => D0S1, when Drive_D0H1 => D0H1, when Drive_S0D1 => S0D1, when Drive_H0D1 => H0D1); CNF_P0.SENSE := (case Config.Sense is when Sense_Disabled => Disabled, when Sense_For_High_Level => High, when Sense_For_Low_Level => Low); end if; end Configure_IO; end nRF.GPIO;
30,611
ada
7
98devin/ada-gba-dev
src/GBA.Display.Backgrounds.Refs.adb
<reponame>98devin/ada-gba-dev -- Copyright (c) 2021 <NAME> -- zlib License -- see LICENSE for details. package body GBA.Display.Backgrounds.Refs is function ID (This : BG_Ref'Class) return BG_ID is ( This.ID ); function Priority (This : BG_Ref'Class) return Display_Priority is ( This.Control.Priority ); function Mosaic_Enabled (This : BG_Ref'Class) return Boolean is ( This.Control.Enable_Mosaic ); procedure Set_Priority (This : in out BG_Ref'Class; Priority : Display_Priority) is begin This.Control.Priority := Priority; end; procedure Enable_Mosaic (This : in out BG_Ref'Class; Enable : Boolean := True) is begin This.Control.Enable_Mosaic := Enable; end; procedure Update_Control_Info (This : in out BG_Ref'Class) is begin Update (BG_Control_Info (This.Control.all)); end; procedure Refresh_Offset_Register (This : in out Reg_BG_Ref'Class) with Inline_Always is begin Set_Offset (This.ID, This.Offset); end; function Offset (This : Reg_BG_Ref'Class) return BG_Offset_Info is ( This.Offset ); procedure Set_Offset ( This : in out Reg_BG_Ref'Class; Offset : BG_Offset_Info ) is begin This.Offset := Offset; Refresh_Offset_Register (This); end; procedure Set_Offset ( This : in out Reg_BG_Ref'Class; X, Y : BG_Scroll_Offset ) is begin This.Offset := (X => X, Y => Y); Refresh_Offset_Register (This); end; procedure Set_Offset_X (This : in out Reg_BG_Ref'Class; Value : BG_Scroll_Offset) is begin This.Offset.X := Value; Refresh_Offset_Register (This); end; procedure Set_Offset_Y (This : in out Reg_BG_Ref'Class; Value : BG_Scroll_Offset) is begin This.Offset.Y := Value; Refresh_Offset_Register (This); end; procedure Move_Offset (This : in out Reg_BG_Ref'Class; DX, DY : BG_Scroll_Offset := 0) is begin This.Offset := ( X => This.Offset.X + DX , Y => This.Offset.Y + DY ); Refresh_Offset_Register (This); end; procedure Update_Offset (This : in out Reg_BG_Ref'Class) is begin Update (This.Offset); Refresh_Offset_Register (This); end; procedure Refresh_Transform_Info (This : Aff_BG_Ref'Class) with Inline_Always is begin Set_Transform (This.ID, This.Transform_Info); end; procedure Refresh_Affine_Matrix (This : Aff_BG_Ref'Class) with Inline_Always is begin Set_Affine_Matrix (This.ID, This.Transform_Info.Affine_Matrix); end; procedure Refresh_Reference_Point (This : Aff_BG_Ref'Class) with Inline_Always is begin Set_Reference_Point (This.ID, This.Transform_Info.Reference_Point); end; function Transform (This : Aff_BG_Ref'Class) return Affine_Transform_Matrix is begin return This.Transform_Info.Affine_Matrix; end; function Reference_Point (This : Aff_BG_Ref'Class) return BG_Reference_Point is begin return This.Transform_Info.Reference_Point; end; procedure Set_Reference_Point (This : in out Aff_BG_Ref'Class; Reference_Point : BG_Reference_Point) is begin This.Transform_Info.Reference_Point := Reference_Point; Refresh_Reference_Point (This); end; procedure Set_Reference_Point (This : in out Aff_BG_Ref'Class; X, Y : BG_Reference_Point_Coordinate) is begin This.Transform_Info.Reference_Point := (X => X, Y => Y); Refresh_Reference_Point (This); end; procedure Set_Reference_X (This : in out Aff_BG_Ref'Class; Value : BG_Reference_Point_Coordinate) is begin This.Transform_Info.Reference_Point.X := Value; Set_Reference_X (This.ID, Value); end; procedure Set_Reference_Y (This : in out Aff_BG_Ref'Class; Value : BG_Reference_Point_Coordinate) is begin This.Transform_Info.Reference_Point.Y := Value; Set_Reference_Y (This.ID, Value); end; procedure Move_Reference_Point (This : in out Aff_BG_Ref'Class; DX, DY : BG_Reference_Point_Coordinate := 0.0) is RP : BG_Reference_Point renames This.Transform_Info.Reference_Point; begin RP := (X => RP.X + DX, Y => RP.Y + DY); Refresh_Reference_Point (This); end; procedure Update_Transform (This : in out Aff_BG_Ref'Class) is begin Update (This.Transform_Info); Refresh_Transform_Info (This); end; end GBA.Display.Backgrounds.Refs;
30,612
ada
1
ekoeppen/STM32_Generic_Ada_Drivers
examples/stm32f0/i2c/peripherals.adb
<reponame>ekoeppen/STM32_Generic_Ada_Drivers<gh_stars>1-10 with System; with STM32_SVD; use STM32_SVD; with STM32_SVD.RCC; use STM32_SVD.RCC; with STM32GD.Board; use STM32GD.Board; with STM32GD.GPIO; use STM32GD.GPIO; package body Peripherals is procedure Init is begin RCC.RCC_Periph.APB1ENR.I2C1EN := 1; RCC.RCC_Periph.APB2ENR.USART1EN := 1; RCC.RCC_Periph.APB2ENR.ADCEN := 1; SCL_OUT.Init; for I in Integer range 0 .. 10 loop -- SCL_OUT.Toggle; for J in Integer range 0 .. 1000 loop null; end loop; end loop; SCL.Init; SDA.Init; I2C.Init; RX.Init; TX.Init; USART.Init; end Init; end Peripherals;
30,613
ada
1
io7m/coreland-openal-ada
UNIT_TESTS/init_003.adb
<filename>UNIT_TESTS/init_003.adb with Test; with OpenAL.Context; with OpenAL.Context.Error; procedure init_003 is package ALC renames OpenAL.Context; package ALC_Error renames OpenAL.Context.Error; Device : ALC.Device_t; Context : ALC.Context_t; Current_OK : Boolean; TC : Test.Context_t; use type ALC.Device_t; use type ALC.Context_t; use type ALC_Error.Error_t; begin Test.Initialize (Test_Context => TC, Program => "init_003", Test_DB => "TEST_DB", Test_Results => "TEST_RESULTS"); Device := ALC.Open_Default_Device; pragma Assert (Device /= ALC.Invalid_Device); pragma Assert (ALC_Error.Get_Error (Device) = ALC_Error.No_Error); Context := ALC.Create_Context (Device); pragma Assert (Context /= ALC.Invalid_Context); pragma Assert (ALC_Error.Get_Error (Device) = ALC_Error.No_Error); Current_OK := ALC.Get_Current_Context = ALC.Null_Context; Test.Check (TC, 12, Current_OK, "Current_OK"); Test.Check (TC, 13, ALC_Error.Get_Error (Device) = ALC_Error.No_Error, "ALC_Error.Get_Error (Device) = ALC_Error.No_Error"); Current_OK := ALC.Make_Context_Current (Context); pragma Assert (Current_OK); pragma Assert (ALC_Error.Get_Error (Device) = ALC_Error.No_Error); Current_OK := ALC.Get_Current_Context = Context; Test.Check (TC, 14, Current_OK, "Current_OK"); Test.Check (TC, 15, ALC_Error.Get_Error (Device) = ALC_Error.No_Error, "ALC_Error.Get_Error (Device) = ALC_Error.No_Error"); Current_OK := ALC.Get_Context_Device (Context) = Device; Test.Check (TC, 16, Current_OK, "Current_OK"); Test.Check (TC, 17, ALC_Error.Get_Error (Device) = ALC_Error.No_Error, "ALC_Error.Get_Error (Device) = ALC_Error.No_Error"); ALC.Destroy_Context (Context); pragma Assert (ALC_Error.Get_Error (Device) = ALC_Error.No_Error); ALC.Close_Device (Device); pragma Assert (Device = ALC.Invalid_Device); end init_003;
30,614
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c3/c36205l.ada
<reponame>best08618/asylo -- C36205L.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- OBJECTIVE -- FOR GENERIC PROCEDURES, CHECK THAT ATTRIBUTES GIVE THE -- CORRECT VALUES FOR UNCONSTRAINED FORMAL PARAMETERS. -- BASIC CHECKS OF ARRAY OBJECTS AND WHOLE ARRAYS PASSED AS -- PARAMETERS TO GENERIC PROCEDURES -- HISTORY -- <NAME>, 9 AUGUST 1990 -- DAS 8 OCT 1990 ADDED OUT MODE PARAMETER TO GENERIC -- PROCEDURE TEST_PROCEDURE AND FORMAL -- GENERIC PARAMETER COMPONENT_VALUE. WITH REPORT ; PROCEDURE C36205L IS SHORT_START : CONSTANT := -100 ; SHORT_END : CONSTANT := 100 ; TYPE SHORT_RANGE IS RANGE SHORT_START .. SHORT_END ; SHORT_LENGTH : CONSTANT NATURAL := (SHORT_END - SHORT_START + 1) ; MEDIUM_START : CONSTANT := 1 ; MEDIUM_END : CONSTANT := 100 ; TYPE MEDIUM_RANGE IS RANGE MEDIUM_START .. MEDIUM_END ; MEDIUM_LENGTH : CONSTANT NATURAL := (MEDIUM_END - MEDIUM_START + 1) ; TYPE MONTH_TYPE IS (JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC) ; TYPE DAY_TYPE IS RANGE 1 .. 31 ; TYPE YEAR_TYPE IS RANGE 1904 .. 2050 ; TYPE DATE IS RECORD MONTH : MONTH_TYPE ; DAY : DAY_TYPE ; YEAR : YEAR_TYPE ; END RECORD ; TODAY : DATE := (MONTH => AUG, DAY => 9, YEAR => 1990) ; SUBTYPE SHORT_STRING IS STRING (1 ..5) ; DEFAULT_STRING : SHORT_STRING := "ABCDE" ; TYPE FIRST_TEMPLATE IS ARRAY (SHORT_RANGE RANGE <>, MEDIUM_RANGE RANGE <>) OF DATE ; TYPE SECOND_TEMPLATE IS ARRAY (MONTH_TYPE RANGE <>, DAY_TYPE RANGE <>) OF SHORT_STRING ; TYPE THIRD_TEMPLATE IS ARRAY (CHARACTER RANGE <>, BOOLEAN RANGE <>) OF DAY_TYPE ; FIRST_ARRAY : FIRST_TEMPLATE (-10 .. 10, 27 .. 35) := (-10 .. 10 => (27 .. 35 => TODAY)) ; SECOND_ARRAY : SECOND_TEMPLATE (JAN .. JUN, 1 .. 25) := (JAN .. JUN => (1 .. 25 => DEFAULT_STRING)) ; THIRD_ARRAY : THIRD_TEMPLATE ('A' .. 'Z', FALSE .. TRUE) := ('A' .. 'Z' => (FALSE .. TRUE => DAY_TYPE (9))) ; FOURTH_ARRAY : FIRST_TEMPLATE (0 .. 27, 75 .. 100) := (0 .. 27 => (75 .. 100 => TODAY)) ; FIFTH_ARRAY : SECOND_TEMPLATE (JUL .. OCT, 6 .. 10) := (JUL .. OCT => (6 .. 10 => DEFAULT_STRING)) ; SIXTH_ARRAY : THIRD_TEMPLATE ('X' .. 'Z', TRUE .. TRUE) := ('X' .. 'Z' => (TRUE .. TRUE => DAY_TYPE (31))) ; GENERIC TYPE FIRST_INDEX IS (<>) ; TYPE SECOND_INDEX IS (<>) ; TYPE COMPONENT_TYPE IS PRIVATE ; TYPE UNCONSTRAINED_ARRAY IS ARRAY (FIRST_INDEX RANGE <>, SECOND_INDEX RANGE <>) OF COMPONENT_TYPE ; COMPONENT_VALUE: IN COMPONENT_TYPE; PROCEDURE TEST_PROCEDURE (FIRST : IN UNCONSTRAINED_ARRAY ; FFIFS : IN FIRST_INDEX ; FFILS : IN FIRST_INDEX ; FSIFS : IN SECOND_INDEX ; FSILS : IN SECOND_INDEX ; FFLEN : IN NATURAL ; FSLEN : IN NATURAL ; FFIRT : IN FIRST_INDEX ; FSIRT : IN SECOND_INDEX ; SECOND : OUT UNCONSTRAINED_ARRAY ; SFIFS : IN FIRST_INDEX ; SFILS : IN FIRST_INDEX ; SSIFS : IN SECOND_INDEX ; SSILS : IN SECOND_INDEX ; SFLEN : IN NATURAL ; SSLEN : IN NATURAL ; SFIRT : IN FIRST_INDEX ; SSIRT : IN SECOND_INDEX ; REMARKS : IN STRING) ; PROCEDURE TEST_PROCEDURE (FIRST : IN UNCONSTRAINED_ARRAY ; FFIFS : IN FIRST_INDEX ; FFILS : IN FIRST_INDEX ; FSIFS : IN SECOND_INDEX ; FSILS : IN SECOND_INDEX ; FFLEN : IN NATURAL ; FSLEN : IN NATURAL ; FFIRT : IN FIRST_INDEX ; FSIRT : IN SECOND_INDEX ; SECOND : OUT UNCONSTRAINED_ARRAY ; SFIFS : IN FIRST_INDEX ; SFILS : IN FIRST_INDEX ; SSIFS : IN SECOND_INDEX ; SSILS : IN SECOND_INDEX ; SFLEN : IN NATURAL ; SSLEN : IN NATURAL ; SFIRT : IN FIRST_INDEX ; SSIRT : IN SECOND_INDEX ; REMARKS : IN STRING) IS BEGIN -- TEST_PROCEDURE IF (FIRST'FIRST /= FFIFS) OR (FIRST'FIRST (1) /= FFIFS) OR (FIRST'FIRST (2) /= FSIFS) OR (SECOND'FIRST /= SFIFS) OR (SECOND'FIRST (1) /= SFIFS) OR (SECOND'FIRST (2) /= SSIFS) THEN REPORT.FAILED ("PROBLEMS WITH 'FIRST. " & REMARKS) ; END IF ; IF (FIRST'LAST /= FFILS) OR (FIRST'LAST (1) /= FFILS) OR (FIRST'LAST (2) /= FSILS) OR (SECOND'LAST /= SFILS) OR (SECOND'LAST (1) /= SFILS) OR (SECOND'LAST (2) /= SSILS) THEN REPORT.FAILED ("PROBLEMS WITH 'LAST. " & REMARKS) ; END IF ; IF (FIRST'LENGTH /= FFLEN) OR (FIRST'LENGTH (1) /= FFLEN) OR (FIRST'LENGTH (2) /= FSLEN) OR (SECOND'LENGTH /= SFLEN) OR (SECOND'LENGTH (1) /= SFLEN) OR (SECOND'LENGTH (2) /= SSLEN) THEN REPORT.FAILED ("PROBLEMS WITH 'LENGTH. " & REMARKS) ; END IF ; IF (FFIRT NOT IN FIRST'RANGE (1)) OR (FFIRT NOT IN FIRST'RANGE) OR (SFIRT NOT IN SECOND'RANGE (1)) OR (SFIRT NOT IN SECOND'RANGE) OR (FSIRT NOT IN FIRST'RANGE (2)) OR (SSIRT NOT IN SECOND'RANGE (2)) THEN REPORT.FAILED ("INCORRECT HANDLING OF 'RANGE " & "ATTRIBUTE. " & REMARKS) ; END IF ; -- ASSIGN VALUES TO THE ARRAY PARAMETER OF MODE OUT FOR I IN SECOND'RANGE(1) LOOP FOR J IN SECOND'RANGE(2) LOOP SECOND(I, J) := COMPONENT_VALUE; END LOOP; END LOOP; END TEST_PROCEDURE ; PROCEDURE FIRST_TEST_PROCEDURE IS NEW TEST_PROCEDURE ( FIRST_INDEX => SHORT_RANGE, SECOND_INDEX => MEDIUM_RANGE, COMPONENT_TYPE => DATE, UNCONSTRAINED_ARRAY => FIRST_TEMPLATE, COMPONENT_VALUE => TODAY) ; PROCEDURE SECOND_TEST_PROCEDURE IS NEW TEST_PROCEDURE ( FIRST_INDEX => MONTH_TYPE, SECOND_INDEX => DAY_TYPE, COMPONENT_TYPE => SHORT_STRING, UNCONSTRAINED_ARRAY => SECOND_TEMPLATE, COMPONENT_VALUE => DEFAULT_STRING) ; PROCEDURE THIRD_TEST_PROCEDURE IS NEW TEST_PROCEDURE ( FIRST_INDEX => CHARACTER, SECOND_INDEX => BOOLEAN, COMPONENT_TYPE => DAY_TYPE, UNCONSTRAINED_ARRAY => THIRD_TEMPLATE, COMPONENT_VALUE => DAY_TYPE'FIRST) ; BEGIN -- C36205L REPORT.TEST ( "C36205L","FOR GENERIC PROCEDURES, CHECK THAT " & "ATTRIBUTES GIVE THE CORRECT VALUES FOR " & "UNCONSTRAINED FORMAL PARAMETERS. BASIC " & "CHECKS OF ARRAY OBJECTS AND WHOLE ARRAYS " & "PASSED AS PARAMETERS TO GENERIC PROCEDURES"); FIRST_TEST_PROCEDURE (FIRST => FIRST_ARRAY, FFIFS => -10, FFILS => 10, FSIFS => 27, FSILS => 35, FFLEN => 21, FSLEN => 9, FFIRT => 0, FSIRT => 29, SECOND => FOURTH_ARRAY, SFIFS => 0, SFILS => 27, SSIFS => 75, SSILS => 100, SFLEN => 28, SSLEN => 26, SFIRT => 5, SSIRT => 100, REMARKS => "FIRST_TEST_PROCEDURE") ; SECOND_TEST_PROCEDURE (FIRST => SECOND_ARRAY, FFIFS => JAN, FFILS => JUN, FSIFS => 1, FSILS => 25, FFLEN => 6, FSLEN => 25, FFIRT => MAR, FSIRT => 17, SECOND => FIFTH_ARRAY, SFIFS => JUL, SFILS => OCT, SSIFS => 6, SSILS => 10, SFLEN => 4, SSLEN => 5, SFIRT => JUL, SSIRT => 6, REMARKS => "SECOND_TEST_PROCEDURE") ; THIRD_TEST_PROCEDURE (FIRST => THIRD_ARRAY, FFIFS => 'A', FFILS => 'Z', FSIFS => FALSE, FSILS => TRUE, FFLEN => 26, FSLEN => 2, FFIRT => 'T', FSIRT => TRUE, SECOND => SIXTH_ARRAY, SFIFS => 'X', SFILS => 'Z', SSIFS => TRUE, SSILS => TRUE, SFLEN => 3, SSLEN => 1, SFIRT => 'Z', SSIRT => TRUE, REMARKS => "THIRD_TEST_PROCEDURE") ; REPORT.RESULT ; END C36205L ;
30,615
ada
8
flyx/OpenCLAda
src/interface/cl-programs.ads
<filename>src/interface/cl-programs.ads -------------------------------------------------------------------------------- -- Copyright (c) 2013, <NAME> <<EMAIL>> -- -- Permission to use, copy, modify, and/or distribute this software for any -- purpose with or without fee is hereby granted, provided that the above -- copyright notice and this permission notice appear in all copies. -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -------------------------------------------------------------------------------- with Ada.Containers.Indefinite_Vectors; with CL.Platforms; with System.Storage_Elements; with CL.Contexts; package CL.Programs is type Program is new Runtime_Object with null record; package SSE renames System.Storage_Elements; type Binary_List is array (Positive range <>) of access SSE.Storage_Array; package String_Vectors is new Ada.Containers.Indefinite_Vectors (Positive, String); subtype String_List is String_Vectors.Vector; type Bool_List is array (Positive range <>) of Boolean; type Build_Status is (In_Progress, Error, None, Success); type Build_Callback is access procedure (Subject : Program); package Constructors is function Create_From_Source (Context : Contexts.Context'Class; Source : String) return Program; -- Create a program from a list of OpenCL sources. function Create_From_Source (Context : Contexts.Context'Class; Sources : String_List) return Program; -- Create a program from a list of files containing OpenCL sources. -- The files can be provided as relative or absolute paths. function Create_From_Files (Context : Contexts.Context'Class; Sources : String_List) return Program; -- The result for each binary in Binaries will be stored in Success -- at the position of the binary's index in Binaries. Therefore, Success -- should have a range covering all indexes Binaries contains. -- If Success misses an index present in Binaries, Invalid_Arg_Size will -- be raised. -- Success.all(I) will be True iff Binaries(I) was loaded successfully. -- Iff Success is null, it will be ignored and instead an Invalid_Binary -- exception will be raised if any of the Binaries fails to build. function Create_From_Binary (Context : Contexts.Context'Class; Devices : Platforms.Device_List; Binaries : Binary_List; Success : access Bool_List) return Program; end Constructors; overriding procedure Adjust (Object : in out Program); overriding procedure Finalize (Object : in out Program); procedure Build (Source : Program; Devices : Platforms.Device_List; Options : String; Callback : Build_Callback); function Reference_Count (Source : Program) return UInt; function Context (Source : Program) return Contexts.Context; function Devices (Source : Program) return Platforms.Device_List; function Source (Source : Program) return String; function Binaries (Source : Program) return Binary_List; function Status (Source : Program; Device : Platforms.Device) return Build_Status; function Build_Options (Source : Program; Device : Platforms.Device) return String; function Build_Log (Source : Program; Device : Platforms.Device) return String; procedure Unload_Compiler; private for Build_Status use (Success => 0, None => -1, Error => -2, In_Progress => -3); for Build_Status'Size use Int'Size; pragma Convention (C, Build_Callback); end CL.Programs;
30,616
ada
0
joffreyhuguet/LmcpGen
ada/src/afrl/afrl.ads
package afrl is end afrl;
30,617
ada
0
reznikmm/slimp
source/slim-messages-bdac.adb
-- Copyright (c) 2019 <NAME> <<EMAIL>> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Slim.Message_Visiters; package body Slim.Messages.bdac is List : constant Field_Description_Array := ((Uint_8_Field, 1), -- Kind (Custom_Field, 1)); -- Data ---------- -- Read -- ---------- overriding function Read (Data : not null access League.Stream_Element_Vectors.Stream_Element_Vector) return Bdac_Message is begin return Result : Bdac_Message do Read_Fields (Result, List, Data.all); end return; end Read; ----------------------- -- Read_Custom_Field -- ----------------------- overriding procedure Read_Custom_Field (Self : in out Bdac_Message; Index : Positive; Input : in out Ada.Streams.Stream_Element_Offset; Data : League.Stream_Element_Vectors.Stream_Element_Vector) is use type Ada.Streams.Stream_Element_Offset; Content : constant Ada.Streams.Stream_Element_Array (1 .. Data.Length) := Data.To_Stream_Element_Array; begin pragma Assert (Index = 1); Self.Data.Clear; Self.Data.Append (Content (Input .. Content'Last)); Input := Content'Last + 1; end Read_Custom_Field; ---------------- -- Initialize -- ---------------- not overriding procedure Initialize (Self : in out Bdac_Message; Kind : Natural; Value : Ada.Streams.Stream_Element_Array) is begin Self.Data.Clear; Self.Data.Append (Value); Self.Data_8 := (1 => Interfaces.Unsigned_8 (Kind)); end Initialize; ----------- -- Visit -- ----------- overriding procedure Visit (Self : not null access Bdac_Message; Visiter : in out Slim.Message_Visiters.Visiter'Class) is begin Visiter.bdac (Self); end Visit; ----------- -- Write -- ----------- overriding procedure Write (Self : Bdac_Message; Tag : out Message_Tag; Data : out League.Stream_Element_Vectors.Stream_Element_Vector) is begin Tag := "bdac"; Write_Fields (Self, List, Data); end Write; ------------------------ -- Write_Custom_Field -- ------------------------ overriding procedure Write_Custom_Field (Self : Bdac_Message; Index : Positive; Data : in out League.Stream_Element_Vectors.Stream_Element_Vector) is begin pragma Assert (Index = 1); Data.Append (Self.Data); end Write_Custom_Field; end Slim.Messages.bdac;
30,618
ada
1
vidkidz/crossbridge
llvm-gcc-4.2-2.9/gcc/ada/a-crbtgo.ads
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- A D A . C O N T A I N E R S . R E D _ B L A C K _ T R E E S . -- -- G E N E R I C _ O P E R A T I O N S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2004-2005, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- -- apply solely to the contents of the part following the private keyword. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- This unit was originally developed by <NAME>. -- ------------------------------------------------------------------------------ with Ada.Streams; use Ada.Streams; generic with package Tree_Types is new Generic_Tree_Types (<>); use Tree_Types; with function Parent (Node : Node_Access) return Node_Access is <>; with procedure Set_Parent (Node : Node_Access; Parent : Node_Access) is <>; with function Left (Node : Node_Access) return Node_Access is <>; with procedure Set_Left (Node : Node_Access; Left : Node_Access) is <>; with function Right (Node : Node_Access) return Node_Access is <>; with procedure Set_Right (Node : Node_Access; Right : Node_Access) is <>; with function Color (Node : Node_Access) return Color_Type is <>; with procedure Set_Color (Node : Node_Access; Color : Color_Type) is <>; package Ada.Containers.Red_Black_Trees.Generic_Operations is pragma Pure; function Min (Node : Node_Access) return Node_Access; function Max (Node : Node_Access) return Node_Access; -- NOTE: The Check_Invariant operation was used during early -- development of the red-black tree. Now that the tree type -- implementation has matured, we don't really need Check_Invariant -- anymore. -- procedure Check_Invariant (Tree : Tree_Type); function Vet (Tree : Tree_Type; Node : Node_Access) return Boolean; function Next (Node : Node_Access) return Node_Access; function Previous (Node : Node_Access) return Node_Access; generic with function Is_Equal (L, R : Node_Access) return Boolean; function Generic_Equal (Left, Right : Tree_Type) return Boolean; procedure Delete_Node_Sans_Free (Tree : in out Tree_Type; Node : Node_Access); generic with procedure Free (X : in out Node_Access); procedure Generic_Delete_Tree (X : in out Node_Access); generic with function Copy_Node (Source : Node_Access) return Node_Access; with procedure Delete_Tree (X : in out Node_Access); function Generic_Copy_Tree (Source_Root : Node_Access) return Node_Access; generic with function Copy_Tree (Root : Node_Access) return Node_Access; procedure Generic_Adjust (Tree : in out Tree_Type); generic with procedure Delete_Tree (X : in out Node_Access); procedure Generic_Clear (Tree : in out Tree_Type); generic with procedure Clear (Tree : in out Tree_Type); procedure Generic_Move (Target, Source : in out Tree_Type); generic with procedure Process (Node : Node_Access) is <>; procedure Generic_Iteration (Tree : Tree_Type); generic with procedure Process (Node : Node_Access) is <>; procedure Generic_Reverse_Iteration (Tree : Tree_Type); generic with procedure Write_Node (Stream : access Root_Stream_Type'Class; Node : Node_Access); procedure Generic_Write (Stream : access Root_Stream_Type'Class; Tree : Tree_Type); generic with procedure Clear (Tree : in out Tree_Type); with function Read_Node (Stream : access Root_Stream_Type'Class) return Node_Access; procedure Generic_Read (Stream : access Root_Stream_Type'Class; Tree : in out Tree_Type); procedure Rebalance_For_Insert (Tree : in out Tree_Type; Node : Node_Access); end Ada.Containers.Red_Black_Trees.Generic_Operations;
30,619
ada
4
faelys/gela-asis
source/asis/asis-gela-unit_utils.ads
<reponame>faelys/gela-asis ------------------------------------------------------------------------------ -- G E L A A S I S -- -- ASIS implementation for Gela project, a portable Ada compiler -- -- http://gela.ada-ru.org -- -- - - - - - - - - - - - - - - - -- -- Read copyright and license at the end of this file -- ------------------------------------------------------------------------------ -- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $ -- Purpose: -- Helper procedures to implement compilation unit abstraction with Asis.Gela.Compilations; package Asis.Gela.Unit_Utils is procedure Set_Unit_Kind (Unit : Compilation_Unit); procedure Set_Unit_Class (Unit : in Compilation_Unit; Is_Private : in Boolean); procedure Set_Unit_Origin (Unit : Compilation_Unit); procedure Set_Unit_Full_Name (Unit : Compilation_Unit); procedure Set_Unique_Name (Unit : Compilation_Unit); procedure Set_Can_Be_Main_Program (Unit : Compilation_Unit); procedure Set_Is_Body_Required (Unit : Compilation_Unit); procedure Set_Text_Name (Unit : Compilation_Unit); procedure Set_Text_Form (Unit : Compilation_Unit); procedure Set_Object_Name (Unit : Compilation_Unit); procedure Set_Object_Form (Unit : Compilation_Unit); procedure Set_Compilation_Command_Line_Options (Unit : Compilation_Unit); procedure Set_Separate_Name (Unit : Compilation_Unit); function Is_Program_Unit_Pragma (Kind : Pragma_Kinds) return Boolean; function Is_Configuration_Pragma (Kind : Pragma_Kinds) return Boolean; function Is_Compilation_Unit_Body (The_Unit : Asis.Compilation_Unit) return Boolean; procedure Add_Pragma (The_Unit : Asis.Element; The_Pragma : Asis.Element; To_Clause : Boolean := False); procedure Add_Subunit (The_Unit : Compilation_Unit; The_Subunit : Compilation_Unit); procedure Add_Child (The_Unit : Compilation_Unit; The_Child : Compilation_Unit); procedure Set_Body (The_Unit : Compilation_Unit; The_Body : Compilation_Unit); function Make_Nonexistent_Unit (The_Context : Context; Full_Unit_Name : Program_Text; Unit_Kind : Unit_Kinds) return Compilation_Unit; procedure Set_Compilation (The_Unit : Compilation_Unit; Compilation : Compilations.Compilation); function Compilation (The_Unit : Compilation_Unit) return Compilations.Compilation; procedure Remove_Context_Clause (The_Unit : Compilation_Unit; Element : Asis.Element); -- procedure Set_Full_Name -- (The_Unit : Compilation_Unit); function Make_Limited_View_Unit (The_Context : Context; Declaration : Compilation_Unit) return Compilation_Unit; procedure Set_Unit_Declaration (Unit : Compilation_Unit; Declaration : Asis.Element); end Asis.Gela.Unit_Utils; ------------------------------------------------------------------------------ -- Copyright (c) 2006-2013, <NAME> -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- * Redistributions of source code must retain the above copyright notice, -- this list of conditions and the following disclaimer. -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- * Neither the name of the Maxim Reznik, IE nor the names of its -- contributors may be used to endorse or promote products derived from -- this software without specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------
30,620
ada
0
faelys/natools
generated/natools-static_maps-s_expressions-templates-dates-t.adb
-- Generated at 2015-06-24 18:19:13 +0000 by Natools.Static_Hash_Maps -- from src/natools-s_expressions-templates-dates-maps.sx with Natools.Static_Maps.S_Expressions.Templates.Dates.Cmds; with Natools.Static_Maps.S_Expressions.Templates.Dates.Zones; function Natools.Static_Maps.S_Expressions.Templates.Dates.T return Boolean is begin for I in Map_1_Keys'Range loop if Natools.Static_Maps.S_Expressions.Templates.Dates.Cmds.Hash (Map_1_Keys (I).all) /= I then return False; end if; end loop; for I in Map_2_Keys'Range loop if Natools.Static_Maps.S_Expressions.Templates.Dates.Zones.Hash (Map_2_Keys (I).all) /= I then return False; end if; end loop; return True; end Natools.Static_Maps.S_Expressions.Templates.Dates.T;
30,621
ada
0
xiashuangxi/coconut
src/account-vector.adb
package body Account.Vector is procedure Add(Item: in out Account_Stack; C: in Default_Account.Instance) is begin Item.Append(C); end Add; procedure Delete(Item: in out Account_Stack; C: in Default_Account.Instance) is begin Item.Delete(Item.Find_Index(C)); end Delete; procedure Delete(Item: in out Account_Stack; I: Integer) is begin Item.Delete(I); end Delete; end Account.Vector;
30,622
ada
0
leomlr/sudoku_ada-jewl
src/JEWL/jewl-windows.ads
<filename>src/JEWL/jewl-windows.ads ------------------------------------------------------------------------------ -- -- -- J E W L . W I N D O W S -- -- -- -- A package for developing GUI-based programs for beginners. -- -- -- -- This is a large package, but splitting it into child packages would -- -- require multiple generic instantiations in order to use it. -- -- -- -- Copyright (C) <NAME> 2000. Contact address: <EMAIL> -- -- This software is released under the terms of the GNU General Public -- -- License and is intended primarily for educational use. Please contact -- -- the author to report bugs, suggestions and modifications. -- -- -- ------------------------------------------------------------------------------ -- $Id: jewl-windows.ads 1.7 2007/01/08 17:00:00 JE Exp $ ------------------------------------------------------------------------------ -- -- $Log: jewl-windows.ads $ -- Revision 1.7 2007/01/08 17:00:00 JE -- * Fixed linker options in JEWL.Win32_Interface to accommodate changes to GNAT -- GPL 2006 compiler (thanks to <NAME> for this) -- * Added delay in message loop to avoid the appearance of hogging 100% of CPU -- time -- -- Revision 1.6 2001/11/02 16:00:00 JE -- * Fixed canvas bug when saving an empty canvas -- * Restore with no prior save now acts as erase -- * Removed redundant variable declaration in Image function -- -- Revision 1.5 2001/08/22 15:00:00 JE -- * Minor bugfix to Get_Text for combo boxes -- * Minor changes to documentation (including new example involving dialogs) -- -- Revision 1.4 2001/01/25 09:00:00 je -- Changes visible to the user: -- -- * Added support for drawing bitmaps on canvases (Draw_Image operations -- and new type Image_Type) -- * Added Play_Sound -- * Added several new operations on all windows: Get_Origin, Get_Width, -- Get_Height, Set_Origin, Set_Size and Focus -- * Added several functions giving screen and window dimensions: Screen_Width, -- Screen_Height, Frame_Width, Frame_Height, Dialog_Width, Dialog_Height and -- Menu_Height -- * Canvases can now handle keyboard events: new constructor and Key_Code added -- * Added procedure Play_Sound -- * Operations "+" and "-" added for Point_Type -- * Pens can now be zero pixels wide -- * The absolute origin of a frame can now have be specified when the frame -- is created -- * Added new File_Dialog operations Add_Filter and Set_Directory -- * Added Get_Line renames to JEWL.IO for compatibility with Ada.Text_IO -- * Added all the Get(File,Item) operations mentioned in documentation but -- unaccountably missing :-( -- * Documentation updated to reflect the above changes -- * HTML versions of public package specifications added with links from -- main documentation pages -- -- Other internal changes: -- -- * Canvas fonts, pens etc. now use JEWL.Reference_Counted_Type rather than -- reinventing this particular wheel, as do images -- * Various minor code formatting changes: some code reordered for clarity, -- some comments added or amended, -- * Changes introduced in 1.2 to support GNAT 3.10 have been reversed, since -- GNAT 3.10 still couldn't compile this code correctly... ;-( -- -- Outstanding issues: -- -- * Optimisation breaks the code (workaround: don't optimise) -- -- Revision 1.3 2000/07/07 12:00:00 je -- * JEWL.Simple_Windows added; JEWL.IO modified to use JEWL.Simple_Windows. -- * JEWL.IO bug fix: Put_Line to file wrote newline to standard output -- instead of to the file (thanks to <NAME> for pointing this out). -- * Panels fixed so that mouse clicks are passed on correctly to subwindows. -- * Memos fixed so that tabs are handled properly. -- * Password feature added to editboxes. -- * Minor typos fixed in comments within the package sources. -- * Documentation corrected and updated following comments from <NAME> -- and <NAME>. -- -- Revision 1.2 2000/04/18 20:00:00 je -- * Minor code changes to enable compilation by GNAT 3.10 -- * Minor documentation errors corrected -- * Some redundant "with" clauses removed -- -- Revision 1.1 2000/04/09 21:00:00 je -- Initial revision -- ------------------------------------------------------------------------------ generic -- This is a generic package which must be type Command_Type is (<>); -- instantiated with a list of possible -- command values to be generated whenever package JEWL.Windows is -- a window is closed, a button is clicked -- or a menu item is selected. ---------------------------------------------------------------------------- -- Miscellaneous operations ---------------------------------------------------------------------------- procedure Show_Error (Text : in String; -- an error message Title : in String := "Error"); function Show_Query (Text : in String; -- a yes/no query Title : in String := "Query") return Boolean; procedure Show_Message (Text : in String; -- an information message Title : in String := "Message"); procedure Play_Sound (Sound : in String); -- play a sound file function Screen_Width return Natural; -- width of display screen function Screen_Height return Natural; -- height of display screen ---------------------------------------------------------------------------- -- -- S U P P O R T T Y P E S -- -- Except for Alignment_Type, these types are defined in the top-level -- package JEWL and are renamed here for convenience: -- -- Alignment_Type : used to specify text alignment with a window. -- Angle_Type : an angle specified as an integral number of -- degrees (0 to 359) -- Colour_Type : a colour specified as an RGB value. -- Font_Type : a font specified by a name, point size and bold -- and italic style options. -- Point_Type : a pair of (X,Y) coordinates within a window. -- Point_List : an array of (X,Y) coordinate pairs. -- ---------------------------------------------------------------------------- type Alignment_Type is (Left, Centre, Right); subtype Angle_Type is JEWL.Angle_Type; subtype Colour_Range is JEWL.Colour_Range; subtype Colour_Type is JEWL.Colour_Type; subtype Font_Type is JEWL.Font_Type; type Image_Type is private; subtype Point_Type is JEWL.Point_Type; subtype Point_List is JEWL.Point_List; ---------------------------------------------------------------------------- -- Renamings for our transatlantic cousins, in the hope that some day -- they'll repay the favour/favor... ;-) ---------------------------------------------------------------------------- subtype Color_Range is Colour_Range; subtype Color_Type is Colour_Type; function Center return Alignment_Type renames Centre; ---------------------------------------------------------------------------- -- -- O P E R A T I O N S O N S U P P O R T T Y P E S -- -- These are renamings of the operations defined in the parent package -- provided for convenience. -- -- Colour operations: -- Light : Generate a lightened version of a colour, e.g. Light(Red). -- Dark : Generate a darkened version of a colour, e.g. Dark(Green). -- -- Font operations: -- Font : Generate a font with the specified properties. -- Name : Get the name of the font typeface. -- Size : Get the font size in points. -- Bold : Test if the font is bold. -- Italic : Test if the font is italic. -- -- Image operations: -- Image : Load an image from a bitmap file. -- Valid : Test if an image is valid. -- Width : Get the width of an image. -- Height : Get the height of an image. -- -- Point operations: -- Endpoint : Calculate the endpoint of a line from a starting point, -- length and angle -- Inside : Test if a specified point is inside a specified rectangle -- (defined by the coordinates of two diagonally opposite -- corners). -- P1 + P2 : Add two points (P1.X+P2.X, P1.Y+P2.Y). -- P1 - P2 : Subtract two points (P1.X-P2.X, P1.Y-P2.Y). -- ---------------------------------------------------------------------------- function Light (Colour : JEWL.Colour_Type) return JEWL.Colour_Type renames JEWL.Light; function Dark (Colour : JEWL.Colour_Type) return JEWL.Colour_Type renames JEWL.Dark; function Font (Name : String; Size : Positive; Bold : Boolean := False; Italic : Boolean := False) return JEWL.Font_Type renames JEWL.Font; function Name (Font : Font_Type) return String renames JEWL.Name; function Size (Font : Font_Type) return Natural renames JEWL.Size; function Bold (Font : Font_Type) return Boolean renames JEWL.Bold; function Italic (Font : Font_Type) return Boolean renames JEWL.Italic; function Image (Name : String) return Image_Type; function Valid (Image : Image_Type) return Boolean; function Width (Image : Image_Type) return Natural; function Height (Image : Image_Type) return Natural; function Endpoint (From : JEWL.Point_Type; Length : Positive; Angle : JEWL.Angle_Type) return JEWL.Point_Type renames JEWL.Endpoint; function Inside (Point : JEWL.Point_Type; From : JEWL.Point_Type; To : JEWL.Point_Type) return Boolean renames JEWL.Inside; function "+" (P1, P2 : Point_Type) return Point_Type renames JEWL."+"; function "-" (P1, P2 : Point_Type) return Point_Type renames JEWL."-"; ---------------------------------------------------------------------------- -- -- S U P P O R T T Y P E C O N S T A N T S -- -- Angles : North, South, East and West -- Colours : Black, White, Red, Green, Blue, etc. -- Fonts : Default_Font (the default font for top-level windows) and -- Parent_Font (the same font as a window's parent uses) -- ---------------------------------------------------------------------------- North : constant Angle_Type := 0; South : constant Angle_Type := 180; East : constant Angle_Type := 90; West : constant Angle_Type := 270; Black : constant Colour_Type := ( 0, 0, 0); White : constant Colour_Type := (255,255,255); Red : constant Colour_Type := (255, 0, 0); Green : constant Colour_Type := ( 0,255, 0); Blue : constant Colour_Type := ( 0, 0,255); Gray : constant Colour_Type := (128,128,128); Yellow : constant Colour_Type := (255,255, 0); Cyan : constant Colour_Type := ( 0,255,255); Magenta : constant Colour_Type := (255, 0,255); Default_Font : constant Font_Type := Font("Arial",9); Parent_Font : constant Font_Type := Font("",1); ---------------------------------------------------------------------------- -- -- W I N D O W _ T Y P E -- -- An abstract class providing basic behaviour which all windows share. -- ---------------------------------------------------------------------------- type Window_Type is abstract tagged private; Invalid_Window : exception; -- raised if an attempt is made to use an -- invalid (non-open) window ---------------------------------------------------------------------------- -- -- Window operations (common to all windows): -- -- Show (Window, -- make the window visible or invisible depending -- Visible) -- on the value of Visible (default: True). -- Hide (Window) -- make the window invisible. -- Focus (Window) -- give the window the input focus. -- Visible (Window) -- return True if the window is visible. -- Get_Origin (Window) -- get the origin (top left point) of the -- -- specified window. -- Get_Width (Window) -- get the width of the specified window. -- Get_Height (Window) -- get the height of the specified window. -- Set_Origin (Window, -- set the origin (top left point) of the -- Origin) -- specified window to this value. -- Set_Size (Window, -- set the size of the specified window -- Width, -- to this width (optional) -- Height) -- and this height (optional). -- Get_Font (Window) -- get the font for the specified window. -- Set_Font (Window, -- set the font for the specified window -- Font) -- to this one. -- ---------------------------------------------------------------------------- procedure Show (Window : in Window_Type; Visible : in Boolean := True); procedure Hide (Window : in Window_Type); procedure Focus (Window : in Window_Type); function Visible (Window : Window_Type) return Boolean; function Get_Origin (Window : Window_Type) return Point_Type; function Get_Width (Window : Window_Type) return Natural; function Get_Height (Window : Window_Type) return Natural; procedure Set_Origin (Window : in Window_Type; Origin : in Point_Type); procedure Set_Size (Window : in Window_Type; Width : in Natural := 0; Height : in Natural := 0); function Get_Font (Window : Window_Type) return Font_Type; procedure Set_Font (Window : in Window_Type; Font : in Font_Type); ---------------------------------------------------------------------------- -- -- W I N D O W S U B C L A S S E S -- -- The primary window subclasses are containers and controls. They -- share the behaviour common to all windows (above) and provide extra -- behaviour as well. -- -- Container_Type : the abstract base type for all containers. -- Control_Type : the abstract base type for all controls. -- ---------------------------------------------------------------------------- type Container_Type is abstract new Window_Type with private; type Control_Type is abstract new Window_Type with private; ---------------------------------------------------------------------------- -- -- C O N T A I N E R S -- -- Containers are windows which can contain other windows. All windows -- except frames and dialogs (see below) must be contained within some -- other container window. There are some restrictions on the types of -- container that a window can be attached to (for example, a menu item -- must be attached to a menu). -- -- Most windows specify an origin, a width and a height whose coordinates -- are taken relative to the enclosing container. Positive widths and -- heights are absolute values, but zero and negative widths and heights -- are interpreted as being relative to the width and height of the -- enclosing container (so a width of 0 means the width of the enclosing -- container, a height of -10 means 10 pixels less than the height of the -- enclosing container). -- -- The types of container windows available are as follows: -- -- Frame_Type : a main window with a title bar, system menu, minimise -- and maximise buttons, and a close button. -- Dialog_Type : a top level window which is used for modal interaction, -- disabling other windows while the interaction takes -- place. -- Panel_Type : a plain window which is used as a container for other -- subwindows. -- Menu_Type : a menu which can contain menu items and submenus. -- ---------------------------------------------------------------------------- type Frame_Type is new Container_Type with private; type Dialog_Type is new Container_Type with private; type Panel_Type is new Container_Type with private; type Menu_Type is new Container_Type with private; ---------------------------------------------------------------------------- -- -- F R A M E S -- -- A frame is a top level window with a title bar, system menu, minimise -- and maximise buttons, and a close button. Closing a frame generates a -- command. Frames are normally visible, but can be hidden if required. -- A frame should be used as the main window for an application. -- -- Frame operations: -- -- Frame (Origin, -- create a frame at the specified position -- Width, -- with the specified width -- Height, -- and height in pixels, -- Title, -- with the specified title in the title bar, -- Command, -- generating this command when it is closed, -- Font) -- using this font (default: Default_Font). -- Frame (Width, -- create a frame with the specified width -- Height, -- and height in pixels, placed randomly, -- Title, -- with the specified title in the title bar, -- Command, -- generating this command when it is closed, -- Font) -- using this font (default: Default_Font). -- -- Close (Frame) -- close the frame. -- Valid (Frame) -- true until the frame is closed. -- -- Frame_Width -- return the width of the frame border. -- Frame_Height -- return the height of the frame border. -- -- Next_Command -- return the next command generated by any -- -- control in any existing frame. -- Command_Ready -- test if there is a command pending -- ---------------------------------------------------------------------------- function Frame (Origin : Point_Type; Width : Positive; Height : Positive; Title : String; Command : Command_Type; Font : Font_Type := Default_Font) return Frame_Type; function Frame (Width : Positive; Height : Positive; Title : String; Command : Command_Type; Font : Font_Type := Default_Font) return Frame_Type; procedure Close (Frame : in Frame_Type); function Valid (Frame : Frame_Type) return Boolean; function Frame_Width return Natural; function Frame_Height return Natural; function Next_Command return Command_Type; function Command_Ready return Boolean; ---------------------------------------------------------------------------- -- -- D I A L O G S -- -- A dialog is a top level window like a frame, but it only has a close -- button on its title bar. Dialogs are intended for user interaction. -- When a dialog is executed it becomes visible and all other windows -- are disabled. Execution of a dialog continues until a command is -- generated by closing the dialog window or by clicking on a button -- attached to the dialog. Dialog windows do not have a menu bar. -- -- Dialog operations: -- -- Dialog (Width, -- create a dialog with the given width and -- Height, -- and height in pixels, -- Title, -- with the specified title in the title bar, -- Command, -- generating this command when it is closed, -- Font) -- using this font (default: Default_Font). -- -- Execute (Dialog) -- execute a dialog and return the command code -- -- used to exit from it. -- -- Dialog_Width -- return the width of the dialog border. -- Dialog_Height -- return the height of the dialog border. -- ---------------------------------------------------------------------------- function Dialog (Width : Positive; Height : Positive; Title : String; Command : Command_Type; Font : Font_Type := Default_Font) return Dialog_Type; function Execute (Dialog : in Dialog_Type) return Command_Type; function Dialog_Width return Natural; function Dialog_Height return Natural; ---------------------------------------------------------------------------- -- -- P A N E L S -- -- -- Panel operations: -- -- Panel (Parent, -- create a panel inside a parent container, with -- Origin, -- top left coordinates relative to the parent, -- Width, -- with the specified width -- Height, -- and the specified height, and -- Title, -- with this title on the border (default: none) -- Font) -- using this font (default: same as Parent). -- ---------------------------------------------------------------------------- function Panel (Parent : Container_Type'Class; Origin : Point_Type; Width : Integer; Height : Integer; Title : String := ""; Font : Font_Type := Parent_Font) return Panel_Type; ---------------------------------------------------------------------------- -- -- M E N U S -- -- A menu is a pull-down list of items attached to a frame's menu bar. -- The items on a menu are either menuitems (which generate a command -- when they are selected, submenus (which display another menu when -- selected) or separators (horizontal bars used to separate a menu -- into subsections. -- -- If the text label for a menu contains the character "&", the character -- which follows is underlined and the menu can be activated by pressing -- Alt + that character. The character "&" is not displayed. -- -- Menu operations: -- -- Menu (Parent, -- create a menu attached to a frame or a menu -- Text) -- with the specified text label. -- -- Menu_Height -- return the height of a menu bar. -- ---------------------------------------------------------------------------- function Menu (Parent : Frame_Type'Class; Text : String) return Menu_Type; function Menu (Parent : Menu_Type'Class; Text : String) return Menu_Type; function Menu_Height return Natural; ---------------------------------------------------------------------------- -- -- C O N T R O L S -- -- Controls are windows for user interaction. They hold values (e.g. a -- text string) which can normally be set by the user, as well as being -- accessed and altered by the program itself. Some controls (e.g. menu -- items) generate command values which can be used to trigger actions -- in the program. The following operations are common to all controls: -- -- Enable (Control, -- enable or disable the control depending on -- Enabled) -- the value of Enabled (default: True). -- Disable (Control) -- disable the control. -- Enabled (Control) -- test if the control is enabled. -- ---------------------------------------------------------------------------- procedure Enable (Control : in Control_Type; Enabled : in Boolean := True); procedure Disable (Control : in Control_Type); function Enabled (Control : Control_Type) return Boolean; ---------------------------------------------------------------------------- -- -- The types of control available are as follows: -- -- Menuitem_Type : controls which can appear on pull-down menus -- Text_Control_Type : controls containing with a single-line text string -- Multiline_Type : controls containing multiple text strings -- Canvas_Type : a plain window for drawing arbitrary shapes on -- ---------------------------------------------------------------------------- type Text_Control_Type is abstract new Control_Type with private; type Multiline_Type is abstract new Control_Type with private; type Canvas_Type is new Control_Type with private; ---------------------------------------------------------------------------- -- -- T E X T C O N T R O L S -- -- Text controls include a single-line text string. The following -- operations are common to all text controls: -- -- Get_Length (Control) -- get the length of the text associated with the -- -- control. -- Get_Text (Control) -- get the text associated with the control as a -- -- string of indefinite size. -- Get_Text (Control, -- get the text associated with the control into -- Text, -- this fixed-size string variable -- Length) -- and set this integer variable to the actual -- -- number of characters copied. -- Set_Text (Control, -- set the text associated with the control. -- Text) -- to the specified new text value. -- ---------------------------------------------------------------------------- function Get_Length (Control : Text_Control_Type) return Natural; function Get_Text (Control : Text_Control_Type) return String; procedure Get_Text (Control : in Text_Control_Type; Text : out String; Length : out Natural); procedure Set_Text (Control : in Text_Control_Type; Text : in String); ---------------------------------------------------------------------------- -- -- The types of text control available are as follows: -- -- Button_Type : a pushbutton which generates a command code. -- Label_Type : a static non-interactive label. -- Editbox_Type : a single-line edit control for text input. -- -- There is a further subclass of text control, as follows: -- -- Boolean_Control_Type : a text control with an associated Boolean state -- ---------------------------------------------------------------------------- type Button_Type is new Text_Control_Type with private; type Label_Type is new Text_Control_Type with private; type Editbox_Type is new Text_Control_Type with private; type Boolean_Control_Type is abstract new Text_Control_Type with private; ---------------------------------------------------------------------------- -- -- B U T T O N S -- -- Buttons are rectangular labelled controls which generate a command -- code when pressed. "Default" buttons are displayed with a heavier -- border and respond when the Enter key is pressed. -- -- Button operations: -- -- Button (Parent, -- create a button in a parent container, with -- Origin, -- top left coordinates relative to the parent, -- Width, -- with the specified width -- Height, -- and the specified height, -- Text, -- labelled with the specified text, -- Command, -- generating this command when it is pressed, -- Default, -- set up as a "default" button (default: False), -- Font) -- using this font (default: same as Parent). -- ---------------------------------------------------------------------------- function Button (Parent : Container_Type'Class; Origin : Point_Type; Width : Integer; Height : Integer; Text : String; Command : Command_Type; Default : Boolean := False; Font : Font_Type := Parent_Font) return Button_Type; ---------------------------------------------------------------------------- -- -- L A B E L S -- -- A label is a static text control that can be used to label other -- controls. Labels do not respond to user interaction, but their -- values can be read and altered by the program in the same way as -- any other text control. -- -- Label operations: -- -- Label (Parent, -- create a label inside a container, with -- Origin, -- top left coordinates relative to the parent, -- Width, -- with the specified width -- Height, -- and the specified height, and -- Text, -- labelled with the specified text -- Align, -- aligned left, right or centre (default: Left), -- Font) -- using this font (default: same as Parent). -- ---------------------------------------------------------------------------- function Label (Parent : Container_Type'Class; Origin : Point_Type; Width : Integer; Height : Integer; Text : String; Align : Alignment_Type := Left; Font : Font_Type := Parent_Font) return Label_Type; ---------------------------------------------------------------------------- -- -- E D I T B O X E S -- -- An editbox is a text control containing a single line of text whose -- value can be edited by the user. -- -- Editbox operations: -- -- Editbox (Parent, -- create an editbox inside a container, with -- Origin, -- top left coordinates relative to the parent, -- Width, -- with the specified width -- Height, -- and the specified height, and -- Text, -- initialised with the specified text, -- Password, -- optionally set up as a password editbox, -- Font) -- using this font (default: same as Parent). -- -- Modified (Editbox) -- test if the editbox has been modified by the -- -- user. -- ---------------------------------------------------------------------------- function Editbox (Parent : Container_Type'Class; Origin : Point_Type; Width : Integer; Height : Integer; Text : String := ""; Password : Boolean := False; Font : Font_Type := Parent_Font) return Editbox_Type; function Modified (Editbox : Editbox_Type) return Boolean; ---------------------------------------------------------------------------- -- -- B O O L E A N C O N T R O L S -- -- Boolean controls are text controls which can be toggled between two -- states (checked or unchecked). The following operations are common -- to all Boolean controls: -- -- Get_State (Control) -- get the current state of the control -- Set_State (Control, -- set the current state of the control -- State) -- to the specified value -- ---------------------------------------------------------------------------- function Get_State (Control : Boolean_Control_Type) return Boolean; procedure Set_State (Control : in Boolean_Control_Type; State : in Boolean); ---------------------------------------------------------------------------- -- -- The types of Boolean controls available are as follows: -- -- Checkbox_Type : a checkbox which can be checked or unchecked. -- Radiobutton_Type : a radio button which can be checked or unchecked. -- ---------------------------------------------------------------------------- type Menuitem_Type is new Boolean_Control_Type with private; type Checkbox_Type is new Boolean_Control_Type with private; type Radiobutton_Type is new Boolean_Control_Type with private; ---------------------------------------------------------------------------- -- -- M E N U I T E M S -- -- Menu items can only be attached to menus. When a menu is clicked, a -- pull-down menu appears which can consist of menu items (which generate -- a command when clicked) or further menus. -- -- Each menu and menu item has a text label in which the character "&" -- is treated specially. "&" will not be displayed, but the following -- character (e.g. 'X') will be underlined to indicate that it can be -- selected by pressing Alt + 'X' when the menu is visible. -- -- Menuitem operations: -- -- Menuitem (Parent, -- create a menu item attached to a parent menu -- Text, -- with this text label, -- Command) -- generating this command code when selected -- -- Separator (Parent) -- create a separator (an inactive horizontal -- -- bar) attached to a parent menu -- ---------------------------------------------------------------------------- function Menuitem (Parent : Menu_Type'Class; Text : String; Command : Command_Type) return Menuitem_Type; function Separator (Parent : Menu_Type'Class) return Menuitem_Type; ---------------------------------------------------------------------------- -- Menu items behave slightly differently to other controls, so the -- following operations are overridden: -- procedure Enable (Control : in Menuitem_Type; Enabled : in Boolean := True); function Enabled (Control : Menuitem_Type) return Boolean; function Get_Length (Control : Menuitem_Type) return Natural; function Get_Text (Control : Menuitem_Type) return String; procedure Set_Text (Control : in Menuitem_Type; Text : in String); function Get_State (Control : Menuitem_Type) return Boolean; procedure Set_State (Control : in Menuitem_Type; State : in Boolean); ---------------------------------------------------------------------------- -- -- C H E C K B O X E S -- -- A checkbox is a labelled control with a left-aligned box that can be -- checked or unchecked. Clicking on a checkbox (or pressing Space when -- it is selected) toggles the checkbox between the checked and unchecked -- states. -- -- Checkbox operations: -- -- Checkbox (Parent, -- create a checkbox in a container, with -- Origin, -- top left coordinates relative to the parent, -- Width, -- with the specified width -- Height, -- and the specified height, and -- Text, -- labelled with the specified text, and -- Checked, -- set to this initial state (default: False), -- Font) -- using this font (default: same as Parent). -- ---------------------------------------------------------------------------- function Checkbox (Parent : Container_Type'Class; Origin : Point_Type; Width : Integer; Height : Integer; Text : String; Checked : Boolean := False; Font : Font_Type := Parent_Font) return Checkbox_Type; ---------------------------------------------------------------------------- -- -- R A D I O B U T T O N S -- -- A radiobutton is a Boolean control with a left-aligned box that can be -- checked or unchecked. Radiobuttons attached to the same container form -- a group. Clicking on an unchecked radiobutton will set the radiobutton -- to the checked state and will also uncheck the other radiobuttons which -- belong to the same group (i.e. which are attached to the same container). -- Unlike a checkbox, a radiobutton cannot be turned off by clicking on it; -- you can only uncheck a radiobutton by checking another one in the same -- group. -- -- Radiobutton operations: -- -- Radiobutton (Parent, -- create a radiobutton in a container, with -- Origin, -- top left coordinates relative to the parent, -- Width, -- with the specified width -- Height, -- and the specified height, and -- Text, -- labelled with the specified text, and -- Checked, -- set to this initial state (default: False), -- Font) -- using this font (default: Default_Font). -- ---------------------------------------------------------------------------- function Radiobutton (Parent : Container_Type'Class; Origin : Point_Type; Width : Integer; Height : Integer; Text : String; Checked : Boolean := False; Font : Font_Type := Parent_Font) return Radiobutton_Type; ---------------------------------------------------------------------------- -- -- M U L T I L I N E C O N T R O L S -- -- Multiline controls contain multiple lines of text numbered from 1 -- upwards. Individual lines can be accessed by specifying a line -- number. The user can select a particular line by clicking on it -- with the mouse or using the keyboard arrow keys when the control -- is selected. Specifying the line number to access as 0 will access -- the currently selected line. If no line is selected, the current -- line number will be reported as 0 but its contents can still be -- accessed . A Constraint_Error will be raised if an attempt is made -- to access a line beyond the last one. -- -- The following operations are common to all multiline controls, but -- their precise effects vary slightly according to the actual type of -- the control (see below): -- -- Get_Count (Control) -- get the number of lines of text in the control. -- Get_Line (Control) -- get the number of the currently selected line. -- Get_Length (Control, -- get the length of the specified line -- Line) -- (default: current line). -- Get_Text (Control, -- get the text of the specified line as a string -- Line) -- of indefinite length (default: current line). -- -- Get_Text (Control, -- get the text of the control -- Line, -- from the specified line (default: current line) -- Text, -- into a fixed-size string variable, together -- Length) -- with the number of characters transferred. -- Set_Text (Control, -- set the text of the control -- Line, -- at the specified line -- Text) -- to the specified value. -- -- Select_Line (Control, -- select the line at the specified line number -- Line) -- (default: 0, meaning deselect). -- Append_Line (Control, -- append a line to the end of the control, where -- Text) -- this is the text to append. -- Insert_Line (Control, -- insert a new line above the specified -- Line, -- line number, where -- Text) -- this is the text to insert. -- Delete_Line (Control, -- delete the specified line. -- Line) -- Delete_All (Control) -- delete all lines. -- ---------------------------------------------------------------------------- function Get_Count (Control : Multiline_Type) return Natural is abstract; function Get_Line (Control : Multiline_Type) return Natural is abstract; function Get_Length (Control : Multiline_Type; Line : Natural := 0) return Natural is abstract; function Get_Text (Control : Multiline_Type; Line : Natural := 0) return String is abstract; procedure Get_Text (Control : in Multiline_Type; Line : in Natural := 0; Text : out String; Length : out Natural); procedure Set_Text (Control : in Multiline_Type; Text : in String; Line : in Natural := 0) is abstract; procedure Select_Line (Control : in Multiline_Type; Line : in Natural := 0) is abstract; procedure Append_Line (Control : in Multiline_Type; Text : in String) is abstract; procedure Insert_Line (Control : in Multiline_Type; Text : in String; Line : in Natural := 0) is abstract; procedure Delete_Line (Control : in Multiline_Type; Line : in Natural := 0) is abstract; procedure Delete_All (Control : in Multiline_Type) is abstract; ---------------------------------------------------------------------------- -- -- The types of multiline controls available are as follows: -- -- Listbox_Type : a list of text items in a scrollable window -- Combobox_Type : an editbox in combination with a drop-down list box -- Memo_Type : a multi-line text editor -- ---------------------------------------------------------------------------- type Listbox_Type is new Multiline_Type with private; type Combobox_Type is new Multiline_Type with private; type Memo_Type is new Multiline_Type with private; ---------------------------------------------------------------------------- -- -- L I S T B O X E S -- -- A listbox is a list of lines of text (initially empty). The lines are -- sorted into ascending order by default, but can be left unsorted if -- required. For a sorted list, the position at which a new line is added -- will be ignored, with the new line being inserted at the appropriate -- position according to its value. When no line has been selected, the -- contents of the current line will be reported as an empty string (""). -- -- Listbox operations: -- -- Listbox (Parent, -- create a listbox inside a container, with -- Origin, -- top left coordinates relative to the parent, -- Width, -- the specified width -- Height, -- and the specified height, using -- Font) -- this font (default: same as Parent). -- ---------------------------------------------------------------------------- function Listbox (Parent : Container_Type'Class; Origin : Point_Type; Width : Integer; Height : Integer; Font : Font_Type := Parent_Font) return Listbox_Type; ---------------------------------------------------------------------------- -- -- C O M B O B O X E S -- -- A combobox consists of an edit control together with a drop-down list -- (effectively a combination of an editbox and a listbox). The currently -- selected line is displayed in the edit control, and you can specify -- whether the user is able to manually edit this value. If not, only -- the values in the drop-down list can be selected. -- -- If the contents of the edit control match one of the values in the list, -- the position of the corresponding line in the list is reported as the -- number of the currently selected line. Otherwise, the number of the -- current line is reported as 0. Accessing the value of the current line -- (line 0) will report the current value of the edit control. -- -- Combobox operations: -- -- Combobox (Parent, -- create a combobox inside a container, with -- Origin, -- top left coordinates relative to the parent, -- Width, -- with the specified width, whose value can -- Editable, -- be manually edited (default: True), -- Font) -- using this font (default: same as Parent). -- ---------------------------------------------------------------------------- function Combobox (Parent : Container_Type'Class; Origin : Point_Type; Width : Integer; Editable : Boolean := True; Font : Font_Type := Parent_Font) return Combobox_Type; ---------------------------------------------------------------------------- -- -- M E M O S -- -- A memo is a simple multi-line text editor similar to Windows Notepad. -- There are several memo-specific operations in addition to the standard -- operations on multi-line controls. The user can select a block of text -- spanning multiple lines using the mouse (or by moving the cursor with -- the Shift key held down) and there are operations to fetch, replace -- and delete the selected text, find the line and column position of -- the start and end of the selected text, and get its total length (which -- will include one or more additional end-of-line characters if the text -- spans more than one line). -- -- Memo operations: -- -- Memo (Parent, -- create a memo inside a container, with -- Origin, -- top left coordinates relative to the parent, -- Width, -- the specified width -- Height) -- and the specified height -- Font) -- using this font (default: same as Parent). -- -- Get_Column (Memo) -- get the column position of the current -- -- selection. -- Modified (Memo) -- test if the user has modified the memo. -- Cut_Selection (Memo) -- cut the current selection to the clipboard. -- Copy_Selection (Memo) -- copy the current selection to the clipboard. -- Paste_Selection (Memo) -- paste the clipboard contents to the memo, -- -- replacing the current selection. -- Undo_Change (Memo) -- undo the user's last change to the memo. -- Show_Selection (Memo) -- scroll the memo so that the current position -- -- is visible on the screen. -- ---------------------------------------------------------------------------- function Memo (Parent : Container_Type'Class; Origin : Point_Type; Width : Integer; Height : Integer; Font : Font_Type := Parent_Font) return Memo_Type; function Get_Column (Memo : Memo_Type) return Natural; function Modified (Memo : Memo_Type) return Boolean; procedure Cut_Selection (Memo : in Memo_Type); procedure Copy_Selection (Memo : in Memo_Type); procedure Paste_Selection (Memo : in Memo_Type); procedure Undo_Change (Memo : in Memo_Type); procedure Show_Selection (Memo : in Memo_Type); ---------------------------------------------------------------------------- -- Most operations on multiline types are implemented in different ways, -- so they are overridden here: -- function Get_Count (Control : Listbox_Type) return Natural; function Get_Count (Control : Combobox_Type) return Natural; function Get_Count (Control : Memo_Type) return Natural; function Get_Line (Control : Listbox_Type) return Natural; function Get_Line (Control : Combobox_Type) return Natural; function Get_Line (Control : Memo_Type) return Natural; function Get_Length (Control : Listbox_Type; Line : Natural := 0) return Natural; function Get_Length (Control : Combobox_Type; Line : Natural := 0) return Natural; function Get_Length (Control : Memo_Type; Line : Natural := 0) return Natural; function Get_Text (Control : Listbox_Type; Line : Natural := 0) return String; function Get_Text (Control : Combobox_Type; Line : Natural := 0) return String; function Get_Text (Control : Memo_Type; Line : Natural := 0) return String; procedure Set_Text (Control : in Listbox_Type; Text : in String; Line : in Natural := 0); procedure Set_Text (Control : in Combobox_Type; Text : in String; Line : in Natural := 0); procedure Set_Text (Control : in Memo_Type; Text : in String; Line : in Natural := 0); procedure Select_Line (Control : in Listbox_Type; Line : in Natural := 0); procedure Select_Line (Control : in Combobox_Type; Line : in Natural := 0); procedure Select_Line (Control : in Memo_Type; Line : in Natural := 0); procedure Append_Line (Control : in Listbox_Type; Text : in String); procedure Append_Line (Control : in Combobox_Type; Text : in String); procedure Append_Line (Control : in Memo_Type; Text : in String); procedure Insert_Line (Control : in Listbox_Type; Text : in String; Line : in Natural := 0); procedure Insert_Line (Control : in Combobox_Type; Text : in String; Line : in Natural := 0); procedure Insert_Line (Control : in Memo_Type; Text : in String; Line : in Natural := 0); procedure Delete_Line (Control : in Listbox_Type; Line : in Natural := 0); procedure Delete_Line (Control : in Combobox_Type; Line : in Natural := 0); procedure Delete_Line (Control : in Memo_Type; Line : in Natural:= 0); procedure Delete_All (Control : in Listbox_Type); procedure Delete_All (Control : in Combobox_Type); procedure Delete_All (Control : in Memo_Type); ---------------------------------------------------------------------------- -- -- C A N V A S E S -- -- A canvas is a blank rectangle for drawing on which can optionally -- be set to generate a command code when the mouse is clicked on it. -- A canvas has an associated font (the same as the parent window by -- default), a background colour (initially white), a pen for drawing -- lines (initially black, one pixel wide) and a fill colour used to -- colour closed shapes (initially white). -- -- The freedom of expression available with canvases make these the -- most complex component of all, with over 20 available operations. -- There are operations to draw lines, rectangles (with or without -- rounded corners), ellipses, circles, line sequences, polygons and -- text. The font, pen size and colour and fill colour can be changed -- at any time any will affect all subsequent drawing operations (but -- everything drawn previously will be unaffected). Rectangles can be -- given rounded corners by specifying a rounding factor, which gives -- the X and Y offsets from the corners to the points where the rounded -- corner begins. -- -- Anything drawn on a canvas will normally stay there, but the canvas -- can be erased or the current state of a drawing can be saved and then -- restored later (which provides a basic "undo" facility). For example, -- a clock can be drawn by drawing a circle, saving the drawing, and then -- drawing the hands. To change the position of the hands, restore the -- saved drawing (thus erasing the hands) and then redraw the hands in -- the new position. You can only save one copy of the drawing, so if you -- save it a second time you will lose the previous saved copy. -- -- A canvas can be set up to generate a command when the mouse button -- is pressed inside its borders. There are operations to get the -- position at which the button was pressed, to get the current mouse -- position, and to test if the mouse button is still down and whether -- the mouse has been moved. As long as the button is down, the mouse -- position will be tracked even if the mouse is moved outside the canvas. -- You can track the mouse visually by saving the drawing when the mouse -- is first pressed, then restoring the drawing and drawing a new line -- from the initial mouse position to the current one. -- -- Canvas operations: -- -- Canvas (Parent, -- create a canvas inside a container, with -- Origin, -- top left coordinates relative to Parent, -- Width, -- the specified width -- Height, -- and the specified height, using -- Font) -- this font (default: same as Parent). -- -- Canvas (Parent, -- create a canvas inside a container, with -- Origin, -- top left coordinates relative to the parent, -- Width, -- the specified width -- Height, -- and the specified height, -- Command, -- which generates this command code, and -- Font) -- uses this font (default: same as Parent). -- -- Canvas (Parent, -- create a canvas inside a container, with -- Origin, -- top left coordinates relative to the parent, -- Width, -- the specified width -- Height, -- and the specified height, -- Command, -- which generates this command code, and -- Keypress, -- this one when a key is pressed, and -- Font) -- uses this font (default: same as Parent). -- -- Set_Colour (Canvas, -- set the background colour for a canvas -- Colour) -- using this colour (default: white) -- -- Erase (Canvas) -- erase the drawing in a canvas. This will -- -- also erase any saved drawing. -- Save (Canvas) -- save the current drawing. -- Restore (Canvas) -- restore a saved drawing, erasing anything -- -- drawn since. If the drawing has never been -- -- saved, or the window has been erased using -- -- Erase, this will do nothing. -- Set_Font (Canvas, -- set a new font for all subsequent text -- Font) -- drawn on the canvas. -- Set_Pen (Canvas, -- set the pen used to draw lines on the -- Colour, -- canvas to this colour (default: black) -- Width) -- and thickness (default: 1 pixel). -- Set_Fill (Canvas, -- set the colour used to fill subsequent -- Colour) -- closed shapes drawn on the canvas. -- Set_Fill (Canvas) -- clear the colour used to fill subsequent -- -- closed shapes drawn on the canvas. -- Draw_Text (Canvas, -- draw a text string on the canvas -- From, -- from this top-left point, where -- Text) -- this is the text to be drawn. -- Draw_Text (Canvas, -- draw a text string on the canvas -- From, -- in a rectangle between this point -- To, -- and this one, where -- Text, -- this is the text to be drawn -- Align) -- with this alignment (default: left). -- Draw_Text (Canvas, -- draw a text string on the canvas -- From, -- in a rectangle starting at this point -- Width, -- with this width -- Height, -- and this height, where -- Text, -- this is the text to be drawn -- Align) -- with this alignment (default: left). -- -- Draw_Line (Canvas, -- draw a line on the canvas -- From, -- from this point -- To) -- to this one. -- Draw_Line (Canvas, -- draw a line on the canvas -- From, -- from this point -- Length, -- for this length -- Angle) -- at this angle. -- Draw_Line_List (Canvas, -- draw lines on the canvas connecting -- Points) -- the points in this list. -- -- Draw_Rectangle (Canvas, -- draw a rectangle on the canvas -- From, -- from this corner point -- To, -- to this diagonally-opposite point -- Rounding) -- with corners rounded this much -- -- (default: no rounding). -- Draw_Rectangle (Canvas, -- draw a rectangle on the canvas -- From, -- from this top-left point -- Width, -- with this width -- Height, -- and this height -- Rounding) -- with corners rounded this much -- -- (default: no rounding). -- -- Draw_Ellipse (Canvas, -- draw an ellipse on the canvas -- From, -- bounded by a rectangle from this point -- To) -- to this point. -- Draw_Ellipse (Canvas, -- draw an ellipse on the canvas -- From, -- bounded by a rectangle from this point -- Width, -- with this width. -- Height) -- and this height -- Draw_Circle (Canvas, -- draw a circle on the canvas -- Centre, -- with this centre point -- Radius) -- and this radius. -- -- Draw_Polygon (Canvas, -- draw a polygon on the canvas -- Points) -- with vertices at these points. -- -- Draw_Image (Canvas, -- draw an image on the canvas -- From, -- from this point -- Image) -- using this image object. -- Draw_Image (Canvas, -- draw an image on the canvas -- From, -- from this point -- To, -- to this one (stretching the image to fit) -- Image) -- using this image object. -- Draw_Image (Canvas, -- draw an image on the canvas -- From, -- from this point -- Width, -- with this width -- Height, -- and this height -- Image) -- using this image object. -- -- Mouse_Down (Canvas) -- test if the left mouse button is down. -- Mouse_Moved (Canvas) -- test if the mouse has been moved. -- Start_Point (Canvas) -- get the point where the mouse button -- -- was first pressed. -- End_Point (Canvas) -- get the point where the mouse is now -- -- (or its final position when the left -- -- button was released). -- Key_Code (Canvas) -- get the character code for the last -- -- key pressed. -- ---------------------------------------------------------------------------- function Canvas (Parent : Container_Type'Class; Origin : Point_Type; Width : Integer; Height : Integer; Font : Font_Type := Parent_Font) return Canvas_Type; function Canvas (Parent : Container_Type'Class; Origin : Point_Type; Width : Integer; Height : Integer; Command : Command_Type; Font : Font_Type := Parent_Font) return Canvas_Type; function Canvas (Parent : Container_Type'Class; Origin : Point_Type; Width : Integer; Height : Integer; Command : Command_Type; Keypress : Command_Type; Font : Font_Type := Parent_Font) return Canvas_Type; procedure Set_Colour (Canvas : in Canvas_Type; Colour : in Colour_Type := White); procedure Erase (Canvas : in Canvas_Type); procedure Save (Canvas : in Canvas_Type); procedure Restore (Canvas : in Canvas_Type); procedure Set_Font (Canvas : in Canvas_Type; Font : in Font_Type); procedure Set_Pen (Canvas : in Canvas_Type; Colour : in Colour_Type := Black; Width : in Natural := 1); procedure Set_Fill (Canvas : in Canvas_Type; Colour : in Colour_Type); procedure Set_Fill (Canvas : in Canvas_Type); procedure Draw_Text (Canvas : in Canvas_Type; From : in Point_Type; Text : in String); procedure Draw_Text (Canvas : in Canvas_Type; From : in Point_Type; To : in Point_Type; Text : in String; Align : in Alignment_Type := Left); procedure Draw_Text (Canvas : in Canvas_Type; From : in Point_Type; Width : in Integer; Height : in Integer; Text : in String; Align : in Alignment_Type := Left); procedure Draw_Line (Canvas : in Canvas_Type; From : in Point_Type; To : in Point_Type); procedure Draw_Line (Canvas : in Canvas_Type; From : in Point_Type; Length : in Positive; Angle : in Angle_Type); procedure Draw_Line_List (Canvas : in Canvas_Type; Points : in Point_List); procedure Draw_Rectangle (Canvas : in Canvas_Type; From : in Point_Type; To : in Point_Type; Rounding : in Point_Type := (0,0)); procedure Draw_Rectangle (Canvas : in Canvas_Type; From : in Point_Type; Width : in Positive; Height : in Positive; Rounding : in Point_Type := (0,0)); procedure Draw_Ellipse (Canvas : in Canvas_Type; From : in Point_Type; To : in Point_Type); procedure Draw_Ellipse (Canvas : in Canvas_Type; From : in Point_Type; Width : in Positive; Height : in Positive); procedure Draw_Circle (Canvas : in Canvas_Type; Centre : in Point_Type; Radius : in Positive); procedure Draw_Polygon (Canvas : in Canvas_Type; Points : in Point_List); procedure Draw_Image (Canvas : in Canvas_Type; From : in Point_Type; Image : in Image_Type); procedure Draw_Image (Canvas : in Canvas_Type; From : in Point_Type; To : in Point_Type; Image : in Image_Type); procedure Draw_Image (Canvas : in Canvas_Type; From : in Point_Type; Width : in Natural; Height : in Natural; Image : in Image_Type); function Start_Point (Canvas : Canvas_Type) return Point_Type; function End_Point (Canvas : Canvas_Type) return Point_Type; function Mouse_Down (Canvas : Canvas_Type) return Boolean; function Mouse_Moved (Canvas : Canvas_Type) return Boolean; function Key_Code (Canvas : Canvas_Type) return Character; ---------------------------------------------------------------------------- -- -- C O M M O N D I A L O G S -- -- Common dialogs are pre-packaged dialog widgets which are not treated -- as normal windows (although they are made to look similar for ease of -- use). -- -- Common dialog operations (common to all dialogs): -- -- Execute (Dialog) -- execute the dialog and return True if the OK -- -- button was used to close the dialog and False -- -- otherwise. -- ---------------------------------------------------------------------------- type Common_Dialog_Type is abstract tagged private; function Execute (Dialog : Common_Dialog_Type) return Boolean; ---------------------------------------------------------------------------- -- -- C O M M O N D I A L O G S U B C L A S S E S -- -- The available dialog subclasses are colour, font and file dialogs. -- -- Colour_Dialog_Type : a dialog to allow the user to select a colour. -- Font_Dialog_Type : a dialog to allow the user to select a font. -- File_Dialog_Type : a dialog to allow the user to select a file name. -- ---------------------------------------------------------------------------- type Colour_Dialog_Type is new Common_Dialog_Type with private; type Font_Dialog_Type is new Common_Dialog_Type with private; type File_Dialog_Type is abstract new Common_Dialog_Type with private; ---------------------------------------------------------------------------- -- -- C O L O U R D I A L O G S -- -- Colour dialogs allow the user to select or create a colour. -- -- Colour dialog operations: -- -- Colour_Dialog -- create a colour dialog. -- Set_Colour (Dialog, -- set the initial colour displayed in the -- Colour) -- dialog to this colour. -- Get_Colour (Dialog) -- get the colour contained in the dialog. -- ---------------------------------------------------------------------------- function Colour_Dialog return Colour_Dialog_Type; procedure Set_Colour (Dialog : in Colour_Dialog_Type; Colour : in Colour_Type); function Get_Colour (Dialog : in Colour_Dialog_Type) return Colour_Type; ---------------------------------------------------------------------------- -- -- F O N T D I A L O G S -- -- Font dialogs allow the user to select a font. -- -- Font dialog operations: -- -- Font_Dialog -- create a font dialog. -- Set_Font (Dialog, -- set the initial font displayed in the -- Font) -- dialog to this font. -- Get_Font (Dialog) -- get the font contained in the dialog. -- ---------------------------------------------------------------------------- function Font_Dialog return Font_Dialog_Type; procedure Set_Font (Dialog : in Font_Dialog_Type; Font : in Font_Type); function Get_Font (Dialog : in Font_Dialog_Type) return Font_Type; ---------------------------------------------------------------------------- -- -- F I L E D I A L O G S -- -- File dialogs allow the user to select or enter a file name. This is an -- abstract type which is further subclassed below. -- -- File dialog operations (common to all file dialogs): -- -- Set_Name (Dialog, -- set the initial file name displayed in the -- Name) -- dialog to this string. -- Get_Name (Dialog) -- get the file name contained in the dialog. -- Add_Filter (Dialog, -- add a file type filter to the dialog -- Text, -- with this description -- Filter) -- to match this wildcard specification. -- Set_Directory (Dialog, -- set the initial directory for the dialog -- Name) -- to this directory. -- ---------------------------------------------------------------------------- procedure Set_Name (Dialog : in File_Dialog_Type; Name : in String); function Get_Name (Dialog : in File_Dialog_Type) return String; procedure Add_Filter (Dialog : in File_Dialog_Type; Text : in String; Filter : in String); procedure Set_Directory (Dialog : in File_Dialog_Type; Name : in String); ---------------------------------------------------------------------------- -- -- O P E N D I A L O G S -- -- Open dialogs allow the user to select or enter a file name for use as -- an input file. The file name selected must be the name of an existing -- file. -- -- Open dialog operations: -- -- Open_Dialog (Title) -- create an open file dialog with this title. -- ---------------------------------------------------------------------------- type Open_Dialog_Type is new File_Dialog_Type with private; function Open_Dialog (Title : String) return Open_Dialog_Type; ---------------------------------------------------------------------------- -- -- S A V E D I A L O G S -- -- Save dialogs allow the user to select or enter a file name for use as -- an output file. If the Create parameter to the constructor function -- below is True (as it is by default) and an existing file is selected, -- the user will be asked if the file should be overwritten. If it is -- False and the file does not exist, the user will be asked if it should -- be created. -- -- Save dialog operations: -- -- Save_Dialog (Title, -- create a save file dialog with this title -- Create) -- which will prompt the user as described above. -- ---------------------------------------------------------------------------- type Save_Dialog_Type is new File_Dialog_Type with private; function Save_Dialog (Title : String; Create : Boolean := True) return Save_Dialog_Type; ---------------------------------------------------------------------------- -- Renamings for our transatlantic cousins, in the hope that some day -- they'll repay the favour/favor... ---------------------------------------------------------------------------- procedure Set_Color (Canvas : in Canvas_Type; Colour : in Colour_Type := White) renames Set_Colour; subtype Color_Dialog_Type is Colour_Dialog_Type; function Color_Dialog return Colour_Dialog_Type renames Colour_Dialog; procedure Set_Color (Dialog : in Colour_Dialog_Type; Colour : in Colour_Type) renames Set_Colour; function Get_Color (Dialog : in Colour_Dialog_Type) return Colour_Type renames Get_Colour; private -- and deliberately uninformative! type Window_Type is abstract tagged record Internals : JEWL.Controlled_Type; -- see package JEWL end record; type Container_Type is abstract new Window_Type with null record; type Control_Type is abstract new Window_Type with null record; type Frame_Type is new Container_Type with null record; type Dialog_Type is new Container_Type with null record; type Panel_Type is new Container_Type with null record; type Menu_Type is new Container_Type with null record; type Text_Control_Type is abstract new Control_Type with null record; type Multiline_Type is abstract new Control_Type with null record; type Canvas_Type is new Control_Type with null record; type Button_Type is new Text_Control_Type with null record; type Label_Type is new Text_Control_Type with null record; type Editbox_Type is new Text_Control_Type with null record; type Boolean_Control_Type is abstract new Text_Control_Type with null record; type Menuitem_Type is new Boolean_Control_Type with null record; type Checkbox_Type is new Boolean_Control_Type with null record; type Radiobutton_Type is new Boolean_Control_Type with null record; type Listbox_Type is new Multiline_Type with null record; type Combobox_Type is new Multiline_Type with null record; type Memo_Type is new Multiline_Type with null record; type Common_Dialog_Type is abstract tagged record Internals : JEWL.Controlled_Type; -- see package JEWL end record; type Colour_Dialog_Type is new Common_Dialog_Type with null record; type Font_Dialog_Type is new Common_Dialog_Type with null record; type File_Dialog_Type is abstract new Common_Dialog_Type with null record; type Open_Dialog_Type is new File_Dialog_Type with null record; type Save_Dialog_Type is new File_Dialog_Type with null record; type Image_Type is record Internals : JEWL.Controlled_Type; -- see package JEWL end record; end JEWL.Windows;
30,623
ada
0
djamal2727/Main-Bearing-Analytical-Model
Validation/pyFrame3DD-master/gcc-master/gcc/ada/sinput.adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S I N P U T -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2020, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ pragma Style_Checks (All_Checks); -- Subprograms not all in alpha order with Atree; use Atree; with Debug; use Debug; with Opt; use Opt; with Output; use Output; with Scans; use Scans; with Widechar; use Widechar; with GNAT.Byte_Order_Mark; use GNAT.Byte_Order_Mark; with System.Storage_Elements; with System.Memory; with System.WCh_Con; use System.WCh_Con; with Unchecked_Conversion; with Unchecked_Deallocation; package body Sinput is use ASCII, System; -- Routines to support conversion between types Lines_Table_Ptr, -- Logical_Lines_Table_Ptr and System.Address. pragma Warnings (Off); -- These unchecked conversions are aliasing safe, since they are never -- used to construct improperly aliased pointer values. function To_Address is new Unchecked_Conversion (Lines_Table_Ptr, Address); function To_Address is new Unchecked_Conversion (Logical_Lines_Table_Ptr, Address); function To_Pointer is new Unchecked_Conversion (Address, Lines_Table_Ptr); function To_Pointer is new Unchecked_Conversion (Address, Logical_Lines_Table_Ptr); pragma Warnings (On); ----------------------------- -- Source_File_Index_Table -- ----------------------------- -- The Get_Source_File_Index function is called very frequently. Earlier -- versions cached a single entry, but then reverted to a serial search, -- and this proved to be a significant source of inefficiency. We then -- switched to using a table with a start point followed by a serial -- search. Now we make sure source buffers are on a reasonable boundary -- (see Types.Source_Align), and we can just use a direct look up in the -- following table. -- Note that this array is pretty large, but in most operating systems -- it will not be allocated in physical memory unless it is actually used. Source_File_Index_Table : array (Int range 0 .. 1 + (Int'Last / Source_Align)) of Source_File_Index; --------------------------- -- Add_Line_Tables_Entry -- --------------------------- procedure Add_Line_Tables_Entry (S : in out Source_File_Record; P : Source_Ptr) is LL : Physical_Line_Number; begin -- Reallocate the lines tables if necessary -- Note: the reason we do not use the normal Table package -- mechanism is that we have several of these tables. We could -- use the new GNAT.Dynamic_Tables package and that would probably -- be a good idea ??? if S.Last_Source_Line = S.Lines_Table_Max then Alloc_Line_Tables (S, Int (S.Last_Source_Line) * ((100 + Alloc.Lines_Increment) / 100)); if Debug_Flag_D then Write_Str ("--> Reallocating lines table, size = "); Write_Int (Int (S.Lines_Table_Max)); Write_Eol; end if; end if; S.Last_Source_Line := S.Last_Source_Line + 1; LL := S.Last_Source_Line; S.Lines_Table (LL) := P; -- Deal with setting new entry in logical lines table if one is -- present. Note that there is always space (because the call to -- Alloc_Line_Tables makes sure both tables are the same length), if S.Logical_Lines_Table /= null then -- We can always set the entry from the previous one, because -- the processing for a Source_Reference pragma ensures that -- at least one entry following the pragma is set up correctly. S.Logical_Lines_Table (LL) := S.Logical_Lines_Table (LL - 1) + 1; end if; end Add_Line_Tables_Entry; ----------------------- -- Alloc_Line_Tables -- ----------------------- procedure Alloc_Line_Tables (S : in out Source_File_Record; New_Max : Nat) is subtype size_t is Memory.size_t; New_Table : Lines_Table_Ptr; New_Logical_Table : Logical_Lines_Table_Ptr; New_Size : constant size_t := size_t (New_Max * Lines_Table_Type'Component_Size / Storage_Unit); begin if S.Lines_Table = null then New_Table := To_Pointer (Memory.Alloc (New_Size)); else New_Table := To_Pointer (Memory.Realloc (To_Address (S.Lines_Table), New_Size)); end if; if New_Table = null then raise Storage_Error; else S.Lines_Table := New_Table; S.Lines_Table_Max := Physical_Line_Number (New_Max); end if; if S.Num_SRef_Pragmas /= 0 then if S.Logical_Lines_Table = null then New_Logical_Table := To_Pointer (Memory.Alloc (New_Size)); else New_Logical_Table := To_Pointer (Memory.Realloc (To_Address (S.Logical_Lines_Table), New_Size)); end if; if New_Logical_Table = null then raise Storage_Error; else S.Logical_Lines_Table := New_Logical_Table; end if; end if; end Alloc_Line_Tables; ----------------- -- Backup_Line -- ----------------- procedure Backup_Line (P : in out Source_Ptr) is Sindex : constant Source_File_Index := Get_Source_File_Index (P); Src : constant Source_Buffer_Ptr := Source_File.Table (Sindex).Source_Text; Sfirst : constant Source_Ptr := Source_File.Table (Sindex).Source_First; begin P := P - 1; if P = Sfirst then return; end if; if Src (P) = CR then if Src (P - 1) = LF then P := P - 1; end if; else -- Src (P) = LF if Src (P - 1) = CR then P := P - 1; end if; end if; -- Now find first character of the previous line while P > Sfirst and then Src (P - 1) /= LF and then Src (P - 1) /= CR loop P := P - 1; end loop; end Backup_Line; --------------------------- -- Build_Location_String -- --------------------------- procedure Build_Location_String (Buf : in out Bounded_String; Loc : Source_Ptr) is Ptr : Source_Ptr := Loc; begin -- Loop through instantiations loop Append (Buf, Reference_Name (Get_Source_File_Index (Ptr))); Append (Buf, ':'); Append (Buf, Nat (Get_Logical_Line_Number (Ptr))); Ptr := Instantiation_Location (Ptr); exit when Ptr = No_Location; Append (Buf, " instantiated at "); end loop; end Build_Location_String; function Build_Location_String (Loc : Source_Ptr) return String is Buf : Bounded_String; begin Build_Location_String (Buf, Loc); return +Buf; end Build_Location_String; ------------------- -- Check_For_BOM -- ------------------- procedure Check_For_BOM is BOM : BOM_Kind; Len : Natural; Tst : String (1 .. 5); C : Character; begin for J in 1 .. 5 loop C := Source (Scan_Ptr + Source_Ptr (J) - 1); -- Definitely no BOM if EOF character marks either end of file, or -- an illegal non-BOM character if not at the end of file. if C = EOF then return; end if; Tst (J) := C; end loop; Read_BOM (Tst, Len, BOM, XML_Support => False); case BOM is when UTF8_All => Scan_Ptr := Scan_Ptr + Source_Ptr (Len); First_Non_Blank_Location := Scan_Ptr; Current_Line_Start := Scan_Ptr; Wide_Character_Encoding_Method := WCEM_UTF8; Upper_Half_Encoding := True; when UTF16_BE | UTF16_LE => Set_Standard_Error; Write_Line ("UTF-16 encoding format not recognized"); Set_Standard_Output; raise Unrecoverable_Error; when UTF32_BE | UTF32_LE => Set_Standard_Error; Write_Line ("UTF-32 encoding format not recognized"); Set_Standard_Output; raise Unrecoverable_Error; when Unknown => null; when others => raise Program_Error; end case; end Check_For_BOM; ----------------------------- -- Clear_Source_File_Table -- ----------------------------- procedure Free is new Unchecked_Deallocation (Lines_Table_Type, Lines_Table_Ptr); procedure Free is new Unchecked_Deallocation (Logical_Lines_Table_Type, Logical_Lines_Table_Ptr); procedure Clear_Source_File_Table is begin for X in 1 .. Source_File.Last loop declare S : Source_File_Record renames Source_File.Table (X); begin if S.Instance = No_Instance_Id then Free_Source_Buffer (S.Source_Text); else Free_Dope (S.Source_Text'Address); S.Source_Text := null; end if; Free (S.Lines_Table); Free (S.Logical_Lines_Table); end; end loop; Source_File.Free; Sinput.Initialize; end Clear_Source_File_Table; --------------------------------- -- Comes_From_Inherited_Pragma -- --------------------------------- function Comes_From_Inherited_Pragma (S : Source_Ptr) return Boolean is SIE : Source_File_Record renames Source_File.Table (Get_Source_File_Index (S)); begin return SIE.Inherited_Pragma; end Comes_From_Inherited_Pragma; ----------------------------- -- Comes_From_Inlined_Body -- ----------------------------- function Comes_From_Inlined_Body (S : Source_Ptr) return Boolean is SIE : Source_File_Record renames Source_File.Table (Get_Source_File_Index (S)); begin return SIE.Inlined_Body; end Comes_From_Inlined_Body; ------------------------ -- Free_Source_Buffer -- ------------------------ procedure Free_Source_Buffer (Src : in out Source_Buffer_Ptr) is -- Unchecked_Deallocation doesn't work for access-to-constant; we need -- to first Unchecked_Convert to access-to-variable. function To_Source_Buffer_Ptr_Var is new Unchecked_Conversion (Source_Buffer_Ptr, Source_Buffer_Ptr_Var); Temp : Source_Buffer_Ptr_Var := To_Source_Buffer_Ptr_Var (Src); procedure Free_Ptr is new Unchecked_Deallocation (Source_Buffer, Source_Buffer_Ptr_Var); begin Free_Ptr (Temp); Src := null; end Free_Source_Buffer; ----------------------- -- Get_Column_Number -- ----------------------- function Get_Column_Number (P : Source_Ptr) return Column_Number is S : Source_Ptr; C : Column_Number; Sindex : Source_File_Index; Src : Source_Buffer_Ptr; begin -- If the input source pointer is not a meaningful value then return -- at once with column number 1. This can happen for a file not found -- condition for a file loaded indirectly by RTE, and also perhaps on -- some unknown internal error conditions. In either case we certainly -- don't want to blow up. if P < 1 then return 1; else Sindex := Get_Source_File_Index (P); Src := Source_File.Table (Sindex).Source_Text; S := Line_Start (P); C := 1; while S < P loop if Src (S) = HT then C := (C - 1) / 8 * 8 + (8 + 1); S := S + 1; -- Deal with wide character case, but don't include brackets -- notation in this circuit, since we know that this will -- display unencoded (no one encodes brackets notation). elsif Src (S) /= '[' and then Is_Start_Of_Wide_Char (Src, S) then C := C + 1; Skip_Wide (Src, S); -- Normal (non-wide) character case or brackets sequence else C := C + 1; S := S + 1; end if; end loop; return C; end if; end Get_Column_Number; ----------------------------- -- Get_Logical_Line_Number -- ----------------------------- function Get_Logical_Line_Number (P : Source_Ptr) return Logical_Line_Number is SFR : Source_File_Record renames Source_File.Table (Get_Source_File_Index (P)); L : constant Physical_Line_Number := Get_Physical_Line_Number (P); begin if SFR.Num_SRef_Pragmas = 0 then return Logical_Line_Number (L); else return SFR.Logical_Lines_Table (L); end if; end Get_Logical_Line_Number; --------------------------------- -- Get_Logical_Line_Number_Img -- --------------------------------- function Get_Logical_Line_Number_Img (P : Source_Ptr) return String is begin Name_Len := 0; Add_Nat_To_Name_Buffer (Nat (Get_Logical_Line_Number (P))); return Name_Buffer (1 .. Name_Len); end Get_Logical_Line_Number_Img; ------------------------------ -- Get_Physical_Line_Number -- ------------------------------ function Get_Physical_Line_Number (P : Source_Ptr) return Physical_Line_Number is Sfile : Source_File_Index; Table : Lines_Table_Ptr; Lo : Physical_Line_Number; Hi : Physical_Line_Number; Mid : Physical_Line_Number; Loc : Source_Ptr; begin -- If the input source pointer is not a meaningful value then return -- at once with line number 1. This can happen for a file not found -- condition for a file loaded indirectly by RTE, and also perhaps on -- some unknown internal error conditions. In either case we certainly -- don't want to blow up. if P < 1 then return 1; -- Otherwise we can do the binary search else Sfile := Get_Source_File_Index (P); Loc := P + Source_File.Table (Sfile).Sloc_Adjust; Table := Source_File.Table (Sfile).Lines_Table; Lo := 1; Hi := Source_File.Table (Sfile).Last_Source_Line; loop Mid := (Lo + Hi) / 2; if Loc < Table (Mid) then Hi := Mid - 1; else -- Loc >= Table (Mid) if Mid = Hi or else Loc < Table (Mid + 1) then return Mid; else Lo := Mid + 1; end if; end if; end loop; end if; end Get_Physical_Line_Number; --------------------------- -- Get_Source_File_Index -- --------------------------- function Get_Source_File_Index (S : Source_Ptr) return Source_File_Index is Result : Source_File_Index; procedure Assertions; -- Assert various properties of the result procedure Assertions is -- ???The old version using zero-origin array indexing without array -- bounds checks returned 1 (i.e. system.ads) for these special -- locations, presumably by accident. We are mimicing that here. Special : constant Boolean := S = No_Location or else S = Standard_Location or else S = Standard_ASCII_Location or else S = System_Location; pragma Assert ((S > No_Location) xor Special); pragma Assert (Result in Source_File.First .. Source_File.Last); SFR : Source_File_Record renames Source_File.Table (Result); begin -- SFR.Source_Text = null if and only if this is the SFR for a debug -- output file (*.dg), and that file is under construction. S can be -- slightly past Source_Last in that case because we haven't updated -- Source_Last. if Null_Source_Buffer_Ptr (SFR.Source_Text) then pragma Assert (S >= SFR.Source_First); null; else pragma Assert (SFR.Source_Text'First = SFR.Source_First); pragma Assert (SFR.Source_Text'Last = SFR.Source_Last); if not Special then pragma Assert (S in SFR.Source_First .. SFR.Source_Last); null; end if; end if; end Assertions; -- Start of processing for Get_Source_File_Index begin if S > No_Location then Result := Source_File_Index_Table (Int (S) / Source_Align); else Result := 1; end if; pragma Debug (Assertions); return Result; end Get_Source_File_Index; ---------------- -- Initialize -- ---------------- procedure Initialize is begin Source_gnat_adc := No_Source_File; Source_File.Init; Instances.Init; Instances.Append (No_Location); pragma Assert (Instances.Last = No_Instance_Id); end Initialize; ------------------- -- Instantiation -- ------------------- function Instantiation (S : SFI) return Source_Ptr is SIE : Source_File_Record renames Source_File.Table (S); begin if SIE.Inlined_Body or SIE.Inherited_Pragma then return SIE.Inlined_Call; else return Instances.Table (SIE.Instance); end if; end Instantiation; ------------------------- -- Instantiation_Depth -- ------------------------- function Instantiation_Depth (S : Source_Ptr) return Nat is Sind : Source_File_Index; Sval : Source_Ptr; Depth : Nat; begin Sval := S; Depth := 0; loop Sind := Get_Source_File_Index (Sval); Sval := Instantiation (Sind); exit when Sval = No_Location; Depth := Depth + 1; end loop; return Depth; end Instantiation_Depth; ---------------------------- -- Instantiation_Location -- ---------------------------- function Instantiation_Location (S : Source_Ptr) return Source_Ptr is begin return Instantiation (Get_Source_File_Index (S)); end Instantiation_Location; -------------------------- -- Iterate_On_Instances -- -------------------------- procedure Iterate_On_Instances is begin for J in 1 .. Instances.Last loop Process (J, Instances.Table (J)); end loop; end Iterate_On_Instances; ---------------------- -- Last_Source_File -- ---------------------- function Last_Source_File return Source_File_Index is begin return Source_File.Last; end Last_Source_File; ---------------- -- Line_Start -- ---------------- function Line_Start (P : Source_Ptr) return Source_Ptr is Sindex : constant Source_File_Index := Get_Source_File_Index (P); Src : constant Source_Buffer_Ptr := Source_File.Table (Sindex).Source_Text; Sfirst : constant Source_Ptr := Source_File.Table (Sindex).Source_First; S : Source_Ptr; begin S := P; while S > Sfirst and then Src (S - 1) /= CR and then Src (S - 1) /= LF loop S := S - 1; end loop; return S; end Line_Start; function Line_Start (L : Physical_Line_Number; S : Source_File_Index) return Source_Ptr is begin return Source_File.Table (S).Lines_Table (L); end Line_Start; ---------- -- Lock -- ---------- procedure Lock is begin Source_File.Release; Source_File.Locked := True; end Lock; ---------------------- -- Num_Source_Files -- ---------------------- function Num_Source_Files return Nat is begin return Int (Source_File.Last) - Int (Source_File.First) + 1; end Num_Source_Files; ---------------------- -- Num_Source_Lines -- ---------------------- function Num_Source_Lines (S : Source_File_Index) return Nat is begin return Nat (Source_File.Table (S).Last_Source_Line); end Num_Source_Lines; ----------------------- -- Original_Location -- ----------------------- function Original_Location (S : Source_Ptr) return Source_Ptr is Sindex : Source_File_Index; Tindex : Source_File_Index; begin if S <= No_Location then return S; else Sindex := Get_Source_File_Index (S); if Instantiation (Sindex) = No_Location then return S; else Tindex := Template (Sindex); while Instantiation (Tindex) /= No_Location loop Tindex := Template (Tindex); end loop; return S - Source_First (Sindex) + Source_First (Tindex); end if; end if; end Original_Location; ------------------------- -- Physical_To_Logical -- ------------------------- function Physical_To_Logical (Line : Physical_Line_Number; S : Source_File_Index) return Logical_Line_Number is SFR : Source_File_Record renames Source_File.Table (S); begin if SFR.Num_SRef_Pragmas = 0 then return Logical_Line_Number (Line); else return SFR.Logical_Lines_Table (Line); end if; end Physical_To_Logical; -------------------------------- -- Register_Source_Ref_Pragma -- -------------------------------- procedure Register_Source_Ref_Pragma (File_Name : File_Name_Type; Stripped_File_Name : File_Name_Type; Mapped_Line : Nat; Line_After_Pragma : Physical_Line_Number) is subtype size_t is Memory.size_t; SFR : Source_File_Record renames Source_File.Table (Current_Source_File); ML : Logical_Line_Number; begin if File_Name /= No_File then SFR.Reference_Name := Stripped_File_Name; SFR.Full_Ref_Name := File_Name; if not Debug_Generated_Code then SFR.Debug_Source_Name := Stripped_File_Name; SFR.Full_Debug_Name := File_Name; end if; SFR.Num_SRef_Pragmas := SFR.Num_SRef_Pragmas + 1; end if; if SFR.Num_SRef_Pragmas = 1 then SFR.First_Mapped_Line := Logical_Line_Number (Mapped_Line); end if; if SFR.Logical_Lines_Table = null then SFR.Logical_Lines_Table := To_Pointer (Memory.Alloc (size_t (SFR.Lines_Table_Max * Logical_Lines_Table_Type'Component_Size / Storage_Unit))); end if; SFR.Logical_Lines_Table (Line_After_Pragma - 1) := No_Line_Number; ML := Logical_Line_Number (Mapped_Line); for J in Line_After_Pragma .. SFR.Last_Source_Line loop SFR.Logical_Lines_Table (J) := ML; ML := ML + 1; end loop; end Register_Source_Ref_Pragma; --------------------------------- -- Set_Source_File_Index_Table -- --------------------------------- procedure Set_Source_File_Index_Table (Xnew : Source_File_Index) is Ind : Int; SP : Source_Ptr; SL : constant Source_Ptr := Source_File.Table (Xnew).Source_Last; begin SP := Source_File.Table (Xnew).Source_First; pragma Assert (SP mod Source_Align = 0); Ind := Int (SP) / Source_Align; while SP <= SL loop Source_File_Index_Table (Ind) := Xnew; SP := SP + Source_Align; Ind := Ind + 1; end loop; end Set_Source_File_Index_Table; --------------------------- -- Skip_Line_Terminators -- --------------------------- procedure Skip_Line_Terminators (P : in out Source_Ptr; Physical : out Boolean) is Chr : constant Character := Source (P); begin if Chr = CR then if Source (P + 1) = LF then P := P + 2; else P := P + 1; end if; elsif Chr = LF then P := P + 1; elsif Chr = FF or else Chr = VT then P := P + 1; Physical := False; return; -- Otherwise we have a wide character else Skip_Wide (Source, P); end if; -- Fall through in the physical line terminator case. First deal with -- making a possible entry into the lines table if one is needed. -- Note: we are dealing with a real source file here, this cannot be -- the instantiation case, so we need not worry about Sloc adjustment. declare S : Source_File_Record renames Source_File.Table (Current_Source_File); begin Physical := True; -- Make entry in lines table if not already made (in some scan backup -- cases, we will be rescanning previously scanned source, so the -- entry may have already been made on the previous forward scan). if Source (P) /= EOF and then P > S.Lines_Table (S.Last_Source_Line) then Add_Line_Tables_Entry (S, P); end if; end; end Skip_Line_Terminators; -------------- -- Set_Dope -- -------------- procedure Set_Dope (Src : System.Address; New_Dope : Dope_Ptr) is -- A fat pointer is a pair consisting of data pointer and dope pointer, -- in that order. So we want to overwrite the second word. Dope : System.Address; pragma Import (Ada, Dope); use System.Storage_Elements; for Dope'Address use Src + System.Address'Size / 8; begin Dope := New_Dope.all'Address; end Set_Dope; procedure Free_Dope (Src : System.Address) is Dope : Dope_Ptr; pragma Import (Ada, Dope); use System.Storage_Elements; for Dope'Address use Src + System.Address'Size / 8; procedure Free is new Unchecked_Deallocation (Dope_Rec, Dope_Ptr); begin Free (Dope); end Free_Dope; ---------------- -- Sloc_Range -- ---------------- procedure Sloc_Range (N : Node_Id; Min, Max : out Source_Ptr) is Indx : constant Source_File_Index := Get_Source_File_Index (Sloc (N)); function Process (N : Node_Id) return Traverse_Result; -- Process function for traversing the node tree procedure Traverse is new Traverse_Proc (Process); ------------- -- Process -- ------------- function Process (N : Node_Id) return Traverse_Result is Orig : constant Node_Id := Original_Node (N); begin -- Skip nodes that may have been added during expansion and -- that originate in other units, such as code for contracts -- in subprogram bodies. if Get_Source_File_Index (Sloc (Orig)) /= Indx then return Skip; end if; if Sloc (Orig) < Min then if Sloc (Orig) > No_Location then Min := Sloc (Orig); end if; elsif Sloc (Orig) > Max then if Sloc (Orig) > No_Location then Max := Sloc (Orig); end if; end if; return OK_Orig; end Process; -- Start of processing for Sloc_Range begin Min := Sloc (N); Max := Sloc (N); Traverse (N); end Sloc_Range; ------------------- -- Source_Offset -- ------------------- function Source_Offset (S : Source_Ptr) return Nat is Sindex : constant Source_File_Index := Get_Source_File_Index (S); Sfirst : constant Source_Ptr := Source_File.Table (Sindex).Source_First; begin return Nat (S - Sfirst); end Source_Offset; ------------------------ -- Top_Level_Location -- ------------------------ function Top_Level_Location (S : Source_Ptr) return Source_Ptr is Oldloc : Source_Ptr; Newloc : Source_Ptr; begin Newloc := S; loop Oldloc := Newloc; Newloc := Instantiation_Location (Oldloc); exit when Newloc = No_Location; end loop; return Oldloc; end Top_Level_Location; -------------------- -- Write_Location -- -------------------- procedure Write_Location (P : Source_Ptr) is begin if P = No_Location then Write_Str ("<no location>"); elsif P <= Standard_Location then Write_Str ("<standard location>"); else declare SI : constant Source_File_Index := Get_Source_File_Index (P); begin Write_Name (Debug_Source_Name (SI)); Write_Char (':'); Write_Int (Int (Get_Logical_Line_Number (P))); Write_Char (':'); Write_Int (Int (Get_Column_Number (P))); if Instantiation (SI) /= No_Location then Write_Str (" ["); Write_Location (Instantiation (SI)); Write_Char (']'); end if; end; end if; end Write_Location; ---------------------- -- Write_Time_Stamp -- ---------------------- procedure Write_Time_Stamp (S : Source_File_Index) is T : constant Time_Stamp_Type := Time_Stamp (S); P : Natural; begin if T (1) = '9' then Write_Str ("19"); P := 0; else Write_Char (T (1)); Write_Char (T (2)); P := 2; end if; Write_Char (T (P + 1)); Write_Char (T (P + 2)); Write_Char ('-'); Write_Char (T (P + 3)); Write_Char (T (P + 4)); Write_Char ('-'); Write_Char (T (P + 5)); Write_Char (T (P + 6)); Write_Char (' '); Write_Char (T (P + 7)); Write_Char (T (P + 8)); Write_Char (':'); Write_Char (T (P + 9)); Write_Char (T (P + 10)); Write_Char (':'); Write_Char (T (P + 11)); Write_Char (T (P + 12)); end Write_Time_Stamp; ---------------------------------------------- -- Access Subprograms for Source File Table -- ---------------------------------------------- function Debug_Source_Name (S : SFI) return File_Name_Type is begin return Source_File.Table (S).Debug_Source_Name; end Debug_Source_Name; function Instance (S : SFI) return Instance_Id is begin return Source_File.Table (S).Instance; end Instance; function File_Name (S : SFI) return File_Name_Type is begin return Source_File.Table (S).File_Name; end File_Name; function File_Type (S : SFI) return Type_Of_File is begin return Source_File.Table (S).File_Type; end File_Type; function First_Mapped_Line (S : SFI) return Logical_Line_Number is begin return Source_File.Table (S).First_Mapped_Line; end First_Mapped_Line; function Full_Debug_Name (S : SFI) return File_Name_Type is begin return Source_File.Table (S).Full_Debug_Name; end Full_Debug_Name; function Full_File_Name (S : SFI) return File_Name_Type is begin return Source_File.Table (S).Full_File_Name; end Full_File_Name; function Full_Ref_Name (S : SFI) return File_Name_Type is begin return Source_File.Table (S).Full_Ref_Name; end Full_Ref_Name; function Identifier_Casing (S : SFI) return Casing_Type is begin return Source_File.Table (S).Identifier_Casing; end Identifier_Casing; function Inherited_Pragma (S : SFI) return Boolean is begin return Source_File.Table (S).Inherited_Pragma; end Inherited_Pragma; function Inlined_Body (S : SFI) return Boolean is begin return Source_File.Table (S).Inlined_Body; end Inlined_Body; function Inlined_Call (S : SFI) return Source_Ptr is begin return Source_File.Table (S).Inlined_Call; end Inlined_Call; function Keyword_Casing (S : SFI) return Casing_Type is begin return Source_File.Table (S).Keyword_Casing; end Keyword_Casing; function Last_Source_Line (S : SFI) return Physical_Line_Number is begin return Source_File.Table (S).Last_Source_Line; end Last_Source_Line; function License (S : SFI) return License_Type is begin return Source_File.Table (S).License; end License; function Num_SRef_Pragmas (S : SFI) return Nat is begin return Source_File.Table (S).Num_SRef_Pragmas; end Num_SRef_Pragmas; function Reference_Name (S : SFI) return File_Name_Type is begin return Source_File.Table (S).Reference_Name; end Reference_Name; function Source_Checksum (S : SFI) return Word is begin return Source_File.Table (S).Source_Checksum; end Source_Checksum; function Source_First (S : SFI) return Source_Ptr is begin return Source_File.Table (S).Source_First; end Source_First; function Source_Last (S : SFI) return Source_Ptr is begin return Source_File.Table (S).Source_Last; end Source_Last; function Source_Text (S : SFI) return Source_Buffer_Ptr is begin return Source_File.Table (S).Source_Text; end Source_Text; function Template (S : SFI) return SFI is begin return Source_File.Table (S).Template; end Template; function Time_Stamp (S : SFI) return Time_Stamp_Type is begin return Source_File.Table (S).Time_Stamp; end Time_Stamp; function Unit (S : SFI) return Unit_Number_Type is begin return Source_File.Table (S).Unit; end Unit; ------------------------------------------ -- Set Procedures for Source File Table -- ------------------------------------------ procedure Set_Identifier_Casing (S : SFI; C : Casing_Type) is begin Source_File.Table (S).Identifier_Casing := C; end Set_Identifier_Casing; procedure Set_Keyword_Casing (S : SFI; C : Casing_Type) is begin Source_File.Table (S).Keyword_Casing := C; end Set_Keyword_Casing; procedure Set_License (S : SFI; L : License_Type) is begin Source_File.Table (S).License := L; end Set_License; procedure Set_Unit (S : SFI; U : Unit_Number_Type) is begin Source_File.Table (S).Unit := U; end Set_Unit; ---------------------- -- Trim_Lines_Table -- ---------------------- procedure Trim_Lines_Table (S : Source_File_Index) is Max : constant Nat := Nat (Source_File.Table (S).Last_Source_Line); begin -- Release allocated storage that is no longer needed Source_File.Table (S).Lines_Table := To_Pointer (Memory.Realloc (To_Address (Source_File.Table (S).Lines_Table), Memory.size_t (Max * (Lines_Table_Type'Component_Size / System.Storage_Unit)))); Source_File.Table (S).Lines_Table_Max := Physical_Line_Number (Max); end Trim_Lines_Table; ------------ -- Unlock -- ------------ procedure Unlock is begin Source_File.Locked := False; Source_File.Release; end Unlock; -------- -- wl -- -------- procedure wl (P : Source_Ptr) is begin Write_Location (P); Write_Eol; end wl; end Sinput;
30,624
ada
24
svn2github/matreshka
source/amf/uml/amf-uml-messages.ads
<gh_stars>10-100 ------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, <NAME> <<EMAIL>> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ -- A message defines a particular communication between lifelines of an -- interaction. ------------------------------------------------------------------------------ limited with AMF.UML.Connectors; limited with AMF.UML.Interactions; limited with AMF.UML.Message_Ends; with AMF.UML.Named_Elements; limited with AMF.UML.Value_Specifications.Collections; package AMF.UML.Messages is pragma Preelaborate; type UML_Message is limited interface and AMF.UML.Named_Elements.UML_Named_Element; type UML_Message_Access is access all UML_Message'Class; for UML_Message_Access'Storage_Size use 0; not overriding function Get_Argument (Self : not null access constant UML_Message) return AMF.UML.Value_Specifications.Collections.Ordered_Set_Of_UML_Value_Specification is abstract; -- Getter of Message::argument. -- -- The arguments of the Message not overriding function Get_Connector (Self : not null access constant UML_Message) return AMF.UML.Connectors.UML_Connector_Access is abstract; -- Getter of Message::connector. -- -- The Connector on which this Message is sent. not overriding procedure Set_Connector (Self : not null access UML_Message; To : AMF.UML.Connectors.UML_Connector_Access) is abstract; -- Setter of Message::connector. -- -- The Connector on which this Message is sent. not overriding function Get_Interaction (Self : not null access constant UML_Message) return AMF.UML.Interactions.UML_Interaction_Access is abstract; -- Getter of Message::interaction. -- -- The enclosing Interaction owning the Message not overriding procedure Set_Interaction (Self : not null access UML_Message; To : AMF.UML.Interactions.UML_Interaction_Access) is abstract; -- Setter of Message::interaction. -- -- The enclosing Interaction owning the Message not overriding function Get_Message_Kind (Self : not null access constant UML_Message) return AMF.UML.UML_Message_Kind is abstract; -- Getter of Message::messageKind. -- -- The derived kind of the Message (complete, lost, found or unknown) not overriding function Get_Message_Sort (Self : not null access constant UML_Message) return AMF.UML.UML_Message_Sort is abstract; -- Getter of Message::messageSort. -- -- The sort of communication reflected by the Message not overriding procedure Set_Message_Sort (Self : not null access UML_Message; To : AMF.UML.UML_Message_Sort) is abstract; -- Setter of Message::messageSort. -- -- The sort of communication reflected by the Message not overriding function Get_Receive_Event (Self : not null access constant UML_Message) return AMF.UML.Message_Ends.UML_Message_End_Access is abstract; -- Getter of Message::receiveEvent. -- -- References the Receiving of the Message not overriding procedure Set_Receive_Event (Self : not null access UML_Message; To : AMF.UML.Message_Ends.UML_Message_End_Access) is abstract; -- Setter of Message::receiveEvent. -- -- References the Receiving of the Message not overriding function Get_Send_Event (Self : not null access constant UML_Message) return AMF.UML.Message_Ends.UML_Message_End_Access is abstract; -- Getter of Message::sendEvent. -- -- References the Sending of the Message. not overriding procedure Set_Send_Event (Self : not null access UML_Message; To : AMF.UML.Message_Ends.UML_Message_End_Access) is abstract; -- Setter of Message::sendEvent. -- -- References the Sending of the Message. not overriding function Get_Signature (Self : not null access constant UML_Message) return AMF.UML.Named_Elements.UML_Named_Element_Access is abstract; -- Getter of Message::signature. -- -- The signature of the Message is the specification of its content. It -- refers either an Operation or a Signal. not overriding procedure Set_Signature (Self : not null access UML_Message; To : AMF.UML.Named_Elements.UML_Named_Element_Access) is abstract; -- Setter of Message::signature. -- -- The signature of the Message is the specification of its content. It -- refers either an Operation or a Signal. not overriding function Message_Kind (Self : not null access constant UML_Message) return AMF.UML.UML_Message_Kind is abstract; -- Operation Message::messageKind. -- -- Missing derivation for Message::/messageKind : MessageKind end AMF.UML.Messages;
30,625
ada
1
jweese/Ada_Vent_19
day_03.adb
with Ada.Containers.Vectors; with Ada.Text_IO; with Ada.Integer_Text_IO; with Ada.IO_Exceptions; procedure Day_03 is type Point is record X, Y: Integer; end record; package Wire_Vec is new Ada.Containers.Vectors( Index_Type => Natural, Element_Type => Point); procedure Append_Comma_Separated_Wire_Points(W: in out Wire_Vec.Vector) is Curr: constant Point := W.Last_Element; Dir: Character; Distance: Natural; begin Ada.Text_IO.Get(Dir); Ada.Integer_Text_IO.Get(Distance); case Dir is when 'U' => for I in 1 .. Distance loop W.Append(Point'(X => Curr.X, Y => Curr.Y + I)); end loop; when 'D' => for I in 1 .. Distance loop W.Append(Point'(X => Curr.X, Y => Curr.Y - I)); end loop; when 'R' => for I in 1 .. Distance loop W.Append(Point'(X => Curr.X + I, Y => Curr.Y)); end loop; when 'L' => for I in 1 .. Distance loop W.Append(Point'(X => Curr.X - I, Y => Curr.Y)); end loop; when others => raise Ada.IO_Exceptions.Data_Error with Character'Image(Dir); end case; end Append_Comma_Separated_Wire_Points; function Read_Wire return Wire_Vec.Vector is W: Wire_Vec.Vector; Comma: Character; begin W.Append(Point'(0, 0)); loop Append_Comma_Separated_Wire_Points(W); exit when Ada.Text_IO.End_Of_Line; Ada.Text_IO.Get(Comma); end loop; return W; end Read_Wire; -- only used in part 1 -- function Manhattan(P: Point) return Natural is (abs(P.X) + abs(P.Y)); Wire_1: constant Wire_Vec.Vector := Read_Wire; Wire_2: constant Wire_Vec.Vector := Read_Wire; Min_Dist: Natural := Natural'Last; begin for I in Wire_1.First_Index .. Wire_1.Last_Index loop declare P: constant Point := Wire_1(I); J: constant Wire_Vec.Extended_Index := Wire_2.Find_Index(P); Dist: constant Natural := I + J; begin if J /= Wire_Vec.No_Index and Dist > 0 then Min_Dist := Natural'Min(Min_Dist, Dist); end if; end; end loop; Ada.Integer_Text_IO.Put(Min_Dist); end Day_03;
30,626
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/task_name.adb
<reponame>best08618/asylo -- { dg-do compile } package body task_name is task body Task_Object is begin null; end Task_Object; end;
30,627
ada
18
jquorning/ada-wiki
src/wiki-streams.ads
----------------------------------------------------------------------- -- wiki-streams -- Wiki input and output streams -- Copyright (C) 2011, 2012, 2013, 2015, 2016, 2020 <NAME> -- Written by <NAME> (<EMAIL>) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Wiki.Strings; -- == Input and Output streams {#wiki-streams} == -- The `Wiki.Streams` package defines the interfaces used by -- the parser or renderer to read and write their outputs. -- -- The `Input_Stream` interface defines the interface that must be implemented to -- read the source Wiki content. The `Read` procedure is called by the parser -- repeatedly while scanning the Wiki content. -- -- The `Output_Stream` interface is the interface used by the renderer -- to write their outpus. It defines the `Write` procedure to write -- a single character or a string. -- -- @include wiki-streams-html.ads -- @include wiki-streams-builders.ads -- @include wiki-streams-html-builders.ads -- @include wiki-streams-text_io.ads -- @include wiki-streams-html-text_io.ads package Wiki.Streams is pragma Preelaborate; type Input_Stream is limited interface; type Input_Stream_Access is access all Input_Stream'Class; -- Read one character from the input stream and return False to the <tt>Eof</tt> indicator. -- When there is no character to read, return True in the <tt>Eof</tt> indicator. procedure Read (Input : in out Input_Stream; Char : out Wiki.Strings.WChar; Eof : out Boolean) is abstract; type Output_Stream is limited interface; type Output_Stream_Access is access all Output_Stream'Class; -- Write the string to the output stream. procedure Write (Stream : in out Output_Stream; Content : in Wiki.Strings.WString) is abstract; -- Write a single character to the output stream. procedure Write (Stream : in out Output_Stream; Char : in Wiki.Strings.WChar) is abstract; end Wiki.Streams;
30,628
ada
0
wildeee/safADA
Exemplos ADA/HelloWorld.adb
With Ada.Text_IO; Use Ada.Text_IO; Procedure HelloWorld is begin Put("Programacao em Ada!"); New_Line; Put_Line("Hello World!!"); end HelloWorld;
30,629
ada
1
ekoeppen/STM32_Generic_Ada_Drivers
boards/stm32f051x8/stm32gd-board.adb
with STM32GD.Startup; package body STM32GD.Board is procedure Init is begin null; end Init; end STM32GD.Board;
30,630
ada
1
charlie5/lace-alire
1-base/lace/source/events/interface/lace-subject.ads
with lace.Event, lace.Observer; limited with lace.Event.Logger; package lace.Subject -- -- Provides an interface for an event subject. -- is pragma remote_Types; type Item is limited interface; type View is access all Item'Class; type Views is array (Positive range <>) of View; type fast_View is access all Item'Class with Asynchronous; type fast_Views is array (Positive range <>) of fast_View; ------------- -- Containers -- type Observer_views is array (Positive range <>) of Observer.view; ------------- -- Attributes -- function Name (Self : in Item) return Event.subject_Name is abstract; ------------ -- Observers -- procedure register (Self : access Item; the_Observer : in Observer.view; of_Kind : in Event.Kind) is abstract; procedure deregister (Self : in out Item; the_Observer : in Observer.view; of_Kind : in Event.Kind) is abstract; function Observers (Self : in Item; of_Kind : in Event.Kind) return Observer_views is abstract; function observer_Count (Self : in Item) return Natural is abstract; ------------- -- Operations -- procedure emit (Self : access Item; the_Event : in Event.item'Class := Event.null_Event) is abstract; -- -- Communication errors are ignored. function emit (Self : access Item; the_Event : in Event.item'Class := Event.null_Event) return Observer_views is abstract; -- -- Observers who cannot be communicated with are returned. ---------- -- Logging -- procedure Logger_is (Now : in Event.Logger.view); function Logger return Event.Logger.view; end lace.Subject;
30,631
ada
0
alexcamposruiz/dds-requestreply
src/orig/dds-request_reply-treqtreprequester.ads
<reponame>alexcamposruiz/dds-requestreply package DDS.Request_Reply.Treqtreprequester is pragma Elaborate_Body; end;
30,632
ada
0
python36/vibecrypt
file_crypter.ads
with byte_package; use byte_package; with raiden; package file_crypter is subtype key_s is raiden.key_s; type mode is (encrypt, decrypt); procedure init_key(key : raiden.key_s); procedure file_crypt(in_file : byte_io.File_Type; out_file : out byte_io.File_Type; mode_crypt : mode); end file_crypter;
30,633
ada
0
sciencylab/lagrangian-solver
src/numerics-max_int_array.adb
<gh_stars>0 separate (Numerics) function Max_Int_Array (Item : in Int_Array) return Integer is Result : Integer := Item (Item'First); begin for N of Item loop Result := Integer'Max (Result, N); end loop; return Result; end Max_Int_Array;
30,634
ada
33
ytomino/drake
source/sjlj/s-unwsea.adb
<filename>source/sjlj/s-unwsea.adb pragma Check_Policy (Trace => Ignore); with Ada.Unchecked_Conversion; with System.Address_To_Constant_Access_Conversions; with System.Storage_Elements; with System.Unwind.Representation; with C.unwind_pe; package body System.Unwind.Searching is pragma Suppress (All_Checks); use type Storage_Elements.Storage_Offset; use type C.ptrdiff_t; use type C.signed_int; use type C.size_t; use type C.unsigned_char; use type C.unsigned_char_const_ptr; use type C.unsigned_int; -- _Unwind_Ptr is unsigned int or unsigned long use type C.unsigned_long; use type C.unsigned_long_long; use type C.unwind.sleb128_t; Foreign_Exception : aliased Exception_Data with Import, Convention => Ada, External_Name => "system__exceptions__foreign_exception"; package unsigned_char_const_ptr_Conv is new Address_To_Constant_Access_Conversions ( C.unsigned_char, C.unsigned_char_const_ptr); function "+" (Left : C.unsigned_char_const_ptr; Right : C.ptrdiff_t) return C.unsigned_char_const_ptr with Convention => Intrinsic; pragma Inline_Always ("+"); function "+" (Left : C.unsigned_char_const_ptr; Right : C.ptrdiff_t) return C.unsigned_char_const_ptr is begin return unsigned_char_const_ptr_Conv.To_Pointer ( unsigned_char_const_ptr_Conv.To_Address (Left) + Storage_Elements.Storage_Offset (Right)); end "+"; -- implementation function Personality ( ABI_Version : C.signed_int; Phases : C.unwind.Unwind_Action; Exception_Class : C.unwind.Unwind_Exception_Class; Exception_Object : access C.unwind.struct_Unwind_Exception; Context : access C.unwind.struct_Unwind_Context) return C.unwind.Unwind_Reason_Code is function To_GNAT is new Ada.Unchecked_Conversion ( C.unwind.struct_Unwind_Exception_ptr, Representation.Machine_Occurrence_Access); function Cast is new Ada.Unchecked_Conversion ( C.unwind.struct_Unwind_Exception_ptr, C.unwind.Unwind_Word); function Cast is new Ada.Unchecked_Conversion ( Exception_Data_Access, C.unwind.Unwind_Ptr); function Cast is new Ada.Unchecked_Conversion (C.char_const_ptr, C.unwind.Unwind_Ptr); GCC_Exception : constant Representation.Machine_Occurrence_Access := To_GNAT (Exception_Object); landing_pad : C.unwind.Unwind_Ptr; ttype_filter : C.unwind.Unwind_Sword; -- 0 => finally, others => handler begin pragma Check (Trace, Ada.Debug.Put ("enter")); if ABI_Version /= 1 then pragma Check (Trace, Ada.Debug.Put ("leave, ABI_Version /= 1")); return C.unwind.URC_FATAL_PHASE1_ERROR; end if; if Exception_Class = Representation.GNAT_Exception_Class and then C.unsigned_int (Phases) = (C.unwind.UA_CLEANUP_PHASE or C.unwind.UA_HANDLER_FRAME) then landing_pad := GCC_Exception.landing_pad; ttype_filter := GCC_Exception.ttype_filter; pragma Check (Trace, Ada.Debug.Put ("shortcut!")); else declare -- about region lsda : C.void_ptr; base : C.unwind.Unwind_Ptr; call_site_table : C.unsigned_char_const_ptr; lp_base : aliased C.unwind.Unwind_Ptr; action_table : C.unsigned_char_const_ptr; ttype_encoding : C.unsigned_char; ttype_table : C.unsigned_char_const_ptr; ttype_base : C.unwind.Unwind_Ptr; -- about action table_entry : C.unsigned_char_const_ptr; begin if Context = null then pragma Check (Trace, Ada.Debug.Put ("leave, Context = null")); return C.unwind.URC_CONTINUE_UNWIND; end if; lsda := C.unwind.Unwind_GetLanguageSpecificData (Context); if Address (lsda) = Null_Address then pragma Check (Trace, Ada.Debug.Put ("leave, lsda = null")); return C.unwind.URC_CONTINUE_UNWIND; end if; base := C.unwind.Unwind_GetRegionStart (Context); declare p : C.unsigned_char_const_ptr := unsigned_char_const_ptr_Conv.To_Pointer (Address (lsda)); tmp : aliased C.unwind.uleb128_t; lpbase_encoding : C.unsigned_char; begin lpbase_encoding := p.all; p := p + 1; if lpbase_encoding /= C.unwind_pe.DW_EH_PE_omit then p := C.unwind_pe.read_encoded_value ( Context, lpbase_encoding, p, lp_base'Access); else lp_base := base; end if; ttype_encoding := p.all; p := p + 1; if ttype_encoding /= C.unwind_pe.DW_EH_PE_omit then p := C.unwind_pe.read_uleb128 (p, tmp'Access); ttype_table := p + C.ptrdiff_t (tmp); else pragma Check (Trace, Check => Ada.Debug.Put ("ttype_encoding = DW_EH_PE_omit")); ttype_table := null; -- be access violation ? end if; ttype_base := C.unwind_pe.base_of_encoded_value (ttype_encoding, Context); p := p + 1; call_site_table := C.unwind_pe.read_uleb128 (p, tmp'Access); action_table := call_site_table + C.ptrdiff_t (tmp); end; declare p : C.unsigned_char_const_ptr := call_site_table; ip_before_insn : aliased C.signed_int := 0; ip : C.unwind.Unwind_Ptr := C.unwind.Unwind_GetIPInfo (Context, ip_before_insn'Access); call_site : C.signed_int; begin if ip_before_insn = 0 then pragma Check (Trace, Ada.Debug.Put ("ip_before_insn = 0")); ip := ip - 1; end if; call_site := C.signed_int (ip); if call_site <= 0 then pragma Check (Trace, Check => Ada.Debug.Put ("leave, no action or terminate")); return C.unwind.URC_CONTINUE_UNWIND; end if; loop declare cs_lp : aliased C.unwind.uleb128_t; cs_action : aliased C.unwind.uleb128_t; begin p := C.unwind_pe.read_uleb128 (p, cs_lp'Access); p := C.unwind_pe.read_uleb128 (p, cs_action'Access); call_site := call_site - 1; if call_site = 0 then landing_pad := C.unwind.Unwind_Ptr (cs_lp + 1); if cs_action /= 0 then table_entry := action_table + C.ptrdiff_t (cs_action - 1); else table_entry := null; end if; exit; end if; end; end loop; end; -- landing_pad is found in here if table_entry = null then ttype_filter := 0; else declare ttype_size : constant C.ptrdiff_t := C.ptrdiff_t ( C.unwind_pe.size_of_encoded_value (ttype_encoding)); p : C.unsigned_char_const_ptr := table_entry; ar_filter, ar_disp : aliased C.unwind.sleb128_t; begin loop p := C.unwind_pe.read_sleb128 (p, ar_filter'Access); declare Dummy : C.unsigned_char_const_ptr; begin Dummy := C.unwind_pe.read_sleb128 (p, ar_disp'Access); end; if ar_filter = 0 then ttype_filter := 0; if ar_disp = 0 then pragma Check (Trace, Ada.Debug.Put ("finally")); exit; end if; elsif ar_filter > 0 and then (C.unsigned_int (Phases) and C.unwind.UA_FORCE_UNWIND) = 0 then declare filter : constant C.ptrdiff_t := C.ptrdiff_t (ar_filter) * ttype_size; choice : aliased C.unwind.Unwind_Ptr; is_handled : Boolean; Dummy : C.unsigned_char_const_ptr; begin Dummy := C.unwind_pe.read_encoded_value_with_base ( ttype_encoding, ttype_base, ttype_table + (-filter), choice'Access); if Exception_Class = Representation.GNAT_Exception_Class then is_handled := choice = Cast (GCC_Exception.Occurrence.Id) or else ( not GCC_Exception.Occurrence.Id .Not_Handled_By_Others and then choice = Cast (Others_Value'Access)) or else choice = Cast (All_Others_Value'Access); else pragma Check (Trace, Check => Ada.Debug.Put ("foreign exception")); is_handled := choice = Cast (Foreign_Exception'Access) or else choice = Cast (Others_Value'Access) or else choice = Cast (All_Others_Value'Access); end if; if is_handled then ttype_filter := C.unwind.Unwind_Sword (ar_filter); pragma Check (Trace, Check => Ada.Debug.Put ("handler is found")); exit; end if; end; else pragma Check (Trace, Ada.Debug.Put ("ar_filter < 0")); null; end if; if ar_disp = 0 then pragma Check (Trace, Check => Ada.Debug.Put ("leave, ar_disp = 0")); return C.unwind.URC_CONTINUE_UNWIND; end if; p := p + C.ptrdiff_t (ar_disp); end loop; end; end if; -- ttype_filter is found (or 0) in here if (C.unsigned_int (Phases) and C.unwind.UA_SEARCH_PHASE) /= 0 then if ttype_filter = 0 then -- cleanup pragma Check (Trace, Check => Ada.Debug.Put ("leave, UA_SEARCH_PHASE, cleanup")); return C.unwind.URC_CONTINUE_UNWIND; else -- Setup_Current_Excep (GCC_Exception); null; -- exception tracing (a-exextr.adb) is not implementd. -- shortcut for phase2 if Exception_Class = Representation.GNAT_Exception_Class then pragma Check (Trace, Ada.Debug.Put ("save for shortcut")); GCC_Exception.landing_pad := landing_pad; GCC_Exception.ttype_filter := ttype_filter; end if; pragma Check (Trace, Check => Ada.Debug.Put ( "leave, UA_SEARCH_PHASE, handler found")); return C.unwind.URC_HANDLER_FOUND; end if; elsif Phases = C.unwind.UA_CLEANUP_PHASE then if ttype_filter = 0 and then Exception_Class = Representation.GNAT_Exception_Class and then GCC_Exception.Stack_Guard /= Null_Address then declare Stack_Pointer : constant C.unwind.Unwind_Word := C.unwind.Unwind_GetCFA (Context); begin if Stack_Pointer < C.unwind.Unwind_Word (GCC_Exception.Stack_Guard) then pragma Check (Trace, Check => Ada.Debug.Put ("leave, skip cleanup")); return C.unwind.URC_CONTINUE_UNWIND; end if; end; end if; pragma Check (Trace, Check => Ada.Debug.Put ( "UA_CLEANUP_PHASE without UA_HANDLER_FRAME")); null; -- ??? else pragma Check (Trace, Ada.Debug.Put ("miscellany phase")); null; -- ??? end if; end; end if; pragma Check (Trace, Ada.Debug.Put ("unwind!")); -- setup_to_install (raise-gcc.c) C.unwind.Unwind_SetGR ( Context, 0, -- builtin_eh_return_data_regno (0), Cast (C.unwind.struct_Unwind_Exception_ptr (Exception_Object))); C.unwind.Unwind_SetGR ( Context, 1, -- builtin_eh_return_data_regno (1), C.unwind.Unwind_Word'Mod (ttype_filter)); C.unwind.Unwind_SetIP (Context, landing_pad); -- Setup_Current_Excep (GCC_Exception); -- moved to Begin_Handler pragma Check (Trace, Ada.Debug.Put ("leave")); return C.unwind.URC_INSTALL_CONTEXT; end Personality; end System.Unwind.Searching;
30,635
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/old_errors.ads
<reponame>best08618/asylo<gh_stars>1-10 package Old_Errors is pragma Elaborate_Body; end Old_Errors;
30,636
ada
12
TUM-EI-RCS/StratoX
tests/subnormal-target/src/calc.adb
<filename>tests/subnormal-target/src/calc.adb package body calc with SPARK_Mode is function calc (f1, f2: Float) return Float is begin return f1 * f2; -- Float overflow check proved, but it throws an exception because of underflow. end calc; end calc;
30,637
ada
1
fabiojna02/OpenCellular
firmware/coreboot/3rdparty/libgfxinit/common/ironlake/hw-gfx-gma-pch-lvds.adb
<filename>firmware/coreboot/3rdparty/libgfxinit/common/ironlake/hw-gfx-gma-pch-lvds.adb -- -- Copyright (C) 2015-2016 secunet Security Networks AG -- Copyright (C) 2016 <NAME> <<EMAIL>> -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- with HW.GFX.GMA.Config; with HW.GFX.GMA.Registers; with HW.Debug; with GNAT.Source_Info; package body HW.GFX.GMA.PCH.LVDS is PCH_LVDS_ENABLE : constant := 1 * 2 ** 31; PCH_LVDS_VSYNC_POLARITY_INVERT : constant := 1 * 2 ** 21; PCH_LVDS_HSYNC_POLARITY_INVERT : constant := 1 * 2 ** 20; PCH_LVDS_CLK_A_DATA_A0A2_POWER_MASK : constant := 3 * 2 ** 8; PCH_LVDS_CLK_A_DATA_A0A2_POWER_DOWN : constant := 0 * 2 ** 8; PCH_LVDS_CLK_A_DATA_A0A2_POWER_UP : constant := 3 * 2 ** 8; PCH_LVDS_CLK_B_POWER_MASK : constant := 3 * 2 ** 4; PCH_LVDS_CLK_B_POWER_DOWN : constant := 0 * 2 ** 4; PCH_LVDS_CLK_B_POWER_UP : constant := 3 * 2 ** 4; PCH_LVDS_DATA_B0B2_POWER_MASK : constant := 3 * 2 ** 2; PCH_LVDS_DATA_B0B2_POWER_DOWN : constant := 0 * 2 ** 2; PCH_LVDS_DATA_B0B2_POWER_UP : constant := 3 * 2 ** 2; ---------------------------------------------------------------------------- procedure On (Port_Cfg : Port_Config; FDI_Port : FDI_Port_Type) is Sync_Polarity : constant Word32 := (if Port_Cfg.Mode.H_Sync_Active_High then 0 else PCH_LVDS_HSYNC_POLARITY_INVERT) or (if Port_Cfg.Mode.V_Sync_Active_High then 0 else PCH_LVDS_VSYNC_POLARITY_INVERT); Two_Channel : constant Word32 := (if Port_Cfg.Mode.Dotclock >= Config.LVDS_Dual_Threshold then PCH_LVDS_CLK_B_POWER_UP or PCH_LVDS_DATA_B0B2_POWER_UP else 0); begin pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); pragma Debug (Port_Cfg.Mode.BPC /= 6, Debug.Put_Line ("WARNING: Only 18bpp LVDS mode implemented.")); Registers.Write (Register => Registers.PCH_LVDS, Value => PCH_LVDS_ENABLE or PCH_TRANSCODER_SELECT (FDI_Port) or Sync_Polarity or PCH_LVDS_CLK_A_DATA_A0A2_POWER_UP or Two_Channel); end On; ---------------------------------------------------------------------------- procedure Off is begin pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); Registers.Write (Register => Registers.PCH_LVDS, Value => PCH_LVDS_CLK_A_DATA_A0A2_POWER_DOWN or PCH_LVDS_CLK_B_POWER_DOWN or PCH_LVDS_DATA_B0B2_POWER_DOWN); end Off; end HW.GFX.GMA.PCH.LVDS;
30,638
ada
15
My-Colaborations/dynamo
src/asis/asis-elements.ads
<filename>src/asis/asis-elements.ads ------------------------------------------------------------------------------ -- -- -- ASIS-for-GNAT INTERFACE COMPONENTS -- -- -- -- A S I S . E L E M E N T S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2006-2011, AdaCore -- -- -- -- This specification is adapted from the Ada Semantic Interface -- -- Specification Standard (ISO/IEC 15291) for use with GNAT. In accordance -- -- with the copyright of that document, you can freely copy and modify this -- -- specification, provided that if you redistribute a modified version, any -- -- changes that you have made are clearly indicated. -- -- -- -- This specification also contains suggestions and discussion items -- -- related to revising the ASIS Standard according to the changes proposed -- -- for the new revision of the Ada standard. The copyright notice above, -- -- and the license provisions that follow apply solely to these suggestions -- -- and discussion items that are separated by the corresponding comment -- -- sentinels -- -- -- -- ASIS-for-GNAT is free software; you can redistribute it and/or modify it -- -- under terms of the GNU General Public License as published by the Free -- -- Software Foundation; either version 2, or (at your option) any later -- -- version. ASIS-for-GNAT is distributed in the hope that it will be use- -- -- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- -- -- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -- -- Public License for more details. You should have received a copy of the -- -- GNU General Public License distributed with ASIS-for-GNAT; see file -- -- COPYING. If not, write to the Free Software Foundation, 51 Franklin -- -- Street, Fifth Floor, Boston, MA 02110-1301, USA. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the -- -- Software Engineering Laboratory of the Swiss Federal Institute of -- -- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the -- -- Scientific Research Computer Center of Moscow State University (SRCC -- -- MSU), Russia, with funding partially provided by grants from the Swiss -- -- National Science Foundation and the Swiss Academy of Engineering -- -- Sciences. ASIS-for-GNAT is now maintained by AdaCore -- -- (http://www.adacore.com). -- -- -- ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- 13 package Asis.Elements -- Suggestions related to changing this specification to accept new Ada -- features as defined in incoming revision of the Ada Standard (ISO 8652) -- are marked by following comment sentinels: -- -- --|A2005 start -- ... the suggestion goes here ... -- --|A2005 end -- -- and the discussion items are marked by the comment sentinels of teh form: -- -- --|D2005 start -- ... the discussion item goes here ... -- --|D2005 end -- -- Suggestions related to changing this specification to accept new Ada -- features as suggested by ARG for next revision of the Ada Standard -- (ISO 8652) grouped in the end of the package specification. ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ package Asis.Elements is ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Asis.Elements encapsulates a set of queries that operate on all elements -- and some queries specific to A_Pragma elements. ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- 13.1 function Unit_Declaration ------------------------------------------------------------------------------ -- Gateway queries between Compilation_Units and Elements. ------------------------------------------------------------------------------ function Unit_Declaration (Compilation_Unit : Asis.Compilation_Unit) return Asis.Declaration; ------------------------------------------------------------------------------ -- Compilation_Unit - Specifies the unit to query -- -- Returns the element representing the declaration of the compilation_unit. -- -- Returns a Nil_Element if the unit is A_Nonexistent_Declaration, -- A_Nonexistent_Body, A_Configuration_Compilation, or An_Unknown_Unit. -- -- All Unit_Kinds are appropriate except Not_A_Unit. -- -- Returns Declaration_Kinds: -- Not_A_Declaration -- A_Function_Body_Declaration -- A_Function_Declaration -- A_Function_Instantiation -- A_Generic_Function_Declaration -- A_Generic_Package_Declaration -- A_Generic_Procedure_Declaration -- A_Package_Body_Declaration -- A_Package_Declaration -- A_Package_Instantiation -- A_Procedure_Body_Declaration -- A_Procedure_Declaration -- A_Procedure_Instantiation -- A_Task_Body_Declaration -- A_Package_Renaming_Declaration -- A_Procedure_Renaming_Declaration -- A_Function_Renaming_Declaration -- A_Generic_Package_Renaming_Declaration -- A_Generic_Procedure_Renaming_Declaration -- A_Generic_Function_Renaming_Declaration -- A_Protected_Body_Declaration -- ------------------------------------------------------------------------------ -- 13.2 function Enclosing_Compilation_Unit ------------------------------------------------------------------------------ function Enclosing_Compilation_Unit (Element : Asis.Element) return Asis.Compilation_Unit; ------------------------------------------------------------------------------ -- Element - Specifies an Element whose Compilation_Unit is desired -- -- Returns the Compilation_Unit that contains the given Element. -- -- Raises ASIS_Inappropriate_Element if the Element is a Nil_Element. -- ------------------------------------------------------------------------------ -- 13.3 function Context_Clause_Elements ------------------------------------------------------------------------------ function Context_Clause_Elements (Compilation_Unit : Asis.Compilation_Unit; Include_Pragmas : Boolean := False) return Asis.Context_Clause_List; ------------------------------------------------------------------------------ -- Compilation_Unit - Specifies the unit to query -- Include_Pragmas - Specifies whether pragmas are to be returned -- -- Returns a list of with clauses, use clauses, and pragmas that explicitly -- appear in the context clause of the compilation unit, in their order of -- appearance. -- -- Returns a Nil_Element_List if the unit has A_Nonexistent_Declaration, -- A_Nonexistent_Body, or An_Unknown_Unit Unit_Kind. -- -- --|IR -- All pragma Elaborate elements for this unit will appear in this list. Other -- pragmas will appear in this list, or in the Compilation_Pragmas list, or -- both. -- --|IP -- Implementors are encouraged to use this list to return all pragmas whose -- full effect is determined by their exact textual position. Pragmas that -- do not have placement dependencies may be returned in either list. Only -- pragmas that appear in the unit's context clause are returned -- by this query. All other pragmas, affecting the compilation of this -- unit, are available from the Compilation_Pragmas query. -- -- Ada predefined packages, such as package Standard, may or may not have -- context-clause elements available for processing by applications. The -- physical existence of a package Standard is implementation specific. -- The same is true for other Ada predefined packages, such as Ada.Text_Io and -- Ada.Direct_Io. The Origin query can be used to determine whether or not -- a particular unit is an Ada Predefined unit. -- -- --|IP -- Results of this query may vary across ASIS implementations. Some -- implementations normalize all multi-name with clauses and use clauses -- into an equivalent sequence of single-name with clause and use clauses. -- Similarly, an implementation may retain only a single reference to a name -- that appeared more than once in the original context clause. -- Some implementors will return only pragma -- Elaborate elements in this list and return all other pragmas via the -- Compilation_Pragmas query. -- -- All Unit_Kinds are appropriate except Not_A_Unit. -- -- Returns Element_Kinds: -- A_Pragma -- A_Clause -- -- Returns Clause_Kinds: -- A_With_Clause -- A_Use_Package_Clause -- ------------------------------------------------------------------------------ -- 13.4 function Configuration_Pragmas ------------------------------------------------------------------------------ function Configuration_Pragmas (The_Context : Asis.Context) return Asis.Pragma_Element_List; ------------------------------------------------------------------------------ -- The_Context - Specifies the Context to query -- -- Returns a list of pragmas that apply to all future compilation_unit -- elements compiled into The_Context. Pragmas returned by this query should -- have appeared in a compilation that had no compilation_unit elements. -- To the extent that order is meaningful, the pragmas should be in -- their order of appearance in the compilation. (The order is implementation -- dependent, many pragmas have the same effect regardless of order.) -- -- Returns a Nil_Element_List if there are no such configuration pragmas. -- -- Returns Element_Kinds: -- A_Pragma -- ------------------------------------------------------------------------------ -- 13.5 function Compilation_Pragmas ------------------------------------------------------------------------------ function Compilation_Pragmas (Compilation_Unit : Asis.Compilation_Unit) return Asis.Pragma_Element_List; ------------------------------------------------------------------------------ -- Compilation_Unit - Specifies the unit to query -- -- Returns a list of pragmas that apply to the compilation of the unit. -- To the extent that order is meaningful, the pragmas should be in -- their order of appearance in the compilation. (The order is implementation -- dependent, many pragmas have the same effect regardless of order.) -- -- There are two sources for the pragmas that appear in this list: -- -- - Program unit pragmas appearing at the place of a compilation_unit. -- See Reference Manual 10.1.5(4). -- -- - Configuration pragmas appearing before the first -- compilation_unit of a compilation. See Reference Manual 10.1.5(8). -- -- This query does not return Elaborate pragmas from the unit context -- clause of the compilation unit; they do not apply to the compilation, -- only to the unit. -- -- Use the Context_Clause_Elements query to obtain a list of all pragmas -- (including Elaborate pragmas) from the context clause of a compilation -- unit. -- -- Pragmas from this query may be duplicates of some or all of the -- non-Elaborate pragmas available from the Context_Clause_Elements query. -- Such duplication is simply the result of the textual position of the -- pragma--globally effective pragmas may appear textually within the context -- clause of a particular unit, and be returned as part of the Context_Clause -- for that unit. -- -- Ada predefined packages, such as package Standard, may or may not have -- pragmas available for processing by applications. The physical -- existence of a package Standard is implementation specific. The same -- is true for other Ada predefined packages, such as Ada.Text_Io and -- Ada.Direct_Io. The Origin query can be used to determine whether or -- not a particular unit is an Ada Predefined unit. -- -- Returns a Nil_Element_List if the compilation unit: -- -- - has no such applicable pragmas. -- -- - is an An_Unknown_Unit, A_Nonexistent_Declaration, or A_Nonexistent_Body. -- -- All Unit_Kinds are appropriate except Not_A_Unit. -- -- Returns Element_Kinds: -- A_Pragma -- ------------------------------------------------------------------------------ -- Element_Kinds Hierarchy ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Element_Kinds Value Subordinate Kinds ------------------------------------------------------------------------------ -- -- Key: Read "->" as "can be further categorized by its" -- -- A_Pragma -> Pragma_Kinds -- -- A_Defining_Name -> Defining_Name_Kinds -- -> Operator_Kinds -- -- A_Declaration -> Declaration_Kinds -- -> Declaration_Origin -- -> Mode_Kinds -- -> Subprogram_Default_Kinds -- -- A_Definition -> Definition_Kinds -- -> Trait_Kinds -- -> Type_Kinds -- -> Formal_Type_Kinds -- -> Access_Type_Kinds -- -> Root_Type_Kinds -- -> Constraint_Kinds -- -> Discrete_Range_Kinds -- -- An_Expression -> Expression_Kinds -- -> Operator_Kinds -- -> Attribute_Kinds -- -- An_Association -> Association_Kinds -- -- A_Statement -> Statement_Kinds -- -- A_Path -> Path_Kinds -- -- A_Clause -> Clause_Kinds -- -> Representation_Clause_Kinds -- -- An_Exception_Handler -- ------------------------------------------------------------------------------ -- 13.6 function Element_Kind ------------------------------------------------------------------------------ function Element_Kind (Element : Asis.Element) return Asis.Element_Kinds; ------------------------------------------------------------------------------ -- Element - Specifies the element to query -- -- Returns the Element_Kinds value of Element. -- Returns Not_An_Element for a Nil_Element. -- -- All element kinds are expected. -- ------------------------------------------------------------------------------ -- 13.7 function Pragma_Kind ------------------------------------------------------------------------------ function Pragma_Kind (Pragma_Element : Asis.Pragma_Element) return Asis.Pragma_Kinds; ------------------------------------------------------------------------------ -- Pragma_Element - Specifies the element to query -- -- Returns the Pragma_Kinds value of Pragma_Element. -- Returns Not_A_Pragma for any unexpected element such as a -- Nil_Element, A_Statement, or A_Declaration. -- -- Expected Element_Kinds: -- A_Pragma -- ------------------------------------------------------------------------------ -- 13.8 function Defining_Name_Kind ------------------------------------------------------------------------------ function Defining_Name_Kind (Defining_Name : Asis.Defining_Name) return Asis.Defining_Name_Kinds; ------------------------------------------------------------------------------ -- Defining_Name - Specifies the element to query -- -- Returns the Defining_Name_Kinds value of the Defining_Name. -- -- Returns Not_A_Defining_Name for any unexpected element such as a -- Nil_Element, A_Clause, or A_Statement. -- -- Expected Element_Kinds: -- A_Defining_Name -- ------------------------------------------------------------------------------ -- 13.9 function Declaration_Kind ------------------------------------------------------------------------------ function Declaration_Kind (Declaration : Asis.Declaration) return Asis.Declaration_Kinds; ------------------------------------------------------------------------------ -- Declaration - Specifies the element to query -- -- Returns the Declaration_Kinds value of the Declaration. -- -- Returns Not_A_Declaration for any unexpected element such as a -- Nil_Element, A_Definition, or A_Statement. -- -- Expected Element_Kinds: -- A_Declaration -- ------------------------------------------------------------------------------ -- 13.10 function Trait_Kind ------------------------------------------------------------------------------ function Trait_Kind (Element : Asis.Element) return Asis.Trait_Kinds; ------------------------------------------------------------------------------ -- Element - Specifies the Element to query -- -- Returns the Trait_Kinds value of the Element. -- -- Returns Not_A_Trait for any unexpected element such as a -- Nil_Element, A_Statement, or An_Expression. -- -- Expected Declaration_Kinds: -- A_Private_Type_Declaration -- A_Private_Extension_Declaration -- A_Variable_Declaration -- A_Constant_Declaration -- A_Deferred_Constant_Declaration -- A_Discriminant_Specification -- A_Loop_Parameter_Specification -- --|A2012 start -- A_Generalized_Iterator_Specification -- An_Element_Iterator_Specification -- --|A2012 end -- A_Procedure_Declaration -- A_Function_Declaration -- A_Parameter_Specification -- --|A2005 start -- A_Return_Object_Declaration -- An_Object_Renaming_Declaration -- A_Formal_Object_Declaration -- A_Formal_Procedure_Declaration -- A_Formal_Function_Declaration -- --|A2005 end -- -- Expected Definition_Kinds: -- A_Component_Definition -- A_Private_Type_Definition -- A_Tagged_Private_Type_Definition -- A_Private_Extension_Definition -- --|A2005 start -- A_Subtype_Indication -- An_Access_Definition -- --|A2005 end -- -- Expected Type_Kinds: -- A_Derived_Type_Definition -- A_Derived_Record_Extension_Definition -- A_Record_Type_Definition -- A_Tagged_Record_Type_Definition -- --|A2005 start -- An_Access_Type_Definition -- --|A2005 end -- -- Expected Formal_Type_Kinds: -- A_Formal_Private_Type_Definition -- A_Formal_Tagged_Private_Type_Definition -- A_Formal_Derived_Type_Definition -- -- --|A2005 start -- Expected Clause_Kinds: -- A_With_Clause -- -- We need a note saying that An_Access_Definition_Trait is an obsolescent -- value kept only because of upward compatibility reasons. Now an -- access_definition that defines an anonymous access kind is represented as -- a first-class citizen in the ASIS Element classification hierarchy -- (An_Access_Definition value in Definition_Kinds and the subordinate -- Access_Definition_Kinds type). -- We have a problem here with A_Discriminant_Specification and -- A_Parameter_Specification arguments. In Ada 95, the only possible value for -- them was An_Access_Definition_Trait. Now we do not need this, because we -- have An_Access_Definition as a new value in Definition_Kinds. But in -- ASIS 2005 we have to define if the argument is of a new -- A_Null_Exclusion_Trait Trait_Kinds value. A good thing is that the -- situations when An_Access_Definition_Trait and A_Null_Exclusion_Trait -- should be returned do not cross, so we can keep returning the -- An_Access_Definition_Trait value even though it does not make very much -- sense for Ada 2005. -- -- Do we need a special note about this? -- Another problem is an access definition of the form: -- -- A : not null access function return not null T; -- B : not null access function return T; -- C : access function return not null T; -- -- We have two null_exclusion syntax elements in the declaration of A, and -- one null_exclusion syntax element in declarations of B and C, but - in -- different places. How to make a difference between these cases? We can -- hardly do this within the Trate_Kinds and with Trate_Kind query. I -- would add a boolean query Is_Not_Null_Return to represent the presence of -- null_exclusion in parameter_and_result_profile, and Trait_Kind should -- reflect only the presence of null_exclusion in the syntax structure -- of access_definition (this looks logical - an Access_Definition Element -- represents exactly what is called access_definition in Ada 2005, and -- we do not have a position in ASIS Elements classification to represent -- as a whole parameter_and_result_profile or what follows the RETURN -- keyword in function specification). -- -- The ARG version of the ASIS 2005 definition says that Trait_Kinds and the -- corresponding query Trait_Kind are obsolescent. And they are right, because -- already for Ada 2005 Trait_Kinds cannot describe all the needed variations -- in Element structure. The ARG definition suggests the following Boolean -- queries as the replacement for Trait_Kind(s) function Has_Abstract (Element : Asis.Element) return Boolean; -- Element specifies the element to query. -- -- Returns True if the reserved word abstract appears in Element, and False -- otherwise. Returns False for any unexpected element, including -- Nil_Element. -- -- Element expects an element that has one of the following -- Declaration_Kinds: -- A_Formal_Procedure_Declaration -- A_Formal_Function_Declaration -- A_Function_Declaration -- An_Ordinary_Type_Declaration -- A_Private_Type_Declaration -- A_Private_Extension_Declaration -- A_Procedure_Declaration -- or an element that has one of the following Definition_Kinds: -- A_Private_Extension_Definition -- A_Private_Type_Definition -- A_Tagged_Private_Type_Definition -- A_Type_Definition -- or an element that has one of the following Formal_Type_Kinds: -- A_Formal_Private_Type_Definition -- A_Formal_Tagged_Private_Type_Definition -- A_Formal_Derived_Type_Definition -- -- Note: the specification above is taken "as is" from the ARG ASIS 2005 -- definition. But there is no sense to include in the list of -- expedcted kinds (that is, to the list of kinds for that the query -- can return True) A_Private_Type_Definition and -- A_Formal_Private_Type_Definition, because only tagged (formal) -- private types can be abstract. function Has_Aliased (Element : Asis.Element) return Boolean; -- Element specifies the Element to query. -- -- Returns True if the reserved word aliased appears in Element, and False -- otherwise. Returns False for any unexpected element, including -- Nil_Element. -- -- Element expects an element that has one of the following -- Declaration_Kinds: -- A_Constant_Declaration -- A_Deferred_Constant_Declaration -- A_Return_Object_Declaration -- A_Variable_Declaration -- A_Component_Declaration -- A_Parameter_Specification -- 2012 -- or an element that has the following Definition_Kinds: -- A_Component_Definition -- -- NOTES: * A_Component_Declaration is added to the list of expected -- Declaration_Kinds given in in ARG version of the ASIS 2005 -- definition. -- -- * A_Parameter_Specification is added to the list of expected -- kinds for Ada 2012 function Has_Limited (Element : Asis.Element) return Boolean; -- Element specifies the Element to query. -- -- Returns True if the reserved word limited appears in Element, and False -- otherwise. Returns False for any unexpected element, including -- Nil_Element. -- -- Element expects an element that has the following Clause_Kinds: -- A_With_Clause -- or an element that has one of the following Declaration_Kinds: -- An_Ordinary_Type_Declaration -- A_Private_Type_Declaration -- A_Private_Extension_Declaration -- or an element that has one of the following Definition_Kinds: -- A_Type_Definition -- A_Private_Type_Definition -- A_Tagged_Private_Type_Definition -- A_Private_Extension_Definition -- or an element that has one of the following Formal_Type_Kinds: -- A_Formal_Private_Type_Definition -- A_Formal_Tagged_Private_Type_Definition -- A_Formal_Derived_Type_Definition function Has_Private (Element : Asis.Element) return Boolean; -- Element specifies the element to query. -- -- Returns True if the reserved word private appears in Element, and False -- otherwise. Returns False for any unexpected element, including -- Nil_Element. -- -- Element expects an element that has one of the following -- Declaration_Kinds: -- A_Private_Extension_Declaration -- A_Private_Type_Declaration -- or an element that has one of the following Definition_Kinds: -- A_Private_Extension_Definition -- A_Private_Type_Definition -- A_Tagged_Private_Type_Definition -- A_Type_Definition -- or an element that has one of the following Formal_Type_Kinds: -- A_Formal_Private_Type_Definition -- A_Formal_Tagged_Private_Type_Definition -- or an element that has the following Clause_Kinds: -- A_With_Clause function Has_Protected (Element : Asis.Element) return Boolean; -- Element specifies the Element to query. -- -- Returns True if the reserved word protected appears in Element, and -- False otherwise. Returns False for any unexpected element, including -- Nil_Element. -- -- Element expects an element that has the following Definition_Kinds: -- A_Protected_Definition -- or an element that has the following Type_Kinds: -- An_Interface_Type_Definition -- or an element that has one of the following Declaration_Kinds: -- A_Protected_Body_Declaration -- A_Protected_Type_Declaration -- A_Single_Protected_Declaration -- -- NOTE: we have added -- A_Protected_Body_Stub -- to the list of expected kinds. Shoudl the list of expected kinds also -- contain -- An_Access_To_Protected_Procedure -- An_Access_To_Protected_Function? -- At the moment the query returns FALSE for these values. function Has_Reverse (Element : Asis.Element) return Boolean; -- Element specifies the Element to query. -- -- Returns True if the reserved word reverse appears in Element, and False -- otherwise. Returns False for any unexpected element, including -- Nil_Element. -- Element expects an element that has the following Declaration_Kinds: -- A_Loop_Parameter_Specification -- A_Generalized_Iterator_Specification -- An_Element_Iterator_Specification function Has_Synchronized (Element : Asis.Element) return Boolean; -- Element specifies the Element to query. -- -- Returns True if the reserved word synchronized appears in Element, and -- False otherwise. Returns False for any unexpected element, including -- Nil_Element. -- -- Element expects an element that has the following Definition_Kinds: -- A_Private_Extension_Definition -- or an element that has the following Type_Kinds: -- An_Interface_Type_Definition -- -- NOTE: it looks like the following Formal_Type_Kinds value is missing -- in the list of expected kinds: -- -- A_Formal_Derived_Type_Definition -- According to the syntax defined in 12.5.1 (3/2), it can contain -- the reserved word 'synchronized' function Has_Tagged (Element : Asis.Element) return Boolean; -- Element specifies the Element to query. -- -- Returns True if the reserved word tagged appears in Element, and False -- otherwise. Returns False for any unexpected element, including -- Nil_Element. -- -- Element expects an element that has one of the following -- Definition_Kinds: -- A_Tagged_Private_Type_Definition -- or an element that has the following Type_Kinds: -- A_Tagged_Record_Type_Definition -- or an element that has the following Formal_Type_Kinds: -- A_Formal_Tagged_Private_Type_Definition -- or an element that has the following Declaration_Kinds: -- A_Tagged_Incomplete_Type_Declaration -- A_Formal_Incomplete_Type_Declaration (Ada 2012) -- -- NOTE: In the ARG ASIS, the definition of this query contains -- A_Tagged_Incomplete_Type_Definition as expected Definition_Kinds -- value. But the GNAT ASIS does not have -- A_Tagged_Incomplete_Type_Definition, but it has -- A_Tagged_Incomplete_Type_Declaration value in Declaration_Kinds -- instead. The definition of the query is adjusted to follow GNAT -- ASIS. function Has_Task (Element : Asis.Element) return Boolean; -- Element specifies the Element to query. -- -- Returns True if the reserved word task appears in Element, and False -- otherwise. Returns False for any unexpected element, including -- Nil_Element. -- -- Element expects an element that has the following Definition_Kinds: -- A_Task_Definition -- or an element that has the following Type_Kinds: -- An_Interface_Type_Definition -- or an element that has one of the following Declaration_Kinds: -- A_Task_Type_Declaration -- A_Single_Task_Declaration -- A_Task_Body_Declaration -- NOTE: we have added -- A_Task_Body_Stub -- to the list of expected kinds. function Has_Null_Exclusion -- 3.2.2(3/2), 3.7(5/2), 3.10 (2/2,6/2), -- 6.1(13/2,15/2), 8.5.1(2/2), 12.4(2/2) (Element : Asis.Element) return Boolean; -- Element specifies the element to query. -- -- Returns True if the argument element has a null_exclusion specifier, and -- returns False otherwise (including for any unexpected element). -- -- Element expects an element that has one of the following -- Definition_Kinds: -- A_Type_Definition -- An_Access_Definition -- A_Subtype_Indication -- or Element expects an that has the following Type_Kinds: -- An_Access_Type_Definition -- or Element expects an that has one of the following Declaration_Kinds: -- A_Discriminant_Specification -- A_Parameter_Specification -- A_Formal_Object_Declaration -- An_Object_Renaming_Declaration -- --|A2005 end -- --|A2005 start ------------------------------------------------------------------------------ -- 13.?? function Is_Not_Null_Return ------------------------------------------------------------------------------ function Is_Not_Null_Return (Element : Asis.Element) return Boolean; ------------------------------------------------------------------------------ -- Element - Specifies the element to check -- -- Checks if the argument element contains a parameter_and_result_profile -- component and if this component has null_exclusion specifier -- -- Returns False for any unexpected element as a Nil_Element, A_Statement or -- A_Clause. -- -- Expected Declaration_Kinds: -- A_Function_Declaration -- A_Function_Body_Declaration -- A_Function_Renaming_Declaration -- A_Function_Body_Stub -- A_Generic_Function_Declaration -- A_Formal_Function_Declaration -- -- Expected Access_Type_Kinds: (not implemented in the compiler yet?) -- An_Access_To_Function -- An_Access_To_Protected_Function -- -- Expected Access_Definition_Kinds: (not implemented in the compiler yet?) -- An_Anonymous_Access_To_Function -- An_Anonymous_Access_To_Protected_Function -- --|A2005 end -- --|A2005 start ------------------------------------------------------------------------------ -- 13.??? function Is_Prefix_Notation (implemented) ------------------------------------------------------------------------------ function Is_Prefix_Notation (Call : Asis.Element) return Boolean; ------------------------------------------------------------------------------ -- Call - Specifies the procedure or function call to query -- -- Returns True if the argument is a procedure or a function call in the -- prefix notation: Object_Name.Operation_Name (...). Returns False for any -- unexpected argument -- -- Expected Statement_Kinds: -- A_Procedure_Call_Statement -- -- Expected Expression_Kinds: -- A_Function_Call -- --|D2005 start -- What is the right place for this query? Should it be here, should it be -- in Asis.Statements (with the reference to it in Asis.Expressions or vise -- versa, or do we need two separate queries - one for procedure calls, and -- another for function calls -- --|D2005 end -- --|A2005 end ------------------------------------------------------------------------------ -- 13.11 function Declaration_Origin ------------------------------------------------------------------------------ function Declaration_Origin (Declaration : Asis.Declaration) return Asis.Declaration_Origins; ------------------------------------------------------------------------------ -- Declaration - Specifies the Declaration to query -- -- Returns the Declaration_Origins value of the Declaration. -- -- Returns Not_A_Declaration_Origin for any unexpected element such as a -- Nil_Element, A_Definition, or A_Clause. -- -- Expected Element_Kinds: -- A_Declaration -- ------------------------------------------------------------------------------ -- 13.12 function Mode_Kind ------------------------------------------------------------------------------ function Mode_Kind (Declaration : Asis.Declaration) return Asis.Mode_Kinds; ------------------------------------------------------------------------------ -- Declaration - Specifies the element to query -- -- Returns the Mode_Kinds value of the Declaration. -- -- Returns A_Default_In_Mode for an access parameter. -- -- Returns Not_A_Mode for any unexpected element such as a -- Nil_Element, A_Definition, or A_Statement. -- -- Expected Declaration_Kinds: -- A_Parameter_Specification -- A_Formal_Object_Declaration -- ------------------------------------------------------------------------------ -- 13.13 function Default_Kind ------------------------------------------------------------------------------ function Default_Kind (Declaration : Asis.Generic_Formal_Parameter) return Asis.Subprogram_Default_Kinds; ------------------------------------------------------------------------------ -- Declaration - Specifies the element to query -- -- Returns the Subprogram_Default_Kinds value of the Declaration. -- -- Returns Not_A_Declaration for any unexpected element such as a -- Nil_Element, A_Definition, or A_Statement. -- -- Expected Declaration_Kinds: -- A_Formal_Function_Declaration -- A_Formal_Procedure_Declaration -- ------------------------------------------------------------------------------ -- 13.14 function Definition_Kind ------------------------------------------------------------------------------ function Definition_Kind (Definition : Asis.Definition) return Asis.Definition_Kinds; ------------------------------------------------------------------------------ -- Definition - Specifies the Definition to query -- -- Returns the Definition_Kinds value of the Definition. -- -- Returns Not_A_Definition for any unexpected element such as a -- Nil_Element, A_Statement, or A_Declaration. -- -- Expected Element_Kinds: -- A_Definition -- ------------------------------------------------------------------------------ -- 13.15 function Type_Kind ------------------------------------------------------------------------------ function Type_Kind (Definition : Asis.Type_Definition) return Asis.Type_Kinds; ------------------------------------------------------------------------------ -- Definition - Specifies the Type_Definition to query -- -- Returns the Type_Kinds value of the Definition. -- -- Returns Not_A_Type_Definition for any unexpected element such as a -- Nil_Element, A_Statement, or A_Declaration. -- -- Expected Definition_Kinds: -- A_Type_Definition -- ------------------------------------------------------------------------------ -- --|A2005 start (implemented) -- 13.#??? function Access_Definition_Kind ------------------------------------------------------------------------------ function Access_Definition_Kind (Definition : Asis.Definition) return Asis.Access_Definition_Kinds; ------------------------------------------------------------------------------ -- Definition - Specifies the Definition to query -- -- Returns the Access_Definition_Kinds value of the Definition. -- -- Returns Not_An_Access_Definition for any unexpected element such as a -- Nil_Element, A_Statement, or A_Declaration. -- -- Expected Definition_Kinds: -- An_Access_Definition -- -- --|A2005 end ------------------------------------------------------------------------------ -- 13.16 function Formal_Type_Kind ------------------------------------------------------------------------------ function Formal_Type_Kind (Definition : Asis.Formal_Type_Definition) return Asis.Formal_Type_Kinds; ------------------------------------------------------------------------------ -- Definition - Specifies the Formal_Type_Definition to query -- -- Returns the Formal_Type_Kinds value of the Definition. -- -- Returns Not_A_Formal_Type_Definition for any unexpected element such as a -- Nil_Element, A_Statement, or A_Declaration. -- -- Expected Definition_Kinds: -- A_Formal_Type_Definition -- ------------------------------------------------------------------------------ -- 13.17 function Access_Type_Kind ------------------------------------------------------------------------------ function Access_Type_Kind (Definition : Asis.Access_Type_Definition) return Asis.Access_Type_Kinds; ------------------------------------------------------------------------------ -- Definition - Specifies the Access_Type_Definition to query -- -- Returns the Access_Type_Kinds value of the Definition. -- -- Returns Not_An_Access_Type_Definition for any unexpected element such as a -- Nil_Element, A_Statement, or A_Declaration. -- -- Expected Type_Kinds: -- An_Access_Type_Definition -- ------------------------------------------------------------------------------ -- --|A2005 start (implemented) -- 13.#??? function Interface_Kind ------------------------------------------------------------------------------ function Interface_Kind (Definition : Asis.Definition) return Asis.Interface_Kinds; ------------------------------------------------------------------------------ -- Definition - Specifies the Definition to query -- -- Returns the Interface_Kinds value of the Definition. -- -- Returns Not_An_Interface for any unexpected element such as a -- Nil_Element, A_Statement, or A_Declaration. -- -- Expected Definition_Kinds: -- A_Type_Definition -- A_Formal_Type_Definition -- -- Expected Type_Kinds: -- An_Interface_Type_Definition -- -- Expected Formal_Type_Kinds: -- A_Formal_Interface_Type_Definition -- -- --|A2005 end ------------------------------------------------------------------------------ -- 13.18 function Root_Type_Kind ------------------------------------------------------------------------------ function Root_Type_Kind (Definition : Asis.Root_Type_Definition) return Asis.Root_Type_Kinds; ------------------------------------------------------------------------------ -- Definition - Specifies the Root_Type_Definition to query -- -- Returns the Root_Type_Kinds value of the Definition. -- -- Returns Not_A_Root_Type_Definition for any unexpected element such as a -- Nil_Element, A_Statement, or A_Declaration. -- -- Expected Type_Kinds: -- A_Root_Type_Definition -- ------------------------------------------------------------------------------ -- 13.19 function Constraint_Kind ------------------------------------------------------------------------------ function Constraint_Kind (Definition : Asis.Constraint) return Asis.Constraint_Kinds; ------------------------------------------------------------------------------ -- Definition - Specifies the constraint to query -- -- Returns the Constraint_Kinds value of the Definition. -- -- Returns Not_A_Constraint for any unexpected element such as a -- Nil_Element, A_Statement, or A_Declaration. -- -- Expected Definition_Kinds: -- A_Constraint -- ------------------------------------------------------------------------------ -- 13.20 function Discrete_Range_Kind ------------------------------------------------------------------------------ function Discrete_Range_Kind (Definition : Asis.Discrete_Range) return Asis.Discrete_Range_Kinds; ------------------------------------------------------------------------------ -- Definition - Specifies the discrete_range to query -- -- Returns the Discrete_Range_Kinds value of the Definition. -- -- Returns Not_A_Discrete_Range for any unexpected element such as a -- Nil_Element, A_Statement, or A_Declaration. -- -- Expected Definition_Kinds: -- A_Discrete_Subtype_Definition -- A_Discrete_Range -- ------------------------------------------------------------------------------ -- 13.21 function Expression_Kind ------------------------------------------------------------------------------ function Expression_Kind (Expression : Asis.Expression) return Asis.Expression_Kinds; ------------------------------------------------------------------------------ -- Expression - Specifies the Expression to query -- -- Returns the Expression_Kinds value of the Expression. -- -- Returns Not_An_Expression for any unexpected element such as a -- Nil_Element, A_Statement, or A_Declaration. -- -- Expected Element_Kinds: -- An_Expression -- ------------------------------------------------------------------------------ -- 13.22 function Operator_Kind ------------------------------------------------------------------------------ function Operator_Kind (Element : Asis.Element) return Asis.Operator_Kinds; ------------------------------------------------------------------------------ -- Element - Specifies the Element to query -- -- Returns the Operator_Kinds value of the A_Defining_Name or An_Expression -- element. -- -- Returns Not_An_Operator for any unexpected element such as a -- Nil_Element, A_Statement, or A_Declaration. -- -- Expected Defining_Name_Kinds: -- A_Defining_Operator_Symbol -- -- Expected Expression_Kinds: -- An_Operator_Symbol -- ------------------------------------------------------------------------------ -- 13.23 function Attribute_Kind ------------------------------------------------------------------------------ function Attribute_Kind (Expression : Asis.Expression) return Asis.Attribute_Kinds; ------------------------------------------------------------------------------ -- Expression - Specifies the Expression to query -- -- Returns the Attribute_Kinds value of the Expression. -- -- Returns Not_An_Attribute for any unexpected element such as a -- Nil_Element, A_Statement, or A_Declaration. -- -- Expected Expression_Kinds: -- An_Attribute_Reference -- ------------------------------------------------------------------------------ -- 13.24 function Association_Kind ------------------------------------------------------------------------------ function Association_Kind (Association : Asis.Association) return Asis.Association_Kinds; ------------------------------------------------------------------------------ -- Association - Specifies the Association to query -- -- Returns the Association_Kinds value of the Association. -- -- Returns Not_An_Association for any unexpected element such as a -- Nil_Element, A_Statement, or A_Declaration. -- -- Expected Element_Kinds: -- An_Association -- ------------------------------------------------------------------------------ -- 13.25 function Statement_Kind ------------------------------------------------------------------------------ function Statement_Kind (Statement : Asis.Statement) return Asis.Statement_Kinds; ------------------------------------------------------------------------------ -- Statement - Specifies the element to query -- -- Returns the Statement_Kinds value of the statement. -- -- Returns Not_A_Statement for any unexpected element such as a -- Nil_Element, A_Definition, or A_Declaration. -- -- Expected Element_Kinds: -- A_Statement -- ------------------------------------------------------------------------------ -- 13.26 function Path_Kind ------------------------------------------------------------------------------ function Path_Kind (Path : Asis.Path) return Asis.Path_Kinds; ------------------------------------------------------------------------------ -- Path - Specifies the Path to query -- -- Returns the Path_Kinds value of the Path. -- -- Returns Not_A_Path for any unexpected element such as a -- Nil_Element, A_Statement, or A_Declaration. -- -- Expected Element_Kinds: -- A_Path -- ------------------------------------------------------------------------------ -- 13.27 function Clause_Kind ------------------------------------------------------------------------------ function Clause_Kind (Clause : Asis.Clause) return Asis.Clause_Kinds; ------------------------------------------------------------------------------ -- Clause - Specifies the element to query -- -- Returns the Clause_Kinds value of the Clause. -- -- Returns Not_A_Clause for any unexpected element such as a -- Nil_Element, A_Definition, or A_Declaration. -- -- Expected Element_Kinds: -- A_Clause -- ------------------------------------------------------------------------------ -- 13.28 function Representation_Clause_Kind ------------------------------------------------------------------------------ function Representation_Clause_Kind (Clause : Asis.Representation_Clause) return Asis.Representation_Clause_Kinds; ------------------------------------------------------------------------------ -- Clause - Specifies the element to query -- -- Returns the Representation_Clause_Kinds value of the Clause. -- -- Returns Not_A_Representation_Clause for any unexpected element such as a -- Nil_Element, A_Definition, or A_Declaration. -- -- Expected Clause_Kinds: -- A_Representation_Clause -- ------------------------------------------------------------------------------ -- 13.29 function Is_Nil ------------------------------------------------------------------------------ function Is_Nil (Right : Asis.Element) return Boolean; ------------------------------------------------------------------------------ -- Right - Specifies the element to check -- -- Returns True if the program element is the Nil_Element. -- ------------------------------------------------------------------------------ -- 13.30 function Is_Nil ------------------------------------------------------------------------------ function Is_Nil (Right : Asis.Element_List) return Boolean; ------------------------------------------------------------------------------ -- Right - Specifies the element list to check -- -- Returns True if the element list has a length of zero. -- ------------------------------------------------------------------------------ -- 13.31 function Is_Equal ------------------------------------------------------------------------------ function Is_Equal (Left : Asis.Element; Right : Asis.Element) return Boolean; ------------------------------------------------------------------------------ -- Left - Specifies the left element to compare -- Right - Specifies the right element to compare -- -- Returns True if Left and Right represent the same physical element, -- from the same physical compilation unit. The two elements may or -- may not be from the same open ASIS Context variable. -- -- Implies: Is_Equal (Enclosing_Compilation_Unit (Left), -- Enclosing_Compilation_Unit (Right)) = True -- ------------------------------------------------------------------------------ -- 13.32 function Is_Identical ------------------------------------------------------------------------------ function Is_Identical (Left : Asis.Element; Right : Asis.Element) return Boolean; ------------------------------------------------------------------------------ -- Left - Specifies the left element -- Right - Specifies the right element -- -- Returns True if Left and Right represent the same physical element, -- from the same physical compilation unit, from the same open ASIS -- Context variable. -- -- Implies: Is_Identical (Enclosing_Compilation_Unit (Left), -- Enclosing_Compilation_Unit (Right)) = True -- ------------------------------------------------------------------------------ -- 13.33 function Is_Part_Of_Implicit ------------------------------------------------------------------------------ function Is_Part_Of_Implicit (Element : Asis.Element) return Boolean; ------------------------------------------------------------------------------ -- Element - Specifies the element to query -- -- Returns True for any Element that is, or that forms part of, any -- implicitly declared or specified program Element structure. -- -- Returns False for a Nil_Element, or any Element that correspond to text -- which was specified explicitly (typed, entered, written). -- -- Generic instance specifications and bodies, while implicit, are treated -- as a special case. These elements will not normally test as -- Is_Part_Of_Implicit. Rather, they are Is_Part_Of_Instance. They only test -- as Is_Part_Of_Implicit if one of the following rules applies. This is -- done so that it is possible to determine whether a declaration, which -- happens to occur within an instance, is an implicit result of -- another declaration which occurs explicitly within the generic template. -- -- Implicit Elements are those that represent these portions of the Ada -- language: -- -- Reference Manual 4.5.(9) - All predefined operator declarations and -- their component elements are -- Is_Part_Of_Implicit -- Reference Manual 3.4(16) - Implicit predefined operators of the derived -- type. -- Reference Manual 3.4(17-22) - Implicit inherited subprogram declarations -- and their component elements are -- Is_Part_Of_Implicit -- -- Reference Manual 6.4(9) - Implicit actual parameter expressions -- (defaults). -- and 12.3(7) - The A_Parameter_Association that includes a -- defaulted parameter value Is_Normalized and -- also Is_Part_Of_Implicit. The -- Formal_Parameter and the Actual_Parameter -- values from such Associations are not -- Is_Part_Of_Implicit unless they are from -- default initializations for an inherited -- subprogram declaration and have an -- Enclosing_Element that is the parameter -- specification of the subprogram declaration. -- (Those elements are shared with (were created -- by) the original subprogram declaration, or -- they are naming expressions representing the -- actual generic subprogram selected at the -- place of an instantiation for A_Box_Default.) -- - All A_Parameter_Association Kinds from a -- Normalized list are Is_Part_Of_Implicit. -- -- Reference Manual 6.6 (6) - Inequality operator declarations for limited -- private types are Is_Part_Of_Implicit. -- - Depending on the ASIS implementation, a "/=" -- appearing in the compilation may result in a -- "NOT" and an "=" in the internal -- representation. These two elements test as -- Is_Part_Of_Implicit because they do not -- represent text from the original compilation -- text. -- Reference Manual 12.3 (16) - implicit generic instance specifications and -- bodies are not Is_Part_Of_Implicit; they are -- Is_Part_Of_Instance and are only implicit if -- some other rule makes them so -- ------------------------------------------------------------------------------ -- 13.34 function Is_Part_Of_Inherited ------------------------------------------------------------------------------ function Is_Part_Of_Inherited (Element : Asis.Element) return Boolean; ------------------------------------------------------------------------------ -- Element - Specifies the element to query -- -- Returns True for any Element that is, or that forms part of, an -- inherited primitive subprogram declaration. -- -- Returns False for any other Element including a Nil_Element. -- ------------------------------------------------------------------------------ -- 13.35 function Is_Part_Of_Instance ------------------------------------------------------------------------------ function Is_Part_Of_Instance (Element : Asis.Element) return Boolean; ------------------------------------------------------------------------------ -- Element - Specifies the element to test -- -- Returns True if the Element is part of an implicit generic specification -- instance or an implicit generic body instance. -- -- Returns False for explicit, inherited, and predefined Elements that are -- not the result of a generic expansion. -- -- Returns False for a Nil_Element. -- -- Instantiations are not themselves Is_Part_Of_Instance unless they are -- encountered while traversing a generic instance. -- ------------------------------------------------------------------------------ -- 13.36 function Enclosing_Element ------------------------------------------------------------------------------ function Enclosing_Element (Element : Asis.Element) return Asis.Element; function Enclosing_Element (Element : Asis.Element; Expected_Enclosing_Element : Asis.Element) return Asis.Element; ------------------------------------------------------------------------------ -- Element - Specifies the element to query -- Expected_Enclosing_Element - Specifies an enclosing element expected to -- contain the element -- -- Returns the Element that immediately encloses the given element. This -- query is intended to exactly reverse any single parent-to-child element -- traversal. For any structural query that returns a subcomponent of an -- element (or that returns a list of subcomponent elements), the original -- element can be determined by passing the subcomponent element to this -- query. -- Note: Semantic queries (queries that test the meaning of a program rather -- than its structure) return Elements that usually do not have the original -- argument Element as their parent. -- -- Returns a Nil_Element if: -- -- - the element is the declaration part of a compilation unit -- (Unit_Declaration). -- -- - the element is with clause or use clause of a context clause -- (Context_Clause_Elements). -- -- - the element is a pragma for a compilation unit -- (Compilation_Pragmas and Context_Clause_Elements). -- -- Use Enclosing_Compilation_Unit to get the enclosing compilation unit for -- any element value other than Nil_Element. -- -- Raises ASIS_Inappropriate_Element if the Element is a Nil_Element. -- -- Examples: -- -- Given a A_Declaration/A_Full_Type_Declaration in the declarative region -- of a block statement, returns the A_Statement/A_Block_Statement Element -- that encloses the type declaration. -- -- Given A_Statement, from the sequence of statements within a loop -- statement, returns the enclosing A_Statement/A_Loop_Statement. -- -- Given the An_Expression/An_Identifier selector from an expanded name, -- returns the An_Expression/A_Selected_Component that represents the -- combination of the prefix, the dot, and the selector. -- -- --|AN Application Note: -- --|AN -- --|AN The optional Expected_Enclosing_Element parameter is used only to -- --|AN optimize. This speed up is only present for ASIS implementations -- --|AN where the underlying implementor's environment does not have "parent -- --|AN pointers". For these implementations, this query is implemented as a -- --|AN "search". The Enclosing_Compilation_Unit is searched for the argument -- --|AN Element. The Expected_Enclosing_Element parameter provides a means of -- --|AN shortening the search. -- --|AN Note: If the argument Element is not a sub-element of the -- --|AN Expected_Enclosing_Element parameter, or if the -- --|AN Expected_Enclosing_Element is a Nil_Element, the result of the -- --|AN call is a Nil_Element. -- --|AN -- --|AN Implementations that do not require the Expected_Enclosing_Element -- --|AN parameter may ignore it. They are encouraged, but not required, to -- --|AN test the Expected_Enclosing_Element parameter and to determine if it -- --|AN is an invalid Element value (its associated Environment Context may -- --|AN be closed) -- --|AN -- --|AN Portable applications should not use the Expected_Enclosing_Element -- --|AN parameter since it can lead to unexpected differences when porting an -- --|AN application between ASIS implementations where one implementation -- --|AN uses the parameter and the other implementation does not. Passing a -- --|AN "wrong" Expected_Enclosing_Element to an implementation that ignores -- --|AN it, is harmless. Passing a "wrong" Expected_Enclosing_Element to an -- --|AN implementation that may utilize it, can lead to an unexpected -- --|AN Nil_Element result. -- -- ------------------------------------------------------------------------------ -- 13.37 function Pragmas ------------------------------------------------------------------------------ function Pragmas (The_Element : Asis.Element) return Asis.Pragma_Element_List; ------------------------------------------------------------------------------ -- The_Element - Specifies the element to query -- -- Returns the list of pragmas, in their order of appearance, that appear -- directly within the given The_Element. Returns only those pragmas that are -- immediate component elements of the given The_Element. Pragmas embedded -- within other component elements are not returned. For example, returns -- the pragmas in a package specification, in the statement list of a loop, -- or in a record component list. -- -- This query returns exactly those pragmas that are returned by the -- various queries, that accept these same argument kinds, and that -- return Declaration_List and Statement_List, where the inclusion of -- Pragmas is controlled by an Include_Pragmas parameter. -- -- Returns a Nil_Element_List if there are no pragmas. -- -- Appropriate Element_Kinds: -- A_Path (pragmas from the statement list + -- pragmas immediately preceding the -- reserved word "when" of the first -- alternative) -- An_Exception_Handler (pragmas from the statement list + -- pragmas immediately preceding the -- reserved word "when" of the first -- exception handler) -- -- Appropriate Declaration_Kinds: -- A_Procedure_Body_Declaration (pragmas from declarative region + -- statements) -- A_Function_Body_Declaration (pragmas from declarative region + -- statements) -- A_Package_Declaration (pragmas from visible + private -- declarative regions) -- A_Package_Body_Declaration (pragmas from declarative region + -- statements) -- A_Task_Body_Declaration (pragmas from declarative region + -- statements) -- A_Protected_Body_Declaration (pragmas from declarative region) -- An_Entry_Body_Declaration (pragmas from declarative region + -- statements) -- A_Generic_Procedure_Declaration (pragmas from formal declarative -- region) -- A_Generic_Function_Declaration (pragmas from formal declarative -- region) -- A_Generic_Package_Declaration (pragmas from formal + visible + -- private declarative regions) -- -- Appropriate Definition_Kinds: -- A_Record_Definition (pragmas from the component list) -- A_Variant_Part (pragmas immediately preceding the -- first reserved word "when" + between -- variants) -- A_Variant (pragmas from the component list) -- A_Task_Definition (pragmas from visible + private -- declarative regions) -- A_Protected_Definition (pragmas from visible + private -- declarative regions) -- -- Appropriate Statement_Kinds: -- A_Loop_Statement (pragmas from statement list) -- A_While_Loop_Statement (pragmas from statement list) -- A_For_Loop_Statement (pragmas from statement list) -- A_Block_Statement (pragmas from declarative region + -- statements) -- An_Accept_Statement (pragmas from statement list + -- -- Appropriate Representation_Clause_Kinds: -- A_Record_Representation_Clause (pragmas from component -- specifications) -- -- Returns Element_Kinds: -- A_Pragma -- ------------------------------------------------------------------------------ -- 13.38 function Corresponding_Pragmas ------------------------------------------------------------------------------ function Corresponding_Pragmas (Element : Asis.Element) return Asis.Pragma_Element_List; ------------------------------------------------------------------------------ -- Element - Specifies the element to query -- -- Returns the list of pragmas semantically associated with the given element, -- in their order of appearance, or, in any order that does not affect their -- relative interpretations. These are pragmas that directly affect the -- given element. For example, a pragma Pack affects the type it names. -- -- Returns a Nil_Element_List if there are no semantically associated pragmas. -- -- --|D2005 start -- See the discussion for -- Asis.Declarations.Corresponding_Representation_Clauses (15.17), we have -- exactly the same problem for this query. -- --|D2005 end -- -- --|AN Application Note: -- --|AN -- --|AN If the argument is a inherited entry declaration from a derived task -- --|AN type, all pragmas returned are elements taken from the original task -- --|AN type's declarative item list. Their Enclosing_Element is the original -- --|AN type definition and not the derived type definition. -- --|AN -- Appropriate Element_Kinds: -- A_Declaration -- A_Statement -- --|D2005 start -- How A_Statement can be an appropriate kind for this query??? -- --|D2005 end -- -- Returns Element_Kinds: -- A_Pragma -- ------------------------------------------------------------------------------ -- 13.39 function Pragma_Name_Image ------------------------------------------------------------------------------ function Pragma_Name_Image (Pragma_Element : Asis.Pragma_Element) return Program_Text; ------------------------------------------------------------------------------ -- Pragma_Element - Specifies the element to query -- -- Returns the program text image of the simple name of the pragma. -- -- The case of names returned by this query may vary between implementors. -- Implementors are encouraged, but not required, to return names in the -- same case as was used in the original compilation text. -- -- Appropriate Element_Kinds: -- A_Pragma -- ------------------------------------------------------------------------------ -- 13.40 function Pragma_Argument_Associations ------------------------------------------------------------------------------ function Pragma_Argument_Associations (Pragma_Element : Asis.Pragma_Element) return Asis.Association_List; ------------------------------------------------------------------------------ -- Pragma_Element - Specifies the element to query -- -- Returns a list of the Pragma_Argument_Associations of the pragma, in their -- order of appearance. -- -- Appropriate Element_Kinds: -- A_Pragma -- -- Returns Element_Kinds: -- A_Pragma_Argument_Association -- ------------------------------------------------------------------------------ -- 13.41 function Debug_Image ------------------------------------------------------------------------------ function Debug_Image (Element : Asis.Element) return Wide_String; ------------------------------------------------------------------------------ -- Element - Specifies the program element to convert -- -- Returns a string value containing implementation-defined debug -- information associated with the element. -- -- The return value uses Asis.Text.Delimiter_Image to separate the lines -- of multi-line results. The return value does not end with -- Asis.Text.Delimiter_Image. -- -- These values are intended for two purposes. They are suitable for -- inclusion in problem reports sent to the ASIS implementor. They can -- be presumed to contain information useful when debugging the implementation -- itself. They are also suitable for use by the ASIS application when -- printing simple application debugging messages during application -- development. They are intended to be, to some worthwhile degree, -- intelligible to the user. -- ------------------------------------------------------------------------------ -- 13.42 function Hash ------------------------------------------------------------------------------ function Hash (Element : Asis.Element) return Asis.ASIS_Integer; -- The purpose of the hash function is to provide a convenient name for an -- object of type Asis.Element in order to facilitate application defined I/O -- and/or other application defined processing. -- -- The hash function maps Asis.Element objects into N discrete classes -- ("buckets") of objects. A good hash function is uniform across its range. -- It is important to note that the distribution of objects in the -- application's domain will affect the distribution of the hash function. -- A good hash measured against one domain will not necessarily be good when -- fed objects from a different set. -- -- A continuous uniform hash can be divided by any N and provide a uniform -- distribution of objects to each of the N discrete classes. A hash value is -- not unique for each hashed Asis.Element. The application is responsible for -- handling name collisions of the hashed value. -- -- The hash function returns a hashed value of type ASIS_Integer. If desired, -- a user could easily map ASIS_Integer'Range to any smaller range for the -- hash based on application constraints (i.e., the application implementor -- can tune the time-space tradeoffs by choosing a small table, implying -- slower lookups within each "bucket", or a large table, implying faster -- lookups within each "bucket"). ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Processing of the Ada extensions that most likely will be included in -- -- Ada 2012 and that are already implemented in GNAT -- ------------------------------------------------------------------------------ end Asis.Elements;
30,639
ada
36
rewriting/tom
src/tom/library/sl/ada/sequencestrategy.adb
with VisitFailurePackage, VisitablePackage, EnvironmentPackage; use VisitFailurePackage, VisitablePackage, EnvironmentPackage; package body SequenceStrategy is ---------------------------------------------------------------------------- -- Object implementation ---------------------------------------------------------------------------- overriding function toString(o: Sequence) return String is begin return "Sequence()"; end; ---------------------------------------------------------------------------- -- Strategy implementation ---------------------------------------------------------------------------- overriding function visitLight(str:access Sequence; any: ObjectPtr; i: access Introspector'Class) return ObjectPtr is op : ObjectPtr := visitLight( StrategyPtr(str.arguments(FIRST)), any, i); begin return visitLight(StrategyPtr(str.arguments(SECOND)), op, i); end; overriding function visit(str: access Sequence; i: access Introspector'Class) return Integer is status : Integer := visit(StrategyPtr(str.arguments(FIRST)), i); begin if status = EnvironmentPackage.SUCCESS then return visit(StrategyPtr(str.arguments(SECOND)), i); else return status; end if; end; ---------------------------------------------------------------------------- procedure makeSequence(s : in out Sequence; str1, str2 : StrategyPtr) is begin initSubterm(s, str1, str2); end; function make(str1, str2: StrategyPtr) return StrategyPtr is ns : StrategyPtr := null; begin if str2 = null then return str1; else ns := new Sequence; makeSequence(Sequence(ns.all), str1, str2); return ns; end if; end; function newSequence(str1, str2: StrategyPtr) return StrategyPtr is begin return SequenceStrategy.make(str1,str2); end; ---------------------------------------------------------------------------- end SequenceStrategy;
30,640
ada
6
afrl-rq/LmcpGen
src/templates/ada/avtas/lmcp/avtas-lmcp-factory.ads
with AVTAS.LMCP.Types; use AVTAS.LMCP.Types; with AVTAS.LMCP.ByteBuffers; use AVTAS.LMCP.ByteBuffers; with AVTAS.LMCP.Object; use AVTAS.LMCP.Object; package AVTAS.LMCP.Factory is HEADER_SIZE : constant UInt32 := 8; CHECKSUM_SIZE : constant UInt32 := 4; SERIESNAME_SIZE : constant UInt32 := 8; LMCP_CONTROL_STR : constant Int32 := 16#4c4d4350#; function packMessage(rootObject : in avtas.lmcp.object.Object_Any; enableChecksum : in Boolean) return ByteBuffer; procedure putObject(object : in avtas.lmcp.object.Object_Any; buffer : in out ByteBuffer); procedure getObject(buffer : in out ByteBuffer; output : out avtas.lmcp.object.Object_Any); function createObject(seriesId : in Int64; msgType : in UInt32; version: in UInt16) return avtas.lmcp.object.Object_Any; function CalculateChecksum (Buffer : in ByteBuffer; Last : in Index) return UInt32; -- Computes the modular checksum for the Buffer contents from 1 .. Last. Assumes -- Big Endian byte order. function getObjectSize(buffer : in ByteBuffer) return UInt32; function Validate (Buffer : in ByteBuffer) return Boolean; -- Validates a buffer by comparing a newly computed checksum with the -- previously computed checksum value stored with the message -- in the buffer. Assumes the buffer is in Big Endian byte order. end AVTAS.LMCP.Factory;
30,641
ada
0
sebsgit/textproc
src/tests/nnclassifiertests.adb
with AUnit.Assertions; use AUnit.Assertions; with Ada.Containers.Vectors; with Ada.Text_IO; with NNClassifier; with NeuralNet; with DataBatch; with MathUtils; use MathUtils.Float_Vec; use Ada.Containers; package body NNClassifierTests is procedure Register_Tests (T: in out TestCase) is use AUnit.Test_Cases.Registration; begin Register_Routine (T, testLogisticRegression'Access, "logistic regression"); end Register_Tests; function Name(T: TestCase) return Test_String is begin return Format("NN Classifier Tests"); end Name; procedure testLogisticRegression(T : in out Test_Cases.Test_Case'Class) is config: NeuralNet.Config(1); dnn: NNClassifier.DNN(config.size + 1); batch: DataBatch.Batch; labels: NNClassifier.LabelVector; trainSetSize: constant Positive := 1000; input: MathUtils.Vector; prediction: MathUtils.Vector; begin config.inputSize := 4; config.act := NeuralNet.LOGISTIC; config.lr := 0.9; config.sizes := (1 => 16); dnn := NNClassifier.create(config => config, numberOfClasses => 2); for i in 1 .. trainSetSize loop batch.append((MathUtils.rand01 + 0.5) & 0.0 & 0.0 & (MathUtils.rand01 + 0.5)); labels.Append(0); batch.append((MathUtils.rand01 + 0.5) & (MathUtils.rand01 + 0.5) & 0.0 & 0.0); labels.Append(1); end loop; dnn.train(batch, labels); input := 0.5 & 0.0 & 0.0 & 0.5; prediction := dnn.classify(input); Assert(prediction(1) > prediction(2), ""); input := 0.5 & 0.5 & 0.0 & 0.0; prediction := dnn.classify(input); Assert(prediction(2) > prediction(1), ""); end testLogisticRegression; end NNClassifierTests;
30,642
ada
1
fabiojna02/OpenCellular
firmware/coreboot/3rdparty/libgfxinit/common/hw-gfx-dp_aux_ch.ads
-- -- Copyright (C) 2015-2016 secunet Security Networks AG -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- with HW.GFX.I2C; with HW.GFX.DP_Defs; private generic type T (<>) is limited private; with procedure Aux_Request (Port : in T; Request : in DP_Defs.Aux_Request; Request_Length : in DP_Defs.Aux_Request_Length; Response : out DP_Defs.Aux_Response; Response_Length : out DP_Defs.Aux_Response_Length; Success : out Boolean); package HW.GFX.DP_Aux_Ch is procedure Aux_Read (Port : in T; Address : in DP_Defs.Aux_Message_Address; Length : in out DP_Defs.Aux_Payload_Length; Data : out DP_Defs.Aux_Payload; Success : out Boolean); procedure Aux_Write (Port : in T; Address : in DP_Defs.Aux_Message_Address; Length : in DP_Defs.Aux_Payload_Length; Data : in DP_Defs.Aux_Payload; Success : out Boolean); ---------------------------------------------------------------------------- procedure I2C_Read (Port : in T; Address : in I2C.Transfer_Address; Length : in out I2C.Transfer_Length; Data : out I2C.Transfer_Data; Success : out Boolean); end HW.GFX.DP_Aux_Ch;
30,643
ada
0
GLADORG/glad-cli
src/commands.adb
<reponame>GLADORG/glad-cli with Commands.Generate; with Commands.Create; with Commands.Init; with Commands.Destroy; with CLIC.TTY; with CLIC.User_Input; with Commands.Topics.Issues; with Commands.Topics.Contribute; with GNAT.OS_Lib; package body Commands is ------------------------- -- Set_Global_Switches -- ------------------------- procedure Set_Global_Switches (Config : in out CLIC.Subcommand.Switches_Configuration) is use CLIC.Subcommand; Help_Switch : aliased Boolean := False; -- Catches the -h/--help help switch begin Define_Switch (Config, Help_Switch'Access, "-h", "--help", "Display general or command-specific help"); end Set_Global_Switches; ------------- -- Execute -- ------------- procedure Execute is begin Sub_Cmd.Parse_Global_Switches; CLIC.TTY.Enable_Color (Force => False); begin Sub_Cmd.Execute; exception when Child_Failed | Command_Failed | Wrong_Command_Arguments => GNAT.OS_Lib.OS_Exit (1); when CLIC.User_Input.User_Interrupt => GNAT.OS_Lib.OS_Exit (1); end; end Execute; begin -- Commands -- Sub_Cmd.Register ("generate", new Generate.Command); --Sub_Cmd.Register ("g", new Generate.Command); Sub_Cmd.Register ("new", new Create.Command); Sub_Cmd.Register ("init", new Init.Command); Sub_Cmd.Register ("destroy", new Destroy.Command); -- Help topics -- Sub_Cmd.Register (new Topics.Issues.Topic); Sub_Cmd.Register (new Topics.Contribute.Topic); end Commands;
30,644
ada
1
BrentSeidel/BBS-Ada
bbs.ads
-- -- Author: <NAME> -- Version: V01.01 -- Date: 27-Apr-2021 -- -- This package defines a number of types for physical units. These are -- generally based off of the Float type since in most cases, 6 digits is -- pretty good for a physical measurement. If you need more precision, go -- ahead and change it to whatever you need. -- -- Conversion routines are provided to convert between different units. Due to -- the number of different units, conversion between two may not be directly -- possible, but should be possible through intermediate units. The ones present -- are the ones that I use most. More will probably be added in the future. For -- each type of measurement, there is a base unit. Conversions to and from this -- unit to other units are provided. -- -- While addition and subtraction of units generally provides a meaningful result, -- multiplication and division may not. For example meters*meters should provide -- a result in meters^2. In some cases (ones that I use) multiplication and -- division will be provided. Most of these routines are trivial and can be -- added as needed. -- -- Ada provides Ada.Calendar to cover time related items. Therefor, there is -- not much time support here. -- -- The naming convention of the units is a prefix indicating what kind of unit, -- an underscore, and the the S.I. code for the unit (if applicable) or a common -- abbreviation (eg. vel_mph for velocity in mile per hour). Since "/" is not -- valid in indentifiers, it will be replaced by an underscore (eg vel_m_s) for -- velocity in meters per second. Exponentiation is indicated by a number (eg -- accel_m_s2). -- -- License: -- This is free and unencumbered software released into the public domain. -- -- Anyone is free to copy, modify, publish, use, compile, sell, or -- distribute this software, either in source code form or as a compiled -- binary, for any purpose, commercial or non-commercial, and by any -- means. -- -- In jurisdictions that recognize copyright laws, the author or authors -- of this software dedicate any and all copyright interest in the -- software to the public domain. We make this dedication for the benefit -- of the public at large and to the detriment of our heirs and -- successors. We intend this dedication to be an overt act of -- relinquishment in perpetuity of all present and future rights to this -- software under copyright law. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR -- OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -- OTHER DEALINGS IN THE SOFTWARE. -- -- For more information, please refer to <http://unlicense.org> -- package BBS with SPARK_Mode => on is pragma Pure; pragma No_Elaboration_Code_All; -- -- Empty package just so that everything that I make is in the BBS namespace. -- -- This is really trivial so I don't care if anyone copies this. If you do -- though, you should at least change it to your name and initials. -- end BBS;
30,645
ada
36
rewriting/tom
src/tom/library/sl/ada/visitablebuiltinpackage.ads
<filename>src/tom/library/sl/ada/visitablebuiltinpackage.ads with VisitablePackage, ObjectPack; use VisitablePackage, ObjectPack; package VisitableBuiltinPackage is type VisitableBuiltin is new Visitable and Object with record builtin : ObjectPtr := null; end record; function toString(vb: VisitableBuiltin) return String; function setChildren(v: access VisitableBuiltin ; children : ObjectPtrArrayPtr) return VisitablePtr; function getChildren(v: access VisitableBuiltin) return ObjectPtrArrayPtr; function getChildAt(v: access VisitableBuiltin; i : Integer) return VisitablePtr; function setChildAt(v: access VisitableBuiltin; i: in Integer; child: in VisitablePtr) return VisitablePtr; function getChildCount(v:access VisitableBuiltin) return Integer; function makeVisitableBuiltinPackage(o: ObjectPtr) return VisitableBuiltin; function getBuiltin(v: VisitableBuiltin) return ObjectPtr; end VisitableBuiltinPackage;
30,646
ada
0
djamal2727/Main-Bearing-Analytical-Model
Validation/pyFrame3DD-master/gcc-master/gcc/ada/libgnat/s-excmac__gcc.ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . E X C E P T I O N S . M A C H I N E -- -- -- -- S p e c -- -- -- -- Copyright (C) 2013-2020, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- Declaration of the machine exception and some associated facilities. The -- machine exception is the object that is propagated by low level routines -- and that contains the Ada exception occurrence. -- This is the version using the GCC EH mechanism with Ada.Unchecked_Conversion; with Ada.Exceptions; package System.Exceptions.Machine is pragma Preelaborate; ------------------------------------------------ -- Entities to interface with the GCC runtime -- ------------------------------------------------ -- These come from "C++ ABI for Itanium: Exception handling", which is -- the reference for GCC. -- Return codes from the GCC runtime functions used to propagate -- an exception. type Unwind_Reason_Code is (URC_NO_REASON, URC_FOREIGN_EXCEPTION_CAUGHT, URC_PHASE2_ERROR, URC_PHASE1_ERROR, URC_NORMAL_STOP, URC_END_OF_STACK, URC_HANDLER_FOUND, URC_INSTALL_CONTEXT, URC_CONTINUE_UNWIND); pragma Unreferenced (URC_NO_REASON, URC_FOREIGN_EXCEPTION_CAUGHT, URC_PHASE2_ERROR, URC_PHASE1_ERROR, URC_NORMAL_STOP, URC_END_OF_STACK, URC_HANDLER_FOUND, URC_INSTALL_CONTEXT, URC_CONTINUE_UNWIND); pragma Convention (C, Unwind_Reason_Code); -- Mandatory common header for any exception object handled by the -- GCC unwinding runtime. type Exception_Class is mod 2 ** 64; GNAT_Exception_Class : constant Exception_Class := 16#474e552d41646100#; -- "GNU-Ada\0" type Unwind_Word is mod 2 ** System.Word_Size; for Unwind_Word'Size use System.Word_Size; -- Map the corresponding C type used in Unwind_Exception below type Unwind_Exception is record Class : Exception_Class; Cleanup : System.Address; Private1 : Unwind_Word; Private2 : Unwind_Word; -- Usual exception structure has only two private fields, but the SEH -- one has six. To avoid making this file more complex, we use six -- fields on all platforms, wasting a few bytes on some. Private3 : Unwind_Word; Private4 : Unwind_Word; Private5 : Unwind_Word; Private6 : Unwind_Word; end record; pragma Convention (C, Unwind_Exception); -- Map the GCC struct used for exception handling for Unwind_Exception'Alignment use Standard'Maximum_Alignment; -- The C++ ABI mandates the common exception header to be at least -- doubleword aligned, and the libGCC implementation actually makes it -- maximally aligned (see unwind.h). See additional comments on the -- alignment below. -- There is a subtle issue with the common header alignment, since the C -- version is aligned on BIGGEST_ALIGNMENT, the Ada version is aligned on -- Standard'Maximum_Alignment, and those two values don't quite represent -- the same concepts and so may be decoupled someday. One typical reason -- is that BIGGEST_ALIGNMENT may be larger than what the underlying system -- allocator guarantees, and there are extra costs involved in allocating -- objects aligned to such factors. -- To deal with the potential alignment differences between the C and Ada -- representations, the Ada part of the whole structure is only accessed -- by the personality routine through accessors. Ada specific fields are -- thus always accessed through consistent layout, and we expect the -- actual alignment to always be large enough to avoid traps from the C -- accesses to the common header. Besides, accessors alleviate the need -- for a C struct whole counterpart, both painful and error-prone to -- maintain anyway. type GCC_Exception_Access is access all Unwind_Exception; -- Pointer to a GCC exception procedure Unwind_DeleteException (Excp : not null GCC_Exception_Access); pragma Import (C, Unwind_DeleteException, "_Unwind_DeleteException"); -- Procedure to free any GCC exception -------------------------------------------------------------- -- GNAT Specific Entities To Deal With The GCC EH Circuitry -- -------------------------------------------------------------- -- A GNAT exception object to be dealt with by the personality routine -- called by the GCC unwinding runtime. type GNAT_GCC_Exception is record Header : Unwind_Exception; -- ABI Exception header first Occurrence : aliased Ada.Exceptions.Exception_Occurrence; -- The Ada occurrence end record; pragma Convention (C, GNAT_GCC_Exception); type GNAT_GCC_Exception_Access is access all GNAT_GCC_Exception; function To_GCC_Exception is new Ada.Unchecked_Conversion (System.Address, GCC_Exception_Access); function To_GNAT_GCC_Exception is new Ada.Unchecked_Conversion (GCC_Exception_Access, GNAT_GCC_Exception_Access); function New_Occurrence return GNAT_GCC_Exception_Access; -- Allocate and initialize a machine occurrence end System.Exceptions.Machine;
30,647
ada
13
annexi-strayline/AURA
configuration-step_3b.adb
<filename>configuration-step_3b.adb ------------------------------------------------------------------------------ -- -- -- Ada User Repository Annex (AURA) -- -- ANNEXI-STRAYLINE Reference Implementation -- -- -- -- Command Line Interface -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. -- -- All rights reserved. -- -- -- -- Original Contributors: -- -- * <NAME> (ANNEXI-STRAYLINE) -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- -- -- * Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -- -- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with Ada.Text_IO; with Ada.Streams; with Ada.Directories; with Ada.Strings.Bounded; with Ada.Characters.Conversions; with Ada.Strings.UTF_Encoding.Wide_Wide_Strings; with Platform_Info; with Child_Processes; with Child_Processes.Path_Searching; with Child_Processes.Wait_And_Buffer; separate (Configuration) procedure Step_3b (Target: in out Subsystem) is package ACC renames Ada.Characters.Conversions; package UTF_8 renames Ada.Strings.UTF_Encoding.Wide_Wide_Strings; package Subsystems renames Registrar.Subsystems; Config_Package_Name: constant Wide_Wide_String := Config_Unit_Name (Target).To_String; Config_Build_Root: constant String := "./.aura/cfg_tmp" & '/' & ACC.To_String (Target.Name.To_String); package Program_Paths renames Child_Processes.Path_Searching; GNAT_Make_Program: aliased constant String := "gnatmake"; GNAT_Make: constant Program_Paths.Elaboration_Path_Search := Program_Paths.Initialize (GNAT_Make_Program); -- Note that this is for the native gnatmake, not the target gnatmake. -- We are using it to compile the generated extraction program that -- retrieves the configuration values from the AURA package configuration, -- hence we don't append the Toolchain_Prefix. -- -- Obviously this is GNAT-specific, one day it might make sense to -- hand-write an internal compile-bind-link subprogram to make AURA more -- portable -- Wait_And_Buffer instantiation package Output_Buffers is new Ada.Strings.Bounded.Generic_Bounded_Length (2048); procedure Buffer_Append (Buffer: in out Output_Buffers.Bounded_String; Item : in String) is begin Output_Buffers.Append (Source => Buffer, New_Item => Item); end Buffer_Append; procedure Wait_And_Buffer is new Child_Processes.Wait_And_Buffer (Buffer_Type => Output_Buffers.Bounded_String, Append => Buffer_Append, Empty_Buffer => Output_Buffers.Null_Bounded_String); -- These are to catch errors in the compilation process, mostly package TIO renames Ada.Text_IO; Out_File: TIO.File_Type; Tab: constant String := (1 .. 4 => ' '); procedure NL (File : in TIO.File_Type := Out_File; Spacing: in TIO.Positive_Count := 1) renames TIO.New_Line; procedure Put (Item: in String; File: in TIO.File_Type := Out_File) is begin TIO.Put (File, Item); end Put; procedure Gen_Loader (Package_Name: Wide_Wide_String; Configs : Subsystems.Configuration_Vector) is -- String'Output (STDOUT, AURA.Subsystem.Package_Name.Element); Target_Prefix: constant String := UTF_8.Encode (Config_Package_Name & '.' & Package_Name); begin for Item of Configs loop Put (Tab & "String'Output (STDOUT, " & Target_Prefix & '.' & UTF_8.Encode (WWU.To_Wide_Wide_String (Item.Name)) & ");"); NL; end loop; NL; end Gen_Loader; procedure Load (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Configs: in out Subsystems.Configuration_Vector) is use Subsystems.Configuration_Vectors; begin for Item of Configs loop Item.Value := UBS.To_Unbounded_String (String'Input (Stream)); end loop; -- Now remove any items with an empty value, start from the "bottom up" -- to try to make it a little more efficient for I in reverse Configs.First_Index .. Configs.Last_Index loop if UBS.Length (Configs(I).Value) = 0 then Configs.Delete (I); end if; end loop; end Load; begin declare use Ada.Directories; begin if Exists (Config_Build_Root) then Delete_Tree (Config_Build_Root); end if; Create_Path (Config_Build_Root); end; -- Phase one: generate the extraction program TIO.Create (File => Out_File, Mode => TIO.Out_File, Name => Config_Build_Root & '/' & "extract.adb"); Put ("with " & UTF_8.Encode (Config_Package_Name) & ';'); NL; Put ("with Ada.Text_IO.Text_Streams; use Ada.Text_IO.Text_Streams;"); NL; NL; Put ("procedure Extract is"); NL; Put (Tab & "STDOUT: constant Stream_Access "); Put (":= Stream (Ada.Text_IO.Standard_Output);"); NL; Put ("begin"); NL; NL; Gen_Loader ("build.external_libraries", Target.Configuration.External_Libraries); Gen_Loader ("build.ada.compiler_options", Target.Configuration.Ada_Compiler_Opts); Gen_Loader ("build.c.compiler_options", Target.Configuration.C_Compiler_Opts); Gen_Loader ("build.c.preprocessor_definitions", Target.Configuration.C_Definitions); Gen_Loader ("codepaths", Target.Configuration.Codepaths); Gen_Loader ("information", Target.Configuration.Information); Put ("end Extract;"); NL; TIO.Close (Out_File); -- Phase two: compile the extraction program declare use Child_Processes; use Output_Buffers; STDOUT, STDERR: Bounded_String; Compiler: Child_Process'Class := Spawn_Process (Image_Path => Program_Paths.Image_Path (GNAT_Make), Arguments => "-I../../../ extract.adb", Working_Directory => Config_Build_Root); Timed_Out: Boolean; Status : Exit_Status; begin Wait_And_Buffer (Process => Compiler, Poll_Rate => 0.1, Timeout => 120.0, Output => STDOUT, Error => STDERR, Timed_Out => Timed_Out, Status => Status); Assert (Check => not Timed_Out and then Status = Success, Message => New_Line & "Compilation of the configuration extraction " & "program failed" & (if Timed_Out then "(Timed out)" else "") & ':' & New_Line & To_String (STDERR)); end; -- Phase three: run the extraction program declare use Child_Processes; use Output_Buffers; STDERR_Buffer: Bounded_String; Extractor: Child_Process'Class := Spawn_Process (Image_Path => Config_Build_Root & "/extract", Arguments => "", Working_Directory => Ada.Directories.Current_Directory); Timed_Out: Boolean; Status : Exit_Status; begin Extractor.Set_Stream_Timeout (Selector => Standard_Output, Timeout => 30.0); declare STDOUT: constant not null access Ada.Streams.Root_Stream_Type'Class := Extractor.IO_Stream (Standard_Output); begin Load (STDOUT, Target.Configuration.External_Libraries); Load (STDOUT, Target.Configuration.Ada_Compiler_Opts ); Load (STDOUT, Target.Configuration.C_Compiler_Opts ); Load (STDOUT, Target.Configuration.C_Definitions ); Load (STDOUT, Target.Configuration.Codepaths ); Load (STDOUT, Target.Configuration.Information ); end; Extractor.Wait_Terminated (Timeout => 10.0, Timed_Out => Timed_Out, Status => Status); if Timed_Out then raise Ada.Assertions.Assertion_Error with "Extractor program timed-out"; elsif Status /= Success then -- Attempt to flush STDERR declare STDERR: constant not null access Ada.Streams.Root_Stream_Type'Class := Extractor.IO_Stream (Standard_Error); C: Character; begin loop Character'Read (STDERR, C); Append (Source => STDERR_Buffer, New_Item => C); end loop; exception when others => null; end; raise Ada.Assertions.Assertion_Error with "Extractor program failed:" & New_Line & To_String (STDERR_Buffer); end if; end; Step_4 (Target); end Step_3b;
30,648
ada
0
damaki/EVB1000
src/evb1000-usb.ads
<gh_stars>0 with Ada.Interrupts.Names; with System; package EVB1000.USB with SPARK_Mode => On is Driver_Priority : constant System.Interrupt_Priority := System.Interrupt_Priority'First; -- By default, use lowest interrupt priority. -- Any interrupt priority value can be used, though. Rx_Buffer_Size : constant Positive := 1024; -- Configures the size of the USB receive buffer. subtype Rx_Length_Number is Natural range 0 .. Rx_Buffer_Size; type Rx_Index is mod Rx_Buffer_Size; protected Buffer with Interrupt_Priority => Driver_Priority is function Is_Connected return Boolean; -- Check if the USB is currently connected. function Can_Read return Boolean with Global => null; -- Check if there is received data waiting to be read. entry Read (Str : in out String; Count : out Natural) with Global => null, Depends => (Buffer => + Str, Count => (Buffer, Str), Str => + Buffer), Contract_Cases => (Str'Length = 0 => Count = 0, Str'Length > 0 => Count in 1 .. Str'Length); -- Read data received over USB. -- -- Data is written to the @Str@ buffer. The number of characters read is -- written to @Count@. This subprogram will try to fill the @Str@ buffer -- but will only read as many characters as available. -- -- This entry blocks until at least 1 byte is available to be read. procedure Write (Str : in String); -- Write data to be sent via USB. -- -- If the USB is not currently connected then the data is discarded -- and this procedure has no effect. procedure Data_Received (Str : in String); -- Notifies this protected object of data received via USB. -- -- This procedure is called by the USB drivers. It should not be called -- by the user. private Rx_Buffer : String (1 .. Rx_Buffer_Size) := (others => Character'First); Rx_Length : Rx_Length_Number := 0; Rx_First : Rx_Index := 0; Has_Data : Boolean := False; end Buffer; private protected Driver with Interrupt_Priority => Driver_Priority is procedure Write (Str : in String); procedure USB_OTG_Interrupt_Handler with Attach_Handler => Ada.Interrupts.Names.OTG_FS_Interrupt; end Driver; end EVB1000.USB;
30,649
ada
0
melwyncarlo/ProjectEuler
problems/036/a036.adb
<filename>problems/036/a036.adb with Ada.Strings.Fixed; with Ada.Integer_Text_IO; -- Copyright 2021 <NAME> procedure A036 is use Ada.Strings.Fixed; use Ada.Integer_Text_IO; -- Initial values denoting the numbers 0, 1, 3, 5, 7, and 9. Sum_Val : Integer := 25; Decimal : String (1 .. 10); Binary : String (1 .. 30); Is_Decimal_Palindromic, Is_Binary_Palindromic : Boolean; J, Decimal_Len, Decimal_Len_By_2, Binary_Len, Binary_Len_By_2, Temp_Len, Quotient : Integer; begin for I in 10 .. 1_000_000 loop if (I mod 2) = 0 then goto Continue; end if; Move (Source => Trim (Integer'Image (I), Ada.Strings.Both), Target => Decimal, Justify => Ada.Strings.Left); Decimal_Len := Trim (Integer'Image (I), Ada.Strings.Both)'Length; Is_Decimal_Palindromic := True; if Decimal_Len /= 1 then Decimal_Len_By_2 := Integer (Float'Floor (Float (Decimal_Len) / 2.0)); for J in 1 .. Decimal_Len_By_2 loop Temp_Len := Decimal_Len - J + 1; if Decimal (J) /= Decimal (Temp_Len) then Is_Decimal_Palindromic := False; exit; end if; end loop; end if; if (not Is_Decimal_Palindromic) then goto Continue; end if; Binary := 30 * " "; J := 1; Quotient := I; while Quotient /= 0 loop Binary (J) := Character'Val ((Quotient mod 2) + Character'Pos ('0')); Quotient := Integer (Float'Floor (Float (Quotient) / 2.0)); J := J + 1; end loop; Is_Binary_Palindromic := True; Binary_Len := Index (Binary, " ") - 1; Binary_Len_By_2 := Integer (Float'Floor (Float (Binary_Len) / 2.0)); for J in 1 .. Binary_Len_By_2 loop Temp_Len := Binary_Len - J + 1; if Binary (J) /= Binary (Temp_Len) then Is_Binary_Palindromic := False; exit; end if; end loop; if not Is_Binary_Palindromic then goto Continue; end if; Sum_Val := Sum_Val + I; <<Continue>> end loop; Put (Sum_Val, Width => 0); end A036;
30,650
ada
1
zrmyers/VulkanAda
test/dmat/vulkan-math-dmat4x2-test.adb
<reponame>zrmyers/VulkanAda -------------------------------------------------------------------------------- -- MIT License -- -- Copyright (c) 2021 <NAME> -- -- Permission is hereby granted, free of charge, to any person obtaining a copy -- of this software and associated documentation files (the "Software"), to deal -- in the Software without restriction, including without limitation the rights -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -- copies of the Software, and to permit persons to whom the Software is -- furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in all -- copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -- SOFTWARE. -------------------------------------------------------------------------------- with Ada.Text_IO; with Ada.Characters.Latin_1; with Vulkan.Math.GenDMatrix; with Vulkan.Math.Dmat2x2; with Vulkan.Math.Dmat4x2; with Vulkan.Math.Dmat3x4; with Vulkan.Math.GenDType; with Vulkan.Math.Dvec2; with Vulkan.Math.Dvec4; with Vulkan.Test.Framework; use Ada.Text_IO; use Ada.Characters.Latin_1; use Vulkan.Math.Dmat2x2; use Vulkan.Math.Dmat4x2; use Vulkan.Math.Dmat3x4; use Vulkan.Math.GenDType; use Vulkan.Math.Dvec2; use Vulkan.Math.Dvec4; use Vulkan.Test.Framework; -------------------------------------------------------------------------------- --< @group Vulkan Math Basic Types -------------------------------------------------------------------------------- --< @summary --< This package provides tests for single precision floating point mat4x2. -------------------------------------------------------------------------------- package body Vulkan.Math.Dmat4x2.Test is -- Test Mat4x2 procedure Test_Dmat4x2 is vec1 : Vkm_Dvec2 := Make_Dvec2(1.0, 2.0); vec2 : Vkm_Dvec4 := Make_Dvec4(1.0, 2.0, 3.0, 4.0); mat1 : Vkm_Dmat4x2 := Make_Dmat4x2; mat2 : Vkm_Dmat4x2 := Make_Dmat4x2(0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0); mat3 : Vkm_Dmat4x2 := Make_Dmat4x2(vec1, - vec1, 2.0 * vec1, - 2.0 * vec1); mat4 : Vkm_Dmat4x2 := Make_Dmat4x2(mat2); mat5 : Vkm_Dmat2x2 := Make_Dmat2x2(5.0); mat6 : Vkm_Dmat4x2 := Make_Dmat4x2(mat5); mat7 : Vkm_Dmat3x4 := Make_Dmat3x4(mat5); begin Put_Line(LF & "Testing Mat4x2 Constructors..."); Put_Line("mat1 " & mat1.Image); Assert_Dmat4x2_Equals(mat1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); Put_Line("mat2 " & mat2.Image); Assert_Dmat4x2_Equals(mat2, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0); Put_Line("mat3 " & mat3.Image); Assert_Dmat4x2_Equals(mat3, 1.0, 2.0, -1.0, -2.0, 2.0, 4.0, -2.0, -4.0); Put_Line("mat4 " & mat4.Image); Assert_Dmat4x2_Equals(mat4, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0); Put_Line("mat6 " & mat6.Image); Assert_Dmat4x2_Equals(mat6, 5.0, 0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0); Put_Line("Testing '=' operator..."); Put_Line(" mat2 != mat3"); Assert_Vkm_Bool_Equals(mat2 = mat3, False); Put_Line(" mat4 != mat5"); Assert_Vkm_Bool_Equals(mat4 = mat5, False); Put_Line(" mat4 = mat2"); Assert_Vkm_Bool_Equals(mat4 = mat2, True); Put_Line(" Testing unary '+/-' operator"); Put_Line(" + mat4 = " & Image(+ mat4)); Assert_Dmat4x2_Equals(+mat4, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0); Put_Line(" - mat4 = " & Image(- mat4)); Assert_Dmat4x2_Equals(-mat4, -0.0, -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0); Put_Line("+(- mat4) = " & Image(+(- mat4))); Assert_Dmat4x2_Equals(-mat4, -0.0, -1.0, -2.0, -3.0, -4.0, -5.0, -6.0, -7.0); Put_Line("Testing 'abs' operator..."); Put_Line(" abs(- mat4) = " & Image(abs(-mat4))); Assert_Dmat4x2_Equals(abs(-mat4), 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0); Put_Line("Testing '+' operator..."); Put_Line(" mat4 + mat3 = " & Image(mat4 + mat3)); Assert_Dmat4x2_Equals(mat4 + mat3, 1.0, 3.0, 1.0, 1.0, 6.0, 9.0, 4.0, 3.0); Put_Line("Testing '-' operator..."); Put_Line(" mat4 - mat3 = " & Image(mat4 -mat3)); Assert_Dmat4x2_Equals(mat4 - mat3, -1.0, -1.0, 3.0, 5.0, 2.0, 1.0, 8.0, 11.0); Put_Line("Testing '*' operator..."); Put_Line(" mat4 * mat5 = " & Image(mat4 * mat5)); Assert_Dmat4x2_Equals(mat4 * mat5, 0.0, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0, 35.0); Put_Line(" mat7 * mat4 = " & Image(mat7 * mat4)); Assert_Dmat3x2_Equals(mat7 * mat4, 0.0, 5.0, 10.0, 15.0, 0.0, 0.0); Put_Line(" mat4 * vec1 = " & Image(mat4 * vec1)); Assert_Dvec4_Equals(mat4 * vec1, 2.0 , 8.0 , 14.0, 20.0); Put_Line(" vec2 * mat4 = " & Image(vec2 * mat4)); Assert_Dvec2_Equals(vec2 * mat4, 40.0 , 50.0 ); end Test_Dmat4x2; end Vulkan.Math.Dmat4x2.Test;
30,651
ada
15
My-Colaborations/dynamo
src/gen-artifacts.adb
<filename>src/gen-artifacts.adb ----------------------------------------------------------------------- -- gen-artifacts -- Artifacts for Code Generator -- Copyright (C) 2012 <NAME> -- Written by <NAME> (<EMAIL>) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body Gen.Artifacts is -- ------------------------------ -- After the configuration file is read, processes the node whose root -- is passed in <b>Node</b> and initializes the <b>Model</b> with the information. -- ------------------------------ procedure Initialize (Handler : in out Artifact; Path : in String; Node : in DOM.Core.Node; Model : in out Gen.Model.Packages.Model_Definition'Class; Context : in out Generator'Class) is pragma Unreferenced (Path, Node, Model, Context); begin Handler.Initialized := True; end Initialize; -- ------------------------------ -- Check whether this artifact has been initialized. -- ------------------------------ function Is_Initialized (Handler : in Artifact) return Boolean is begin return Handler.Initialized; end Is_Initialized; end Gen.Artifacts;
30,652
ada
1
Jellix/open_weather_map_api
src/open_weather_map-api-query.ads
-------------------------------------------------------------------------------- -- Copyright (C) 2020 by Heisenbug Ltd. (<EMAIL>) -- -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the LICENSE file for more details. -------------------------------------------------------------------------------- pragma License (Unrestricted); -------------------------------------------------------------------------------- --% @summary --% Open_Weather_Map.API.Query (private) -- --% @description --% Provides the abstract tagged type implementing a context where query timings --% are stored. -------------------------------------------------------------------------------- private package Open_Weather_Map.API.Query is ----------------------------------------------------------------------------- -- Abstract context base type, and its primitive operations. ----------------------------------------------------------------------------- type T is abstract new Open_Weather_Map.API.T with private; ----------------------------------------------------------------------------- -- Initialize ----------------------------------------------------------------------------- procedure Initialize (Self : out T); --% Initializes the object. -- --% @param Self --% The object to be initialized. ----------------------------------------------------------------------------- -- Last_Query ----------------------------------------------------------------------------- overriding function Last_Query (Self : in T) return Ada.Real_Time.Time with Inline => True; --% Returns the time of the last query done with that context. -- --% @param Self --% The object to retrive its last update time from. -- --% @return --% Time of the last server update for This. ----------------------------------------------------------------------------- -- Set_Last_Query ----------------------------------------------------------------------------- procedure Set_Last_Query (Self : in out T; Value : in Ada.Real_Time.Time); --% Sets a new last time a query has been executed. Should be called by --% derived types whenever a query is about to be performed. -- --% @param Self --% The object to be updated. -- --% @param Value --% The new time to be set for the last update being performed. private type T is abstract new Open_Weather_Map.API.T with record Last_Query : Ada.Real_Time.Time; --% @field Last_Query --% Stores the last time the object has been updated from the server. -- Used to implement and caching and rate limiting. end record; ----------------------------------------------------------------------------- -- Last_Query ----------------------------------------------------------------------------- overriding function Last_Query (Self : in T) return Ada.Real_Time.Time is (Self.Last_Query); end Open_Weather_Map.API.Query;
30,653
ada
20
charlie5/lace
3-mid/opengl/source/opengl-errors.adb
with openGL.Tasks, GL.Binding, ada.Text_IO; package body openGL.Errors is use GL; function Current return String is use GL.Binding; check_is_OK : constant Boolean := openGL.Tasks.Check; pragma Unreferenced (check_is_OK); the_Error : constant GL.GLenum := glGetError; begin case the_Error is when GL.GL_NO_ERROR => return "no error"; when GL_INVALID_ENUM => return "invalid Enum"; when GL_INVALID_VALUE => return "invalid Value"; when GL_INVALID_OPERATION => return "invalid Operation"; when GL_OUT_OF_MEMORY => return "out of Memory"; when others => return "unknown openGL error detected"; end case; end Current; procedure log (Prefix : in String := "") is current_Error : constant String := Current; function Error_Message return String is begin if Prefix = "" then return "openGL error: '" & current_Error & "'"; else return Prefix & ": '" & current_Error & "'"; end if; end Error_Message; begin if current_Error = "no error" then return; end if; raise openGL.Error with Error_Message; end log; procedure log (Prefix : in String := ""; Error_occurred : out Boolean) is use ada.Text_IO; current_Error : constant String := Current; begin if current_Error = "no error" then error_Occurred := False; return; end if; error_Occurred := True; if Prefix = "" then put_Line ("openGL error: '" & current_Error & "'"); else put_Line (Prefix & ": '" & current_Error & "'"); end if; end log; end openGL.Errors;
30,654
ada
1
irion7/aflex-ayacc-mirror
ayacc/src/cli__read_command_line_vax.ada
<gh_stars>1-10 separate (Command_Line_Interface) procedure Read_Command_Line (Command_Args : out Command_Line_Type) is procedure Get_Foreign (P : out String); pragma Interface (External, Get_Foreign); pragma Import_Valued_Procedure (Get_Foreign, "LIB$GET_FOREIGN", (String), (Descriptor (S))); begin Get_Foreign (Command_Args); end Read_Command_Line;
30,655
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c8/c83030c.ada
-- C83030C.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- OBJECTIVE: -- CHECK THAT WITHIN A GENERIC SUBPROGRAM BODY COMPILED AS A SUBUNIT -- IN THE SAME COMPILATION, NON-HOMOGRAPH SUBPROGRAMS DECLARED -- OUTSIDE THE GENERIC UNIT, AND HAVING THE SAME IDENTIFIER, ARE NOT -- HIDDEN. -- HISTORY: -- JET 10/17/88 CREATED ORIGINAL TEST. -- BCB 10/03/90 ADDED "PRAGMA ELABORATE (REPORT);". WITH REPORT; USE REPORT; PRAGMA ELABORATE (REPORT); PACKAGE C83030C_DECL1 IS GLOBAL : INTEGER := IDENT_INT(INTEGER'FIRST); SWITCH : BOOLEAN := TRUE; PROCEDURE C83030C_PROC1; PROCEDURE C83030C_PROC1 (X : INTEGER); PROCEDURE C83030C_PROC2; PROCEDURE C83030C_PROC2 (X : INTEGER); FUNCTION C83030C_FUNC3 RETURN INTEGER; FUNCTION C83030C_FUNC3 RETURN BOOLEAN; FUNCTION C83030C_FUNC3 (X : INTEGER) RETURN INTEGER; FUNCTION C83030C_FUNC4 RETURN INTEGER; FUNCTION C83030C_FUNC4 RETURN BOOLEAN; END C83030C_DECL1; WITH REPORT; USE REPORT; WITH C83030C_DECL1; USE C83030C_DECL1; PACKAGE C83030C_DECL2 IS GENERIC PROCEDURE C83030C_PROC1; GENERIC TYPE T IS (<>); PROCEDURE C83030C_PROC2 (X : T); GENERIC FUNCTION C83030C_FUNC3 RETURN INTEGER; GENERIC TYPE T IS (<>); FUNCTION C83030C_FUNC4 RETURN T; END C83030C_DECL2; WITH REPORT; USE REPORT; PACKAGE BODY C83030C_DECL1 IS PROCEDURE C83030C_PROC1 IS BEGIN GLOBAL := IDENT_INT(1); END C83030C_PROC1; PROCEDURE C83030C_PROC1 (X : INTEGER) IS BEGIN GLOBAL := IDENT_INT(X); END C83030C_PROC1; PROCEDURE C83030C_PROC2 IS BEGIN GLOBAL := IDENT_INT(1); END C83030C_PROC2; PROCEDURE C83030C_PROC2 (X : INTEGER) IS BEGIN GLOBAL := IDENT_INT(X); END C83030C_PROC2; FUNCTION C83030C_FUNC3 RETURN INTEGER IS BEGIN RETURN IDENT_INT(1); END C83030C_FUNC3; FUNCTION C83030C_FUNC3 RETURN BOOLEAN IS BEGIN RETURN IDENT_BOOL(FALSE); END C83030C_FUNC3; FUNCTION C83030C_FUNC3 (X : INTEGER) RETURN INTEGER IS BEGIN RETURN IDENT_INT(X); END C83030C_FUNC3; FUNCTION C83030C_FUNC4 RETURN INTEGER IS BEGIN RETURN IDENT_INT(1); END C83030C_FUNC4; FUNCTION C83030C_FUNC4 RETURN BOOLEAN IS BEGIN RETURN IDENT_BOOL(FALSE); END C83030C_FUNC4; END C83030C_DECL1; WITH REPORT; USE REPORT; WITH C83030C_DECL1; USE C83030C_DECL1; PACKAGE BODY C83030C_DECL2 IS PROCEDURE C83030C_PROC1 IS SEPARATE; PROCEDURE C83030C_PROC2 (X : T) IS SEPARATE; FUNCTION C83030C_FUNC3 RETURN INTEGER IS SEPARATE; FUNCTION C83030C_FUNC4 RETURN T IS SEPARATE; END C83030C_DECL2; SEPARATE (C83030C_DECL2) PROCEDURE C83030C_PROC1 IS A : INTEGER := IDENT_INT(2); BEGIN IF SWITCH THEN SWITCH := FALSE; C83030C_PROC1; IF GLOBAL /= IDENT_INT(3) THEN FAILED ("INCORRECT VALUE FOR PROCEDURE CALL - 1"); END IF; END IF; C83030C_PROC1(A); IF GLOBAL /= IDENT_INT(2) THEN FAILED ("INCORRECT VALUE FOR PROCEDURE CALL - 2"); END IF; GLOBAL := IDENT_INT(3); END C83030C_PROC1; SEPARATE (C83030C_DECL2) PROCEDURE C83030C_PROC2 (X : T) IS A : T := T'FIRST; BEGIN IF SWITCH THEN SWITCH := FALSE; C83030C_PROC2 (X); IF GLOBAL /= IDENT_INT(2) THEN FAILED ("INCORRECT VALUE FOR PROCEDURE CALL - 20"); END IF; GLOBAL := IDENT_INT(3); ELSE GLOBAL := IDENT_INT(2); END IF; END C83030C_PROC2; SEPARATE (C83030C_DECL2) FUNCTION C83030C_FUNC3 RETURN INTEGER IS A : INTEGER := INTEGER'LAST; BEGIN IF SWITCH THEN SWITCH := FALSE; IF C83030C_FUNC3 /= IDENT_INT(3) THEN FAILED ("INCORRECT VALUE FROM FUNCTION CALL - 30"); END IF; END IF; IF C83030C_FUNC3(A) /= IDENT_INT(INTEGER'LAST) THEN FAILED ("INCORRECT VALUE FROM FUNCTION CALL - 31"); END IF; IF C83030C_FUNC3 THEN FAILED ("INCORRECT VALUE FROM FUNCTION CALL - 32"); END IF; RETURN IDENT_INT(3); END C83030C_FUNC3; SEPARATE (C83030C_DECL2) FUNCTION C83030C_FUNC4 RETURN T IS A : T := T'LAST; BEGIN IF SWITCH THEN SWITCH := FALSE; IF C83030C_FUNC4 /= T'LAST THEN FAILED ("INCORRECT VALUE FROM FUNCTION CALL - 40"); END IF; RETURN T'FIRST; ELSE IF C83030C_FUNC4 THEN FAILED ("INCORRECT VALUE FROM FUNCTION CALL - 41"); END IF; RETURN T'LAST; END IF; END C83030C_FUNC4; WITH REPORT; USE REPORT; WITH C83030C_DECL1, C83030C_DECL2; USE C83030C_DECL1, C83030C_DECL2; PROCEDURE C83030C IS BEGIN TEST ("C83030C", "CHECK THAT WITHIN A GENERIC SUBPROGRAM BODY " & "COMPILED AS A SUBUNIT IN THE SAME COMPILATION," & " NON-HOMOGRAPH SUBPROGRAMS DECLARED OUTSIDE " & "THE GENERIC UNIT, AND HAVING THE SAME " & "IDENTIFIER, ARE NOT HIDDEN"); ONE: DECLARE PROCEDURE PROC1 IS NEW C83030C_DECL2.C83030C_PROC1; BEGIN IF GLOBAL /= IDENT_INT(INTEGER'FIRST) THEN FAILED ("INCORRECT VALUE FOR START OF TEST ONE"); END IF; PROC1; IF GLOBAL /= IDENT_INT(3) THEN FAILED ("INCORRECT VALUE FOR END OF TEST ONE"); END IF; GLOBAL := IDENT_INT(INTEGER'FIRST); SWITCH := TRUE; END ONE; TWO: DECLARE PROCEDURE PROC2 IS NEW C83030C_DECL2.C83030C_PROC2(INTEGER); BEGIN IF GLOBAL /= IDENT_INT(INTEGER'FIRST) THEN FAILED ("INCORRECT VALUE FOR START OF TEST TWO"); END IF; PROC2 (1); IF GLOBAL /= IDENT_INT(3) THEN FAILED ("INCORRECT VALUE FOR END OF TEST TWO"); END IF; SWITCH := TRUE; END TWO; THREE: DECLARE FUNCTION FUNC3 IS NEW C83030C_DECL2.C83030C_FUNC3; BEGIN IF FUNC3 /= IDENT_INT(3) THEN FAILED ("INCORRECT VALUE FOR END OF TEST THREE"); END IF; SWITCH := TRUE; END THREE; FOUR: DECLARE FUNCTION FUNC4 IS NEW C83030C_DECL2.C83030C_FUNC4 (INTEGER); BEGIN IF FUNC4 /= IDENT_INT(INTEGER'FIRST) THEN FAILED ("INCORRECT VALUE FOR END OF TEST FOUR"); END IF; GLOBAL := INTEGER'FIRST; SWITCH := TRUE; END FOUR; RESULT; END C83030C;
30,656
ada
1
tomberek/RaySAR
libraries/zlib/contrib/ada/mtest.adb
<reponame>tomberek/RaySAR ---------------------------------------------------------------- -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2003 <NAME> -- -- -- -- Open source license information is in the zlib.ads file. -- ---------------------------------------------------------------- -- Continuous test for ZLib multithreading. If the test is fail -- Wou should provide thread safe allocation routines for the Z_Stream. -- -- $Id: mtest.adb,v 1.2 2003/08/12 12:11:05 vagul Exp $ with ZLib; with Ada.Streams; with Ada.Numerics.Discrete_Random; with Ada.Text_IO; with Ada.Exceptions; with Ada.Task_Identification; procedure MTest is use Ada.Streams; use ZLib; Stop : Boolean := False; pragma Atomic (Stop); subtype Visible_Symbols is Stream_Element range 16#20# .. 16#7E#; package Random_Elements is new Ada.Numerics.Discrete_Random (Visible_Symbols); task type Test_Task; task body Test_Task is Buffer : Stream_Element_Array (1 .. 100_000); Gen : Random_Elements.Generator; Buffer_First : Stream_Element_Offset; Compare_First : Stream_Element_Offset; Deflate : Filter_Type; Inflate : Filter_Type; procedure Further (Item : in Stream_Element_Array); procedure Read_Buffer (Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); ------------- -- Further -- ------------- procedure Further (Item : in Stream_Element_Array) is procedure Compare (Item : in Stream_Element_Array); ------------- -- Compare -- ------------- procedure Compare (Item : in Stream_Element_Array) is Next_First : Stream_Element_Offset := Compare_First + Item'Length; begin if Buffer (Compare_First .. Next_First - 1) /= Item then raise Program_Error; end if; Compare_First := Next_First; end Compare; procedure Compare_Write is new ZLib.Write (Write => Compare); begin Compare_Write (Inflate, Item, No_Flush); end Further; ----------------- -- Read_Buffer -- ----------------- procedure Read_Buffer (Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset) is Buff_Diff : Stream_Element_Offset := Buffer'Last - Buffer_First; Next_First : Stream_Element_Offset; begin if Item'Length <= Buff_Diff then Last := Item'Last; Next_First := Buffer_First + Item'Length; Item := Buffer (Buffer_First .. Next_First - 1); Buffer_First := Next_First; else Last := Item'First + Buff_Diff; Item (Item'First .. Last) := Buffer (Buffer_First .. Buffer'Last); Buffer_First := Buffer'Last + 1; end if; end Read_Buffer; procedure Translate is new Generic_Translate (Data_In => Read_Buffer, Data_Out => Further); begin Random_Elements.Reset (Gen); Buffer := (others => 20); Main : loop for J in Buffer'Range loop Buffer (J) := Random_Elements.Random (Gen); Deflate_Init (Deflate); Inflate_Init (Inflate); Buffer_First := Buffer'First; Compare_First := Buffer'First; Translate (Deflate); if Compare_First /= Buffer'Last + 1 then raise Program_Error; end if; Ada.Text_IO.Put_Line (Ada.Task_Identification.Image (Ada.Task_Identification.Current_Task) & Stream_Element_Offset'Image (J) & ZLib.Count'Image (Total_Out (Deflate))); Close (Deflate); Close (Inflate); exit Main when Stop; end loop; end loop Main; exception when E : others => Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Information (E)); Stop := True; end Test_Task; Test : array (1 .. 4) of Test_Task; pragma Unreferenced (Test); begin null; end MTest;
30,657
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/ada/s-traceb-mastop.adb
<filename>gcc-gcc-7_3_0-release/gcc/ada/s-traceb-mastop.adb ------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . T R A C E B A C K -- -- -- -- B o d y -- -- -- -- Copyright (C) 1999-2015, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This version uses System.Machine_State_Operations routines with System.Machine_State_Operations; package body System.Traceback is use System.Machine_State_Operations; procedure Call_Chain (Traceback : System.Address; Max_Len : Natural; Len : out Natural; Exclude_Min : System.Address := System.Null_Address; Exclude_Max : System.Address := System.Null_Address; Skip_Frames : Natural := 1); -- Same as the exported version, but takes Traceback as an Address ---------------- -- Call_Chain -- ---------------- procedure Call_Chain (Traceback : System.Address; Max_Len : Natural; Len : out Natural; Exclude_Min : System.Address := System.Null_Address; Exclude_Max : System.Address := System.Null_Address; Skip_Frames : Natural := 1) is type Tracebacks_Array is array (1 .. Max_Len) of Code_Loc; pragma Suppress_Initialization (Tracebacks_Array); M : Machine_State; Code : Code_Loc; Trace : Tracebacks_Array; for Trace'Address use Traceback; N_Skips : Natural := 0; begin M := Allocate_Machine_State; Set_Machine_State (M); -- Skip the requested number of frames loop Code := Get_Code_Loc (M); exit when Code = Null_Address or else N_Skips = Skip_Frames; Pop_Frame (M); N_Skips := N_Skips + 1; end loop; -- Now, record the frames outside the exclusion bounds, updating -- the Len output value along the way. Len := 0; loop Code := Get_Code_Loc (M); exit when Code = Null_Address or else Len = Max_Len; if Code < Exclude_Min or else Code > Exclude_Max then Len := Len + 1; Trace (Len) := Code; end if; Pop_Frame (M); end loop; Free_Machine_State (M); end Call_Chain; procedure Call_Chain (Traceback : in out System.Traceback_Entries.Tracebacks_Array; Max_Len : Natural; Len : out Natural; Exclude_Min : System.Address := System.Null_Address; Exclude_Max : System.Address := System.Null_Address; Skip_Frames : Natural := 1) is begin Call_Chain (Traceback'Address, Max_Len, Len, Exclude_Min, Exclude_Max, -- Skip one extra frame to skip the other Call_Chain entry as well Skip_Frames => Skip_Frames + 1); end Call_Chain; ------------------ -- C_Call_Chain -- ------------------ function C_Call_Chain (Traceback : System.Address; Max_Len : Natural) return Natural is Val : Natural; begin Call_Chain (Traceback, Max_Len, Val); return Val; end C_Call_Chain; end System.Traceback;
30,658
ada
15
AdaCore/training_material
courses/fundamentals_of_ada/labs/radar/030_basic_types/answers/main.adb
with Radar_Internals; procedure Main is -- You are in charge of developping a rotating radar for the new T-1000 -- Some of the radar code is already in place, it is just missing the -- high-level interface to handle incoming objects. type Object_Status_T is (Out_Of_Range, Tracked, Cleared, Selected); -- QUESTION 1 - Part A -- -- Define a type Angle_Degrees_T that is modulo 360 type Angle_Degrees_T is mod 360; -- Define a subtype Object_Distance_Km_T as a Float with values -- between 10cm and 100km subtype Object_Distance_Km_T is Float range 0.000_01 .. 100.0; -- Define a subtype Speed_Kph_T that is a Float between 0 and 50 km/h subtype Speed_Kph_T is Float range 0.0 .. 50.0; John_Connor : Object_Status_T := Out_Of_Range; -- QUESTION 1 - Part B -- -- Set Radar_Angle to be an Angle_Degrees_T with a starting value Radar_Angle : Angle_Degrees_T := 180; -- Declare an Object_Distance_Km_T named Distance_Closest_Object, set to 10km Distance_Closest_Object : Object_Distance_Km_T := 10.0; -- Declare a Speed_Kph_T named Running_Speed, set to 25km/h Running_Speed : Speed_Kph_T := 25.0; -- Assign Time_To_Arrival to -- Distance_Closest_Object divided by Running_Speed * 3600 Time_To_Arrival : Float := Distance_Closest_Object / Running_Speed * 3600.0; begin -- This line will compile if the declarations are OK Radar_Internals.Time_Step (Float (Radar_Angle), Time_To_Arrival, Object_Status_T'Image (John_Connor)); -- QUESTION 2 - Part A -- -- Some time has passed since setup, set variables as follow to reflect that. -- -- Rotate the radar 200 degrees by incrementing its value Radar_Angle := Radar_Angle + 200; -- Set the status of John_Connor to Tracked John_Connor := Tracked; -- Set distance to closest object to 4km Distance_Closest_Object := 4.0; -- Update Running_Time accordingly Time_To_Arrival := Distance_Closest_Object / Running_Speed * 3600.0; -- This line will compile if the declarations are OK Radar_Internals.Time_Step (Float (Radar_Angle), Time_To_Arrival, Object_Status_T'Image (John_Connor)); -- QUESTION 2 - Part B -- -- Some more time has passed since setup. -- -- Rotate the radar 180 degrees Radar_Angle := Radar_Angle + 180; -- Set the status of John_Connor to Selected John_Connor := Selected; -- This line will compile if the declarations are OK Radar_Internals.Time_Step (Float (Radar_Angle), Time_To_Arrival, Object_Status_T'Image (John_Connor)); -- QUESTION 3 - Quiz -- -- a. What happens if we want to rotate the radar by 361 degrees? -- This won't compile: 361 is not a valid `Angle_Degrees_T` -- Radar_Angle := Radar_Angle + 361; -- This will work though, end result is identical to adding 1 degree Radar_Angle := Radar_Angle + 359; Radar_Angle := Radar_Angle + 2; -- b. There is a last minute change in the spec: John Connor is now in -- the "Friend" status, make changes to the code to allow for that. -- Simply add a Friend value to Object_Status_T and call -- John_Connor := Friend; -- Notice that Time_Step handles the new enumeral without issue -- c. What happens to the E.T.A. if Running_Speed is 0? Try it. -- Running speed is used as a divisor, so there will be a division -- by 0. This will either return a NaN or raise a Constraint_Error -- depending on value of Real'Machine_Overflows. -- QUESTION 4 - Advanced -- -- Redefine Object_Distance_Km_T as a type instead of subtype. -- Modify the two division to make it work, using explicit casting. end Main;
30,659
ada
0
melwyncarlo/ProjectEuler
problems/023/a023.adb
with Ada.Integer_Text_IO; -- Copyright 2021 <NAME> procedure A023 is use Ada.Integer_Text_IO; Abundant_Numbers : array (Integer range 1 .. 10000) of Integer := (others => 0); N : Integer := 1; Count_Val : Integer := 1; J_Max, K, Count_By_2, Proper_Divisors_Sum : Integer; Abundant_Sum_Found : Boolean; begin for I in 2 .. 28123 loop Proper_Divisors_Sum := 0; J_Max := Integer (Float'Floor (Float (I) / 2.0)); for J in 1 .. J_Max loop if (I mod J) = 0 then Proper_Divisors_Sum := Proper_Divisors_Sum + J; end if; end loop; if Proper_Divisors_Sum > I then Abundant_Numbers (Count_Val) := I; Count_Val := Count_Val + 1; end if; Count_By_2 := Integer (Float'Floor (Float (Count_Val) / 2.0)); Abundant_Sum_Found := False; for J in 1 .. Count_By_2 loop K := J; while (Abundant_Numbers (J) + Abundant_Numbers (K)) < I loop K := K + 1; end loop; if (Abundant_Numbers (J) + Abundant_Numbers (K)) = I then Abundant_Sum_Found := True; exit; end if; end loop; if not Abundant_Sum_Found then N := N + I; end if; end loop; Put (N, Width => 0); end A023;
30,660
ada
52
onox/orka
orka_egl/src/egl-objects-displays.ads
<filename>orka_egl/src/egl-objects-displays.ads -- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2020 onox <<EMAIL>> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with EGL.Objects.Devices; package EGL.Objects.Displays is pragma Preelaborate; type Platform_Kind is (Device, GBM, Wayland); -- The following extension is required for a specific platform: -- -- Device: EGL_EXT_platform_device -- Wayland: EGL_EXT_platform_wayland -- GBM: EGL_MESA_platform_gbm type Display (Platform : Platform_Kind) is new EGL_Object with private; -- Not_Initialized_Error is raised if a display for the requested -- platform could not be initialized function Create_Display (Platform : Platform_Kind) return Display; -- Create a display using the first device or default connection to -- the given platform -- -- This function primarily exists for the Orka_EGL_Info tool to query -- a list of platform extensions and other info about the platform. -- To create an actual useful connection to a platform, one of the -- functions below must be used. function Create_Display (Device : Devices.Device) return Display with Pre => not Device.In_Use; function Create_Display (Wayland_Display : Native_Display_Ptr) return Display; function Client_Extensions return String_List; -- Return a list of EGL client extensions -- -- Requires EGL 1.5 or EGL_EXT_client_extensions. If an -- Invalid_Operation_Error is raised, then the extension is not -- supported. function Extensions (Object : Display) return String_List; -- Return a list of EGL display extensions function Vendor (Object : Display) return String; function Version (Object : Display) return String; function Device (Object : Display) return Devices.Device; -- Return the device on which the display is based -- -- Requires EGL_EXT_device_query extension. No_Display : constant Display; private for Platform_Kind use (Device => 16#313F#, GBM => 16#31D7#, Wayland => 16#31D8#); for Platform_Kind'Size use Enum'Size; type Display (Platform : Platform_Kind) is new EGL_Object with record Device : Devices.Device := Devices.No_Device; end record; overriding procedure Pre_Finalize (Object : in out Display); No_Display : constant Display := (EGL_Object with Platform => Device, others => <>); end EGL.Objects.Displays;
30,661
ada
0
Tim-Tom/project-euler
Ada/inc/Problem_34.ads
package Problem_34 is procedure Solve; end Problem_34;
30,662
ada
79
Roldak/OpenGLAda
src/glfw/v3/glfw-windows-context.adb
-- part of OpenGLAda, (c) 2017 <NAME> -- released under the terms of the MIT license, see the file "COPYING" with Glfw.API; with Glfw.Enums; package body Glfw.Windows.Context is procedure Make_Current (Window : access Glfw.Windows.Window'Class) is begin if not Window.Initialized then -- null is accepted to detach the current context, but an uninitialized -- window *should* lead to an exception instead of detaching the -- context, so we handle this here raise Operation_Exception with "Window not initialized"; end if; if Window = null then API.Make_Context_Current (System.Null_Address); else API.Make_Context_Current (Window.Handle); end if; end Make_Current; function Current return access Glfw.Windows.Window'Class is use type System.Address; Raw : constant System.Address := API.Get_Current_Context; begin if Raw = System.Null_Address then return null; else return Window_Ptr (Raw); end if; end Current; procedure Swap_Buffers (Window : not null access Glfw.Windows.Window'Class) is begin API.Swap_Buffers (Window.Handle); end Swap_Buffers; procedure Set_Swap_Interval (Value : Swap_Interval) renames API.Swap_Interval; function Client_API (Window : not null access Glfw.Windows.Window'Class) return API_Kind is begin return API.Get_Window_Attrib (Window.Handle, Enums.Client_API); end Client_API; function Profile (Window : not null access Glfw.Windows.Window'Class) return OpenGL_Profile_Kind is begin return API.Get_Window_Attrib (Window.Handle, Enums.OpenGL_Profile); end Profile; procedure Get_Context_Version (Window : not null access Glfw.Windows.Window'Class; Major : out Positive; Minor, Revision : out Natural) is begin Major := Positive (Interfaces.C.int'( (API.Get_Window_Attrib (Window.Handle, Enums.Context_Version_Major)))); Minor := Natural (Interfaces.C.int'( (API.Get_Window_Attrib (Window.Handle, Enums.Context_Version_Minor)))); Revision := Natural (Interfaces.C.int'( (API.Get_Window_Attrib (Window.Handle, Enums.Context_Revision)))); end Get_Context_Version; function Is_Forward_Compat (Window : not null access Glfw.Windows.Window'Class) return Boolean is begin return Boolean (Bool'(API.Get_Window_Attrib (Window.Handle, Enums.OpenGL_Forward_Compat))); end Is_Forward_Compat; function Is_Debug_Context (Window : not null access Glfw.Windows.Window'Class) return Boolean is begin return Boolean (Bool'(API.Get_Window_Attrib (Window.Handle, Enums.OpenGL_Debug_Context))); end Is_Debug_Context; function Robustness (Window : not null access Glfw.Windows.Window'Class) return Robustness_Kind is begin return API.Get_Window_Attrib (Window.Handle, Enums.Context_Robustness); end Robustness; end Glfw.Windows.Context;
30,663
ada
0
csb6/libtcod-ada
demo/tutorial/components-destructibles.adb
with Actors, Engines, Libtcod.Color; use Libtcod; package body Components.Destructibles is ------------- -- is_dead -- ------------- function is_dead(self : Destructible) return Boolean is (self.hp = 0); ----------------- -- take_damage -- ----------------- function take_damage(self : in out Destructible'Class; owner : in out Actors.Actor; damage : Health; engine : in out Engines.Engine) return Health is real_damage : Health; begin if Health(self.defense_stat) > damage then real_damage := 0; else real_damage := damage - Health(self.defense_stat); if real_damage >= self.hp then self.hp := 0; self.die(owner, engine); else self.hp := self.hp - real_damage; end if; end if; return real_damage; end take_damage; --------- -- die -- --------- procedure die(self : in out Destructible; owner : in out Actors.Actor; engine : in out Engines.Engine) is begin owner.ch := '%'; owner.color := Color.dark_red; owner.blocks := False; end die; --------- -- die -- --------- overriding procedure die(self : in out Monster_Destructible; owner : in out Actors.Actor; engine : in out Engines.Engine) is begin engine.gui.log(owner.get_name & " is dead"); die(Destructible(self), owner, engine); end die; --------- -- die -- --------- overriding procedure die(self : in out Player_Destructible; owner : in out Actors.Actor; engine : in out Engines.Engine) is begin engine.gui.log("You died", Color.red); die(Destructible(self), owner, engine); engine.status := Engines.Status_Defeat; end die; end Components.Destructibles;
30,664
ada
2
morbos/Ada_Drivers_Library
arch/ARM/STM32/svd/stm32l4x6/stm32_svd-lcd.ads
-- This spec has been automatically generated from STM32L4x6.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.LCD is pragma Preelaborate; --------------- -- Registers -- --------------- subtype CR_DUTY_Field is HAL.UInt3; subtype CR_BIAS_Field is HAL.UInt2; -- control register type CR_Register is record -- LCD controller enable LCDEN : Boolean := False; -- Voltage source selection VSEL : Boolean := False; -- Duty selection DUTY : CR_DUTY_Field := 16#0#; -- Bias selector BIAS : CR_BIAS_Field := 16#0#; -- Mux segment enable MUX_SEG : Boolean := False; -- Voltage output buffer enable BUFEN : Boolean := False; -- unspecified Reserved_9_31 : HAL.UInt23 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR_Register use record LCDEN at 0 range 0 .. 0; VSEL at 0 range 1 .. 1; DUTY at 0 range 2 .. 4; BIAS at 0 range 5 .. 6; MUX_SEG at 0 range 7 .. 7; BUFEN at 0 range 8 .. 8; Reserved_9_31 at 0 range 9 .. 31; end record; subtype FCR_PON_Field is HAL.UInt3; subtype FCR_DEAD_Field is HAL.UInt3; subtype FCR_CC_Field is HAL.UInt3; subtype FCR_BLINKF_Field is HAL.UInt3; subtype FCR_BLINK_Field is HAL.UInt2; subtype FCR_DIV_Field is HAL.UInt4; subtype FCR_PS_Field is HAL.UInt4; -- frame control register type FCR_Register is record -- High drive enable HD : Boolean := False; -- Start of frame interrupt enable SOFIE : Boolean := False; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- Update display done interrupt enable UDDIE : Boolean := False; -- Pulse ON duration PON : FCR_PON_Field := 16#0#; -- Dead time duration DEAD : FCR_DEAD_Field := 16#0#; -- Contrast control CC : FCR_CC_Field := 16#0#; -- Blink frequency selection BLINKF : FCR_BLINKF_Field := 16#0#; -- Blink mode selection BLINK : FCR_BLINK_Field := 16#0#; -- DIV clock divider DIV : FCR_DIV_Field := 16#0#; -- PS 16-bit prescaler PS : FCR_PS_Field := 16#0#; -- unspecified Reserved_26_31 : HAL.UInt6 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for FCR_Register use record HD at 0 range 0 .. 0; SOFIE at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; UDDIE at 0 range 3 .. 3; PON at 0 range 4 .. 6; DEAD at 0 range 7 .. 9; CC at 0 range 10 .. 12; BLINKF at 0 range 13 .. 15; BLINK at 0 range 16 .. 17; DIV at 0 range 18 .. 21; PS at 0 range 22 .. 25; Reserved_26_31 at 0 range 26 .. 31; end record; -- status register type SR_Register is record -- Read-only. ENS ENS : Boolean := False; -- Read-only. Start of frame flag SOF : Boolean := False; -- Write-only. Update display request UDR : Boolean := False; -- Read-only. Update Display Done UDD : Boolean := False; -- Read-only. Ready flag RDY : Boolean := False; -- Read-only. LCD Frame Control Register Synchronization flag FCRSF : Boolean := True; -- unspecified Reserved_6_31 : HAL.UInt26 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SR_Register use record ENS at 0 range 0 .. 0; SOF at 0 range 1 .. 1; UDR at 0 range 2 .. 2; UDD at 0 range 3 .. 3; RDY at 0 range 4 .. 4; FCRSF at 0 range 5 .. 5; Reserved_6_31 at 0 range 6 .. 31; end record; -- clear register type CLR_Register is record -- unspecified Reserved_0_0 : HAL.Bit := 16#0#; -- Write-only. Start of frame flag clear SOFC : Boolean := False; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- Write-only. Update display done clear UDDC : Boolean := False; -- unspecified Reserved_4_31 : HAL.UInt28 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CLR_Register use record Reserved_0_0 at 0 range 0 .. 0; SOFC at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; UDDC at 0 range 3 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; -- RAM_COM0_S array type RAM_COM0_S_Field_Array is array (0 .. 30) of Boolean with Component_Size => 1, Size => 31; -- Type definition for RAM_COM0_S type RAM_COM0_S_Field (As_Array : Boolean := False) is record case As_Array is when False => -- S as a value Val : HAL.UInt31; when True => -- S as an array Arr : RAM_COM0_S_Field_Array; end case; end record with Unchecked_Union, Size => 31; for RAM_COM0_S_Field use record Val at 0 range 0 .. 30; Arr at 0 range 0 .. 30; end record; -- display memory type RAM_COM0_Register is record -- S00 S : RAM_COM0_S_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for RAM_COM0_Register use record S at 0 range 0 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; -- RAM_COM_S array type RAM_COM_S_Field_Array is array (0 .. 31) of Boolean with Component_Size => 1, Size => 32; -- display memory type RAM_COM_Register (As_Array : Boolean := False) is record case As_Array is when False => -- S as a value Val : HAL.UInt32; when True => -- S as an array Arr : RAM_COM_S_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for RAM_COM_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Liquid crystal display controller type LCD_Peripheral is record -- control register CR : aliased CR_Register; -- frame control register FCR : aliased FCR_Register; -- status register SR : aliased SR_Register; -- clear register CLR : aliased CLR_Register; -- display memory RAM_COM0 : aliased RAM_COM0_Register; -- display memory RAM_COM1 : aliased RAM_COM_Register; -- display memory RAM_COM2 : aliased RAM_COM_Register; -- display memory RAM_COM3 : aliased RAM_COM_Register; -- display memory RAM_COM4 : aliased RAM_COM_Register; -- display memory RAM_COM5 : aliased RAM_COM_Register; -- display memory RAM_COM6 : aliased RAM_COM_Register; -- display memory RAM_COM7 : aliased RAM_COM_Register; end record with Volatile; for LCD_Peripheral use record CR at 16#0# range 0 .. 31; FCR at 16#4# range 0 .. 31; SR at 16#8# range 0 .. 31; CLR at 16#C# range 0 .. 31; RAM_COM0 at 16#14# range 0 .. 31; RAM_COM1 at 16#1C# range 0 .. 31; RAM_COM2 at 16#24# range 0 .. 31; RAM_COM3 at 16#2C# range 0 .. 31; RAM_COM4 at 16#34# range 0 .. 31; RAM_COM5 at 16#3C# range 0 .. 31; RAM_COM6 at 16#44# range 0 .. 31; RAM_COM7 at 16#4C# range 0 .. 31; end record; -- Liquid crystal display controller LCD_Periph : aliased LCD_Peripheral with Import, Address => System'To_Address (16#40002400#); end STM32_SVD.LCD;
30,665
ada
488
ouankou/rose
src/frontend/Experimental_Ada_ROSE_Connection/parser/support/source/indented_text.ads
<gh_stars>100-1000 -- At the beginning of each line, puts out white space relative to the -- current indent. Emits Wide text: package Indented_Text is -------------------------------------------------------- -- Trace routines emit no output when Trace_On is False. At the moment, -- Indented_Text.Class output routines call these: procedure Trace_Put (Message : in Wide_String); procedure Trace_Put_Line (Message : in Wide_String); -- Controls behavior of Trace_ routines:: Trace_On : Boolean := False; -------------------------------------------------------- type Class is tagged private; type Access_Class is access Class; procedure Indent (This : in out Class); procedure Dedent (This : in out Class); -- Sets Line_In_Progress: procedure New_Line (This : in out Class); -- Puts a new line only if a line is in progress: -- Sets Line_In_Progress: procedure End_Line (This : in out Class); -- Prepends the indent if this is the first put on this line: procedure Put (This : in out Class; Message : in String); procedure Put (This : in out Class; Message : in Wide_String); -- Prepends the indent if this is the first put on this line: procedure Put_Indented_Line (This : in out Class; Message : in String); procedure Put_Indented_Line (This : in out Class; Message : in Wide_String); private -- Can't be limited because generic Asis.Iterator.Traverse_Element doesn't -- want limited state information: -- (In Asis_Adapter.Element) type Class is tagged -- Initialized record Line_In_Progress : Boolean := False; Indent_Level : Natural := 0; end record; -- Puts an indent only if a line is not in progress (no indent put yet): -- Sets Line_In_Progress: procedure Put_Indent_If_Needed (This : in out Class); function White_Space (This : in Class) return Wide_String; end Indented_Text;
30,666
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/trampoline3.adb
-- { dg-do compile { target *-*-linux* } } -- { dg-options "-gnatws" } procedure Trampoline3 is A : Integer; type FuncPtr is access function (I : Integer) return Integer; function F (I : Integer) return Integer is begin return A + I; end F; P : FuncPtr := F'Access; I : Integer; begin I := P(0); end; -- { dg-final { scan-assembler-not "GNU-stack.*x" } }
30,667
ada
24
svn2github/matreshka
source/amf/ocl/amf-factories-ocl_factories.ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-2013, <NAME> <<EMAIL>> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.OCL.Any_Types; with AMF.OCL.Association_Class_Call_Exps; with AMF.OCL.Bag_Types; with AMF.OCL.Boolean_Literal_Exps; with AMF.OCL.Collection_Items; with AMF.OCL.Collection_Literal_Exps; with AMF.OCL.Collection_Ranges; with AMF.OCL.Collection_Types; with AMF.OCL.Enum_Literal_Exps; with AMF.OCL.Expression_In_Ocls; with AMF.OCL.If_Exps; with AMF.OCL.Integer_Literal_Exps; with AMF.OCL.Invalid_Literal_Exps; with AMF.OCL.Invalid_Types; with AMF.OCL.Iterate_Exps; with AMF.OCL.Iterator_Exps; with AMF.OCL.Let_Exps; with AMF.OCL.Message_Exps; with AMF.OCL.Message_Types; with AMF.OCL.Null_Literal_Exps; with AMF.OCL.Operation_Call_Exps; with AMF.OCL.Ordered_Set_Types; with AMF.OCL.Property_Call_Exps; with AMF.OCL.Real_Literal_Exps; with AMF.OCL.Sequence_Types; with AMF.OCL.Set_Types; with AMF.OCL.State_Exps; with AMF.OCL.String_Literal_Exps; with AMF.OCL.Template_Parameter_Types; with AMF.OCL.Tuple_Literal_Exps; with AMF.OCL.Tuple_Literal_Parts; with AMF.OCL.Tuple_Types; with AMF.OCL.Type_Exps; with AMF.OCL.Unlimited_Natural_Literal_Exps; with AMF.OCL.Unspecified_Value_Exps; with AMF.OCL.Variable_Exps; with AMF.OCL.Variables; with AMF.OCL.Void_Types; package AMF.Factories.OCL_Factories is pragma Preelaborate; type OCL_Factory is limited interface and AMF.Factories.Factory; type OCL_Factory_Access is access all OCL_Factory'Class; for OCL_Factory_Access'Storage_Size use 0; not overriding function Create_Any_Type (Self : not null access OCL_Factory) return AMF.OCL.Any_Types.OCL_Any_Type_Access is abstract; not overriding function Create_Association_Class_Call_Exp (Self : not null access OCL_Factory) return AMF.OCL.Association_Class_Call_Exps.OCL_Association_Class_Call_Exp_Access is abstract; not overriding function Create_Bag_Type (Self : not null access OCL_Factory) return AMF.OCL.Bag_Types.OCL_Bag_Type_Access is abstract; not overriding function Create_Boolean_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.Boolean_Literal_Exps.OCL_Boolean_Literal_Exp_Access is abstract; not overriding function Create_Collection_Item (Self : not null access OCL_Factory) return AMF.OCL.Collection_Items.OCL_Collection_Item_Access is abstract; not overriding function Create_Collection_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.Collection_Literal_Exps.OCL_Collection_Literal_Exp_Access is abstract; not overriding function Create_Collection_Range (Self : not null access OCL_Factory) return AMF.OCL.Collection_Ranges.OCL_Collection_Range_Access is abstract; not overriding function Create_Collection_Type (Self : not null access OCL_Factory) return AMF.OCL.Collection_Types.OCL_Collection_Type_Access is abstract; not overriding function Create_Enum_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.Enum_Literal_Exps.OCL_Enum_Literal_Exp_Access is abstract; not overriding function Create_Expression_In_Ocl (Self : not null access OCL_Factory) return AMF.OCL.Expression_In_Ocls.OCL_Expression_In_Ocl_Access is abstract; not overriding function Create_If_Exp (Self : not null access OCL_Factory) return AMF.OCL.If_Exps.OCL_If_Exp_Access is abstract; not overriding function Create_Integer_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.Integer_Literal_Exps.OCL_Integer_Literal_Exp_Access is abstract; not overriding function Create_Invalid_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.Invalid_Literal_Exps.OCL_Invalid_Literal_Exp_Access is abstract; not overriding function Create_Invalid_Type (Self : not null access OCL_Factory) return AMF.OCL.Invalid_Types.OCL_Invalid_Type_Access is abstract; not overriding function Create_Iterate_Exp (Self : not null access OCL_Factory) return AMF.OCL.Iterate_Exps.OCL_Iterate_Exp_Access is abstract; not overriding function Create_Iterator_Exp (Self : not null access OCL_Factory) return AMF.OCL.Iterator_Exps.OCL_Iterator_Exp_Access is abstract; not overriding function Create_Let_Exp (Self : not null access OCL_Factory) return AMF.OCL.Let_Exps.OCL_Let_Exp_Access is abstract; not overriding function Create_Message_Exp (Self : not null access OCL_Factory) return AMF.OCL.Message_Exps.OCL_Message_Exp_Access is abstract; not overriding function Create_Message_Type (Self : not null access OCL_Factory) return AMF.OCL.Message_Types.OCL_Message_Type_Access is abstract; not overriding function Create_Null_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.Null_Literal_Exps.OCL_Null_Literal_Exp_Access is abstract; not overriding function Create_Operation_Call_Exp (Self : not null access OCL_Factory) return AMF.OCL.Operation_Call_Exps.OCL_Operation_Call_Exp_Access is abstract; not overriding function Create_Ordered_Set_Type (Self : not null access OCL_Factory) return AMF.OCL.Ordered_Set_Types.OCL_Ordered_Set_Type_Access is abstract; not overriding function Create_Property_Call_Exp (Self : not null access OCL_Factory) return AMF.OCL.Property_Call_Exps.OCL_Property_Call_Exp_Access is abstract; not overriding function Create_Real_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.Real_Literal_Exps.OCL_Real_Literal_Exp_Access is abstract; not overriding function Create_Sequence_Type (Self : not null access OCL_Factory) return AMF.OCL.Sequence_Types.OCL_Sequence_Type_Access is abstract; not overriding function Create_Set_Type (Self : not null access OCL_Factory) return AMF.OCL.Set_Types.OCL_Set_Type_Access is abstract; not overriding function Create_State_Exp (Self : not null access OCL_Factory) return AMF.OCL.State_Exps.OCL_State_Exp_Access is abstract; not overriding function Create_String_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.String_Literal_Exps.OCL_String_Literal_Exp_Access is abstract; not overriding function Create_Template_Parameter_Type (Self : not null access OCL_Factory) return AMF.OCL.Template_Parameter_Types.OCL_Template_Parameter_Type_Access is abstract; not overriding function Create_Tuple_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.Tuple_Literal_Exps.OCL_Tuple_Literal_Exp_Access is abstract; not overriding function Create_Tuple_Literal_Part (Self : not null access OCL_Factory) return AMF.OCL.Tuple_Literal_Parts.OCL_Tuple_Literal_Part_Access is abstract; not overriding function Create_Tuple_Type (Self : not null access OCL_Factory) return AMF.OCL.Tuple_Types.OCL_Tuple_Type_Access is abstract; not overriding function Create_Type_Exp (Self : not null access OCL_Factory) return AMF.OCL.Type_Exps.OCL_Type_Exp_Access is abstract; not overriding function Create_Unlimited_Natural_Literal_Exp (Self : not null access OCL_Factory) return AMF.OCL.Unlimited_Natural_Literal_Exps.OCL_Unlimited_Natural_Literal_Exp_Access is abstract; not overriding function Create_Unspecified_Value_Exp (Self : not null access OCL_Factory) return AMF.OCL.Unspecified_Value_Exps.OCL_Unspecified_Value_Exp_Access is abstract; not overriding function Create_Variable (Self : not null access OCL_Factory) return AMF.OCL.Variables.OCL_Variable_Access is abstract; not overriding function Create_Variable_Exp (Self : not null access OCL_Factory) return AMF.OCL.Variable_Exps.OCL_Variable_Exp_Access is abstract; not overriding function Create_Void_Type (Self : not null access OCL_Factory) return AMF.OCL.Void_Types.OCL_Void_Type_Access is abstract; end AMF.Factories.OCL_Factories;
30,668
ada
0
reznikmm/gela
source/nodes/program-nodes-index_constraints.adb
<filename>source/nodes/program-nodes-index_constraints.adb<gh_stars>0 -- SPDX-FileCopyrightText: 2019 <NAME> <<EMAIL>> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- package body Program.Nodes.Index_Constraints is function Create (Left_Bracket_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Ranges : not null Program.Elements.Discrete_Ranges .Discrete_Range_Vector_Access; Right_Bracket_Token : not null Program.Lexical_Elements .Lexical_Element_Access) return Index_Constraint is begin return Result : Index_Constraint := (Left_Bracket_Token => Left_Bracket_Token, Ranges => Ranges, Right_Bracket_Token => Right_Bracket_Token, Enclosing_Element => null) do Initialize (Result); end return; end Create; function Create (Ranges : not null Program.Elements.Discrete_Ranges .Discrete_Range_Vector_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False) return Implicit_Index_Constraint is begin return Result : Implicit_Index_Constraint := (Ranges => Ranges, Is_Part_Of_Implicit => Is_Part_Of_Implicit, Is_Part_Of_Inherited => Is_Part_Of_Inherited, Is_Part_Of_Instance => Is_Part_Of_Instance, Enclosing_Element => null) do Initialize (Result); end return; end Create; overriding function Ranges (Self : Base_Index_Constraint) return not null Program.Elements.Discrete_Ranges .Discrete_Range_Vector_Access is begin return Self.Ranges; end Ranges; overriding function Left_Bracket_Token (Self : Index_Constraint) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Left_Bracket_Token; end Left_Bracket_Token; overriding function Right_Bracket_Token (Self : Index_Constraint) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Right_Bracket_Token; end Right_Bracket_Token; overriding function Is_Part_Of_Implicit (Self : Implicit_Index_Constraint) return Boolean is begin return Self.Is_Part_Of_Implicit; end Is_Part_Of_Implicit; overriding function Is_Part_Of_Inherited (Self : Implicit_Index_Constraint) return Boolean is begin return Self.Is_Part_Of_Inherited; end Is_Part_Of_Inherited; overriding function Is_Part_Of_Instance (Self : Implicit_Index_Constraint) return Boolean is begin return Self.Is_Part_Of_Instance; end Is_Part_Of_Instance; procedure Initialize (Self : in out Base_Index_Constraint'Class) is begin for Item in Self.Ranges.Each_Element loop Set_Enclosing_Element (Item.Element, Self'Unchecked_Access); end loop; null; end Initialize; overriding function Is_Index_Constraint (Self : Base_Index_Constraint) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Index_Constraint; overriding function Is_Constraint (Self : Base_Index_Constraint) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Constraint; overriding function Is_Definition (Self : Base_Index_Constraint) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Definition; overriding procedure Visit (Self : not null access Base_Index_Constraint; Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is begin Visitor.Index_Constraint (Self); end Visit; overriding function To_Index_Constraint_Text (Self : in out Index_Constraint) return Program.Elements.Index_Constraints.Index_Constraint_Text_Access is begin return Self'Unchecked_Access; end To_Index_Constraint_Text; overriding function To_Index_Constraint_Text (Self : in out Implicit_Index_Constraint) return Program.Elements.Index_Constraints.Index_Constraint_Text_Access is pragma Unreferenced (Self); begin return null; end To_Index_Constraint_Text; end Program.Nodes.Index_Constraints;
30,669
ada
0
reznikmm/gela
source/library/program-unit_naming.ads
<reponame>reznikmm/gela<filename>source/library/program-unit_naming.ads<gh_stars>0 -- SPDX-FileCopyrightText: 2020 <NAME> <<EMAIL>> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- -- -- This package provides Unit_Naming_Schema interface and its methods. package Program.Unit_Naming is pragma Preelaborate; type Unit_Naming_Schema is limited interface; -- Interface to get compilation Text_Name for given compilation unit. type Unit_Naming_Schema_Access is access all Unit_Naming_Schema'Class; for Unit_Naming_Schema_Access'Storage_Size use 0; not overriding function Standard_Text_Name (Self : Unit_Naming_Schema) return Text is abstract; -- Get compilation Text_Name for Standard library package. not overriding function Declaration_Text_Name (Self : Unit_Naming_Schema; Name : Program.Text) return Text is abstract; -- Get compilation Text_Name for given library declaration unit. not overriding function Body_Text_Name (Self : Unit_Naming_Schema; Name : Program.Text) return Text is abstract; -- Get compilation Text_Name for given body. not overriding function Subunit_Text_Name (Self : Unit_Naming_Schema; Name : Program.Text) return Text is abstract; -- Get compilation Text_Name for given subunit. end Program.Unit_Naming;
30,670
ada
1
vidkidz/crossbridge
llvm-gcc-4.2-2.9/gcc/ada/osint.adb
<reponame>vidkidz/crossbridge<gh_stars>1-10 ------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- O S I N T -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2006, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Fmap; use Fmap; with Gnatvsn; use Gnatvsn; with Hostparm; with Namet; use Namet; with Opt; use Opt; with Output; use Output; with Sdefault; use Sdefault; with Table; with Targparm; use Targparm; with System.Case_Util; use System.Case_Util; with Unchecked_Conversion; with GNAT.HTable; package body Osint is Running_Program : Program_Type := Unspecified; -- comment required here ??? Program_Set : Boolean := False; -- comment required here ??? Std_Prefix : String_Ptr; -- Standard prefix, computed dynamically the first time Relocate_Path -- is called, and cached for subsequent calls. Empty : aliased String := ""; No_Dir : constant String_Ptr := Empty'Access; -- Used in Locate_File as a fake directory when Name is already an -- absolute path. ------------------------------------- -- Use of Name_Find and Name_Enter -- ------------------------------------- -- This package creates a number of source, ALI and object file names -- that are used to locate the actual file and for the purpose of -- message construction. These names need not be accessible by Name_Find, -- and can be therefore created by using routine Name_Enter. The files in -- question are file names with a prefix directory (ie the files not -- in the current directory). File names without a prefix directory are -- entered with Name_Find because special values might be attached to -- the various Info fields of the corresponding name table entry. ----------------------- -- Local Subprograms -- ----------------------- function Append_Suffix_To_File_Name (Name : Name_Id; Suffix : String) return Name_Id; -- Appends Suffix to Name and returns the new name function OS_Time_To_GNAT_Time (T : OS_Time) return Time_Stamp_Type; -- Convert OS format time to GNAT format time stamp function Concat (String_One : String; String_Two : String) return String; -- Concatenates 2 strings and returns the result of the concatenation function Executable_Prefix return String_Ptr; -- Returns the name of the root directory where the executable is stored. -- The executable must be located in a directory called "bin", or -- under root/lib/gcc-lib/..., or under root/libexec/gcc/... Thus, if -- the executable is stored in directory "/foo/bar/bin", this routine -- returns "/foo/bar/". Return "" if the location is not recognized -- as described above. function Update_Path (Path : String_Ptr) return String_Ptr; -- Update the specified path to replace the prefix with the location -- where GNAT is installed. See the file prefix.c in GCC for details. procedure Write_With_Check (A : Address; N : Integer); -- Writes N bytes from buffer starting at address A to file whose FD is -- stored in Output_FD, and whose file name is stored as a File_Name_Type -- in Output_File_Name. A check is made for disk full, and if this is -- detected, the file being written is deleted, and a fatal error is -- signalled. function Locate_File (N : File_Name_Type; T : File_Type; Dir : Natural; Name : String) return File_Name_Type; -- See if the file N whose name is Name exists in directory Dir. Dir is -- an index into the Lib_Search_Directories table if T = Library. -- Otherwise if T = Source, Dir is an index into the -- Src_Search_Directories table. Returns the File_Name_Type of the -- full file name if file found, or No_File if not found. function C_String_Length (S : Address) return Integer; -- Returns length of a C string. Returns zero for a null address function To_Path_String_Access (Path_Addr : Address; Path_Len : Integer) return String_Access; -- Converts a C String to an Ada String. Are we doing this to avoid -- withing Interfaces.C.Strings ??? ------------------------------ -- Other Local Declarations -- ------------------------------ EOL : constant Character := ASCII.LF; -- End of line character Number_File_Names : Int := 0; -- The total number of file names found on command line and placed in -- File_Names. Look_In_Primary_Directory_For_Current_Main : Boolean := False; -- When this variable is True, Find_File will only look in -- the Primary_Directory for the Current_Main file. -- This variable is always True for the compiler. -- It is also True for gnatmake, when the soucr name given -- on the command line has directory information. Current_Full_Source_Name : File_Name_Type := No_File; Current_Full_Source_Stamp : Time_Stamp_Type := Empty_Time_Stamp; Current_Full_Lib_Name : File_Name_Type := No_File; Current_Full_Lib_Stamp : Time_Stamp_Type := Empty_Time_Stamp; Current_Full_Obj_Name : File_Name_Type := No_File; Current_Full_Obj_Stamp : Time_Stamp_Type := Empty_Time_Stamp; -- Respectively full name (with directory info) and time stamp of -- the latest source, library and object files opened by Read_Source_File -- and Read_Library_Info. ------------------ -- Search Paths -- ------------------ Primary_Directory : constant := 0; -- This is index in the tables created below for the first directory to -- search in for source or library information files. This is the -- directory containing the latest main input file (a source file for -- the compiler or a library file for the binder). package Src_Search_Directories is new Table.Table ( Table_Component_Type => String_Ptr, Table_Index_Type => Natural, Table_Low_Bound => Primary_Directory, Table_Initial => 10, Table_Increment => 100, Table_Name => "Osint.Src_Search_Directories"); -- Table of names of directories in which to search for source (Compiler) -- files. This table is filled in the order in which the directories are -- to be searched, and then used in that order. package Lib_Search_Directories is new Table.Table ( Table_Component_Type => String_Ptr, Table_Index_Type => Natural, Table_Low_Bound => Primary_Directory, Table_Initial => 10, Table_Increment => 100, Table_Name => "Osint.Lib_Search_Directories"); -- Table of names of directories in which to search for library (Binder) -- files. This table is filled in the order in which the directories are -- to be searched and then used in that order. The reason for having two -- distinct tables is that we need them both in gnatmake. --------------------- -- File Hash Table -- --------------------- -- The file hash table is provided to free the programmer from any -- efficiency concern when retrieving full file names or time stamps of -- source files. If the programmer calls Source_File_Data (Cache => True) -- he is guaranteed that the price to retrieve the full name (ie with -- directory info) or time stamp of the file will be payed only once, -- the first time the full name is actually searched (or the first time -- the time stamp is actually retrieved). This is achieved by employing -- a hash table that stores as a key the File_Name_Type of the file and -- associates to that File_Name_Type the full file name of the file and its -- time stamp. File_Cache_Enabled : Boolean := False; -- Set to true if you want the enable the file data caching mechanism type File_Hash_Num is range 0 .. 1020; function File_Hash (F : File_Name_Type) return File_Hash_Num; -- Compute hash index for use by Simple_HTable package File_Name_Hash_Table is new GNAT.HTable.Simple_HTable ( Header_Num => File_Hash_Num, Element => File_Name_Type, No_Element => No_File, Key => File_Name_Type, Hash => File_Hash, Equal => "="); package File_Stamp_Hash_Table is new GNAT.HTable.Simple_HTable ( Header_Num => File_Hash_Num, Element => Time_Stamp_Type, No_Element => Empty_Time_Stamp, Key => File_Name_Type, Hash => File_Hash, Equal => "="); function Smart_Find_File (N : File_Name_Type; T : File_Type) return File_Name_Type; -- Exactly like Find_File except that if File_Cache_Enabled is True this -- routine looks first in the hash table to see if the full name of the -- file is already available. function Smart_File_Stamp (N : File_Name_Type; T : File_Type) return Time_Stamp_Type; -- Takes the same parameter as the routine above (N is a file name -- without any prefix directory information) and behaves like File_Stamp -- except that if File_Cache_Enabled is True this routine looks first in -- the hash table to see if the file stamp of the file is already -- available. ----------------------------- -- Add_Default_Search_Dirs -- ----------------------------- procedure Add_Default_Search_Dirs is Search_Dir : String_Access; Search_Path : String_Access; Path_File_Name : String_Access; procedure Add_Search_Dir (Search_Dir : String; Additional_Source_Dir : Boolean); procedure Add_Search_Dir (Search_Dir : String_Access; Additional_Source_Dir : Boolean); -- Add a source search dir or a library search dir, depending on the -- value of Additional_Source_Dir. procedure Get_Dirs_From_File (Additional_Source_Dir : Boolean); -- Open a path file and read the directory to search, one per line function Get_Libraries_From_Registry return String_Ptr; -- On Windows systems, get the list of installed standard libraries -- from the registry key: -- HKEY_LOCAL_MACHINE\SOFTWARE\Ada Core Technologies\ -- GNAT\Standard Libraries -- Return an empty string on other systems -------------------- -- Add_Search_Dir -- -------------------- procedure Add_Search_Dir (Search_Dir : String; Additional_Source_Dir : Boolean) is begin if Additional_Source_Dir then Add_Src_Search_Dir (Search_Dir); else Add_Lib_Search_Dir (Search_Dir); end if; end Add_Search_Dir; procedure Add_Search_Dir (Search_Dir : String_Access; Additional_Source_Dir : Boolean) is begin if Additional_Source_Dir then Add_Src_Search_Dir (Search_Dir.all); else Add_Lib_Search_Dir (Search_Dir.all); end if; end Add_Search_Dir; ------------------------ -- Get_Dirs_From_File -- ------------------------ procedure Get_Dirs_From_File (Additional_Source_Dir : Boolean) is File_FD : File_Descriptor; Buffer : String (1 .. Path_File_Name'Length + 1); Len : Natural; Actual_Len : Natural; S : String_Access; Curr : Natural; First : Natural; Ch : Character; Status : Boolean; -- For the call to Close begin -- Construct a C compatible character string buffer Buffer (1 .. Buffer'Last - 1) := Path_File_Name.all; Buffer (Buffer'Last) := ASCII.NUL; File_FD := Open_Read (Buffer'Address, Binary); -- If we cannot open the file, we ignore it, we don't fail if File_FD = Invalid_FD then return; end if; Len := Integer (File_Length (File_FD)); S := new String (1 .. Len); -- Read the file. Note that the loop is not necessary since the -- whole file is read at once except on VMS. Curr := 1; Actual_Len := Len; while Curr <= Len and then Actual_Len /= 0 loop Actual_Len := Read (File_FD, S (Curr)'Address, Len); Curr := Curr + Actual_Len; end loop; -- We are done with the file, so we close it Close (File_FD, Status); -- We ignore any error here, because we have successfully read the -- file. -- Now, we read line by line First := 1; Curr := 0; while Curr < Len loop Ch := S (Curr + 1); if Ch = ASCII.CR or else Ch = ASCII.LF or else Ch = ASCII.FF or else Ch = ASCII.VT then if First <= Curr then Add_Search_Dir (S (First .. Curr), Additional_Source_Dir); end if; First := Curr + 2; end if; Curr := Curr + 1; end loop; -- Last line is a special case, if the file does not end with -- an end of line mark. if First <= S'Last then Add_Search_Dir (S (First .. S'Last), Additional_Source_Dir); end if; end Get_Dirs_From_File; --------------------------------- -- Get_Libraries_From_Registry -- --------------------------------- function Get_Libraries_From_Registry return String_Ptr is function C_Get_Libraries_From_Registry return Address; pragma Import (C, C_Get_Libraries_From_Registry, "__gnat_get_libraries_from_registry"); function Strlen (Str : Address) return Integer; pragma Import (C, Strlen, "strlen"); procedure Strncpy (X : Address; Y : Address; Length : Integer); pragma Import (C, Strncpy, "strncpy"); Result_Ptr : Address; Result_Length : Integer; Out_String : String_Ptr; begin Result_Ptr := C_Get_Libraries_From_Registry; Result_Length := Strlen (Result_Ptr); Out_String := new String (1 .. Result_Length); Strncpy (Out_String.all'Address, Result_Ptr, Result_Length); return Out_String; end Get_Libraries_From_Registry; -- Start of processing for Add_Default_Search_Dirs begin -- After the locations specified on the command line, the next places -- to look for files are the directories specified by the appropriate -- environment variable. Get this value, extract the directory names -- and store in the tables. -- Check for eventual project path file env vars Path_File_Name := Getenv (Project_Include_Path_File); if Path_File_Name'Length > 0 then Get_Dirs_From_File (Additional_Source_Dir => True); end if; Path_File_Name := Getenv (Project_Objects_Path_File); if Path_File_Name'Length > 0 then Get_Dirs_From_File (Additional_Source_Dir => False); end if; -- On VMS, don't expand the logical name (e.g. environment variable), -- just put it into Unix (e.g. canonical) format. System services -- will handle the expansion as part of the file processing. for Additional_Source_Dir in False .. True loop if Additional_Source_Dir then Search_Path := Getenv (Ada_Include_Path); if Search_Path'Length > 0 then if Hostparm.OpenVMS then Search_Path := To_Canonical_Path_Spec ("ADA_INCLUDE_PATH:"); else Search_Path := To_Canonical_Path_Spec (Search_Path.all); end if; end if; else Search_Path := Getenv (Ada_Objects_Path); if Search_Path'Length > 0 then if Hostparm.OpenVMS then Search_Path := To_Canonical_Path_Spec ("ADA_OBJECTS_PATH:"); else Search_Path := To_Canonical_Path_Spec (Search_Path.all); end if; end if; end if; Get_Next_Dir_In_Path_Init (Search_Path); loop Search_Dir := Get_Next_Dir_In_Path (Search_Path); exit when Search_Dir = null; Add_Search_Dir (Search_Dir, Additional_Source_Dir); end loop; end loop; -- For the compiler, if --RTS= was specified, add the runtime -- directories. if RTS_Src_Path_Name /= null and then RTS_Lib_Path_Name /= null then Add_Search_Dirs (RTS_Src_Path_Name, Include); Add_Search_Dirs (RTS_Lib_Path_Name, Objects); else if not Opt.No_Stdinc then -- For WIN32 systems, look for any system libraries defined in -- the registry. These are added to both source and object -- directories. Search_Path := String_Access (Get_Libraries_From_Registry); Get_Next_Dir_In_Path_Init (Search_Path); loop Search_Dir := Get_Next_Dir_In_Path (Search_Path); exit when Search_Dir = null; Add_Search_Dir (Search_Dir, False); Add_Search_Dir (Search_Dir, True); end loop; -- The last place to look are the defaults Search_Path := Read_Default_Search_Dirs (String_Access (Update_Path (Search_Dir_Prefix)), Include_Search_File, String_Access (Update_Path (Include_Dir_Default_Name))); Get_Next_Dir_In_Path_Init (Search_Path); loop Search_Dir := Get_Next_Dir_In_Path (Search_Path); exit when Search_Dir = null; Add_Search_Dir (Search_Dir, True); end loop; end if; if not Opt.No_Stdlib and not Opt.RTS_Switch then Search_Path := Read_Default_Search_Dirs (String_Access (Update_Path (Search_Dir_Prefix)), Objects_Search_File, String_Access (Update_Path (Object_Dir_Default_Name))); Get_Next_Dir_In_Path_Init (Search_Path); loop Search_Dir := Get_Next_Dir_In_Path (Search_Path); exit when Search_Dir = null; Add_Search_Dir (Search_Dir, False); end loop; end if; end if; end Add_Default_Search_Dirs; -------------- -- Add_File -- -------------- procedure Add_File (File_Name : String; Index : Int := No_Index) is begin Number_File_Names := Number_File_Names + 1; -- As Add_File may be called for mains specified inside -- a project file, File_Names may be too short and needs -- to be extended. if Number_File_Names > File_Names'Last then File_Names := new File_Name_Array'(File_Names.all & File_Names.all); File_Indexes := new File_Index_Array'(File_Indexes.all & File_Indexes.all); end if; File_Names (Number_File_Names) := new String'(File_Name); File_Indexes (Number_File_Names) := Index; end Add_File; ------------------------ -- Add_Lib_Search_Dir -- ------------------------ procedure Add_Lib_Search_Dir (Dir : String) is begin if Dir'Length = 0 then Fail ("missing library directory name"); end if; Lib_Search_Directories.Increment_Last; Lib_Search_Directories.Table (Lib_Search_Directories.Last) := Normalize_Directory_Name (Dir); end Add_Lib_Search_Dir; --------------------- -- Add_Search_Dirs -- --------------------- procedure Add_Search_Dirs (Search_Path : String_Ptr; Path_Type : Search_File_Type) is Current_Search_Path : String_Access; begin Get_Next_Dir_In_Path_Init (String_Access (Search_Path)); loop Current_Search_Path := Get_Next_Dir_In_Path (String_Access (Search_Path)); exit when Current_Search_Path = null; if Path_Type = Include then Add_Src_Search_Dir (Current_Search_Path.all); else Add_Lib_Search_Dir (Current_Search_Path.all); end if; end loop; end Add_Search_Dirs; ------------------------ -- Add_Src_Search_Dir -- ------------------------ procedure Add_Src_Search_Dir (Dir : String) is begin if Dir'Length = 0 then Fail ("missing source directory name"); end if; Src_Search_Directories.Increment_Last; Src_Search_Directories.Table (Src_Search_Directories.Last) := Normalize_Directory_Name (Dir); end Add_Src_Search_Dir; -------------------------------- -- Append_Suffix_To_File_Name -- -------------------------------- function Append_Suffix_To_File_Name (Name : Name_Id; Suffix : String) return Name_Id is begin Get_Name_String (Name); Name_Buffer (Name_Len + 1 .. Name_Len + Suffix'Length) := Suffix; Name_Len := Name_Len + Suffix'Length; return Name_Find; end Append_Suffix_To_File_Name; --------------------- -- C_String_Length -- --------------------- function C_String_Length (S : Address) return Integer is function Strlen (S : Address) return Integer; pragma Import (C, Strlen, "strlen"); begin if S = Null_Address then return 0; else return Strlen (S); end if; end C_String_Length; ------------------------------ -- Canonical_Case_File_Name -- ------------------------------ -- For now, we only deal with the case of a-z. Eventually we should -- worry about other Latin-1 letters on systems that support this ??? procedure Canonical_Case_File_Name (S : in out String) is begin if not File_Names_Case_Sensitive then for J in S'Range loop if S (J) in 'A' .. 'Z' then S (J) := Character'Val ( Character'Pos (S (J)) + Character'Pos ('a') - Character'Pos ('A')); end if; end loop; end if; end Canonical_Case_File_Name; ------------ -- Concat -- ------------ function Concat (String_One : String; String_Two : String) return String is Buffer : String (1 .. String_One'Length + String_Two'Length); begin Buffer (1 .. String_One'Length) := String_One; Buffer (String_One'Length + 1 .. Buffer'Last) := String_Two; return Buffer; end Concat; --------------------------- -- Create_File_And_Check -- --------------------------- procedure Create_File_And_Check (Fdesc : out File_Descriptor; Fmode : Mode) is begin Output_File_Name := Name_Enter; Fdesc := Create_File (Name_Buffer'Address, Fmode); if Fdesc = Invalid_FD then Fail ("Cannot create: ", Name_Buffer (1 .. Name_Len)); end if; end Create_File_And_Check; ------------------------ -- Current_File_Index -- ------------------------ function Current_File_Index return Int is begin return File_Indexes (Current_File_Name_Index); end Current_File_Index; -------------------------------- -- Current_Library_File_Stamp -- -------------------------------- function Current_Library_File_Stamp return Time_Stamp_Type is begin return Current_Full_Lib_Stamp; end Current_Library_File_Stamp; ------------------------------- -- Current_Object_File_Stamp -- ------------------------------- function Current_Object_File_Stamp return Time_Stamp_Type is begin return Current_Full_Obj_Stamp; end Current_Object_File_Stamp; ------------------------------- -- Current_Source_File_Stamp -- ------------------------------- function Current_Source_File_Stamp return Time_Stamp_Type is begin return Current_Full_Source_Stamp; end Current_Source_File_Stamp; ---------------------------- -- Dir_In_Obj_Search_Path -- ---------------------------- function Dir_In_Obj_Search_Path (Position : Natural) return String_Ptr is begin if Opt.Look_In_Primary_Dir then return Lib_Search_Directories.Table (Primary_Directory + Position - 1); else return Lib_Search_Directories.Table (Primary_Directory + Position); end if; end Dir_In_Obj_Search_Path; ---------------------------- -- Dir_In_Src_Search_Path -- ---------------------------- function Dir_In_Src_Search_Path (Position : Natural) return String_Ptr is begin if Opt.Look_In_Primary_Dir then return Src_Search_Directories.Table (Primary_Directory + Position - 1); else return Src_Search_Directories.Table (Primary_Directory + Position); end if; end Dir_In_Src_Search_Path; --------------------- -- Executable_Name -- --------------------- function Executable_Name (Name : File_Name_Type) return File_Name_Type is Exec_Suffix : String_Access; begin if Name = No_File then return No_File; end if; Get_Name_String (Name); Exec_Suffix := Get_Executable_Suffix; for J in Exec_Suffix'Range loop Name_Len := Name_Len + 1; Name_Buffer (Name_Len) := Exec_Suffix (J); end loop; Free (Exec_Suffix); return Name_Enter; end Executable_Name; ----------------------- -- Executable_Prefix -- ----------------------- function Executable_Prefix return String_Ptr is function Get_Install_Dir (Exec : String) return String_Ptr; -- S is the executable name preceeded by the absolute or relative -- path, e.g. "c:\usr\bin\gcc.exe" or "..\bin\gcc". --------------------- -- Get_Install_Dir -- --------------------- function Get_Install_Dir (Exec : String) return String_Ptr is begin for J in reverse Exec'Range loop if Is_Directory_Separator (Exec (J)) then if J < Exec'Last - 5 then if (To_Lower (Exec (J + 1)) = 'l' and then To_Lower (Exec (J + 2)) = 'i' and then To_Lower (Exec (J + 3)) = 'b') or else (To_Lower (Exec (J + 1)) = 'b' and then To_Lower (Exec (J + 2)) = 'i' and then To_Lower (Exec (J + 3)) = 'n') then return new String'(Exec (Exec'First .. J)); end if; end if; end if; end loop; return new String'(""); end Get_Install_Dir; -- Start of processing for Executable_Prefix begin if Exec_Name = null then Exec_Name := new String (1 .. Len_Arg (0)); Osint.Fill_Arg (Exec_Name (1)'Address, 0); end if; -- First determine if a path prefix was placed in front of the -- executable name. for J in reverse Exec_Name'Range loop if Is_Directory_Separator (Exec_Name (J)) then return Get_Install_Dir (Exec_Name.all); end if; end loop; -- If we come here, the user has typed the executable name with no -- directory prefix. return Get_Install_Dir (GNAT.OS_Lib.Locate_Exec_On_Path (Exec_Name.all).all); end Executable_Prefix; ------------------ -- Exit_Program -- ------------------ procedure Exit_Program (Exit_Code : Exit_Code_Type) is begin -- The program will exit with the following status: -- 0 if the object file has been generated (with or without warnings) -- 1 if recompilation was not needed (smart recompilation) -- 2 if gnat1 has been killed by a signal (detected by GCC) -- 4 for a fatal error -- 5 if there were errors -- 6 if no code has been generated (spec) -- Note that exit code 3 is not used and must not be used as this is -- the code returned by a program aborted via C abort() routine on -- Windows. GCC checks for that case and thinks that the child process -- has been aborted. This code (exit code 3) used to be the code used -- for E_No_Code, but E_No_Code was changed to 6 for this reason. case Exit_Code is when E_Success => OS_Exit (0); when E_Warnings => OS_Exit (0); when E_No_Compile => OS_Exit (1); when E_Fatal => OS_Exit (4); when E_Errors => OS_Exit (5); when E_No_Code => OS_Exit (6); when E_Abort => OS_Abort; end case; end Exit_Program; ---------- -- Fail -- ---------- procedure Fail (S1 : String; S2 : String := ""; S3 : String := "") is begin -- We use Output in case there is a special output set up. -- In this case Set_Standard_Error will have no immediate effect. Set_Standard_Error; Osint.Write_Program_Name; Write_Str (": "); Write_Str (S1); Write_Str (S2); Write_Str (S3); Write_Eol; Exit_Program (E_Fatal); end Fail; --------------- -- File_Hash -- --------------- function File_Hash (F : File_Name_Type) return File_Hash_Num is begin return File_Hash_Num (Int (F) rem File_Hash_Num'Range_Length); end File_Hash; ---------------- -- File_Stamp -- ---------------- function File_Stamp (Name : File_Name_Type) return Time_Stamp_Type is begin if Name = No_File then return Empty_Time_Stamp; end if; Get_Name_String (Name); if not Is_Regular_File (Name_Buffer (1 .. Name_Len)) then return Empty_Time_Stamp; else Name_Buffer (Name_Len + 1) := ASCII.NUL; return OS_Time_To_GNAT_Time (File_Time_Stamp (Name_Buffer)); end if; end File_Stamp; --------------- -- Find_File -- --------------- function Find_File (N : File_Name_Type; T : File_Type) return File_Name_Type is begin Get_Name_String (N); declare File_Name : String renames Name_Buffer (1 .. Name_Len); File : File_Name_Type := No_File; Last_Dir : Natural; begin -- If we are looking for a config file, look only in the current -- directory, i.e. return input argument unchanged. Also look -- only in the current directory if we are looking for a .dg -- file (happens in -gnatD mode) if T = Config or else (Debug_Generated_Code and then Name_Len > 3 and then (Name_Buffer (Name_Len - 2 .. Name_Len) = ".dg" or else (Hostparm.OpenVMS and then Name_Buffer (Name_Len - 2 .. Name_Len) = "_dg"))) then return N; -- If we are trying to find the current main file just look in the -- directory where the user said it was. elsif Look_In_Primary_Directory_For_Current_Main and then Current_Main = N then return Locate_File (N, T, Primary_Directory, File_Name); -- Otherwise do standard search for source file else -- Check the mapping of this file name File := Mapped_Path_Name (N); -- If the file name is mapped to a path name, return the -- corresponding path name if File /= No_File then -- For locally removed file, Error_Name is returned; then -- return No_File, indicating the file is not a source. if File = Error_Name then return No_File; else return File; end if; end if; -- First place to look is in the primary directory (i.e. the same -- directory as the source) unless this has been disabled with -I- if Opt.Look_In_Primary_Dir then File := Locate_File (N, T, Primary_Directory, File_Name); if File /= No_File then return File; end if; end if; -- Finally look in directories specified with switches -I/-aI/-aO if T = Library then Last_Dir := Lib_Search_Directories.Last; else Last_Dir := Src_Search_Directories.Last; end if; for D in Primary_Directory + 1 .. Last_Dir loop File := Locate_File (N, T, D, File_Name); if File /= No_File then return File; end if; end loop; return No_File; end if; end; end Find_File; ----------------------- -- Find_Program_Name -- ----------------------- procedure Find_Program_Name is Command_Name : String (1 .. Len_Arg (0)); Cindex1 : Integer := Command_Name'First; Cindex2 : Integer := Command_Name'Last; begin Fill_Arg (Command_Name'Address, 0); -- The program name might be specified by a full path name. However, -- we don't want to print that all out in an error message, so the -- path might need to be stripped away. for J in reverse Cindex1 .. Cindex2 loop if Is_Directory_Separator (Command_Name (J)) then Cindex1 := J + 1; exit; end if; end loop; -- Command_Name(Cindex1 .. Cindex2) is now the equivalent of the -- POSIX command "basename argv[0]" -- Strip off any versioning information such as found on VMS. -- This would take the form of TOOL.exe followed by a ";" or "." -- and a sequence of one or more numbers. if Command_Name (Cindex2) in '0' .. '9' then for J in reverse Cindex1 .. Cindex2 loop if Command_Name (J) = '.' or Command_Name (J) = ';' then Cindex2 := J - 1; exit; end if; exit when Command_Name (J) not in '0' .. '9'; end loop; end if; -- Strip off any executable extension (usually nothing or .exe) -- but formally reported by autoconf in the variable EXEEXT if Cindex2 - Cindex1 >= 4 then if To_Lower (Command_Name (Cindex2 - 3)) = '.' and then To_Lower (Command_Name (Cindex2 - 2)) = 'e' and then To_Lower (Command_Name (Cindex2 - 1)) = 'x' and then To_Lower (Command_Name (Cindex2)) = 'e' then Cindex2 := Cindex2 - 4; end if; end if; Name_Len := Cindex2 - Cindex1 + 1; Name_Buffer (1 .. Name_Len) := Command_Name (Cindex1 .. Cindex2); end Find_Program_Name; ------------------------ -- Full_Lib_File_Name -- ------------------------ function Full_Lib_File_Name (N : File_Name_Type) return File_Name_Type is begin return Find_File (N, Library); end Full_Lib_File_Name; ---------------------------- -- Full_Library_Info_Name -- ---------------------------- function Full_Library_Info_Name return File_Name_Type is begin return Current_Full_Lib_Name; end Full_Library_Info_Name; --------------------------- -- Full_Object_File_Name -- --------------------------- function Full_Object_File_Name return File_Name_Type is begin return Current_Full_Obj_Name; end Full_Object_File_Name; ---------------------- -- Full_Source_Name -- ---------------------- function Full_Source_Name return File_Name_Type is begin return Current_Full_Source_Name; end Full_Source_Name; ---------------------- -- Full_Source_Name -- ---------------------- function Full_Source_Name (N : File_Name_Type) return File_Name_Type is begin return Smart_Find_File (N, Source); end Full_Source_Name; ------------------- -- Get_Directory -- ------------------- function Get_Directory (Name : File_Name_Type) return File_Name_Type is begin Get_Name_String (Name); for J in reverse 1 .. Name_Len loop if Is_Directory_Separator (Name_Buffer (J)) then Name_Len := J; return Name_Find; end if; end loop; Name_Len := Hostparm.Normalized_CWD'Length; Name_Buffer (1 .. Name_Len) := Hostparm.Normalized_CWD; return Name_Find; end Get_Directory; -------------------------- -- Get_Next_Dir_In_Path -- -------------------------- Search_Path_Pos : Integer; -- Keeps track of current position in search path. Initialized by the -- call to Get_Next_Dir_In_Path_Init, updated by Get_Next_Dir_In_Path. function Get_Next_Dir_In_Path (Search_Path : String_Access) return String_Access is Lower_Bound : Positive := Search_Path_Pos; Upper_Bound : Positive; begin loop while Lower_Bound <= Search_Path'Last and then Search_Path.all (Lower_Bound) = Path_Separator loop Lower_Bound := Lower_Bound + 1; end loop; exit when Lower_Bound > Search_Path'Last; Upper_Bound := Lower_Bound; while Upper_Bound <= Search_Path'Last and then Search_Path.all (Upper_Bound) /= Path_Separator loop Upper_Bound := Upper_Bound + 1; end loop; Search_Path_Pos := Upper_Bound; return new String'(Search_Path.all (Lower_Bound .. Upper_Bound - 1)); end loop; return null; end Get_Next_Dir_In_Path; ------------------------------- -- Get_Next_Dir_In_Path_Init -- ------------------------------- procedure Get_Next_Dir_In_Path_Init (Search_Path : String_Access) is begin Search_Path_Pos := Search_Path'First; end Get_Next_Dir_In_Path_Init; -------------------------------------- -- Get_Primary_Src_Search_Directory -- -------------------------------------- function Get_Primary_Src_Search_Directory return String_Ptr is begin return Src_Search_Directories.Table (Primary_Directory); end Get_Primary_Src_Search_Directory; ------------------------ -- Get_RTS_Search_Dir -- ------------------------ function Get_RTS_Search_Dir (Search_Dir : String; File_Type : Search_File_Type) return String_Ptr is procedure Get_Current_Dir (Dir : System.Address; Length : System.Address); pragma Import (C, Get_Current_Dir, "__gnat_get_current_dir"); Max_Path : Integer; pragma Import (C, Max_Path, "__gnat_max_path_len"); -- Maximum length of a path name Current_Dir : String_Ptr; Default_Search_Dir : String_Access; Default_Suffix_Dir : String_Access; Local_Search_Dir : String_Access; Norm_Search_Dir : String_Access; Result_Search_Dir : String_Access; Search_File : String_Access; Temp_String : String_Ptr; begin -- Add a directory separator at the end of the directory if necessary -- so that we can directly append a file to the directory if Search_Dir (Search_Dir'Last) /= Directory_Separator then Local_Search_Dir := new String' (Concat (Search_Dir, String'(1 => Directory_Separator))); else Local_Search_Dir := new String'(Search_Dir); end if; if File_Type = Include then Search_File := Include_Search_File; Default_Suffix_Dir := new String'("adainclude"); else Search_File := Objects_Search_File; Default_Suffix_Dir := new String'("adalib"); end if; Norm_Search_Dir := To_Canonical_Path_Spec (Local_Search_Dir.all); if Is_Absolute_Path (Norm_Search_Dir.all) then -- We first verify if there is a directory Include_Search_Dir -- containing default search directories Result_Search_Dir := Read_Default_Search_Dirs (Norm_Search_Dir, Search_File, null); Default_Search_Dir := new String' (Concat (Norm_Search_Dir.all, Default_Suffix_Dir.all)); Free (Norm_Search_Dir); if Result_Search_Dir /= null then return String_Ptr (Result_Search_Dir); elsif Is_Directory (Default_Search_Dir.all) then return String_Ptr (Default_Search_Dir); else return null; end if; -- Search in the current directory else -- Get the current directory declare Buffer : String (1 .. Max_Path + 2); Path_Len : Natural := Max_Path; begin Get_Current_Dir (Buffer'Address, Path_Len'Address); if Buffer (Path_Len) /= Directory_Separator then Path_Len := Path_Len + 1; Buffer (Path_Len) := Directory_Separator; end if; Current_Dir := new String'(Buffer (1 .. Path_Len)); end; Norm_Search_Dir := new String'(Concat (Current_Dir.all, Local_Search_Dir.all)); Result_Search_Dir := Read_Default_Search_Dirs (Norm_Search_Dir, Search_File, null); Default_Search_Dir := new String' (Concat (Norm_Search_Dir.all, Default_Suffix_Dir.all)); Free (Norm_Search_Dir); if Result_Search_Dir /= null then return String_Ptr (Result_Search_Dir); elsif Is_Directory (Default_Search_Dir.all) then return String_Ptr (Default_Search_Dir); else -- Search in Search_Dir_Prefix/Search_Dir Norm_Search_Dir := new String' (Concat (Update_Path (Search_Dir_Prefix).all, Local_Search_Dir.all)); Result_Search_Dir := Read_Default_Search_Dirs (Norm_Search_Dir, Search_File, null); Default_Search_Dir := new String' (Concat (Norm_Search_Dir.all, Default_Suffix_Dir.all)); Free (Norm_Search_Dir); if Result_Search_Dir /= null then return String_Ptr (Result_Search_Dir); elsif Is_Directory (Default_Search_Dir.all) then return String_Ptr (Default_Search_Dir); else -- We finally search in Search_Dir_Prefix/rts-Search_Dir Temp_String := new String' (Concat (Update_Path (Search_Dir_Prefix).all, "rts-")); Norm_Search_Dir := new String'(Concat (Temp_String.all, Local_Search_Dir.all)); Result_Search_Dir := Read_Default_Search_Dirs (Norm_Search_Dir, Search_File, null); Default_Search_Dir := new String' (Concat (Norm_Search_Dir.all, Default_Suffix_Dir.all)); Free (Norm_Search_Dir); if Result_Search_Dir /= null then return String_Ptr (Result_Search_Dir); elsif Is_Directory (Default_Search_Dir.all) then return String_Ptr (Default_Search_Dir); else return null; end if; end if; end if; end if; end Get_RTS_Search_Dir; -------------------------------- -- Include_Dir_Default_Prefix -- -------------------------------- function Include_Dir_Default_Prefix return String is Include_Dir : String_Access := String_Access (Update_Path (Include_Dir_Default_Name)); begin if Include_Dir = null then return ""; else declare Result : constant String := Include_Dir.all; begin Free (Include_Dir); return Result; end; end if; end Include_Dir_Default_Prefix; ---------------- -- Initialize -- ---------------- procedure Initialize is begin Number_File_Names := 0; Current_File_Name_Index := 0; Src_Search_Directories.Init; Lib_Search_Directories.Init; -- Start off by setting all suppress options to False, these will -- be reset later (turning some on if -gnato is not specified, and -- turning all of them on if -gnatp is specified). Suppress_Options := (others => False); -- Reserve the first slot in the search paths table. This is the -- directory of the main source file or main library file and is -- filled in by each call to Next_Main_Source/Next_Main_Lib_File with -- the directory specified for this main source or library file. This -- is the directory which is searched first by default. This default -- search is inhibited by the option -I- for both source and library -- files. Src_Search_Directories.Set_Last (Primary_Directory); Src_Search_Directories.Table (Primary_Directory) := new String'(""); Lib_Search_Directories.Set_Last (Primary_Directory); Lib_Search_Directories.Table (Primary_Directory) := new String'(""); end Initialize; ---------------------------- -- Is_Directory_Separator -- ---------------------------- function Is_Directory_Separator (C : Character) return Boolean is begin -- In addition to the default directory_separator allow the '/' to -- act as separator since this is allowed in MS-DOS, Windows 95/NT, -- and OS2 ports. On VMS, the situation is more complicated because -- there are two characters to check for. return C = Directory_Separator or else C = '/' or else (Hostparm.OpenVMS and then (C = ']' or else C = ':')); end Is_Directory_Separator; ------------------------- -- Is_Readonly_Library -- ------------------------- function Is_Readonly_Library (File : File_Name_Type) return Boolean is begin Get_Name_String (File); pragma Assert (Name_Buffer (Name_Len - 3 .. Name_Len) = ".ali"); return not Is_Writable_File (Name_Buffer (1 .. Name_Len)); end Is_Readonly_Library; ------------------- -- Lib_File_Name -- ------------------- function Lib_File_Name (Source_File : File_Name_Type; Munit_Index : Nat := 0) return File_Name_Type is begin Get_Name_String (Source_File); for J in reverse 2 .. Name_Len loop if Name_Buffer (J) = '.' then Name_Len := J - 1; exit; end if; end loop; if Munit_Index /= 0 then Add_Char_To_Name_Buffer (Multi_Unit_Index_Character); Add_Nat_To_Name_Buffer (Munit_Index); end if; Add_Char_To_Name_Buffer ('.'); Add_Str_To_Name_Buffer (ALI_Suffix.all); return Name_Find; end Lib_File_Name; ------------------------ -- Library_File_Stamp -- ------------------------ function Library_File_Stamp (N : File_Name_Type) return Time_Stamp_Type is begin return File_Stamp (Find_File (N, Library)); end Library_File_Stamp; ----------------- -- Locate_File -- ----------------- function Locate_File (N : File_Name_Type; T : File_Type; Dir : Natural; Name : String) return File_Name_Type is Dir_Name : String_Ptr; begin -- If Name is already an absolute path, do not look for a directory if Is_Absolute_Path (Name) then Dir_Name := No_Dir; elsif T = Library then Dir_Name := Lib_Search_Directories.Table (Dir); else pragma Assert (T /= Config); Dir_Name := Src_Search_Directories.Table (Dir); end if; declare Full_Name : String (1 .. Dir_Name'Length + Name'Length); begin Full_Name (1 .. Dir_Name'Length) := Dir_Name.all; Full_Name (Dir_Name'Length + 1 .. Full_Name'Length) := Name; if not Is_Regular_File (Full_Name) then return No_File; else -- If the file is in the current directory then return N itself if Dir_Name'Length = 0 then return N; else Name_Len := Full_Name'Length; Name_Buffer (1 .. Name_Len) := Full_Name; return Name_Enter; end if; end if; end; end Locate_File; ------------------------------- -- Matching_Full_Source_Name -- ------------------------------- function Matching_Full_Source_Name (N : File_Name_Type; T : Time_Stamp_Type) return File_Name_Type is begin Get_Name_String (N); declare File_Name : constant String := Name_Buffer (1 .. Name_Len); File : File_Name_Type := No_File; Last_Dir : Natural; begin if Opt.Look_In_Primary_Dir then File := Locate_File (N, Source, Primary_Directory, File_Name); if File /= No_File and then T = File_Stamp (N) then return File; end if; end if; Last_Dir := Src_Search_Directories.Last; for D in Primary_Directory + 1 .. Last_Dir loop File := Locate_File (N, Source, D, File_Name); if File /= No_File and then T = File_Stamp (File) then return File; end if; end loop; return No_File; end; end Matching_Full_Source_Name; ---------------- -- More_Files -- ---------------- function More_Files return Boolean is begin return (Current_File_Name_Index < Number_File_Names); end More_Files; ------------------------------- -- Nb_Dir_In_Obj_Search_Path -- ------------------------------- function Nb_Dir_In_Obj_Search_Path return Natural is begin if Opt.Look_In_Primary_Dir then return Lib_Search_Directories.Last - Primary_Directory + 1; else return Lib_Search_Directories.Last - Primary_Directory; end if; end Nb_Dir_In_Obj_Search_Path; ------------------------------- -- Nb_Dir_In_Src_Search_Path -- ------------------------------- function Nb_Dir_In_Src_Search_Path return Natural is begin if Opt.Look_In_Primary_Dir then return Src_Search_Directories.Last - Primary_Directory + 1; else return Src_Search_Directories.Last - Primary_Directory; end if; end Nb_Dir_In_Src_Search_Path; -------------------- -- Next_Main_File -- -------------------- function Next_Main_File return File_Name_Type is File_Name : String_Ptr; Dir_Name : String_Ptr; Fptr : Natural; begin pragma Assert (More_Files); Current_File_Name_Index := Current_File_Name_Index + 1; -- Get the file and directory name File_Name := File_Names (Current_File_Name_Index); Fptr := File_Name'First; for J in reverse File_Name'Range loop if File_Name (J) = Directory_Separator or else File_Name (J) = '/' then if J = File_Name'Last then Fail ("File name missing"); end if; Fptr := J + 1; exit; end if; end loop; -- Save name of directory in which main unit resides for use in -- locating other units Dir_Name := new String'(File_Name (File_Name'First .. Fptr - 1)); case Running_Program is when Compiler => Src_Search_Directories.Table (Primary_Directory) := Dir_Name; Look_In_Primary_Directory_For_Current_Main := True; when Make => Src_Search_Directories.Table (Primary_Directory) := Dir_Name; if Fptr > File_Name'First then Look_In_Primary_Directory_For_Current_Main := True; end if; when Binder | Gnatls => Dir_Name := Normalize_Directory_Name (Dir_Name.all); Lib_Search_Directories.Table (Primary_Directory) := Dir_Name; when Unspecified => null; end case; Name_Len := File_Name'Last - Fptr + 1; Name_Buffer (1 .. Name_Len) := File_Name (Fptr .. File_Name'Last); Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len)); Current_Main := File_Name_Type (Name_Find); -- In the gnatmake case, the main file may have not have the -- extension. Try ".adb" first then ".ads" if Running_Program = Make then declare Orig_Main : constant File_Name_Type := Current_Main; begin if Strip_Suffix (Orig_Main) = Orig_Main then Current_Main := Append_Suffix_To_File_Name (Orig_Main, ".adb"); if Full_Source_Name (Current_Main) = No_File then Current_Main := Append_Suffix_To_File_Name (Orig_Main, ".ads"); if Full_Source_Name (Current_Main) = No_File then Current_Main := Orig_Main; end if; end if; end if; end; end if; return Current_Main; end Next_Main_File; ------------------------------ -- Normalize_Directory_Name -- ------------------------------ function Normalize_Directory_Name (Directory : String) return String_Ptr is function Is_Quoted (Path : String) return Boolean; pragma Inline (Is_Quoted); -- Returns true if Path is quoted (either double or single quotes) --------------- -- Is_Quoted -- --------------- function Is_Quoted (Path : String) return Boolean is First : constant Character := Path (Path'First); Last : constant Character := Path (Path'Last); begin if (First = ''' and then Last = ''') or else (First = '"' and then Last = '"') then return True; else return False; end if; end Is_Quoted; Result : String_Ptr; -- Start of processing for Normalize_Directory_Name begin if Directory'Length = 0 then Result := new String'(Hostparm.Normalized_CWD); elsif Is_Directory_Separator (Directory (Directory'Last)) then Result := new String'(Directory); elsif Is_Quoted (Directory) then -- This is a quoted string, it certainly means that the directory -- contains some spaces for example. We can safely remove the quotes -- here as the OS_Lib.Normalize_Arguments will be called before any -- spawn routines. This ensure that quotes will be added when needed. Result := new String (1 .. Directory'Length - 1); Result (1 .. Directory'Length - 1) := Directory (Directory'First + 1 .. Directory'Last - 1); Result (Result'Last) := Directory_Separator; else Result := new String (1 .. Directory'Length + 1); Result (1 .. Directory'Length) := Directory; Result (Directory'Length + 1) := Directory_Separator; end if; return Result; end Normalize_Directory_Name; --------------------- -- Number_Of_Files -- --------------------- function Number_Of_Files return Int is begin return Number_File_Names; end Number_Of_Files; ------------------------------- -- Object_Dir_Default_Prefix -- ------------------------------- function Object_Dir_Default_Prefix return String is Object_Dir : String_Access := String_Access (Update_Path (Object_Dir_Default_Name)); begin if Object_Dir = null then return ""; else declare Result : constant String := Object_Dir.all; begin Free (Object_Dir); return Result; end; end if; end Object_Dir_Default_Prefix; ---------------------- -- Object_File_Name -- ---------------------- function Object_File_Name (N : File_Name_Type) return File_Name_Type is begin if N = No_File then return No_File; end if; Get_Name_String (N); Name_Len := Name_Len - ALI_Suffix'Length - 1; for J in Target_Object_Suffix'Range loop Name_Len := Name_Len + 1; Name_Buffer (Name_Len) := Target_Object_Suffix (J); end loop; return Name_Enter; end Object_File_Name; -------------------------- -- OS_Time_To_GNAT_Time -- -------------------------- function OS_Time_To_GNAT_Time (T : OS_Time) return Time_Stamp_Type is GNAT_Time : Time_Stamp_Type; Y : Year_Type; Mo : Month_Type; D : Day_Type; H : Hour_Type; Mn : Minute_Type; S : Second_Type; begin GM_Split (T, Y, Mo, D, H, Mn, S); Make_Time_Stamp (Year => Nat (Y), Month => Nat (Mo), Day => Nat (D), Hour => Nat (H), Minutes => Nat (Mn), Seconds => Nat (S), TS => GNAT_Time); return GNAT_Time; end OS_Time_To_GNAT_Time; ------------------ -- Program_Name -- ------------------ function Program_Name (Nam : String) return String_Access is Res : String_Access; begin -- Get the name of the current program being executed Find_Program_Name; -- Find the target prefix if any, for the cross compilation case -- for instance in "alpha-dec-vxworks-gcc" the target prefix is -- "alpha-dec-vxworks-" while Name_Len > 0 loop -- All done if we find the last hyphen if Name_Buffer (Name_Len) = '-' then exit; -- If directory separator found, we don't want to look further -- since in this case, no prefix has been found. elsif Is_Directory_Separator (Name_Buffer (Name_Len)) then Name_Len := 0; exit; end if; Name_Len := Name_Len - 1; end loop; -- Create the new program name Res := new String (1 .. Name_Len + Nam'Length); Res.all (1 .. Name_Len) := Name_Buffer (1 .. Name_Len); Res.all (Name_Len + 1 .. Name_Len + Nam'Length) := Nam; return Res; end Program_Name; ------------------------------ -- Read_Default_Search_Dirs -- ------------------------------ function Read_Default_Search_Dirs (Search_Dir_Prefix : String_Access; Search_File : String_Access; Search_Dir_Default_Name : String_Access) return String_Access is Prefix_Len : constant Integer := Search_Dir_Prefix.all'Length; Buffer : String (1 .. Prefix_Len + Search_File.all'Length + 1); File_FD : File_Descriptor; S, S1 : String_Access; Len : Integer; Curr : Integer; Actual_Len : Integer; J1 : Integer; Prev_Was_Separator : Boolean; Nb_Relative_Dir : Integer; function Is_Relative (S : String; K : Positive) return Boolean; pragma Inline (Is_Relative); -- Returns True if a relative directory specification is found -- in S at position K, False otherwise. ----------------- -- Is_Relative -- ----------------- function Is_Relative (S : String; K : Positive) return Boolean is begin return not Is_Absolute_Path (S (K .. S'Last)); end Is_Relative; -- Start of processing for Read_Default_Search_Dirs begin -- Construct a C compatible character string buffer Buffer (1 .. Search_Dir_Prefix.all'Length) := Search_Dir_Prefix.all; Buffer (Search_Dir_Prefix.all'Length + 1 .. Buffer'Last - 1) := Search_File.all; Buffer (Buffer'Last) := ASCII.NUL; File_FD := Open_Read (Buffer'Address, Binary); if File_FD = Invalid_FD then return Search_Dir_Default_Name; end if; Len := Integer (File_Length (File_FD)); -- An extra character for a trailing Path_Separator is allocated S := new String (1 .. Len + 1); S (Len + 1) := Path_Separator; -- Read the file. Note that the loop is not necessary since the -- whole file is read at once except on VMS. Curr := 1; Actual_Len := Len; while Actual_Len /= 0 loop Actual_Len := Read (File_FD, S (Curr)'Address, Len); Curr := Curr + Actual_Len; end loop; -- Process the file, translating line and file ending -- control characters to a path separator character. Prev_Was_Separator := True; Nb_Relative_Dir := 0; for J in 1 .. Len loop if S (J) in ASCII.NUL .. ASCII.US or else S (J) = ' ' then S (J) := Path_Separator; end if; if S (J) = Path_Separator then Prev_Was_Separator := True; else if Prev_Was_Separator and then Is_Relative (S.all, J) then Nb_Relative_Dir := Nb_Relative_Dir + 1; end if; Prev_Was_Separator := False; end if; end loop; if Nb_Relative_Dir = 0 then return S; end if; -- Add the Search_Dir_Prefix to all relative paths S1 := new String (1 .. S'Length + Nb_Relative_Dir * Prefix_Len); J1 := 1; Prev_Was_Separator := True; for J in 1 .. Len + 1 loop if S (J) = Path_Separator then Prev_Was_Separator := True; else if Prev_Was_Separator and then Is_Relative (S.all, J) then S1 (J1 .. J1 + Prefix_Len - 1) := Search_Dir_Prefix.all; J1 := J1 + Prefix_Len; end if; Prev_Was_Separator := False; end if; S1 (J1) := S (J); J1 := J1 + 1; end loop; Free (S); return S1; end Read_Default_Search_Dirs; ----------------------- -- Read_Library_Info -- ----------------------- function Read_Library_Info (Lib_File : File_Name_Type; Fatal_Err : Boolean := False) return Text_Buffer_Ptr is Lib_FD : File_Descriptor; -- The file descriptor for the current library file. A negative value -- indicates failure to open the specified source file. Text : Text_Buffer_Ptr; -- Allocated text buffer Status : Boolean; -- For the calls to Close begin Current_Full_Lib_Name := Find_File (Lib_File, Library); Current_Full_Obj_Name := Object_File_Name (Current_Full_Lib_Name); if Current_Full_Lib_Name = No_File then if Fatal_Err then Fail ("Cannot find: ", Name_Buffer (1 .. Name_Len)); else Current_Full_Obj_Stamp := Empty_Time_Stamp; return null; end if; end if; Get_Name_String (Current_Full_Lib_Name); Name_Buffer (Name_Len + 1) := ASCII.NUL; -- Open the library FD, note that we open in binary mode, because as -- documented in the spec, the caller is expected to handle either -- DOS or Unix mode files, and there is no point in wasting time on -- text translation when it is not required. Lib_FD := Open_Read (Name_Buffer'Address, Binary); if Lib_FD = Invalid_FD then if Fatal_Err then Fail ("Cannot open: ", Name_Buffer (1 .. Name_Len)); else Current_Full_Obj_Stamp := Empty_Time_Stamp; return null; end if; end if; -- Check for object file consistency if requested if Opt.Check_Object_Consistency then Current_Full_Lib_Stamp := File_Stamp (Current_Full_Lib_Name); Current_Full_Obj_Stamp := File_Stamp (Current_Full_Obj_Name); if Current_Full_Obj_Stamp (1) = ' ' then -- When the library is readonly, always assume that -- the object is consistent. if Is_Readonly_Library (Current_Full_Lib_Name) then Current_Full_Obj_Stamp := Current_Full_Lib_Stamp; elsif Fatal_Err then Get_Name_String (Current_Full_Obj_Name); Close (Lib_FD, Status); -- No need to check the status, we fail anyway Fail ("Cannot find: ", Name_Buffer (1 .. Name_Len)); else Current_Full_Obj_Stamp := Empty_Time_Stamp; Close (Lib_FD, Status); -- No need to check the status, we return null anyway return null; end if; end if; end if; -- Read data from the file declare Len : constant Integer := Integer (File_Length (Lib_FD)); -- Length of source file text. If it doesn't fit in an integer -- we're probably stuck anyway (>2 gigs of source seems a lot!) Actual_Len : Integer := 0; Lo : constant Text_Ptr := 0; -- Low bound for allocated text buffer Hi : Text_Ptr := Text_Ptr (Len); -- High bound for allocated text buffer. Note length is Len + 1 -- which allows for extra EOF character at the end of the buffer. begin -- Allocate text buffer. Note extra character at end for EOF Text := new Text_Buffer (Lo .. Hi); -- Some systems (e.g. VMS) have file types that require one -- read per line, so read until we get the Len bytes or until -- there are no more characters. Hi := Lo; loop Actual_Len := Read (Lib_FD, Text (Hi)'Address, Len); Hi := Hi + Text_Ptr (Actual_Len); exit when Actual_Len = Len or Actual_Len <= 0; end loop; Text (Hi) := EOF; end; -- Read is complete, close file and we are done Close (Lib_FD, Status); -- The status should never be False. But, if it is, what can we do? -- So, we don't test it. return Text; end Read_Library_Info; ---------------------- -- Read_Source_File -- ---------------------- procedure Read_Source_File (N : File_Name_Type; Lo : Source_Ptr; Hi : out Source_Ptr; Src : out Source_Buffer_Ptr; T : File_Type := Source) is Source_File_FD : File_Descriptor; -- The file descriptor for the current source file. A negative value -- indicates failure to open the specified source file. Len : Integer; -- Length of file. Assume no more than 2 gigabytes of source! Actual_Len : Integer; Status : Boolean; -- For the call to Close -- LLVM local pragma Warnings (Off, Status); begin Current_Full_Source_Name := Find_File (N, T); Current_Full_Source_Stamp := File_Stamp (Current_Full_Source_Name); if Current_Full_Source_Name = No_File then -- If we were trying to access the main file and we could not -- find it we have an error. if N = Current_Main then Get_Name_String (N); Fail ("Cannot find: ", Name_Buffer (1 .. Name_Len)); end if; Src := null; Hi := No_Location; return; end if; Get_Name_String (Current_Full_Source_Name); Name_Buffer (Name_Len + 1) := ASCII.NUL; -- Open the source FD, note that we open in binary mode, because as -- documented in the spec, the caller is expected to handle either -- DOS or Unix mode files, and there is no point in wasting time on -- text translation when it is not required. Source_File_FD := Open_Read (Name_Buffer'Address, Binary); if Source_File_FD = Invalid_FD then Src := null; Hi := No_Location; return; end if; -- Prepare to read data from the file Len := Integer (File_Length (Source_File_FD)); -- Set Hi so that length is one more than the physical length, -- allowing for the extra EOF character at the end of the buffer Hi := Lo + Source_Ptr (Len); -- Do the actual read operation declare subtype Actual_Source_Buffer is Source_Buffer (Lo .. Hi); -- Physical buffer allocated type Actual_Source_Ptr is access Actual_Source_Buffer; -- This is the pointer type for the physical buffer allocated Actual_Ptr : constant Actual_Source_Ptr := new Actual_Source_Buffer; -- And this is the actual physical buffer begin -- Allocate source buffer, allowing extra character at end for EOF -- Some systems (e.g. VMS) have file types that require one -- read per line, so read until we get the Len bytes or until -- there are no more characters. Hi := Lo; loop Actual_Len := Read (Source_File_FD, Actual_Ptr (Hi)'Address, Len); Hi := Hi + Source_Ptr (Actual_Len); exit when Actual_Len = Len or Actual_Len <= 0; end loop; Actual_Ptr (Hi) := EOF; -- Now we need to work out the proper virtual origin pointer to -- return. This is exactly Actual_Ptr (0)'Address, but we have -- to be careful to suppress checks to compute this address. declare pragma Suppress (All_Checks); pragma Warnings (Off); -- This use of unchecked conversion is aliasing safe function To_Source_Buffer_Ptr is new Unchecked_Conversion (Address, Source_Buffer_Ptr); pragma Warnings (On); begin Src := To_Source_Buffer_Ptr (Actual_Ptr (0)'Address); end; end; -- Read is complete, get time stamp and close file and we are done Close (Source_File_FD, Status); -- The status should never be False. But, if it is, what can we do? -- So, we don't test it. end Read_Source_File; ------------------- -- Relocate_Path -- ------------------- function Relocate_Path (Prefix : String; Path : String) return String_Ptr is S : String_Ptr; procedure set_std_prefix (S : String; Len : Integer); pragma Import (C, set_std_prefix); begin if Std_Prefix = null then Std_Prefix := Executable_Prefix; if Std_Prefix.all /= "" then -- Remove trailing directory separator when calling set_std_prefix set_std_prefix (Std_Prefix.all, Std_Prefix'Length - 1); end if; end if; if Path (Prefix'Range) = Prefix then if Std_Prefix.all /= "" then S := new String (1 .. Std_Prefix'Length + Path'Last - Prefix'Last); S (1 .. Std_Prefix'Length) := Std_Prefix.all; S (Std_Prefix'Length + 1 .. S'Last) := Path (Prefix'Last + 1 .. Path'Last); return S; end if; end if; return new String'(Path); end Relocate_Path; ----------------- -- Set_Program -- ----------------- procedure Set_Program (P : Program_Type) is begin if Program_Set then Fail ("Set_Program called twice"); end if; Program_Set := True; Running_Program := P; end Set_Program; ---------------- -- Shared_Lib -- ---------------- function Shared_Lib (Name : String) return String is Library : String (1 .. Name'Length + Library_Version'Length + 3); -- 3 = 2 for "-l" + 1 for "-" before lib version begin Library (1 .. 2) := "-l"; Library (3 .. 2 + Name'Length) := Name; Library (3 + Name'Length) := '-'; Library (4 + Name'Length .. Library'Last) := Library_Version; if OpenVMS_On_Target then for K in Library'First + 2 .. Library'Last loop if Library (K) = '.' or else Library (K) = '-' then Library (K) := '_'; end if; end loop; end if; return Library; end Shared_Lib; ---------------------- -- Smart_File_Stamp -- ---------------------- function Smart_File_Stamp (N : File_Name_Type; T : File_Type) return Time_Stamp_Type is Time_Stamp : Time_Stamp_Type; begin if not File_Cache_Enabled then return File_Stamp (Find_File (N, T)); end if; Time_Stamp := File_Stamp_Hash_Table.Get (N); if Time_Stamp (1) = ' ' then Time_Stamp := File_Stamp (Smart_Find_File (N, T)); File_Stamp_Hash_Table.Set (N, Time_Stamp); end if; return Time_Stamp; end Smart_File_Stamp; --------------------- -- Smart_Find_File -- --------------------- function Smart_Find_File (N : File_Name_Type; T : File_Type) return File_Name_Type is Full_File_Name : File_Name_Type; begin if not File_Cache_Enabled then return Find_File (N, T); end if; Full_File_Name := File_Name_Hash_Table.Get (N); if Full_File_Name = No_File then Full_File_Name := Find_File (N, T); File_Name_Hash_Table.Set (N, Full_File_Name); end if; return Full_File_Name; end Smart_Find_File; ---------------------- -- Source_File_Data -- ---------------------- procedure Source_File_Data (Cache : Boolean) is begin File_Cache_Enabled := Cache; end Source_File_Data; ----------------------- -- Source_File_Stamp -- ----------------------- function Source_File_Stamp (N : File_Name_Type) return Time_Stamp_Type is begin return Smart_File_Stamp (N, Source); end Source_File_Stamp; --------------------- -- Strip_Directory -- --------------------- function Strip_Directory (Name : File_Name_Type) return File_Name_Type is begin Get_Name_String (Name); for J in reverse 1 .. Name_Len - 1 loop -- If we find the last directory separator if Is_Directory_Separator (Name_Buffer (J)) then -- Return the part of Name that follows this last directory -- separator. Name_Buffer (1 .. Name_Len - J) := Name_Buffer (J + 1 .. Name_Len); Name_Len := Name_Len - J; return Name_Find; end if; end loop; -- There were no directory separator, just return Name return Name; end Strip_Directory; ------------------ -- Strip_Suffix -- ------------------ function Strip_Suffix (Name : File_Name_Type) return File_Name_Type is begin Get_Name_String (Name); for J in reverse 2 .. Name_Len loop -- If we found the last '.', return part of Name that precedes it if Name_Buffer (J) = '.' then Name_Len := J - 1; return Name_Enter; end if; end loop; return Name; end Strip_Suffix; --------------------------- -- To_Canonical_Dir_Spec -- --------------------------- function To_Canonical_Dir_Spec (Host_Dir : String; Prefix_Style : Boolean) return String_Access is function To_Canonical_Dir_Spec (Host_Dir : Address; Prefix_Flag : Integer) return Address; pragma Import (C, To_Canonical_Dir_Spec, "__gnat_to_canonical_dir_spec"); C_Host_Dir : String (1 .. Host_Dir'Length + 1); Canonical_Dir_Addr : Address; Canonical_Dir_Len : Integer; begin C_Host_Dir (1 .. Host_Dir'Length) := Host_Dir; C_Host_Dir (C_Host_Dir'Last) := ASCII.NUL; if Prefix_Style then Canonical_Dir_Addr := To_Canonical_Dir_Spec (C_Host_Dir'Address, 1); else Canonical_Dir_Addr := To_Canonical_Dir_Spec (C_Host_Dir'Address, 0); end if; Canonical_Dir_Len := C_String_Length (Canonical_Dir_Addr); if Canonical_Dir_Len = 0 then return null; else return To_Path_String_Access (Canonical_Dir_Addr, Canonical_Dir_Len); end if; exception when others => Fail ("erroneous directory spec: ", Host_Dir); return null; end To_Canonical_Dir_Spec; --------------------------- -- To_Canonical_File_List -- --------------------------- function To_Canonical_File_List (Wildcard_Host_File : String; Only_Dirs : Boolean) return String_Access_List_Access is function To_Canonical_File_List_Init (Host_File : Address; Only_Dirs : Integer) return Integer; pragma Import (C, To_Canonical_File_List_Init, "__gnat_to_canonical_file_list_init"); function To_Canonical_File_List_Next return Address; pragma Import (C, To_Canonical_File_List_Next, "__gnat_to_canonical_file_list_next"); procedure To_Canonical_File_List_Free; pragma Import (C, To_Canonical_File_List_Free, "__gnat_to_canonical_file_list_free"); Num_Files : Integer; C_Wildcard_Host_File : String (1 .. Wildcard_Host_File'Length + 1); begin C_Wildcard_Host_File (1 .. Wildcard_Host_File'Length) := Wildcard_Host_File; C_Wildcard_Host_File (C_Wildcard_Host_File'Last) := ASCII.NUL; -- Do the expansion and say how many there are Num_Files := To_Canonical_File_List_Init (C_Wildcard_Host_File'Address, Boolean'Pos (Only_Dirs)); declare Canonical_File_List : String_Access_List (1 .. Num_Files); Canonical_File_Addr : Address; Canonical_File_Len : Integer; begin -- Retrieve the expanded directoy names and build the list for J in 1 .. Num_Files loop Canonical_File_Addr := To_Canonical_File_List_Next; Canonical_File_Len := C_String_Length (Canonical_File_Addr); Canonical_File_List (J) := To_Path_String_Access (Canonical_File_Addr, Canonical_File_Len); end loop; -- Free up the storage To_Canonical_File_List_Free; return new String_Access_List'(Canonical_File_List); end; end To_Canonical_File_List; ---------------------------- -- To_Canonical_File_Spec -- ---------------------------- function To_Canonical_File_Spec (Host_File : String) return String_Access is function To_Canonical_File_Spec (Host_File : Address) return Address; pragma Import (C, To_Canonical_File_Spec, "__gnat_to_canonical_file_spec"); C_Host_File : String (1 .. Host_File'Length + 1); Canonical_File_Addr : Address; Canonical_File_Len : Integer; begin C_Host_File (1 .. Host_File'Length) := Host_File; C_Host_File (C_Host_File'Last) := ASCII.NUL; Canonical_File_Addr := To_Canonical_File_Spec (C_Host_File'Address); Canonical_File_Len := C_String_Length (Canonical_File_Addr); if Canonical_File_Len = 0 then return null; else return To_Path_String_Access (Canonical_File_Addr, Canonical_File_Len); end if; exception when others => Fail ("erroneous file spec: ", Host_File); return null; end To_Canonical_File_Spec; ---------------------------- -- To_Canonical_Path_Spec -- ---------------------------- function To_Canonical_Path_Spec (Host_Path : String) return String_Access is function To_Canonical_Path_Spec (Host_Path : Address) return Address; pragma Import (C, To_Canonical_Path_Spec, "__gnat_to_canonical_path_spec"); C_Host_Path : String (1 .. Host_Path'Length + 1); Canonical_Path_Addr : Address; Canonical_Path_Len : Integer; begin C_Host_Path (1 .. Host_Path'Length) := Host_Path; C_Host_Path (C_Host_Path'Last) := ASCII.NUL; Canonical_Path_Addr := To_Canonical_Path_Spec (C_Host_Path'Address); Canonical_Path_Len := C_String_Length (Canonical_Path_Addr); -- Return a null string (vice a null) for zero length paths, for -- compatibility with getenv(). return To_Path_String_Access (Canonical_Path_Addr, Canonical_Path_Len); exception when others => Fail ("erroneous path spec: ", Host_Path); return null; end To_Canonical_Path_Spec; --------------------------- -- To_Host_Dir_Spec -- --------------------------- function To_Host_Dir_Spec (Canonical_Dir : String; Prefix_Style : Boolean) return String_Access is function To_Host_Dir_Spec (Canonical_Dir : Address; Prefix_Flag : Integer) return Address; pragma Import (C, To_Host_Dir_Spec, "__gnat_to_host_dir_spec"); C_Canonical_Dir : String (1 .. Canonical_Dir'Length + 1); Host_Dir_Addr : Address; Host_Dir_Len : Integer; begin C_Canonical_Dir (1 .. Canonical_Dir'Length) := Canonical_Dir; C_Canonical_Dir (C_Canonical_Dir'Last) := ASCII.NUL; if Prefix_Style then Host_Dir_Addr := To_Host_Dir_Spec (C_Canonical_Dir'Address, 1); else Host_Dir_Addr := To_Host_Dir_Spec (C_Canonical_Dir'Address, 0); end if; Host_Dir_Len := C_String_Length (Host_Dir_Addr); if Host_Dir_Len = 0 then return null; else return To_Path_String_Access (Host_Dir_Addr, Host_Dir_Len); end if; end To_Host_Dir_Spec; ---------------------------- -- To_Host_File_Spec -- ---------------------------- function To_Host_File_Spec (Canonical_File : String) return String_Access is function To_Host_File_Spec (Canonical_File : Address) return Address; pragma Import (C, To_Host_File_Spec, "__gnat_to_host_file_spec"); C_Canonical_File : String (1 .. Canonical_File'Length + 1); Host_File_Addr : Address; Host_File_Len : Integer; begin C_Canonical_File (1 .. Canonical_File'Length) := Canonical_File; C_Canonical_File (C_Canonical_File'Last) := ASCII.NUL; Host_File_Addr := To_Host_File_Spec (C_Canonical_File'Address); Host_File_Len := C_String_Length (Host_File_Addr); if Host_File_Len = 0 then return null; else return To_Path_String_Access (Host_File_Addr, Host_File_Len); end if; end To_Host_File_Spec; --------------------------- -- To_Path_String_Access -- --------------------------- function To_Path_String_Access (Path_Addr : Address; Path_Len : Integer) return String_Access is subtype Path_String is String (1 .. Path_Len); type Path_String_Access is access Path_String; function Address_To_Access is new Unchecked_Conversion (Source => Address, Target => Path_String_Access); Path_Access : constant Path_String_Access := Address_To_Access (Path_Addr); Return_Val : String_Access; begin Return_Val := new String (1 .. Path_Len); for J in 1 .. Path_Len loop Return_Val (J) := Path_Access (J); end loop; return Return_Val; end To_Path_String_Access; ----------------- -- Update_Path -- ----------------- function Update_Path (Path : String_Ptr) return String_Ptr is function C_Update_Path (Path, Component : Address) return Address; pragma Import (C, C_Update_Path, "update_path"); function Strlen (Str : Address) return Integer; pragma Import (C, Strlen, "strlen"); procedure Strncpy (X : Address; Y : Address; Length : Integer); pragma Import (C, Strncpy, "strncpy"); In_Length : constant Integer := Path'Length; In_String : String (1 .. In_Length + 1); Component_Name : aliased String := "GCC" & ASCII.NUL; Result_Ptr : Address; Result_Length : Integer; Out_String : String_Ptr; begin In_String (1 .. In_Length) := Path.all; In_String (In_Length + 1) := ASCII.NUL; Result_Ptr := C_Update_Path (In_String'Address, Component_Name'Address); Result_Length := Strlen (Result_Ptr); Out_String := new String (1 .. Result_Length); Strncpy (Out_String.all'Address, Result_Ptr, Result_Length); return Out_String; end Update_Path; ---------------- -- Write_Info -- ---------------- procedure Write_Info (Info : String) is begin Write_With_Check (Info'Address, Info'Length); Write_With_Check (EOL'Address, 1); end Write_Info; ------------------------ -- Write_Program_Name -- ------------------------ procedure Write_Program_Name is Save_Buffer : constant String (1 .. Name_Len) := Name_Buffer (1 .. Name_Len); begin Find_Program_Name; -- Convert the name to lower case so error messages are the same on -- all systems. for J in 1 .. Name_Len loop if Name_Buffer (J) in 'A' .. 'Z' then Name_Buffer (J) := Character'Val (Character'Pos (Name_Buffer (J)) + 32); end if; end loop; Write_Str (Name_Buffer (1 .. Name_Len)); -- Restore Name_Buffer which was clobbered by the call to -- Find_Program_Name Name_Len := Save_Buffer'Last; Name_Buffer (1 .. Name_Len) := Save_Buffer; end Write_Program_Name; ---------------------- -- Write_With_Check -- ---------------------- procedure Write_With_Check (A : Address; N : Integer) is Ignore : Boolean; begin if N = Write (Output_FD, A, N) then return; else Write_Str ("error: disk full writing "); Write_Name_Decoded (Output_File_Name); Write_Eol; Name_Len := Name_Len + 1; Name_Buffer (Name_Len) := ASCII.NUL; Delete_File (Name_Buffer'Address, Ignore); Exit_Program (E_Fatal); end if; end Write_With_Check; ---------------------------- -- Package Initialization -- ---------------------------- begin Initialization : declare function Get_Default_Identifier_Character_Set return Character; pragma Import (C, Get_Default_Identifier_Character_Set, "__gnat_get_default_identifier_character_set"); -- Function to determine the default identifier character set, -- which is system dependent. See Opt package spec for a list of -- the possible character codes and their interpretations. function Get_Maximum_File_Name_Length return Int; pragma Import (C, Get_Maximum_File_Name_Length, "__gnat_get_maximum_file_name_length"); -- Function to get maximum file name length for system begin Identifier_Character_Set := Get_Default_Identifier_Character_Set; Maximum_File_Name_Length := Get_Maximum_File_Name_Length; -- Following should be removed by having above function return -- Integer'Last as indication of no maximum instead of -1 ??? if Maximum_File_Name_Length = -1 then Maximum_File_Name_Length := Int'Last; end if; Src_Search_Directories.Set_Last (Primary_Directory); Src_Search_Directories.Table (Primary_Directory) := new String'(""); Lib_Search_Directories.Set_Last (Primary_Directory); Lib_Search_Directories.Table (Primary_Directory) := new String'(""); Osint.Initialize; end Initialization; end Osint;
30,671
ada
7
Fabien-Chouteau/Giza
src/giza-widget-keyboards.ads
<reponame>Fabien-Chouteau/Giza<gh_stars>1-10 ------------------------------------------------------------------------------ -- -- -- Giza -- -- -- -- Copyright (C) 2016 <NAME> (<EMAIL>) -- -- -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with Giza.Widget.Composite; use Giza.Widget.Composite; with Giza.Widget.Tiles; with Giza.Widget.Button; with Giza.Widget.Text; use Giza.Widget; package Giza.Widget.Keyboards is subtype Parent is Giza.Widget.Composite.Instance; type Instance is new Parent with private; subtype Class is Instance'Class; type Ref is access all Class; procedure On_Init (This : in out Instance); overriding procedure Draw (This : in out Instance; Ctx : in out Context.Class; Force : Boolean := True); overriding function On_Position_Event (This : in out Instance; Evt : Position_Event_Ref; Pos : Point_T) return Boolean; procedure Set_Max_Entry_Length (This : in out Instance; Len : Natural); function Get_Text (This : Instance) return String; private type Button_Type is (Btn_1, Btn_2, Btn_3, Btn_4, Btn_5, Btn_6, Btn_7, Btn_8, Btn_9, Btn_0, Btn_Q, Btn_W, Btn_E, Btn_R, Btn_T, Btn_Y, Btn_U, Btn_I, Btn_O, Btn_P, Btn_Caps, Btn_A, Btn_S, Btn_D, Btn_F, Btn_G, Btn_H, Btn_J, Btn_K, Btn_L, Btn_Nothing, Btn_Z, Btn_X, Btn_C, Btn_V, Btn_B, Btn_N, Btn_M, Btn_Del, Btn_Return, Btn_Special, Btn_Space, Btn_OK); type Button_Pos_Type is record Line, Row : Natural; end record; Button_To_Pos : constant array (Button_Type) of Button_Pos_Type := (Btn_1 => (1, 1), Btn_2 => (1, 2), Btn_3 => (1, 3), Btn_4 => (1, 4), Btn_5 => (1, 5), Btn_6 => (1, 6), Btn_7 => (1, 7), Btn_8 => (1, 8), Btn_9 => (1, 9), Btn_0 => (1, 10), Btn_Q => (2, 1), Btn_W => (2, 2), Btn_E => (2, 3), Btn_R => (2, 4), Btn_T => (2, 5), Btn_Y => (2, 6), Btn_U => (2, 7), Btn_I => (2, 8), Btn_O => (2, 9), Btn_P => (2, 10), Btn_Caps => (3, 1), Btn_A => (3, 2), Btn_S => (3, 3), Btn_D => (3, 4), Btn_F => (3, 5), Btn_G => (3, 6), Btn_H => (3, 7), Btn_J => (3, 8), Btn_K => (3, 9), Btn_L => (3, 10), Btn_Nothing => (4, 1), Btn_Z => (4, 2), Btn_X => (4, 3), Btn_C => (4, 4), Btn_V => (4, 5), Btn_B => (4, 6), Btn_N => (4, 7), Btn_M => (4, 8), Btn_Del => (4, 9), Btn_Return => (4, 10), Btn_Special => (5, 1), Btn_Space => (5, 2), Btn_OK => (5, 3)); type Tiles_10_Array is array (Integer range <>) of aliased Tiles.Instance (10, Tiles.Left_Right); type Gbutton_Array is array (Button_Type) of aliased Button.Instance; type Instance is new Parent with record Initialised : Boolean := False; Max_Text_Len : Natural := 100; Text_Display : aliased Text.Instance; Cursor : Natural; Root : aliased Tiles.Instance (5, Tiles.Top_Down); Lines : Tiles_10_Array (1 .. 4); Last_Line : aliased Tiles.Instance (3, Tiles.Left_Right); Buttons : Gbutton_Array; Caps : Boolean := False; Special : Boolean := False; end record; end Giza.Widget.Keyboards;
30,672
ada
3
shalithasuranga/hello-world
hello_world.adb
<filename>hello_world.adb with Ada.Text_IO; procedure HelloWorld is begin Ada.Text_IO.Put_Line("Hello, world!"); end HelloWorld;
30,673
ada
80
enfoTek/tomato.linksys.e2000.nvram-mod
tools-src/gnu/gcc/gcc/ada/debug_a.ads
<gh_stars>10-100 ------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- D E B U G _ A -- -- -- -- S p e c -- -- -- -- $Revision$ -- -- -- Copyright (C) 1992-1998 Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -- -- MA 02111-1307, USA. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package contains data and subprograms to support the A debug switch -- that is used to generate output showing what node is being analyzed, -- resolved, evaluated, or expanded. with Types; use Types; package Debug_A is -- Note: the following subprograms are used in a stack like manner, with -- an exit call matching each entry call. This means that they can keep -- track of the current node being worked on, with the entry call setting -- a new value, by pushing the Node_Id value on a stack, and the exit call -- popping this value off. Comperr.Current_Error_Node is set by both the -- entry and exit routines to point to the current node so that an abort -- message indicates the node involved as accurately as possible. procedure Debug_A_Entry (S : String; N : Node_Id); pragma Inline (Debug_A_Entry); -- Generates a message prefixed by a sequence of bars showing the nesting -- depth (depth increases by 1 for a Debug_A_Entry call and is decreased -- by the corresponding Debug_A_Exit call). Then the string is output -- (analyzing, expanding etc), followed by the node number and its kind. -- This output is generated only if the debug A flag is set. If the debug -- A flag is not set, then no output is generated. This call also sets the -- Node_Id value in Comperr.Current_Error_Node in case a bomb occurs. This -- is done unconditionally, whether or not the debug A flag is set. procedure Debug_A_Exit (S : String; N : Node_Id; Comment : String); pragma Inline (Debug_A_Exit); -- Generates the corresponding termination message. The message is preceded -- by a sequence of bars, followed by the string S, the node number, and -- a trailing comment (e.g. " (already evaluated)"). This output is -- generated only if the debug A flag is set. If the debug A flag is not -- set, then no output is generated. This call also resets the value in -- Comperr.Current_Error_Node to what it was before the corresponding call -- to Debug_A_Entry. end Debug_A;
30,674
ada
81
twdroeger/ada-awa
awa/regtests/awa-events-services-tests.ads
----------------------------------------------------------------------- -- events-tests -- Unit tests for AWA events -- Copyright (C) 2012, 2019 <NAME> -- Written by <NAME> (<EMAIL>) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; with AWA.Tests; private with Util.Beans.Methods; package AWA.Events.Services.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new AWA.Tests.Test with null record; -- Test searching an event name in the definition list. procedure Test_Find_Event (T : in out Test); -- Test the Get_Event_Type_Name internal operation. procedure Test_Get_Event_Name (T : in out Test); -- Test creation and initialization of event manager. procedure Test_Initialize (T : in out Test); -- Test adding an action. procedure Test_Add_Action (T : in out Test); -- Test dispatching synchronous event to a global bean. procedure Test_Dispatch_Synchronous (T : in out Test); -- Test dispatching event through a fifo queue. procedure Test_Dispatch_Fifo (T : in out Test); -- Test dispatching event through a database queue. procedure Test_Dispatch_Persist (T : in out Test); -- Test dispatching synchronous event to a dynamic bean (created on demand). procedure Test_Dispatch_Synchronous_Dyn (T : in out Test); -- Test dispatching synchronous event to a dynamic bean and raise an exception in the action. procedure Test_Dispatch_Synchronous_Raise (T : in out Test); procedure Dispatch_Event (T : in out Test; Kind : in Event_Index; Expect_Count : in Natural; Expect_Prio : in Natural); private type Action_Bean is new Util.Beans.Basic.Bean and Util.Beans.Methods.Method_Bean with record Count : Natural := 0; Priority : Integer := 0; Raise_Exception : Boolean := False; end record; type Action_Bean_Access is access all Action_Bean'Class; -- Get the value identified by the name. -- If the name cannot be found, the method should return the Null object. overriding function Get_Value (From : in Action_Bean; Name : in String) return Util.Beans.Objects.Object; -- Set the value identified by the name. -- If the name cannot be found, the method should raise the No_Value -- exception. overriding procedure Set_Value (From : in out Action_Bean; Name : in String; Value : in Util.Beans.Objects.Object); overriding function Get_Method_Bindings (From : in Action_Bean) return Util.Beans.Methods.Method_Binding_Array_Access; procedure Event_Action (From : in out Action_Bean; Event : in AWA.Events.Module_Event'Class); function Create_Action_Bean return Util.Beans.Basic.Readonly_Bean_Access; end AWA.Events.Services.Tests;
30,675
ada
20
charlie5/lace
3-mid/impact/source/3d/dynamics/impact-d3-motion_state-default.adb
<reponame>charlie5/lace<gh_stars>10-100 package body impact.d3.motion_State.default is function to_motion_State (startTrans, centerOfMassOffset : Transform_3d := impact.d3.Transform.getIdentity) return Item is Self : Item; begin Self.m_graphicsWorldTrans := startTrans; Self.m_centerOfMassOffset := centerOfMassOffset; Self.m_startWorldTrans := startTrans; return Self; end to_motion_State; -- impact.d3.motion_State.default(const impact.d3.Transform& startTrans = impact.d3.Transform::getIdentity(),const impact.d3.Transform& centerOfMassOffset = impact.d3.Transform::getIdentity()) -- : m_graphicsWorldTrans(startTrans), -- m_centerOfMassOffset(centerOfMassOffset), -- m_startWorldTrans(startTrans), -- m_userPointer(0) -- -- { -- } overriding procedure getWorldTransform (Self : in Item; worldTrans : out Transform_3d) is use linear_Algebra_3d, impact.d3.Transform; begin WorldTrans := inverse (Self.m_centerOfMassOffset) * Self.m_graphicsWorldTrans; end getWorldTransform; -- virtual void getWorldTransform(impact.d3.Transform& centerOfMassWorldTrans ) const -- { -- centerOfMassWorldTrans = m_centerOfMassOffset.inverse() * m_graphicsWorldTrans ; -- } overriding procedure setWorldTransform (Self : in out Item; worldTrans : in Transform_3d) is use linear_Algebra_3d, impact.d3.Transform; begin Self.m_graphicsWorldTrans := WorldTrans * Self.m_centerOfMassOffset; end setWorldTransform; -- virtual void setWorldTransform(const impact.d3.Transform& centerOfMassWorldTrans) -- { -- m_graphicsWorldTrans = centerOfMassWorldTrans * m_centerOfMassOffset ; -- } end impact.d3.motion_State.default;
30,676
ada
1
LaudateCorpus1/RosettaCodeData
Task/Pascals-triangle/Ada/pascals-triangle-2.ada
<filename>Task/Pascals-triangle/Ada/pascals-triangle-2.ada package body Pascal is function First_Row(Max_Length: Positive) return Row is R: Row(0 .. Max_Length) := (0 | 1 => 1, others => 0); begin return R; end First_Row; function Next_Row(R: Row) return Row is S: Row(R'Range); begin S(0) := Length(R)+1; S(Length(S)) := 1; for J in reverse 2 .. Length(R) loop S(J) := R(J)+R(J-1); end loop; S(1) := 1; return S; end Next_Row; function Length(R: Row) return Positive is begin return R(0); end Length; end Pascal;
30,677
ada
45
alkalinin/raytracer
ada/src/colors.ads
<filename>ada/src/colors.ads -- -- Raytracer implementation in Ada -- by <NAME> (github: johnperry-math) -- 2021 -- -- specification for Colors, both RGB ("Color_Type") -- and RGBA ("Transparent_Color_Type") -- -- local packages with RayTracing_Constants; use RayTracing_Constants; -- @summary -- specification for Colors, both RGB ("Color_Type") -- and RGBA ("Transparent_Color_Type") package Colors is type Color_Type is record Blue, Green, Red: Float15; end record; -- RGB channels only; for transparency channel see Color_With_Transparency White: constant Color_Type := ( 1.0, 1.0, 1.0 ); Grey: constant Color_Type := ( 0.5, 0.5, 0.5 ); Black: constant Color_Type := ( 0.0, 0.0, 0.0 ); Background: constant Color_Type := Black; Default_Color: constant Color_Type := Black; type Color_With_Transparency_Type is record Blue, Green, Red, Alpha: UInt8; end record; -- R, G, B, and Alpha (transparency) channels function Create_Color( Red, Green, Blue: Float15 ) return Color_Type; function Scale( Color: Color_Type; K: Float15 ) return Color_Type; -- scales Color by a factor of K, returns result pragma Inline_Always(Scale); procedure Scale_Self( Color: in out Color_Type; K: Float15 ); -- scales Color by a factor of K, modifies self pragma Inline_Always(Scale); function "*"(First, Second: Color_Type) return Color_Type; -- componentwise product of First and Second, returns result pragma Inline_Always("*"); procedure Color_Multiply_Self(First: in out Color_Type; Second: Color_Type); pragma Inline_Always(Color_Multiply_Self); function "+"(First, Second: Color_Type) return Color_Type; -- returns sum of First and Second pragma Inline_Always("+"); function Legalize(C: Float15) return UInt8; -- modifies C, expected in the range 0.0 .. 1.0, to the range 0 .. 255, -- with values less than 0.0 converted to 0, and values greater than 1.0 -- converted to 255 pragma Inline_Always(Legalize); function To_Drawing_Color(C: Color_Type) return Color_With_Transparency_Type; -- converts RGB to RGBA with A = 255 pragma Inline_Always(To_Drawing_Color); end Colors;
30,678
ada
0
RREE/Ada_Drivers_Library
examples/shared/serial_ports/src/serial_io-streaming.ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2016-2022, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- A demonstration of a higher-level USART interface using streams. In -- particular, the serial port is presented as a stream type, so these ports -- can be used with stream attributes to send values or arbitrary types, not -- just characters or Strings. -- Polling is used within the procedures to determine when characters are sent -- and received. with Ada.Streams; with Ada.Real_Time; use Ada.Real_Time; package Serial_IO.Streaming is pragma Elaborate_Body; type Serial_Port (Device : not null access Peripheral_Descriptor) is new Ada.Streams.Root_Stream_Type with private; procedure Initialize_Hardware (This : out Serial_Port); procedure Configure (This : in out Serial_Port; Baud_Rate : Baud_Rates; Parity : Parities := No_Parity; Data_Bits : Word_Lengths := Word_Length_8; End_Bits : Stop_Bits := Stopbits_1; Control : Flow_Control := No_Flow_Control); procedure Set_Read_Timeout (This : in out Serial_Port; Wait : Time_Span); -- Stream attributes that call Read (below) can either wait indefinitely or -- can be set to return any current values received after a given interval. -- If the value Time_Span_Last is passed to Wait, the effect is essentially to wait -- forever, i.e., blocking. That is also the effect if this routine is -- never called. overriding procedure Read (This : in out Serial_Port; Buffer : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); overriding procedure Write (This : in out Serial_Port; Buffer : Ada.Streams.Stream_Element_Array); private type Serial_Port (Device : access Peripheral_Descriptor) is new Ada.Streams.Root_Stream_Type with record Timeout : Time_Span := Time_Span_Last; end record; procedure Await_Send_Ready (This : USART) with Inline; procedure Await_Data_Available (This : USART; Timeout : Time_Span := Time_Span_Last; Timed_Out : out Boolean) with Inline; use Ada.Streams; function Last_Index (First : Stream_Element_Offset; Count : Long_Integer) return Stream_Element_Offset with Inline; end Serial_IO.Streaming;
30,679
ada
1
charlie5/lace-alire
3-mid/opengl/source/lean/model/opengl-model-polygon-lit_colored.ads
<reponame>charlie5/lace-alire<filename>3-mid/opengl/source/lean/model/opengl-model-polygon-lit_colored.ads with openGL.Model, openGL.Font, openGL.Geometry; package openGL.Model.polygon.lit_colored -- -- Models a lit, colored polygon. -- is type Item is new Model.polygon.item with private; type View is access all Item'Class; --------- --- Forge -- function new_Polygon (Vertices : in Vector_2_array; Color : in lucid_Color) return View; -------------- --- Attributes -- overriding function to_GL_Geometries (Self : access Item; Textures : access Texture.name_Map_of_texture'Class; Fonts : in Font.font_id_Map_of_font) return Geometry.views; private type Item is new Model.polygon.item with record Color : lucid_Color; Vertices : Vector_2_array (1 .. 8); vertex_Count : Natural := 0; end record; end openGL.Model.polygon.lit_colored;
30,680
ada
15
AdaCore/training_material
extern/gnat_sdl/gnat_sdl2/src/wmmintrin_h.ads
pragma Ada_2005; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; package wmmintrin_h is -- Copyright (C) 2008-2017 Free Software Foundation, Inc. -- This file is part of GCC. -- GCC is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3, or (at your option) -- any later version. -- GCC is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- Under Section 7 of GPL version 3, you are granted additional -- permissions described in the GCC Runtime Library Exception, version -- 3.1, as published by the Free Software Foundation. -- You should have received a copy of the GNU General Public License and -- a copy of the GCC Runtime Library Exception along with this program; -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- <http://www.gnu.org/licenses/>. -- Implemented from the specification included in the Intel C++ Compiler -- User Guide and Reference, version 10.1. -- We need definitions from the SSE2 header file. -- AES -- Performs 1 round of AES decryption of the first m128i using -- the second m128i as a round key. -- skipped func _mm_aesdec_si128 -- Performs the last round of AES decryption of the first m128i -- using the second m128i as a round key. -- skipped func _mm_aesdeclast_si128 -- Performs 1 round of AES encryption of the first m128i using -- the second m128i as a round key. -- skipped func _mm_aesenc_si128 -- Performs the last round of AES encryption of the first m128i -- using the second m128i as a round key. -- skipped func _mm_aesenclast_si128 -- Performs the InverseMixColumn operation on the source m128i -- and stores the result into m128i destination. -- skipped func _mm_aesimc_si128 -- Generates a m128i round key for the input m128i AES cipher key and -- byte round constant. The second parameter must be a compile time -- constant. -- PCLMUL -- Performs carry-less integer multiplication of 64-bit halves of -- 128-bit input operands. The third parameter inducates which 64-bit -- haves of the input parameters v1 and v2 should be used. It must be -- a compile time constant. end wmmintrin_h;
30,681
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/ada/sinfo-cn.adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S I N F O . C N -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This child package of Sinfo contains some routines that permit in place -- alteration of existing tree nodes by changing the value in the Nkind -- field. Since Nkind functions logically in a manner similar to a variant -- record discriminant part, such alterations cannot be permitted in a -- general manner, but in some specific cases, the fields of related nodes -- have been deliberately layed out in a manner that permits such alteration. with Atree; use Atree; with Snames; use Snames; package body Sinfo.CN is use Atree.Unchecked_Access; -- This package is one of the few packages which is allowed to make direct -- references to tree nodes (since it is in the business of providing a -- higher level of tree access which other clients are expected to use and -- which implements checks). ------------------------------------------------------------ -- Change_Character_Literal_To_Defining_Character_Literal -- ------------------------------------------------------------ procedure Change_Character_Literal_To_Defining_Character_Literal (N : in out Node_Id) is begin Set_Nkind (N, N_Defining_Character_Literal); N := Extend_Node (N); end Change_Character_Literal_To_Defining_Character_Literal; ------------------------------------ -- Change_Conversion_To_Unchecked -- ------------------------------------ procedure Change_Conversion_To_Unchecked (N : Node_Id) is begin Set_Do_Overflow_Check (N, False); Set_Do_Tag_Check (N, False); Set_Do_Length_Check (N, False); Set_Nkind (N, N_Unchecked_Type_Conversion); end Change_Conversion_To_Unchecked; ---------------------------------------------- -- Change_Identifier_To_Defining_Identifier -- ---------------------------------------------- procedure Change_Identifier_To_Defining_Identifier (N : in out Node_Id) is begin Set_Nkind (N, N_Defining_Identifier); N := Extend_Node (N); end Change_Identifier_To_Defining_Identifier; --------------------------------------------- -- Change_Name_To_Procedure_Call_Statement -- --------------------------------------------- procedure Change_Name_To_Procedure_Call_Statement (N : Node_Id) is begin -- Case of Indexed component, which is a procedure call with arguments if Nkind (N) = N_Indexed_Component then declare Prefix_Node : constant Node_Id := Prefix (N); Exprs_Node : constant List_Id := Expressions (N); begin Change_Node (N, N_Procedure_Call_Statement); Set_Name (N, Prefix_Node); Set_Parameter_Associations (N, Exprs_Node); end; -- Case of function call node, which is a really a procedure call elsif Nkind (N) = N_Function_Call then declare Fname_Node : constant Node_Id := Name (N); Params_List : constant List_Id := Parameter_Associations (N); begin Change_Node (N, N_Procedure_Call_Statement); Set_Name (N, Fname_Node); Set_Parameter_Associations (N, Params_List); end; -- Case of call to attribute that denotes a procedure. Here we just -- leave the attribute reference unchanged. elsif Nkind (N) = N_Attribute_Reference and then Is_Procedure_Attribute_Name (Attribute_Name (N)) then null; -- All other cases of names are parameterless procedure calls else declare Name_Node : constant Node_Id := Relocate_Node (N); begin Change_Node (N, N_Procedure_Call_Statement); Set_Name (N, Name_Node); end; end if; end Change_Name_To_Procedure_Call_Statement; -------------------------------------------------------- -- Change_Operator_Symbol_To_Defining_Operator_Symbol -- -------------------------------------------------------- procedure Change_Operator_Symbol_To_Defining_Operator_Symbol (N : in out Node_Id) is begin Set_Nkind (N, N_Defining_Operator_Symbol); Set_Node2 (N, Empty); -- Clear unused Str2 field N := Extend_Node (N); end Change_Operator_Symbol_To_Defining_Operator_Symbol; ---------------------------------------------- -- Change_Operator_Symbol_To_String_Literal -- ---------------------------------------------- procedure Change_Operator_Symbol_To_String_Literal (N : Node_Id) is begin Set_Nkind (N, N_String_Literal); Set_Node1 (N, Empty); -- clear Name1 field end Change_Operator_Symbol_To_String_Literal; ------------------------------------------------ -- Change_Selected_Component_To_Expanded_Name -- ------------------------------------------------ procedure Change_Selected_Component_To_Expanded_Name (N : Node_Id) is begin Set_Nkind (N, N_Expanded_Name); Set_Chars (N, Chars (Selector_Name (N))); end Change_Selected_Component_To_Expanded_Name; end Sinfo.CN;
30,682
ada
1
Fabien-Chouteau/sdlada
src/sdl-versions.ads
<reponame>Fabien-Chouteau/sdlada<gh_stars>1-10 -------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2013-2020, <NAME> -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- -- 1. The origin of this software must not be misrepresented; you must not -- claim that you wrote the original software. If you use this software -- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- -- 3. This notice may not be removed or altered from any source -- distribution. -------------------------------------------------------------------------------------------------------------------- -- SDL.Versions -- -- Library version information. -------------------------------------------------------------------------------------------------------------------- package SDL.Versions is type Version_Level is mod 2 ** 8 with Size => 8, Convention => C; -- TODO: Check this against the library, as they use an int. type Revision_Level is mod 2 ** 32; type Version is record Major : Version_Level; Minor : Version_Level; Patch : Version_Level; end record with Convention => C; -- These allow the user to determine which version of SDLAda they compiled with. Compiled_Major : constant Version_Level with Import => True, Convention => C, External_Name => "SDL_Ada_Major_Version"; Compiled_Minor : constant Version_Level with Import => True, Convention => C, External_Name => "SDL_Ada_Minor_Version"; Compiled_Patch : constant Version_Level with Import => True, Convention => C, External_Name => "SDL_Ada_Patch_Version"; Compiled : constant Version := (Major => Compiled_Major, Minor => Compiled_Minor, Patch => Compiled_Patch); function Revision return String with Inline => True; function Revision return Revision_Level; procedure Linked_With (Info : in out Version); end SDL.Versions;
30,683
ada
0
persan/AUnit-addons
tests/src/tc.ads
with AUnit.Test_Cases; package Tc is type Test_Case is new AUnit.Test_Cases.Test_Case with null record; function Name (Test : Test_Case) return AUnit.Message_String; procedure Register_Tests (Test : in out Test_Case); end tc;
30,684
ada
1
philipbjorge/Parallel-Elliptic-Partial-Differential-Equation-Solver
barrier.adb
<reponame>philipbjorge/Parallel-Elliptic-Partial-Differential-Equation-Solver -- <NAME> -- Simple barrier using protected types that -- waits on a certain number of entrants package body Barrier is protected body Barrier_Type is entry Here when not leave is begin count := count + 1; if count < wait_for then requeue Wait; else count := count - 1; if count /= 0 then leave := True; end if; end if; end; entry Wait when leave is begin count := count - 1; if count = 0 then leave := False; end if; end; end Barrier_Type; end Barrier;
30,685
ada
0
caqg/linux-home
.emacs.d/elpa/wisi-3.1.3/gen_run_wisi_lr_text_rep_parse.ads
<filename>.emacs.d/elpa/wisi-3.1.3/gen_run_wisi_lr_text_rep_parse.ads -- Abstract : -- -- Run an Emacs LR text_rep parser as a standalone executable, for debugging. -- -- See gen_emacs_wisi_*_parse.ads for the Emacs background process. -- -- Copyright (C) 2018, 2019 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or -- modify it under terms of the GNU General Public License as -- published by the Free Software Foundation; either version 3, or (at -- your option) any later version. This program is distributed in the -- hope that it will be useful, but WITHOUT ANY WARRANTY; without even -- the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -- PURPOSE. See the GNU General Public License for more details. You -- should have received a copy of the GNU General Public License -- distributed with this program; see file COPYING. If not, write to -- the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, -- MA 02110-1335, USA. pragma License (GPL); with WisiToken.Parse.LR.Parser; with WisiToken.Syntax_Trees; with Wisi; generic type Parse_Data_Type is new Wisi.Parse_Data_Type with private; Descriptor : in WisiToken.Descriptor; Language_Fixes : in WisiToken.Parse.LR.Parser.Language_Fixes_Access; Language_Matching_Begin_Tokens : in WisiToken.Parse.LR.Parser.Language_Matching_Begin_Tokens_Access; Language_String_ID_Set : in WisiToken.Parse.LR.Parser.Language_String_ID_Set_Access; Text_Rep_File_Name : in String; with procedure Create_Parser (Parser : out WisiToken.Parse.LR.Parser.Parser; Language_Fixes : in WisiToken.Parse.LR.Parser.Language_Fixes_Access; Language_Matching_Begin_Tokens : in WisiToken.Parse.LR.Parser.Language_Matching_Begin_Tokens_Access; Language_String_ID_Set : in WisiToken.Parse.LR.Parser.Language_String_ID_Set_Access; Trace : not null access WisiToken.Trace'Class; User_Data : in WisiToken.Syntax_Trees.User_Data_Access; Text_Rep_File_Name : in String); procedure Gen_Run_Wisi_LR_Text_Rep_Parse;
30,686
ada
1
LaudateCorpus1/RosettaCodeData
Task/Function-composition/Ada/function-composition-1.ada
generic type Argument is private; package Functions is type Primitive_Operation is not null access function (Value : Argument) return Argument; type Func (<>) is private; function "*" (Left : Func; Right : Argument) return Argument; function "*" (Left : Func; Right : Primitive_Operation) return Func; function "*" (Left, Right : Primitive_Operation) return Func; function "*" (Left, Right : Func) return Func; private type Func is array (Positive range <>) of Primitive_Operation; end Functions;
30,687
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c8/c85005c.ada
<filename>gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c8/c85005c.ada -- C85005C.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- OBJECTIVE: -- CHECK THAT A VARIABLE CREATED BY AN ENTRY 'IN OUT' FORMAL -- PARAMETER CAN BE RENAMED AND HAS THE CORRECT VALUE, AND THAT -- THE NEW NAME CAN BE USED IN AN ASSIGNMENT STATEMENT AND PASSED -- ON AS AN ACTUAL SUBPROGRAM OR ENTRY 'IN OUT' OR 'OUT' PARAMETER, -- AND AS AN ACTUAL GENERIC 'IN OUT' PARAMETER, AND THAT WHEN THE -- VALUE OF THE RENAMED VARIABLE IS CHANGED, THE NEW VALUE IS -- REFLECTED BY THE VALUE OF THE NEW NAME. -- HISTORY: -- JET 03/15/88 CREATED ORIGINAL TEST. WITH REPORT; USE REPORT; PROCEDURE C85005C IS TYPE ARRAY1 IS ARRAY (POSITIVE RANGE <>) OF INTEGER; TYPE RECORD1 (D : INTEGER) IS RECORD FIELD1 : INTEGER := 1; END RECORD; TYPE POINTER1 IS ACCESS INTEGER; PACKAGE PACK1 IS TYPE PRIVY IS PRIVATE; ZERO : CONSTANT PRIVY; ONE : CONSTANT PRIVY; TWO : CONSTANT PRIVY; THREE : CONSTANT PRIVY; FOUR : CONSTANT PRIVY; FIVE : CONSTANT PRIVY; FUNCTION IDENT (I : PRIVY) RETURN PRIVY; FUNCTION NEXT (I : PRIVY) RETURN PRIVY; PRIVATE TYPE PRIVY IS RANGE 0..127; ZERO : CONSTANT PRIVY := 0; ONE : CONSTANT PRIVY := 1; TWO : CONSTANT PRIVY := 2; THREE : CONSTANT PRIVY := 3; FOUR : CONSTANT PRIVY := 4; FIVE : CONSTANT PRIVY := 5; END PACK1; TASK TYPE TASK1 IS ENTRY ASSIGN (J : IN INTEGER); ENTRY VALU (J : OUT INTEGER); ENTRY NEXT; ENTRY STOP; END TASK1; DI1 : INTEGER := 0; DA1 : ARRAY1(1..3) := (OTHERS => 0); DR1 : RECORD1(1) := (D => 1, FIELD1 => 0); DP1 : POINTER1 := NEW INTEGER'(0); DV1 : PACK1.PRIVY := PACK1.ZERO; DT1 : TASK1; I : INTEGER; GENERIC GI1 : IN OUT INTEGER; GA1 : IN OUT ARRAY1; GR1 : IN OUT RECORD1; GP1 : IN OUT POINTER1; GV1 : IN OUT PACK1.PRIVY; GT1 : IN OUT TASK1; PACKAGE GENERIC1 IS END GENERIC1; FUNCTION IDENT (P : POINTER1) RETURN POINTER1 IS BEGIN IF EQUAL (3,3) THEN RETURN P; ELSE RETURN NULL; END IF; END IDENT; PACKAGE BODY PACK1 IS FUNCTION IDENT (I : PRIVY) RETURN PRIVY IS BEGIN IF EQUAL(3,3) THEN RETURN I; ELSE RETURN PRIVY'(0); END IF; END IDENT; FUNCTION NEXT (I : PRIVY) RETURN PRIVY IS BEGIN RETURN I+1; END NEXT; END PACK1; PACKAGE BODY GENERIC1 IS BEGIN GI1 := GI1 + 1; GA1 := (GA1(1)+1, GA1(2)+1, GA1(3)+1); GR1 := (D => 1, FIELD1 => GR1.FIELD1 + 1); GP1 := NEW INTEGER'(GP1.ALL + 1); GV1 := PACK1.NEXT(GV1); GT1.NEXT; END GENERIC1; TASK BODY TASK1 IS TASK_VALUE : INTEGER := 0; ACCEPTING_ENTRIES : BOOLEAN := TRUE; BEGIN WHILE ACCEPTING_ENTRIES LOOP SELECT ACCEPT ASSIGN (J : IN INTEGER) DO TASK_VALUE := J; END ASSIGN; OR ACCEPT VALU (J : OUT INTEGER) DO J := TASK_VALUE; END VALU; OR ACCEPT NEXT DO TASK_VALUE := TASK_VALUE + 1; END NEXT; OR ACCEPT STOP DO ACCEPTING_ENTRIES := FALSE; END STOP; END SELECT; END LOOP; END TASK1; BEGIN TEST ("C85005C", "CHECK THAT A VARIABLE CREATED BY AN ENTRY " & "'IN OUT' FORMAL PARAMETER CAN BE RENAMED " & "AND HAS THE CORRECT VALUE, AND THAT THE NEW " & "NAME CAN BE USED IN AN ASSIGNMENT STATEMENT " & "AND PASSED ON AS AN ACTUAL SUBPROGRAM OR " & "ENTRY 'IN OUT' OR 'OUT' PARAMETER, AND AS AN " & "ACTUAL GENERIC 'IN OUT' PARAMETER, AND THAT " & "WHEN THE VALUE OF THE RENAMED VARIABLE IS " & "CHANGED, THE NEW VALUE IS REFLECTED BY THE " & "VALUE OF THE NEW NAME"); DECLARE TASK MAIN_TASK IS ENTRY START (TI1 : IN OUT INTEGER; TA1 : IN OUT ARRAY1; TR1 : IN OUT RECORD1; TP1 : IN OUT POINTER1; TV1 : IN OUT PACK1.PRIVY; TT1 : IN OUT TASK1); END MAIN_TASK; TASK BODY MAIN_TASK IS BEGIN ACCEPT START (TI1: IN OUT INTEGER; TA1: IN OUT ARRAY1; TR1: IN OUT RECORD1; TP1: IN OUT POINTER1; TV1: IN OUT PACK1.PRIVY; TT1: IN OUT TASK1) DO DECLARE XTI1 : INTEGER RENAMES TI1; XTA1 : ARRAY1 RENAMES TA1; XTR1 : RECORD1 RENAMES TR1; XTP1 : POINTER1 RENAMES TP1; XTV1 : PACK1.PRIVY RENAMES TV1; XTT1 : TASK1 RENAMES TT1; TASK TYPE TASK2 IS ENTRY ENTRY1 (TTI1 : OUT INTEGER; TTA1 : OUT ARRAY1; TTR1 : OUT RECORD1; TTP1 : IN OUT POINTER1; TTV1 : IN OUT PACK1.PRIVY; TTT1 : IN OUT TASK1); END TASK2; CHK_TASK : TASK2; PROCEDURE PROC1 (PTI1 : IN OUT INTEGER; PTA1 : IN OUT ARRAY1; PTR1 : IN OUT RECORD1; PTP1 : OUT POINTER1; PTV1 : OUT PACK1.PRIVY; PTT1 : IN OUT TASK1) IS BEGIN PTI1 := PTI1 + 1; PTA1 := (PTA1(1)+1, PTA1(2)+1, PTA1(3)+1); PTR1 := (D => 1, FIELD1 => PTR1.FIELD1 + 1); PTP1 := NEW INTEGER'(TP1.ALL + 1); PTV1 := PACK1.NEXT(TV1); PTT1.NEXT; END PROC1; TASK BODY TASK2 IS BEGIN ACCEPT ENTRY1 (TTI1 : OUT INTEGER; TTA1 : OUT ARRAY1; TTR1 : OUT RECORD1; TTP1 : IN OUT POINTER1; TTV1 : IN OUT PACK1.PRIVY; TTT1 : IN OUT TASK1) DO TTI1 := TI1 + 1; TTA1 := (TA1(1)+1, TA1(2)+1, TA1(3)+1); TTR1 := (D => 1, FIELD1 => TR1.FIELD1 + 1); TTP1 := NEW INTEGER'(TTP1.ALL + 1); TTV1 := PACK1.NEXT(TTV1); TTT1.NEXT; END ENTRY1; END TASK2; PACKAGE GENPACK1 IS NEW GENERIC1 (XTI1, XTA1, XTR1, XTP1, XTV1, XTT1); BEGIN IF XTI1 /= IDENT_INT(1) THEN FAILED ("INCORRECT VALUE OF XTI1 (1)"); END IF; IF XTA1 /= (IDENT_INT(1),IDENT_INT(1), IDENT_INT(1)) THEN FAILED ("INCORRECT VALUE OF XTA1 (1)"); END IF; IF XTR1 /= (D => 1, FIELD1 => IDENT_INT(1)) THEN FAILED ("INCORRECT VALUE OF XTR1 (1)"); END IF; IF XTP1 /= IDENT(TP1) OR XTP1.ALL /= IDENT_INT(1) THEN FAILED ("INCORRECT VALUE OF XTP1 (1)"); END IF; IF PACK1."/=" (XTV1, PACK1.IDENT(PACK1.ONE)) THEN FAILED ("INCORRECT VALUE OF XTV1 (1)"); END IF; XTT1.VALU(I); IF I /= IDENT_INT(1) THEN FAILED ("INCORRECT RETURN VALUE OF " & "XTT1.VALU (1)"); END IF; PROC1(XTI1, XTA1, XTR1, XTP1, XTV1, XTT1); IF XTI1 /= IDENT_INT(2) THEN FAILED ("INCORRECT VALUE OF XTI1 (2)"); END IF; IF XTA1 /= (IDENT_INT(2),IDENT_INT(2), IDENT_INT(2)) THEN FAILED ("INCORRECT VALUE OF XTA1 (2)"); END IF; IF XTR1 /= (D => 1, FIELD1 => IDENT_INT(2)) THEN FAILED ("INCORRECT VALUE OF XTR1 (2)"); END IF; IF XTP1 /= IDENT(TP1) OR XTP1.ALL /= IDENT_INT(2) THEN FAILED ("INCORRECT VALUE OF XTP1 (2)"); END IF; IF PACK1."/=" (XTV1, PACK1.IDENT(PACK1.TWO)) THEN FAILED ("INCORRECT VALUE OF XTV1 (2)"); END IF; XTT1.VALU(I); IF I /= IDENT_INT(2) THEN FAILED ("INCORRECT RETURN VALUE FROM " & "XTT1.VALU (2)"); END IF; CHK_TASK.ENTRY1 (XTI1, XTA1, XTR1, XTP1, XTV1, XTT1); IF XTI1 /= IDENT_INT(3) THEN FAILED ("INCORRECT VALUE OF XTI1 (3)"); END IF; IF XTA1 /= (IDENT_INT(3),IDENT_INT(3), IDENT_INT(3)) THEN FAILED ("INCORRECT VALUE OF XTA1 (3)"); END IF; IF XTR1 /= (D => 1, FIELD1 => IDENT_INT(3)) THEN FAILED ("INCORRECT VALUE OF XTR1 (3)"); END IF; IF XTP1 /= IDENT(TP1) OR XTP1.ALL /= IDENT_INT(3) THEN FAILED ("INCORRECT VALUE OF XTP1 (3)"); END IF; IF PACK1."/=" (XTV1, PACK1.IDENT(PACK1.THREE)) THEN FAILED ("INCORRECT VALUE OF XTV1 (3)"); END IF; XTT1.VALU(I); IF I /= IDENT_INT(3) THEN FAILED ("INCORRECT RETURN VALUE OF " & "XTT1.VALU (3)"); END IF; XTI1 := XTI1 + 1; XTA1 := (XTA1(1)+1, XTA1(2)+1, XTA1(3)+1); XTR1 := (D => 1, FIELD1 => XTR1.FIELD1 + 1); XTP1 := NEW INTEGER'(XTP1.ALL + 1); XTV1 := PACK1.NEXT(XTV1); XTT1.NEXT; IF XTI1 /= IDENT_INT(4) THEN FAILED ("INCORRECT VALUE OF XTI1 (4)"); END IF; IF XTA1 /= (IDENT_INT(4),IDENT_INT(4), IDENT_INT(4)) THEN FAILED ("INCORRECT VALUE OF XTA1 (4)"); END IF; IF XTR1 /= (D => 1, FIELD1 => IDENT_INT(4)) THEN FAILED ("INCORRECT VALUE OF XTR1 (4)"); END IF; IF XTP1 /= IDENT(TP1) OR XTP1.ALL /= IDENT_INT(4) THEN FAILED ("INCORRECT VALUE OF XTP1 (4)"); END IF; IF PACK1."/=" (XTV1, PACK1.IDENT(PACK1.FOUR)) THEN FAILED ("INCORRECT VALUE OF XTV1 (4)"); END IF; XTT1.VALU(I); IF I /= IDENT_INT(4) THEN FAILED ("INCORRECT RETURN VALUE OF " & "XTT1.VALU (4)"); END IF; TI1 := TI1 + 1; TA1 := (TA1(1)+1, TA1(2)+1, TA1(3)+1); TR1 := (D => 1, FIELD1 => TR1.FIELD1 + 1); TP1 := NEW INTEGER'(TP1.ALL + 1); TV1 := PACK1.NEXT(TV1); TT1.NEXT; IF XTI1 /= IDENT_INT(5) THEN FAILED ("INCORRECT VALUE OF XTI1 (5)"); END IF; IF XTA1 /= (IDENT_INT(5),IDENT_INT(5), IDENT_INT(5)) THEN FAILED ("INCORRECT VALUE OF XTA1 (5)"); END IF; IF XTR1 /= (D => 1, FIELD1 => IDENT_INT(5)) THEN FAILED ("INCORRECT VALUE OF XTR1 (5)"); END IF; IF XTP1 /= IDENT(TP1) OR XTP1.ALL /= IDENT_INT(5) THEN FAILED ("INCORRECT VALUE OF XTP1 (5)"); END IF; IF PACK1."/=" (XTV1, PACK1.IDENT(PACK1.FIVE)) THEN FAILED ("INCORRECT VALUE OF XTV1 (5)"); END IF; XTT1.VALU(I); IF I /= IDENT_INT(5) THEN FAILED ("INCORRECT RETURN VALUE OF " & "XTT1.VALU (5)"); END IF; END; END START; END MAIN_TASK; BEGIN MAIN_TASK.START (DI1, DA1, DR1, DP1, DV1, DT1); END; DT1.STOP; RESULT; END C85005C;
30,688
ada
0
skill-lang/adaCommon
src/skill-streams-reader.ads
-- ___ _ ___ _ _ -- -- / __| |/ (_) | | Common SKilL implementation -- -- \__ \ ' <| | | |__ stream to skill tokens -- -- |___/_|\_\_|_|____| by: <NAME>, <NAME> -- -- -- pragma Ada_2012; with Interfaces.C; with Interfaces.C.Pointers; with Interfaces.C.Strings; with Interfaces.C_Streams; with Skill.Types; with Ada.Exceptions; package Skill.Streams.Reader is type Abstract_Stream is tagged private; type Stream is access all Abstract_Stream'Class; type Input_Stream_T is new Abstract_Stream with private; type Input_Stream is not null access Skill.Streams.Reader.Input_Stream_T; type Sub_Stream_T is new Abstract_Stream with private; type Sub_Stream is access Sub_Stream_T; -- type cast function To (This : access Abstract_Stream'Class) return Stream is (Stream(This)); -- note an empty stream will be created if path is null function Open (Path : Skill.Types.String_Access) return Input_Stream; -- creates a sub map function Map (This : access Input_Stream_T; Base : Types.v64; First : Types.v64; Last : Types.v64) return Sub_Stream; function Empty_Sub_Stream return Sub_Stream; -- destroy a map and close the file procedure Close (This : access Input_Stream_T); -- destroy a sub map procedure Free (This : access Sub_Stream_T); function Path (This : access Input_Stream_T) return Skill.Types.String_Access; function Eof (This : access Abstract_Stream'Class) return Boolean; function Position (This : access Abstract_Stream'Class) return Skill.Types.v64; -- checks validity of argument position for this stream, -- if invalid, raise constraint error procedure Check_Offset (This : access Abstract_Stream'Class; Pos : Skill.Types.v64); procedure Jump (This : access Abstract_Stream'Class; Pos : Skill.Types.v64); function I8 (This : access Abstract_Stream'Class) return Skill.Types.i8; pragma Inline (I8); use type Interfaces.Integer_8; function Bool (This : access Abstract_Stream'Class) return Boolean is (This.I8 /= 0); pragma Inline (Bool); function I16 (This : access Abstract_Stream'Class) return Skill.Types.i16; pragma Inline (I16); function I32 (This : access Abstract_Stream'Class) return Skill.Types.i32; pragma Inline (I32); function I64 (This : access Abstract_Stream'Class) return Skill.Types.i64; pragma Inline (I64); function F32 (This : access Abstract_Stream'Class) return Skill.Types.F32; pragma Inline (F32); function F64 (This : access Abstract_Stream'Class) return Skill.Types.F64; pragma Inline (F64); function V64 (This : access Abstract_Stream'Class) return Skill.Types.v64; -- wont happen, simply too large pragma Inline (V64); function Parse_Exception (This : access Input_Stream_T; Block_Counter : Positive; Cause : in Ada.Exceptions.Exception_Occurrence; Message : String) return String; function Parse_Exception (This : access Input_Stream_T; Block_Counter : Positive; Message : String) return String; private package C renames Interfaces.C; -- returns an invalid map pointer, that can be used in empty maps function Invalid_Pointer return Map_Pointer; pragma Inline (Invalid_Pointer); -- mmap_c_array mmap_open (char const * filename) function MMap_Open (Path : Interfaces.C.Strings.chars_ptr) return Mmap; pragma Import (C, MMap_Open, "mmap_read"); -- void mmap_close(FILE *stream) procedure MMap_Close (File : Interfaces.C_Streams.FILEs); pragma Import (C, MMap_Close, "mmap_close"); type Abstract_Stream is tagged record -- current position Map : Map_Pointer; -- first position Base : Map_Pointer; -- last position EOF : Map_Pointer; end record; type Input_Stream_T is new Abstract_Stream with record Path : Skill.Types.String_Access; -- shared string! File : Interfaces.C_Streams.FILEs; end record; -- a part that is a sub section of an input stream type Sub_Stream_T is new Abstract_Stream with null record; end Skill.Streams.Reader;
30,689
ada
0
Roldak/OpenGLAda
src/glfw/v2/glfw-display-modes.ads
-- part of OpenGLAda, (c) 2017 <NAME> -- released under the terms of the MIT license, see the file "COPYING" package Glfw.Display.Modes is type Mode is record Width, Height : Natural; Red_Bits, Green_Bits, Blue_Bits : Natural; end record; type Mode_List is array (Positive range <>) of Mode; function Available_Modes return Mode_List; function Desktop_Mode return Mode; end Glfw.Display.Modes;
30,690
ada
19
jrcarter/Ada_GUI
parsers-generic_source-keywords.adb
-- -- -- procedure Copyright (c) <NAME> -- -- Parsers.Generic_Source.Keywords Luebeck -- -- Interface Summer, 2005 -- -- -- -- Last revision : 11:37 13 Oct 2007 -- -- -- -- This library is free software; you can redistribute it and/or -- -- modify it under the terms of the GNU General Public License as -- -- published by the Free Software Foundation; either version 2 of -- -- the License, or (at your option) any later version. This library -- -- is distributed in the hope that it will be useful, but WITHOUT -- -- ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. You should have -- -- received a copy of the GNU General Public License along with -- -- this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- -- As a special exception, if other files instantiate generics from -- -- this unit, or you link this unit with other files to produce an -- -- executable, this unit does not by itself cause the resulting -- -- executable to be covered by the GNU General Public License. This -- -- exception does not however invalidate any other reasons why the -- -- executable file might be covered by the GNU Public License. -- --____________________________________________________________________-- with Ada.Characters.Handling; use Ada.Characters.Handling; with Parsers.Generic_Source.Get_Token; package body Parsers.Generic_Source.Keywords is use Keyword_Tables; Folder : Dictionary; procedure Check_Spelling (Name : String) is Symbol : Character; begin if Name'Length = 0 or else not Is_Letter (Name (Name'First)) then raise Constraint_Error; end if; for Index in Name'First + 1 .. Name'Last loop Symbol := Name (Index); if not (Is_Alphanumeric (Symbol) or else Symbol = '_') then raise Constraint_Error; end if; end loop; end Check_Spelling; function Check_Matched (Source : String; Pointer : Integer) return Boolean is begin return not ( Is_Alphanumeric (Source (Pointer)) or else Source (Pointer) = '_' ); end Check_Matched; procedure Get_Keyword is new Parsers.Generic_Source.Get_Token (Keyword_Raw_Tables); procedure Get ( Code : in out Source_Type; Token : out Keyword; Got_It : out Boolean ) is begin Get_Keyword (Code, Folder, Token, Got_It); end Get; begin for Item in Keyword'Range loop Add (Folder, Keyword'Image (Item), Item); end loop; end Parsers.Generic_Source.Keywords;
30,691
ada
286
auzkok/libagar
ada/original_2008/ada-gui/agar-gui-types.ads
<reponame>auzkok/libagar -- This file only exists because of circular type dependencies in the C -- library. Types must therefore be collected here, imported and renamed -- in each package to prevent loops. with agar.core.tail_queue; with agar.core.types; with agar.gui.rect; with agar.gui.widget.box; with agar.gui.widget.button; with agar.gui.widget.label; with agar.gui.widget; package agar.gui.types is -- widget.icon type widget_icon_t is limited private; type widget_icon_access_t is access all widget_icon_t; pragma convention (c, widget_icon_access_t); type widget_icon_flags_t is new c.unsigned; pragma convention (c, widget_icon_flags_t); function widget_icon_widget (icon : widget_icon_access_t) return agar.gui.widget.widget_access_t; pragma inline (widget_icon_widget); -- window type window_t is limited private; type window_access_t is access all window_t; pragma convention (c, window_access_t); type window_flags_t is new c.unsigned; pragma convention (c, window_flags_t); package window_tail_queue is new agar.core.tail_queue (entry_type => window_access_t); type window_alignment_t is ( WINDOW_TL, WINDOW_TC, WINDOW_TR, WINDOW_ML, WINDOW_MC, WINDOW_MR, WINDOW_BL, WINDOW_BC, WINDOW_BR ); for window_alignment_t use ( WINDOW_TL => 0, WINDOW_TC => 1, WINDOW_TR => 2, WINDOW_ML => 3, WINDOW_MC => 4, WINDOW_MR => 5, WINDOW_BL => 6, WINDOW_BC => 7, WINDOW_BR => 8 ); for window_alignment_t'size use c.unsigned'size; pragma convention (c, window_alignment_t); window_caption_max : constant c.unsigned := 512; function window_widget (window : window_access_t) return agar.gui.widget.widget_access_t; pragma inline (window_widget); -- widget.titlebar type widget_titlebar_t is limited private; type widget_titlebar_access_t is access all widget_titlebar_t; pragma convention (c, widget_titlebar_access_t); type widget_titlebar_flags_t is new c.unsigned; function widget_titlebar_widget (titlebar : widget_titlebar_access_t) return agar.gui.widget.widget_access_t; pragma inline (widget_titlebar_widget); private type widget_icon_name_t is array (1 .. agar.gui.widget.label.max) of aliased c.char; pragma convention (c, widget_icon_name_t); type widget_icon_t is record widget : aliased agar.gui.widget.widget_t; flags : widget_icon_flags_t; surface : c.int; label_text : widget_icon_name_t; label_surface : c.int; label_pad : c.int; window : window_access_t; socket : agar.core.types.void_ptr_t; x_saved : c.int; y_saved : c.int; w_saved : c.int; h_saved : c.int; c_background : agar.core.types.uint32_t; end record; pragma convention (c, widget_icon_t); type window_caption_t is array (1 .. window_caption_max) of aliased c.char; pragma convention (c, window_caption_t); type window_t is record widget : aliased agar.gui.widget.widget_t; flags : window_flags_t; caption : window_caption_t; visible : c.int; tbar : widget_titlebar_access_t; alignment : window_alignment_t; spacing : c.int; tpad : c.int; bpad : c.int; lpad : c.int; rpad : c.int; reqw : c.int; reqh : c.int; minw : c.int; minh : c.int; border_bot : c.int; border_side : c.int; resize_ctrl : c.int; r_saved : agar.gui.rect.rect_t; min_pct : c.int; subwins : window_tail_queue.head_t; windows : window_tail_queue.entry_t; swins : window_tail_queue.entry_t; detach : window_tail_queue.entry_t; icon : widget_icon_access_t; r : agar.gui.rect.rect_t; end record; pragma convention (c, window_t); type widget_titlebar_t is record box : aliased agar.gui.widget.box.box_t; flags : widget_titlebar_flags_t; pressed : c.int; window : window_access_t; label : agar.gui.widget.label.label_access_t; close_button : agar.gui.widget.button.button_access_t; minimize_button : agar.gui.widget.button.button_access_t; maximize_button : agar.gui.widget.button.button_access_t; end record; pragma convention (c, widget_titlebar_t); end agar.gui.types;
30,692
ada
24
svn2github/matreshka
source/amf/dd/amf-internals-tables-dg_metamodel-links.ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, <NAME> <<EMAIL>> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ package AMF.Internals.Tables.DG_Metamodel.Links is procedure Initialize; private procedure Initialize_1; procedure Initialize_2; procedure Initialize_3; procedure Initialize_4; procedure Initialize_5; procedure Initialize_6; procedure Initialize_7; procedure Initialize_8; procedure Initialize_9; procedure Initialize_10; procedure Initialize_11; procedure Initialize_12; procedure Initialize_13; procedure Initialize_14; procedure Initialize_15; procedure Initialize_16; procedure Initialize_17; procedure Initialize_18; procedure Initialize_19; procedure Initialize_20; procedure Initialize_21; procedure Initialize_22; procedure Initialize_23; procedure Initialize_24; procedure Initialize_25; procedure Initialize_26; procedure Initialize_27; procedure Initialize_28; procedure Initialize_29; procedure Initialize_30; procedure Initialize_31; procedure Initialize_32; procedure Initialize_33; procedure Initialize_34; procedure Initialize_35; procedure Initialize_36; procedure Initialize_37; procedure Initialize_38; procedure Initialize_39; procedure Initialize_40; procedure Initialize_41; procedure Initialize_42; procedure Initialize_43; procedure Initialize_44; procedure Initialize_45; procedure Initialize_46; procedure Initialize_47; procedure Initialize_48; procedure Initialize_49; procedure Initialize_50; procedure Initialize_51; procedure Initialize_52; procedure Initialize_53; procedure Initialize_54; procedure Initialize_55; procedure Initialize_56; procedure Initialize_57; procedure Initialize_58; procedure Initialize_59; procedure Initialize_60; procedure Initialize_61; procedure Initialize_62; procedure Initialize_63; procedure Initialize_64; procedure Initialize_65; procedure Initialize_66; procedure Initialize_67; procedure Initialize_68; procedure Initialize_69; procedure Initialize_70; procedure Initialize_71; procedure Initialize_72; procedure Initialize_73; procedure Initialize_74; procedure Initialize_75; procedure Initialize_76; procedure Initialize_77; procedure Initialize_78; procedure Initialize_79; procedure Initialize_80; procedure Initialize_81; procedure Initialize_82; procedure Initialize_83; procedure Initialize_84; procedure Initialize_85; procedure Initialize_86; procedure Initialize_87; procedure Initialize_88; procedure Initialize_89; procedure Initialize_90; procedure Initialize_91; procedure Initialize_92; procedure Initialize_93; procedure Initialize_94; procedure Initialize_95; procedure Initialize_96; procedure Initialize_97; procedure Initialize_98; procedure Initialize_99; procedure Initialize_100; procedure Initialize_101; procedure Initialize_102; procedure Initialize_103; procedure Initialize_104; procedure Initialize_105; procedure Initialize_106; procedure Initialize_107; procedure Initialize_108; procedure Initialize_109; procedure Initialize_110; procedure Initialize_111; procedure Initialize_112; procedure Initialize_113; procedure Initialize_114; procedure Initialize_115; procedure Initialize_116; procedure Initialize_117; procedure Initialize_118; procedure Initialize_119; procedure Initialize_120; procedure Initialize_121; procedure Initialize_122; procedure Initialize_123; procedure Initialize_124; procedure Initialize_125; procedure Initialize_126; procedure Initialize_127; procedure Initialize_128; procedure Initialize_129; procedure Initialize_130; procedure Initialize_131; procedure Initialize_132; procedure Initialize_133; procedure Initialize_134; procedure Initialize_135; procedure Initialize_136; procedure Initialize_137; procedure Initialize_138; procedure Initialize_139; procedure Initialize_140; procedure Initialize_141; procedure Initialize_142; procedure Initialize_143; procedure Initialize_144; procedure Initialize_145; procedure Initialize_146; procedure Initialize_147; procedure Initialize_148; procedure Initialize_149; procedure Initialize_150; procedure Initialize_151; procedure Initialize_152; procedure Initialize_153; procedure Initialize_154; procedure Initialize_155; procedure Initialize_156; procedure Initialize_157; procedure Initialize_158; procedure Initialize_159; procedure Initialize_160; procedure Initialize_161; procedure Initialize_162; procedure Initialize_163; procedure Initialize_164; procedure Initialize_165; procedure Initialize_166; procedure Initialize_167; procedure Initialize_168; procedure Initialize_169; procedure Initialize_170; procedure Initialize_171; procedure Initialize_172; procedure Initialize_173; procedure Initialize_174; procedure Initialize_175; procedure Initialize_176; procedure Initialize_177; procedure Initialize_178; procedure Initialize_179; procedure Initialize_180; procedure Initialize_181; procedure Initialize_182; procedure Initialize_183; procedure Initialize_184; procedure Initialize_185; procedure Initialize_186; procedure Initialize_187; procedure Initialize_188; procedure Initialize_189; procedure Initialize_190; procedure Initialize_191; procedure Initialize_192; procedure Initialize_193; procedure Initialize_194; procedure Initialize_195; procedure Initialize_196; procedure Initialize_197; procedure Initialize_198; procedure Initialize_199; procedure Initialize_200; procedure Initialize_201; procedure Initialize_202; procedure Initialize_203; procedure Initialize_204; procedure Initialize_205; procedure Initialize_206; procedure Initialize_207; procedure Initialize_208; procedure Initialize_209; procedure Initialize_210; procedure Initialize_211; procedure Initialize_212; procedure Initialize_213; procedure Initialize_214; procedure Initialize_215; procedure Initialize_216; procedure Initialize_217; procedure Initialize_218; procedure Initialize_219; procedure Initialize_220; procedure Initialize_221; procedure Initialize_222; procedure Initialize_223; procedure Initialize_224; procedure Initialize_225; procedure Initialize_226; procedure Initialize_227; procedure Initialize_228; procedure Initialize_229; procedure Initialize_230; procedure Initialize_231; procedure Initialize_232; procedure Initialize_233; procedure Initialize_234; procedure Initialize_235; procedure Initialize_236; procedure Initialize_237; procedure Initialize_238; procedure Initialize_239; procedure Initialize_240; procedure Initialize_241; procedure Initialize_242; procedure Initialize_243; procedure Initialize_244; procedure Initialize_245; procedure Initialize_246; procedure Initialize_247; procedure Initialize_248; procedure Initialize_249; procedure Initialize_250; procedure Initialize_251; procedure Initialize_252; procedure Initialize_253; procedure Initialize_254; procedure Initialize_255; procedure Initialize_256; procedure Initialize_257; procedure Initialize_258; procedure Initialize_259; procedure Initialize_260; procedure Initialize_261; procedure Initialize_262; procedure Initialize_263; procedure Initialize_264; procedure Initialize_265; procedure Initialize_266; procedure Initialize_267; procedure Initialize_268; procedure Initialize_269; procedure Initialize_270; procedure Initialize_271; procedure Initialize_272; procedure Initialize_273; procedure Initialize_274; procedure Initialize_275; procedure Initialize_276; procedure Initialize_277; procedure Initialize_278; procedure Initialize_279; procedure Initialize_280; procedure Initialize_281; procedure Initialize_282; procedure Initialize_283; procedure Initialize_284; procedure Initialize_285; procedure Initialize_286; procedure Initialize_287; procedure Initialize_288; procedure Initialize_289; procedure Initialize_290; procedure Initialize_291; procedure Initialize_292; procedure Initialize_293; procedure Initialize_294; procedure Initialize_295; procedure Initialize_296; procedure Initialize_297; procedure Initialize_298; procedure Initialize_299; procedure Initialize_300; procedure Initialize_301; procedure Initialize_302; procedure Initialize_303; procedure Initialize_304; procedure Initialize_305; procedure Initialize_306; procedure Initialize_307; procedure Initialize_308; procedure Initialize_309; procedure Initialize_310; procedure Initialize_311; procedure Initialize_312; procedure Initialize_313; procedure Initialize_314; procedure Initialize_315; procedure Initialize_316; procedure Initialize_317; procedure Initialize_318; procedure Initialize_319; procedure Initialize_320; procedure Initialize_321; procedure Initialize_322; end AMF.Internals.Tables.DG_Metamodel.Links;
30,693
ada
1
micahwelf/FLTK-Ada
src/fltk-widgets-inputs.ads
private with Interfaces.C.Strings, System; package FLTK.Widgets.Inputs is type Input is new Widget with private; type Input_Reference (Data : not null access Input'Class) is limited null record with Implicit_Dereference => Data; type Input_Kind is (Normal_Kind, Float_Kind, Integer_Kind, Multiline_Kind, Secret_Kind, Readonly_Kind, Wrap_Kind); package Forge is function Create (X, Y, W, H : in Integer; Text : in String) return Input; end Forge; procedure Copy (This : in out Input); procedure Cut (This : in out Input); procedure Cut (This : in out Input; Num_Bytes : in Integer); procedure Cut (This : in out Input; Start, Finish : in Integer); procedure Copy_Cuts (This : in out Input); procedure Undo (This : in out Input); function Has_Changed (This : in Input) return Boolean; procedure Clear_Changed (This : in out Input); function Is_Readonly (This : in Input) return Boolean; procedure Set_Readonly (This : in out Input; To : in Boolean); function Is_Tab_Nav (This : in Input) return Boolean; procedure Set_Tab_Nav (This : in out Input; To : in Boolean); function Is_Wrap (This : in Input) return Boolean; procedure Set_Wrap (This : in out Input; To : in Boolean); function Get_Input_Type (This : in Input) return Input_Kind; function Get_Shortcut_Key (This : in Input) return Key_Combo; procedure Set_Shortcut_Key (This : in out Input; To : in Key_Combo); function Get_Mark (This : in Input) return Natural; procedure Set_Mark (This : in out Input; To : in Natural); function Get_Position (This : in Input) return Natural; procedure Set_Position (This : in out Input; To : in Natural); function Index (This : in Input; Place : in Integer) return Character; procedure Insert (This : in out Input; Str : in String); procedure Replace (This : in out Input; From, To : in Natural; New_Text : in String); function Get_Value (This : in Input) return String; procedure Set_Value (This : in out Input; To : in String); function Get_Maximum_Size (This : in Input) return Natural; procedure Set_Maximum_Size (This : in out Input; To : in Natural); function Size (This : in Input) return Natural; function Get_Cursor_Color (This : in Input) return Color; procedure Set_Cursor_Color (This : in out Input; To : in Color); function Get_Text_Color (This : in Input) return Color; procedure Set_Text_Color (This : in out Input; To : in Color); function Get_Text_Font (This : in Input) return Font_Kind; procedure Set_Text_Font (This : in out Input; To : in Font_Kind); function Get_Text_Size (This : in Input) return Font_Size; procedure Set_Text_Size (This : in out Input; To : in Font_Size); procedure Resize (This : in out Input; W, H : in Integer); procedure Draw (This : in out Input); function Handle (This : in out Input; Event : in Event_Kind) return Event_Outcome; package Extra is procedure Set_Input_Type (This : in out Input; To : in Input_Kind); end Extra; private type Input is new Widget with record Was_Changed : Boolean := False; end record; overriding procedure Finalize (This : in out Input); pragma Inline (Copy); pragma Inline (Cut); pragma Inline (Copy_Cuts); pragma Inline (Undo); pragma Inline (Has_Changed); pragma Inline (Clear_Changed); pragma Inline (Is_Readonly); pragma Inline (Set_Readonly); pragma Inline (Is_Tab_Nav); pragma Inline (Set_Tab_Nav); pragma Inline (Is_Wrap); pragma Inline (Set_Wrap); pragma Inline (Get_Input_Type); pragma Inline (Get_Shortcut_Key); pragma Inline (Set_Shortcut_Key); pragma Inline (Get_Mark); pragma Inline (Set_Mark); pragma Inline (Get_Position); pragma Inline (Set_Position); pragma Inline (Index); pragma Inline (Insert); pragma Inline (Replace); pragma Inline (Get_Value); pragma Inline (Set_Value); pragma Inline (Get_Maximum_Size); pragma Inline (Set_Maximum_Size); pragma Inline (Size); pragma Inline (Get_Cursor_Color); pragma Inline (Set_Cursor_Color); pragma Inline (Get_Text_Color); pragma Inline (Set_Text_Color); pragma Inline (Get_Text_Font); pragma Inline (Set_Text_Font); pragma Inline (Get_Text_Size); pragma Inline (Set_Text_Size); pragma Inline (Resize); pragma Inline (Draw); pragma Inline (Handle); Input_Kind_Values : array (Input_Kind) of Interfaces.C.int := (Normal_Kind => 0, Float_Kind => 1, Integer_Kind => 2, Multiline_Kind => 4, Secret_Kind => 5, Readonly_Kind => 8, Wrap_Kind => 16); function fl_input_get_value (F : in System.Address) return Interfaces.C.Strings.chars_ptr; pragma Import (C, fl_input_get_value, "fl_input_get_value"); pragma Inline (fl_input_get_value); end FLTK.Widgets.Inputs;
30,694
ada
5
kokkonisd/locstats
tests/data/test.adb
with Ada.Text_IO; use Ada.Text_IO; procedure Main is begin -- Say hello! Put_Line("Hello, World!"); end Main;
30,695
ada
1
brucegua/moocos
tools/scitools/conf/understand/ada/ada95/a-stwise.ads
<gh_stars>1-10 ------------------------------------------------------------------------------ -- -- -- GNAT RUNTIME COMPONENTS -- -- -- -- A D A . S T R I N G S . W I D E _ S E A R C H -- -- -- -- S p e c -- -- -- -- $Revision: 2 $ -- -- -- -- Copyright (c) 1992,1993,1994 NYU, All Rights Reserved -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -- -- -- ------------------------------------------------------------------------------ -- This package contains the search functions from Ada.Strings.Wide_Fixed. -- They are separated out because they are shared by Ada.Strings.Wide_Bounded -- and Ada.Strings.Wide_Unbounded, and we don't want to drag other irrelevant -- stuff from Ada.Strings.Wide_Fixed when using the other two packages. We -- make this a private package, since user programs should access these -- subprograms via one of the standard string packages. with Ada.Strings.Wide_Maps; private package Ada.Strings.Wide_Search is pragma Preelaborate (Wide_Search); function Index (Source : in Wide_String; Pattern : in Wide_String; Going : in Direction := Forward; Mapping : in Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity) return Natural; function Index (Source : in Wide_String; Pattern : in Wide_String; Going : in Direction := Forward; Mapping : in Wide_Maps.Wide_Character_Mapping_Function) return Natural; function Index (Source : in Wide_String; Set : in Wide_Maps.Wide_Character_Set; Test : in Membership := Inside; Going : in Direction := Forward) return Natural; function Index_Non_Blank (Source : in Wide_String; Going : in Direction := Forward) return Natural; function Count (Source : in Wide_String; Pattern : in Wide_String; Mapping : in Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity) return Natural; function Count (Source : in Wide_String; Pattern : in Wide_String; Mapping : in Wide_Maps.Wide_Character_Mapping_Function) return Natural; function Count (Source : in Wide_String; Set : in Wide_Maps.Wide_Character_Set) return Natural; procedure Find_Token (Source : in Wide_String; Set : in Wide_Maps.Wide_Character_Set; Test : in Membership; First : out Positive; Last : out Natural); end Ada.Strings.Wide_Search;
30,696
ada
1
Fabien-Chouteau/tiled-code-gen
src/tcg-collision_objects.adb
<reponame>Fabien-Chouteau/tiled-code-gen<filename>src/tcg-collision_objects.adb<gh_stars>1-10 with Ada.Strings.Fixed; with TCG.Utils; use TCG.Utils; with DOM.Core; use DOM.Core; with DOM.Core.Elements; use DOM.Core.Elements; with DOM.Core.Nodes; use DOM.Core.Nodes; package body TCG.Collision_Objects is type Polygon_Access is access all Polygon; function To_Float (Str : String) return Float; function To_Point (Str : String) return Point; function To_Polygon (Offset : Point; Str : String) return not null Polygon_Access; function Create (N : Node) return Collision_Shape; function Inside_Ellipse (Pt : Point; Ellipse : Polygon) return Boolean with Pre => Ellipse'Length = 4 and then Ellipse'First = 1; -------------- -- To_Float -- -------------- function To_Float (Str : String) return Float is (Float'Value (Str)); -------------- -- To_Point -- -------------- function To_Point (Str : String) return Point is Index : constant Natural := Ada.Strings.Fixed.Index (Str, ","); begin return (To_Float (Str (Str'First .. Index - 1)), To_Float (Str (Index + 1 .. Str'Last))); end To_Point; ---------------- -- To_Polygon -- ---------------- function To_Polygon (Offset : Point; Str : String) return not null Polygon_Access is Number_Of_Points : constant Natural := Ada.Strings.Fixed.Count (Str, " ") + 1; Ret : constant not null Polygon_Access := new Polygon (1 .. Number_Of_Points); Index : Natural; Last_Index : Natural := Str'First; begin for Pt of Ret.all loop Index := Ada.Strings.Fixed.Index (Str (Last_Index .. Str'Last), " "); if Index = 0 then -- Last point in the list Pt := To_Point (Str (Last_Index .. Str'Last)); else Pt := To_Point (Str (Last_Index .. Index - 1)); end if; Pt.X := Pt.X + Offset.X; Pt.Y := Pt.Y + Offset.Y; Last_Index := Index + 1; end loop; return Ret; end To_Polygon; ------------ -- Create -- ------------ function Create (N : Node) return Collision_Shape is X : constant Float := To_Float (Item_As_String (N, "x")); Y : constant Float := To_Float (Item_As_String (N, "y")); Has_Width : constant Boolean := Item_Exists (N, "width"); Has_Height : constant Boolean := Item_Exists (N, "height"); Height, Width : Float; Rect : Polygon (1 .. 4); Poly : access Polygon; List : Node_List; begin if Has_Width or else Has_Height then Width := To_Float (Item_As_String (N, "width")); Height := To_Float (Item_As_String (N, "height")); Rect := ((X, Y), (X + Width, Y), (X + Width, Y + Height), (X, Y + Height)); List := Get_Elements_By_Tag_Name (N, "ellipse"); if Length (List) /= 0 then Free (List); return (Ellipse_Shape, Rect); else Free (List); return (Rectangle_Shape, Rect); end if; else List := Get_Elements_By_Tag_Name (N, "polygon"); if Length (List) /= 1 then raise Program_Error with "Invalid number of polygon elements"; end if; Poly := To_Polygon ((X, Y), Item_As_String (Item (List, 0), "points")); Free (List); return (Polygon_Shape, Poly); end if; end Create; ------------------- -- Has_Collision -- ------------------- function Has_Collision (This : Collisions) return Boolean is (not This.List.Is_Empty); ------------ -- Create -- ------------ procedure Load (This : in out Collisions; N : DOM.Core.Node) is List : Node_List; begin List := Elements.Get_Elements_By_Tag_Name (N, "object"); for Index in 1 .. Length (List) loop This.List.Append (Create (Item (List, Index - 1))); end loop; Free (List); end Load; -------------------- -- Inside_Ellipse -- -------------------- function Inside_Ellipse (Pt : Point; Ellipse : Polygon) return Boolean is Diag_1 : constant Geometry.Line := To_Line (Ellipse (1), Ellipse (3)); Diag_2 : constant Geometry.Line := To_Line (Ellipse (2), Ellipse (4)); Center : constant Point := Intersection (Diag_1, Diag_2); H_Axis : constant Vector := To_Vector ((Ellipse (1), Ellipse (2))); V_Axis : constant Vector := To_Vector ((Ellipse (2), Ellipse (3))); H_Semi : constant Distance_Type := Length (H_Axis) / 2.0; V_Semi : constant Distance_Type := Length (V_Axis) / 2.0; begin return ( ((Pt.X - Center.X)**2 / H_Semi**2) + ((Pt.Y - Center.Y)**2 / V_Semi**2) ) <= 1.0; end Inside_Ellipse; ------------- -- Collide -- ------------- function Collide (This : Collisions; X, Y : Float) return Boolean is function Fixed_Inside (P : Point; Poly : Polygon) return Boolean; function Fixed_Inside (P : Point; Poly : Polygon) return Boolean is J : Natural := Poly'Last; C : Boolean := False; Deltay : Float; begin -- See http://www.ecse.rpi.edu/Homepages/wrf/Research -- /Short_Notes/pnpoly.html for S in Poly'Range loop Deltay := P.Y - Poly (S).Y; -- The divide below is mandatory: if you transform it into a -- multiplication on the other side, the sign of the denominator -- will flip the inequality, and thus make the code harder. if ((0.0 <= Deltay and then P.Y < Poly (J).Y) or else (Poly (J).Y <= P.Y and then Deltay < 0.0)) and then (P.X - Poly (S).X < (Poly (J).X - Poly (S).X) * Deltay / (Poly (J).Y - Poly (S).Y)) then C := not C; end if; J := S; end loop; return C; end Fixed_Inside; begin for Shape of This.List loop case Shape.Kind is when Rectangle_Shape => if Fixed_Inside ((X, Y), Shape.Rect) then return True; end if; when Ellipse_Shape => if Inside_Ellipse ((X, Y), Shape.Rect) then return True; end if; when Polygon_Shape => if Fixed_Inside ((X, Y), Shape.Poly.all) then return True; end if; end case; end loop; return False; end Collide; end TCG.Collision_Objects;
30,697
ada
0
persan/midnightsun-ctf-LoveLacedLetter
src/posix.ads
<gh_stars>0 with System.Storage_Elements; private with Ada.Unchecked_Conversion; package Posix is type File; type File_Status; type Memory_Map; -- subtype unsigned_long is Interfaces.C.unsigned_long; -- subtype unsigned is Interfaces.C.unsigned; -- subtype int is Interfaces.C.int; -- subtype long is Interfaces.C.long; -- subtype Unsigned_32 is Interfaces.Unsigned_32; type unsigned is mod 2 ** Integer'Size; type unsigned_long is mod 2 ** Long_Integer'Size; type int is new Integer; type long is new Long_Integer; type Unsigned_32 is mod 2 ** 32; for Unsigned_32'Size use 32; subtype Void_Ptr is System.Address; type S_FLag is new Unsigned_32; type O_FLag is new Unsigned_32; type Prot_FLag is new Unsigned_32; use type Void_Ptr; -- function Shift_Right -- (Value : Unsigned_32; -- Amount : Natural) return Unsigned_32 renames -- Interfaces.Shift_Right; -- -- function Shift_Right -- (Value : S_FLag; -- Amount : Natural) return S_FLag is -- (S_FLag (Shift_Right (Unsigned_32 (Value), Amount))); Nul : constant Character := Character'Val (0); type C_String is new String with Dynamic_Predicate => C_String'Length > 0 and then C_String (C_String'Last) = Nul; function "-" (Text : C_String) return String; -- Removes the last 'Nul' character and returns a normal String. function "+" (Text : String) return C_String; -- Appends a 'Nul' character to a standard String and returns a C_String. -- -- Non-primitive subprograms -- -- Write to standard out. May be used instead of Ada.Text_IO.Put (). procedure Put (Text : String) with Global => null; -- Write to standard out. May be used instead of Ada.Text_IO.Put_Line (). procedure Put_Line (Text : String) with Global => null; function Get_Line return String; -- -- Encoding of the file mode. -- S_IFMT : constant S_FLag := 0170000; --These bits determine file type. -- -- File types -- S_IFDIR : constant S_FLag := 0040000; -- Directory. S_IFCHR : constant S_FLag := 0020000; -- Character device. S_IFBLK : constant S_FLag := 0060000; -- Block device. S_IFREG : constant S_FLag := 0100000; -- Regular file. S_IFIFO : constant S_FLag := 0010000; -- FIFO. S_IFLNK : constant S_FLag := 0120000; -- Symbolic link. S_IFSOCK : constant S_FLag := 0140000; -- Socket. -- #define __S_ISUID 04000 /* Set user ID on execution. */ -- #define __S_ISGID 02000 /* Set group ID on execution. */ -- #define __S_ISVTX 01000 /* Save swapped text after use (sticky). */ -- #define __S_IREAD 0400 /* Read by owner. */ -- #define __S_IWRITE 0200 /* Write by owner. */ -- #define __S_IEXEC 0100 /* Execute by owner. */ -- Read by owner. S_IRUSR : constant S_FLag := 0400; -- Write by owner. S_IWUSR : constant S_FLag := 0200; -- Execute by owner. S_IXUSR : constant S_FLag := 0100; -- Read, write, and execute by owner. S_IRWXU : constant S_FLag := S_IRUSR or S_IWUSR or S_IXUSR; -- Read by group. S_IRGRP : constant S_FLag := 3_200; -- Write by group. S_IWGRP : constant S_FLag := 1_600; -- Execute by group. S_IXGRP : constant S_FLag := 800; -- Read, write, and execute by group. S_IRWXG : constant S_FLag := 5_600; -- Read by others. S_IROTH : constant S_FLag := 25_600; -- Write by others. S_IWOTH : constant S_FLag := 12_800; -- Execute by others. S_IXOTH : constant S_FLag := 6_400; -- Read, write, and execute by others. S_IRWXO : constant S_FLag := 44_800; -- Open for reading only O_RDONLY : constant O_FLag := 16#00#; -- Open for write only O_WRONLY : constant O_FLag := 16#01#; -- Open for reading and writing O_RDWR : constant O_FLag := 16#02#; O_ACCMODE : constant O_FLag := 16#03#; O_CREAT : constant O_FLag := 0100; O_EXCL : constant O_FLag := 0200; O_NOCTTY : constant O_FLag := 0400; O_TRUNC : constant O_FLag := 01000; O_APPEND : constant O_FLag := 02000; O_NONBLOCK : constant O_FLag := 04000; O_SYNC : constant O_FLag := 04010000; O_ASYNC : constant O_FLag := 020000; -- Protections are chosen from these bits, OR'd together. The -- implementation does not necessarily support PROT_EXEC or PROT_WRITE -- without PROT_READ. The only guarantees are that no writing will be -- allowed without PROT_WRITE and no access will be allowed for PROT_NONE. -- Page can be read. PROT_READ : constant Prot_FLag := 16#1#; -- Page can be written. PROT_WRITE : constant Prot_FLag := 16#2#; -- Page can be executed. PROT_EXEC : constant Prot_FLag := 16#4#; -- Page can not be accessed. PROT_NONE : constant Prot_FLag := 16#0#; -- Extend change to start of growsdown vma (mprotect only). PROT_GROWSDOWN : constant Prot_FLag := 16#01000000#; -- Extend change to start of growsup vma (mprotect only). PROT_GROWSUP : constant Prot_FLag := 16#02000000#; -- -- Sharing types (must choose one and only one of these). -- -- Share changes. MAP_SHARED : constant := 16#01#; -- Changes are private. MAP_PRIVATE : constant := 16#02#; -- Interpret addr exactly. MAP_FIXED : constant := 16#10#; -- Don't use a file. MAP_ANON : constant := 16#20#; MAP_HUGE_SHIFT : constant := 26; MAP_HUGE_MASK : constant := 16#3f#; MAP_FAILED : constant Void_Ptr; -- -- Flags to `msync'. -- -- Sync memory asynchronously. MS_ASYNC : constant := 1; -- Synchronous memory sync. MS_SYNC : constant := 4; -- Invalidate the caches. MS_INVALIDATE : constant := 2; subtype Device_Id_Type is unsigned_long; subtype Inode_Number_Type is unsigned_long; subtype Hard_Link_Count_Type is unsigned_long; subtype Mode_Type is unsigned; subtype User_Id_Type is unsigned; subtype Group_Id_Type is unsigned; subtype Size_Type is unsigned_long; subtype SSize_Type is long; subtype Block_Size_Type is long; subtype Block_Count_Type is long; subtype Time_Sec is long; subtype Time_Nano_Sec is long; Nil : Void_Ptr renames System.Null_Address; subtype Offset is long; subtype Byte is System.Storage_Elements.Storage_Element; subtype Byte_Array is System.Storage_Elements.Storage_Array; type Time is record Sec : aliased Time_Sec; Nano_Sec : aliased Time_Nano_Sec; end record with Convention => C_Pass_By_Copy; type File is tagged limited private with Default_Initial_Condition => Is_Closed (File); procedure Open (File : in out Posix.File; File_Name : in C_String; Flags : in O_FLag; S_Flags : in S_FLag) with Global => null, Pre => File.Is_Closed; -- To open a file for reading example: -- -- File : Posix.File; -- procedure Close (File : in out Posix.File) with Global => null, Pre => File.Is_Open, Post => File.Is_Closed; procedure Write (File : Posix.File; Bytes : Byte_Array) with Global => null, Pre => File.Is_Open; function Read (File : Posix.File; Bytes : in out Byte_Array) return SSize_Type with Global => null, Pre => File.Is_Open; function File_Descriptor (File : Posix.File) return Integer with Global => null, Pre => File.Is_Open; procedure Get_File_Status (File : in Posix.File; Status : in out File_Status) with Global => null, Pre => File.Is_Open; procedure Map_Memory (File : in Posix.File; Address : Void_Ptr; Len : Size_Type; Prot : Prot_FLag; Flags : int; Offset : Posix.Offset; Memory_Map : in out Posix.Memory_Map) with Global => null, Pre => not Has_Mapping (Memory_Map); function Is_Open (File : Posix.File) return Boolean with Global => null; function Is_Closed (File : Posix.File) return Boolean with Global => null; type File_Status is tagged limited private; function Is_Valid (Status : File_Status) return Boolean with Global => null; function Device_Id (Status : File_Status) return Device_Id_Type with Global => null, Pre => Status.Is_Valid; function Inode_Number (Status : File_Status) return Inode_Number_Type with Global => null, Pre => Status.Is_Valid; function Hard_Link_Count (Status : File_Status) return Hard_Link_Count_Type with Global => null, Pre => Status.Is_Valid; function Mode (Status : File_Status) return Mode_Type with Global => null, Pre => Status.Is_Valid; function User_Id (Status : File_Status) return User_Id_Type with Global => null, Pre => Status.Is_Valid; function Group_Id (Status : File_Status) return Group_Id_Type with Global => null, Pre => Status.Is_Valid; function Special_Device_Id (Status : File_Status) return Device_Id_Type with Global => null, Pre => Status.Is_Valid; function Size (Status : File_Status) return Offset with Global => null, Pre => Status.Is_Valid; -- The file size in bytes. function Block_Size (Status : File_Status) return Block_Size_Type with Global => null, Pre => Status.Is_Valid; -- Number of 512B blocks allocated function Block_Count (Status : File_Status) return Block_Size_Type with Global => null, Pre => Status.Is_Valid; function Last_Access_Time (Status : File_Status) return Time with Global => null, Pre => Status.Is_Valid; function Modification_Time (Status : File_Status) return Time with Global => null, Pre => Status.Is_Valid; -- Last status change time function Change_Time (Status : File_Status) return Time with Global => null, Pre => Status.Is_Valid; type Memory_Map is tagged limited private; function Has_Mapping (Map : Posix.Memory_Map) return Boolean with Global => null; function Mapping (Map : Posix.Memory_Map) return Void_Ptr with Global => null, Pre => Map.Has_Mapping; -- Returns 0 on success, otherwise -1. function Unmap_Memory (Map : in out Posix.Memory_Map) return Integer with Global => null, Post => (if Unmap_Memory'Result = 0 then not Map.Has_Mapping); -- Returns 0 on success, otherwise -1. function Memory_Unmap (Address : Void_Ptr; Length : Size_Type) return Integer with Global => null; -- -- Standard file descriptors. -- STDIN : constant File; -- Standard input. STDOUT : constant File; -- Standard output. STDERR : constant File; -- Standard error output. private package Px_Thin is -- Standard file descriptors. STDIN_FILENO : constant := 0; -- Standard input. STDOUT_FILENO : constant := 1; -- Standard output. STDERR_FILENO : constant := 2; -- Standard error output. type File_Status_T is record -- ID of device containing file Device_Id : aliased Device_Id_Type; Inode_Number : aliased Inode_Number_Type; Hard_Link_Count : aliased Hard_Link_Count_Type; -- Protection Mode : aliased Mode_Type; User_Id : aliased User_Id_Type; Group_Id : aliased Group_Id_Type; Padding_0 : aliased int; -- Device ID (if special file) Special_Device_Id : aliased Device_Id_Type; -- Total size, in bytes Size : aliased Offset; -- Blocksize for file system I/O Block_Size : aliased Block_Size_Type; -- Number of 512B blocks allocated Block_Count : aliased Block_Count_Type; -- Time of last access Access_Time : aliased Time; -- Time of last modification Modification_Time : aliased Time; -- Time of last status change Change_Time : aliased Time; Padding_1 : long; Padding_2 : long; Padding_3 : long; end record with Convention => C_Pass_By_Copy; function Get_File_Status (Fd : Integer; Status : access File_Status_T) return Integer with Import => True, Convention => C, External_Name => "fstat"; -- Establishes a connection between a file and a file descriptor. -- The file descriptor handle (a non-negative number) -- is returned upon success, otherwise -1. -- -- Applications shall specify exactly one of the first three flags: -- O_RDONLY, O_WRONLY and O_RDWR. And then any combination of O_APPEND, -- O_CREAT, O_DSYNC, O_EXCL, O_NOCTTY, O_NONBLOCK, O_RSYNC, -- O_SYNC, O_TRUNC. function Open (File_Name : C_String; Flags : O_FLag; S_Flags : S_FLag) return Integer with Import => True, Convention => C, External_Name => "open"; procedure Close (File_Descriptor : Integer) with Import => True, Convention => C, External_Name => "close"; function Write (File_Descriptor : Integer; Buffer : Byte_Array; Count : Size_Type) return SSize_Type with Import => True, Convention => C, External_Name => "write"; function Write (File_Descriptor : Integer; Buffer : String; Count : Size_Type) return SSize_Type with Import => True, Convention => C, External_Name => "write"; function Read (File_Descriptor : Integer; Buffer : in out Byte_Array; Count : Size_Type) return SSize_Type with Import => True, Convention => C, External_Name => "read"; function Mmap (Addr : Void_Ptr; Len : Size_Type; Prot : Prot_FLag; Flags : int; Fd : Integer; Offset : Posix.Offset) return Void_Ptr with Import => True, Convention => C, External_Name => "mmap"; function Munmap (Addr : Void_Ptr; Length : Size_Type) return Integer with Import => True, Convention => C, External_Name => "munmap"; end Px_Thin; type File is tagged limited record My_File_Descriptor : Integer; My_Is_Open : Boolean := False; end record; function Is_Open (File : Posix.File) return Boolean is (File.My_Is_Open); function Is_Closed (File : Posix.File) return Boolean is (not File.My_Is_Open); type File_Status is tagged limited record My_Status : aliased Px_Thin.File_Status_T; My_Is_Valid : Boolean := False; end record; function File_Descriptor (File : Posix.File) return Integer is (File.My_File_Descriptor); function Is_Valid (Status : File_Status) return Boolean is (Status.My_Is_Valid); function Device_Id (Status : File_Status) return Device_Id_Type is (Status.My_Status.Device_Id); function Inode_Number (Status : File_Status) return Inode_Number_Type is (Status.My_Status.Inode_Number); function Hard_Link_Count (Status : File_Status) return Hard_Link_Count_Type is (Status.My_Status.Hard_Link_Count); function Mode (Status : File_Status) return Mode_Type is (Status.My_Status.Mode); function User_Id (Status : File_Status) return User_Id_Type is (Status.My_Status.User_Id); function Group_Id (Status : File_Status) return Group_Id_Type is (Status.My_Status.Group_Id); function Special_Device_Id (Status : File_Status) return Device_Id_Type is (Status.My_Status.Special_Device_Id); function Size (Status : File_Status) return Offset is (Status.My_Status.Size); function Block_Size (Status : File_Status) return Block_Size_Type is (Status.My_Status.Block_Size); function Block_Count (Status : File_Status) return Block_Size_Type is (Status.My_Status.Block_Count); function Last_Access_Time (Status : File_Status) return Time is (Status.My_Status.Access_Time); function Modification_Time (Status : File_Status) return Time is (Status.My_Status.Modification_Time); function Change_Time (Status : File_Status) return Time is (Status.My_Status.Change_Time); function Conv is new Ada.Unchecked_Conversion (Source => long, Target => Void_Ptr); MAP_FAILED_VALUE : constant long := -1; MAP_FAILED : constant Void_Ptr := Conv (MAP_FAILED_VALUE); type Memory_Map is tagged limited record My_Mapping : Void_Ptr := MAP_FAILED; My_Length : Size_Type; end record; function Has_Mapping (Map : Posix.Memory_Map) return Boolean is (Map.My_Mapping /= MAP_FAILED); function Mapping (Map : Posix.Memory_Map) return Void_Ptr is (Map.My_Mapping); STDIN : constant File := ( My_File_Descriptor => Px_Thin.STDIN_FILENO, My_Is_Open => True ); STDOUT : constant File := ( My_File_Descriptor => Px_Thin.STDOUT_FILENO, My_Is_Open => True ); STDERR : constant File := ( My_File_Descriptor => Px_Thin.STDERR_FILENO, My_Is_Open => True ); end Posix;
30,698
ada
0
caqg/linux-home
.emacs.d/elpa/ada-ref-man-2012.5/progs/arm_texi.adb
with Ada.Exceptions; with Ada.Strings.Fixed; package body ARM_Texinfo is -- Copyright (C) 2003, 2007, 2010 - 2013, 2015, 2017, 2018 <NAME>. All Rights Reserved. -- E-Mail: <EMAIL> -- -- This library is free software; you can redistribute it and/or -- modify it under terms of the GNU General Public License as -- published by the Free Software Foundation; either version 3, or (at -- your option) any later version. This library is distributed in the -- hope that it will be useful, but WITHOUT ANY WARRANTY; without even -- the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -- PURPOSE. See the GNU General Public License for more details. You -- should have received a copy of the GNU General Public License -- distributed with this program; see file gnu-3-0.txt. If not, write to -- the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -- MA 02111-1307, USA. -- --------------------------------------- -- -- Edit History: -- -- Ancient - S L - Developed package as add-on to Arm_Form. -- 10/19/11 - RLB - Integrated outside-developed package into Arm_Form. -- Commented out/replaced Ada 2005 features (this is -- Ada 95 code). Updated for a few other changes since -- the last update. -- 10/25/11 - RLB - Added old insertion version to Revised_Clause_Header. -- 4/ 1/12 - S L - Implemented remaining Texinfo implementation. -- 4/22/12 - S L - Move @dircategory, @direntry before first @node. -- 4/28/12 - S L - Add @w{} after @anchor; otherwise following whitespace -- is dropped. -- 8/31/12 - RLB - Added Output_Path. -- 10/18/12 - RLB - Added additional hanging styles. -- 11/26/12 - RLB - Added subdivision names to Clause_Header and -- Revised_Clause_Header. -- 3/12/13 - S L - use correct version in direntry use Ada.Text_IO; Indentation : constant := 5; -- VERSION: This is fragile; it changes with each version of the manual. Index_Clause_Name : constant String := "Index"; Operators_Clause : constant String := "operators"; Last_Index_Clause : constant Character := 'Y'; ---------- -- local subprograms procedure Check_Not_In_Paragraph (Output_Object : in Texinfo_Output_Type) is begin if Output_Object.In_Paragraph then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, "In paragraph"); end if; end Check_Not_In_Paragraph; procedure Check_Valid (Output_Object : in Texinfo_Output_Type) is begin if not Output_Object.Is_Valid then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, "Not valid object"); end if; end Check_Valid; procedure Unexpected_State (Output_Object : in Texinfo_Output_Type) is begin Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, "Unexpected state: " & State_Type'Image (Output_Object.State)); end Unexpected_State; procedure Escape_Put (Output_Object : in Texinfo_Output_Type; Char : in Character; Preserve_Space : in Boolean := False) is begin -- Escape special chars if Char = '@' then Put (Output_Object.File, "@@"); elsif Char = '{' then Put (Output_Object.File, "@{"); elsif Char = '}' then Put (Output_Object.File, "@}"); elsif Char = ''' then -- Avoid makeinfo converting '' into " Put (Output_Object.File, "'@w{}"); elsif Char = '`' then -- Avoid makeinfo converting `` into " Put (Output_Object.File, "`@w{}"); elsif Char = '-' then Put (Output_Object.File, "@minus{}"); elsif Char = ' ' and Preserve_Space then -- Don't allow collapsing spaces Put (Output_Object.File, "@w{ }"); elsif Char = '\' then -- This confuses texi2dvi if not escaped. Put (Output_Object.File, "@code{\}"); else Put (Output_Object.File, Char); end if; end Escape_Put; procedure Escape_Put (Output_Object : in Texinfo_Output_Type; Text : in String; Preserve_Space : in Boolean := False) is begin for I in Text'Range loop Escape_Put (Output_Object, Text (I), Preserve_Space); end loop; end Escape_Put; procedure End_Title_Page (Output_Object : in out Texinfo_Output_Type) is use ARM_Contents; procedure Put_Top_Menu_Item (Title : in Title_Type; Level : in Level_Type; Clause_Number : in Clause_Number_Type; Version : in ARM_Contents.Change_Version_Type; Quit : out Boolean) is pragma Unreferenced (Version); -- we are only concerned with version 2 First_Part : String (1 .. 14); -- Get all Titles aligned. begin Quit := False; case Level is when Section | Normative_Annex | Informative_Annex | Plain_Annex => Ada.Strings.Fixed.Move (Source => "* " & Make_Clause_Number (Level, Clause_Number) & " ::", Target => First_Part); Put_Line (Output_Object.File, First_Part & Title); when Unnumbered_Section | Clause | Subclause | Subsubclause => null; when ARM_Contents.Dead_Clause => raise Program_Error with "Dead_Clause header??"; -- No headers for dead clauses. end case; end Put_Top_Menu_Item; procedure Put_Top_Menu is new For_Each (Put_Top_Menu_Item); begin New_Line (Output_Object.File); -- Terminate unneeded "@center" Put_Line (Output_Object.File, "@menu"); Put_Line (Output_Object.File, "* Front Matter:: Copyright, Foreword, etc."); -- Not a section in ARM sources Put_Top_Menu; Put_Line (Output_Object.File, "* Index :: Index"); -- Not in ARM sources Put_Line (Output_Object.File, "@end menu"); -- @node current Put_Line (Output_Object.File, "@node Front Matter"); Put_Line (Output_Object.File, "@chapter Front Matter"); end End_Title_Page; procedure Get_Clause_Section (Clause_String : in String; Section_Number : out ARM_Contents.Section_Number_Type; Clause_Integer : out Natural) is -- This is a partial inverse of ARM_Contents.Make_Clause_Number. -- -- Clause_String has "section.clause.subclause", possibly no subclause. -- -- "section" can be a number, a letter "N", or "Annex N", where -- -- 'N' = Character'Val (Character'Pos('A') + (Section_Number - ANNEX_START) Section_Dot : constant Natural := Ada.Strings.Fixed.Index (Source => Clause_String, Pattern => "."); Clause_Dot : constant Natural := Ada.Strings.Fixed.Index (Source => Clause_String (Section_Dot + 1 .. Clause_String'Last), Pattern => "."); use type ARM_Contents.Section_Number_Type; begin if Section_Dot = 8 then -- Section is "Annex N" Section_Number := ARM_Contents.ANNEX_START + Character'Pos (Clause_String (Clause_String'First + 6)) - Character'Pos ('A'); elsif Character'Pos (Clause_String (Clause_String'First)) >= Character'Pos ('A') then -- Section is letter. Section_Number := ARM_Contents.ANNEX_START + Character'Pos (Clause_String (Clause_String'First)) - Character'Pos ('A'); else Section_Number := ARM_Contents.Section_Number_Type'Value (Clause_String (Clause_String'First .. Section_Dot - 1)); end if; if Clause_Dot = 0 then Clause_Integer := Natural'Value (Clause_String (Section_Dot + 1 .. Clause_String'Last)); else Clause_Integer := Natural'Value (Clause_String (Section_Dot + 1 .. Clause_Dot - 1)); end if; end Get_Clause_Section; procedure Handle_Indent (Output_Object : in Texinfo_Output_Type; Texinfo_Item : in String; Extra_Indent : in ARM_Output.Paragraph_Indent_Type := 0) is use type ARM_Output.Paragraph_Indent_Type; begin for I in 1 .. Output_Object.Indent + Extra_Indent loop Put_Line (Output_Object.File, Texinfo_Item); end loop; end Handle_Indent; procedure Add_To_Column_Item (Output_Object : in out Texinfo_Output_Type; Text : in String) is begin if Output_Object.Column_Text (Output_Object.Current_Column) = null or else Output_Object.Column_Text (Output_Object.Current_Column).Row /= Output_Object.Current_Row then -- Start a new row. Output_Object.Column_Text (Output_Object.Current_Column) := new Column_Text_Item_Type' (Text => (others => ' '), Length => 0, Row => Output_Object.Current_Row, Next => Output_Object.Column_Text (Output_Object.Current_Column)); end if; if Output_Object.Column_Text (Output_Object.Current_Column).Length + Text'Length > Output_Object.Column_Text (Output_Object.Current_Column).Text'Length then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, "Column item full, but more text: " & Output_Object.Column_Text (Output_Object.Current_Column).Text (1 .. Output_Object.Column_Text (Output_Object.Current_Column).Length)); else declare Current_Text : Column_Text_Item_Type renames Output_Object.Column_Text (Output_Object.Current_Column).all; begin Current_Text.Text (Current_Text.Length + 1 .. Current_Text.Length + Text'Length) := Text; Current_Text.Length := Current_Text.Length + Text'Length; if Output_Object.Column_Widths (Output_Object.Current_Column) < Current_Text.Length then Output_Object.Column_Widths (Output_Object.Current_Column) := Current_Text.Length; end if; end; end if; end Add_To_Column_Item; procedure Pad_Columns (Output_Object : in out Texinfo_Output_Type) -- Ensure that all columns have the same number of (possibly -- empty) rows, for table headers. is Item : Column_Text_Ptr; First_New_Row : Natural; begin for Col in 1 .. Output_Object.Column_Count loop Item := Output_Object.Column_Text (Col); if Item = null then First_New_Row := 1; else First_New_Row := Item.Row + 1; end if; for I in First_New_Row .. Output_Object.Max_Row loop Output_Object.Column_Text (Col) := new Column_Text_Item_Type' (Text => (others => ' '), Length => 1, Row => I, Next => Output_Object.Column_Text (Col)); end loop; end loop; end Pad_Columns; procedure Output_Column_Widths (Output_Object : in out Texinfo_Output_Type) is begin New_Line (Output_Object.File); Put (Output_Object.File, "@multitable "); for I in 1 .. Output_Object.Column_Count loop Put (Output_Object.File, " {" & String'(1 .. Output_Object.Column_Widths (I) => 'w') & "}"); end loop; end Output_Column_Widths; procedure Output_Columns (Output_Object : in out Texinfo_Output_Type) is Row : Natural := 1; Item : Column_Text_Ptr; Temp : Column_Text_Ptr; begin Rows : loop New_Line (Output_Object.File); Put (Output_Object.File, "@item "); -- For all columns, output the items for this row. Note that -- the last row is at the front of each column list; the -- first row is at the end. We delete the rows as we output -- them, so the one we want is always at the end of the -- column list. Columns : for Col in 1 .. Output_Object.Column_Count loop Item := Output_Object.Column_Text (Col); if Item = null then -- Previously finished column null; elsif Item.Next = null then -- This is the last item in the column. if Item.Row /= Row then -- This column is empty for this row. Item := null; else -- Output Item, and mark that we're done outputing -- this column. Output_Object.Column_Text (Col) := null; end if; else -- Find first item for this row in the column. while Item.Next /= null and then Item.Next.Row /= Row loop Item := Item.Next; end loop; -- Output Item.Next, take it out of list. Temp := Item; Item := Item.Next; Temp.Next := null; end if; if Item /= null then -- Output the item Escape_Put (Output_Object, Item.Text (1 .. Item.Length), Preserve_Space => True); Free (Item); if Col /= Output_Object.Column_Count then Put (Output_Object.File, " @tab "); end if; else -- This column is empty for this row if Col < Output_Object.Column_Count then Put (Output_Object.File, " @tab "); end if; end if; end loop Columns; if Output_Object.Column_Text = Column_Text_Ptrs_Type'(others => null) then -- We've output everything. exit Rows; end if; -- End the row: Row := Row + 1; end loop Rows; end Output_Columns; procedure Index_Menu (Output_Object : in out Texinfo_Output_Type) is begin Put_Line (Output_Object.File, "@menu"); Put_Line (Output_Object.File, "* operators::"); Put_Line (Output_Object.File, "* A::"); Put_Line (Output_Object.File, "* B::"); Put_Line (Output_Object.File, "* C::"); Put_Line (Output_Object.File, "* D::"); Put_Line (Output_Object.File, "* E::"); Put_Line (Output_Object.File, "* F::"); Put_Line (Output_Object.File, "* G::"); Put_Line (Output_Object.File, "* H::"); Put_Line (Output_Object.File, "* I::"); Put_Line (Output_Object.File, "* J::"); Put_Line (Output_Object.File, "* K::"); Put_Line (Output_Object.File, "* L::"); Put_Line (Output_Object.File, "* M::"); Put_Line (Output_Object.File, "* N::"); Put_Line (Output_Object.File, "* O::"); Put_Line (Output_Object.File, "* P::"); Put_Line (Output_Object.File, "* Q::"); Put_Line (Output_Object.File, "* R::"); Put_Line (Output_Object.File, "* S::"); Put_Line (Output_Object.File, "* T::"); Put_Line (Output_Object.File, "* U::"); Put_Line (Output_Object.File, "* V::"); Put_Line (Output_Object.File, "* W::"); Put_Line (Output_Object.File, "* X::"); Put_Line (Output_Object.File, "* Y::"); -- Put_Line (Output_Object.File, "* Z::"); -- VERSION: No entries in Z Put_Line (Output_Object.File, "@end menu"); -- @node current Put_Line (Output_Object.File, "@node " & Operators_Clause); Put_Line (Output_Object.File, "@section operators"); end Index_Menu; ---------- -- Public subprograms. Alphabetical order procedure AI_Reference (Output_Object : in out Texinfo_Output_Type; Text : in String; AI_Number : in String) is begin Ordinary_Text (Output_Object, AI_Number & Text); end AI_Reference; procedure Category_Header (Output_Object : in out Texinfo_Output_Type; Header_Text : String) is begin Check_Not_In_Paragraph (Output_Object); -- Can't be in a multi-column setting. -- -- Don't use @heading; that causes a weird underline in info, -- that isn't centered! Put_Line (Output_Object.File, "@center @emph{" & Header_Text & "}"); New_Line (Output_Object.File, 2); end Category_Header; procedure Clause_Header (Output_Object : in out Texinfo_Output_Type; Header_Text : in String; Level : in ARM_Contents.Level_Type; Clause_Number : in String; Top_Level_Subdivision_Name : in ARM_Output.Top_Level_Subdivision_Name_Kind; No_Page_Break : in Boolean := False) is pragma Unreferenced (No_Page_Break); pragma Unreferenced (Top_Level_Subdivision_Name); Title : constant String := Clause_Number & " " & Header_Text; use ARM_Contents; Section_Number : Section_Number_Type; Clause_Integer : Natural; procedure Put_Clause_Menu_Item (Item_Title : in Title_Type; Item_Level : in Level_Type; Item_Clause_Number : in Clause_Number_Type; Version : in ARM_Contents.Change_Version_Type; Quit : out Boolean) is pragma Unreferenced (Version); -- only version 2 First_Part : String (1 .. 14); -- Get all Titles aligned. begin Quit := False; case Item_Level is when Section | Unnumbered_Section | Normative_Annex | Informative_Annex | Plain_Annex | Subclause | Subsubclause => -- We are doing Clause here null; when Clause => if Item_Clause_Number.Section < Section_Number then null; elsif Item_Clause_Number.Section = Section_Number then Ada.Strings.Fixed.Move (Source => "* " & Make_Clause_Number (Item_Level, Item_Clause_Number) & " ::", Target => First_Part); Put_Line (Output_Object.File, First_Part & Item_Title); else Quit := True; end if; when Dead_Clause => raise Program_Error with "Dead Clause in menu??"; -- No dead clauses should be output. end case; end Put_Clause_Menu_Item; procedure Put_Clause_Menu is new For_Each (Put_Clause_Menu_Item); procedure Put_Subclause_Menu_Item (Item_Title : in Title_Type; Item_Level : in Level_Type; Item_Clause_Number : in Clause_Number_Type; Version : in ARM_Contents.Change_Version_Type; Quit : out Boolean) is pragma Unreferenced (Version); -- only version 2 First_Part : String (1 .. 14); -- Get all Titles aligned. begin Quit := False; case Item_Level is when Section | Unnumbered_Section | Normative_Annex | Informative_Annex | Plain_Annex | Clause | Subsubclause => -- We are doing Subclause here null; when Subclause => if Item_Clause_Number.Section < Section_Number then null; elsif Item_Clause_Number.Section = Section_Number then if Item_Clause_Number.Clause < Clause_Integer then null; elsif Item_Clause_Number.Clause = Clause_Integer then Ada.Strings.Fixed.Move (Source => "* " & Make_Clause_Number (Item_Level, Item_Clause_Number) & " ::", Target => First_Part); Put_Line (Output_Object.File, First_Part & Item_Title); else Quit := True; end if; else Quit := True; end if; when Dead_Clause => raise Program_Error with "Dead clause in submenu??"; -- No dead clauses should be output. end case; end Put_Subclause_Menu_Item; procedure Put_Subclause_Menu is new For_Each (Put_Subclause_Menu_Item); begin Check_Not_In_Paragraph (Output_Object); -- Handle special cases if Clause_Number = "" and Header_Text = "Table of Contents" then -- Actual contents output in TOC_Marker below. return; elsif Header_Text = "The Standard Libraries" then -- This section has no content; don't confuse makeinfo. return; elsif Header_Text = Index_Clause_Name then Put_Line (Output_Object.File, "@node " & Index_Clause_Name); Put_Line (Output_Object.File, "@chapter Index"); Output_Object.State := Index_Start; return; end if; case Level is when Section | Normative_Annex | Informative_Annex | Plain_Annex => -- Menu of these done at @node Top null; when Unnumbered_Section => -- Unnumbered sections are not in ARM_Contents, but there's -- currently only one of them, so they are not worth adding; -- just hard-code the menu here. Get_Clause_Section (Clause_Number, Section_Number, Clause_Integer); if Section_Number = 0 and Clause_Integer = 1 then Put_Line (Output_Object.File, "@menu"); Put_Line (Output_Object.File, "* 0.1 :: Foreword to this version of the Ada Reference Manual"); Put_Line (Output_Object.File, "* 0.2 :: Foreword"); Put_Line (Output_Object.File, "* 0.3 :: Introduction"); Put_Line (Output_Object.File, "* 0.99 :: International Standard"); Put_Line (Output_Object.File, "@end menu"); end if; when Clause => -- Output menu of Clauses in this section, if we haven't already Get_Clause_Section (Clause_Number, Section_Number, Clause_Integer); if Output_Object.Menu_Section /= Section_Number then Put_Line (Output_Object.File, "@menu"); Put_Clause_Menu; Put_Line (Output_Object.File, "@end menu"); Output_Object.Menu_Section := Section_Number; Output_Object.Menu_Clause := 0; end if; when Subclause => -- Output menu of Subclauses in this Clause, if we haven't already Get_Clause_Section (Clause_Number, Section_Number, Clause_Integer); if Output_Object.Menu_Section = Section_Number and Output_Object.Menu_Clause /= Clause_Integer then Put_Line (Output_Object.File, "@menu"); Put_Subclause_Menu; Put_Line (Output_Object.File, "@end menu"); Output_Object.Menu_Clause := Clause_Integer; end if; when Subsubclause => Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, "Clause_Header: Subsubclause"); when Dead_Clause => Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, "Clause_Header: Dead_clause"); end case; Put_Line (Output_Object.File, "@node " & Clause_Number); case Level is when Section => Put_Line (Output_Object.File, "@chapter " & Title); when Normative_Annex | Informative_Annex | Plain_Annex => Put_Line (Output_Object.File, "@chapter " & Title); when Clause | Unnumbered_Section => Put_Line (Output_Object.File, "@section " & Title); when Subclause => Put_Line (Output_Object.File, "@subsection " & Title); when Subsubclause => Put_Line (Output_Object.File, "@subsubsection " & Title); when Dead_Clause => raise Program_Error with "Dead_Clause in header?"; -- No output of dead clauses. end case; end Clause_Header; procedure Clause_Reference (Output_Object : in out Texinfo_Output_Type; Text : in String; Clause_Number : in String) is begin case Output_Object.State is when Contents => null; when Multi_Column | Table_Header => -- If this happens, we need to store escaped text in columns. Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, "clause reference in multi-column"); when Normal => if Text = Clause_Number then Put (Output_Object.File, "@ref{" & Clause_Number & "}"); else Put (Output_Object.File, "@ref{" & Clause_Number & "} " & Text); end if; when Title | Index_Start | Index => Unexpected_State (Output_Object); end case; end Clause_Reference; procedure Close (Output_Object : in out Texinfo_Output_Type) is begin Check_Valid (Output_Object); Put_Line (Output_Object.File, "@bye"); Close (Output_Object.File); Output_Object.Is_Valid := False; end Close; procedure Create (Output_Object : in out Texinfo_Output_Type; File_Prefix : in String; Output_Path : in String; Change_Version : in ARM_Contents.Change_Version_Type; Title : in String) is File_Name : constant String := Output_Path & Ada.Strings.Fixed.Trim (File_Prefix, Ada.Strings.Right) & ".texinfo"; begin if Output_Object.Is_Valid then Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, "Already valid object"); end if; Output_Object.Is_Valid := True; Create (Output_Object.File, Out_File, File_Name); Put_Line (Output_Object.File, "\input texinfo"); Put_Line (Output_Object.File, "@documentencoding ISO-8859-1"); Put_Line (Output_Object.File, "@dircategory GNU Ada tools"); Put_Line (Output_Object.File, "@direntry"); case Change_Version is when '2' => Put_Line (Output_Object.File, "* Ada Reference Manual: (arm2005)."); Put_Line (Output_Object.File, "* Annotated ARM: (arm2005)."); when '3' => Put_Line (Output_Object.File, "* Ada Reference Manual: (arm2012)."); Put_Line (Output_Object.File, "* Annotated ARM: (arm2012)."); when '4' => Put_Line (Output_Object.File, "* Ada Reference Manual TC1: (arm2012)."); Put_Line (Output_Object.File, "* Annotated ARM TC1: (arm2012)."); when others => Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, "unsupported Change_Version"); end case; Put_Line (Output_Object.File, "@end direntry"); Put_Line (Output_Object.File, "@settitle " & Title); Put_Line (Output_Object.File, "@paragraphindent none"); Put_Line (Output_Object.File, "@exampleindent" & Integer'Image (Indentation)); Put_Line (Output_Object.File, "@node Top"); Put_Line (Output_Object.File, "@top " & Title); Output_Object.State := ARM_Texinfo.Title; Output_Object.First_Word_Last := 0; end Create; procedure DR_Reference (Output_Object : in out Texinfo_Output_Type; Text : in String; DR_Number : in String) is begin Ordinary_Text (Output_Object, DR_Number & Text); end DR_Reference; procedure End_Hang_Item (Output_Object : in out Texinfo_Output_Type) is use ARM_Output; begin Output_Object.End_Hang_Seen := True; case Output_Object.Style is when Normal | Wide_Above | Small | Small_Wide_Above | Header | Small_Header | Syntax_Summary => Handle_Indent (Output_Object, "@quotation"); when Index | Title => null; when Examples | Small_Examples | Swiss_Examples | Small_Swiss_Examples => Handle_Indent (Output_Object, "@example"); when Bulleted | Small_Bulleted => Handle_Indent (Output_Object, "@itemize"); when Nested_Bulleted | Small_Nested_Bulleted => Handle_Indent (Output_Object, "@itemize", Extra_Indent => 1); when Enumerated | Small_Enumerated => -- Number has just been output; start text. Put (Output_Object.File, "@w{ }"); when Giant_Hanging | Small_Giant_Hanging | Wide_Hanging | Small_Wide_Hanging | Medium_Hanging | Small_Medium_Hanging | Narrow_Hanging | Small_Narrow_Hanging | Hanging_in_Bulleted | Small_Hanging_in_Bulleted => New_Line (Output_Object.File); Handle_Indent (Output_Object, "@quotation"); end case; end End_Hang_Item; procedure Text_Format (Output_Object : in out Texinfo_Output_Type; Format : in ARM_Output.Format_Type) is begin -- We only handle italic, for annotated syntax item names if Format.Italic /= Output_Object.Format.Italic then -- Info format does not support fonts, so we use <> Put (Output_Object.File, (if Format.Italic then '<' else '>')); end if; Output_Object.Format := Format; end Text_Format; procedure End_Paragraph (Output_Object : in out Texinfo_Output_Type) is use ARM_Output; begin Output_Object.In_Paragraph := False; case Output_Object.State is when Contents => null; when Multi_Column => -- Skip a row, to separate paragraphs in a column. Output_Object.Current_Row := Output_Object.Current_Row + 2; when Title => if Output_Object.Line_Empty then null; else New_Line (Output_Object.File, 2); Put (Output_Object.File, "@center "); Output_Object.Line_Empty := True; end if; when Normal => case Output_Object.Style is when Normal | Wide_Above | Small | Small_Wide_Above | Header | Small_Header | Syntax_Summary => New_Line (Output_Object.File); Handle_Indent (Output_Object, "@end quotation"); New_Line (Output_Object.File); when Index | Title => New_Line (Output_Object.File, 2); when Examples | Small_Examples | Swiss_Examples | Small_Swiss_Examples => New_Line (Output_Object.File); Handle_Indent (Output_Object, "@end example"); New_Line (Output_Object.File); when Bulleted | Small_Bulleted => New_Line (Output_Object.File); Handle_Indent (Output_Object, "@end itemize"); New_Line (Output_Object.File); when Nested_Bulleted | Small_Nested_Bulleted => New_Line (Output_Object.File); Handle_Indent (Output_Object, "@end itemize", Extra_Indent => 1); New_Line (Output_Object.File); when Enumerated | Small_Enumerated => New_Line (Output_Object.File); Handle_Indent (Output_Object, "@end itemize"); New_Line (Output_Object.File); when Giant_Hanging | Small_Giant_Hanging | Wide_Hanging | Small_Wide_Hanging | Medium_Hanging | Small_Medium_Hanging | Narrow_Hanging | Small_Narrow_Hanging | Hanging_in_Bulleted | Small_Hanging_in_Bulleted => New_Line (Output_Object.File); if Output_Object.End_Hang_Seen then Handle_Indent (Output_Object, "@end quotation"); end if; New_Line (Output_Object.File); end case; when Index_Start => Output_Object.State := Index; Index_Menu (Output_Object); when Index => -- Keep index items tightly grouped. Put_Line (Output_Object.File, "@*"); when Table_Header => Unexpected_State (Output_Object); end case; end End_Paragraph; procedure Hard_Space (Output_Object : in out Texinfo_Output_Type) is begin case Output_Object.State is when Contents => null; when Multi_Column | Table_Header => -- Can't do line breaks in columns Add_To_Column_Item (Output_Object, " "); when Title => if Output_Object.Line_Empty then null; else Put (Output_Object.File, "@w{ }"); end if; when Normal | Index_Start | Index => Put (Output_Object.File, "@w{ }"); end case; end Hard_Space; procedure Index_Line_Break (Output_Object : in out Texinfo_Output_Type; Clear_Keep_with_Next : in Boolean) is pragma Unreferenced (Clear_Keep_with_Next); begin Put_Line (Output_Object.File, "@*"); end Index_Line_Break; procedure Index_Reference (Output_Object : in out Texinfo_Output_Type; Text : in String; Index_Key : in Natural; Clause_Number : in String) is pragma Unreferenced (Clause_Number); -- Text is clause_number & paragraph number (optional). begin Put (Output_Object.File, "@ref{" & Integer'Image (Index_Key) & ", " & Text & "}"); end Index_Reference; procedure Index_Target (Output_Object : in out Texinfo_Output_Type; Index_Key : in Natural) is begin -- Add an empty non-break object, because @anchor ignores -- whitespace after it, which often occurs in the current -- Scribe-like source. Put (Output_Object.File, "@anchor{" & Integer'Image (Index_Key) & "}@w{}"); end Index_Target; procedure Line_Break (Output_Object : in out Texinfo_Output_Type) is use ARM_Output; begin case Output_Object.State is when Title => if Output_Object.Line_Empty then null; else Put_Line (Output_Object.File, "@*"); Output_Object.Line_Empty := True; end if; when Contents => null; when Multi_Column | Table_Header => Output_Object.Current_Row := Output_Object.Current_Row + 1; if Output_Object.Max_Row < Output_Object.Current_Row then Output_Object.Max_Row := Output_Object.Current_Row; end if; when Index_Start => -- This doesn't happen Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, "Line_Break Index_Start"); when Normal | Index => case Output_Object.Style is when Normal | Wide_Above | Small | Small_Wide_Above | Header | Small_Header | Syntax_Summary | Index | Title => Put_Line (Output_Object.File, "@*"); when Examples | Small_Examples | Swiss_Examples | Small_Swiss_Examples => New_Line (Output_Object.File); when Bulleted | Small_Bulleted | Nested_Bulleted | Small_Nested_Bulleted | Enumerated | Small_Enumerated | Giant_Hanging | Small_Giant_Hanging | Wide_Hanging | Small_Wide_Hanging | Medium_Hanging | Small_Medium_Hanging | Narrow_Hanging | Small_Narrow_Hanging | Hanging_in_Bulleted | Small_Hanging_in_Bulleted => Put_Line (Output_Object.File, "@*"); end case; end case; end Line_Break; procedure Local_Link (Output_Object : in out Texinfo_Output_Type; Text : in String; Target : in String; Clause_Number : in String) is pragma Unreferenced (Target); pragma Unreferenced (Clause_Number); begin -- These are typically references to words in the grammar -- summary. Mildly useful, but the best we can do is: -- -- "@ref{" & Target & "," & Text & "}" -- -- makeinfo prepends 'see' and postpends '.', so it screws up -- the text. For example, section 2.1 (1) ends up with "the -- @ref{S0229, compilation}s." => "the see compilation: S0229." -- Emacs info-mode suppresses the ': S0229', but not the 'see' -- and the trailing '.'. So we just output the text. Ordinary_Text (Output_Object, Text); end Local_Link; procedure Local_Link_End (Output_Object : in out Texinfo_Output_Type; Target : in String; Clause_Number : in String) is begin -- These work better than local links, because they are not in -- the middle of plurals. First use is section 3.1 (1). Put (Output_Object.File, " (@pxref{" & Target & "," & Clause_Number & "})"); end Local_Link_End; procedure Local_Link_Start (Output_Object : in out Texinfo_Output_Type; Target : in String; Clause_Number : in String) is pragma Unreferenced (Output_Object); pragma Unreferenced (Target); pragma Unreferenced (Clause_Number); begin -- implemented in Local_Link_End null; end Local_Link_Start; procedure Local_Target (Output_Object : in out Texinfo_Output_Type; Text : in String; Target : in String) is begin -- Add an empty non-break object, because @anchor ignores -- whitespace after it, which often occurs in the current -- Scheme source. Put (Output_Object.File, "@anchor{" & Target & "}@w{}"); Ordinary_Text (Output_Object, Text); end Local_Target; procedure New_Column (Output_Object : in out Texinfo_Output_Type) is begin if Output_Object.Column_Count >= 4 then Output_Object.Current_Column := Output_Object.Current_Column + 1; Output_Object.Current_Row := 1; end if; end New_Column; procedure New_Page (Output_Object : in out Texinfo_Output_Type; Kind : ARM_Output.Page_Kind_Type := ARM_Output.Any_Page) is pragma Unreferenced (Kind); pragma Unreferenced (Output_Object); begin -- No such thing in Info. null; end New_Page; procedure Ordinary_Character (Output_Object : in out Texinfo_Output_Type; Char : in Character) is Copyright : constant String := "Copyright"; begin case Output_Object.State is when Contents => null; when Multi_Column | Table_Header => Add_To_Column_Item (Output_Object, "" & Char); when Title => -- Check for end of title page; indicated by line starting with "Copyright" if Output_Object.Line_Empty then if Output_Object.First_Word_Last > 0 then if Copyright (Output_Object.First_Word_Last + 1) = Char then Output_Object.First_Word_Last := Output_Object.First_Word_Last + 1; Output_Object.First_Word (Output_Object.First_Word_Last) := Char; if Output_Object.First_Word_Last = Copyright'Last then End_Title_Page (Output_Object); Output_Object.State := Normal; Ordinary_Text (Output_Object, Output_Object.First_Word (1 .. Output_Object.First_Word_Last)); end if; else -- First word is not Copyright; output it Ordinary_Text (Output_Object, Output_Object.First_Word (1 .. Output_Object.First_Word_Last)); Output_Object.Line_Empty := False; end if; else -- No non-space seen yet if Char = ' ' then null; elsif Char = Copyright (1) then Output_Object.First_Word_Last := 1; Output_Object.First_Word (1) := Char; else Escape_Put (Output_Object, Char); Output_Object.Line_Empty := False; end if; end if; else -- Line already has stuff on it Escape_Put (Output_Object, Char); end if; when Normal => Output_Object.Line_Empty := Char /= ' '; Escape_Put (Output_Object, Char); when Index_Start => Escape_Put (Output_Object, Char); if Char = '&' then -- give debugger a place to break Put_Line ("first index entry"); end if; when Index => case Char is when ' ' | ',' | '[' | ']' => Put (Output_Object.File, Char); when 'A' .. Last_Index_Clause => -- Index section heading -- @node current Put_Line (Output_Object.File, "@node " & Char); -- Add non-break space so Emacs info will use big bold -- font for single letter titles. Put_Line (Output_Object.File, "@section " & Char & "@w{ }"); when others => Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, "Unexpected char in Index: " & Char); end case; end case; end Ordinary_Character; procedure Ordinary_Text (Output_Object : in out Texinfo_Output_Type; Text : in String) is begin case Output_Object.State is when Contents => null; when Multi_Column | Table_Header => Add_To_Column_Item (Output_Object, Text); when Normal | Title | Index_Start | Index => Output_Object.Line_Empty := False; Escape_Put (Output_Object, Text); end case; end Ordinary_Text; procedure Picture (Output_Object : in out Texinfo_Output_Type; Name : in String; Descr : in String; Alignment : in ARM_Output.Picture_Alignment; Height, Width : in Natural; Border : in ARM_Output.Border_Kind) is pragma Unreferenced (Border); pragma Unreferenced (Width); pragma Unreferenced (Height); pragma Unreferenced (Alignment); pragma Unreferenced (Name); begin Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, "Picture: " & Descr); end Picture; procedure Revised_Clause_Header (Output_Object : in out Texinfo_Output_Type; New_Header_Text : in String; Old_Header_Text : in String; Level : in ARM_Contents.Level_Type; Clause_Number : in String; Version : in ARM_Contents.Change_Version_Type; Old_Version : in ARM_Contents.Change_Version_Type; Top_Level_Subdivision_Name : in ARM_Output.Top_Level_Subdivision_Name_Kind; No_Page_Break : in Boolean := False) is pragma Unreferenced (Version); pragma Unreferenced (Old_Version); pragma Unreferenced (Old_Header_Text); begin Clause_Header (Output_Object, New_Header_Text, Level, Clause_Number, Top_Level_Subdivision_Name, No_Page_Break); end Revised_Clause_Header; procedure Section (Output_Object : in out Texinfo_Output_Type; Section_Title : in String; Section_Name : in String) is pragma Unreferenced (Section_Name); pragma Unreferenced (Section_Title); pragma Unreferenced (Output_Object); begin -- This is redundant with the various Clause functions null; end Section; procedure Separator_Line (Output_Object : in out Texinfo_Output_Type; Is_Thin : Boolean := True) is begin -- Can't be in a multi-column setting. New_Line (Output_Object.File); if Is_Thin then Put_Line (Output_Object.File, "----------"); else Put_Line (Output_Object.File, "=========="); end if; end Separator_Line; procedure Set_Columns (Output_Object : in out Texinfo_Output_Type; Number_of_Columns : in ARM_Output.Column_Count) is begin Check_Valid (Output_Object); Check_Not_In_Paragraph (Output_Object); -- 2 and 3 column formats are displayed without any columns. -- This is mainly used for the syntax cross-reference and -- index, and these definitely look better without columns. -- -- 4 or more columns are output as a table. Note that we assume -- such items are formated with explicit New_Column calls, and -- do not contain any nested paragraph formats. case Output_Object.State is when Normal => if Number_of_Columns >= 4 then Output_Object.State := Multi_Column; Output_Object.Current_Column := 1; Output_Object.Current_Row := 1; Output_Object.Column_Widths := (others => 0); -- Accumulate all column rows in Output_Text, then output -- when done, so we can set the correct column width in -- the header. Each column is a linked list of allocated -- Column_Text_Item_Type. else null; end if; when Multi_Column => if Number_of_Columns = 1 then -- Finished accumulating columns, output the columns as a table. Output_Column_Widths (Output_Object); Output_Columns (Output_Object); New_Line (Output_Object.File); Put_Line (Output_Object.File, "@end multitable"); New_Line (Output_Object.File); Output_Object.State := Normal; else Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, "New multi-column section before end of old"); end if; when Index_Start | Index => null; when Table_Header | Contents | Title => Unexpected_State (Output_Object); end case; Output_Object.Column_Count := Number_of_Columns; end Set_Columns; procedure Soft_Hyphen_Break (Output_Object : in out Texinfo_Output_Type) is begin Put (Output_Object.File, "@-"); end Soft_Hyphen_Break; procedure Soft_Line_Break (Output_Object : in out Texinfo_Output_Type) is begin case Output_Object.State is when Contents | Title => null; when Normal | Index_Start | Index => Put (Output_Object.File, "@-"); when Multi_Column | Table_Header => Unexpected_State (Output_Object); end case; end Soft_Line_Break; procedure Special_Character (Output_Object : in out Texinfo_Output_Type; Char : in ARM_Output.Special_Character_Type) is begin -- We use Ordinary_Text, so this is output to columns when appropriate. case Char is when ARM_Output.EM_Dash => Ordinary_Text (Output_Object, "--"); when ARM_Output.EN_Dash => Ordinary_Text (Output_Object, "-"); -- used for '-' in binary_adding_operator when ARM_Output.GEQ => Ordinary_Text (Output_Object, ">="); when ARM_Output.LEQ => Ordinary_Text (Output_Object, "<="); when ARM_Output.NEQ => Ordinary_Text (Output_Object, "/="); when ARM_Output.PI => Ordinary_Text (Output_Object, "PI"); when ARM_Output.Left_Ceiling => case Output_Object.State is when Multi_Column | Table_Header => Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, "Info does not support ceiling in multi-column"); when Contents => null; when Normal | Index_Start | Index => Put (Output_Object.File, "@code{ceiling("); when Title => Unexpected_State (Output_Object); end case; when ARM_Output.Right_Ceiling => case Output_Object.State is when Multi_Column | Table_Header => Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, "Info does not support ceiling in multi-column"); when Contents => null; when Normal | Index_Start | Index => Put (Output_Object.File, ")}"); when Title => Unexpected_State (Output_Object); end case; when ARM_Output.Left_Floor => case Output_Object.State is when Multi_Column | Table_Header => Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, "Info does not support floor in multi-column"); when Contents => null; when Normal | Index_Start | Index => Put (Output_Object.File, "@code{floor("); when Title => Unexpected_State (Output_Object); end case; when ARM_Output.Right_Floor => case Output_Object.State is when Multi_Column | Table_Header => Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, "Info does not support floor in multi-column"); when Contents => null; when Normal | Index_Start | Index => Put (Output_Object.File, ")}"); when Title => Unexpected_State (Output_Object); end case; when ARM_Output.Thin_Space => Ordinary_Text (Output_Object, " "); when ARM_Output.Left_Quote => Ordinary_Text (Output_Object, "`"); when ARM_Output.Right_Quote => Ordinary_Text (Output_Object, "'"); when ARM_Output.Left_Double_Quote => Ordinary_Text (Output_Object, """"); when ARM_Output.Right_Double_Quote => Ordinary_Text (Output_Object, """"); when ARM_Output.Small_Dotless_I => Ordinary_Text (Output_Object, "i"); when ARM_Output.Capital_Dotted_I => Ordinary_Text (Output_Object, "I"); end case; end Special_Character; procedure Start_Paragraph (Output_Object : in out Texinfo_Output_Type; Style : in ARM_Output.Paragraph_Style_Type; Indent : in ARM_Output.Paragraph_Indent_Type; Number : in String; No_Prefix : in Boolean := False; Tab_Stops : in ARM_Output.Tab_Info := ARM_Output.NO_TABS; No_Breaks : in Boolean := False; Keep_with_Next : in Boolean := False; Space_After : in ARM_Output.Space_After_Type := ARM_Output.Normal; Justification : in ARM_Output.Justification_Type := ARM_Output.Default) is pragma Unreferenced (Justification); pragma Unreferenced (Space_After); pragma Unreferenced (Keep_with_Next); pragma Unreferenced (No_Breaks); pragma Unreferenced (Tab_Stops); use ARM_Output; begin Check_Valid (Output_Object); Check_Not_In_Paragraph (Output_Object); -- Note: makeinfo will do most of the formatting, so No_Breaks, -- Keep_with_Next, Space_After, and Justification have no -- effect here. In addition, info format has no support for -- fonts, so the font aspects of Style are ignored as well. But -- we try to respect the indentation and margin aspects. -- TexInfo does not directly support tabs, but does use a fixed -- font, so we could emulate them. But then we'd have to track -- output characters; let's see if we really need it. case Output_Object.State is when Contents => null; when Normal => if Number'Length > 0 then Put_Line (Output_Object.File, Number & " @*"); end if; Output_Object.In_Paragraph := True; Output_Object.Style := Style; Output_Object.Indent := Indent; case Style is when Normal | Wide_Above | Small | Small_Wide_Above | Header | Small_Header | Syntax_Summary => Handle_Indent (Output_Object, "@quotation"); when Index | Title => null; when Examples | Small_Examples | Swiss_Examples | Small_Swiss_Examples => Handle_Indent (Output_Object, "@example"); when Bulleted | Small_Bulleted => Handle_Indent (Output_Object, "@itemize @bullet"); if not No_Prefix then Put (Output_Object.File, "@item "); end if; when Nested_Bulleted | Small_Nested_Bulleted => Handle_Indent (Output_Object, "@itemize @bullet", Extra_Indent => 1); if not No_Prefix then Put (Output_Object.File, "@item "); end if; when Enumerated | Small_Enumerated => Handle_Indent (Output_Object, "@itemize @w{}"); Put (Output_Object.File, "@item "); when Giant_Hanging | Small_Giant_Hanging | Wide_Hanging | Small_Wide_Hanging | Medium_Hanging | Small_Medium_Hanging | Narrow_Hanging | Small_Narrow_Hanging | Hanging_in_Bulleted | Small_Hanging_in_Bulleted => if No_Prefix then -- Still in hanging part Handle_Indent (Output_Object, "@quotation"); Output_Object.End_Hang_Seen := True; else Output_Object.End_Hang_Seen := False; end if; end case; when Index_Start | Index | Title | Multi_Column | Table_Header => if Number'Length > 0 then Unexpected_State (Output_Object); end if; Output_Object.In_Paragraph := True; Output_Object.Style := Style; Output_Object.Indent := Indent; end case; end Start_Paragraph; procedure Start_Table (Output_Object : in out Texinfo_Output_Type; Columns : in ARM_Output.Column_Count; First_Column_Width : in ARM_Output.Column_Count; Last_Column_Width : in ARM_Output.Column_Count; Alignment : in ARM_Output.Column_Text_Alignment; No_Page_Break : in Boolean; Has_Border : in Boolean; Small_Text_Size : in Boolean; Header_Kind : in ARM_Output.Header_Kind_Type) is pragma Unreferenced (Small_Text_Size); pragma Unreferenced (Has_Border); pragma Unreferenced (No_Page_Break); pragma Unreferenced (Alignment); pragma Unreferenced (Last_Column_Width); pragma Unreferenced (First_Column_Width); use ARM_Output; begin Output_Object.Column_Count := Columns; case Header_Kind is when Both_Caption_and_Header => New_Line (Output_Object.File); -- Next text output will be the caption, which we don't -- format in any special way (first example is F.3.2 (19)). -- Then Table_Marker (End_Caption) is called, which will -- start the actual table. when Header_Only => -- Same as Table_Marker, End_Caption. case Columns is when 1 => Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, "Table with 1 column"); when 2 => -- @table doesn't work inside @display; PDFTex fails with @table here. -- https://lists.gnu.org/archive/html/bug-texinfo/2004-10/txtJLetHrEhdc.txt New_Line (Output_Object.File); Put_Line (Output_Object.File, "@multitable {wwwwwwwwww} {wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww}"); Put (Output_Object.File, "@headitem "); when others => New_Line (Output_Object.File); Put (Output_Object.File, "@multitable"); Output_Object.State := Table_Header; Output_Object.Current_Column := 1; Output_Object.Current_Row := 1; Output_Object.Max_Row := 0; -- The next text output via Ordinary_Text or -- Ordinary_Character is the table headers. We -- capture them in Output_Object.Column_Text, and -- use them to set the table column widths. end case; when No_Headers => null; end case; end Start_Table; procedure Tab (Output_Object : in out Texinfo_Output_Type) is begin case Output_Object.State is when Contents => null; when Multi_Column | Table_Header => Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, "Tab in multi-column"); when Title => if Output_Object.Line_Empty then null; else Put (Output_Object.File, "@w{ }"); end if; when Normal | Index_Start | Index => -- Just three spaces for now, for indented trees Put (Output_Object.File, "@w{ }"); end case; end Tab; procedure Table_Marker (Output_Object : in out Texinfo_Output_Type; Marker : in ARM_Output.Table_Marker_Type) is begin case Marker is when ARM_Output.End_Caption => -- Start the actual table case Output_Object.Column_Count is when 1 => Ada.Exceptions.Raise_Exception (ARM_Output.Not_Valid_Error'Identity, "Table with 1 column"); when 2 => New_Line (Output_Object.File); Put_Line (Output_Object.File, "@multitable {wwwwwwwwww} {wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww}"); Put (Output_Object.File, "@headitem "); when others => New_Line (Output_Object.File); Put (Output_Object.File, "@multitable"); Output_Object.State := Table_Header; Output_Object.Current_Column := 1; Output_Object.Current_Row := 1; Output_Object.Max_Row := 0; -- The next text output via Ordinary_Text or -- Ordinary_Character is the table headers. We -- capture them in Output_Object.Column_Text, and -- use them to set the table column widths. end case; when ARM_Output.End_Item => case Output_Object.State is when Table_Header => Output_Object.Current_Column := Output_Object.Current_Column + 1; Output_Object.Current_Row := 1; when Normal => case Output_Object.Column_Count is when 2 => New_Line (Output_Object.File); Put (Output_Object.File, "@tab "); when others => Put (Output_Object.File, " @tab "); end case; when Multi_Column | Contents | Title | Index_Start | Index => Unexpected_State (Output_Object); end case; when ARM_Output.End_Header => case Output_Object.State is when Table_Header => Output_Object.State := Normal; for I in 1 .. Output_Object.Column_Count loop Put (Output_Object.File, " {" & Output_Object.Column_Text (I).Text (1 .. Output_Object.Column_Text (I).Length) & "}"); end loop; New_Line (Output_Object.File); Put (Output_Object.File, "@item "); Pad_Columns (Output_Object); Output_Columns (Output_Object); New_Line (Output_Object.File); Put (Output_Object.File, "@item "); Output_Object.Current_Column := 1; when Normal => -- A two-column table; header has been output New_Line (Output_Object.File); Put (Output_Object.File, "@item "); when Contents | Multi_Column | Title | Index_Start | Index => Unexpected_State (Output_Object); end case; when ARM_Output.End_Row | ARM_Output.End_Row_Next_Is_Last => New_Line (Output_Object.File); Put (Output_Object.File, "@item "); Output_Object.Current_Column := 1; when ARM_Output.End_Table => case Output_Object.Column_Count is when 2 => New_Line (Output_Object.File); Put_Line (Output_Object.File, "@end multitable"); when others => Put_Line (Output_Object.File, "@end multitable"); end case; end case; end Table_Marker; procedure TOC_Marker (Output_Object : in out Texinfo_Output_Type; For_Start : in Boolean) is begin -- We use menus, not @contents (since makeinfo ignores -- @contents in info mode). The menus (including the top menu) -- are generated from data stored in ARM_Contents during the -- scan pass. if For_Start then Output_Object.State := Contents; -- Ignore futher output until For_Start = False. else Output_Object.State := Normal; end if; end TOC_Marker; procedure Unicode_Character (Output_Object : in out Texinfo_Output_Type; Char : in ARM_Output.Unicode_Type) is begin -- Used in section 2.3 Identifiers examples, 2.5 character -- literals examples, 2.6 string literals examples, 3.3.1 -- Object Declarations examples, 4.4 Expressions examples Put (Output_Object.File, "[Unicode" & ARM_Output.Unicode_Type'Image (Char) & "]"); end Unicode_Character; procedure URL_Link (Output_Object : in out Texinfo_Output_Type; Text : in String; URL : in String) is begin Put (Output_Object.File, "@uref{" & URL & "," & Text & "}"); end URL_Link; end ARM_Texinfo;
30,699
ada
2
stcarrez/jason
src/jason-tickets-beans.ads
----------------------------------------------------------------------- -- jason-tickets-beans -- Beans for module tickets -- Copyright (C) 2016, 2017, 2019 Stephane.Carrez -- Written by Stephane.Carrez (<EMAIL>) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; with Ada.Containers.Vectors; with Ada.Containers.Ordered_Maps; with ADO; with Util.Beans.Basic; with Util.Beans.Objects; with AWA.Tags.Beans; with Jason.Tickets.Modules; with Jason.Tickets.Models; with Jason.Projects.Beans; package Jason.Tickets.Beans is type Ticket_Bean is new Jason.Tickets.Models.Ticket_Bean with record Module : Jason.Tickets.Modules.Ticket_Module_Access := null; Ticket_Id : ADO.Identifier := ADO.NO_IDENTIFIER; Project : Jason.Projects.Beans.Project_Bean_Access; -- List of tags associated with the wiki page. Tags : aliased AWA.Tags.Beans.Tag_List_Bean; Tags_Bean : Util.Beans.Basic.Readonly_Bean_Access; end record; type Ticket_Bean_Access is access all Ticket_Bean'Class; -- Get the value identified by the name. overriding function Get_Value (From : in Ticket_Bean; Name : in String) return Util.Beans.Objects.Object; -- Set the value identified by the name. overriding procedure Set_Value (From : in out Ticket_Bean; Name : in String; Value : in Util.Beans.Objects.Object); -- Create ticket action. overriding procedure Create (Bean : in out Ticket_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String); -- Save ticket action. overriding procedure Save (Bean : in out Ticket_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String); -- Save ticket action. overriding procedure Save_Status (Bean : in out Ticket_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String); -- Load ticket action. overriding procedure Load (Bean : in out Ticket_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String); -- Create the Tickets_Bean bean instance. function Create_Ticket_Bean (Module : in Jason.Tickets.Modules.Ticket_Module_Access) return Util.Beans.Basic.Readonly_Bean_Access; -- ------------------------------ -- Bean that collects the list of tickets filtered by tag, priority and project. -- ------------------------------ type Ticket_List_Bean is new Jason.Tickets.Models.Ticket_List_Bean with record Module : Jason.Tickets.Modules.Ticket_Module_Access := null; Project : Jason.Projects.Beans.Project_Bean_Access; -- List of tickets. Tickets : aliased Jason.Tickets.Models.List_Info_List_Bean; Tickets_Bean : Jason.Tickets.Models.List_Info_List_Bean_Access; -- List of tags associated with the tickets. Tags : AWA.Tags.Beans.Entity_Tag_Map; -- Whether the ticket type filter is enabled. Type_Filter : Boolean := False; Status_Filter : Ada.Strings.Unbounded.Unbounded_String; Priority_Filter : Ada.Strings.Unbounded.Unbounded_String; end record; type Ticket_List_Bean_Access is access all Ticket_List_Bean'Class; -- Get the value identified by the name. overriding function Get_Value (From : in Ticket_List_Bean; Name : in String) return Util.Beans.Objects.Object; -- Set the value identified by the name. overriding procedure Set_Value (From : in out Ticket_List_Bean; Name : in String; Value : in Util.Beans.Objects.Object); -- Load list of tickets. overriding procedure Load (Bean : in out Ticket_List_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String); -- Create the Tickets_List_Bean bean instance. function Create_Ticket_List_Bean (Module : in Jason.Tickets.Modules.Ticket_Module_Access) return Util.Beans.Basic.Readonly_Bean_Access; -- Get a select item list which contains a list of ticket status. function Create_Status_List (Module : in Jason.Tickets.Modules.Ticket_Module_Access) return Util.Beans.Basic.Readonly_Bean_Access; -- Get a select item list which contains a list of ticket types. function Create_Type_List (Module : in Jason.Tickets.Modules.Ticket_Module_Access) return Util.Beans.Basic.Readonly_Bean_Access; use type Jason.Tickets.Models.Ticket_Type; type Ticket_Stat_Bean is new Models.Stat_Bean with record Low : aliased Models.Stat_Bean; High : aliased Models.Stat_Bean; Medium : aliased Models.Stat_Bean; Closed : aliased Models.Stat_Bean; Progress : Natural := 0; end record; package Ticket_Stat_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Ticket_Stat_Bean); package Ticket_Stat_Map is new Ada.Containers.Ordered_Maps (Key_Type => Models.Ticket_Type, Element_Type => Ticket_Stat_Bean, "<" => Models."<", "=" => "="); type Ticket_Raw_Stat_Bean is new Ticket_Stat_Bean with record Low_Bean : Util.Beans.Objects.Object; High_Bean : Util.Beans.Objects.Object; Medium_Bean : Util.Beans.Objects.Object; Closed_Bean : Util.Beans.Objects.Object; end record; procedure Initialize (Object : in out Ticket_Raw_Stat_Bean); -- Get the value identified by the name. overriding function Get_Value (From : in Ticket_Raw_Stat_Bean; Name : in String) return Util.Beans.Objects.Object; type Ticket_Report_Bean is new Jason.Tickets.Models.Report_Bean and Util.Beans.Basic.List_Bean with record Module : Jason.Tickets.Modules.Ticket_Module_Access := null; Project : Jason.Projects.Beans.Project_Bean_Access; Row : Util.Beans.Objects.Object; Current : Ticket_Stat_Vectors.Cursor; Current_Pos : Natural := 0; Element : aliased Ticket_Raw_Stat_Bean; Total : aliased Ticket_Raw_Stat_Bean; Total_Bean : Util.Beans.Objects.Object; List : Ticket_Stat_Map.Map; Report : Ticket_Stat_Vectors.Vector; end record; type Ticket_Report_Bean_Access is access all Ticket_Report_Bean'Class; -- Get the value identified by the name. overriding function Get_Value (From : in Ticket_Report_Bean; Name : in String) return Util.Beans.Objects.Object; -- Set the value identified by the name. overriding procedure Set_Value (From : in out Ticket_Report_Bean; Name : in String; Value : in Util.Beans.Objects.Object); -- Get the number of elements in the list. function Get_Count (From : Ticket_Report_Bean) return Natural; -- Set the current row index. Valid row indexes start at 1. overriding procedure Set_Row_Index (From : in out Ticket_Report_Bean; Index : in Natural); -- Get the element at the current row index. overriding function Get_Row (From : in Ticket_Report_Bean) return Util.Beans.Objects.Object; -- Load the information for the tickets. overriding procedure Load (Bean : in out Ticket_Report_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String); -- Create the Tickets_Report_Bean bean instance. function Create_Ticket_Report_Bean (Module : in Jason.Tickets.Modules.Ticket_Module_Access) return Util.Beans.Basic.Readonly_Bean_Access; end Jason.Tickets.Beans;