repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
im-prakher/Amass
Ada
1,749
ads
-- Copyright 2017 Jeff Foley. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. local json = require("json") name = "BinaryEdge" type = "api" function start() setratelimit(2) end function check() if (api ~= nil and api.key ~= nil and api.key ~= "") then return true end return false end function vertical(ctx, domain) if check() then apiquery(ctx, domain) end end function apiquery(ctx, domain) local hdrs={ ['X-KEY']=api["key"], ['Content-Type']="application/json", } for i=1,500 do local resp local vurl = apiurl(domain, i) -- Check if the response data is in the graph database if (api.ttl ~= nil and api.ttl > 0) then resp = obtain_response(vurl, api.ttl) end if (resp == nil or resp == "") then local err resp, err = request({ url=vurl, headers=hdrs, }) if (err ~= nil and err ~= "") then return end if (api.ttl ~= nil and api.ttl > 0) then cache_response(vurl, resp) end end local d = json.decode(resp) if (d == nil or #(d.events) == 0) then return end for i, v in pairs(d.events) do newname(ctx, v) end if (d.page > 500 or d.page > (d.total / d.pagesize)) then return end active(ctx) checkratelimit() end end function apiurl(domain, pagenum) return "https://api.binaryedge.io/v2/query/domains/subdomain/" .. domain .. "?page=" .. pagenum end
reznikmm/matreshka
Ada
4,866
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-2013, Vadim Godunko <[email protected]> -- -- 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.Generic_Collections; package AMF.OCL.Let_Exps.Collections is pragma Preelaborate; package OCL_Let_Exp_Collections is new AMF.Generic_Collections (OCL_Let_Exp, OCL_Let_Exp_Access); type Set_Of_OCL_Let_Exp is new OCL_Let_Exp_Collections.Set with null record; Empty_Set_Of_OCL_Let_Exp : constant Set_Of_OCL_Let_Exp; type Ordered_Set_Of_OCL_Let_Exp is new OCL_Let_Exp_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_OCL_Let_Exp : constant Ordered_Set_Of_OCL_Let_Exp; type Bag_Of_OCL_Let_Exp is new OCL_Let_Exp_Collections.Bag with null record; Empty_Bag_Of_OCL_Let_Exp : constant Bag_Of_OCL_Let_Exp; type Sequence_Of_OCL_Let_Exp is new OCL_Let_Exp_Collections.Sequence with null record; Empty_Sequence_Of_OCL_Let_Exp : constant Sequence_Of_OCL_Let_Exp; private Empty_Set_Of_OCL_Let_Exp : constant Set_Of_OCL_Let_Exp := (OCL_Let_Exp_Collections.Set with null record); Empty_Ordered_Set_Of_OCL_Let_Exp : constant Ordered_Set_Of_OCL_Let_Exp := (OCL_Let_Exp_Collections.Ordered_Set with null record); Empty_Bag_Of_OCL_Let_Exp : constant Bag_Of_OCL_Let_Exp := (OCL_Let_Exp_Collections.Bag with null record); Empty_Sequence_Of_OCL_Let_Exp : constant Sequence_Of_OCL_Let_Exp := (OCL_Let_Exp_Collections.Sequence with null record); end AMF.OCL.Let_Exps.Collections;
reznikmm/torrent
Ada
7,657
adb
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Ada.Directories; package body Torrent.Storages is use type Ada.Streams.Stream_Element_Count; protected body Storage is ---------------- -- Initialize -- ---------------- procedure Initialize (Path : League.Strings.Universal_String) is Offset : Ada.Streams.Stream_Element_Count := 0; begin Root_Path := Path; Is_Empty := True; for J in 1 .. Meta.File_Count loop declare use type League.Strings.Universal_String; Name : constant League.Strings.Universal_String := Path & "/" & Meta.File_Path (J).Join ("/"); File : constant String := Name.To_UTF_8_String; Dir : constant String := Ada.Directories.Containing_Directory (File); begin if not Ada.Directories.Exists (Dir) then Ada.Directories.Create_Path (Dir); end if; if not Ada.Directories.Exists (File) then declare Dummy : Ada.Streams.Stream_IO.File_Type; begin Ada.Streams.Stream_IO.Create (Dummy, Name => File); Ada.Streams.Stream_IO.Close (Dummy); end; elsif Ada.Directories.Size (File) not in 0 then Is_Empty := False; end if; end; if Meta.File_Length (J) > 0 then Files.Insert (Offset, J); Offset := Offset + Meta.File_Length (J); end if; end loop; end Initialize; ---------------------- -- Is_Empty_Storage -- ---------------------- function Is_Empty_Storage return Boolean is begin return Is_Empty; end Is_Empty_Storage; ---------- -- Read -- ---------- entry Read (Offset : Ada.Streams.Stream_Element_Count; Data : out Ada.Streams.Stream_Element_Array) when Reading is use type League.Strings.Universal_String; Name : League.Strings.Universal_String; From : Ada.Streams.Stream_Element_Count := Data'First; Last : Ada.Streams.Stream_Element_Count; Cursor : File_Index_Maps.Cursor := Files.Floor (Offset); -- The last node whose key is not greater (i.e. less or equal). -- The first key in map is 0, so we expect Floor fine some item. Skip : Ada.Streams.Stream_Element_Count := -- Offset inside a file Offset - File_Index_Maps.Key (Cursor); File : Positive := File_Index_Maps.Element (Cursor); File_Length : Ada.Streams.Stream_Element_Count := Meta.File_Length (File); begin if Skip >= File_Length then return; -- Offset is greater then torrent size. end if; loop Name := Root_Path & "/" & Meta.File_Path (File).Join ('/'); if Skip + Data'Last - From + 1 > File_Length then Last := From + File_Length - Skip - 1; else Last := Data'Last; end if; if Read_Cache.Name /= Name then if Ada.Streams.Stream_IO.Is_Open (Read_Cache.Input) then Ada.Streams.Stream_IO.Close (Read_Cache.Input); end if; Ada.Streams.Stream_IO.Open (Read_Cache.Input, Ada.Streams.Stream_IO.In_File, Name.To_UTF_8_String, Form => "shared=no"); Read_Cache.Name := Name; end if; declare use type Ada.Streams.Stream_IO.Count; Done : Ada.Streams.Stream_Element_Offset; begin if Ada.Streams.Stream_IO.Size (Read_Cache.Input) >= Ada.Streams.Stream_IO.Count (Skip + Last - From + 1) then Ada.Streams.Stream_IO.Read (File => Read_Cache.Input, Item => Data (From .. Last), Last => Done, From => Ada.Streams.Stream_IO.Count (Skip + 1)); pragma Assert (Done = Last); else Data := (others => 0); end if; end; exit when Last >= Data'Last; File_Index_Maps.Next (Cursor); Skip := 0; File := File_Index_Maps.Element (Cursor); File_Length := Meta.File_Length (File); From := Last + 1; end loop; end Read; ------------------- -- Start_Reading -- ------------------- entry Start_Reading when not Reading is begin Reading := True; end Start_Reading; ------------------ -- Stop_Reading -- ------------------ entry Stop_Reading when Reading is begin Reading := False; end Stop_Reading; ----------- -- Write -- ----------- entry Write (Offset : Ada.Streams.Stream_Element_Count; Data : Ada.Streams.Stream_Element_Array) when not Reading is Cursor : File_Index_Maps.Cursor := Files.Floor (Offset); -- The last node whose key is not greater (i.e. less or equal). -- The first key in map is 0, so we expect Floor fine some item. Skip : Ada.Streams.Stream_Element_Count := -- File offset Offset - File_Index_Maps.Key (Cursor); File : Positive := File_Index_Maps.Element (Cursor); File_Length : Ada.Streams.Stream_Element_Count := Meta.File_Length (File); From : Ada.Streams.Stream_Element_Count := Data'First; Last : Ada.Streams.Stream_Element_Count; begin if Skip >= File_Length then return; -- Offset is greater then torrent size. end if; loop if Skip + Data'Last - From + 1 > File_Length then Last := From + File_Length - Skip - 1; else Last := Data'Last; end if; declare use type League.Strings.Universal_String; Output : Ada.Streams.Stream_IO.File_Type; Name : constant League.Strings.Universal_String := Root_Path & "/" & Meta.File_Path (File).Join ('/'); begin if Read_Cache.Name = Name then Read_Cache.Name.Clear; Ada.Streams.Stream_IO.Close (Read_Cache.Input); end if; Ada.Streams.Stream_IO.Open (Output, Ada.Streams.Stream_IO.Out_File, Name.To_UTF_8_String, Form => "shared=no"); Ada.Streams.Stream_IO.Write (File => Output, Item => Data (From .. Last), To => Ada.Streams.Stream_IO.Count (Skip + 1)); Ada.Streams.Stream_IO.Close (Output); end; exit when Last >= Data'Last; File_Index_Maps.Next (Cursor); Skip := 0; File := File_Index_Maps.Element (Cursor); File_Length := Meta.File_Length (File); From := Last + 1; end loop; end Write; end Storage; end Torrent.Storages;
jhersack/ini-files
Ada
8,325
ads
----------------------------------------------------------------------------- -- Config - A simple package for parsing and modifying configuration files -- (also known as .ini, .inf, .cfg, ... files) -- -- Copyright (c) Rolf Ebert & Gautier de Montmollin 1996 .. 2019 -- -- 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. -- NB: this is the MIT License, as found 12-Sep-2007 on the site -- http://www.opensource.org/licenses/mit-license.php ----------------------------------------------------------------------------- -- Change log -- -- 19-Aug-2017: RE: Report offending line number in case of error -- 16-Jan-2017: GdM: Variable terminator symbol can be different than '=' -- 18-Dec-2016: RE: Added Read_Sections -- 26-Oct-2011: GdM/DB: Init also as a function -- 18-Mar-2010: GdM: Float replaced by Long_Float -- 20-Jul-2009: GdM: Added Replace_Section -- 17-Jul-2009: GdM: Improved Replace_Value -- 15-Jul-2009: GdM: - Added type Configuration to wrap name and options -- - Added Replace_Value -- - A few fixes -- 26-Apr-1996: RE: Created -- -- Created On : Fri Apr 26 08:09:14 1996 with Ada.Containers.Indefinite_Vectors; package Config is web : constant String := "https://sourceforge.net/projects/ini-files/"; web_alt : constant String := "https://github.com/zertovitch/ini-files"; -- Hopefully the latest version is at one of those locations. type Configuration is tagged private; type Type_Mismatch_Action is (Raise_Data_Error, Print_Warning, Be_Quiet); -- Initialize a Configuration object by providing the absolute path to the -- file where the configuration parameters are stored. The -- routine can be called multiple times to read several files. -- procedure Init (Cfg : out Configuration; Config_File_Name : String; -- -- Read the config file in a case sensitive way if True, i.e. Section -- and Mark must match exactly the upper and lower case spelling. If -- set False, case is irrelevant for Section and Mark. The return value -- still contains the exact case as in the config file. Case_Sensitive : Boolean := True; -- -- What to do in case the found mark does not match the expected type -- (e.g. the program wants an integer, but the config file contains a -- string) On_Type_Mismatch : Type_Mismatch_Action := Raise_Data_Error; -- Some configuration files have the form "Var value" instead of -- "Var=value". Of course, if Variable_Terminator = ' ', variable -- names cannot have a space in them. Variable_Terminator : Character := '=' -- ); -- Same, as a function (can be used in a declaration part as a constructor) function Init (Config_File_Name : String; Case_Sensitive : Boolean := True; On_Type_Mismatch : Type_Mismatch_Action := Raise_Data_Error; Variable_Terminator : Character := '=' ) return Configuration; -- Value_Of : getting values from a configuration file. -- If the Section is "*", the Mark is looked for in the whole configuration file. -- -- We intentionally use the built-in types Integer and Long_Float to keep -- this package as portable as possible and to avoid unnecessary project -- dependencies. Clients of this package generally can directly convert -- to the target types. -- function Value_Of (Cfg : Configuration; Section : String; Mark : String; Default : String := "") return String; function Value_Of (Cfg : Configuration; Section : String; Mark : String; Default : Integer := 0) return Integer; function Value_Of (Cfg : Configuration; Section : String; Mark : String; Default : Long_Float := 0.0) return Long_Float; -- Value_Of for Boolean: you may also want to consider the Is_Set function below. -- function Value_Of (Cfg : Configuration; Section : String; Mark : String; Default : Boolean := False) return Boolean; -- Return True if one of the following conditions is met: -- o the Mark is within the Section, but no equal sign is in that line, -- o the Mark is set to either 1, True or Yes. -- All other cases return False. -- function Is_Set (Cfg : Configuration; Section : String; Mark : String) return Boolean; -- Get the file name, e.g. to rewrite a fresh new config file. -- function File_Name (Cfg : Configuration) return String; -- Replace a single value in a configuration file. -- The whole .ini file is rewritten each time, so it's rather a -- solution for making sporadic changes. -- For changing many values, it might be better to rewrite -- the whole file in one go, or at least use Replace_Section. -- procedure Replace_Value (Cfg : Configuration; Section : String; Mark : String; New_Value : String); Location_Not_Found : exception; -- Replace the full contents of a section with new contents. -- Line breaks are obtained by inserting the LF character -- (defined below) in the New_Contents string. -- Replace_Section is especially useful for config files -- shared by several programs, with not all sections in common. -- procedure Replace_Section (Cfg : Configuration; Section : String; New_Contents : String); LF : constant Character := Character'Val (10); Section_Not_Found : exception; -- Disable the Mark using a semicolon prefix -- procedure Disable (Cfg : Configuration; Section : String; Mark : String); -- retrieve a list of all available sections in the ini file package String_Vector is new Ada.Containers.Indefinite_Vectors (Natural, String); subtype Section_List is String_Vector.Vector; function Read_Sections (Cfg : Configuration) return Section_List; private type Str_Ptr is access String; type Configuration is tagged record Config_File : Str_Ptr := null; Case_Sensitive : Boolean := True; On_Type_Mismatch : Type_Mismatch_Action := Raise_Data_Error; Variable_Terminator : Character := '='; end record; end Config;
AdaCore/gpr
Ada
476
adb
with Ada.Text_IO; use Ada.Text_IO; with Ada_lib2; use ada_lib2; package body Ada_Lib is procedure overflo (S : integer; X : out character) is C : constant := 1_000 * 1024 * 1024; V : String (1 .. C); begin V (S) := '1'; X := V (S); end; procedure Do_It_In_Ada is begin Put_Line ("Done in Ada"); Do_It2; exception when others => Put_Line ("exception raised and handled"); end Do_It_In_Ada; end Ada_Lib;
sungyeon/drake
Ada
1,247
ads
pragma License (Unrestricted); -- implementation unit specialized for POSIX (Darwin, FreeBSD, or Linux) with Ada.Colors; package System.Native_Text_IO.Terminal_Colors is pragma Preelaborate; type Color is mod 256; -- Note: Color represents: -- 0 .. 7 => Normal System Colors (R, G, B => 0 or 16#C0#) -- if $TERM = xterm-256color, -- 8 .. 16 => Bright System Colors (R, G, B => 16#80# or 16#FF#) -- 16 .. 231 => (B, G, R => 0, 16#5F#, 16#87#, 16#AF#, 16#D7# or 16#FF#) -- 232 .. 255 => Grayscale (16#08# + 10 * (Index - 232)) function RGB_To_Color (Item : Ada.Colors.RGB) return Color; function Brightness_To_Grayscale_Color (Item : Ada.Colors.Brightness) return Color; procedure Set ( Handle : Handle_Type; Reset : Boolean; Bold_Changing : Boolean; Bold : Boolean; Underline_Changing : Boolean; Underline : Boolean; Blink_Changing : Boolean; Blink : Boolean; Reversed_Changing : Boolean; Reversed : Boolean; Foreground_Changing : Boolean; Foreground : Color; Background_Changing : Boolean; Background : Color); procedure Reset ( Handle : Handle_Type); end System.Native_Text_IO.Terminal_Colors;
Fabien-Chouteau/GESTE
Ada
4,426
ads
with GESTE; with GESTE.Grid; pragma Style_Checks (Off); package Game_Assets.Level_2 is -- Level_2 Width : constant := 20; Height : constant := 15; Tile_Width : constant := 16; Tile_Height : constant := 16; -- Back package Back is Width : constant := 20; Height : constant := 20; Data : aliased GESTE.Grid.Grid_Data := (( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 0, 0, 83, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 0, 0, 84, 0, 0, 0, 0, 0, 0, 90, 0, 0, 0, 0, 0), ( 0, 0, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 0, 0, 0, 0, 0, 0, 0, 90, 0, 0, 0, 0, 0, 0, 0), ( 0, 0, 0, 0, 0, 86, 86, 86, 86, 86, 86, 86, 86, 86, 0), ( 0, 0, 0, 0, 0, 86, 86, 86, 86, 86, 86, 86, 86, 86, 0), ( 0, 0, 0, 0, 0, 86, 86, 86, 86, 86, 86, 86, 86, 86, 0), ( 0, 0, 0, 0, 0, 86, 86, 86, 86, 86, 86, 86, 86, 86, 0), ( 0, 0, 0, 0, 0, 86, 86, 86, 0, 0, 0, 86, 86, 86, 0), ( 0, 0, 0, 0, 0, 86, 86, 86, 0, 0, 0, 86, 86, 86, 0), ( 0, 0, 0, 0, 0, 86, 86, 86, 86, 90, 86, 86, 86, 86, 0), ( 0, 0, 0, 0, 0, 86, 86, 86, 86, 86, 86, 86, 86, 86, 0), ( 0, 0, 0, 0, 0, 90, 86, 86, 86, 86, 86, 86, 86, 86, 0), ( 0, 0, 0, 0, 90, 0, 86, 86, 86, 86, 86, 86, 90, 0, 0), ( 0, 0, 0, 109, 0, 0, 86, 86, 86, 86, 86, 90, 0, 0, 0), ( 0, 0, 0, 110, 0, 0, 86, 86, 86, 86, 90, 0, 0, 0, 0), ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) ; end Back; -- Mid package Mid is Width : constant := 20; Height : constant := 20; Data : aliased GESTE.Grid.Grid_Data := (( 0, 0, 0, 0, 0, 0, 0, 0, 0, 89, 90, 90, 90, 90, 90), ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 89, 90, 90, 90, 90, 90), ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 89, 90, 90, 90, 90, 90), ( 0, 0, 0, 0, 0, 0, 0, 91, 99, 111, 90, 90, 90, 90, 90), ( 0, 0, 0, 0, 0, 0, 0, 89, 90, 90, 90, 90, 90, 90, 90), ( 0, 0, 0, 0, 0, 91, 99, 111, 90, 90, 90, 90, 90, 90, 90), ( 0, 0, 0, 0, 0, 92, 93, 93, 93, 93, 93, 93, 93, 93, 90), ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 90), ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 90), ( 0, 0, 0, 0, 0, 112, 113, 113, 99, 99, 99, 114, 0, 0, 90), ( 0, 0, 0, 0, 0, 111, 0, 0, 89, 90, 90, 115, 0, 0, 90), ( 0, 0, 0, 0, 0, 0, 0, 0, 89, 90, 90, 116, 0, 0, 90), ( 0, 0, 0, 0, 0, 0, 0, 0, 92, 117, 116, 0, 0, 0, 90), ( 0, 0, 0, 0, 0, 118, 0, 0, 0, 119, 0, 0, 0, 0, 90), ( 0, 0, 0, 0, 91, 111, 120, 0, 0, 0, 0, 0, 91, 99, 90), ( 0, 0, 0, 91, 111, 90, 115, 0, 0, 0, 0, 91, 111, 90, 90), ( 0, 0, 0, 89, 90, 90, 115, 0, 0, 0, 91, 111, 90, 90, 90), ( 0, 0, 0, 89, 90, 90, 90, 99, 99, 99, 111, 90, 90, 90, 90), ( 0, 0, 0, 89, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90), ( 0, 0, 0, 89, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90)) ; end Mid; -- Front package Front is Width : constant := 20; Height : constant := 20; Data : aliased GESTE.Grid.Grid_Data := (( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 0, 0, 83, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 0, 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 0, 0, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 121, 0), ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 122, 0), ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 0, 0, 105, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) ; end Front; end Game_Assets.Level_2;
DrenfongWong/tkm-rpc
Ada
1,823
ads
with Tkmrpc.Types; with Tkmrpc.Operations.Ike; package Tkmrpc.Request.Ike.Cc_Set_User_Certificate is Data_Size : constant := 1528; type Data_Type is record Cc_Id : Types.Cc_Id_Type; Ri_Id : Types.Ri_Id_Type; Autha_Id : Types.Autha_Id_Type; Certificate : Types.Certificate_Type; end record; for Data_Type use record Cc_Id at 0 range 0 .. (8 * 8) - 1; Ri_Id at 8 range 0 .. (8 * 8) - 1; Autha_Id at 16 range 0 .. (8 * 8) - 1; Certificate at 24 range 0 .. (1504 * 8) - 1; end record; for Data_Type'Size use Data_Size * 8; Padding_Size : constant := Request.Body_Size - Data_Size; subtype Padding_Range is Natural range 1 .. Padding_Size; subtype Padding_Type is Types.Byte_Sequence (Padding_Range); type Request_Type is record Header : Request.Header_Type; Data : Data_Type; Padding : Padding_Type; end record; for Request_Type use record Header at 0 range 0 .. (Request.Header_Size * 8) - 1; Data at Request.Header_Size range 0 .. (Data_Size * 8) - 1; Padding at Request.Header_Size + Data_Size range 0 .. (Padding_Size * 8) - 1; end record; for Request_Type'Size use Request.Request_Size * 8; Null_Request : constant Request_Type := Request_Type' (Header => Request.Header_Type'(Operation => Operations.Ike.Cc_Set_User_Certificate, Request_Id => 0), Data => Data_Type'(Cc_Id => Types.Cc_Id_Type'First, Ri_Id => Types.Ri_Id_Type'First, Autha_Id => Types.Autha_Id_Type'First, Certificate => Types.Null_Certificate_Type), Padding => Padding_Type'(others => 0)); end Tkmrpc.Request.Ike.Cc_Set_User_Certificate;
Rodeo-McCabe/orka
Ada
3,611
adb
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2017 onox <[email protected]> -- -- 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 GL.Low_Level.Enums; with GL.Pixels; with GL.Types; with Orka.Strings; package body Orka.Rendering.Textures is procedure Bind (Object : GL.Objects.Textures.Texture_Base'Class; Target : Indexed_Texture_Target; Index : Natural) is begin case Target is when Texture => Object.Bind_Texture_Unit (GL.Types.UInt (Index)); when Image => Object.Bind_Image_Texture (GL.Types.UInt (Index)); end case; end Bind; function Bayer_Dithering_Pattern return GL.Objects.Samplers.Sampler is use all type GL.Objects.Textures.Minifying_Function; use all type GL.Objects.Textures.Wrapping_Mode; begin return Result : GL.Objects.Samplers.Sampler do Result.Set_X_Wrapping (Repeat); Result.Set_Y_Wrapping (Repeat); Result.Set_Minifying_Filter (Nearest); Result.Set_Magnifying_Filter (Nearest); end return; end Bayer_Dithering_Pattern; function Bayer_Dithering_Pattern return GL.Objects.Textures.Texture is Pixels : aliased constant GL.Types.UByte_Array := (0, 32, 8, 40, 2, 34, 10, 42, 48, 16, 56, 24, 50, 18, 58, 26, 12, 44, 4, 36, 14, 46, 6, 38, 60, 28, 52, 20, 62, 30, 54, 22, 3, 35, 11, 43, 1, 33, 9, 41, 51, 19, 59, 27, 49, 17, 57, 25, 15, 47, 7, 39, 13, 45, 5, 37, 63, 31, 55, 23, 61, 29, 53, 21); -- * Bayer, B. E. (1973). An optimum method for two-level rendition of -- continuous-tone pictures. In IEEE Int. Conf. on Communications -- (Vol. 26, pp. 11-15). -- * http://www.anisopteragames.com/how-to-fix-color-banding-with-dithering/ begin return Result : GL.Objects.Textures.Texture (GL.Low_Level.Enums.Texture_2D) do Result.Allocate_Storage (1, 1, GL.Pixels.R8, Width => 8, Height => 8, Depth => 1); Result.Load_From_Data (Level => 0, Width => 8, Height => 8, Depth => 1, Source_Format => GL.Pixels.Red, Source_Type => GL.Pixels.Unsigned_Byte, Source => Pixels'Address); end return; end Bayer_Dithering_Pattern; function Image (Texture : GL.Objects.Textures.Texture; Level : GL.Objects.Textures.Mipmap_Level := 0) return String is Width : constant String := Orka.Strings.Trim (Texture.Width (Level)'Image); Height : constant String := Orka.Strings.Trim (Texture.Height (Level)'Image); Depth : constant String := Orka.Strings.Trim (Texture.Depth (Level)'Image); begin return (if Texture.Allocated then "" else "unallocated ") & Width & " x " & Height & " x " & Depth & " " & Texture.Kind'Image & " with " & (if Texture.Compressed then Texture.Compressed_Format'Image else Texture.Internal_Format'Image) & " format"; end Image; end Orka.Rendering.Textures;
charlie5/cBound
Ada
1,106
ads
-- This file is generated by SWIG. Please do *not* modify by hand. -- with gmp_c.a_a_gmp_randstate_struct_a_mp_algdata; with gmp_c.mpz_t; with Interfaces.C; package gmp_c.a_a_gmp_randstate_struct is -- Item -- type Item is record a_mp_seed : aliased gmp_c.mpz_t.Item; a_mp_alg : aliased gmp_c.gmp_randalg_t; a_mp_algdata : aliased gmp_c.a_a_gmp_randstate_struct_a_mp_algdata.Item; end record; -- Items -- type Items is array (Interfaces.C .size_t range <>) of aliased gmp_c.a_a_gmp_randstate_struct.Item; -- Pointer -- type Pointer is access all gmp_c.a_a_gmp_randstate_struct.Item; -- Pointers -- type Pointers is array (Interfaces.C .size_t range <>) of aliased gmp_c.a_a_gmp_randstate_struct.Pointer; -- Pointer_Pointer -- type Pointer_Pointer is access all gmp_c.a_a_gmp_randstate_struct.Pointer; function construct return gmp_c.a_a_gmp_randstate_struct.Item; private pragma Import (C, construct, "Ada_new___gmp_randstate_struct"); end gmp_c.a_a_gmp_randstate_struct;
AdaCore/libadalang
Ada
197
adb
procedure Test is type T is record X : Integer; --% node.p_get_pragma("atomic") pragma Atomic (X); --% node.p_associated_entities end record; begin null; end Test;
michael-hardeman/contacts_app
Ada
60,604
adb
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../../License.txt package body AdaBase.Statement.Base is ------------------ -- successful -- ------------------ overriding function successful (Stmt : Base_Statement) return Boolean is begin return Stmt.successful_execution; end successful; ---------------------- -- data_discarded -- ---------------------- overriding function data_discarded (Stmt : Base_Statement) return Boolean is begin return Stmt.rows_leftover; end data_discarded; --------------------- -- rows_affected -- --------------------- overriding function rows_affected (Stmt : Base_Statement) return Affected_Rows is begin if not Stmt.successful_execution then raise PRIOR_EXECUTION_FAILED with "Has query been executed yet?"; end if; if Stmt.result_present then raise INVALID_FOR_RESULT_SET with "Result set found; use rows_returned"; else return Stmt.impacted; end if; end rows_affected; --------------------- -- transform_sql -- --------------------- function transform_sql (Stmt : out Base_Statement; sql : String) return String is procedure reserve_marker; sql_mask : String := CT.redact_quotes (sql); procedure reserve_marker is brec : bindrec; begin brec.v00 := False; Stmt.realmccoy.Append (New_Item => brec); end reserve_marker; begin Stmt.alpha_markers.Clear; Stmt.realmccoy.Clear; if CT.IsBlank (sql) then return ""; end if; declare -- This block does two things: -- 1) finds "?" and increments the replacement index -- 2) finds ":[A-Za-z0-9_]*", replaces with "?", increments the -- replacement index, and pushes the string into alpha markers -- Normally ? and : aren't mixed but we will support it. procedure replace_alias; procedure lock_and_advance (symbol : Character); start : Natural := 0; final : Natural := 0; arrow : Positive := 1; polaris : Natural := 0; scanning : Boolean := False; product : String (1 .. sql'Length) := (others => ' '); adjacent_error : constant String := "Bindings are not separated; they are touching: "; procedure lock_and_advance (symbol : Character) is begin polaris := polaris + 1; product (polaris) := symbol; end lock_and_advance; procedure replace_alias is len : Natural := final - start; alias : String (1 .. len) := sql_mask (start + 1 .. final); begin if Stmt.alpha_markers.Contains (Key => alias) then raise ILLEGAL_BIND_SQL with "multiple instances of " & alias; end if; reserve_marker; Stmt.alpha_markers.Insert (alias, Stmt.realmccoy.Last_Index); scanning := False; end replace_alias; begin loop case sql_mask (arrow) is when ASCII.Query => if scanning then raise ILLEGAL_BIND_SQL with adjacent_error & sql_mask (start .. arrow); end if; reserve_marker; lock_and_advance (ASCII.Query); when ASCII.Colon => if scanning then raise ILLEGAL_BIND_SQL with adjacent_error & sql_mask (start .. arrow); end if; scanning := True; start := arrow; when others => if scanning then case sql_mask (arrow) is when 'A' .. 'Z' | 'a' .. 'z' | '0' .. '9' | '_' => final := arrow; when others => replace_alias; lock_and_advance (ASCII.Query); lock_and_advance (sql (arrow)); end case; else lock_and_advance (sql (arrow)); end if; end case; if scanning and then arrow = sql_mask'Length then replace_alias; lock_and_advance (ASCII.Query); end if; exit when arrow = sql_mask'Length; arrow := arrow + 1; end loop; return product (1 .. polaris); end; end transform_sql; ---------------------------------- -- convert string to textwide -- ---------------------------------- function convert (nv : String) return AR.Textwide is begin return SUW.To_Unbounded_Wide_String (ACC.To_Wide_String (nv)); end convert; ----------------------------------- -- convert string to textsuper -- ----------------------------------- function convert (nv : String) return AR.Textsuper is begin return SWW.To_Unbounded_Wide_Wide_String (ACC.To_Wide_Wide_String (nv)); end convert; -------------------- -- Same_Strings -- -------------------- function Same_Strings (S, T : String) return Boolean is begin return S = T; end Same_Strings; ------------------- -- log_nominal -- ------------------- procedure log_nominal (statement : Base_Statement; category : Log_Category; message : String) is begin logger_access.all.log_nominal (driver => statement.dialect, category => category, message => CT.SUS (message)); end log_nominal; -------------------- -- bind_proceed -- -------------------- function bind_proceed (Stmt : Base_Statement; index : Positive) return Boolean is begin if not Stmt.successful_execution then raise PRIOR_EXECUTION_FAILED with "Use bind after 'execute' but before 'fetch_next'"; end if; if index > Stmt.crate.Last_Index then raise BINDING_COLUMN_NOT_FOUND with "Index" & index'Img & " is too high; only" & Stmt.crate.Last_Index'Img & " columns exist."; end if; return True; end bind_proceed; ------------------ -- bind_index -- ------------------ function bind_index (Stmt : Base_Statement; heading : String) return Positive is use type Markers.Cursor; cursor : Markers.Cursor; begin cursor := Stmt.headings_map.Find (Key => heading); if cursor = Markers.No_Element then raise BINDING_COLUMN_NOT_FOUND with "There is no column named '" & heading & "'."; end if; return Markers.Element (Position => cursor); end bind_index; --------------------------------- -- check_bound_column_access -- --------------------------------- procedure check_bound_column_access (absent : Boolean) is begin if absent then raise ILLEGAL_BIND_SQL with "Binding column with null access is illegal"; end if; end check_bound_column_access; ------------------------------------------------------ -- 23 bind functions (impossible to make generic) -- ------------------------------------------------------ procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte0_Access) is use type AR.NByte0_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_nbyte0, a00 => vaxx, v00 => False, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte1_Access) is use type AR.NByte1_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_nbyte1, a01 => vaxx, v01 => 0, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte2_Access) is use type AR.NByte2_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_nbyte2, a02 => vaxx, v02 => 0, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte3_Access) is use type AR.NByte3_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_nbyte3, a03 => vaxx, v03 => 0, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte4_Access) is use type AR.NByte4_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_nbyte4, a04 => vaxx, v04 => 0, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte8_Access) is use type AR.NByte8_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_nbyte8, a05 => vaxx, v05 => 0, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte1_Access) is use type AR.Byte1_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_byte1, a06 => vaxx, v06 => 0, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte2_Access) is use type AR.Byte2_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_byte2, a07 => vaxx, v07 => 0, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte3_Access) is use type AR.Byte3_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_byte3, a08 => vaxx, v08 => 0, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte4_Access) is use type AR.Byte4_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_byte4, a09 => vaxx, v09 => 0, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte8_Access) is use type AR.Byte8_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_byte8, a10 => vaxx, v10 => 0, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Real9_Access) is use type AR.Real9_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_real9, a11 => vaxx, v11 => 0.0, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Real18_Access) is use type AR.Real18_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_real18, a12 => vaxx, v12 => 0.0, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Str1_Access) is use type AR.Str1_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_textual, a13 => vaxx, v13 => CT.blank, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Str2_Access) is use type AR.Str2_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_widetext, a14 => vaxx, bound => True, v14 => AR.Blank_WString, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Str4_Access) is use type AR.Str4_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_supertext, a15 => vaxx, bound => True, v15 => AR.Blank_WWString, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Time_Access) is use type AR.Time_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_timestamp, a16 => vaxx, v16 => CAL.Clock, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Chain_Access) is use type AR.Chain_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_chain, a17 => vaxx, v17 => CT.blank, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Enum_Access) is use type AR.Enum_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_enumtype, a18 => vaxx, bound => True, v18 => AR.PARAM_IS_ENUM, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Settype_Access) is use type AR.Settype_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_settype, a19 => vaxx, v19 => CT.blank, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Bits_Access) is use type AR.Bits_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_bits, a20 => vaxx, v20 => CT.blank, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.S_UTF8_Access) is use type AR.S_UTF8_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_utf8, a21 => vaxx, v21 => CT.blank, bound => True, null_data => False)); end if; end bind; procedure bind (Stmt : out Base_Statement; index : Positive; vaxx : AR.Geometry_Access) is use type AR.Geometry_Access; absent : Boolean := (vaxx = null); begin check_bound_column_access (absent); if Stmt.bind_proceed (index => index) then Stmt.crate.Replace_Element (index, (output_type => ft_geometry, a22 => vaxx, v22 => CT.blank, bound => True, null_data => False)); end if; end bind; ------------------------------------------------------------------ -- bind via headings (believe me, generics are not possible) -- ------------------------------------------------------------------ procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.NByte0_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.NByte1_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.NByte2_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.NByte3_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.NByte4_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.NByte8_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Byte1_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Byte2_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Byte3_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Byte4_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Byte8_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Real9_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Real18_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Str1_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Str2_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Str4_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Time_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Chain_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Enum_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Settype_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Bits_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.S_UTF8_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; procedure bind (Stmt : out Base_Statement; heading : String; vaxx : AR.Geometry_Access) is begin Stmt.bind (vaxx => vaxx, index => Stmt.bind_index (heading)); end bind; -------------------- -- assign_index -- -------------------- function assign_index (Stmt : Base_Statement; moniker : String) return Positive is use type Markers.Cursor; cursor : Markers.Cursor; begin cursor := Stmt.alpha_markers.Find (Key => moniker); if cursor = Markers.No_Element then raise MARKER_NOT_FOUND with "There is no marker known as '" & moniker & "'."; end if; return Markers.Element (Position => cursor); end assign_index; ------------------------------------------------------------------ -- assign via moniker (Access, 23) -- ------------------------------------------------------------------ procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.NByte0_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.NByte1_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.NByte2_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.NByte3_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.NByte4_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.NByte8_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Byte1_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Byte2_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Byte3_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Byte4_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Byte8_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Real9_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Real18_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Str1_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Str2_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Str4_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Time_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Chain_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Enum_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Settype_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Bits_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.S_UTF8_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Geometry_Access) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; ------------------------------------------------------------------ -- assign via moniker (Value, 23) -- ------------------------------------------------------------------ procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.NByte0) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.NByte1) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.NByte2) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.NByte3) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.NByte4) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.NByte8) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Byte1) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Byte2) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Byte3) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Byte4) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Byte8) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Real9) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Real18) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Textual) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Textwide) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Textsuper) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : CAL.Time) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Chain) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Enumtype) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Settype) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Bits) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : AR.Text_UTF8) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; procedure assign (Stmt : out Base_Statement; moniker : String; vaxx : Spatial_Data.Geometry) is begin Stmt.assign (vaxx => vaxx, index => Stmt.assign_index (moniker)); end assign; ------------------------------------------------------ -- 23 + 23 = 46 assign functions -- ------------------------------------------------------ procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte0_Access) is use type AR.NByte0_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_nbyte0, a00 => vaxx, v00 => False, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte0) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_nbyte0, a00 => null, v00 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte1_Access) is use type AR.NByte1_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_nbyte1, a01 => vaxx, v01 => 0, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte1) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_nbyte1, a01 => null, v01 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte2_Access) is use type AR.NByte2_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_nbyte2, a02 => vaxx, v02 => 0, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte2) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_nbyte2, a02 => null, v02 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte3_Access) is use type AR.NByte3_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_nbyte3, a03 => vaxx, v03 => 0, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte3) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_nbyte3, a03 => null, v03 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte4_Access) is use type AR.NByte4_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_nbyte4, a04 => vaxx, v04 => 0, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte4) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_nbyte4, a04 => null, v04 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte8_Access) is use type AR.NByte8_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_nbyte8, a05 => vaxx, v05 => 0, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.NByte8) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_nbyte8, a05 => null, v05 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte1_Access) is use type AR.Byte1_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_byte1, a06 => vaxx, v06 => 0, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte1) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_byte1, a06 => null, v06 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte2_Access) is use type AR.Byte2_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_byte2, a07 => vaxx, v07 => 0, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte2) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_byte2, a07 => null, v07 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte3_Access) is use type AR.Byte3_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_byte3, a08 => vaxx, v08 => 0, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte3) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_byte3, a08 => null, v08 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte4_Access) is use type AR.Byte4_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_byte4, a09 => vaxx, v09 => 0, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte4) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_byte4, a09 => null, v09 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte8_Access) is use type AR.Byte8_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_byte8, a10 => vaxx, v10 => 0, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Byte8) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_byte8, a10 => null, v10 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Real9_Access) is use type AR.Real9_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_real9, a11 => vaxx, v11 => 0.0, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Real9) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_real9, a11 => null, v11 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Real18_Access) is use type AR.Real18_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_real18, a12 => vaxx, v12 => 0.0, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Real18) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_real18, a12 => null, v12 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Str1_Access) is use type AR.Str1_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_textual, a13 => vaxx, v13 => CT.blank, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Textual) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_textual, a13 => null, v13 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Str2_Access) is use type AR.Str2_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_widetext, a14 => vaxx, v14 => AR.Blank_WString, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Textwide) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_widetext, a14 => null, v14 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Str4_Access) is use type AR.Str4_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_supertext, a15 => vaxx, bound => True, v15 => AR.Blank_WWString, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Textsuper) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_supertext, a15 => null, v15 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Time_Access) is use type AR.Time_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_timestamp, a16 => vaxx, v16 => CAL.Clock, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : CAL.Time) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_timestamp, a16 => null, v16 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Chain_Access) is use type AR.Chain_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_chain, a17 => vaxx, v17 => CT.blank, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Chain) is payload : constant String := ARC.convert (vaxx); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_chain, a17 => null, v17 => CT.SUS (payload), bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Enum_Access) is use type AR.Enum_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_enumtype, a18 => vaxx, v18 => AR.PARAM_IS_ENUM, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Enumtype) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_enumtype, a18 => null, v18 => vaxx, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Settype_Access) is use type AR.Settype_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_settype, a19 => vaxx, v19 => CT.blank, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Settype) is payload : AR.Textual := CT.blank; begin for x in vaxx'Range loop if x /= vaxx'First then CT.SU.Append (payload, ","); end if; CT.SU.Append (payload, vaxx (x).enumeration); end loop; Stmt.realmccoy.Replace_Element (index, (output_type => ft_settype, a19 => null, v19 => payload, bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Bits_Access) is use type AR.Bits_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_bits, a20 => vaxx, v20 => CT.blank, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Bits) is payload : constant String := ARC.convert (vaxx); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_bits, a20 => null, v20 => CT.SUS (payload), bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.S_UTF8_Access) is use type AR.S_UTF8_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_utf8, a21 => vaxx, v21 => CT.blank, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Text_UTF8) is begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_utf8, a21 => null, v21 => CT.SUS (vaxx), bound => True, null_data => False)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : AR.Geometry_Access) is use type AR.Geometry_Access; absent : Boolean := (vaxx = null); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_geometry, a22 => vaxx, v22 => CT.blank, bound => True, null_data => absent)); end assign; procedure assign (Stmt : out Base_Statement; index : Positive; vaxx : Spatial_Data.Geometry) is shape : String := Spatial_Data.Well_Known_Text (vaxx); begin Stmt.realmccoy.Replace_Element (index, (output_type => ft_geometry, a22 => null, v22 => CT.SUS (shape), bound => True, null_data => False)); end assign; ------------------ -- iterate #1 -- ------------------ overriding procedure iterate (Stmt : out Base_Statement; process : not null access procedure) is begin loop exit when not fetch_bound (Stmt => Base_Statement'Class (Stmt)); process.all; end loop; end iterate; ------------------ -- iterate #2 -- ------------------ overriding procedure iterate (Stmt : out Base_Statement; process : not null access procedure (row : ARS.Datarow)) is begin loop declare local_row : ARS.Datarow := fetch_next (Stmt => Base_Statement'Class (Stmt)); begin exit when local_row.data_exhausted; process.all (row => local_row); end; end loop; end iterate; ------------------- -- auto_assign -- ------------------- procedure auto_assign (Stmt : out Base_Statement; index : Positive; value : String) is zone : bindrec renames Stmt.realmccoy.Element (index); ST : AR.Textual; STW : AR.Textwide; STS : AR.Textsuper; hold : ARF.Variant; begin case zone.output_type is when ft_widetext => ST := CT.SUS (value); STW := SUW.To_Unbounded_Wide_String (ARC.convert (ST)); when ft_supertext => ST := CT.SUS (value); STS := SWW.To_Unbounded_Wide_Wide_String (ARC.convert (ST)); when ft_timestamp | ft_settype | ft_chain => null; when others => ST := CT.SUS (value); end case; case zone.output_type is when ft_nbyte0 => hold := (ft_nbyte0, ARC.convert (ST)); when ft_nbyte1 => hold := (ft_nbyte1, ARC.convert (ST)); when ft_nbyte2 => hold := (ft_nbyte2, ARC.convert (ST)); when ft_nbyte3 => hold := (ft_nbyte3, ARC.convert (ST)); when ft_nbyte4 => hold := (ft_nbyte4, ARC.convert (ST)); when ft_nbyte8 => hold := (ft_nbyte8, ARC.convert (ST)); when ft_byte1 => hold := (ft_byte1, ARC.convert (ST)); when ft_byte2 => hold := (ft_byte2, ARC.convert (ST)); when ft_byte3 => hold := (ft_byte3, ARC.convert (ST)); when ft_byte4 => hold := (ft_byte4, ARC.convert (ST)); when ft_byte8 => hold := (ft_byte8, ARC.convert (ST)); when ft_real9 => hold := (ft_real9, ARC.convert (ST)); when ft_real18 => hold := (ft_real18, ARC.convert (ST)); when ft_textual => hold := (ft_textual, ST); when ft_widetext => hold := (ft_widetext, STW); when ft_supertext => hold := (ft_supertext, STS); when ft_timestamp => hold := (ft_timestamp, (ARC.convert (value))); when ft_chain => null; when ft_enumtype => hold := (ft_enumtype, (ARC.convert (ST))); when ft_settype => null; when ft_bits => null; when ft_utf8 => hold := (ft_utf8, ST); when ft_geometry => hold := (ft_geometry, ST); -- ST=WKB end case; case zone.output_type is when ft_nbyte0 => Stmt.assign (index, hold.v00); when ft_nbyte1 => Stmt.assign (index, hold.v01); when ft_nbyte2 => Stmt.assign (index, hold.v02); when ft_nbyte3 => Stmt.assign (index, hold.v03); when ft_nbyte4 => Stmt.assign (index, hold.v04); when ft_nbyte8 => Stmt.assign (index, hold.v05); when ft_byte1 => Stmt.assign (index, hold.v06); when ft_byte2 => Stmt.assign (index, hold.v07); when ft_byte3 => Stmt.assign (index, hold.v08); when ft_byte4 => Stmt.assign (index, hold.v09); when ft_byte8 => Stmt.assign (index, hold.v10); when ft_real9 => Stmt.assign (index, hold.v11); when ft_real18 => Stmt.assign (index, hold.v12); when ft_textual => Stmt.assign (index, hold.v13); when ft_widetext => Stmt.assign (index, hold.v14); when ft_supertext => Stmt.assign (index, hold.v15); when ft_timestamp => Stmt.assign (index, hold.v16); when ft_enumtype => Stmt.assign (index, hold.v18); when ft_utf8 => Stmt.assign (index, hold.v21); when ft_geometry => Stmt.assign (index, hold.v22); when ft_chain => declare my_chain : AR.Chain := ARC.convert (value); begin Stmt.assign (index, my_chain); end; when ft_settype => declare set : AR.Settype := ARC.convert (value); begin Stmt.assign (index, set); end; when ft_bits => declare bitchain : AR.Bits := ARC.convert (value); begin Stmt.assign (index, bitchain); end; end case; end auto_assign; ------------------ -- set_as_null -- ------------------- procedure set_as_null (param : bindrec) is data_type : field_types := param.output_type; begin case data_type is when ft_nbyte0 => param.a00.all := AR.PARAM_IS_BOOLEAN; when ft_nbyte1 => param.a01.all := AR.PARAM_IS_NBYTE_1; when ft_nbyte2 => param.a02.all := AR.PARAM_IS_NBYTE_2; when ft_nbyte3 => param.a03.all := AR.PARAM_IS_NBYTE_3; when ft_nbyte4 => param.a04.all := AR.PARAM_IS_NBYTE_4; when ft_nbyte8 => param.a05.all := AR.PARAM_IS_NBYTE_8; when ft_byte1 => param.a06.all := AR.PARAM_IS_BYTE_1; when ft_byte2 => param.a07.all := AR.PARAM_IS_BYTE_2; when ft_byte3 => param.a08.all := AR.PARAM_IS_BYTE_3; when ft_byte4 => param.a09.all := AR.PARAM_IS_BYTE_4; when ft_byte8 => param.a10.all := AR.PARAM_IS_BYTE_8; when ft_real9 => param.a11.all := AR.PARAM_IS_REAL_9; when ft_real18 => param.a12.all := AR.PARAM_IS_REAL_18; when ft_textual => param.a13.all := AR.PARAM_IS_TEXTUAL; when ft_widetext => param.a14.all := AR.PARAM_IS_TEXTWIDE; when ft_supertext => param.a15.all := AR.PARAM_IS_TEXTSUPER; when ft_timestamp => param.a16.all := AR.PARAM_IS_TIMESTAMP; when ft_enumtype => param.a18.all := AR.PARAM_IS_ENUM; when ft_chain => param.a17.all := ARC.convert ("", param.a17.all'Length); when ft_settype => param.a19.all := ARC.convert ("", param.a19.all'Length); when ft_bits => param.a20.all := ARC.convert ("", param.a20.all'Length); when ft_utf8 => param.a21.all := AR.PARAM_IS_TEXT_UTF8; when ft_geometry => param.a22.all := GEO.initialize_as_point (GEO.Origin_Point); end case; end set_as_null; end AdaBase.Statement.Base;
zhmu/ananas
Ada
8,953
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . V E C T O R S . B O O L E A N _ O P E R A T I O N S -- -- -- -- B o d y -- -- -- -- Copyright (C) 2002-2022, 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. -- -- -- ------------------------------------------------------------------------------ -- Ghost code, loop invariants and assertions in this unit are meant for -- analysis only, not for run-time checking, as it would be too costly -- otherwise. This is enforced by setting the assertion policy to Ignore. pragma Assertion_Policy (Ghost => Ignore, Loop_Invariant => Ignore, Assert => Ignore); package body System.Vectors.Boolean_Operations with SPARK_Mode is SU : constant := Storage_Unit; -- Convenient short hand, used throughout -- The coding of this unit depends on the fact that the Component_Size -- of a normally declared array of Boolean is equal to Storage_Unit. We -- can't use the Component_Size directly since it is non-static. The -- following declaration checks that this declaration is correct type Boolean_Array is array (Integer range <>) of Boolean; pragma Compile_Time_Error (Boolean_Array'Component_Size /= SU, "run time compile failure"); -- NOTE: The boolean literals must be qualified here to avoid visibility -- anomalies when this package is compiled through Rtsfind, in a context -- that includes a user-defined type derived from boolean. True_Val : constant Vector := Standard.True'Enum_Rep + Standard.True'Enum_Rep * 2**SU + Standard.True'Enum_Rep * 2**(SU * 2) + Standard.True'Enum_Rep * 2**(SU * 3) + Standard.True'Enum_Rep * 2**(SU * 4) + Standard.True'Enum_Rep * 2**(SU * 5) + Standard.True'Enum_Rep * 2**(SU * 6) + Standard.True'Enum_Rep * 2**(SU * 7); -- This constant represents the bits to be flipped to perform a logical -- "not" on a vector of booleans, independent of the actual -- representation of True. -- The representations of (False, True) are assumed to be zero/one and -- the maximum number of unpacked booleans per Vector is assumed to be 8. pragma Assert (Standard.False'Enum_Rep = 0); pragma Assert (Standard.True'Enum_Rep = 1); pragma Assert (Vector'Size / Storage_Unit <= 8); -- The reason we need to do these gymnastics is that no call to -- Unchecked_Conversion can be made at the library level since this -- unit is pure. Also a conversion from the array type to the Vector type -- inside the body of "not" is inefficient because of alignment issues. ----------- -- "not" -- ----------- function "not" (Item : Vectors.Vector) return Vectors.Vector is procedure Prove_Not (Result : Vectors.Vector) with Ghost, Pre => Valid (Item) and then Result = (Item xor True_Val), Post => Valid (Result) and then (for all J in 1 .. Vector_Boolean_Size => Model (Result) (J) = not Model (Item) (J)); procedure Prove_Not (Result : Vectors.Vector) is begin for J in 1 .. Vector_Boolean_Size loop pragma Assert (Element (Result, J) = 1 - Element (Item, J)); end loop; end Prove_Not; begin Prove_Not (Item xor True_Val); return Item xor True_Val; end "not"; ---------- -- Nand -- ---------- function Nand (Left, Right : Boolean) return Boolean is begin return not (Left and Right); end Nand; function Nand (Left, Right : Vectors.Vector) return Vectors.Vector is procedure Prove_And (Result : Vectors.Vector) with Ghost, Pre => Valid (Left) and then Valid (Right) and then Result = (Left and Right), Post => Valid (Result) and then (for all J in 1 .. Vector_Boolean_Size => Model (Result) (J) = (Model (Left) (J) and Model (Right) (J))); procedure Prove_And (Result : Vectors.Vector) is begin for J in 1 .. Vector_Boolean_Size loop pragma Assert (Element (Result, J) = (if Element (Left, J) = 1 and Element (Right, J) = 1 then 1 else 0)); end loop; end Prove_And; begin Prove_And (Left and Right); return not (Left and Right); end Nand; --------- -- Nor -- --------- function Nor (Left, Right : Boolean) return Boolean is begin return not (Left or Right); end Nor; function Nor (Left, Right : Vectors.Vector) return Vectors.Vector is procedure Prove_Or (Result : Vectors.Vector) with Ghost, Pre => Valid (Left) and then Valid (Right) and then Result = (Left or Right), Post => Valid (Result) and then (for all J in 1 .. Vector_Boolean_Size => Model (Result) (J) = (Model (Left) (J) or Model (Right) (J))); procedure Prove_Or (Result : Vectors.Vector) is begin for J in 1 .. Vector_Boolean_Size loop pragma Assert (Element (Result, J) = (if Element (Left, J) = 1 or Element (Right, J) = 1 then 1 else 0)); end loop; end Prove_Or; begin Prove_Or (Left or Right); return not (Left or Right); end Nor; ---------- -- Nxor -- ---------- function Nxor (Left, Right : Boolean) return Boolean is begin return not (Left xor Right); end Nxor; function Nxor (Left, Right : Vectors.Vector) return Vectors.Vector is procedure Prove_Xor (Result : Vectors.Vector) with Ghost, Pre => Valid (Left) and then Valid (Right) and then Result = (Left xor Right), Post => Valid (Result) and then (for all J in 1 .. Vector_Boolean_Size => Model (Result) (J) = (Model (Left) (J) xor Model (Right) (J))); procedure Prove_Xor (Result : Vectors.Vector) is begin for J in 1 .. Vector_Boolean_Size loop pragma Assert (Element (Result, J) = (if Element (Left, J) = 1 xor Element (Right, J) = 1 then 1 else 0)); end loop; end Prove_Xor; begin Prove_Xor (Left xor Right); return not (Left xor Right); end Nxor; end System.Vectors.Boolean_Operations;
reznikmm/matreshka
Ada
5,775
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- 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$ ------------------------------------------------------------------------------ with Matreshka.XML_Schema.Visitors; package body Matreshka.XML_Schema.AST.Element_Declarations is ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Element_Declaration_Node; Visitor : in out Matreshka.XML_Schema.Visitors.Abstract_Visitor'Class; Control : in out Matreshka.XML_Schema.Visitors.Traverse_Control) is begin Visitor.Enter_Element_Declaration (Matreshka.XML_Schema.AST.Element_Declaration_Access (Self), Control); end Enter_Node; -------------- -- Get_Name -- -------------- overriding function Get_Name (Self : not null access Element_Declaration_Node) return League.Strings.Universal_String is begin return Self.Name; end Get_Name; -------------------------- -- Get_Target_Namespace -- -------------------------- overriding function Get_Target_Namespace (Self : not null access Element_Declaration_Node) return League.Strings.Universal_String is begin return Self.Target_Namespace; end Get_Target_Namespace; -------------- -- Get_Type -- -------------- overriding function Get_Type (Self : not null access Element_Declaration_Node) return XML.Schema.Component_Type is pragma Unreferenced (Self); begin return XML.Schema.Element_Declaration; end Get_Type; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Element_Declaration_Node; Visitor : in out Matreshka.XML_Schema.Visitors.Abstract_Visitor'Class; Control : in out Matreshka.XML_Schema.Visitors.Traverse_Control) is begin Visitor.Leave_Element_Declaration (Matreshka.XML_Schema.AST.Element_Declaration_Access (Self), Control); end Leave_Node; ---------------- -- Visit_Node -- ---------------- overriding procedure Visit_Node (Self : not null access Element_Declaration_Node; Iterator : in out Matreshka.XML_Schema.Visitors.Abstract_Iterator'Class; Visitor : in out Matreshka.XML_Schema.Visitors.Abstract_Visitor'Class; Control : in out Matreshka.XML_Schema.Visitors.Traverse_Control) is begin Iterator.Visit_Element_Declaration (Visitor, Matreshka.XML_Schema.AST.Element_Declaration_Access (Self), Control); end Visit_Node; end Matreshka.XML_Schema.AST.Element_Declarations;
AaronC98/PlaneSystem
Ada
3,226
ads
------------------------------------------------------------------------------ -- Ada Web Server -- -- -- -- Copyright (C) 2008-2014, AdaCore -- -- -- -- 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. -- -- -- -- -- -- -- -- -- -- -- -- 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/>. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ------------------------------------------------------------------------------ with Ada.Strings.Unbounded; with AWS.Translator; package AWS.Jabber.Digest_Md5 is use Ada.Strings.Unbounded; -- DIGEST-MD5 authentication mechanism for python SASL implementation. -- -- Normative reference: RFC 2831 <http://www.ietf.org/rfc/rfc2831.txt> type Challenge is record Nonce : Unbounded_String; Realm : Unbounded_String; end record; function Decode_Challenge (Encoded_Challenge : Translator.Base64_String) return Challenge with Pre => Encoded_Challenge'Length > 0, Post => Decode_Challenge'Result /= (Null_Unbounded_String, Null_Unbounded_String); -- Decode the Base64 encoded message and returns the challenge function Reply_Challenge (Username, Realm, Password, Host, Nonce : String) return Translator.Base64_String with Pre => Username'Length > 0 and then Password'Length > 0 and then Host'Length > 0 and then Nonce'Length > 0; end AWS.Jabber.Digest_Md5;
AdaCore/libadalang
Ada
41
adb
procedure Bar is begin null; end Bar;
aherd2985/Amass
Ada
328
ads
-- Copyright 2017-2021 Jeff Foley. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. name = "ArchiveToday" type = "archive" function start() setratelimit(2) end function vertical(ctx, domain) scrape(ctx, {url="http://archive.is/*." .. domain}) end
stcarrez/ada-ado
Ada
3,681
ads
----------------------------------------------------------------------- -- ado-sessions-sources -- Database Sources -- Copyright (C) 2017, 2019 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- 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. ----------------------------------------------------------------------- -- == Connection string == -- The database connection string is an URI that specifies the database driver to use as well -- as the information for the database driver to connect to the database. -- The driver connection is a string of the form: -- -- driver://[host][:port]/[database][?property1][=value1]... -- -- The database connection string is passed to the session factory that maintains connections -- to the database (see ADO.Sessions.Factory). -- package ADO.Sessions.Sources is -- ------------------------------ -- The database connection source -- ------------------------------ -- The <b>DataSource</b> is the factory for getting a connection to the database. -- It contains the configuration properties to define which database driver must -- be used and which connection parameters the driver has to use to establish -- the connection. type Data_Source is new ADO.Connections.Configuration with private; type Data_Source_Access is access all Data_Source'Class; -- ------------------------------ -- Replicated Data Source -- ------------------------------ -- The replicated data source supports a Master/Slave database configuration. -- When using this data source, the master is used to execute -- update, insert, delete and also query statements. The slave is used -- to execute query statements. The master and slave are represented by -- two separate data sources. This allows to have a master on one server, -- use a specific user/password and get a slave on another server with other -- credentials. type Replicated_DataSource is new Data_Source with private; type Replicated_DataSource_Access is access all Replicated_DataSource'Class; -- Set the master data source procedure Set_Master (Controller : in out Replicated_DataSource; Master : in Data_Source_Access); -- Get the master data source function Get_Master (Controller : in Replicated_DataSource) return Data_Source_Access; -- Set the slave data source procedure Set_Slave (Controller : in out Replicated_DataSource; Slave : in Data_Source_Access); -- Get the slace data source function Get_Slave (Controller : in Replicated_DataSource) return Data_Source_Access; -- Get a slave database connection -- function Get_Slave_Connection (Controller : in Replicated_DataSource) -- return Connection'Class; private type Data_Source is new ADO.Connections.Configuration with null record; type Replicated_DataSource is new Data_Source with record Master : Data_Source_Access := null; Slave : Data_Source_Access := null; end record; end ADO.Sessions.Sources;
vpodzime/ada-util
Ada
6,264
adb
----------------------------------------------------------------------- -- util-serialize-tools -- Tools to Serialize objects in various formats -- Copyright (C) 2012, 2016, 2017 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- 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.Containers; with Util.Streams.Texts; with Util.Streams.Buffered; with Util.Serialize.Mappers.Record_Mapper; package body Util.Serialize.Tools is type Object_Field is (FIELD_NAME, FIELD_VALUE); type Object_Map_Access is access all Util.Beans.Objects.Maps.Map'Class; type Object_Mapper_Context is record Map : Object_Map_Access; Name : Util.Beans.Objects.Object; end record; type Object_Mapper_Context_Access is access all Object_Mapper_Context; procedure Set_Member (Into : in out Object_Mapper_Context; Field : in Object_Field; Value : in Util.Beans.Objects.Object); procedure Set_Member (Into : in out Object_Mapper_Context; Field : in Object_Field; Value : in Util.Beans.Objects.Object) is begin case Field is when FIELD_NAME => Into.Name := Value; when FIELD_VALUE => Into.Map.Include (Util.Beans.Objects.To_String (Into.Name), Value); Into.Name := Util.Beans.Objects.Null_Object; end case; end Set_Member; package Object_Mapper is new Util.Serialize.Mappers.Record_Mapper (Element_Type => Object_Mapper_Context, Element_Type_Access => Object_Mapper_Context_Access, Fields => Object_Field, Set_Member => Set_Member); JSON_Mapping : aliased Object_Mapper.Mapper; -- ----------------------- -- Serialize the objects defined in the object map <b>Map</b> into the <b>Output</b> -- JSON stream. Use the <b>Name</b> as the name of the JSON object. -- ----------------------- procedure To_JSON (Output : in out Util.Serialize.IO.JSON.Output_Stream'Class; Name : in String; Map : in Util.Beans.Objects.Maps.Map) is use type Ada.Containers.Count_Type; procedure Write (Name : in String; Value : in Util.Beans.Objects.Object); procedure Write (Name : in String; Value : in Util.Beans.Objects.Object) is begin Output.Start_Entity (Name => ""); Output.Write_Attribute (Name => "name", Value => Util.Beans.Objects.To_Object (Name)); Output.Write_Attribute (Name => "value", Value => Value); Output.End_Entity (Name => ""); end Write; begin if Map.Length > 0 then declare Iter : Util.Beans.Objects.Maps.Cursor := Map.First; begin Output.Start_Array (Name => Name); while Util.Beans.Objects.Maps.Has_Element (Iter) loop Util.Beans.Objects.Maps.Query_Element (Iter, Write'Access); Util.Beans.Objects.Maps.Next (Iter); end loop; Output.End_Array (Name => Name); end; end if; end To_JSON; -- ----------------------- -- Serialize the objects defined in the object map <b>Map</b> into an XML stream. -- Returns the JSON string that contains a serialization of the object maps. -- ----------------------- function To_JSON (Map : in Util.Beans.Objects.Maps.Map) return String is use type Ada.Containers.Count_Type; begin if Map.Length = 0 then return ""; end if; declare Buffer : aliased Util.Streams.Texts.Print_Stream; Output : Util.Serialize.IO.JSON.Output_Stream; begin Buffer.Initialize (Size => 10000); Output.Initialize (Buffer'Unchecked_Access); Output.Start_Document; To_JSON (Output, "params", Map); Output.End_Document; return Util.Streams.Texts.To_String (Util.Streams.Buffered.Buffered_Stream (Buffer)); end; end To_JSON; -- ----------------------- -- Deserializes the JSON content passed in <b>Content</b> and restore the object map -- with their values. The object map passed in <b>Map</b> can contain existing values. -- They will be overriden by the JSON values. -- ----------------------- procedure From_JSON (Content : in String; Map : in out Util.Beans.Objects.Maps.Map) is Parser : Util.Serialize.IO.JSON.Parser; Mapper : Util.Serialize.Mappers.Processing; Context : aliased Object_Mapper_Context; begin if Content'Length > 0 then Context.Map := Map'Unchecked_Access; Mapper.Add_Mapping ("**", JSON_Mapping'Access); Object_Mapper.Set_Context (Mapper, Context'Unchecked_Access); Parser.Parse_String (Content, Mapper); end if; end From_JSON; -- ----------------------- -- Deserializes the JSON content passed in <b>Content</b> and restore the object map -- with their values. -- Returns the object map that was restored. -- ----------------------- function From_JSON (Content : in String) return Util.Beans.Objects.Maps.Map is Result : Util.Beans.Objects.Maps.Map; begin From_JSON (Content, Result); return Result; end From_JSON; begin JSON_Mapping.Add_Mapping ("name", FIELD_NAME); JSON_Mapping.Add_Mapping ("value", FIELD_VALUE); end Util.Serialize.Tools;
zhmu/ananas
Ada
61,105
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . T E X T _ I O -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2022, 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. -- -- -- ------------------------------------------------------------------------------ with Ada.Streams; use Ada.Streams; with Interfaces.C_Streams; use Interfaces.C_Streams; with System.File_IO; with System.CRTL; with System.WCh_Cnv; use System.WCh_Cnv; with System.WCh_Con; use System.WCh_Con; with Ada.Unchecked_Conversion; with Ada.Unchecked_Deallocation; pragma Elaborate_All (System.File_IO); -- Needed because of calls to Chain_File in package body elaboration package body Ada.Text_IO with SPARK_Mode => Off, Refined_State => (File_System => (Standard_In, Standard_Out, Standard_Err, Current_In, Current_Out, Current_Err, In_Name, Out_Name, Err_Name, WC_Encoding)) is package FIO renames System.File_IO; subtype AP is FCB.AFCB_Ptr; function To_FCB is new Ada.Unchecked_Conversion (File_Mode, FCB.File_Mode); function To_TIO is new Ada.Unchecked_Conversion (FCB.File_Mode, File_Mode); use type FCB.File_Mode; use type System.CRTL.size_t; WC_Encoding : constant Character; pragma Import (C, WC_Encoding, "__gl_wc_encoding"); -- Default wide character encoding Err_Name : aliased String := "*stderr" & ASCII.NUL; In_Name : aliased String := "*stdin" & ASCII.NUL; Out_Name : aliased String := "*stdout" & ASCII.NUL; -- Names of standard files -- -- Use "preallocated" strings to avoid calling "new" during the elaboration -- of the run time. This is needed in the tasking case to avoid calling -- Task_Lock too early. A filename is expected to end with a null character -- in the runtime, here the null characters are added just to have a -- correct filename length. -- -- Note: the names for these files are bogus, and probably it would be -- better for these files to have no names, but the ACVC tests insist. -- We use names that are bound to fail in open etc. Null_Str : aliased constant String := ""; -- Used as form string for standard files ----------------------- -- Local Subprograms -- ----------------------- function Get_Upper_Half_Char (C : Character; File : File_Type) return Character; -- This function is shared by Get and Get_Immediate to extract an encoded -- upper half character value from the given File. The first byte has -- already been read and is passed in C. The character value is returned as -- the result, and the file pointer is bumped past the character. -- Constraint_Error is raised if the encoded value is outside the bounds of -- type Character. function Get_Upper_Half_Char_Immed (C : Character; File : File_Type) return Character; -- This routine is identical to Get_Upper_Half_Char, except that the reads -- are done in Get_Immediate mode (i.e. without waiting for a line return). function Getc (File : File_Type) return int; -- Gets next character from file, which has already been checked for being -- in read status, and returns the character read if no error occurs. The -- result is EOF if the end of file was read. function Getc_Immed (File : File_Type) return int; -- This routine is identical to Getc, except that the read is done in -- Get_Immediate mode (i.e. without waiting for a line return). function Has_Upper_Half_Character (Item : String) return Boolean; -- Returns True if any of the characters is in the range 16#80#-16#FF# function Nextc (File : File_Type) return int; -- Returns next character from file without skipping past it (i.e. it is a -- combination of Getc followed by an Ungetc). procedure Put_Encoded (File : File_Type; Char : Character); -- Called to output a character Char to the given File, when the encoding -- method for the file is other than brackets, and Char is upper half. procedure Putc (ch : int; File : File_Type); -- Outputs the given character to the file, which has already been checked -- for being in output status. Device_Error is raised if the character -- cannot be written. procedure Set_WCEM (File : in out File_Type); -- Called by Open and Create to set the wide character encoding method for -- the file, processing a WCEM form parameter if one is present. File is -- IN OUT because it may be closed in case of an error. procedure Terminate_Line (File : File_Type); -- If the file is in Write_File or Append_File mode, and the current line -- is not terminated, then a line terminator is written using New_Line. -- Note that there is no Terminate_Page routine, because the page mark at -- the end of the file is implied if necessary. procedure Ungetc (ch : int; File : File_Type); -- Pushes back character into stream, using ungetc. The caller has checked -- that the file is in read status. Device_Error is raised if the character -- cannot be pushed back. An attempt to push back and end of file character -- (EOF) is ignored. ------------------- -- AFCB_Allocate -- ------------------- function AFCB_Allocate (Control_Block : Text_AFCB) return FCB.AFCB_Ptr is pragma Unreferenced (Control_Block); begin return new Text_AFCB; end AFCB_Allocate; ---------------- -- AFCB_Close -- ---------------- procedure AFCB_Close (File : not null access Text_AFCB) is begin -- If the file being closed is one of the current files, then close -- the corresponding current file. It is not clear that this action -- is required (RM A.10.3(23)) but it seems reasonable, and besides -- ACVC test CE3208A expects this behavior. if File = Current_In then Current_In := null; elsif File = Current_Out then Current_Out := null; elsif File = Current_Err then Current_Err := null; end if; Terminate_Line (File.all'Access); end AFCB_Close; --------------- -- AFCB_Free -- --------------- procedure AFCB_Free (File : not null access Text_AFCB) is FT : File_Type := File.all'Access; procedure Free is new Ada.Unchecked_Deallocation (Text_AFCB, File_Type); begin Free (FT); end AFCB_Free; ----------- -- Close -- ----------- procedure Close (File : in out File_Type) is begin FIO.Close (AP (File)'Unrestricted_Access); end Close; --------- -- Col -- --------- -- Note: we assume that it is impossible in practice for the column -- to exceed the value of Count'Last, i.e. no check is required for -- overflow raising layout error. function Col (File : File_Type) return Positive_Count is begin FIO.Check_File_Open (AP (File)); return File.Col; end Col; function Col return Positive_Count is begin return Col (Current_Out); end Col; ------------ -- Create -- ------------ procedure Create (File : in out File_Type; Mode : File_Mode := Out_File; Name : String := ""; Form : String := "") is Dummy_File_Control_Block : Text_AFCB; pragma Warnings (Off, Dummy_File_Control_Block); -- Yes, we know this is never assigned a value, only the tag -- is used for dispatching purposes, so that's expected. begin FIO.Open (File_Ptr => AP (File), Dummy_FCB => Dummy_File_Control_Block, Mode => To_FCB (Mode), Name => Name, Form => Form, Amethod => 'T', Creat => True, Text => True); File.Self := File; Set_WCEM (File); end Create; ------------------- -- Current_Error -- ------------------- function Current_Error return File_Type is begin return Current_Err; end Current_Error; function Current_Error return File_Access is begin return Current_Err.Self'Access; end Current_Error; ------------------- -- Current_Input -- ------------------- function Current_Input return File_Type is begin return Current_In; end Current_Input; function Current_Input return File_Access is begin return Current_In.Self'Access; end Current_Input; -------------------- -- Current_Output -- -------------------- function Current_Output return File_Type is begin return Current_Out; end Current_Output; function Current_Output return File_Access is begin return Current_Out.Self'Access; end Current_Output; ------------ -- Delete -- ------------ procedure Delete (File : in out File_Type) is begin FIO.Delete (AP (File)'Unrestricted_Access); end Delete; ----------------- -- End_Of_File -- ----------------- function End_Of_File (File : File_Type) return Boolean is ch : int; begin FIO.Check_Read_Status (AP (File)); if File.Before_Upper_Half_Character then return False; elsif File.Before_LM then if File.Before_LM_PM then return Nextc (File) = EOF; end if; else ch := Getc (File); if ch = EOF then return True; elsif ch /= LM then Ungetc (ch, File); return False; else -- ch = LM File.Before_LM := True; end if; end if; -- Here we are just past the line mark with Before_LM set so that we -- do not have to try to back up past the LM, thus avoiding the need -- to back up more than one character. ch := Getc (File); if ch = EOF then return True; elsif ch = PM and then File.Is_Regular_File then File.Before_LM_PM := True; return Nextc (File) = EOF; -- Here if neither EOF nor PM followed end of line else Ungetc (ch, File); return False; end if; end End_Of_File; function End_Of_File return Boolean is begin return End_Of_File (Current_In); end End_Of_File; ----------------- -- End_Of_Line -- ----------------- function End_Of_Line (File : File_Type) return Boolean is ch : int; begin FIO.Check_Read_Status (AP (File)); if File.Before_Upper_Half_Character then return False; elsif File.Before_LM then return True; else ch := Getc (File); if ch = EOF then return True; else Ungetc (ch, File); return (ch = LM); end if; end if; end End_Of_Line; function End_Of_Line return Boolean is begin return End_Of_Line (Current_In); end End_Of_Line; ----------------- -- End_Of_Page -- ----------------- function End_Of_Page (File : File_Type) return Boolean is ch : int; begin FIO.Check_Read_Status (AP (File)); if not File.Is_Regular_File then return False; elsif File.Before_Upper_Half_Character then return False; elsif File.Before_LM then if File.Before_LM_PM then return True; end if; else ch := Getc (File); if ch = EOF then return True; elsif ch /= LM then Ungetc (ch, File); return False; else -- ch = LM File.Before_LM := True; end if; end if; -- Here we are just past the line mark with Before_LM set so that we -- do not have to try to back up past the LM, thus avoiding the need -- to back up more than one character. ch := Nextc (File); return ch = PM or else ch = EOF; end End_Of_Page; function End_Of_Page return Boolean is begin return End_Of_Page (Current_In); end End_Of_Page; -------------- -- EOF_Char -- -------------- function EOF_Char return Integer is begin return EOF; end EOF_Char; ----------- -- Flush -- ----------- procedure Flush (File : File_Type) is begin FIO.Flush (AP (File)); end Flush; procedure Flush is begin Flush (Current_Out); end Flush; ---------- -- Form -- ---------- function Form (File : File_Type) return String is begin return FIO.Form (AP (File)); end Form; --------- -- Get -- --------- procedure Get (File : File_Type; Item : out Character) is ch : int; begin FIO.Check_Read_Status (AP (File)); if File.Before_Upper_Half_Character then File.Before_Upper_Half_Character := False; Item := File.Saved_Upper_Half_Character; elsif File.Before_LM then File.Before_LM := False; File.Col := 1; if File.Before_LM_PM then File.Line := 1; File.Page := File.Page + 1; File.Before_LM_PM := False; else File.Line := File.Line + 1; end if; end if; loop ch := Getc (File); if ch = EOF then raise End_Error; elsif ch = LM then File.Line := File.Line + 1; File.Col := 1; elsif ch = PM and then File.Is_Regular_File then File.Page := File.Page + 1; File.Line := 1; else Item := Character'Val (ch); File.Col := File.Col + 1; return; end if; end loop; end Get; procedure Get (Item : out Character) is begin Get (Current_In, Item); end Get; procedure Get (File : File_Type; Item : out String) is ch : int; J : Natural; begin FIO.Check_Read_Status (AP (File)); if File.Before_LM then File.Before_LM := False; File.Before_LM_PM := False; File.Col := 1; if File.Before_LM_PM then File.Line := 1; File.Page := File.Page + 1; File.Before_LM_PM := False; else File.Line := File.Line + 1; end if; end if; J := Item'First; while J <= Item'Last loop ch := Getc (File); if ch = EOF then raise End_Error; elsif ch = LM then File.Line := File.Line + 1; File.Col := 1; elsif ch = PM and then File.Is_Regular_File then File.Page := File.Page + 1; File.Line := 1; else Item (J) := Character'Val (ch); J := J + 1; File.Col := File.Col + 1; end if; end loop; end Get; procedure Get (Item : out String) is begin Get (Current_In, Item); end Get; ------------------- -- Get_Immediate -- ------------------- procedure Get_Immediate (File : File_Type; Item : out Character) is ch : int; begin FIO.Check_Read_Status (AP (File)); if File.Before_Upper_Half_Character then File.Before_Upper_Half_Character := False; Item := File.Saved_Upper_Half_Character; elsif File.Before_LM then File.Before_LM := False; File.Before_LM_PM := False; Item := Character'Val (LM); else ch := Getc_Immed (File); if ch = EOF then raise End_Error; else Item := (if not Is_Start_Of_Encoding (Character'Val (ch), File.WC_Method) then Character'Val (ch) else Get_Upper_Half_Char_Immed (Character'Val (ch), File)); end if; end if; end Get_Immediate; procedure Get_Immediate (Item : out Character) is begin Get_Immediate (Current_In, Item); end Get_Immediate; procedure Get_Immediate (File : File_Type; Item : out Character; Available : out Boolean) is ch : int; end_of_file : int; avail : int; procedure getc_immediate_nowait (stream : FILEs; ch : out int; end_of_file : out int; avail : out int); pragma Import (C, getc_immediate_nowait, "getc_immediate_nowait"); begin FIO.Check_Read_Status (AP (File)); Available := True; if File.Before_Upper_Half_Character then File.Before_Upper_Half_Character := False; Item := File.Saved_Upper_Half_Character; elsif File.Before_LM then File.Before_LM := False; File.Before_LM_PM := False; Item := Character'Val (LM); else getc_immediate_nowait (File.Stream, ch, end_of_file, avail); if ferror (File.Stream) /= 0 then raise Device_Error; elsif end_of_file /= 0 then raise End_Error; elsif avail = 0 then Available := False; Item := ASCII.NUL; else Available := True; Item := (if not Is_Start_Of_Encoding (Character'Val (ch), File.WC_Method) then Character'Val (ch) else Get_Upper_Half_Char_Immed (Character'Val (ch), File)); end if; end if; end Get_Immediate; procedure Get_Immediate (Item : out Character; Available : out Boolean) is begin Get_Immediate (Current_In, Item, Available); end Get_Immediate; -------------- -- Get_Line -- -------------- procedure Get_Line (File : File_Type; Item : out String; Last : out Natural) is separate; -- The implementation of Ada.Text_IO.Get_Line is split into a subunit so -- that different implementations can be used on different systems. procedure Get_Line (Item : out String; Last : out Natural) is begin Get_Line (Current_In, Item, Last); end Get_Line; function Get_Line (File : File_Type) return String is function Get_Rest (S : String) return String; -- This is a recursive function that reads the rest of the line and -- returns it. S is the part read so far. -------------- -- Get_Rest -- -------------- function Get_Rest (S : String) return String is -- The first time we allocate a buffer of size 500. Each following -- time we allocate a buffer the same size as what we have read so -- far. This limits us to a logarithmic number of calls to Get_Rest -- and also ensures only a linear use of stack space. Buffer : String (1 .. Integer'Max (500, S'Length)); Last : Natural; begin Get_Line (File, Buffer, Last); declare R : constant String := S & Buffer (1 .. Last); begin if Last < Buffer'Last then return R; else pragma Assert (Last = Buffer'Last); -- If the String has the same length as the buffer, and there -- is no end of line, check whether we are at the end of file, -- in which case we have the full String in the buffer. if End_Of_File (File) then return R; else return Get_Rest (R); end if; end if; end; end Get_Rest; -- Start of processing for Get_Line begin return Get_Rest (""); end Get_Line; function Get_Line return String is begin return Get_Line (Current_In); end Get_Line; ------------------------- -- Get_Upper_Half_Char -- ------------------------- function Get_Upper_Half_Char (C : Character; File : File_Type) return Character is Result : Wide_Character; function In_Char return Character; -- Function used to obtain additional characters it the wide character -- sequence is more than one character long. function WC_In is new Char_Sequence_To_Wide_Char (In_Char); ------------- -- In_Char -- ------------- function In_Char return Character is ch : constant Integer := Getc (File); begin if ch = EOF then raise End_Error; else return Character'Val (ch); end if; end In_Char; -- Start of processing for Get_Upper_Half_Char begin Result := WC_In (C, File.WC_Method); if Wide_Character'Pos (Result) > 16#FF# then raise Constraint_Error with "invalid wide character in Text_'I'O input"; else return Character'Val (Wide_Character'Pos (Result)); end if; end Get_Upper_Half_Char; ------------------------------- -- Get_Upper_Half_Char_Immed -- ------------------------------- function Get_Upper_Half_Char_Immed (C : Character; File : File_Type) return Character is Result : Wide_Character; function In_Char return Character; -- Function used to obtain additional characters it the wide character -- sequence is more than one character long. function WC_In is new Char_Sequence_To_Wide_Char (In_Char); ------------- -- In_Char -- ------------- function In_Char return Character is ch : constant Integer := Getc_Immed (File); begin if ch = EOF then raise End_Error; else return Character'Val (ch); end if; end In_Char; -- Start of processing for Get_Upper_Half_Char_Immed begin Result := WC_In (C, File.WC_Method); if Wide_Character'Pos (Result) > 16#FF# then raise Constraint_Error with "invalid wide character in Text_'I'O input"; else return Character'Val (Wide_Character'Pos (Result)); end if; end Get_Upper_Half_Char_Immed; ---------- -- Getc -- ---------- function Getc (File : File_Type) return int is ch : int; begin ch := fgetc (File.Stream); if ch = EOF and then ferror (File.Stream) /= 0 then raise Device_Error; else return ch; end if; end Getc; ---------------- -- Getc_Immed -- ---------------- function Getc_Immed (File : File_Type) return int is ch : int; end_of_file : int; procedure getc_immediate (stream : FILEs; ch : out int; end_of_file : out int); pragma Import (C, getc_immediate, "getc_immediate"); begin FIO.Check_Read_Status (AP (File)); if File.Before_LM then File.Before_LM := False; File.Before_LM_PM := False; ch := LM; else getc_immediate (File.Stream, ch, end_of_file); if ferror (File.Stream) /= 0 then raise Device_Error; elsif end_of_file /= 0 then return EOF; end if; end if; return ch; end Getc_Immed; ------------------------------ -- Has_Upper_Half_Character -- ------------------------------ function Has_Upper_Half_Character (Item : String) return Boolean is begin for J in Item'Range loop if Character'Pos (Item (J)) >= 16#80# then return True; end if; end loop; return False; end Has_Upper_Half_Character; ------------------------------- -- Initialize_Standard_Files -- ------------------------------- procedure Initialize_Standard_Files is begin Standard_Err.Stream := stderr; Standard_Err.Name := Err_Name'Access; Standard_Err.Form := Null_Str'Unrestricted_Access; Standard_Err.Mode := FCB.Out_File; Standard_Err.Is_Regular_File := is_regular_file (fileno (stderr)) /= 0; Standard_Err.Is_Temporary_File := False; Standard_Err.Is_System_File := True; Standard_Err.Text_Encoding := Default_Text; Standard_Err.Access_Method := 'T'; Standard_Err.Self := Standard_Err; Standard_Err.WC_Method := Default_WCEM; Standard_In.Stream := stdin; Standard_In.Name := In_Name'Access; Standard_In.Form := Null_Str'Unrestricted_Access; Standard_In.Mode := FCB.In_File; Standard_In.Is_Regular_File := is_regular_file (fileno (stdin)) /= 0; Standard_In.Is_Temporary_File := False; Standard_In.Is_System_File := True; Standard_In.Text_Encoding := Default_Text; Standard_In.Access_Method := 'T'; Standard_In.Self := Standard_In; Standard_In.WC_Method := Default_WCEM; Standard_Out.Stream := stdout; Standard_Out.Name := Out_Name'Access; Standard_Out.Form := Null_Str'Unrestricted_Access; Standard_Out.Mode := FCB.Out_File; Standard_Out.Is_Regular_File := is_regular_file (fileno (stdout)) /= 0; Standard_Out.Is_Temporary_File := False; Standard_Out.Is_System_File := True; Standard_Out.Text_Encoding := Default_Text; Standard_Out.Access_Method := 'T'; Standard_Out.Self := Standard_Out; Standard_Out.WC_Method := Default_WCEM; FIO.Make_Unbuffered (AP (Standard_Out)); FIO.Make_Unbuffered (AP (Standard_Err)); end Initialize_Standard_Files; ------------- -- Is_Open -- ------------- function Is_Open (File : File_Type) return Boolean is begin return FIO.Is_Open (AP (File)); end Is_Open; ---------- -- Line -- ---------- -- Note: we assume that it is impossible in practice for the line -- to exceed the value of Count'Last, i.e. no check is required for -- overflow raising layout error. function Line (File : File_Type) return Positive_Count is begin FIO.Check_File_Open (AP (File)); return File.Line; end Line; function Line return Positive_Count is begin return Line (Current_Out); end Line; ----------------- -- Line_Length -- ----------------- function Line_Length (File : File_Type) return Count is begin FIO.Check_Write_Status (AP (File)); return File.Line_Length; end Line_Length; function Line_Length return Count is begin return Line_Length (Current_Out); end Line_Length; ---------------- -- Look_Ahead -- ---------------- procedure Look_Ahead (File : File_Type; Item : out Character; End_Of_Line : out Boolean) is ch : int; begin FIO.Check_Read_Status (AP (File)); -- If we are logically before a line mark, we can return immediately if File.Before_LM then End_Of_Line := True; Item := ASCII.NUL; -- If we are before an upper half character just return it (this can -- happen if there are two calls to Look_Ahead in a row). elsif File.Before_Upper_Half_Character then End_Of_Line := False; Item := File.Saved_Upper_Half_Character; -- Otherwise we must read a character from the input stream else ch := Getc (File); if ch = LM or else ch = EOF or else (ch = PM and then File.Is_Regular_File) then End_Of_Line := True; Ungetc (ch, File); Item := ASCII.NUL; -- Case where character obtained does not represent the start of an -- encoded sequence so it stands for itself and we can unget it with -- no difficulty. elsif not Is_Start_Of_Encoding (Character'Val (ch), File.WC_Method) then End_Of_Line := False; Ungetc (ch, File); Item := Character'Val (ch); -- For the start of an encoding, we read the character using the -- Get_Upper_Half_Char routine. It will occupy more than one byte -- so we can't put it back with ungetc. Instead we save it in the -- control block, setting a flag that everyone interested in reading -- characters must test before reading the stream. else Item := Get_Upper_Half_Char (Character'Val (ch), File); End_Of_Line := False; File.Saved_Upper_Half_Character := Item; File.Before_Upper_Half_Character := True; end if; end if; end Look_Ahead; procedure Look_Ahead (Item : out Character; End_Of_Line : out Boolean) is begin Look_Ahead (Current_In, Item, End_Of_Line); end Look_Ahead; ---------- -- Mode -- ---------- function Mode (File : File_Type) return File_Mode is begin return To_TIO (FIO.Mode (AP (File))); end Mode; ---------- -- Name -- ---------- function Name (File : File_Type) return String is begin return FIO.Name (AP (File)); end Name; -------------- -- New_Line -- -------------- procedure New_Line (File : File_Type; Spacing : Positive_Count := 1) is begin -- Raise Constraint_Error if out of range value. The reason for this -- explicit test is that we don't want junk values around, even if -- checks are off in the caller. if not Spacing'Valid then raise Constraint_Error; end if; FIO.Check_Write_Status (AP (File)); for K in 1 .. Spacing loop Putc (LM, File); File.Line := File.Line + 1; if File.Page_Length /= 0 and then File.Line > File.Page_Length then Putc (PM, File); File.Line := 1; File.Page := File.Page + 1; end if; end loop; File.Col := 1; end New_Line; procedure New_Line (Spacing : Positive_Count := 1) is begin New_Line (Current_Out, Spacing); end New_Line; -------------- -- New_Page -- -------------- procedure New_Page (File : File_Type) is begin FIO.Check_Write_Status (AP (File)); if File.Col /= 1 or else File.Line = 1 then Putc (LM, File); end if; Putc (PM, File); File.Page := File.Page + 1; File.Line := 1; File.Col := 1; end New_Page; procedure New_Page is begin New_Page (Current_Out); end New_Page; ----------- -- Nextc -- ----------- function Nextc (File : File_Type) return int is ch : int; begin ch := fgetc (File.Stream); if ch = EOF then if ferror (File.Stream) /= 0 then raise Device_Error; end if; else if ungetc (ch, File.Stream) = EOF then raise Device_Error; end if; end if; return ch; end Nextc; ---------- -- Open -- ---------- procedure Open (File : in out File_Type; Mode : File_Mode; Name : String; Form : String := "") is Dummy_File_Control_Block : Text_AFCB; pragma Warnings (Off, Dummy_File_Control_Block); -- Yes, we know this is never assigned a value, only the tag -- is used for dispatching purposes, so that's expected. begin FIO.Open (File_Ptr => AP (File), Dummy_FCB => Dummy_File_Control_Block, Mode => To_FCB (Mode), Name => Name, Form => Form, Amethod => 'T', Creat => False, Text => True); File.Self := File; Set_WCEM (File); end Open; ---------- -- Page -- ---------- -- Note: we assume that it is impossible in practice for the page -- to exceed the value of Count'Last, i.e. no check is required for -- overflow raising layout error. function Page (File : File_Type) return Positive_Count is begin FIO.Check_File_Open (AP (File)); return File.Page; end Page; function Page return Positive_Count is begin return Page (Current_Out); end Page; ----------------- -- Page_Length -- ----------------- function Page_Length (File : File_Type) return Count is begin FIO.Check_Write_Status (AP (File)); return File.Page_Length; end Page_Length; function Page_Length return Count is begin return Page_Length (Current_Out); end Page_Length; --------- -- Put -- --------- procedure Put (File : File_Type; Item : Character) is begin FIO.Check_Write_Status (AP (File)); if File.Line_Length /= 0 and then File.Col > File.Line_Length then New_Line (File); end if; -- If lower half character, or brackets encoding, output directly if Character'Pos (Item) < 16#80# or else File.WC_Method = WCEM_Brackets then if fputc (Character'Pos (Item), File.Stream) = EOF then raise Device_Error; end if; -- Case of upper half character with non-brackets encoding else Put_Encoded (File, Item); end if; File.Col := File.Col + 1; end Put; procedure Put (Item : Character) is begin Put (Current_Out, Item); end Put; --------- -- Put -- --------- procedure Put (File : File_Type; Item : String) is begin FIO.Check_Write_Status (AP (File)); -- Only have something to do if string is non-null if Item'Length > 0 then -- If we have bounded lines, or if the file encoding is other than -- Brackets and the string has at least one upper half character, -- then output the string character by character. if File.Line_Length /= 0 or else (File.WC_Method /= WCEM_Brackets and then Has_Upper_Half_Character (Item)) then for J in Item'Range loop Put (File, Item (J)); end loop; -- Otherwise we can output the entire string at once. Note that if -- there are LF or FF characters in the string, we do not bother to -- count them as line or page terminators. else FIO.Write_Buf (AP (File), Item'Address, Item'Length); File.Col := File.Col + Item'Length; end if; end if; end Put; procedure Put (Item : String) is begin Put (Current_Out, Item); end Put; ----------------- -- Put_Encoded -- ----------------- procedure Put_Encoded (File : File_Type; Char : Character) is procedure Out_Char (C : Character); -- Procedure to output one character of an upper half encoded sequence procedure WC_Out is new Wide_Char_To_Char_Sequence (Out_Char); -------------- -- Out_Char -- -------------- procedure Out_Char (C : Character) is begin Putc (Character'Pos (C), File); end Out_Char; -- Start of processing for Put_Encoded begin WC_Out (Wide_Character'Val (Character'Pos (Char)), File.WC_Method); end Put_Encoded; -------------- -- Put_Line -- -------------- procedure Put_Line (File : File_Type; Item : String) is Ilen : Natural := Item'Length; Istart : Natural := Item'First; begin FIO.Check_Write_Status (AP (File)); -- If we have bounded lines, or if the file encoding is other than -- Brackets and the string has at least one upper half character, then -- output the string character by character. if File.Line_Length /= 0 or else (File.WC_Method /= WCEM_Brackets and then Has_Upper_Half_Character (Item)) then for J in Item'Range loop Put (File, Item (J)); end loop; New_Line (File); return; end if; -- Normal case where we do not need to output character by character -- We setup a single string that has the necessary terminators and -- then write it with a single call. The reason for doing this is -- that it gives better behavior for the use of Put_Line in multi- -- tasking programs, since often the OS will treat the entire put -- operation as an atomic operation. -- We only do this if the message is 512 characters or less in length, -- since otherwise Put_Line would use an unbounded amount of stack -- space and could cause undetected stack overflow. If we have a -- longer string, then output the first part separately to avoid this. if Ilen > 512 then FIO.Write_Buf (AP (File), Item'Address, size_t (Ilen - 512)); Istart := Istart + Ilen - 512; Ilen := 512; end if; -- Now prepare the string with its terminator declare Buffer : String (1 .. Ilen + 2); Plen : size_t; begin Buffer (1 .. Ilen) := Item (Istart .. Item'Last); Buffer (Ilen + 1) := Character'Val (LM); if File.Page_Length /= 0 and then File.Line > File.Page_Length then Buffer (Ilen + 2) := Character'Val (PM); Plen := size_t (Ilen) + 2; File.Line := 1; File.Page := File.Page + 1; else Plen := size_t (Ilen) + 1; File.Line := File.Line + 1; end if; FIO.Write_Buf (AP (File), Buffer'Address, Plen); File.Col := 1; end; end Put_Line; procedure Put_Line (Item : String) is begin Put_Line (Current_Out, Item); end Put_Line; ---------- -- Putc -- ---------- procedure Putc (ch : int; File : File_Type) is begin if fputc (ch, File.Stream) = EOF then raise Device_Error; end if; end Putc; ---------- -- Read -- ---------- -- This is the primitive Stream Read routine, used when a Text_IO file -- is treated directly as a stream using Text_IO.Streams.Stream. procedure Read (File : in out Text_AFCB; Item : out Stream_Element_Array; Last : out Stream_Element_Offset) is Discard_ch : int; pragma Warnings (Off, Discard_ch); begin -- Need to deal with Before_Upper_Half_Character ??? if File.Mode /= FCB.In_File then raise Mode_Error; end if; -- Deal with case where our logical and physical position do not match -- because of being after an LM or LM-PM sequence when in fact we are -- logically positioned before it. if File.Before_LM then -- If we are before a PM, then it is possible for a stream read -- to leave us after the LM and before the PM, which is a bit -- odd. The easiest way to deal with this is to unget the PM, -- so we are indeed positioned between the characters. This way -- further stream read operations will work correctly, and the -- effect on text processing is a little weird, but what can -- be expected if stream and text input are mixed this way? if File.Before_LM_PM then Discard_ch := ungetc (PM, File.Stream); File.Before_LM_PM := False; end if; File.Before_LM := False; Item (Item'First) := Stream_Element (Character'Pos (ASCII.LF)); if Item'Length = 1 then Last := Item'Last; else Last := Item'First + Stream_Element_Offset (fread (buffer => Item'Address, index => size_t (Item'First + 1), size => 1, count => Item'Length - 1, stream => File.Stream)); end if; return; end if; -- Now we do the read. Since this is a text file, it is normally in -- text mode, but stream data must be read in binary mode, so we -- temporarily set binary mode for the read, resetting it after. -- These calls have no effect in a system (like Unix) where there is -- no distinction between text and binary files. set_binary_mode (fileno (File.Stream)); Last := Item'First + Stream_Element_Offset (fread (Item'Address, 1, Item'Length, File.Stream)) - 1; if Last < Item'Last then if ferror (File.Stream) /= 0 then raise Device_Error; end if; end if; set_text_mode (fileno (File.Stream)); end Read; ----------- -- Reset -- ----------- procedure Reset (File : in out File_Type; Mode : File_Mode) is begin -- Don't allow change of mode for current file (RM A.10.2(5)) if (File = Current_In or else File = Current_Out or else File = Current_Error) and then To_FCB (Mode) /= File.Mode then raise Mode_Error; end if; Terminate_Line (File); FIO.Reset (AP (File)'Unrestricted_Access, To_FCB (Mode)); File.Page := 1; File.Line := 1; File.Col := 1; File.Line_Length := 0; File.Page_Length := 0; File.Before_LM := False; File.Before_LM_PM := False; end Reset; procedure Reset (File : in out File_Type) is begin Terminate_Line (File); FIO.Reset (AP (File)'Unrestricted_Access); File.Page := 1; File.Line := 1; File.Col := 1; File.Line_Length := 0; File.Page_Length := 0; File.Before_LM := False; File.Before_LM_PM := False; end Reset; ------------- -- Set_Col -- ------------- procedure Set_Col (File : File_Type; To : Positive_Count) is ch : int; begin -- Raise Constraint_Error if out of range value. The reason for this -- explicit test is that we don't want junk values around, even if -- checks are off in the caller. if not To'Valid then raise Constraint_Error; end if; FIO.Check_File_Open (AP (File)); -- Output case if Mode (File) >= Out_File then -- Error if we attempt to set Col to a value greater than the -- maximum permissible line length. if File.Line_Length /= 0 and then To > File.Line_Length then raise Layout_Error; end if; -- If we are behind current position, then go to start of new line if To < File.Col then New_Line (File); end if; -- Loop to output blanks till we are at the required column while File.Col < To loop Put (File, ' '); end loop; -- Input case else -- If we are logically before a LM, but physically after it, the -- file position still reflects the position before the LM, so eat -- it now and adjust the file position appropriately. if File.Before_LM then File.Before_LM := False; File.Before_LM_PM := False; File.Line := File.Line + 1; File.Col := 1; end if; -- Loop reading characters till we get one at the required Col value loop -- Read next character. The reason we have to read ahead is to -- skip formatting characters, the effect of Set_Col is to set -- us to a real character with the right Col value, and format -- characters don't count. ch := Getc (File); -- Error if we hit an end of file if ch = EOF then raise End_Error; -- If line mark, eat it and adjust file position elsif ch = LM then File.Line := File.Line + 1; File.Col := 1; -- If recognized page mark, eat it, and adjust file position elsif ch = PM and then File.Is_Regular_File then File.Page := File.Page + 1; File.Line := 1; File.Col := 1; -- Otherwise this is the character we are looking for, so put it -- back in the input stream (we have not adjusted the file -- position yet, so everything is set right after this ungetc). elsif To = File.Col then Ungetc (ch, File); return; -- Keep skipping characters if we are not there yet, updating the -- file position past the skipped character. else File.Col := File.Col + 1; end if; end loop; end if; end Set_Col; procedure Set_Col (To : Positive_Count) is begin Set_Col (Current_Out, To); end Set_Col; --------------- -- Set_Error -- --------------- procedure Set_Error (File : File_Type) is begin FIO.Check_Write_Status (AP (File)); Current_Err := File; end Set_Error; --------------- -- Set_Input -- --------------- procedure Set_Input (File : File_Type) is begin FIO.Check_Read_Status (AP (File)); Current_In := File; end Set_Input; -------------- -- Set_Line -- -------------- procedure Set_Line (File : File_Type; To : Positive_Count) is begin -- Raise Constraint_Error if out of range value. The reason for this -- explicit test is that we don't want junk values around, even if -- checks are off in the caller. if not To'Valid then raise Constraint_Error; end if; FIO.Check_File_Open (AP (File)); if To = File.Line then return; end if; if Mode (File) >= Out_File then if File.Page_Length /= 0 and then To > File.Page_Length then raise Layout_Error; end if; if To < File.Line then New_Page (File); end if; while File.Line < To loop New_Line (File); end loop; else while To /= File.Line loop Skip_Line (File); end loop; end if; end Set_Line; procedure Set_Line (To : Positive_Count) is begin Set_Line (Current_Out, To); end Set_Line; --------------------- -- Set_Line_Length -- --------------------- procedure Set_Line_Length (File : File_Type; To : Count) is begin -- Raise Constraint_Error if out of range value. The reason for this -- explicit test is that we don't want junk values around, even if -- checks are off in the caller. if not To'Valid then raise Constraint_Error; end if; FIO.Check_Write_Status (AP (File)); File.Line_Length := To; end Set_Line_Length; procedure Set_Line_Length (To : Count) is begin Set_Line_Length (Current_Out, To); end Set_Line_Length; ---------------- -- Set_Output -- ---------------- procedure Set_Output (File : File_Type) is begin FIO.Check_Write_Status (AP (File)); Current_Out := File; end Set_Output; --------------------- -- Set_Page_Length -- --------------------- procedure Set_Page_Length (File : File_Type; To : Count) is begin -- Raise Constraint_Error if out of range value. The reason for this -- explicit test is that we don't want junk values around, even if -- checks are off in the caller. if not To'Valid then raise Constraint_Error; end if; FIO.Check_Write_Status (AP (File)); File.Page_Length := To; end Set_Page_Length; procedure Set_Page_Length (To : Count) is begin Set_Page_Length (Current_Out, To); end Set_Page_Length; -------------- -- Set_WCEM -- -------------- procedure Set_WCEM (File : in out File_Type) is Start : Natural; Stop : Natural; begin FIO.Form_Parameter (File.Form.all, "wcem", Start, Stop); if Start = 0 then File.WC_Method := Default_WCEM; else if Stop = Start then for J in WC_Encoding_Letters'Range loop if File.Form (Start) = WC_Encoding_Letters (J) then File.WC_Method := J; return; end if; end loop; end if; Close (File); raise Use_Error with "invalid WCEM form parameter"; end if; end Set_WCEM; --------------- -- Skip_Line -- --------------- procedure Skip_Line (File : File_Type; Spacing : Positive_Count := 1) is ch : int; begin -- Raise Constraint_Error if out of range value. The reason for this -- explicit test is that we don't want junk values around, even if -- checks are off in the caller. if not Spacing'Valid then raise Constraint_Error; end if; FIO.Check_Read_Status (AP (File)); for L in 1 .. Spacing loop if File.Before_LM then File.Before_LM := False; -- Note that if File.Before_LM_PM is currently set, we also have -- to reset it (because it makes sense for Before_LM_PM to be set -- only when Before_LM is also set). This is done later on in this -- subprogram, as soon as Before_LM_PM has been taken into account -- for the purpose of page and line counts. else ch := Getc (File); -- If at end of file now, then immediately raise End_Error. Note -- that we can never be positioned between a line mark and a page -- mark, so if we are at the end of file, we cannot logically be -- before the implicit page mark that is at the end of the file. -- For the same reason, we do not need an explicit check for a -- page mark. If there is a FF in the middle of a line, the file -- is not in canonical format and we do not care about the page -- numbers for files other than ones in canonical format. if ch = EOF then raise End_Error; end if; -- If not at end of file, then loop till we get to an LM or EOF. -- The latter case happens only in non-canonical files where the -- last line is not terminated by LM, but we don't want to blow -- up for such files, so we assume an implicit LM in this case. loop exit when ch = LM or else ch = EOF; ch := Getc (File); end loop; end if; -- We have got past a line mark, now, for a regular file only, -- see if a page mark immediately follows this line mark and -- if so, skip past the page mark as well. We do not do this -- for non-regular files, since it would cause an undesirable -- wait for an additional character. File.Col := 1; File.Line := File.Line + 1; if File.Before_LM_PM then File.Page := File.Page + 1; File.Line := 1; File.Before_LM_PM := False; elsif File.Is_Regular_File then ch := Getc (File); -- Page mark can be explicit, or implied at the end of the file if (ch = PM or else ch = EOF) and then File.Is_Regular_File then File.Page := File.Page + 1; File.Line := 1; else Ungetc (ch, File); end if; end if; end loop; File.Before_Upper_Half_Character := False; end Skip_Line; procedure Skip_Line (Spacing : Positive_Count := 1) is begin Skip_Line (Current_In, Spacing); end Skip_Line; --------------- -- Skip_Page -- --------------- procedure Skip_Page (File : File_Type) is ch : int; begin FIO.Check_Read_Status (AP (File)); -- If at page mark already, just skip it if File.Before_LM_PM then File.Before_LM := False; File.Before_LM_PM := False; File.Page := File.Page + 1; File.Line := 1; File.Col := 1; return; end if; -- This is a bit tricky, if we are logically before an LM then -- it is not an error if we are at an end of file now, since we -- are not really at it. if File.Before_LM then File.Before_LM := False; File.Before_LM_PM := False; ch := Getc (File); -- Otherwise we do raise End_Error if we are at the end of file now else ch := Getc (File); if ch = EOF then raise End_Error; end if; end if; -- Now we can just rumble along to the next page mark, or to the -- end of file, if that comes first. The latter case happens when -- the page mark is implied at the end of file. loop exit when ch = EOF or else (ch = PM and then File.Is_Regular_File); ch := Getc (File); end loop; File.Page := File.Page + 1; File.Line := 1; File.Col := 1; File.Before_Upper_Half_Character := False; end Skip_Page; procedure Skip_Page is begin Skip_Page (Current_In); end Skip_Page; -------------------- -- Standard_Error -- -------------------- function Standard_Error return File_Type is begin return Standard_Err; end Standard_Error; function Standard_Error return File_Access is begin return Standard_Err'Access; end Standard_Error; -------------------- -- Standard_Input -- -------------------- function Standard_Input return File_Type is begin return Standard_In; end Standard_Input; function Standard_Input return File_Access is begin return Standard_In'Access; end Standard_Input; --------------------- -- Standard_Output -- --------------------- function Standard_Output return File_Type is begin return Standard_Out; end Standard_Output; function Standard_Output return File_Access is begin return Standard_Out'Access; end Standard_Output; -------------------- -- Terminate_Line -- -------------------- procedure Terminate_Line (File : File_Type) is begin FIO.Check_File_Open (AP (File)); -- For file other than In_File, test for needing to terminate last line if Mode (File) /= In_File then -- If not at start of line definition need new line if File.Col /= 1 then New_Line (File); -- For files other than standard error and standard output, we -- make sure that an empty file has a single line feed, so that -- it is properly formatted. We avoid this for the standard files -- because it is too much of a nuisance to have these odd line -- feeds when nothing has been written to the file. -- We also avoid this for files opened in append mode, in -- accordance with (RM A.8.2(10)) elsif (File /= Standard_Err and then File /= Standard_Out) and then (File.Line = 1 and then File.Page = 1) and then Mode (File) = Out_File then New_Line (File); end if; end if; end Terminate_Line; ------------ -- Ungetc -- ------------ procedure Ungetc (ch : int; File : File_Type) is begin if ch /= EOF then if ungetc (ch, File.Stream) = EOF then raise Device_Error; end if; end if; end Ungetc; ----------- -- Write -- ----------- -- This is the primitive Stream Write routine, used when a Text_IO file -- is treated directly as a stream using Text_IO.Streams.Stream. procedure Write (File : in out Text_AFCB; Item : Stream_Element_Array) is pragma Warnings (Off, File); -- Because in this implementation we don't need IN OUT, we only read function Has_Translated_Characters return Boolean; -- return True if Item array contains a character which will be -- translated under the text file mode. There is only one such -- character under DOS based systems which is character 10. text_translation_required : Boolean; for text_translation_required'Size use Character'Size; pragma Import (C, text_translation_required, "__gnat_text_translation_required"); Siz : constant size_t := Item'Length; ------------------------------- -- Has_Translated_Characters -- ------------------------------- function Has_Translated_Characters return Boolean is begin for K in Item'Range loop if Item (K) = 10 then return True; end if; end loop; return False; end Has_Translated_Characters; Needs_Binary_Write : constant Boolean := text_translation_required and then Has_Translated_Characters; -- Start of processing for Write begin if File.Mode = FCB.In_File then raise Mode_Error; end if; -- Now we do the write. Since this is a text file, it is normally in -- text mode, but stream data must be written in binary mode, so we -- temporarily set binary mode for the write, resetting it after. This -- is done only if needed (i.e. there is some characters in Item which -- needs to be written using the binary mode). -- These calls have no effect in a system (like Unix) where there is -- no distinction between text and binary files. -- Since the character translation is done at the time the buffer is -- written (this is true under Windows) we first flush current buffer -- with text mode if needed. if Needs_Binary_Write then if fflush (File.Stream) = -1 then raise Device_Error; end if; set_binary_mode (fileno (File.Stream)); end if; if fwrite (Item'Address, 1, Siz, File.Stream) /= Siz then raise Device_Error; end if; -- At this point we need to flush the buffer using the binary mode then -- we reset to text mode. if Needs_Binary_Write then if fflush (File.Stream) = -1 then raise Device_Error; end if; set_text_mode (fileno (File.Stream)); end if; end Write; begin -- Initialize Standard Files for J in WC_Encoding_Method loop if WC_Encoding = WC_Encoding_Letters (J) then Default_WCEM := J; end if; end loop; Initialize_Standard_Files; FIO.Chain_File (AP (Standard_In)); FIO.Chain_File (AP (Standard_Out)); FIO.Chain_File (AP (Standard_Err)); end Ada.Text_IO;
stcarrez/ada-asf
Ada
2,912
ads
----------------------------------------------------------------------- -- asf-events-phases -- Lifecycle phase event -- Copyright (C) 2012 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- 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.Events; -- The <b>ASF.Events.Phases</b> package defines the phase event which represents -- the beginning or ending of processing for a particular phase of the request lifecycle. -- -- This package is an Ada adaptation for the Java Server Faces Specification -- JSR 314 - 3.4.2 Application Events. package ASF.Events.Phases is type Phase_Type is (ANY_PHASE, RESTORE_VIEW, APPLY_REQUEST_VALUES, PROCESS_VALIDATION, UPDATE_MODEL_VALUES, INVOKE_APPLICATION, RENDER_RESPONSE); -- ------------------------------ -- Phase event -- ------------------------------ -- The <b>Phase_Event</b> represents the phase event notifying application of the -- current lifecycly processing. type Phase_Event (Phase : Phase_Type) is new Util.Events.Event with null record; -- ------------------------------ -- Phase listener -- ------------------------------ -- The <b>Phase_Listener</b> is an interface which allows application to be called -- and receive the <b>Phase_Event</b> during the ASF lifecycle processing. type Phase_Listener is limited interface and Util.Events.Event_Listener; type Phase_Listener_Access is access all Phase_Listener'Class; -- Notifies that the lifecycle phase described by the event is about to begin. procedure Before_Phase (Listener : in Phase_Listener; Event : in Phase_Event'Class) is null; -- Notifies that the lifecycle phase described by the event has finished. procedure After_Phase (Listener : in Phase_Listener; Event : in Phase_Event'Class) is null; -- Return the phase that this listener is interested in processing the <b>Phase_Event</b> -- events. If the listener is interested by several events, it should return <b>ANY_PHASE</b>. function Get_Phase (Listener : in Phase_Listener) return Phase_Type is abstract; end ASF.Events.Phases;
tum-ei-rcs/StratoX
Ada
1,304
adb
package body p4 with SPARK_MODE is -- minimalist evil: line 32 is missed silently, but post is obviosuly stupid --function f1 (X : Integer) return Integer is (X) with Post => False; -- this is more evil: Post has no failing VC -- because a failing VC in the body shadows it -- and line 32 is missed function f1 (X : Integer) return Integer with Pre => X in Integer'Range, Post => f1'Result = X + 1 is begin return X ;--+ 1; end f1; -- this is a semi-benign case: -- failing VC indicated in Post, so user has to act upon it. -- nevertheless, line 32 is missed! -- function f1 (X : Integer) return Integer with -- Pre => X in Integer'Range, -- Post => f1'Result = X + 1 -- is -- begin -- return X; -- end f1; -- the following function is needed just to get this faulty program -- to compile. Otherwise the compiler detects the overflow and refuses. function hide_addition_from_compiler (X : Integer) return Integer is begin return X + 1; -- this is a guaranteed exception being missed end hide_addition_from_compiler; procedure foo is X : Integer := Integer'Last; Z : Integer; begin Z := X + 1; --hide_addition_from_compiler (X); Z := f1(X); end foo; end p4;
1Crazymoney/LearnAda
Ada
431
ads
generic type Position is (<>); package Garden_Pkg is function GetRandPos return Position; function GetField(pos : Position) return Boolean; procedure Start; task type Gardener; task type Mantis; type Mantis_Access is access Mantis; type Mantis_Array is array (Integer range <>) of Mantis_Access; numberOfMantises : Natural; John : access Gardener; Fields : array(Position) of Boolean; end Garden_Pkg;
HackInvent/Ada_Drivers_Library
Ada
12,205
ads
-- This spec has been automatically generated from stm32_svd.svd -- Definition of the device's interrupts package STM32_SVD.Interrupts is ---------------- -- Interrupts -- ---------------- -- Window Watchdog interrupt WWDG1 : constant := 0; -- PVD through EXTI line PVD_PVM : constant := 1; -- RTC tamper, timestamp RTC_TAMP_STAMP_CSS_LSE : constant := 2; -- RTC Wakeup interrupt RTC_WKUP : constant := 3; -- Flash memory FLASH : constant := 4; -- RCC global interrupt RCC : constant := 5; -- EXTI Line 0 interrupt EXTI0 : constant := 6; -- EXTI Line 1 interrupt EXTI1 : constant := 7; -- EXTI Line 2 interrupt EXTI2 : constant := 8; -- EXTI Line 3interrupt EXTI3 : constant := 9; -- EXTI Line 4interrupt EXTI4 : constant := 10; -- DMA1 Stream0 DMA_STR0 : constant := 11; -- DMA1 Stream1 DMA_STR1 : constant := 12; -- DMA1 Stream2 DMA_STR2 : constant := 13; -- DMA1 Stream3 DMA_STR3 : constant := 14; -- DMA1 Stream4 DMA_STR4 : constant := 15; -- DMA1 Stream5 DMA_STR5 : constant := 16; -- DMA1 Stream6 DMA_STR6 : constant := 17; -- ADC1 and ADC2 ADC1_2 : constant := 18; -- FDCAN1 Interrupt 0 FDCAN1_IT0 : constant := 19; -- FDCAN2 Interrupt 0 FDCAN2_IT0 : constant := 20; -- FDCAN1 Interrupt 1 FDCAN1_IT1 : constant := 21; -- FDCAN2 Interrupt 1 FDCAN2_IT1 : constant := 22; -- EXTI Line[9:5] interrupts EXTI9_5 : constant := 23; -- TIM1 break interrupt TIM1_BRK : constant := 24; -- TIM1 update interrupt TIM1_UP : constant := 25; -- TIM1 trigger and commutation TIM1_TRG_COM : constant := 26; -- TIM1 capture / compare TIM_CC : constant := 27; -- TIM2 global interrupt TIM2 : constant := 28; -- TIM3 global interrupt TIM3 : constant := 29; -- TIM4 global interrupt TIM4 : constant := 30; -- I2C1 event interrupt I2C1_EV : constant := 31; -- I2C1 error interrupt I2C1_ER : constant := 32; -- I2C2 event interrupt I2C2_EV : constant := 33; -- I2C2 error interrupt I2C2_ER : constant := 34; -- SPI1 global interrupt SPI1 : constant := 35; -- SPI2 global interrupt SPI2 : constant := 36; -- USART1 global interrupt USART1 : constant := 37; -- USART2 global interrupt USART2 : constant := 38; -- USART3 global interrupt USART3 : constant := 39; -- EXTI Line[15:10] interrupts EXTI15_10 : constant := 40; -- RTC alarms (A and B) RTC_ALARM : constant := 41; -- TIM8 and 12 break global TIM8_BRK_TIM12 : constant := 43; -- TIM8 and 13 update global TIM8_UP_TIM13 : constant := 44; -- TIM8 and 14 trigger /commutation and global TIM8_TRG_COM_TIM14 : constant := 45; -- TIM8 capture / compare TIM8_CC : constant := 46; -- DMA1 Stream7 DMA1_STR7 : constant := 47; -- FMC global interrupt FMC : constant := 48; -- SDMMC global interrupt SDMMC1 : constant := 49; -- TIM5 global interrupt TIM5 : constant := 50; -- SPI3 global interrupt SPI3 : constant := 51; -- UART4 global interrupt UART4 : constant := 52; -- UART5 global interrupt UART5 : constant := 53; -- TIM6 global interrupt TIM6_DAC : constant := 54; -- TIM7 global interrupt TIM7 : constant := 55; -- DMA2 Stream0 interrupt DMA2_STR0 : constant := 56; -- DMA2 Stream1 interrupt DMA2_STR1 : constant := 57; -- DMA2 Stream2 interrupt DMA2_STR2 : constant := 58; -- DMA2 Stream3 interrupt DMA2_STR3 : constant := 59; -- DMA2 Stream4 interrupt DMA2_STR4 : constant := 60; -- Ethernet global interrupt ETH : constant := 61; -- Ethernet wakeup through EXTI ETH_WKUP : constant := 62; -- CAN2TX interrupts FDCAN_CAL : constant := 63; -- DMA2 Stream5 interrupt DMA2_STR5 : constant := 68; -- DMA2 Stream6 interrupt DMA2_STR6 : constant := 69; -- DMA2 Stream7 interrupt DMA2_STR7 : constant := 70; -- USART6 global interrupt USART6 : constant := 71; -- I2C3 event interrupt I2C3_EV : constant := 72; -- I2C3 error interrupt I2C3_ER : constant := 73; -- OTG_HS out global interrupt OTG_HS_EP1_OUT : constant := 74; -- OTG_HS in global interrupt OTG_HS_EP1_IN : constant := 75; -- OTG_HS wakeup interrupt OTG_HS_WKUP : constant := 76; -- OTG_HS global interrupt OTG_HS : constant := 77; -- DCMI global interrupt DCMI : constant := 78; -- CRYP global interrupt CRYP : constant := 79; -- HASH and RNG HASH_RNG : constant := 80; -- CPU FPU FPU : constant := 81; -- UART7 global interrupt UART7 : constant := 82; -- UART8 global interrupt UART8 : constant := 83; -- SPI4 global interrupt SPI4 : constant := 84; -- SPI5 global interrupt SPI5 : constant := 85; -- SPI6 global interrupt SPI6 : constant := 86; -- SAI1 global interrupt SAI1 : constant := 87; -- LCD-TFT global interrupt LTDC : constant := 88; -- LCD-TFT error interrupt LTDC_ER : constant := 89; -- DMA2D global interrupt DMA2D : constant := 90; -- SAI2 global interrupt SAI2 : constant := 91; -- QuadSPI global interrupt QUADSPI : constant := 92; -- LPTIM1 global interrupt LPTIM1 : constant := 93; -- HDMI-CEC global interrupt CEC : constant := 94; -- I2C4 event interrupt I2C4_EV : constant := 95; -- I2C4 error interrupt I2C4_ER : constant := 96; -- SPDIFRX global interrupt SPDIF : constant := 97; -- OTG_FS out global interrupt OTG_FS_EP1_OUT : constant := 98; -- OTG_FS in global interrupt OTG_FS_EP1_IN : constant := 99; -- OTG_FS wakeup OTG_FS_WKUP : constant := 100; -- OTG_FS global interrupt OTG_FS : constant := 101; -- DMAMUX1 overrun interrupt DMAMUX1_OV : constant := 102; -- HRTIM1 master timer interrupt HRTIM1_MST : constant := 103; -- HRTIM1 timer A interrupt HRTIM1_TIMA : constant := 104; -- HRTIM1 timer B interrupt HRTIM_TIMB : constant := 105; -- HRTIM1 timer C interrupt HRTIM1_TIMC : constant := 106; -- HRTIM1 timer D interrupt HRTIM1_TIMD : constant := 107; -- HRTIM1 timer E interrupt HRTIM_TIME : constant := 108; -- HRTIM1 fault interrupt HRTIM1_FLT : constant := 109; -- DFSDM1 filter 0 interrupt DFSDM1_FLT0 : constant := 110; -- DFSDM1 filter 1 interrupt DFSDM1_FLT1 : constant := 111; -- DFSDM1 filter 2 interrupt DFSDM1_FLT2 : constant := 112; -- DFSDM1 filter 3 interrupt DFSDM1_FLT3 : constant := 113; -- SAI3 global interrupt SAI3 : constant := 114; -- SWPMI global interrupt SWPMI1 : constant := 115; -- TIM15 global interrupt TIM15 : constant := 116; -- TIM16 global interrupt TIM16 : constant := 117; -- TIM17 global interrupt TIM17 : constant := 118; -- MDIOS wakeup MDIOS_WKUP : constant := 119; -- MDIOS global interrupt MDIOS : constant := 120; -- JPEG global interrupt JPEG : constant := 121; -- MDMA MDMA : constant := 122; -- SDMMC global interrupt SDMMC : constant := 124; -- HSEM global interrupt 1 HSEM0 : constant := 125; -- ADC3 global interrupt ADC3 : constant := 127; -- DMAMUX2 overrun interrupt DMAMUX2_OVR : constant := 128; -- BDMA channel 1 interrupt BDMA_CH1 : constant := 129; -- BDMA channel 2 interrupt BDMA_CH2 : constant := 130; -- BDMA channel 3 interrupt BDMA_CH3 : constant := 131; -- BDMA channel 4 interrupt BDMA_CH4 : constant := 132; -- BDMA channel 5 interrupt BDMA_CH5 : constant := 133; -- BDMA channel 6 interrupt BDMA_CH6 : constant := 134; -- BDMA channel 7 interrupt BDMA_CH7 : constant := 135; -- BDMA channel 8 interrupt BDMA_CH8 : constant := 136; -- COMP1 and COMP2 COMP : constant := 137; -- LPTIM2 timer interrupt LPTIM2 : constant := 138; -- LPTIM2 timer interrupt LPTIM3 : constant := 139; -- LPTIM2 timer interrupt LPTIM4 : constant := 140; -- LPTIM2 timer interrupt LPTIM5 : constant := 141; -- LPUART global interrupt LPUART : constant := 142; -- Window Watchdog interrupt WWDG1_RST : constant := 143; -- Clock Recovery System globa CRS : constant := 144; -- SAI4 global interrupt SAI4 : constant := 146; -- WKUP1 to WKUP6 pins WKUP : constant := 149; end STM32_SVD.Interrupts;
charlie5/cBound
Ada
1,487
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces; with swig; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_render_pictdepth_t is -- Item -- type Item is record depth : aliased Interfaces.Unsigned_8; pad0 : aliased Interfaces.Unsigned_8; num_visuals : aliased Interfaces.Unsigned_16; pad1 : aliased swig.int8_t_Array (0 .. 3); end record; -- Item_Array -- type Item_Array is array (Interfaces.C.size_t range <>) of aliased xcb.xcb_render_pictdepth_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_render_pictdepth_t.Item, Element_Array => xcb.xcb_render_pictdepth_t.Item_Array, Default_Terminator => (others => <>)); subtype Pointer is C_Pointers.Pointer; -- Pointer_Array -- type Pointer_Array is array (Interfaces.C.size_t range <>) of aliased xcb.xcb_render_pictdepth_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_render_pictdepth_t.Pointer, Element_Array => xcb.xcb_render_pictdepth_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_render_pictdepth_t;
burratoo/Acton
Ada
5,655
ads
------------------------------------------------------------------------------------------ -- -- -- OAK PROCESSOR SUPPORT PACKAGE -- -- FREESCALE MPC5544 -- -- -- -- MPC5554.ETPU.UTIL -- -- -- -- Copyright (C) 2010-2021, Patrick Bernardi -- -- -- ------------------------------------------------------------------------------------------ with MPC5554; use MPC5554; with MPC5554.eTPU; use MPC5554.eTPU; package MPC5554.eTPU.Util with Preelaborate is type eTPU_Config_Type is record MISC_Enable : Enable_Type; MISC_Value : MISC_Value_Type; Engine_Configuration_A : Engine_Configuration_Type; Time_Base_Configuration_A : Time_Base_Configuration_Type; STAC_A : STAC_Bus_Configuration_Type; Engine_Configuration_B : Engine_Configuration_Type; Time_Base_Configuration_B : Time_Base_Configuration_Type; STAC_B : STAC_Bus_Configuration_Type; end record; subtype Byte_Quanity_Type is Shared_Data_Offset; procedure Initialize (Config : in eTPU_Config_Type; Code : in Shared_Code_Type; Global_Values : in Shared_Data_Type_32); procedure Timer_Start; procedure Malloc (Number_Of_Bytes : in Byte_Quanity_Type; Data_Offset : out Shared_Data_Offset); procedure Malloc2 (Engine : in eTPU_Engine; Channel : in eTPU_ID_Type; Number_Of_Bytes : in Byte_Quanity_Type); procedure Interrupt_Enable (Engine : in eTPU_Engine; Channel : in eTPU_ID_Type); procedure Interrupt_Disable (Engine : in eTPU_Engine; Channel : in eTPU_ID_Type); procedure DMA_Enable (Engine : in eTPU_Engine; Channel : in eTPU_ID_Type); procedure DMA_Disable (Engine : in eTPU_Engine; Channel : in eTPU_ID_Type); procedure Channel_Enable (Engine : in eTPU_Engine; Channel : in eTPU_ID_Type; Priority : in Priority_Type); procedure Channel_Disable (Engine : in eTPU_Engine; Channel : in eTPU_ID_Type); function Get_Pending_Host_Request (Engine : in eTPU_Engine; Channel : in eTPU_ID_Type) return HSR_Type; procedure Request_Channel_Service (Engine : in eTPU_Engine; Channel : in eTPU_ID_Type; HSR : in HSR_Type); -- Memory Accessors function Local_Data_Adress (Engine : in eTPU_Engine; Channel : in eTPU_ID_Type) return Shared_Data_Offset; procedure Set_Local_32_Data (Engine : in eTPU_Engine; Channel : in eTPU_ID_Type; Offset : in Shared_Data_Offset; Data : in Unsigned_32); function Get_Local_32_Data (Engine : in eTPU_Engine; Channel : in eTPU_ID_Type; Offset : in Shared_Data_Offset) return Unsigned_32; procedure Set_Local_24_Data (Engine : in eTPU_Engine; Channel : in eTPU_ID_Type; Offset : in Shared_Data_Offset; Data : in Unsigned_32); function Get_Local_24_Data (Engine : in eTPU_Engine; Channel : in eTPU_ID_Type; Offset : in Shared_Data_Offset) return Unsigned_32; function Get_Local_24_Signed_Data (Engine : in eTPU_Engine; Channel : in eTPU_ID_Type; Offset : in Shared_Data_Offset) return Integer_32; procedure Set_Local_16_Data (Engine : in eTPU_Engine; Channel : in eTPU_ID_Type; Offset : in Shared_Data_Offset; Data : in Unsigned_16); function Get_Local_16_Data (Engine : in eTPU_Engine; Channel : in eTPU_ID_Type; Offset : in Shared_Data_Offset) return Unsigned_16; procedure Set_Local_8_Data (Engine : in eTPU_Engine; Channel : in eTPU_ID_Type; Offset : in Shared_Data_Offset; Data : in Unsigned_8); function Get_Local_8_Data (Engine : in eTPU_Engine; Channel : in eTPU_ID_Type; Offset : in Shared_Data_Offset) return Unsigned_8; procedure Set_Global_32_Data (Offset : in Shared_Data_Offset; Data : in Unsigned_32); function Get_Global_32_Data (Offset : in Shared_Data_Offset) return Unsigned_32; procedure Set_Global_24_Data (Offset : in Shared_Data_Offset; Data : in Integer_32); function Get_Global_24_Data (Offset : in Shared_Data_Offset) return Unsigned_32; function Get_Global_24_Signed_Data (Offset : in Shared_Data_Offset) return Integer_32; procedure Set_Global_16_Data (Offset : in Shared_Data_Offset; Data : in Unsigned_16); function Get_Global_16_Data (Offset : in Shared_Data_Offset) return Unsigned_16; procedure Set_Global_8_Data (Offset : in Shared_Data_Offset; Data : in Unsigned_8); function Get_Global_8_Data (Offset : in Shared_Data_Offset) return Unsigned_8; private Free_Parameter_RAM_Offset : Shared_Data_Offset; Extension_Mask : constant Unsigned_32 := 16#FF_FFFF#; end MPC5554.eTPU.Util;
AdaCore/training_material
Ada
80
ads
package Queens_Pkg is procedure Generate (Count : Positive); end Queens_Pkg;
zhmu/ananas
Ada
2,145
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- V A S T -- -- -- -- B o d y -- -- -- -- Copyright (C) 2020-2022, 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. -- -- -- ------------------------------------------------------------------------------ -- Dummy implementation package body VAST is ---------------- -- Check_Tree -- ---------------- procedure Check_Tree (GNAT_Root : Node_Id) is pragma Unreferenced (GNAT_Root); begin null; end Check_Tree; end VAST;
BrickBot/Bound-T-H8-300
Ada
8,938
ads
-- Flow.Execution (decl) -- -- Executions of flow graphs represented as execution counts -- of nodes and edges. Computation of the execution time for -- each node in a flow-graph, possibly depending on modified -- times for step edges. -- -- A component of the Bound-T Worst-Case Execution Time Tool. -- ------------------------------------------------------------------------------- -- Copyright (c) 1999 .. 2015 Tidorum Ltd -- All rights reserved. -- -- 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. -- -- 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. -- -- Other modules (files) of this software composition should contain their -- own copyright statements, which may have different copyright and usage -- conditions. The above conditions apply to this file. ------------------------------------------------------------------------------- -- -- $Revision: 1.20 $ -- $Date: 2015/10/24 19:36:49 $ -- -- $Log: flow-execution.ads,v $ -- Revision 1.20 2015/10/24 19:36:49 niklas -- Moved to free licence. -- -- Revision 1.19 2009-01-18 08:01:21 niklas -- Removed unused context clause. -- -- Revision 1.18 2008/09/24 08:38:52 niklas -- BT-CH-0146: Assertions on "loop starts <bound> times". -- BT-CH-0146: Loop-repeat assertions set both lower and upper bound. -- BT-CH-0146: Report locations of contradictory "count" assertions. -- BT-CH-0146: Contradictory "count" assertions imply infeasibility. -- -- Revision 1.17 2008/07/28 19:23:45 niklas -- BT-CH-0140: Detect contradictory execution-count bounds. -- -- Revision 1.16 2008/07/14 19:16:56 niklas -- BT-CH-0135: Assertions on "instructions". -- -- Revision 1.15 2007/12/17 13:54:36 niklas -- BT-CH-0098: Assertions on stack usage and final stack height, etc. -- -- Revision 1.14 2007/04/18 18:34:38 niklas -- BT-CH-0057. -- -- Revision 1.13 2007/03/29 15:18:02 niklas -- BT-CH-0056. -- -- Revision 1.12 2007/01/25 21:25:15 niklas -- BT-CH-0043. -- -- Revision 1.11 2005/10/09 08:10:21 niklas -- BT-CH-0013. -- -- Revision 1.10 2005/08/24 10:16:12 niklas -- Added the inquiry functions Total_Count (Node_List) and -- Total_Count (Edge_List) to support the Analysis Workbench. -- -- Revision 1.9 2004/04/28 19:02:13 niklas -- First Tidorum version. -- Moved the operations Count_Memory_Traffic and Work from the parent -- package to this child package, where they are more at home. -- Added operations Node_Times and Edge_Times to compute the total -- execution time per node and per (node-) edge. -- -- Revision 1.8 2001/04/17 11:10:07 ville -- Edge_Index_T used in Count_Per_Edge_T (NC_067) -- -- Revision 1.7 2001/02/19 09:27:36 holsti -- Infinite and Bounded added. -- -- Revision 1.6 2001/01/13 11:08:36 holsti -- Remove to-be's in favour of NC's. -- -- Revision 1.5 2000/09/08 13:05:57 saarinen -- Changed edges to be indexed by Edge_Count_T, -- since the number of edges can be zero. -- -- Revision 1.4 2000/07/13 10:50:40 parviain -- Added Loop_Counts_T. -- -- Revision 1.3 2000/07/04 10:58:09 parviain -- added times type -- -- Revision 1.2 2000/06/29 11:06:43 parviain -- added Counts_Ref_T -- -- Revision 1.1 2000/06/20 13:32:07 holsti -- First version. -- with Loops; with Processor; package Flow.Execution is subtype Count_T is Natural; -- -- The number of times an element of a flow graph is (or can -- be) executed. function Image (Item : Count_T) return String; -- -- Decimal image without leading blank. function "*" ( Left : Count_T; Right : Processor.Time_T) return Processor.Time_T; -- -- The total execution time that results from repeating a given -- execution time (Right) a given number (Left) of times. And if -- that isn't belabouring the obvious... Infinite : constant Count_T := Count_T'Last; -- -- Represents an unbounded count (an absent bound on some count). function Bounded (Count : Count_T) return Boolean; -- -- Whether the Count, which represents some other execution-count -- bound, is really bounded (less than Infinite). type Bound_T is record Min : Count_T; Max : Count_T; end record; -- -- Bounds on the number of times an element of a flow graph can -- be executed. The execution count must be in Min .. Max. -- The "unbounded" case is represented by Min = 0 and -- Max = Infinite, respectively. Unbounded : constant Bound_T := (Min => 0, Max => Infinite); -- -- Represents an unbounded number of executions. Impossible : constant Bound_T := (Min => 1, Max => 0); -- -- Represents an impossible number of executions. function Bounded (Bound : Bound_T) return Boolean; -- -- Whether the Bound is really bounded at either end, that is, -- whether Min > 0 or Max < Infinite. function Image (Item : Bound_T) return String; -- -- The bounds in the form min .. max, with max omitted if Infinite. function Void (Item : Bound_T) return Boolean; -- -- Whether the bounds are void (contradictory), that is, -- whether Min > Max. function Is_In (Count : Count_T; Bound : Bound_T) return Boolean; -- -- Whether the Count is within the Bound. function "and" (Left, Right : Bound_T) return Bound_T; -- -- Intersection (conjunction) of bounds. type Bounds_T is array (Node_Index_T range <>) of Bound_T; -- -- Bounds on the execution of a flow graph, given as bounds -- on the number of executions of each node. type Count_Per_Node_T is array (Node_Index_T range <>) of Count_T; type Count_Per_Edge_T is array (Edge_Index_T range <>) of Count_T; -- -- A count for each node/edge in a flow graph. type Counts_T ( Nodes : Node_Index_T; Edges : Edge_Count_T) -- -- An execution of a flow graph, given as the number of times -- each node or edge is executed. -- The number of Nodes and Edges are given as discriminants. -- Note that not all values of this type are consistent with -- the structure of the flow graph. -- is record Node : Count_Per_Node_T (1 .. Nodes); Edge : Count_Per_Edge_T (1 .. Edges); end record; type Counts_Ref is access Counts_T; -- -- Reference, to avoid supplying the discriminants to -- Counts_T when not applicable or not yet known. function Count ( Node : Node_T; Within : Counts_T) return Count_T; -- -- The execution count of this Node, Within the given execution. function Total_Count ( Nodes : Node_List_T; Within : Counts_T) return Count_T; -- -- The total execution count of the listed Nodes, Within the -- given execution. function Total_Count ( Edges : Edge_List_T; Within : Counts_T) return Count_T; -- -- The total execution count of the listed Edges, Within the -- given execution. type Loop_Bounds_T is array (Loops.Loop_Index_T range <>) of Bound_T; -- -- For each loop in a subprogram, a bound on the number of -- times the loop starts or repeats. type Node_Count_Bound_T is record Node : Node_T; Count : Bound_T; end record; -- -- Bounds on the execution count of a single node. type Node_Count_Bounds_T is array (Positive range <>) of Node_Count_Bound_T; -- -- A set of nodes with bounded execution counts. -- The order of nodes in the list is generally irrelevant, and -- nodes are generally not duplicated in the list. -- -- Memory traffic counts -- procedure Count_Memory_Traffic ( From : in Node_T; Reads : out Natural; Writes : out Natural); -- -- Returns the total number of memory reads and memory writes -- executed by one node of a flow-graph. end Flow.Execution;
luk9400/nsi
Ada
803
ads
package Bubble with SPARK_Mode is type Arr is array (Integer range <>) of Integer; function Sorted (A : Arr) return Boolean is (for all I in A'First .. A'Last - 1 => A(I) <= A(I + 1)) with Ghost, Pre => A'Last > Integer'First, Post => Sorted'Result = (for all I in A'First .. A'Last - 1 => A(I) <= A(I + 1)); function Bubbled (A : Arr) return Boolean is (for all I in A'First .. A'Last - 1 => A(I) <= A(A'Last)) with Ghost, Pre => A'Last > Integer'First, Post => Bubbled'Result = (for all I in A'First .. A'Last - 1 => A(I) <= A(A'Last)); procedure Sort (A : in out Arr) with Pre => A'Last > Integer'First and A'Last < Integer'Last, Post => Sorted(A); end Bubble;
reznikmm/matreshka
Ada
4,597
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- 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$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Db.As_Template_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Db_As_Template_Attribute_Node is begin return Self : Db_As_Template_Attribute_Node do Matreshka.ODF_Db.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Db_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Db_As_Template_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.As_Template_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Db_URI, Matreshka.ODF_String_Constants.As_Template_Attribute, Db_As_Template_Attribute_Node'Tag); end Matreshka.ODF_Db.As_Template_Attributes;
ytomino/xml-ada
Ada
3,524
adb
with Ada.Characters.Latin_1; with Ada.Command_Line; with Ada.Exceptions; with Ada.Integer_Text_IO; with Ada.Streams.Stream_IO; with Ada.Text_IO; with XML.Streams; procedure dump_event is use type XML.Encoding_Type; use type XML.Event_Type; use type XML.Standalone_Type; procedure Dump_One_Event (Event : in XML.Event) is use Ada.Characters.Latin_1; use Ada.Integer_Text_IO; use Ada.Text_IO; begin Put_Line (XML.Event_Type'Image (Event.Event_Type)); case Event.Event_Type is when XML.Element_Start | XML.Attribute | XML.Processing_Instruction | XML.Document_Type => Put (HT); Put (Event.Name.all); case Event.Event_Type is when XML.Attribute => Put (" = """); Put (Event.Value.all); Put ('"'); when XML.Document_Type => if Event.Public_Id /= null then Put (" public id = "); Put (Event.Public_Id.all); end if; if Event.System_Id /= null then Put (" system id = "); Put (Event.System_Id.all); end if; if Event.Subset /= null then Put (" subset = "); Put (Event.Subset.all); end if; when others => null; end case; New_Line; when XML.Text | XML.CDATA | XML.Comment => Put (HT & '"'); Put (Event.Content.all); Put ('"'); New_Line; when XML.Whitespace | XML.Significant_Whitespace => Put (HT); Put (Event.Content'Length, Width => 1); Put (" whitespaces"); New_Line; when others => null; end case; end Dump_One_Event; procedure Dump_XML (Reader : in out XML.Reader) is use Ada.Text_IO; begin Put_Line ("version = " & XML.Version (Reader).all); declare Encoding : constant XML.Encoding_Type := XML.Encoding (Reader); begin Put ("encoding = "); if Encoding = XML.No_Encoding then Put ("none"); else Put (XML.Name (Encoding)); end if; New_Line; end; declare Standalone : constant XML.Standalone_Type := XML.Standalone (Reader); begin Put ("standalone = "); if Standalone = XML.No_Specific then Put ("none"); else Put (XML.Standalone_Type'Image (Standalone)); end if; New_Line; end; Put_Line ("base URI = " & XML.Base_URI (Reader)); loop declare Parsing_Entry : aliased XML.Parsing_Entry_Type; begin XML.Get (Reader, Parsing_Entry); declare Event : XML.Event renames XML.Value (Parsing_Entry); begin exit when Event.Event_Type = XML.No_Event; Dump_One_Event (Event); end; end; end loop; end Dump_XML; procedure Read_From_File (Name : in String) is File : Ada.Streams.Stream_IO.File_Type; begin Ada.Streams.Stream_IO.Open (File, Ada.Streams.Stream_IO.In_File, Name => Name); declare Reader : XML.Reader := XML.Streams.Create (Ada.Streams.Stream_IO.Stream (File), URI => "file://" & Name); begin Dump_XML (Reader); XML.Finish (Reader); exception when E : XML.Data_Error => Ada.Text_IO.Put_Line ( Ada.Text_IO.Current_Error.all, "error: " & Ada.Exceptions.Exception_Message (E)); end; Ada.Streams.Stream_IO.Close (File); end Read_From_File; begin if Ada.Command_Line.Argument_Count = 0 then Ada.Text_IO.Put_Line ("please tell XML file name."); else for I in 1 .. Ada.Command_Line.Argument_Count loop declare Name : constant String := Ada.Command_Line.Argument (I); begin if Ada.Command_Line.Argument_Count > 1 then Ada.Text_IO.Put_Line (Name & ":"); end if; Read_From_File (Name); end; end loop; end if; end dump_event;
micahwelf/FLTK-Ada
Ada
19,397
adb
with Interfaces.C.Strings, System; use type Interfaces.C.int, Interfaces.C.Strings.chars_ptr, System.Address; package body FLTK.Widgets.Inputs is procedure input_set_draw_hook (W, D : in System.Address); pragma Import (C, input_set_draw_hook, "input_set_draw_hook"); pragma Inline (input_set_draw_hook); procedure input_set_handle_hook (W, H : in System.Address); pragma Import (C, input_set_handle_hook, "input_set_handle_hook"); pragma Inline (input_set_handle_hook); function new_fl_input (X, Y, W, H : in Interfaces.C.int; Text : in Interfaces.C.char_array) return System.Address; pragma Import (C, new_fl_input, "new_fl_input"); pragma Inline (new_fl_input); procedure free_fl_input (F : in System.Address); pragma Import (C, free_fl_input, "free_fl_input"); pragma Inline (free_fl_input); function fl_input_copy (I : in System.Address) return Interfaces.C.int; pragma Import (C, fl_input_copy, "fl_input_copy"); pragma Inline (fl_input_copy); function fl_input_cut (I : in System.Address) return Interfaces.C.int; pragma Import (C, fl_input_cut, "fl_input_cut"); pragma Inline (fl_input_cut); function fl_input_cut2 (I : in System.Address; B : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_input_cut2, "fl_input_cut2"); pragma Inline (fl_input_cut2); function fl_input_cut3 (I : in System.Address; A, B : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_input_cut3, "fl_input_cut3"); pragma Inline (fl_input_cut3); function fl_input_copy_cuts (I : in System.Address) return Interfaces.C.int; pragma Import (C, fl_input_copy_cuts, "fl_input_copy_cuts"); pragma Inline (fl_input_copy_cuts); function fl_input_undo (I : in System.Address) return Interfaces.C.int; pragma Import (C, fl_input_undo, "fl_input_undo"); pragma Inline (fl_input_undo); function fl_input_get_readonly (I : in System.Address) return Interfaces.C.int; pragma Import (C, fl_input_get_readonly, "fl_input_get_readonly"); pragma Inline (fl_input_get_readonly); procedure fl_input_set_readonly (I : in System.Address; T : in Interfaces.C.int); pragma Import (C, fl_input_set_readonly, "fl_input_set_readonly"); pragma Inline (fl_input_set_readonly); function fl_input_get_tab_nav (I : in System.Address) return Interfaces.C.int; pragma Import (C, fl_input_get_tab_nav, "fl_input_get_tab_nav"); pragma Inline (fl_input_get_tab_nav); procedure fl_input_set_tab_nav (I : in System.Address; T : in Interfaces.C.int); pragma Import (C, fl_input_set_tab_nav, "fl_input_set_tab_nav"); pragma Inline (fl_input_set_tab_nav); function fl_input_get_wrap (I : in System.Address) return Interfaces.C.int; pragma Import (C, fl_input_get_wrap, "fl_input_get_wrap"); pragma Inline (fl_input_get_wrap); procedure fl_input_set_wrap (I : in System.Address; T : in Interfaces.C.int); pragma Import (C, fl_input_set_wrap, "fl_input_set_wrap"); pragma Inline (fl_input_set_wrap); function fl_input_get_input_type (I : in System.Address) return Interfaces.C.int; pragma Import (C, fl_input_get_input_type, "fl_input_get_input_type"); pragma Inline (fl_input_get_input_type); procedure fl_input_set_input_type (I : in System.Address; T : in Interfaces.C.int); pragma Import (C, fl_input_set_input_type, "fl_input_set_input_type"); pragma Inline (fl_input_set_input_type); function fl_input_get_shortcut (I : in System.Address) return Interfaces.C.unsigned_long; pragma Import (C, fl_input_get_shortcut, "fl_input_get_shortcut"); pragma Inline (fl_input_get_shortcut); procedure fl_input_set_shortcut (I : in System.Address; T : in Interfaces.C.unsigned_long); pragma Import (C, fl_input_set_shortcut, "fl_input_set_shortcut"); pragma Inline (fl_input_set_shortcut); function fl_input_get_mark (I : in System.Address) return Interfaces.C.int; pragma Import (C, fl_input_get_mark, "fl_input_get_mark"); pragma Inline (fl_input_get_mark); function fl_input_set_mark (I : in System.Address; T : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_input_set_mark, "fl_input_set_mark"); pragma Inline (fl_input_set_mark); function fl_input_get_position (I : in System.Address) return Interfaces.C.int; pragma Import (C, fl_input_get_position, "fl_input_get_position"); pragma Inline (fl_input_get_position); function fl_input_set_position (I : in System.Address; T : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_input_set_position, "fl_input_set_position"); pragma Inline (fl_input_set_position); function fl_input_index (I : in System.Address; P : in Interfaces.C.int) return Interfaces.C.unsigned; pragma Import (C, fl_input_index, "fl_input_index"); pragma Inline (fl_input_index); function fl_input_insert (I : in System.Address; S : in Interfaces.C.char_array; L : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_input_insert, "fl_input_insert"); pragma Inline (fl_input_insert); function fl_input_replace (I : in System.Address; B, E : in Interfaces.C.int; S : in Interfaces.C.char_array; L : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_input_replace, "fl_input_replace"); pragma Inline (fl_input_replace); procedure fl_input_set_value (I : in System.Address; T : in Interfaces.C.char_array; L : in Interfaces.C.int); pragma Import (C, fl_input_set_value, "fl_input_set_value"); pragma Inline (fl_input_set_value); function fl_input_get_maximum_size (I : in System.Address) return Interfaces.C.int; pragma Import (C, fl_input_get_maximum_size, "fl_input_get_maximum_size"); pragma Inline (fl_input_get_maximum_size); procedure fl_input_set_maximum_size (I : in System.Address; T : in Interfaces.C.int); pragma Import (C, fl_input_set_maximum_size, "fl_input_set_maximum_size"); pragma Inline (fl_input_set_maximum_size); function fl_input_get_size (I : in System.Address) return Interfaces.C.int; pragma Import (C, fl_input_get_size, "fl_input_get_size"); pragma Inline (fl_input_get_size); function fl_input_get_cursor_color (I : in System.Address) return Interfaces.C.unsigned; pragma Import (C, fl_input_get_cursor_color, "fl_input_get_cursor_color"); pragma Inline (fl_input_get_cursor_color); procedure fl_input_set_cursor_color (I : in System.Address; T : in Interfaces.C.unsigned); pragma Import (C, fl_input_set_cursor_color, "fl_input_set_cursor_color"); pragma Inline (fl_input_set_cursor_color); function fl_input_get_textcolor (I : in System.Address) return Interfaces.C.unsigned; pragma Import (C, fl_input_get_textcolor, "fl_input_get_textcolor"); pragma Inline (fl_input_get_textcolor); procedure fl_input_set_textcolor (I : in System.Address; T : in Interfaces.C.unsigned); pragma Import (C, fl_input_set_textcolor, "fl_input_set_textcolor"); pragma Inline (fl_input_set_textcolor); function fl_input_get_textfont (I : in System.Address) return Interfaces.C.int; pragma Import (C, fl_input_get_textfont, "fl_input_get_textfont"); pragma Inline (fl_input_get_textfont); procedure fl_input_set_textfont (I : in System.Address; T : in Interfaces.C.int); pragma Import (C, fl_input_set_textfont, "fl_input_set_textfont"); pragma Inline (fl_input_set_textfont); function fl_input_get_textsize (I : in System.Address) return Interfaces.C.int; pragma Import (C, fl_input_get_textsize, "fl_input_get_textsize"); pragma Inline (fl_input_get_textsize); procedure fl_input_set_textsize (I : in System.Address; T : in Interfaces.C.int); pragma Import (C, fl_input_set_textsize, "fl_input_set_textsize"); pragma Inline (fl_input_set_textsize); procedure fl_input_set_size (I : in System.Address; W, H : in Interfaces.C.int); pragma Import (C, fl_input_set_size, "fl_input_set_size"); pragma Inline (fl_input_set_size); procedure fl_input_draw (W : in System.Address); pragma Import (C, fl_input_draw, "fl_input_draw"); pragma Inline (fl_input_draw); function fl_input_handle (W : in System.Address; E : in Interfaces.C.int) return Interfaces.C.int; pragma Import (C, fl_input_handle, "fl_input_handle"); pragma Inline (fl_input_handle); procedure Finalize (This : in out Input) is begin if This.Void_Ptr /= System.Null_Address and then This in Input'Class then if This.Needs_Dealloc then free_fl_input (This.Void_Ptr); end if; This.Void_Ptr := System.Null_Address; end if; Finalize (Widget (This)); end Finalize; package body Forge is function Create (X, Y, W, H : in Integer; Text : in String) return Input is begin return This : Input do This.Void_Ptr := new_fl_input (Interfaces.C.int (X), Interfaces.C.int (Y), Interfaces.C.int (W), Interfaces.C.int (H), Interfaces.C.To_C (Text)); fl_widget_set_user_data (This.Void_Ptr, Widget_Convert.To_Address (This'Unchecked_Access)); input_set_draw_hook (This.Void_Ptr, Draw_Hook'Address); input_set_handle_hook (This.Void_Ptr, Handle_Hook'Address); end return; end Create; end Forge; procedure Copy (This : in out Input) is begin This.Was_Changed := fl_input_copy (This.Void_Ptr) /= 0; end Copy; procedure Cut (This : in out Input) is begin This.Was_Changed := fl_input_cut (This.Void_Ptr) /= 0; end Cut; procedure Cut (This : in out Input; Num_Bytes : in Integer) is begin This.Was_Changed := fl_input_cut2 (This.Void_Ptr, Interfaces.C.int (Num_Bytes)) /= 0; end Cut; procedure Cut (This : in out Input; Start, Finish : in Integer) is begin This.Was_Changed := fl_input_cut3 (This.Void_Ptr, Interfaces.C.int (Start), Interfaces.C.int (Finish)) /= 0; end Cut; procedure Copy_Cuts (This : in out Input) is begin This.Was_Changed := fl_input_copy_cuts (This.Void_Ptr) /= 0; end Copy_Cuts; procedure Undo (This : in out Input) is begin This.Was_Changed := fl_input_undo (This.Void_Ptr) /= 0; end Undo; function Has_Changed (This : in Input) return Boolean is begin return This.Was_Changed; end Has_Changed; procedure Clear_Changed (This : in out Input) is begin This.Was_Changed := False; end Clear_Changed; function Is_Readonly (This : in Input) return Boolean is begin return fl_input_get_readonly (This.Void_Ptr) /= 0; end Is_Readonly; procedure Set_Readonly (This : in out Input; To : in Boolean) is begin fl_input_set_readonly (This.Void_Ptr, Boolean'Pos (To)); end Set_Readonly; function Is_Tab_Nav (This : in Input) return Boolean is begin return fl_input_get_tab_nav (This.Void_Ptr) /= 0; end Is_Tab_Nav; procedure Set_Tab_Nav (This : in out Input; To : in Boolean) is begin fl_input_set_tab_nav (This.Void_Ptr, Boolean'Pos (To)); end Set_Tab_Nav; function Is_Wrap (This : in Input) return Boolean is begin return fl_input_get_wrap (This.Void_Ptr) /= 0; end Is_Wrap; procedure Set_Wrap (This : in out Input; To : in Boolean) is begin fl_input_set_wrap (This.Void_Ptr, Boolean'Pos (To)); end Set_Wrap; function Get_Input_Type (This : in Input) return Input_Kind is C_Val : Interfaces.C.int := fl_input_get_input_type (This.Void_Ptr); begin for V in Input_Kind loop if Input_Kind_Values (V) = C_Val then return V; end if; end loop; return Normal_Kind; end Get_Input_Type; function Get_Shortcut_Key (This : in Input) return Key_Combo is begin return To_Ada (fl_input_get_shortcut (This.Void_Ptr)); end Get_Shortcut_Key; procedure Set_Shortcut_Key (This : in out Input; To : in Key_Combo) is begin fl_input_set_shortcut (This.Void_Ptr, To_C (To)); end Set_Shortcut_Key; function Get_Mark (This : in Input) return Natural is begin return Natural (fl_input_get_mark (This.Void_Ptr)); end Get_Mark; procedure Set_Mark (This : in out Input; To : in Natural) is begin This.Was_Changed := fl_input_set_mark (This.Void_Ptr, Interfaces.C.int (To)) /= 0; end Set_Mark; function Get_Position (This : in Input) return Natural is begin return Natural (fl_input_get_position (This.Void_Ptr)); end Get_Position; procedure Set_Position (This : in out Input; To : in Natural) is begin This.Was_Changed := fl_input_set_position (This.Void_Ptr, Interfaces.C.int (To)) /= 0; end Set_Position; function Index (This : in Input; Place : in Integer) return Character is begin return Character'Val (fl_input_index (This.Void_Ptr, Interfaces.C.int (Place))); end Index; procedure Insert (This : in out Input; Str : in String) is begin This.Was_Changed := fl_input_insert (This.Void_Ptr, Interfaces.C.To_C (Str), Str'Length) /= 0; end Insert; procedure Replace (This : in out Input; From, To : in Natural; New_Text : in String) is begin This.Was_Changed := fl_input_replace (This.Void_Ptr, Interfaces.C.int (From), Interfaces.C.int (To), Interfaces.C.To_C (New_Text), New_Text'Length) /= 0; end Replace; function Get_Value (This : in Input) return String is Ptr : Interfaces.C.Strings.chars_ptr := fl_input_get_value (This.Void_Ptr); begin if Ptr = Interfaces.C.Strings.Null_Ptr then return ""; else -- pointer to internal buffer only, so no Free required return Interfaces.C.Strings.Value (Ptr); end if; end Get_Value; procedure Set_Value (This : in out Input; To : in String) is begin fl_input_set_value (This.Void_Ptr, Interfaces.C.To_C (To), To'Length); end Set_Value; function Get_Maximum_Size (This : in Input) return Natural is begin return Natural (fl_input_get_maximum_size (This.Void_Ptr)); end Get_Maximum_Size; procedure Set_Maximum_Size (This : in out Input; To : in Natural) is begin fl_input_set_maximum_size (This.Void_Ptr, Interfaces.C.int (To)); end Set_Maximum_Size; function Size (This : in Input) return Natural is begin return Natural (fl_input_get_size (This.Void_Ptr)); end Size; function Get_Cursor_Color (This : in Input) return Color is begin return Color (fl_input_get_cursor_color (This.Void_Ptr)); end Get_Cursor_Color; procedure Set_Cursor_Color (This : in out Input; To : in Color) is begin fl_input_set_cursor_color (This.Void_Ptr, Interfaces.C.unsigned (To)); end Set_Cursor_Color; function Get_Text_Color (This : in Input) return Color is begin return Color (fl_input_get_textcolor (This.Void_Ptr)); end Get_Text_Color; procedure Set_Text_Color (This : in out Input; To : in Color) is begin fl_input_set_textcolor (This.Void_Ptr, Interfaces.C.unsigned (To)); end Set_Text_Color; function Get_Text_Font (This : in Input) return Font_Kind is begin return Font_Kind'Val (fl_input_get_textfont (This.Void_Ptr)); end Get_Text_Font; procedure Set_Text_Font (This : in out Input; To : in Font_Kind) is begin fl_input_set_textfont (This.Void_Ptr, Font_Kind'Pos (To)); end Set_Text_Font; function Get_Text_Size (This : in Input) return Font_Size is begin return Font_Size (fl_input_get_textsize (This.Void_Ptr)); end Get_Text_Size; procedure Set_Text_Size (This : in out Input; To : in Font_Size) is begin fl_input_set_textsize (This.Void_Ptr, Interfaces.C.int (To)); end Set_Text_Size; procedure Resize (This : in out Input; W, H : in Integer) is begin fl_input_set_size (This.Void_Ptr, Interfaces.C.int (W), Interfaces.C.int (H)); end Resize; procedure Draw (This : in out Input) is begin fl_input_draw (This.Void_Ptr); end Draw; function Handle (This : in out Input; Event : in Event_Kind) return Event_Outcome is begin return Event_Outcome'Val (fl_input_handle (This.Void_Ptr, Event_Kind'Pos (Event))); end Handle; package body Extra is procedure Set_Input_Type (This : in out Input; To : in Input_Kind) is begin fl_input_set_input_type (This.Void_Ptr, Input_Kind_Values (To)); end Set_Input_Type; pragma Inline (Set_Input_Type); end Extra; end FLTK.Widgets.Inputs;
reznikmm/matreshka
Ada
3,729
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- 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$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Style_Vertical_Pos_Attributes is pragma Preelaborate; type ODF_Style_Vertical_Pos_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Style_Vertical_Pos_Attribute_Access is access all ODF_Style_Vertical_Pos_Attribute'Class with Storage_Size => 0; end ODF.DOM.Style_Vertical_Pos_Attributes;
zrmyers/VulkanAda
Ada
11,276
adb
-------------------------------------------------------------------------------- -- MIT License -- -- Copyright (c) 2020 Zane Myers -- -- 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.Unchecked_Conversion; with Interfaces; use Interfaces; package body Vulkan.Math.Integers is -- 32-bit LSB mask. LSB32_MASK : constant := 16#00000000FFFFFFFF#; -- A 64-bit unsigned integer type. type Vkm_Uint64 is new Interfaces.Unsigned_64; -- A 64-bit signed integer type. type Vkm_Int64 is new Interfaces.Integer_64; -- A representation of a 32-bit integer as an array of 32 booleans. type Vkm_Bits32 is array (0 .. 31) of Boolean; for Vkm_Bits32'Component_Size use 1; for Vkm_Bits32'Size use 32; ---------------------------------------------------------------------------- -- Local Operations ---------------------------------------------------------------------------- -- Unchecked conversion from a 64-bit signed integer to a 64-bit unsigned -- integer. function To_Vkm_Uint64 is new Ada.Unchecked_Conversion( Source => Vkm_Int64, Target => Vkm_Uint64); function To_Vkm_Bits32 is new Ada.Unchecked_Conversion( Source => Vkm_Uint, Target => Vkm_Bits32); function To_Vkm_Bits32 is new Ada.Unchecked_Conversion( Source => Vkm_Int, Target => Vkm_Bits32); function To_Vkm_Uint is new Ada.Unchecked_Conversion( Source => Vkm_Bits32, Target => Vkm_Uint); function To_Vkm_Int is new Ada.Unchecked_Conversion( Source => Vkm_Bits32, Target => Vkm_Int); ---------------------------------------------------------------------------- -- Operations ---------------------------------------------------------------------------- function Unsigned_Add_Carry(x, y : in Vkm_Uint; carry : out Vkm_Uint) return Vkm_Uint is begin if (Vkm_Uint64(x) + Vkm_Uint64(y)) > Vkm_Uint64(Vkm_Uint'Last) then carry := 1; else carry := 0; end if; return x + y; end Unsigned_Add_Carry; ---------------------------------------------------------------------------- function Unsigned_Sub_Borrow(x, y : in Vkm_Uint; borrow : out Vkm_Uint) return Vkm_Uint is begin borrow := (if x >= y then 0 else 1); return x - y; end Unsigned_Sub_Borrow; ---------------------------------------------------------------------------- procedure Unsigned_Mul_Extended(x, y : in Vkm_Uint; msb, lsb : out Vkm_Uint) is result : constant Vkm_Uint64 := Vkm_Uint64(x) * Vkm_Uint64(y); begin lsb := Vkm_Uint(LSB32_MASK and result); msb := Vkm_Uint(LSB32_MASK and Shift_Right(result, 32)); end Unsigned_Mul_Extended; ---------------------------------------------------------------------------- procedure Signed_Mul_Extended(x, y : in Vkm_Int; msb, lsb : out Vkm_Int) is result : constant Vkm_Int64 := Vkm_Int64(x) * Vkm_Int64(y); begin lsb := To_Vkm_Int(Vkm_Uint(LSB32_MASK and To_Vkm_Uint64(result))); msb := To_Vkm_Int(Vkm_Uint(LSB32_MASK and Shift_Right(To_Vkm_Uint64(result), 32))); end Signed_Mul_Extended; ---------------------------------------------------------------------------- function Bitfield_Extract(value, offset, bits : in Vkm_Int) return Vkm_Int is value_bits : constant Vkm_Bits32 := To_Vkm_Bits32(value); result_bits : Vkm_Bits32 := (others => value_bits(Integer(offset + bits -1))); begin for bit_index in 0 .. bits - 1 loop result_bits(Integer(bit_index)) := value_bits(Integer(offset + bit_index)); end loop; return To_Vkm_Int(result_bits); end Bitfield_Extract; ---------------------------------------------------------------------------- function Bitfield_Extract(value : in Vkm_Uint; offset, bits : in Vkm_Int) return Vkm_Uint is value_bits : constant Vkm_Bits32 := To_Vkm_Bits32(value); result_bits : Vkm_Bits32 := (others => False); begin for bit_index in 0 .. bits - 1 loop result_bits(Integer(bit_index)) := value_bits(Integer(offset + bit_index)); end loop; return To_Vkm_Uint(result_bits); end Bitfield_Extract; ---------------------------------------------------------------------------- function Bitfield_Insert(base, insert, offset, bits : in Vkm_Int) return Vkm_Int is base_bits : Vkm_Bits32 := To_Vkm_Bits32(base); insert_bits : constant Vkm_Bits32 := To_Vkm_Bits32(insert); begin for bit_index in 0 .. bits - 1 loop base_bits(Integer(offset + bit_index)) := insert_bits(Integer(bit_index)); end loop; return To_Vkm_Int(base_bits); end Bitfield_Insert; ---------------------------------------------------------------------------- function Bitfield_Insert(base, insert : in Vkm_Uint; offset, bits : in Vkm_Int) return Vkm_Uint is base_bits : Vkm_Bits32 := To_Vkm_Bits32(base); insert_bits : constant Vkm_Bits32 := To_Vkm_Bits32(insert); begin for bit_index in 0 .. bits - 1 loop base_bits(Integer(offset + bit_index)) := insert_bits(Integer(bit_index)); end loop; return To_Vkm_Uint(base_bits); end Bitfield_Insert; ---------------------------------------------------------------------------- function Bitfield_Reverse(value : in Vkm_Int) return Vkm_Int is value_bits : constant Vkm_Bits32 := To_Vkm_Bits32(value); result_bits : Vkm_Bits32 := (others => False); begin for bit_index in 0 .. 31 loop result_bits(bit_index) := value_bits(31 - bit_index); end loop; return To_Vkm_Int(result_bits); end Bitfield_Reverse; ---------------------------------------------------------------------------- function Bitfield_Reverse(value : in Vkm_Uint) return Vkm_Uint is value_bits : constant Vkm_Bits32 := To_Vkm_Bits32(value); result_bits : Vkm_Bits32 := (others => False); begin for bit_index in 0 .. 31 loop result_bits(bit_index) := value_bits(31 - bit_index); end loop; return To_Vkm_Uint(result_bits); end Bitfield_Reverse; ---------------------------------------------------------------------------- function Bit_Count(value : in Vkm_Int) return Vkm_Int is value_bits : constant Vkm_Bits32 := To_Vkm_Bits32(value); result : Vkm_Int := 0; begin for bit_index in 0 .. 31 loop result := result + (if value_bits(bit_index) then 1 else 0); end loop; return result; end Bit_Count; ---------------------------------------------------------------------------- function Bit_Count(value : in Vkm_Uint) return Vkm_Int is value_bits : constant Vkm_Bits32 := To_Vkm_Bits32(value); result : Vkm_Int := 0; begin for bit_index in 0 .. 31 loop result := result + (if value_bits(bit_index) then 1 else 0); end loop; return result; end Bit_Count; ---------------------------------------------------------------------------- function Find_Lsb(value : in Vkm_Int) return Vkm_Int is value_bits : constant Vkm_Bits32 := To_Vkm_Bits32(value); result : Vkm_Int := -1; begin for bit_index in 0 .. 31 loop if value_bits(bit_index) then result := Vkm_Int(bit_index); end if; exit when result /= -1; end loop; return result; end Find_Lsb; ---------------------------------------------------------------------------- function Find_Lsb(value : in Vkm_Uint) return Vkm_Int is value_bits : constant Vkm_Bits32 := To_Vkm_Bits32(value); result : Vkm_Int := -1; begin for bit_index in 0 .. 31 loop if value_bits(bit_index) then result := Vkm_Int(bit_index); end if; exit when result /= -1; end loop; return result; end Find_Lsb; ---------------------------------------------------------------------------- function Find_Msb(value : in Vkm_Int) return Vkm_Int is value_bits : constant Vkm_Bits32 := To_Vkm_Bits32(value); result : Vkm_Int := -1; begin for bit_index in reverse 0 .. 31 loop if not value_bits(bit_index) then result := Vkm_Int(bit_index); end if; exit when result /= -1; end loop; return result; end Find_Msb; ---------------------------------------------------------------------------- function Find_Msb(value : in Vkm_Uint) return Vkm_Int is value_bits : constant Vkm_Bits32 := To_Vkm_Bits32(value); result : Vkm_Int := -1; begin for bit_index in reverse 0 .. 31 loop if value_bits(bit_index) then result := Vkm_Int(bit_index); end if; exit when result /= -1; end loop; return result; end Find_Msb; end Vulkan.Math.Integers;
osannolik/Ada_Drivers_Library
Ada
14,116
ads
-- This spec has been automatically generated from STM32F446x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.DAC is pragma Preelaborate; --------------- -- Registers -- --------------- subtype CR_TSEL1_Field is HAL.UInt3; subtype CR_WAVE1_Field is HAL.UInt2; subtype CR_MAMP1_Field is HAL.UInt4; subtype CR_TSEL2_Field is HAL.UInt3; subtype CR_WAVE2_Field is HAL.UInt2; subtype CR_MAMP2_Field is HAL.UInt4; -- control register type CR_Register is record -- DAC channel1 enable EN1 : Boolean := False; -- DAC channel1 output buffer disable BOFF1 : Boolean := False; -- DAC channel1 trigger enable TEN1 : Boolean := False; -- DAC channel1 trigger selection TSEL1 : CR_TSEL1_Field := 16#0#; -- DAC channel1 noise/triangle wave generation enable WAVE1 : CR_WAVE1_Field := 16#0#; -- DAC channel1 mask/amplitude selector MAMP1 : CR_MAMP1_Field := 16#0#; -- DAC channel1 DMA enable DMAEN1 : Boolean := False; -- DAC channel1 DMA Underrun Interrupt enable DMAUDRIE1 : Boolean := False; -- unspecified Reserved_14_15 : HAL.UInt2 := 16#0#; -- DAC channel2 enable EN2 : Boolean := False; -- DAC channel2 output buffer disable BOFF2 : Boolean := False; -- DAC channel2 trigger enable TEN2 : Boolean := False; -- DAC channel2 trigger selection TSEL2 : CR_TSEL2_Field := 16#0#; -- DAC channel2 noise/triangle wave generation enable WAVE2 : CR_WAVE2_Field := 16#0#; -- DAC channel2 mask/amplitude selector MAMP2 : CR_MAMP2_Field := 16#0#; -- DAC channel2 DMA enable DMAEN2 : Boolean := False; -- DAC channel2 DMA underrun interrupt enable DMAUDRIE2 : Boolean := False; -- unspecified Reserved_30_31 : HAL.UInt2 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR_Register use record EN1 at 0 range 0 .. 0; BOFF1 at 0 range 1 .. 1; TEN1 at 0 range 2 .. 2; TSEL1 at 0 range 3 .. 5; WAVE1 at 0 range 6 .. 7; MAMP1 at 0 range 8 .. 11; DMAEN1 at 0 range 12 .. 12; DMAUDRIE1 at 0 range 13 .. 13; Reserved_14_15 at 0 range 14 .. 15; EN2 at 0 range 16 .. 16; BOFF2 at 0 range 17 .. 17; TEN2 at 0 range 18 .. 18; TSEL2 at 0 range 19 .. 21; WAVE2 at 0 range 22 .. 23; MAMP2 at 0 range 24 .. 27; DMAEN2 at 0 range 28 .. 28; DMAUDRIE2 at 0 range 29 .. 29; Reserved_30_31 at 0 range 30 .. 31; end record; -- SWTRIGR_SWTRIG array type SWTRIGR_SWTRIG_Field_Array is array (1 .. 2) of Boolean with Component_Size => 1, Size => 2; -- Type definition for SWTRIGR_SWTRIG type SWTRIGR_SWTRIG_Field (As_Array : Boolean := False) is record case As_Array is when False => -- SWTRIG as a value Val : HAL.UInt2; when True => -- SWTRIG as an array Arr : SWTRIGR_SWTRIG_Field_Array; end case; end record with Unchecked_Union, Size => 2; for SWTRIGR_SWTRIG_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; -- software trigger register type SWTRIGR_Register is record -- Write-only. DAC channel1 software trigger SWTRIG : SWTRIGR_SWTRIG_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_2_31 : HAL.UInt30 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SWTRIGR_Register use record SWTRIG at 0 range 0 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; subtype DHR12R1_DACC1DHR_Field is HAL.UInt12; -- channel1 12-bit right-aligned data holding register type DHR12R1_Register is record -- DAC channel1 12-bit right-aligned data DACC1DHR : DHR12R1_DACC1DHR_Field := 16#0#; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DHR12R1_Register use record DACC1DHR at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; subtype DHR12L1_DACC1DHR_Field is HAL.UInt12; -- channel1 12-bit left aligned data holding register type DHR12L1_Register is record -- unspecified Reserved_0_3 : HAL.UInt4 := 16#0#; -- DAC channel1 12-bit left-aligned data DACC1DHR : DHR12L1_DACC1DHR_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DHR12L1_Register use record Reserved_0_3 at 0 range 0 .. 3; DACC1DHR at 0 range 4 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype DHR8R1_DACC1DHR_Field is HAL.UInt8; -- channel1 8-bit right aligned data holding register type DHR8R1_Register is record -- DAC channel1 8-bit right-aligned data DACC1DHR : DHR8R1_DACC1DHR_Field := 16#0#; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DHR8R1_Register use record DACC1DHR at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype DHR12R2_DACC2DHR_Field is HAL.UInt12; -- channel2 12-bit right aligned data holding register type DHR12R2_Register is record -- DAC channel2 12-bit right-aligned data DACC2DHR : DHR12R2_DACC2DHR_Field := 16#0#; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DHR12R2_Register use record DACC2DHR at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; subtype DHR12L2_DACC2DHR_Field is HAL.UInt12; -- channel2 12-bit left aligned data holding register type DHR12L2_Register is record -- unspecified Reserved_0_3 : HAL.UInt4 := 16#0#; -- DAC channel2 12-bit left-aligned data DACC2DHR : DHR12L2_DACC2DHR_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DHR12L2_Register use record Reserved_0_3 at 0 range 0 .. 3; DACC2DHR at 0 range 4 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype DHR8R2_DACC2DHR_Field is HAL.UInt8; -- channel2 8-bit right-aligned data holding register type DHR8R2_Register is record -- DAC channel2 8-bit right-aligned data DACC2DHR : DHR8R2_DACC2DHR_Field := 16#0#; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DHR8R2_Register use record DACC2DHR at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype DHR12RD_DACC1DHR_Field is HAL.UInt12; subtype DHR12RD_DACC2DHR_Field is HAL.UInt12; -- Dual DAC 12-bit right-aligned data holding register type DHR12RD_Register is record -- DAC channel1 12-bit right-aligned data DACC1DHR : DHR12RD_DACC1DHR_Field := 16#0#; -- unspecified Reserved_12_15 : HAL.UInt4 := 16#0#; -- DAC channel2 12-bit right-aligned data DACC2DHR : DHR12RD_DACC2DHR_Field := 16#0#; -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DHR12RD_Register use record DACC1DHR at 0 range 0 .. 11; Reserved_12_15 at 0 range 12 .. 15; DACC2DHR at 0 range 16 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; subtype DHR12LD_DACC1DHR_Field is HAL.UInt12; subtype DHR12LD_DACC2DHR_Field is HAL.UInt12; -- DUAL DAC 12-bit left aligned data holding register type DHR12LD_Register is record -- unspecified Reserved_0_3 : HAL.UInt4 := 16#0#; -- DAC channel1 12-bit left-aligned data DACC1DHR : DHR12LD_DACC1DHR_Field := 16#0#; -- unspecified Reserved_16_19 : HAL.UInt4 := 16#0#; -- DAC channel2 12-bit left-aligned data DACC2DHR : DHR12LD_DACC2DHR_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DHR12LD_Register use record Reserved_0_3 at 0 range 0 .. 3; DACC1DHR at 0 range 4 .. 15; Reserved_16_19 at 0 range 16 .. 19; DACC2DHR at 0 range 20 .. 31; end record; subtype DHR8RD_DACC1DHR_Field is HAL.UInt8; subtype DHR8RD_DACC2DHR_Field is HAL.UInt8; -- DUAL DAC 8-bit right aligned data holding register type DHR8RD_Register is record -- DAC channel1 8-bit right-aligned data DACC1DHR : DHR8RD_DACC1DHR_Field := 16#0#; -- DAC channel2 8-bit right-aligned data DACC2DHR : DHR8RD_DACC2DHR_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DHR8RD_Register use record DACC1DHR at 0 range 0 .. 7; DACC2DHR at 0 range 8 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype DOR1_DACC1DOR_Field is HAL.UInt12; -- channel1 data output register type DOR1_Register is record -- Read-only. DAC channel1 data output DACC1DOR : DOR1_DACC1DOR_Field; -- unspecified Reserved_12_31 : HAL.UInt20; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DOR1_Register use record DACC1DOR at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; subtype DOR2_DACC2DOR_Field is HAL.UInt12; -- channel2 data output register type DOR2_Register is record -- Read-only. DAC channel2 data output DACC2DOR : DOR2_DACC2DOR_Field; -- unspecified Reserved_12_31 : HAL.UInt20; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DOR2_Register use record DACC2DOR at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; -- status register type SR_Register is record -- unspecified Reserved_0_12 : HAL.UInt13 := 16#0#; -- DAC channel1 DMA underrun flag DMAUDR1 : Boolean := False; -- unspecified Reserved_14_28 : HAL.UInt15 := 16#0#; -- DAC channel2 DMA underrun flag DMAUDR2 : Boolean := False; -- unspecified Reserved_30_31 : HAL.UInt2 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SR_Register use record Reserved_0_12 at 0 range 0 .. 12; DMAUDR1 at 0 range 13 .. 13; Reserved_14_28 at 0 range 14 .. 28; DMAUDR2 at 0 range 29 .. 29; Reserved_30_31 at 0 range 30 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Digital-to-analog converter type DAC_Peripheral is record -- control register CR : aliased CR_Register; -- software trigger register SWTRIGR : aliased SWTRIGR_Register; -- channel1 12-bit right-aligned data holding register DHR12R1 : aliased DHR12R1_Register; -- channel1 12-bit left aligned data holding register DHR12L1 : aliased DHR12L1_Register; -- channel1 8-bit right aligned data holding register DHR8R1 : aliased DHR8R1_Register; -- channel2 12-bit right aligned data holding register DHR12R2 : aliased DHR12R2_Register; -- channel2 12-bit left aligned data holding register DHR12L2 : aliased DHR12L2_Register; -- channel2 8-bit right-aligned data holding register DHR8R2 : aliased DHR8R2_Register; -- Dual DAC 12-bit right-aligned data holding register DHR12RD : aliased DHR12RD_Register; -- DUAL DAC 12-bit left aligned data holding register DHR12LD : aliased DHR12LD_Register; -- DUAL DAC 8-bit right aligned data holding register DHR8RD : aliased DHR8RD_Register; -- channel1 data output register DOR1 : aliased DOR1_Register; -- channel2 data output register DOR2 : aliased DOR2_Register; -- status register SR : aliased SR_Register; end record with Volatile; for DAC_Peripheral use record CR at 16#0# range 0 .. 31; SWTRIGR at 16#4# range 0 .. 31; DHR12R1 at 16#8# range 0 .. 31; DHR12L1 at 16#C# range 0 .. 31; DHR8R1 at 16#10# range 0 .. 31; DHR12R2 at 16#14# range 0 .. 31; DHR12L2 at 16#18# range 0 .. 31; DHR8R2 at 16#1C# range 0 .. 31; DHR12RD at 16#20# range 0 .. 31; DHR12LD at 16#24# range 0 .. 31; DHR8RD at 16#28# range 0 .. 31; DOR1 at 16#2C# range 0 .. 31; DOR2 at 16#30# range 0 .. 31; SR at 16#34# range 0 .. 31; end record; -- Digital-to-analog converter DAC_Periph : aliased DAC_Peripheral with Import, Address => System'To_Address (16#40007400#); end STM32_SVD.DAC;
RREE/ada-util
Ada
2,306
adb
----------------------------------------------------------------------- -- util-beans-vectors -- Object vectors -- Copyright (C) 2011, 2017, 2019 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- 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 Util.Beans.Objects.Vectors is -- ------------------------------ -- Get the value identified by the name. -- If the name cannot be found, the method should return the Null object. -- ------------------------------ function Get_Value (From : in Vector_Bean; Name : in String) return Object is begin if Name = "count" then return To_Object (Natural (From.Length)); else return Null_Object; end if; end Get_Value; -- ------------------------------ -- Get the number of elements in the list. -- ------------------------------ overriding function Get_Count (From : in Vector_Bean) return Natural is begin return Natural (From.Length); end Get_Count; -- ------------------------------ -- Get the element at the given position. -- ------------------------------ overriding function Get_Row (From : in Vector_Bean; Position : in Natural) return Util.Beans.Objects.Object is begin return From.Element (Position); end Get_Row; -- ----------------------- -- Create an object that contains a <tt>Vector_Bean</tt> instance. -- ----------------------- function Create return Object is M : constant Vector_Bean_Access := new Vector_Bean; begin return To_Object (Value => M, Storage => DYNAMIC); end Create; end Util.Beans.Objects.Vectors;
onox/orka
Ada
2,001
adb
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2016 onox <[email protected]> -- -- 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 Orka.SIMD.SSE2.Doubles.Compare; with Orka.SIMD.SSE2.Doubles.Logical; with Orka.SIMD.SSE2.Doubles.Swizzle; package body Orka.SIMD.SSE2.Doubles.Arithmetic is function Divide_Or_Zero (Left, Right : m128d) return m128d is use SIMD.SSE2.Doubles.Compare; use SIMD.SSE2.Doubles.Logical; -- Create a mask with all 1's for each element that is non-zero Zero : constant m128d := (0.0, 0.0); Mask : constant m128d := Zero /= Right; Normalized : constant m128d := Left / Right; begin -- Any element in Right that is zero will result in a -- corresponding element consisting of all 0's in the Mask. -- This will avoid the divide-by-zero exception when dividing. return Mask and Normalized; end Divide_Or_Zero; function "abs" (Elements : m128d) return m128d is use SIMD.SSE2.Doubles.Logical; begin return And_Not ((-0.0, -0.0), Elements); end "abs"; function Sum (Elements : m128d) return Float_64 is use SIMD.SSE2.Doubles.Swizzle; -- Based on SIMD.SSE.Singles.Arithmetic.Sum Mask_1_0 : constant := 1 + 0 * 2; Shuffled : constant m128d := Shuffle (Elements, Elements, Mask_1_0); Sum : constant m128d := Elements + Shuffled; begin return Sum (X); end Sum; end Orka.SIMD.SSE2.Doubles.Arithmetic;
onox/orka
Ada
1,095
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2021 onox <[email protected]> -- -- 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 Orka.SIMD.AVX.Singles; package Orka.SIMD.AVX.Integers.Convert is pragma Pure; use SIMD.AVX.Singles; function Convert (Elements : m256) return m256i with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_cvtps2dq256"; function Convert (Elements : m256i) return m256 with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_cvtdq2ps256"; end Orka.SIMD.AVX.Integers.Convert;
tum-ei-rcs/StratoX
Ada
173
adb
with Constants; use constants; with Interfaces; use Interfaces; with Ada.Real_Time; use Ada.Real_Time; procedure main with SPARK_Mode is begin Do_Something; end main;
charlie5/lace
Ada
3,393
ads
with gel.Joint, gel.Sprite, physics.Joint.slider, physics.Space; package gel.slider_Joint -- -- Allows sprites to be connected via a slider joint. -- is type Item is new gel.Joint.Item with private; type View is access all Item'Class; type Views is array (math.Index range <>) of View; Sway : constant Joint.Degree_of_freedom := 1; -- TODO: These are duplicated. Heave : constant Joint.Degree_of_freedom := 2; Surge : constant Joint.Degree_of_freedom := 3; Pitch : constant Joint.Degree_of_freedom := 4; Yaw : constant Joint.Degree_of_freedom := 5; Roll : constant Joint.Degree_of_freedom := 6; package std_physics renames standard.Physics; use Math; --------- --- Forge -- procedure define (Self : access Item; in_Space : in std_physics.Space.view; Sprite_A, Sprite_B : access gel.Sprite.item'Class; pivot_Anchor : in Vector_3; pivot_Axis : in Matrix_3x3); procedure define (Self : access Item; in_Space : in std_physics.Space.view; Sprite_A, Sprite_B : access gel.Sprite.item'Class; Frame_A, Frame_B : in Matrix_4x4); overriding procedure destroy (Self : in out Item); -------------- --- Attributes -- overriding function Physics (Self : in Item) return gel.Joint.Physics_view; overriding function Frame_A (Self : in Item) return Matrix_4x4; overriding function Frame_B (Self : in Item) return Matrix_4x4; overriding procedure Frame_A_is (Self : in out Item; Now : in Matrix_4x4); overriding procedure Frame_B_is (Self : in out Item; Now : in Matrix_4x4); overriding function Degrees_of_freedom (Self : in Item) return Joint.Degree_of_freedom; -- Bounds - limits the range of motion for a Degree of freedom. -- overriding function is_Bound (Self : in Item; for_Degree : in Joint.Degree_of_freedom) return Boolean; overriding function low_Bound (Self : access Item; for_Degree : in Joint.Degree_of_freedom) return Real; overriding procedure low_Bound_is (Self : access Item; for_Degree : in Joint.Degree_of_freedom; Now : in Real); overriding function high_Bound (Self : access Item; for_Degree : in Joint.Degree_of_freedom) return Real; overriding procedure high_Bound_is (Self : access Item; for_Degree : in Joint.Degree_of_freedom; Now : in Real); overriding function Extent (Self : in Item; for_Degree : in Joint.Degree_of_freedom) return Real; overriding procedure Velocity_is (Self : in Item; for_Degree : in Joint.Degree_of_freedom; Now : in Real); -------------- --- Operations -- -- Nil. private type physics_slider_Joint_view is access all std_physics.Joint.slider.item'Class; type Item is new gel.Joint.Item with record Physics : access std_physics.Joint.slider.item'Class; end record; end gel.slider_Joint;
crssnky/Ada
Ada
102
adb
with Ada.Text_IO; use Ada.Text_IO; procedure helloworld is begin Put("Helloworld!"); end helloworld;
AdaCore/gpr
Ada
2,955
adb
-- -- Copyright (C) 2021-2023, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-Exception -- package body GPR2.Project.Source.Part_Set is ----------- -- Clear -- ----------- procedure Clear (Self : in out Object) is begin if Self.Sorted then Self.SS.Clear; else Self.HS.Clear; end if; end Clear; function Constant_Reference (Self : aliased Object; Position : Cursor) return Constant_Reference_Type is begin if Self.Sorted then declare Ref : constant Source_Part_Ordered_Sets.Constant_Reference_Type := Self.SS.Constant_Reference (Position.SC); begin return (Part => Ref.Element.all'Unrestricted_Access, Sorted => True, SRef => Ref); end; else declare Ref : constant Source_Part_Hashed_Sets.Constant_Reference_Type := Self.HS.Constant_Reference (Position.HC); begin return (Part => Ref.Element.all'Unrestricted_Access, Sorted => False, HRef => Ref); end; end if; end Constant_Reference; ------------ -- Insert -- ------------ procedure Insert (Self : in out Object; Element : Source_Part) is begin if Self.Sorted then Self.SS.Insert (Element); else Self.HS.Insert (Element); end if; end Insert; procedure Insert (Self : in out Object; Element : Source_Part; Position : out Cursor; Inserted : out Boolean) is begin if Self.Sorted then Position := (Sorted => True, SC => Source_Part_Ordered_Sets.No_Element); Self.SS.Insert (Element, Position.SC, Inserted); else Position := (Sorted => False, HC => Source_Part_Hashed_Sets.No_Element); Self.HS.Insert (Element, Position.HC, Inserted); end if; end Insert; ------------- -- Iterate -- ------------- function Iterate (Self : Object) return Source_Part_Iterator.Forward_Iterator'Class is begin if Self.Sorted then return Iterator'(Sorted => True, SRoot => Self.SS'Unchecked_Access); else return Iterator'(Sorted => False, HRoot => Self.HS'Unchecked_Access); end if; end Iterate; ----------- -- Union -- ----------- procedure Union (Self : in out Object; Other : Object) is C : Cursor; Inserted : Boolean; begin if Self.Sorted /= Other.Sorted then for Item of Other loop Self.Insert (Item, C, Inserted); end loop; elsif Self.Sorted then Self.SS.Union (Other.SS); else Self.HS.Union (Other.HS); end if; end Union; end GPR2.Project.Source.Part_Set;
charlie5/aIDE
Ada
1,063
ads
with Ada.Streams; package AdaM.a_Type.universal_type is type Item is new a_Type.item with private; type View is access all Item'Class; -- Forge -- function new_Type (Name : in String := "") return universal_type.view; overriding procedure destruct (Self : in out Item); procedure free (Self : in out universal_type.view); -- Attributes -- overriding function Id (Self : access Item) return AdaM.Id; overriding function to_Source (Self : in Item) return text_Vectors.Vector; private type Item is new a_Type.elementary_Type with record null; end record; -- Streams -- procedure View_write (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : in View); procedure View_read (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : out View); for View'write use View_write; for View'read use View_read; end AdaM.a_Type.universal_type;
optikos/oasis
Ada
42,671
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Elements.Pragmas; with Program.Elements.Defining_Identifiers; with Program.Elements.Defining_Character_Literals; with Program.Elements.Defining_Operator_Symbols; with Program.Elements.Defining_Expanded_Names; with Program.Elements.Type_Declarations; with Program.Elements.Task_Type_Declarations; with Program.Elements.Protected_Type_Declarations; with Program.Elements.Subtype_Declarations; with Program.Elements.Object_Declarations; with Program.Elements.Single_Task_Declarations; with Program.Elements.Single_Protected_Declarations; with Program.Elements.Number_Declarations; with Program.Elements.Enumeration_Literal_Specifications; with Program.Elements.Discriminant_Specifications; with Program.Elements.Component_Declarations; with Program.Elements.Loop_Parameter_Specifications; with Program.Elements.Generalized_Iterator_Specifications; with Program.Elements.Element_Iterator_Specifications; with Program.Elements.Procedure_Declarations; with Program.Elements.Function_Declarations; with Program.Elements.Parameter_Specifications; with Program.Elements.Procedure_Body_Declarations; with Program.Elements.Function_Body_Declarations; with Program.Elements.Return_Object_Specifications; with Program.Elements.Package_Declarations; with Program.Elements.Package_Body_Declarations; with Program.Elements.Object_Renaming_Declarations; with Program.Elements.Exception_Renaming_Declarations; with Program.Elements.Procedure_Renaming_Declarations; with Program.Elements.Function_Renaming_Declarations; with Program.Elements.Package_Renaming_Declarations; with Program.Elements.Generic_Package_Renaming_Declarations; with Program.Elements.Generic_Procedure_Renaming_Declarations; with Program.Elements.Generic_Function_Renaming_Declarations; with Program.Elements.Task_Body_Declarations; with Program.Elements.Protected_Body_Declarations; with Program.Elements.Entry_Declarations; with Program.Elements.Entry_Body_Declarations; with Program.Elements.Entry_Index_Specifications; with Program.Elements.Procedure_Body_Stubs; with Program.Elements.Function_Body_Stubs; with Program.Elements.Package_Body_Stubs; with Program.Elements.Task_Body_Stubs; with Program.Elements.Protected_Body_Stubs; with Program.Elements.Exception_Declarations; with Program.Elements.Choice_Parameter_Specifications; with Program.Elements.Generic_Package_Declarations; with Program.Elements.Generic_Procedure_Declarations; with Program.Elements.Generic_Function_Declarations; with Program.Elements.Package_Instantiations; with Program.Elements.Procedure_Instantiations; with Program.Elements.Function_Instantiations; with Program.Elements.Formal_Object_Declarations; with Program.Elements.Formal_Type_Declarations; with Program.Elements.Formal_Procedure_Declarations; with Program.Elements.Formal_Function_Declarations; with Program.Elements.Formal_Package_Declarations; with Program.Elements.Subtype_Indications; with Program.Elements.Component_Definitions; with Program.Elements.Discrete_Subtype_Indications; with Program.Elements.Discrete_Range_Attribute_References; with Program.Elements.Discrete_Simple_Expression_Ranges; with Program.Elements.Unknown_Discriminant_Parts; with Program.Elements.Known_Discriminant_Parts; with Program.Elements.Record_Definitions; with Program.Elements.Null_Components; with Program.Elements.Variant_Parts; with Program.Elements.Variants; with Program.Elements.Others_Choices; with Program.Elements.Anonymous_Access_To_Objects; with Program.Elements.Anonymous_Access_To_Procedures; with Program.Elements.Anonymous_Access_To_Functions; with Program.Elements.Private_Type_Definitions; with Program.Elements.Private_Extension_Definitions; with Program.Elements.Incomplete_Type_Definitions; with Program.Elements.Task_Definitions; with Program.Elements.Protected_Definitions; with Program.Elements.Aspect_Specifications; with Program.Elements.Real_Range_Specifications; with Program.Elements.Numeric_Literals; with Program.Elements.String_Literals; with Program.Elements.Identifiers; with Program.Elements.Operator_Symbols; with Program.Elements.Character_Literals; with Program.Elements.Explicit_Dereferences; with Program.Elements.Infix_Operators; with Program.Elements.Function_Calls; with Program.Elements.Indexed_Components; with Program.Elements.Slices; with Program.Elements.Selected_Components; with Program.Elements.Attribute_References; with Program.Elements.Record_Aggregates; with Program.Elements.Extension_Aggregates; with Program.Elements.Array_Aggregates; with Program.Elements.Short_Circuit_Operations; with Program.Elements.Membership_Tests; with Program.Elements.Null_Literals; with Program.Elements.Parenthesized_Expressions; with Program.Elements.Raise_Expressions; with Program.Elements.Type_Conversions; with Program.Elements.Qualified_Expressions; with Program.Elements.Allocators; with Program.Elements.Case_Expressions; with Program.Elements.If_Expressions; with Program.Elements.Quantified_Expressions; with Program.Elements.Discriminant_Associations; with Program.Elements.Record_Component_Associations; with Program.Elements.Array_Component_Associations; with Program.Elements.Parameter_Associations; with Program.Elements.Formal_Package_Associations; with Program.Elements.Null_Statements; with Program.Elements.Assignment_Statements; with Program.Elements.If_Statements; with Program.Elements.Case_Statements; with Program.Elements.Loop_Statements; with Program.Elements.While_Loop_Statements; with Program.Elements.For_Loop_Statements; with Program.Elements.Block_Statements; with Program.Elements.Exit_Statements; with Program.Elements.Goto_Statements; with Program.Elements.Call_Statements; with Program.Elements.Simple_Return_Statements; with Program.Elements.Extended_Return_Statements; with Program.Elements.Accept_Statements; with Program.Elements.Requeue_Statements; with Program.Elements.Delay_Statements; with Program.Elements.Terminate_Alternative_Statements; with Program.Elements.Select_Statements; with Program.Elements.Abort_Statements; with Program.Elements.Raise_Statements; with Program.Elements.Code_Statements; with Program.Elements.Elsif_Paths; with Program.Elements.Case_Paths; with Program.Elements.Select_Paths; with Program.Elements.Case_Expression_Paths; with Program.Elements.Elsif_Expression_Paths; with Program.Elements.Use_Clauses; with Program.Elements.With_Clauses; with Program.Elements.Component_Clauses; with Program.Elements.Derived_Types; with Program.Elements.Derived_Record_Extensions; with Program.Elements.Enumeration_Types; with Program.Elements.Signed_Integer_Types; with Program.Elements.Modular_Types; with Program.Elements.Root_Types; with Program.Elements.Floating_Point_Types; with Program.Elements.Ordinary_Fixed_Point_Types; with Program.Elements.Decimal_Fixed_Point_Types; with Program.Elements.Unconstrained_Array_Types; with Program.Elements.Constrained_Array_Types; with Program.Elements.Record_Types; with Program.Elements.Interface_Types; with Program.Elements.Object_Access_Types; with Program.Elements.Procedure_Access_Types; with Program.Elements.Function_Access_Types; with Program.Elements.Formal_Private_Type_Definitions; with Program.Elements.Formal_Derived_Type_Definitions; with Program.Elements.Formal_Discrete_Type_Definitions; with Program.Elements.Formal_Signed_Integer_Type_Definitions; with Program.Elements.Formal_Modular_Type_Definitions; with Program.Elements.Formal_Floating_Point_Definitions; with Program.Elements.Formal_Ordinary_Fixed_Point_Definitions; with Program.Elements.Formal_Decimal_Fixed_Point_Definitions; with Program.Elements.Formal_Unconstrained_Array_Types; with Program.Elements.Formal_Constrained_Array_Types; with Program.Elements.Formal_Object_Access_Types; with Program.Elements.Formal_Procedure_Access_Types; with Program.Elements.Formal_Function_Access_Types; with Program.Elements.Formal_Interface_Types; with Program.Elements.Range_Attribute_References; with Program.Elements.Simple_Expression_Ranges; with Program.Elements.Digits_Constraints; with Program.Elements.Delta_Constraints; with Program.Elements.Index_Constraints; with Program.Elements.Discriminant_Constraints; with Program.Elements.Attribute_Definition_Clauses; with Program.Elements.Enumeration_Representation_Clauses; with Program.Elements.Record_Representation_Clauses; with Program.Elements.At_Clauses; with Program.Elements.Exception_Handlers; package Program.Element_Visitors is pragma Pure (Program.Element_Visitors); type Element_Visitor is limited interface; procedure Pragma_Element (Self : in out Element_Visitor; Element : not null Program.Elements.Pragmas.Pragma_Access) is null; procedure Defining_Identifier (Self : in out Element_Visitor; Element : not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access) is null; procedure Defining_Character_Literal (Self : in out Element_Visitor; Element : not null Program.Elements.Defining_Character_Literals .Defining_Character_Literal_Access) is null; procedure Defining_Operator_Symbol (Self : in out Element_Visitor; Element : not null Program.Elements.Defining_Operator_Symbols .Defining_Operator_Symbol_Access) is null; procedure Defining_Expanded_Name (Self : in out Element_Visitor; Element : not null Program.Elements.Defining_Expanded_Names .Defining_Expanded_Name_Access) is null; procedure Type_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Type_Declarations .Type_Declaration_Access) is null; procedure Task_Type_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Task_Type_Declarations .Task_Type_Declaration_Access) is null; procedure Protected_Type_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Protected_Type_Declarations .Protected_Type_Declaration_Access) is null; procedure Subtype_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Subtype_Declarations .Subtype_Declaration_Access) is null; procedure Object_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Object_Declarations .Object_Declaration_Access) is null; procedure Single_Task_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Single_Task_Declarations .Single_Task_Declaration_Access) is null; procedure Single_Protected_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Single_Protected_Declarations .Single_Protected_Declaration_Access) is null; procedure Number_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Number_Declarations .Number_Declaration_Access) is null; procedure Enumeration_Literal_Specification (Self : in out Element_Visitor; Element : not null Program.Elements.Enumeration_Literal_Specifications .Enumeration_Literal_Specification_Access) is null; procedure Discriminant_Specification (Self : in out Element_Visitor; Element : not null Program.Elements.Discriminant_Specifications .Discriminant_Specification_Access) is null; procedure Component_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Component_Declarations .Component_Declaration_Access) is null; procedure Loop_Parameter_Specification (Self : in out Element_Visitor; Element : not null Program.Elements.Loop_Parameter_Specifications .Loop_Parameter_Specification_Access) is null; procedure Generalized_Iterator_Specification (Self : in out Element_Visitor; Element : not null Program.Elements.Generalized_Iterator_Specifications .Generalized_Iterator_Specification_Access) is null; procedure Element_Iterator_Specification (Self : in out Element_Visitor; Element : not null Program.Elements.Element_Iterator_Specifications .Element_Iterator_Specification_Access) is null; procedure Procedure_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Procedure_Declarations .Procedure_Declaration_Access) is null; procedure Function_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Function_Declarations .Function_Declaration_Access) is null; procedure Parameter_Specification (Self : in out Element_Visitor; Element : not null Program.Elements.Parameter_Specifications .Parameter_Specification_Access) is null; procedure Procedure_Body_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Procedure_Body_Declarations .Procedure_Body_Declaration_Access) is null; procedure Function_Body_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Function_Body_Declarations .Function_Body_Declaration_Access) is null; procedure Return_Object_Specification (Self : in out Element_Visitor; Element : not null Program.Elements.Return_Object_Specifications .Return_Object_Specification_Access) is null; procedure Package_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Package_Declarations .Package_Declaration_Access) is null; procedure Package_Body_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Package_Body_Declarations .Package_Body_Declaration_Access) is null; procedure Object_Renaming_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Object_Renaming_Declarations .Object_Renaming_Declaration_Access) is null; procedure Exception_Renaming_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Exception_Renaming_Declarations .Exception_Renaming_Declaration_Access) is null; procedure Procedure_Renaming_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Procedure_Renaming_Declarations .Procedure_Renaming_Declaration_Access) is null; procedure Function_Renaming_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Function_Renaming_Declarations .Function_Renaming_Declaration_Access) is null; procedure Package_Renaming_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Package_Renaming_Declarations .Package_Renaming_Declaration_Access) is null; procedure Generic_Package_Renaming_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Generic_Package_Renaming_Declarations .Generic_Package_Renaming_Declaration_Access) is null; procedure Generic_Procedure_Renaming_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements .Generic_Procedure_Renaming_Declarations .Generic_Procedure_Renaming_Declaration_Access) is null; procedure Generic_Function_Renaming_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Generic_Function_Renaming_Declarations .Generic_Function_Renaming_Declaration_Access) is null; procedure Task_Body_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Task_Body_Declarations .Task_Body_Declaration_Access) is null; procedure Protected_Body_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Protected_Body_Declarations .Protected_Body_Declaration_Access) is null; procedure Entry_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Entry_Declarations .Entry_Declaration_Access) is null; procedure Entry_Body_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Entry_Body_Declarations .Entry_Body_Declaration_Access) is null; procedure Entry_Index_Specification (Self : in out Element_Visitor; Element : not null Program.Elements.Entry_Index_Specifications .Entry_Index_Specification_Access) is null; procedure Procedure_Body_Stub (Self : in out Element_Visitor; Element : not null Program.Elements.Procedure_Body_Stubs .Procedure_Body_Stub_Access) is null; procedure Function_Body_Stub (Self : in out Element_Visitor; Element : not null Program.Elements.Function_Body_Stubs .Function_Body_Stub_Access) is null; procedure Package_Body_Stub (Self : in out Element_Visitor; Element : not null Program.Elements.Package_Body_Stubs .Package_Body_Stub_Access) is null; procedure Task_Body_Stub (Self : in out Element_Visitor; Element : not null Program.Elements.Task_Body_Stubs.Task_Body_Stub_Access) is null; procedure Protected_Body_Stub (Self : in out Element_Visitor; Element : not null Program.Elements.Protected_Body_Stubs .Protected_Body_Stub_Access) is null; procedure Exception_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Exception_Declarations .Exception_Declaration_Access) is null; procedure Choice_Parameter_Specification (Self : in out Element_Visitor; Element : not null Program.Elements.Choice_Parameter_Specifications .Choice_Parameter_Specification_Access) is null; procedure Generic_Package_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Generic_Package_Declarations .Generic_Package_Declaration_Access) is null; procedure Generic_Procedure_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Generic_Procedure_Declarations .Generic_Procedure_Declaration_Access) is null; procedure Generic_Function_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Generic_Function_Declarations .Generic_Function_Declaration_Access) is null; procedure Package_Instantiation (Self : in out Element_Visitor; Element : not null Program.Elements.Package_Instantiations .Package_Instantiation_Access) is null; procedure Procedure_Instantiation (Self : in out Element_Visitor; Element : not null Program.Elements.Procedure_Instantiations .Procedure_Instantiation_Access) is null; procedure Function_Instantiation (Self : in out Element_Visitor; Element : not null Program.Elements.Function_Instantiations .Function_Instantiation_Access) is null; procedure Formal_Object_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Formal_Object_Declarations .Formal_Object_Declaration_Access) is null; procedure Formal_Type_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Formal_Type_Declarations .Formal_Type_Declaration_Access) is null; procedure Formal_Procedure_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Formal_Procedure_Declarations .Formal_Procedure_Declaration_Access) is null; procedure Formal_Function_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Formal_Function_Declarations .Formal_Function_Declaration_Access) is null; procedure Formal_Package_Declaration (Self : in out Element_Visitor; Element : not null Program.Elements.Formal_Package_Declarations .Formal_Package_Declaration_Access) is null; procedure Subtype_Indication (Self : in out Element_Visitor; Element : not null Program.Elements.Subtype_Indications .Subtype_Indication_Access) is null; procedure Component_Definition (Self : in out Element_Visitor; Element : not null Program.Elements.Component_Definitions .Component_Definition_Access) is null; procedure Discrete_Subtype_Indication (Self : in out Element_Visitor; Element : not null Program.Elements.Discrete_Subtype_Indications .Discrete_Subtype_Indication_Access) is null; procedure Discrete_Range_Attribute_Reference (Self : in out Element_Visitor; Element : not null Program.Elements.Discrete_Range_Attribute_References .Discrete_Range_Attribute_Reference_Access) is null; procedure Discrete_Simple_Expression_Range (Self : in out Element_Visitor; Element : not null Program.Elements.Discrete_Simple_Expression_Ranges .Discrete_Simple_Expression_Range_Access) is null; procedure Unknown_Discriminant_Part (Self : in out Element_Visitor; Element : not null Program.Elements.Unknown_Discriminant_Parts .Unknown_Discriminant_Part_Access) is null; procedure Known_Discriminant_Part (Self : in out Element_Visitor; Element : not null Program.Elements.Known_Discriminant_Parts .Known_Discriminant_Part_Access) is null; procedure Record_Definition (Self : in out Element_Visitor; Element : not null Program.Elements.Record_Definitions .Record_Definition_Access) is null; procedure Null_Component (Self : in out Element_Visitor; Element : not null Program.Elements.Null_Components.Null_Component_Access) is null; procedure Variant_Part (Self : in out Element_Visitor; Element : not null Program.Elements.Variant_Parts.Variant_Part_Access) is null; procedure Variant (Self : in out Element_Visitor; Element : not null Program.Elements.Variants.Variant_Access) is null; procedure Others_Choice (Self : in out Element_Visitor; Element : not null Program.Elements.Others_Choices.Others_Choice_Access) is null; procedure Anonymous_Access_To_Object (Self : in out Element_Visitor; Element : not null Program.Elements.Anonymous_Access_To_Objects .Anonymous_Access_To_Object_Access) is null; procedure Anonymous_Access_To_Procedure (Self : in out Element_Visitor; Element : not null Program.Elements.Anonymous_Access_To_Procedures .Anonymous_Access_To_Procedure_Access) is null; procedure Anonymous_Access_To_Function (Self : in out Element_Visitor; Element : not null Program.Elements.Anonymous_Access_To_Functions .Anonymous_Access_To_Function_Access) is null; procedure Private_Type_Definition (Self : in out Element_Visitor; Element : not null Program.Elements.Private_Type_Definitions .Private_Type_Definition_Access) is null; procedure Private_Extension_Definition (Self : in out Element_Visitor; Element : not null Program.Elements.Private_Extension_Definitions .Private_Extension_Definition_Access) is null; procedure Incomplete_Type_Definition (Self : in out Element_Visitor; Element : not null Program.Elements.Incomplete_Type_Definitions .Incomplete_Type_Definition_Access) is null; procedure Task_Definition (Self : in out Element_Visitor; Element : not null Program.Elements.Task_Definitions .Task_Definition_Access) is null; procedure Protected_Definition (Self : in out Element_Visitor; Element : not null Program.Elements.Protected_Definitions .Protected_Definition_Access) is null; procedure Aspect_Specification (Self : in out Element_Visitor; Element : not null Program.Elements.Aspect_Specifications .Aspect_Specification_Access) is null; procedure Real_Range_Specification (Self : in out Element_Visitor; Element : not null Program.Elements.Real_Range_Specifications .Real_Range_Specification_Access) is null; procedure Numeric_Literal (Self : in out Element_Visitor; Element : not null Program.Elements.Numeric_Literals .Numeric_Literal_Access) is null; procedure String_Literal (Self : in out Element_Visitor; Element : not null Program.Elements.String_Literals.String_Literal_Access) is null; procedure Identifier (Self : in out Element_Visitor; Element : not null Program.Elements.Identifiers.Identifier_Access) is null; procedure Operator_Symbol (Self : in out Element_Visitor; Element : not null Program.Elements.Operator_Symbols .Operator_Symbol_Access) is null; procedure Character_Literal (Self : in out Element_Visitor; Element : not null Program.Elements.Character_Literals .Character_Literal_Access) is null; procedure Explicit_Dereference (Self : in out Element_Visitor; Element : not null Program.Elements.Explicit_Dereferences .Explicit_Dereference_Access) is null; procedure Infix_Operator (Self : in out Element_Visitor; Element : not null Program.Elements.Infix_Operators.Infix_Operator_Access) is null; procedure Function_Call (Self : in out Element_Visitor; Element : not null Program.Elements.Function_Calls.Function_Call_Access) is null; procedure Indexed_Component (Self : in out Element_Visitor; Element : not null Program.Elements.Indexed_Components .Indexed_Component_Access) is null; procedure Slice (Self : in out Element_Visitor; Element : not null Program.Elements.Slices.Slice_Access) is null; procedure Selected_Component (Self : in out Element_Visitor; Element : not null Program.Elements.Selected_Components .Selected_Component_Access) is null; procedure Attribute_Reference (Self : in out Element_Visitor; Element : not null Program.Elements.Attribute_References .Attribute_Reference_Access) is null; procedure Record_Aggregate (Self : in out Element_Visitor; Element : not null Program.Elements.Record_Aggregates .Record_Aggregate_Access) is null; procedure Extension_Aggregate (Self : in out Element_Visitor; Element : not null Program.Elements.Extension_Aggregates .Extension_Aggregate_Access) is null; procedure Array_Aggregate (Self : in out Element_Visitor; Element : not null Program.Elements.Array_Aggregates .Array_Aggregate_Access) is null; procedure Short_Circuit_Operation (Self : in out Element_Visitor; Element : not null Program.Elements.Short_Circuit_Operations .Short_Circuit_Operation_Access) is null; procedure Membership_Test (Self : in out Element_Visitor; Element : not null Program.Elements.Membership_Tests .Membership_Test_Access) is null; procedure Null_Literal (Self : in out Element_Visitor; Element : not null Program.Elements.Null_Literals.Null_Literal_Access) is null; procedure Parenthesized_Expression (Self : in out Element_Visitor; Element : not null Program.Elements.Parenthesized_Expressions .Parenthesized_Expression_Access) is null; procedure Raise_Expression (Self : in out Element_Visitor; Element : not null Program.Elements.Raise_Expressions .Raise_Expression_Access) is null; procedure Type_Conversion (Self : in out Element_Visitor; Element : not null Program.Elements.Type_Conversions .Type_Conversion_Access) is null; procedure Qualified_Expression (Self : in out Element_Visitor; Element : not null Program.Elements.Qualified_Expressions .Qualified_Expression_Access) is null; procedure Allocator (Self : in out Element_Visitor; Element : not null Program.Elements.Allocators.Allocator_Access) is null; procedure Case_Expression (Self : in out Element_Visitor; Element : not null Program.Elements.Case_Expressions .Case_Expression_Access) is null; procedure If_Expression (Self : in out Element_Visitor; Element : not null Program.Elements.If_Expressions.If_Expression_Access) is null; procedure Quantified_Expression (Self : in out Element_Visitor; Element : not null Program.Elements.Quantified_Expressions .Quantified_Expression_Access) is null; procedure Discriminant_Association (Self : in out Element_Visitor; Element : not null Program.Elements.Discriminant_Associations .Discriminant_Association_Access) is null; procedure Record_Component_Association (Self : in out Element_Visitor; Element : not null Program.Elements.Record_Component_Associations .Record_Component_Association_Access) is null; procedure Array_Component_Association (Self : in out Element_Visitor; Element : not null Program.Elements.Array_Component_Associations .Array_Component_Association_Access) is null; procedure Parameter_Association (Self : in out Element_Visitor; Element : not null Program.Elements.Parameter_Associations .Parameter_Association_Access) is null; procedure Formal_Package_Association (Self : in out Element_Visitor; Element : not null Program.Elements.Formal_Package_Associations .Formal_Package_Association_Access) is null; procedure Null_Statement (Self : in out Element_Visitor; Element : not null Program.Elements.Null_Statements.Null_Statement_Access) is null; procedure Assignment_Statement (Self : in out Element_Visitor; Element : not null Program.Elements.Assignment_Statements .Assignment_Statement_Access) is null; procedure If_Statement (Self : in out Element_Visitor; Element : not null Program.Elements.If_Statements.If_Statement_Access) is null; procedure Case_Statement (Self : in out Element_Visitor; Element : not null Program.Elements.Case_Statements.Case_Statement_Access) is null; procedure Loop_Statement (Self : in out Element_Visitor; Element : not null Program.Elements.Loop_Statements.Loop_Statement_Access) is null; procedure While_Loop_Statement (Self : in out Element_Visitor; Element : not null Program.Elements.While_Loop_Statements .While_Loop_Statement_Access) is null; procedure For_Loop_Statement (Self : in out Element_Visitor; Element : not null Program.Elements.For_Loop_Statements .For_Loop_Statement_Access) is null; procedure Block_Statement (Self : in out Element_Visitor; Element : not null Program.Elements.Block_Statements .Block_Statement_Access) is null; procedure Exit_Statement (Self : in out Element_Visitor; Element : not null Program.Elements.Exit_Statements.Exit_Statement_Access) is null; procedure Goto_Statement (Self : in out Element_Visitor; Element : not null Program.Elements.Goto_Statements.Goto_Statement_Access) is null; procedure Call_Statement (Self : in out Element_Visitor; Element : not null Program.Elements.Call_Statements.Call_Statement_Access) is null; procedure Simple_Return_Statement (Self : in out Element_Visitor; Element : not null Program.Elements.Simple_Return_Statements .Simple_Return_Statement_Access) is null; procedure Extended_Return_Statement (Self : in out Element_Visitor; Element : not null Program.Elements.Extended_Return_Statements .Extended_Return_Statement_Access) is null; procedure Accept_Statement (Self : in out Element_Visitor; Element : not null Program.Elements.Accept_Statements .Accept_Statement_Access) is null; procedure Requeue_Statement (Self : in out Element_Visitor; Element : not null Program.Elements.Requeue_Statements .Requeue_Statement_Access) is null; procedure Delay_Statement (Self : in out Element_Visitor; Element : not null Program.Elements.Delay_Statements .Delay_Statement_Access) is null; procedure Terminate_Alternative_Statement (Self : in out Element_Visitor; Element : not null Program.Elements.Terminate_Alternative_Statements .Terminate_Alternative_Statement_Access) is null; procedure Select_Statement (Self : in out Element_Visitor; Element : not null Program.Elements.Select_Statements .Select_Statement_Access) is null; procedure Abort_Statement (Self : in out Element_Visitor; Element : not null Program.Elements.Abort_Statements .Abort_Statement_Access) is null; procedure Raise_Statement (Self : in out Element_Visitor; Element : not null Program.Elements.Raise_Statements .Raise_Statement_Access) is null; procedure Code_Statement (Self : in out Element_Visitor; Element : not null Program.Elements.Code_Statements.Code_Statement_Access) is null; procedure Elsif_Path (Self : in out Element_Visitor; Element : not null Program.Elements.Elsif_Paths.Elsif_Path_Access) is null; procedure Case_Path (Self : in out Element_Visitor; Element : not null Program.Elements.Case_Paths.Case_Path_Access) is null; procedure Select_Path (Self : in out Element_Visitor; Element : not null Program.Elements.Select_Paths.Select_Path_Access) is null; procedure Case_Expression_Path (Self : in out Element_Visitor; Element : not null Program.Elements.Case_Expression_Paths .Case_Expression_Path_Access) is null; procedure Elsif_Expression_Path (Self : in out Element_Visitor; Element : not null Program.Elements.Elsif_Expression_Paths .Elsif_Expression_Path_Access) is null; procedure Use_Clause (Self : in out Element_Visitor; Element : not null Program.Elements.Use_Clauses.Use_Clause_Access) is null; procedure With_Clause (Self : in out Element_Visitor; Element : not null Program.Elements.With_Clauses.With_Clause_Access) is null; procedure Component_Clause (Self : in out Element_Visitor; Element : not null Program.Elements.Component_Clauses .Component_Clause_Access) is null; procedure Derived_Type (Self : in out Element_Visitor; Element : not null Program.Elements.Derived_Types.Derived_Type_Access) is null; procedure Derived_Record_Extension (Self : in out Element_Visitor; Element : not null Program.Elements.Derived_Record_Extensions .Derived_Record_Extension_Access) is null; procedure Enumeration_Type (Self : in out Element_Visitor; Element : not null Program.Elements.Enumeration_Types .Enumeration_Type_Access) is null; procedure Signed_Integer_Type (Self : in out Element_Visitor; Element : not null Program.Elements.Signed_Integer_Types .Signed_Integer_Type_Access) is null; procedure Modular_Type (Self : in out Element_Visitor; Element : not null Program.Elements.Modular_Types.Modular_Type_Access) is null; procedure Root_Type (Self : in out Element_Visitor; Element : not null Program.Elements.Root_Types.Root_Type_Access) is null; procedure Floating_Point_Type (Self : in out Element_Visitor; Element : not null Program.Elements.Floating_Point_Types .Floating_Point_Type_Access) is null; procedure Ordinary_Fixed_Point_Type (Self : in out Element_Visitor; Element : not null Program.Elements.Ordinary_Fixed_Point_Types .Ordinary_Fixed_Point_Type_Access) is null; procedure Decimal_Fixed_Point_Type (Self : in out Element_Visitor; Element : not null Program.Elements.Decimal_Fixed_Point_Types .Decimal_Fixed_Point_Type_Access) is null; procedure Unconstrained_Array_Type (Self : in out Element_Visitor; Element : not null Program.Elements.Unconstrained_Array_Types .Unconstrained_Array_Type_Access) is null; procedure Constrained_Array_Type (Self : in out Element_Visitor; Element : not null Program.Elements.Constrained_Array_Types .Constrained_Array_Type_Access) is null; procedure Record_Type (Self : in out Element_Visitor; Element : not null Program.Elements.Record_Types.Record_Type_Access) is null; procedure Interface_Type (Self : in out Element_Visitor; Element : not null Program.Elements.Interface_Types.Interface_Type_Access) is null; procedure Object_Access_Type (Self : in out Element_Visitor; Element : not null Program.Elements.Object_Access_Types .Object_Access_Type_Access) is null; procedure Procedure_Access_Type (Self : in out Element_Visitor; Element : not null Program.Elements.Procedure_Access_Types .Procedure_Access_Type_Access) is null; procedure Function_Access_Type (Self : in out Element_Visitor; Element : not null Program.Elements.Function_Access_Types .Function_Access_Type_Access) is null; procedure Formal_Private_Type_Definition (Self : in out Element_Visitor; Element : not null Program.Elements.Formal_Private_Type_Definitions .Formal_Private_Type_Definition_Access) is null; procedure Formal_Derived_Type_Definition (Self : in out Element_Visitor; Element : not null Program.Elements.Formal_Derived_Type_Definitions .Formal_Derived_Type_Definition_Access) is null; procedure Formal_Discrete_Type_Definition (Self : in out Element_Visitor; Element : not null Program.Elements.Formal_Discrete_Type_Definitions .Formal_Discrete_Type_Definition_Access) is null; procedure Formal_Signed_Integer_Type_Definition (Self : in out Element_Visitor; Element : not null Program.Elements.Formal_Signed_Integer_Type_Definitions .Formal_Signed_Integer_Type_Definition_Access) is null; procedure Formal_Modular_Type_Definition (Self : in out Element_Visitor; Element : not null Program.Elements.Formal_Modular_Type_Definitions .Formal_Modular_Type_Definition_Access) is null; procedure Formal_Floating_Point_Definition (Self : in out Element_Visitor; Element : not null Program.Elements.Formal_Floating_Point_Definitions .Formal_Floating_Point_Definition_Access) is null; procedure Formal_Ordinary_Fixed_Point_Definition (Self : in out Element_Visitor; Element : not null Program.Elements .Formal_Ordinary_Fixed_Point_Definitions .Formal_Ordinary_Fixed_Point_Definition_Access) is null; procedure Formal_Decimal_Fixed_Point_Definition (Self : in out Element_Visitor; Element : not null Program.Elements.Formal_Decimal_Fixed_Point_Definitions .Formal_Decimal_Fixed_Point_Definition_Access) is null; procedure Formal_Unconstrained_Array_Type (Self : in out Element_Visitor; Element : not null Program.Elements.Formal_Unconstrained_Array_Types .Formal_Unconstrained_Array_Type_Access) is null; procedure Formal_Constrained_Array_Type (Self : in out Element_Visitor; Element : not null Program.Elements.Formal_Constrained_Array_Types .Formal_Constrained_Array_Type_Access) is null; procedure Formal_Object_Access_Type (Self : in out Element_Visitor; Element : not null Program.Elements.Formal_Object_Access_Types .Formal_Object_Access_Type_Access) is null; procedure Formal_Procedure_Access_Type (Self : in out Element_Visitor; Element : not null Program.Elements.Formal_Procedure_Access_Types .Formal_Procedure_Access_Type_Access) is null; procedure Formal_Function_Access_Type (Self : in out Element_Visitor; Element : not null Program.Elements.Formal_Function_Access_Types .Formal_Function_Access_Type_Access) is null; procedure Formal_Interface_Type (Self : in out Element_Visitor; Element : not null Program.Elements.Formal_Interface_Types .Formal_Interface_Type_Access) is null; procedure Range_Attribute_Reference (Self : in out Element_Visitor; Element : not null Program.Elements.Range_Attribute_References .Range_Attribute_Reference_Access) is null; procedure Simple_Expression_Range (Self : in out Element_Visitor; Element : not null Program.Elements.Simple_Expression_Ranges .Simple_Expression_Range_Access) is null; procedure Digits_Constraint (Self : in out Element_Visitor; Element : not null Program.Elements.Digits_Constraints .Digits_Constraint_Access) is null; procedure Delta_Constraint (Self : in out Element_Visitor; Element : not null Program.Elements.Delta_Constraints .Delta_Constraint_Access) is null; procedure Index_Constraint (Self : in out Element_Visitor; Element : not null Program.Elements.Index_Constraints .Index_Constraint_Access) is null; procedure Discriminant_Constraint (Self : in out Element_Visitor; Element : not null Program.Elements.Discriminant_Constraints .Discriminant_Constraint_Access) is null; procedure Attribute_Definition_Clause (Self : in out Element_Visitor; Element : not null Program.Elements.Attribute_Definition_Clauses .Attribute_Definition_Clause_Access) is null; procedure Enumeration_Representation_Clause (Self : in out Element_Visitor; Element : not null Program.Elements.Enumeration_Representation_Clauses .Enumeration_Representation_Clause_Access) is null; procedure Record_Representation_Clause (Self : in out Element_Visitor; Element : not null Program.Elements.Record_Representation_Clauses .Record_Representation_Clause_Access) is null; procedure At_Clause (Self : in out Element_Visitor; Element : not null Program.Elements.At_Clauses.At_Clause_Access) is null; procedure Exception_Handler (Self : in out Element_Visitor; Element : not null Program.Elements.Exception_Handlers .Exception_Handler_Access) is null; end Program.Element_Visitors;
Salvatore-tech/Sistemas-de-Tiempo-Real
Ada
930
adb
with Ada.Text_IO, Ada.Real_Time, Pck_tareas; use Ada.Text_IO, Ada.Real_Time, Pck_tareas; procedure Main is P: Time_Span := Milliseconds(50); T : Time; type Ciclo is mod 16; Turno : Ciclo := 0; begin T := Clock; loop T := T + P; delay(2.0); case Turno is when 0|4|8|12 => Seguridad.S; Modulo_MD.MD1; Modulo_MD.MD2; Modulo_MD.MD3; Modulo_MD.MD4; when 1 => Seguridad.S; Modulo_MD.MD5; Control_cs.CS1; Control_cs.CS2; Control_cs.CS3; when 2 => Seguridad.S; Control_cs.CS4; Control_cs.CS5; when 3|6|7|10|11|14|15 => Seguridad.S; when 5|9|13 => Seguridad.S; Modulo_MD.MD5; end case; delay until(T); Turno := Turno + 1; end loop; end Main;
reznikmm/matreshka
Ada
3,694
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- 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$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Form_Filter_Attributes is pragma Preelaborate; type ODF_Form_Filter_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Form_Filter_Attribute_Access is access all ODF_Form_Filter_Attribute'Class with Storage_Size => 0; end ODF.DOM.Form_Filter_Attributes;
AdaCore/gpr
Ada
3,906
ads
-- -- Copyright (C) 2014-2022, AdaCore -- SPDX-License-Identifier: Apache-2.0 -- -- This package provides the user of bump pointer pools with a Vector like -- container. Traditional vectors reallocate their whole storage when we -- outgrow their current capacity, but this is not possible without a very -- large memory cost with bump pointer pools, since you cannot free individual -- chunks of memory. -- -- So in this package, we have a vector that is constituted of exponentially -- growing chunks of memory. Since the maximum number of chunks is a constant -- fixed by the memory of the system (32 being the limit on a modern machine -- with 16gb of ram), random element access is still amortized O(1), with a -- large constant. -- Beware though, random access is still on the average of 100x slower than in -- order iteration, so *never* use Get_At_Index to iterate over the vector! with Gpr_Parser_Support.Bump_Ptr; use Gpr_Parser_Support.Bump_Ptr; generic type Element_Type is private; package Gpr_Parser_Support.Bump_Ptr_Vectors is subtype Index_Type is Positive; type Vector is private with Iterable => (First => First, Next => Next, Has_Element => Has_Element, Element => Get); type Cursor is private; Empty_Cursor : constant Cursor; type Element_Access is not null access all Element_Type; function Create (P : Bump_Ptr_Pool) return Vector; -- Returns a newly created vector using P as it's pool storage function Length (Self : Vector) return Natural with Inline; -- Return the Length of the vector, ie. the number of elements it contains function First_Index (Self : Vector) return Index_Type with Inline; -- Return the index of the first element in Self function Last_Index (Self : Vector) return Integer with Inline; -- Return the index of the last element in Self, or First_Index (Self) - 1 -- if Self is empty. procedure Append (Self : in out Vector; Element : Element_Type) with Inline; -- Appends Element to Self function Get (Self : Vector; C : Cursor) return Element_Type with Inline; -- Get the element at Index function Get_At_Index (Self : Vector; I : Index_Type) return Element_Type with Inline, Pre => I <= Last_Index (Self); -- Get the element at Index function Get_Access (Self : Vector; C : Cursor) return Element_Access with Inline; -- Get an access to the element at Index. The lifetime of the access is the -- one of the vector. function First (Self : Vector) return Cursor with Inline; -- Return the first index, only used for the Iterable aspect function Next (Self : Vector; C : Cursor) return Cursor with Inline; -- Given a vector and an index, return the next index. Only used for the -- iterable aspect. function Has_Element (Self : Vector; C : Cursor) return Boolean with Inline; -- Given a vector and an index, return True if the index is in the vector -- range. Only used for the iterable aspect. private type Elements_Array is array (Positive range <>) of Element_Type; type Chunk; type Chunk_Access is access all Chunk; pragma No_Strict_Aliasing (Chunk_Access); type Chunk (Capacity : Natural) is record Elements : Elements_Array (1 .. Capacity); Next_Chunk : Chunk_Access; Length : Natural := 0; end record; type Vector is record Pool : Bump_Ptr_Pool; First_Chunk, Current_Chunk : Chunk_Access := null; Length : Natural := 0; end record; type Cursor is record Chunk : Chunk_Access; Index_In_Chunk : Natural; end record; Empty_Cursor : constant Cursor := (null, 0); end Gpr_Parser_Support.Bump_Ptr_Vectors;
KipodAfterFree/KAF-2019-FireHog
Ada
8,936
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- Sample.Menu_Demo.Aux -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998 Free Software Foundation, Inc. -- -- -- -- 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, distribute with modifications, 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 ABOVE 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. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Juergen Pfeifer <[email protected]> 1996 -- Version Control -- $Revision: 1.7 $ -- Binding Version 00.93 ------------------------------------------------------------------------------ with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; with Sample.Manifest; use Sample.Manifest; with Sample.Helpers; use Sample.Helpers; with Sample.Keyboard_Handler; use Sample.Keyboard_Handler; with Sample.Explanation; use Sample.Explanation; package body Sample.Menu_Demo.Aux is procedure Geometry (M : in Menu; L : out Line_Count; C : out Column_Count; Y : out Line_Position; X : out Column_Position; Fy : out Line_Position; Fx : out Column_Position); procedure Geometry (M : in Menu; L : out Line_Count; -- Lines used for menu C : out Column_Count; -- Columns used for menu Y : out Line_Position; -- Proposed Line for menu X : out Column_Position; -- Proposed Column for menu Fy : out Line_Position; -- Vertical inner frame Fx : out Column_Position) -- Horiz. inner frame is Spc_Desc : Column_Position; -- spaces between description and item begin Set_Mark (M, Menu_Marker); Spacing (M, Spc_Desc, Fy, Fx); Scale (M, L, C); Fx := Fx + Column_Position (Fy - 1); -- looks a bit nicer L := L + 2 * Fy; -- count for frame at top and bottom C := C + 2 * Fx; -- " -- Calculate horizontal coordinate at the screen center X := (Columns - C) / 2; Y := 1; -- always startin line 1 end Geometry; procedure Geometry (M : in Menu; L : out Line_Count; -- Lines used for menu C : out Column_Count; -- Columns used for menu Y : out Line_Position; -- Proposed Line for menu X : out Column_Position) -- Proposed Column for menu is Fy : Line_Position; Fx : Column_Position; begin Geometry (M, L, C, Y, X, Fy, Fx); end Geometry; function Create (M : Menu; Title : String; Lin : Line_Position; Col : Column_Position) return Panel is W, S : Window; L : Line_Count; C : Column_Count; Y, Fy : Line_Position; X, Fx : Column_Position; Pan : Panel; begin Geometry (M, L, C, Y, X, Fy, Fx); W := New_Window (L, C, Lin, Col); Set_Meta_Mode (W); Set_KeyPad_Mode (W); if Has_Colors then Set_Background (Win => W, Ch => (Ch => ' ', Color => Menu_Back_Color, Attr => Normal_Video)); Set_Foreground (Men => M, Color => Menu_Fore_Color); Set_Background (Men => M, Color => Menu_Back_Color); Set_Grey (Men => M, Color => Menu_Grey_Color); Erase (W); end if; S := Derived_Window (W, L - Fy, C - Fx, Fy, Fx); Set_Meta_Mode (S); Set_KeyPad_Mode (S); Box (W); Set_Window (M, W); Set_Sub_Window (M, S); if Title'Length > 0 then Window_Title (W, Title); end if; Pan := New_Panel (W); Post (M); return Pan; end Create; procedure Destroy (M : in Menu; P : in out Panel) is W, S : Window; begin W := Get_Window (M); S := Get_Sub_Window (M); Post (M, False); Erase (W); Delete (P); Set_Window (M, Null_Window); Set_Sub_Window (M, Null_Window); Delete (S); Delete (W); Update_Panels; end Destroy; function Get_Request (M : Menu; P : Panel) return Key_Code is W : constant Window := Get_Window (M); K : Real_Key_Code; Ch : Character; begin Top (P); loop K := Get_Key (W); if K in Special_Key_Code'Range then case K is when HELP_CODE => Explain_Context; when EXPLAIN_CODE => Explain ("MENUKEYS"); when Key_Home => return REQ_FIRST_ITEM; when QUIT_CODE => return QUIT; when Key_Cursor_Down => return REQ_DOWN_ITEM; when Key_Cursor_Up => return REQ_UP_ITEM; when Key_Cursor_Left => return REQ_LEFT_ITEM; when Key_Cursor_Right => return REQ_RIGHT_ITEM; when Key_End => return REQ_LAST_ITEM; when Key_Backspace => return REQ_BACK_PATTERN; when Key_Next_Page => return REQ_SCR_DPAGE; when Key_Previous_Page => return REQ_SCR_UPAGE; when others => return K; end case; elsif K in Normal_Key_Code'Range then Ch := Character'Val (K); case Ch is when CAN => return QUIT; -- CTRL-X when SO => return REQ_NEXT_ITEM; -- CTRL-N when DLE => return REQ_PREV_ITEM; -- CTRL-P when NAK => return REQ_SCR_ULINE; -- CTRL-U when EOT => return REQ_SCR_DLINE; -- CTRL-D when ACK => return REQ_SCR_DPAGE; -- CTRL-F when STX => return REQ_SCR_UPAGE; -- CTRL-B when EM => return REQ_CLEAR_PATTERN; -- CTRL-Y when BS => return REQ_BACK_PATTERN; -- CTRL-H when SOH => return REQ_NEXT_MATCH; -- CTRL-A when ENQ => return REQ_PREV_MATCH; -- CTRL-E when DC4 => return REQ_TOGGLE_ITEM; -- CTRL-T when CR | LF => return SELECT_ITEM; when others => return K; end case; else return K; end if; end loop; end Get_Request; end Sample.Menu_Demo.Aux;
reznikmm/matreshka
Ada
3,694
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- 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$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Form_Formatted_Text_Elements is pragma Preelaborate; type ODF_Form_Formatted_Text is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Form_Formatted_Text_Access is access all ODF_Form_Formatted_Text'Class with Storage_Size => 0; end ODF.DOM.Form_Formatted_Text_Elements;
reznikmm/matreshka
Ada
5,150
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- 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. ------------------------------------------------------------------------------ -- When applied to a usage dependency, it specifies that the client -- classifier creates instances of the supplier classifier. When applied to a -- BehavioralFeature, it specifies that the designated feature creates an -- instance of the classifier to which the feature is attached. ------------------------------------------------------------------------------ limited with AMF.UML.Behavioral_Features; limited with AMF.UML.Usages; package AMF.Standard_Profile_L2.Creates is pragma Preelaborate; type Standard_Profile_L2_Create is limited interface; type Standard_Profile_L2_Create_Access is access all Standard_Profile_L2_Create'Class; for Standard_Profile_L2_Create_Access'Storage_Size use 0; not overriding function Get_Base_Behavioral_Feature (Self : not null access constant Standard_Profile_L2_Create) return AMF.UML.Behavioral_Features.UML_Behavioral_Feature_Access is abstract; -- Getter of Create::base_BehavioralFeature. -- not overriding procedure Set_Base_Behavioral_Feature (Self : not null access Standard_Profile_L2_Create; To : AMF.UML.Behavioral_Features.UML_Behavioral_Feature_Access) is abstract; -- Setter of Create::base_BehavioralFeature. -- not overriding function Get_Base_Usage (Self : not null access constant Standard_Profile_L2_Create) return AMF.UML.Usages.UML_Usage_Access is abstract; -- Getter of Create::base_Usage. -- not overriding procedure Set_Base_Usage (Self : not null access Standard_Profile_L2_Create; To : AMF.UML.Usages.UML_Usage_Access) is abstract; -- Setter of Create::base_Usage. -- end AMF.Standard_Profile_L2.Creates;
VitalijBondarenko/Formatted_Output_NG
Ada
1,805
ads
------------------------------------------------------------------------------ -- -- -- File: -- -- formatted_output-enumeration_output.ads -- -- -- -- Description: -- -- Formatted_Output.Enumeration_Output generic package specification, -- -- contains prototypes of functions that supports formatted output of -- -- enumeration types -- -- -- -- Author: -- -- Eugene Nonko, [email protected] -- -- -- -- Revision history: -- -- 28/01/99 - original -- -- -- ------------------------------------------------------------------------------ generic type Item_Type is (<>); package Formatted_Output.Enumeration_Output is function "&" (Fmt : Format_Type; Value : Item_Type) return Format_Type; -- Replaces leftmost formatting sequence in Fmt with formatted -- Value image, then returns Fmt. Raises exception Format_Error -- when invalid formatting sequence is found or no formatting -- sequence found at all end Formatted_Output.Enumeration_Output;
dan76/Amass
Ada
1,692
ads
-- Copyright © by Jeff Foley 2017-2023. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. -- SPDX-License-Identifier: Apache-2.0 local json = require("json") name = "Pastebin" type = "api" function start() set_rate_limit(1) end function check() local c local cfg = datasrc_config() if (cfg ~= nil) then c = cfg.credentials end if (c ~= nil and c.key ~= nil and c.key ~= "") then return true end return false end function vertical(ctx, domain) local c local cfg = datasrc_config() if (cfg ~= nil) then c = cfg.credentials end if (c == nil or c.key == nil or c.key == "") then return end local resp, err = request(ctx, {['url']=search_url(domain)}) if (err ~= nil and err ~= "") then log(ctx, "vertical request to service failed: " .. err) return elseif (resp.status_code < 200 or resp.status_code >= 400) then log(ctx, "vertical request to service returned with status: " .. resp.status) return end local d = json.decode(resp.body) if (d == nil) then log(ctx, "failed to decode the JSON response") return elseif (d.count == nil or d.count == 0) then return end for _, dump in pairs(d.data) do if (dump ~= nil and dump.id ~= nil and dump.id ~= "") then scrape(ctx, {['url']=dump_url(dump.id, c.key)}) end end end function search_url(domain) return "https://psbdmp.ws/api/v3/search/" .. domain end function dump_url(id, key) return "https://psbdmp.ws/api/v3/dump/" .. id .. "?key=" .. key end
google-code/ada-security
Ada
3,434
adb
----------------------------------------------------------------------- -- auth_cb -- Authentication callback examples -- Copyright (C) 2013 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- 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.Properties; with Util.Log.Loggers; with Util.Http.Clients.Web; with AWS.Config; with AWS.Config.Set; with AWS.Server; with AWS.Services.Dispatchers.URI; with AWS.Services.Page_Server; with AWS.Services.Web_Block.Registry; with AWS.Net.SSL; with Auth_CB; procedure Auth_Demo is Log : Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Auth_Demo"); Dispatcher : AWS.Services.Dispatchers.URI.Handler; WS : AWS.Server.HTTP; Config : AWS.Config.Object; begin if not AWS.Net.SSL.Is_Supported then Log.Error ("SSL is not supported by AWS."); Log.Error ("SSL is required for the OpenID connector to connect to OpenID providers."); Log.Error ("Please, rebuild AWS with SSL support."); return; end if; -- Get the authentication provider configuration. We use the Util.Properties and some -- java like property file. Other configuration implementation are possible. Auth_CB.Config.Load_Properties ("samples.properties"); Util.Log.Loggers.Initialize (Util.Properties.Manager (Auth_CB.Config)); -- Setup the HTTP client implementation to use AWS. Util.Http.Clients.Web.Register; -- Setup AWS dispatchers. AWS.Services.Dispatchers.URI.Register (Dispatcher, "/atlas/auth/auth", Auth_CB.Get_Authorization'Access, Prefix => True); AWS.Services.Dispatchers.URI.Register (Dispatcher, "/verify", Auth_CB.Verify_Authorization'Access); AWS.Services.Dispatchers.URI.Register (Dispatcher, "/atlas", AWS.Services.Page_Server.Callback'Access, Prefix => True); AWS.Services.Dispatchers.URI.Register (Dispatcher, "/success", Auth_CB.User_Info'Access); AWS.Services.Web_Block.Registry.Register ("success", "samples/web/success.thtml", null); -- Configure AWS. Config := AWS.Config.Get_Current; AWS.Config.Set.Session (Config, True); AWS.Config.Set.Session_Name (Config, "AUTH_DEMO"); AWS.Config.Set.Reuse_Address (Config, True); AWS.Config.Set.WWW_Root (Config, "samples/web"); AWS.Server.Start (WS, Dispatcher => Dispatcher, Config => Config); Log.Info ("Connect you browser to: http://localhost:8080/atlas/login.html"); Log.Info ("Press 'q' key to stop the server."); AWS.Server.Wait (AWS.Server.Q_Key_Pressed); Log.Info ("Shutting down server..."); AWS.Server.Shutdown (WS); end Auth_Demo;
sungyeon/drake
Ada
10,793
adb
with System.Native_IO; package body Ada.Streams.Stream_IO is use type System.Native_IO.File_Mode; procedure Create ( File : in out File_Type; Mode : File_Mode := Out_File; Name : String := ""; Form : String) is NC_File : Naked_Stream_IO.Non_Controlled_File_Type renames Controlled.Reference (File).all; begin Naked_Stream_IO.Create ( NC_File, IO_Modes.File_Mode (Mode), Name => Name, Form => Naked_Stream_IO.Pack (Form)); end Create; procedure Create ( File : in out File_Type; Mode : File_Mode := Out_File; Name : String := ""; Shared : IO_Modes.File_Shared_Spec := IO_Modes.By_Mode; Wait : Boolean := False; Overwrite : Boolean := True) is NC_File : Naked_Stream_IO.Non_Controlled_File_Type renames Controlled.Reference (File).all; begin Naked_Stream_IO.Create ( NC_File, IO_Modes.File_Mode (Mode), Name => Name, Form => (Shared, Wait, Overwrite)); end Create; function Create ( Mode : File_Mode := Out_File; Name : String := ""; Shared : IO_Modes.File_Shared_Spec := IO_Modes.By_Mode; Wait : Boolean := False; Overwrite : Boolean := True) return File_Type is begin return Result : File_Type do declare NC_Result : Naked_Stream_IO.Non_Controlled_File_Type renames Controlled.Reference (Result).all; begin Naked_Stream_IO.Create ( NC_Result, IO_Modes.File_Mode (Mode), Name => Name, Form => (Shared, Wait, Overwrite)); end; end return; end Create; procedure Open ( File : in out File_Type; Mode : File_Mode; Name : String; Form : String) is NC_File : Naked_Stream_IO.Non_Controlled_File_Type renames Controlled.Reference (File).all; begin Naked_Stream_IO.Open ( NC_File, IO_Modes.File_Mode (Mode), Name => Name, Form => Naked_Stream_IO.Pack (Form)); end Open; procedure Open ( File : in out File_Type; Mode : File_Mode; Name : String; Shared : IO_Modes.File_Shared_Spec := IO_Modes.By_Mode; Wait : Boolean := False; Overwrite : Boolean := True) is NC_File : Naked_Stream_IO.Non_Controlled_File_Type renames Controlled.Reference (File).all; begin Naked_Stream_IO.Open ( NC_File, IO_Modes.File_Mode (Mode), Name => Name, Form => (Shared, Wait, Overwrite)); end Open; function Open ( Mode : File_Mode; Name : String; Shared : IO_Modes.File_Shared_Spec := IO_Modes.By_Mode; Wait : Boolean := False; Overwrite : Boolean := True) return File_Type is begin return Result : File_Type do declare NC_Result : Naked_Stream_IO.Non_Controlled_File_Type renames Controlled.Reference (Result).all; begin Naked_Stream_IO.Open ( NC_Result, IO_Modes.File_Mode (Mode), Name => Name, Form => (Shared, Wait, Overwrite)); end; end return; end Open; procedure Close (File : in out File_Type) is NC_File : Naked_Stream_IO.Non_Controlled_File_Type renames Controlled.Reference (File).all; begin Naked_Stream_IO.Close (NC_File, Raise_On_Error => True); end Close; procedure Delete (File : in out File_Type) is NC_File : Naked_Stream_IO.Non_Controlled_File_Type renames Controlled.Reference (File).all; begin Naked_Stream_IO.Delete (NC_File); end Delete; procedure Reset (File : in out File_Type; Mode : File_Mode) is NC_File : Naked_Stream_IO.Non_Controlled_File_Type renames Controlled.Reference (File).all; begin Naked_Stream_IO.Reset (NC_File, IO_Modes.File_Mode (Mode)); end Reset; procedure Reset (File : in out File_Type) is begin Reset (File, Mode (File)); end Reset; function Mode ( File : File_Type) return File_Mode is pragma Check (Dynamic_Predicate, Check => Is_Open (File) or else raise Status_Error); NC_File : Naked_Stream_IO.Non_Controlled_File_Type renames Controlled.Reference (File).all; begin return File_Mode (IO_Modes.File_Mode'(Naked_Stream_IO.Mode (NC_File))); end Mode; function Name ( File : File_Type) return String is pragma Check (Dynamic_Predicate, Check => Is_Open (File) or else raise Status_Error); NC_File : Naked_Stream_IO.Non_Controlled_File_Type renames Controlled.Reference (File).all; begin return Naked_Stream_IO.Name (NC_File); end Name; function Form ( File : File_Type) return String is pragma Check (Dynamic_Predicate, Check => Is_Open (File) or else raise Status_Error); NC_File : Naked_Stream_IO.Non_Controlled_File_Type renames Controlled.Reference (File).all; Result : Naked_Stream_IO.Form_String; Last : Natural; begin Naked_Stream_IO.Unpack (Naked_Stream_IO.Form (NC_File), Result, Last); return Result (Result'First .. Last); end Form; function Is_Open (File : File_Type) return Boolean is NC_File : Naked_Stream_IO.Non_Controlled_File_Type renames Controlled.Reference (File).all; begin return Naked_Stream_IO.Is_Open (NC_File); end Is_Open; function End_Of_File ( File : File_Type) return Boolean is pragma Check (Dynamic_Predicate, Check => Is_Open (File) or else raise Status_Error); NC_File : Naked_Stream_IO.Non_Controlled_File_Type renames Controlled.Reference (File).all; begin return Naked_Stream_IO.End_Of_File (NC_File); end End_Of_File; function Stream ( File : File_Type) return Stream_Access is pragma Check (Dynamic_Predicate, Check => Is_Open (File) or else raise Status_Error); NC_File : Naked_Stream_IO.Non_Controlled_File_Type renames Controlled.Reference (File).all; begin return Naked_Stream_IO.Stream (NC_File); end Stream; procedure Read ( File : File_Type; Item : out Stream_Element_Array; Last : out Stream_Element_Offset; From : Positive_Count) is pragma Check (Dynamic_Predicate, Check => Is_Open (File) or else raise Status_Error); pragma Check (Dynamic_Predicate, Check => Is_Readable (File) or else raise Mode_Error); begin Set_Index (File, From); Read (File, Item, Last); end Read; procedure Read ( File : File_Type; Item : out Stream_Element_Array; Last : out Stream_Element_Offset) is pragma Check (Dynamic_Predicate, Check => Is_Open (File) or else raise Status_Error); pragma Check (Dynamic_Predicate, Check => Is_Readable (File) or else raise Mode_Error); NC_File : Naked_Stream_IO.Non_Controlled_File_Type renames Controlled.Reference (File).all; begin Naked_Stream_IO.Read (NC_File, Item, Last); end Read; procedure Write ( File : File_Type; Item : Stream_Element_Array; To : Positive_Count) is pragma Check (Dynamic_Predicate, Check => Is_Open (File) or else raise Status_Error); pragma Check (Dynamic_Predicate, Check => Mode (File) /= In_File or else raise Mode_Error); begin Set_Index (File, To); Write (File, Item); end Write; procedure Write ( File : File_Type; Item : Stream_Element_Array) is pragma Check (Dynamic_Predicate, Check => Is_Open (File) or else raise Status_Error); pragma Check (Dynamic_Predicate, Check => Mode (File) /= In_File or else raise Mode_Error); NC_File : Naked_Stream_IO.Non_Controlled_File_Type renames Controlled.Reference (File).all; begin Naked_Stream_IO.Write (NC_File, Item); end Write; procedure Set_Index ( File : File_Type; To : Positive_Count) is pragma Check (Dynamic_Predicate, Check => Is_Open (File) or else raise Status_Error); NC_File : Naked_Stream_IO.Non_Controlled_File_Type renames Controlled.Reference (File).all; begin Naked_Stream_IO.Set_Index (NC_File, To); end Set_Index; function Index ( File : File_Type) return Positive_Count is pragma Check (Dynamic_Predicate, Check => Is_Open (File) or else raise Status_Error); NC_File : Naked_Stream_IO.Non_Controlled_File_Type renames Controlled.Reference (File).all; begin return Naked_Stream_IO.Index (NC_File); end Index; function Size ( File : File_Type) return Count is pragma Check (Dynamic_Predicate, Check => Is_Open (File) or else raise Status_Error); NC_File : Naked_Stream_IO.Non_Controlled_File_Type renames Controlled.Reference (File).all; begin return Naked_Stream_IO.Size (NC_File); end Size; procedure Set_Mode (File : in out File_Type; Mode : File_Mode) is NC_File : Naked_Stream_IO.Non_Controlled_File_Type renames Controlled.Reference (File).all; begin Naked_Stream_IO.Set_Mode (NC_File, IO_Modes.File_Mode (Mode)); end Set_Mode; procedure Flush ( File : File_Type) is pragma Check (Dynamic_Predicate, Check => Is_Open (File) or else raise Status_Error); pragma Check (Dynamic_Predicate, Check => Mode (File) /= In_File or else raise Mode_Error); NC_File : Naked_Stream_IO.Non_Controlled_File_Type renames Controlled.Reference (File).all; begin Naked_Stream_IO.Flush (NC_File); end Flush; function Is_Readable (File : File_Type) return Boolean is NC_File : Naked_Stream_IO.Non_Controlled_File_Type renames Controlled.Reference (File).all; begin return (Naked_Stream_IO.Mode (NC_File) and System.Native_IO.Read_Write_Mask) /= System.Native_IO.Write_Only_Mode; end Is_Readable; package body Controlled is function Reference (File : Stream_IO.File_Type) return not null access Naked_Stream_IO.Non_Controlled_File_Type is begin return File_Type (File).Stream'Unrestricted_Access; end Reference; overriding procedure Finalize (Object : in out File_Type) is begin if Naked_Stream_IO.Is_Open (Object.Stream) then Naked_Stream_IO.Close (Object.Stream, Raise_On_Error => False); end if; end Finalize; end Controlled; end Ada.Streams.Stream_IO;
niechaojun/Amass
Ada
1,783
ads
-- Copyright 2017 Jeff Foley. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. local json = require("json") name = "Spyse" type = "api" function start() setratelimit(2) end function check() local c local cfg = datasrc_config() if cfg ~= nil then c = cfg.credentials end if (c ~= nil and c.key ~= nil and c.key ~= "") then return true end return false end function vertical(ctx, domain) local c local cfg = datasrc_config() if cfg ~= nil then c = cfg.credentials end if (c == nil or c.key == nil or c.key == "") then return end local resp local vurl = buildurl(domain) -- Check if the response data is in the graph database if (cfg.ttl ~= nil and cfg.ttl > 0) then resp = obtain_response(domain, cfg.ttl) end if (resp == nil or resp == "") then local err resp, err = request({ url=vurl, headers={['Authorization']="Bearer " .. c.key}, }) if (err ~= nil and err ~= "") then return end if (cfg.ttl ~= nil and cfg.ttl > 0) then cache_response(domain, resp) end end local d = json.decode(resp) if (d == nil or #(d['data'].items) == 0) then return end for i, item in pairs(d['data'].items) do sendnames(ctx, item.name) end end function buildurl(domain) return "https://api.spyse.com/v3/data/domain/subdomain?limit=100&domain=" .. domain end function sendnames(ctx, content) local names = find(content, subdomainre) if names == nil then return end for i, v in pairs(names) do newname(ctx, v) end end
stcarrez/ada-util
Ada
2,985
ads
-- Generated by utildgen.c from system includes with Interfaces.C; package Util.Systems.Constants is pragma Pure; -- Flags used when opening a file with open/creat. O_RDONLY : constant Interfaces.C.int := 8#000000#; O_WRONLY : constant Interfaces.C.int := 8#000001#; O_RDWR : constant Interfaces.C.int := 8#000002#; O_CREAT : constant Interfaces.C.int := 8#000100#; O_EXCL : constant Interfaces.C.int := 8#000200#; O_TRUNC : constant Interfaces.C.int := 8#001000#; O_APPEND : constant Interfaces.C.int := 8#002000#; O_CLOEXEC : constant Interfaces.C.int := 8#2000000#; O_SYNC : constant Interfaces.C.int := 8#4010000#; O_DIRECT : constant Interfaces.C.int := 0; O_NONBLOCK : constant Interfaces.C.int := 8#004000#; -- Some error codes EPERM : constant := 1; ENOENT : constant := 2; EINTR : constant := 4; EIO : constant := 5; ENOEXEC : constant := 8; EBADF : constant := 9; EAGAIN : constant := 11; ENOMEM : constant := 12; EACCES : constant := 13; EFAULT : constant := 14; EBUSY : constant := 16; EEXIST : constant := 17; ENOTDIR : constant := 20; EISDIR : constant := 21; EINVAL : constant := 22; ENFILE : constant := 23; EMFILE : constant := 24; EFBIG : constant := 27; ENOSPC : constant := 28; EROFS : constant := 30; EPIPE : constant := 32; -- Flags used by fcntl F_SETFL : constant Interfaces.C.int := 4; F_GETFL : constant Interfaces.C.int := 3; FD_CLOEXEC : constant Interfaces.C.int := 1; -- Flags used by dlopen RTLD_LAZY : constant Interfaces.C.int := 8#000001#; RTLD_NOW : constant Interfaces.C.int := 8#000002#; RTLD_NOLOAD : constant Interfaces.C.int := 8#000004#; RTLD_DEEPBIND : constant Interfaces.C.int := 8#000010#; RTLD_GLOBAL : constant Interfaces.C.int := 8#000400#; RTLD_LOCAL : constant Interfaces.C.int := 8#000000#; RTLD_NODELETE : constant Interfaces.C.int := 8#010000#; DLL_OPTIONS : constant String := "-ldl"; SYMBOL_PREFIX : constant String := ""; end Util.Systems.Constants;
stcarrez/ada-awa
Ada
1,555
adb
----------------------------------------------------------------------- -- awa-mail-clients-factory -- Factory to create the mail manager -- Copyright (C) 2012 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- 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 AWA.Mail.Clients.Files; separate (AWA.Mail.Clients) -- ------------------------------ -- Factory to create the mail manager. The mail manager implementation is identified by -- the <b>Name</b>. It is configured according to the properties defined in <b>Props</b>. -- Returns null if the mail manager identified by the name is not supported. -- ------------------------------ function Factory (Name : in String; Props : in Util.Properties.Manager'Class) return Mail_Manager_Access is begin if Name = AWA.Mail.Clients.Files.NAME then return AWA.Mail.Clients.Files.Create_Manager (Props); else return null; end if; end Factory;
AdaCore/libadalang
Ada
35
ads
generic procedure Foo.Bar (X : U);
zhmu/ananas
Ada
11,181
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . M M A P . O S _ I N T E R F A C E -- -- -- -- B o d y -- -- -- -- Copyright (C) 2007-2022, AdaCore -- -- -- -- 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 MERCHAN- -- -- TABILITY 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. -- -- -- ------------------------------------------------------------------------------ with Ada.IO_Exceptions; with System.Strings; use System.Strings; with System.OS_Lib; pragma Unreferenced (System.OS_Lib); -- Only used to generate same runtime dependencies and same binder file on -- GNU/Linux and Windows. package body System.Mmap.OS_Interface is use Win; function Align (Addr : File_Size) return File_Size; -- Align some offset/length to the lowest page boundary function Open_Common (Filename : String; Use_Mmap_If_Available : Boolean; Write : Boolean) return System_File; function From_UTF8 (Path : String) return Wide_String; -- Convert from UTF-8 to Wide_String --------------- -- From_UTF8 -- --------------- function From_UTF8 (Path : String) return Wide_String is function MultiByteToWideChar (Codepage : Interfaces.C.unsigned; Flags : Interfaces.C.unsigned; Mbstr : Address; Mb : Natural; Wcstr : Address; Wc : Natural) return Integer; pragma Import (Stdcall, MultiByteToWideChar, "MultiByteToWideChar"); Current_Codepage : Interfaces.C.unsigned; pragma Import (C, Current_Codepage, "__gnat_current_codepage"); Len : Natural; begin -- Compute length of the result Len := MultiByteToWideChar (Current_Codepage, 0, Path'Address, Path'Length, Null_Address, 0); if Len = 0 then raise Constraint_Error; end if; declare -- Declare result Res : Wide_String (1 .. Len); begin -- And compute it Len := MultiByteToWideChar (Current_Codepage, 0, Path'Address, Path'Length, Res'Address, Len); if Len = 0 then raise Constraint_Error; end if; return Res; end; end From_UTF8; ----------------- -- Open_Common -- ----------------- function Open_Common (Filename : String; Use_Mmap_If_Available : Boolean; Write : Boolean) return System_File is dwDesiredAccess, dwShareMode : DWORD; PageFlags : DWORD; W_Filename : constant Wide_String := From_UTF8 (Filename) & Wide_Character'Val (0); File_Handle, Mapping_Handle : HANDLE; SizeH : aliased DWORD; Size : File_Size; begin if Write then dwDesiredAccess := GENERIC_READ + GENERIC_WRITE; dwShareMode := 0; PageFlags := Win.PAGE_READWRITE; else dwDesiredAccess := GENERIC_READ; dwShareMode := Win.FILE_SHARE_READ; PageFlags := Win.PAGE_READONLY; end if; -- Actually open the file File_Handle := CreateFile (W_Filename'Address, dwDesiredAccess, dwShareMode, null, OPEN_EXISTING, Win.FILE_ATTRIBUTE_NORMAL, 0); if File_Handle = Win.INVALID_HANDLE_VALUE then return Invalid_System_File; end if; -- Compute its size Size := File_Size (Win.GetFileSize (File_Handle, SizeH'Access)); if Size = Win.INVALID_FILE_SIZE then return Invalid_System_File; end if; if SizeH /= 0 and then File_Size'Size > 32 then Size := Size + (File_Size (SizeH) * 2 ** 32); end if; -- Then create a mapping object, if needed. On Win32, file memory -- mapping is always available. if Use_Mmap_If_Available then Mapping_Handle := Win.CreateFileMapping (File_Handle, null, PageFlags, 0, DWORD (Size), Standard.System.Null_Address); else Mapping_Handle := Win.INVALID_HANDLE_VALUE; end if; return (Handle => File_Handle, Mapped => Use_Mmap_If_Available, Mapping_Handle => Mapping_Handle, Write => Write, Length => Size); end Open_Common; --------------- -- Open_Read -- --------------- function Open_Read (Filename : String; Use_Mmap_If_Available : Boolean := True) return System_File is begin return Open_Common (Filename, Use_Mmap_If_Available, False); end Open_Read; ---------------- -- Open_Write -- ---------------- function Open_Write (Filename : String; Use_Mmap_If_Available : Boolean := True) return System_File is begin return Open_Common (Filename, Use_Mmap_If_Available, True); end Open_Write; ----------- -- Close -- ----------- procedure Close (File : in out System_File) is Ignored : BOOL; pragma Unreferenced (Ignored); begin Ignored := CloseHandle (File.Mapping_Handle); Ignored := CloseHandle (File.Handle); File.Handle := Win.INVALID_HANDLE_VALUE; File.Mapping_Handle := Win.INVALID_HANDLE_VALUE; end Close; -------------------- -- Read_From_Disk -- -------------------- function Read_From_Disk (File : System_File; Offset, Length : File_Size) return System.Strings.String_Access is Buffer : String_Access := new String (1 .. Integer (Length)); Pos : DWORD; NbRead : aliased DWORD; pragma Unreferenced (Pos); begin Pos := Win.SetFilePointer (File.Handle, LONG (Offset), null, Win.FILE_BEGIN); if Win.ReadFile (File.Handle, Buffer.all'Address, DWORD (Length), NbRead'Unchecked_Access, null) = Win.FALSE then System.Strings.Free (Buffer); raise Ada.IO_Exceptions.Device_Error; end if; return Buffer; end Read_From_Disk; ------------------- -- Write_To_Disk -- ------------------- procedure Write_To_Disk (File : System_File; Offset, Length : File_Size; Buffer : System.Strings.String_Access) is Pos : DWORD; NbWritten : aliased DWORD; pragma Unreferenced (Pos); begin pragma Assert (File.Write); Pos := Win.SetFilePointer (File.Handle, LONG (Offset), null, Win.FILE_BEGIN); if Win.WriteFile (File.Handle, Buffer.all'Address, DWORD (Length), NbWritten'Unchecked_Access, null) = Win.FALSE then raise Ada.IO_Exceptions.Device_Error; end if; end Write_To_Disk; -------------------- -- Create_Mapping -- -------------------- procedure Create_Mapping (File : System_File; Offset, Length : in out File_Size; Mutable : Boolean; Mapping : out System_Mapping) is Flags : DWORD; begin if File.Write then Flags := Win.FILE_MAP_WRITE; elsif Mutable then Flags := Win.FILE_MAP_COPY; else Flags := Win.FILE_MAP_READ; end if; -- Adjust offset and mapping length to account for the required -- alignment of offset on page boundary. declare Queried_Offset : constant File_Size := Offset; begin Offset := Align (Offset); -- First extend the length to compensate the offset shift, then align -- it on the upper page boundary, so that the whole queried area is -- covered. Length := Length + Queried_Offset - Offset; Length := Align (Length + Get_Page_Size - 1); -- But do not exceed the length of the file if Offset + Length > File.Length then Length := File.Length - Offset; end if; end; if Length > File_Size (Integer'Last) then raise Ada.IO_Exceptions.Device_Error; else Mapping := Invalid_System_Mapping; Mapping.Address := Win.MapViewOfFile (File.Mapping_Handle, Flags, 0, DWORD (Offset), SIZE_T (Length)); Mapping.Length := Length; end if; end Create_Mapping; --------------------- -- Dispose_Mapping -- --------------------- procedure Dispose_Mapping (Mapping : in out System_Mapping) is Ignored : BOOL; pragma Unreferenced (Ignored); begin Ignored := Win.UnmapViewOfFile (Mapping.Address); Mapping := Invalid_System_Mapping; end Dispose_Mapping; ------------------- -- Get_Page_Size -- ------------------- function Get_Page_Size return File_Size is SystemInfo : aliased SYSTEM_INFO; begin GetSystemInfo (SystemInfo'Unchecked_Access); return File_Size (SystemInfo.dwAllocationGranularity); end Get_Page_Size; ----------- -- Align -- ----------- function Align (Addr : File_Size) return File_Size is begin return Addr - Addr mod Get_Page_Size; end Align; end System.Mmap.OS_Interface;
compiler-explorer/compiler-explorer
Ada
783
adb
with Ada.Command_Line; with Ada.Text_IO; function Example return Integer is function Square(num : Integer) return Integer is begin return num**2; end Square; function ReadCmdArgumentOrDefault(default: Integer) return Integer is begin if Ada.Command_Line.Argument_Count > 0 then return Integer'Value(Ada.Command_Line.Argument(1)); else return Default; end if; end ReadCmdArgumentOrDefault; NumberToSquare: Integer; Answer: Integer; begin NumberToSquare := ReadCmdArgumentOrDefault(4); Ada.Text_IO.Put_Line("Number to square: " & NumberToSquare'Image); Answer := Square(NumberToSquare); Ada.Text_IO.Put_Line("Square answer: " & Answer'Image); return Answer; end Example;
tum-ei-rcs/StratoX
Ada
5,262
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015, 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 STMicroelectronics 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. -- -- -- ------------------------------------------------------------------------------ -- The Floating-point unit (FPU) provides IEEE754-compliant operations on -- single precision, 32-bit, floating-point values. -- Of particular interest may be the Sqrt function, implemented as a single -- machine code instruction. -- See ST Micro Application Note AN4044: "Using floating-point unit (FPU) with -- STM32F405/07xx and STM32F415/417xx microcontrollers" March 2012, Doc ID -- 022737 Rev 1, file "DM00047230.pdf" -- See ST Micro Programming manual PM0214: -- "STM32F3 and STM32F4 Series Cortex-M4 programming manual" -- May 2014 DocID022708 Rev 4, file "DM00046982.pdf" -- especially section 4.6.4 with HAL; use HAL; package Cortex_M.FPU is function Sqrt (X : Float) return Float; type Rounding_Mode is (To_Nearest, To_Plus_Infinity, To_Minus_Infinity, To_Zero); type Bits_1 is mod 2**1 with Size => 1; type Bits_2 is mod 2**2 with Size => 2; type Bits_6 is mod 2**6 with Size => 6; type Status_Control_Register is record -- negative condition flag N : Boolean; -- zero condition flag Z : Boolean; -- carry condition flag C : Boolean; -- overflow condition flag V : Boolean; Reserved1 : Bits_1; -- Alternative Half-Precision format AHP : Boolean; -- Default NaN mode DN : Boolean; -- Flush-to-zero mode FZ : Boolean; -- rounding mode RM : Rounding_Mode; Reserved2 : Bits_6; Reserved3 : Byte; -- flush to zero IDC : Boolean; Reserved4 : Bits_2; -- inexact result: the rounded (and returned) value is different from -- the mathematically exact result of the operation IXC : Boolean; -- underflow, result is a denorm UFC : Boolean; -- overflow, result depends on rounding mode OFC : Boolean; -- division by zero DZC : Boolean; -- invalid operation, result is a NaN IOC : Boolean; end record with Atomic, Size => 32; for Status_Control_Register use record N at 0 range 31 .. 31; Z at 0 range 30 .. 30; C at 0 range 29 .. 29; V at 0 range 28 .. 28; Reserved1 at 0 range 27 .. 27; AHP at 0 range 26 .. 26; DN at 0 range 25 .. 25; FZ at 0 range 24 .. 24; RM at 0 range 22 .. 23; Reserved2 at 0 range 16 .. 21; Reserved3 at 0 range 8 .. 15; IDC at 0 range 7 .. 7; Reserved4 at 0 range 5 .. 6; IXC at 0 range 4 .. 4; UFC at 0 range 3 .. 3; OFC at 0 range 2 .. 2; DZC at 0 range 1 .. 1; IOC at 0 range 0 .. 0; end record; function FPSCR return Status_Control_Register; end Cortex_M.FPU;
flyx/OpenGLAda
Ada
401
ads
-- part of OpenGLAda, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "COPYING" -- Autogenerated by Generate, do not edit package GL.API.Doubles is pragma Preelaborate; Vertex_Attrib1 : T1; Vertex_Attrib2 : T2; Vertex_Attrib2v : T3; Vertex_Attrib3 : T4; Vertex_Attrib3v : T5; Vertex_Attrib4 : T6; Vertex_Attrib4v : T7; end GL.API.Doubles;
damaki/SPARKNaCl
Ada
377
adb
separate (SPARKNaCl) procedure Sanitize_GF16 (R : out Normal_GF) is begin R := Normal_GF'(others => 0); pragma Inspection_Point (R); -- See RM H3.2 (9) -- Add target-dependent code here to -- 1. flush and invalidate data cache, -- 2. wait until writes have committed (e.g. a memory-fence instruction) -- 3. whatever else is required. end Sanitize_GF16;
burratoo/Acton
Ada
7,549
adb
------------------------------------------------------------------------------------------ -- -- -- OAK COMPONENTS -- -- -- -- OAK.STORAGE.UNSORTED_POOL -- -- -- -- Copyright (C) 2013-2021, Patrick Bernardi -- -- -- ------------------------------------------------------------------------------------------ package body Oak.Storage.Unsorted_Pool is -- pragma Suppress (All_Checks); -- ???? TODO: Need to write some code to verify this actually works. Spark -- should help. ----------------------- -- Local Subprograms -- ----------------------- procedure Allocate_Node (Pool : in out Pool_Type; New_Node : out Node_Location); -- Allocate storage for a node. procedure Deallocate_Node (Pool : in out Pool_Type; Node_Id : in Node_Location); -- Deallocate a node from the storage pool. The node to be deallocated must -- already be removed from the tree. TODO: add function to search tree for -- node as a precondition. ------------------- -- Allocate_Node -- ------------------- procedure Allocate_Node (Pool : in out Pool_Type; New_Node : out Node_Location) is begin -- Unallocated nodes live in one of two places. The first is in the bulk -- free store which is the group of unallocated nodes at the right end -- of the storage array (assuming that node are allocated from the array -- left to right. When a pool is first initialised all the nodes but the -- No_Node node are part of the bulk free store. -- -- The second group of unallocated nodes live on the free list. Nodes -- are added to the free list when they are unallocated and they are not -- next to the bulk free store, where in this case the node joins that -- store. This dual store approach prevents the need to have to -- initialise the free list during setup, which would be an O(n) -- operation. The free list is a linked list using the nodes' right -- link. -- -- The array looks like this (x marks an allocated node): -- -- --------------------------------------------------------------------- -- | x | | x | x | | | x | | | x | | | | | | | | -- --------------------------------------------------------------------- -- ^-----------^---^-------^---^ | ^ --- Bulk Free Store ----| -- | | -- Free_list Bulk_Free -- if Pool.Free_List = No_Node then -- The free list is empty so we allocate a node from the bulk free -- store. if Pool.Bulk_Free = No_Node then -- No more room in the pool! raise Pool_Capacity_Error with "No room in the pool!"; end if; New_Node := Pool.Bulk_Free; Pool.Bulk_Free := Pool.Bulk_Free + 1; else -- Extract a node from the free list. New_Node := Pool.Free_List; Pool.Free_List := Pool.Nodes (Pool.Free_List).Next_Free_Node; end if; end Allocate_Node; --------------------- -- Deallocate_Node -- --------------------- procedure Deallocate_Node (Pool : in out Pool_Type; Node_Id : in Node_Location) is begin -- See the Allocate_Node procedure above for a description of how free -- nodes are stored. if Node_Id + 1 = Pool.Bulk_Free then -- The next node is adjacent to the bulk free store, so we move the -- node inside it. Pool.Nodes (Node_Id).Has_Element := False; Pool.Bulk_Free := Node_Id; else -- Add the node to the free list. Pool.Nodes (Node_Id).Next_Free_Node := Pool.Free_List; Pool.Free_List := Node_Id; end if; end Deallocate_Node; ----------------- -- Delete_Item -- ----------------- procedure Delete_Item (Pool : in out Pool_Type; Item_Id : in Node_Location) is begin if In_Tree (Pool, Item_Id) then Remove_Node (Pool, Item_Id); end if; Deallocate_Node (Pool, Item_Id); end Delete_Item; ----------------------- -- Find_Earlest_Item -- ----------------------- function Find_Earliest_Item (In_Pool : in Pool_Type; Above_Priority : in Priority_Type := Priority_Type'First) return Node_Location is Nodes : Node_Array renames In_Pool.Nodes; Selected_Node : Node_Location := No_Node; begin for N in 1 .. Nodes'Last loop if Nodes (N).In_Tree and then Priority (Nodes (N).Element) > Above_Priority then if Selected_Node = No_Node_Value or else Nodes (N).Element < Nodes (Selected_Node).Element then Selected_Node := N; end if; end if; end loop; return Selected_Node; end Find_Earliest_Item; ------------------------- -- Generic_Update_Time -- ------------------------- procedure Generic_Update_Time (Pool : in out Pool_Type; Item_Id : in Node_Location; Time : in Oak_Time.Time) is Element : Element_Type renames Pool.Nodes (Item_Id).Element; begin Set_Time (Element, Time); end Generic_Update_Time; ----------------- -- Insert_Node -- ----------------- procedure Insert_Node (Pool : in out Pool_Type; Node : in Node_Location) is N : Node_Array renames Pool.Nodes; begin N (Node).In_Tree := True; end Insert_Node; -------------- -- New_Item -- -------------- procedure New_Item (Pool : in out Pool_Type; Item : in Element_Type; Item_Id : out Node_Location; Add_To_Tree : in Boolean := True) is begin if Is_Pool_Full (Pool) then -- No more room in the pool! raise Pool_Capacity_Error with "No room in the pool!"; end if; Allocate_Node (Pool => Pool, New_Node => Item_Id); Pool.Nodes (Item_Id) := (Has_Element => True, In_Tree => False, Next_Free_Node => No_Node, Element => Item); if Add_To_Tree then Insert_Node (Pool => Pool, Node => Item_Id); end if; end New_Item; ----------------- -- Remove_Node -- ----------------- procedure Remove_Node (Pool : in out Pool_Type; Node : in Node_Location) is N : Node_Array renames Pool.Nodes; begin N (Node).In_Tree := False; end Remove_Node; ------------------ -- Replace_Item -- ------------------ procedure Replace_Item (Pool : in out Pool_Type; Item_Id : in Node_Location; Contents : in Element_Type) is Node : Node_Type renames Pool.Nodes (Item_Id); begin Node.Element := Contents; end Replace_Item; end Oak.Storage.Unsorted_Pool;
reznikmm/matreshka
Ada
5,810
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- 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 time constraint is a constraint that refers to a time interval. ------------------------------------------------------------------------------ with AMF.UML.Interval_Constraints; limited with AMF.UML.Time_Intervals; package AMF.UML.Time_Constraints is pragma Preelaborate; type UML_Time_Constraint is limited interface and AMF.UML.Interval_Constraints.UML_Interval_Constraint; type UML_Time_Constraint_Access is access all UML_Time_Constraint'Class; for UML_Time_Constraint_Access'Storage_Size use 0; not overriding function Get_First_Event (Self : not null access constant UML_Time_Constraint) return AMF.Optional_Boolean is abstract; -- Getter of TimeConstraint::firstEvent. -- -- The value of firstEvent is related to constrainedElement. If firstEvent -- is true, then the corresponding observation event is the first time -- instant the execution enters constrainedElement. If firstEvent is -- false, then the corresponding observation event is the last time -- instant the execution is within constrainedElement. not overriding procedure Set_First_Event (Self : not null access UML_Time_Constraint; To : AMF.Optional_Boolean) is abstract; -- Setter of TimeConstraint::firstEvent. -- -- The value of firstEvent is related to constrainedElement. If firstEvent -- is true, then the corresponding observation event is the first time -- instant the execution enters constrainedElement. If firstEvent is -- false, then the corresponding observation event is the last time -- instant the execution is within constrainedElement. not overriding function Get_Specification (Self : not null access constant UML_Time_Constraint) return AMF.UML.Time_Intervals.UML_Time_Interval_Access is abstract; -- Getter of TimeConstraint::specification. -- -- A condition that must be true when evaluated in order for the -- constraint to be satisfied. not overriding procedure Set_Specification (Self : not null access UML_Time_Constraint; To : AMF.UML.Time_Intervals.UML_Time_Interval_Access) is abstract; -- Setter of TimeConstraint::specification. -- -- A condition that must be true when evaluated in order for the -- constraint to be satisfied. end AMF.UML.Time_Constraints;
reznikmm/matreshka
Ada
4,713
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2015, Vadim Godunko <[email protected]> -- -- 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$ ------------------------------------------------------------------------------ with OPM.Stores; with AWFC.Accounts.Sessions.Stores; with AWFC.Accounts.Users.Stores; package body Forum.Forums.Servers is ------------------------------ -- Get_HTTP_Session_Manager -- ------------------------------ function Get_HTTP_Session_Manager (Self : Server_Forum'Class) return not null Spikedog.HTTP_Session_Managers.HTTP_Session_Manager_Access is begin return Spikedog.HTTP_Session_Managers.HTTP_Session_Manager_Access (Self.Engine.Get_Store (AWFC.Accounts.Sessions.Session'Tag)); end Get_HTTP_Session_Manager; ---------------- -- Initialize -- ---------------- procedure Initialize (Self : in out Server_Forum'Class; Driver : League.Strings.Universal_String; Options : SQL.Options.SQL_Options) is Aux : OPM.Stores.Store_Access; begin Standard.Forum.Forums.Initialize (Self, Driver, Options); Self.Password_Manager := new AWFC.Accounts.Password_Managers.Password_Manager (Self.Engine'Unchecked_Access); Aux := new AWFC.Accounts.Sessions.Stores.Session_Manager (Self.Engine'Unchecked_Access); Aux.Initialize; Aux := new AWFC.Accounts.Users.Stores.User_Store (Self.Engine'Unchecked_Access); Aux.Initialize; end Initialize; end Forum.Forums.Servers;
stcarrez/ada-awa
Ada
4,432
adb
----------------------------------------------------------------------- -- awa-mail-components-recipients -- Mail UI Recipients -- Copyright (C) 2012 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- 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.Beans.Objects; package body AWA.Mail.Components.Recipients is -- ------------------------------ -- Set the recipient type. -- ------------------------------ procedure Set_Recipient (UI : in out UIMailRecipient; Recipient : in AWA.Mail.Clients.Recipient_Type) is begin UI.Recipient := Recipient; end Set_Recipient; -- ------------------------------ -- Get the mail name. -- ------------------------------ function Get_Name (UI : in UIMailRecipient; Context : in ASF.Contexts.Faces.Faces_Context'Class) return String is Name : constant Util.Beans.Objects.Object := UI.Get_Attribute (Context, "name"); begin if Util.Beans.Objects.Is_Null (Name) then return ""; else return Util.Beans.Objects.To_String (Name); end if; end Get_Name; -- ------------------------------ -- Get the mail address. -- ------------------------------ function Get_Address (UI : in UIMailRecipient; Context : in ASF.Contexts.Faces.Faces_Context'Class) return String is Addr : constant Util.Beans.Objects.Object := UI.Get_Attribute (Context, "address"); begin if Util.Beans.Objects.Is_Null (Addr) then return ""; else return Util.Beans.Objects.To_String (Addr); end if; end Get_Address; -- ------------------------------ -- Render the children components to obtain an email address and set the TO/CC/BCC address -- of the message with the result. -- ------------------------------ overriding procedure Encode_Children (UI : in UIMailRecipient; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is procedure Process (Content : in String); procedure Process (Content : in String) is Msg : constant AWA.Mail.Clients.Mail_Message_Access := UI.Get_Message; Name : constant String := UI.Get_Name (Context); begin if Content'Length > 0 then Msg.Add_Recipient (Kind => UI.Recipient, Name => Name, Address => Content); else Msg.Add_Recipient (Kind => UI.Recipient, Name => Name, Address => UI.Get_Address (Context)); end if; end Process; begin UI.Wrap_Encode_Children (Context, Process'Access); end Encode_Children; -- ------------------------------ -- Render the children components to obtain an email address and set the From address -- of the message with the result. -- ------------------------------ overriding procedure Encode_Children (UI : in UISender; Context : in out ASF.Contexts.Faces.Faces_Context'Class) is procedure Process (Content : in String); procedure Process (Content : in String) is Msg : constant AWA.Mail.Clients.Mail_Message_Access := UI.Get_Message; Name : constant String := UI.Get_Name (Context); begin if Content'Length > 0 then Msg.Set_From (Name => Name, Address => Content); else Msg.Set_From (Name => Name, Address => UI.Get_Address (Context)); end if; end Process; begin UI.Wrap_Encode_Children (Context, Process'Access); end Encode_Children; end AWA.Mail.Components.Recipients;
zhmu/ananas
Ada
3,514
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . V A L _ C H A R -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2022, 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. -- -- -- ------------------------------------------------------------------------------ with System.Val_Util; use System.Val_Util; package body System.Val_Char is --------------------- -- Value_Character -- --------------------- function Value_Character (Str : String) return Character is F : Natural; L : Natural; S : String (Str'Range) := Str; begin Normalize_String (S, F, L); -- Accept any single character enclosed in quotes if L - F = 2 and then S (F) = ''' and then S (L) = ''' then return Character'Val (Character'Pos (S (F + 1))); -- Check control character cases else for C in Character'Val (16#00#) .. Character'Val (16#1F#) loop if S (F .. L) = Character'Image (C) then return C; end if; end loop; for C in Character'Val (16#7F#) .. Character'Val (16#9F#) loop if S (F .. L) = Character'Image (C) then return C; end if; end loop; if S (F .. L) = "SOFT_HYPHEN" then return Character'Val (16#AD#); end if; Bad_Value (Str); end if; end Value_Character; end System.Val_Char;
charlie5/aIDE
Ada
3,245
adb
with -- AdaM.a_Package, Glib, Glib.Error, Glib.Object, Gtk.Builder, Gtk.Handlers; with Ada.Text_IO; use Ada.Text_IO; package body aIDE.Palette.of_packages_subpackages is use Glib, Glib.Error, Glib.Object, Gtk.Box, Gtk.Builder, Gtk.Button, Gtk.Frame; type button_Info is record the_Package : AdaM.a_Package.view; package_Name : AdaM.Text; packages_Palette : aIDE.Palette.of_packages.view; end record; procedure on_select_Button_clicked (the_Button : access Gtk_Button_Record'Class; the_Info : in button_Info) is pragma Unreferenced (the_Button); use AdaM; begin the_Info.packages_Palette.choice_is (+the_Info.package_Name, the_Info.the_Package); end on_select_Button_clicked; package Button_Callbacks is new Gtk.Handlers.User_Callback (Gtk_Button_Record, button_Info); -- Forge -- function to_packages_Palette_package return View is Self : constant Palette.of_packages_subpackages.view := new Palette.of_packages_subpackages.item; the_Builder : Gtk_Builder; Error : aliased GError; Result : Guint; pragma Unreferenced (Result); begin Gtk_New (the_Builder); Result := the_Builder.Add_From_File ("glade/palette/packages_palette-subpackages.glade", Error'Access); if Error /= null then Put_Line ("Error: 'adam.Palette.of_packages_subpackages.to_packages_Palette_package' ~ " & Get_Message (Error)); Error_Free (Error); end if; Self.Top := gtk_Frame (the_Builder.get_Object ("top_Frame")); Self.select_button_Box := gtk_Box (the_Builder.get_Object ("select_button_Box")); Self.children_Notebook := gtk_Notebook (the_Builder.get_Object ("children_Notebook")); return Self; end to_packages_Palette_package; function new_Button (for_Package : in AdaM.a_Package.view; Named : in String; packages_Palette : in palette.of_packages.view) return gtk_Button is use AdaM; the_Button : gtk_Button; begin gtk_New (the_Button, Named); Button_Callbacks.connect (the_Button, "clicked", on_select_Button_clicked'Access, (for_Package, +Named, packages_Palette)); return the_Button; end new_Button; -- Attributes -- procedure Parent_is (Self : in out Item; Now : in aIDE.Palette.of_packages.view) is begin Self.Parent := Now; end Parent_is; function top_Widget (Self : in Item) return gtk.Widget.Gtk_Widget is begin return gtk.Widget.Gtk_Widget (Self.Top); end top_Widget; function children_Notebook (Self : in Item) return gtk_Notebook is begin return Self.children_Notebook; end children_Notebook; end aIDE.Palette.of_packages_subpackages;
AdaCore/langkit
Ada
8,575
adb
-- -- Copyright (C) 2014-2022, AdaCore -- SPDX-License-Identifier: Apache-2.0 -- with Ada.IO_Exceptions; with System; with GNAT.Byte_Order_Mark; with GNATCOLL.Iconv; with GNATCOLL.Mmap; with Langkit_Support.Slocs; use Langkit_Support.Slocs; package body Langkit_Support.File_Readers is ---------------------------------- -- Create_Decoded_File_Contents -- ---------------------------------- function Create_Decoded_File_Contents (Buffer : Text_Type) return Decoded_File_Contents is begin return (Buffer => new Text_Type'(Buffer), First => Buffer'First, Last => Buffer'Last); end Create_Decoded_File_Contents; ------------------- -- Decode_Buffer -- ------------------- procedure Decode_Buffer (Buffer : String; Charset : String; Read_BOM : Boolean; Contents : out Decoded_File_Contents; Diagnostics : in out Diagnostics_Vectors.Vector) is use GNAT.Byte_Order_Mark; use GNATCOLL.Iconv; -- In the worst case, we have one character per input byte, so the -- following is supposed to be big enough. Result : Text_Access := new Text_Type (1 .. Buffer'Length); State : Iconv_T; Status : Iconv_Result; BOM : BOM_Kind := Unknown; Input_Index, Output_Index : Positive; First_Output_Index : constant Positive := Result'First; -- Index of the first byte in Result at which Iconv must decode Buffer Output : Byte_Sequence (1 .. 4 * Buffer'Size); for Output'Address use Result.all'Address; -- Iconv works on mere strings, so this is a kind of a view conversion begin Contents.Buffer := Result; Contents.First := Result'First; -- If we have a byte order mark, it overrides the requested Charset Input_Index := Buffer'First; if Read_BOM then declare Len : Natural; begin GNAT.Byte_Order_Mark.Read_BOM (Buffer, Len, BOM); Input_Index := Input_Index + Len; end; end if; -- GNATCOLL.Iconv raises a Constraint_Error for empty strings: handle -- them here. if Input_Index > Buffer'Last then Contents.Last := Contents.First - 1; return; end if; -- Create the Iconv converter. We will notice unknown charsets here declare type String_Access is access all String; BOM_Kind_To_Charset : constant array (UTF8_All .. UTF32_BE) of String_Access := (UTF8_All => UTF8'Unrestricted_Access, UTF16_LE => UTF16LE'Unrestricted_Access, UTF16_BE => UTF16BE'Unrestricted_Access, UTF32_LE => UTF32LE'Unrestricted_Access, UTF32_BE => UTF32BE'Unrestricted_Access); Actual_Charset : constant String := (if BOM in UTF8_All .. UTF32_BE then BOM_Kind_To_Charset (BOM).all else Charset); begin State := Iconv_Open (Text_Charset, Actual_Charset); exception when Unsupported_Conversion => Free (Result); Contents := Create_Decoded_File_Contents (""); Append (Diagnostics, Message => To_Text ("Unknown charset """ & Charset & """")); return; end; -- Perform the conversion itself Output_Index := First_Output_Index; Iconv (State, Buffer, Input_Index, Output (Output_Index .. Output'Last), Output_Index, Status); Contents.Last := (Output_Index - 1 - Output'First) / 4 + Result'First; -- Report an error if the input was invalid case Status is when Invalid_Multibyte_Sequence | Incomplete_Multibyte_Sequence => -- TODO??? It may be more helpful to actually perform lexing on an -- incomplete buffer. The user would get both a diagnostic for the -- charset error and a best-effort list of tokens. declare Line_Offset : Natural := Result.all'First; Sloc : Source_Location := (1, 0); begin -- Compute the sloc of the codepoint past the last codepoint -- that was successfully decoded, to be used as the sloc for -- the decoding error. -- When no codepoint could be decoded at all, ``Output_Index`` -- (and thus ``Contents.Last``) still contain 1, while it -- should be 0 (impossible due to its ``Positive`` type). -- Fortunately we can detect this situation thanks to -- ``Input_Index``, which contains the index of the first byte -- of the sequence that could not be decoded. Correctly compute -- the column number in that case. if Input_Index = 1 then Sloc.Column := 1; else -- In this branch, we know that ``Output_Index`` and -- ``Contents.Last`` contain indexes that refer to the last -- decoded codepoint. -- -- First, compute the line number where the error happened -- (i.e. the number of line feed (LF) codepoints that were -- decoded plus 1). Also keep track of the index of the -- first codepoint that follows a line feed. for I in Result.all'First .. Contents.Last loop if Result.all (I) = Chars.LF then Sloc.Line := Sloc.Line + 1; Line_Offset := I + 1; end if; end loop; -- We can then compute the column number at which the error -- occurred (right after the last codepoint that was -- decoded, hence the +1). declare Last_Decoded_Line : Text_Type renames Result.all (Line_Offset .. Contents.Last); begin Sloc.Column := 1 + Column_Count (Last_Decoded_Line); end; end if; -- We no longer need the result buffer: free it and create the -- diagnostic. Free (Result); Contents := Create_Decoded_File_Contents (""); Append (Diagnostics, Make_Range (Sloc, Sloc), To_Text ("Could not decode source as """ & Charset & """")); end; when Full_Buffer => -- This is not supposed to happen: we allocated Result to be big -- enough in all cases. raise Program_Error; when Success => null; end case; Iconv_Close (State); end Decode_Buffer; ----------------- -- Direct_Read -- ----------------- procedure Direct_Read (Filename : String; Charset : String; Read_BOM : Boolean; Contents : out Decoded_File_Contents; Diagnostics : in out Diagnostics_Vectors.Vector) is use GNATCOLL.Mmap; File : Mapped_File; Region : Mapped_Region; begin begin File := Open_Read (Filename); exception when Exc : Ada.IO_Exceptions.Name_Error => Contents := Create_Decoded_File_Contents (""); Append (Diagnostics, Exc => Exc); return; end; Region := Read (File); declare Buffer_Addr : constant System.Address := Data (Region).all'Address; Buffer : String (1 .. Last (Region)) with Import => True, Address => Buffer_Addr; begin Decode_Buffer (Buffer, Charset, Read_BOM, Contents, Diagnostics); end; Free (Region); Close (File); end Direct_Read; ---------------- -- Do_Release -- ---------------- procedure Do_Release (Self : in out File_Reader_Interface'Class) is begin Self.Release; end Do_Release; ---------------------------------- -- Create_File_Reader_Reference -- ---------------------------------- function Create_File_Reader_Reference (File_Reader : File_Reader_Interface'Class) return File_Reader_Reference is begin return Result : File_Reader_Reference do Result.Set (File_Reader); end return; end Create_File_Reader_Reference; end Langkit_Support.File_Readers;
reznikmm/matreshka
Ada
7,887
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2015, Vadim Godunko <[email protected]> -- -- 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$ ------------------------------------------------------------------------------ with Ada.Wide_Text_IO; with Asis.Compilation_Units; with Asis.Declarations; with Asis.Elements; with Properties.Tools; package body Properties.Declarations.Function_Declarations is --------------------- -- Call_Convention -- --------------------- function Call_Convention (Engine : access Engines.Contexts.Context; Element : Asis.Declaration; Name : Engines.Convention_Property) return Engines.Convention_Kind is begin if Asis.Elements.Is_Part_Of_Inherited (Element) then return Call_Convention (Engine, Asis.Declarations.Corresponding_Subprogram_Derivation (Element), Name); end if; if Asis.Elements.Is_Part_Of_Implicit (Element) then return Engines.Intrinsic; end if; declare Unit : constant Asis.Program_Text := Asis.Compilation_Units.Unit_Full_Name (Asis.Elements.Enclosing_Compilation_Unit (Element)); begin if Unit = "League.Strings" or else Unit = "System.Storage_Elements" then return Engines.Intrinsic; end if; end; declare Result : constant Wide_String := Properties.Tools.Get_Aspect (Element, "Convention"); begin if Result = "" then null; elsif Result = "JavaScript_Property_Getter" then return Engines.JavaScript_Property_Getter; elsif Result = "JavaScript_Property_Setter" then return Engines.JavaScript_Property_Setter; elsif Result = "JavaScript_Getter" then return Engines.JavaScript_Getter; elsif Result = "JavaScript_Function" then return Engines.JavaScript_Function; elsif Result = "JavaScript_Method" then return Engines.JavaScript_Method; else Ada.Wide_Text_IO.Put ("Unknown call conv: "); Ada.Wide_Text_IO.Put_Line (Result); raise Program_Error; end if; end; return Engines.Unspecified; end Call_Convention; ---------- -- Code -- ---------- function Code (Engine : access Engines.Contexts.Context; Element : Asis.Declaration; Name : Engines.Text_Property) return League.Strings.Universal_String is pragma Unreferenced (Engine, Element, Name); begin return League.Strings.Empty_Universal_String; end Code; ------------ -- Export -- ------------ function Export (Engine : access Engines.Contexts.Context; Element : Asis.Declaration; Name : Engines.Boolean_Property) return Boolean is pragma Unreferenced (Engine, Name); Result : constant Wide_String := Properties.Tools.Get_Aspect (Element, "Export"); begin return Result = "True"; end Export; -------------------- -- Intrinsic_Name -- -------------------- function Intrinsic_Name (Engine : access Engines.Contexts.Context; Element : Asis.Declaration; Name : Engines.Text_Property) return League.Strings.Universal_String is pragma Unreferenced (Engine, Name); Result : League.Strings.Universal_String; Unit : constant Wide_String := Asis.Compilation_Units.Unit_Full_Name (Asis.Elements.Enclosing_Compilation_Unit (Element)); Func : constant Wide_String := Asis.Declarations.Defining_Name_Image (Asis.Declarations.Names (Element) (1)); begin if Unit = "League.Strings" or else Unit = "System.Storage_Elements" then Result := League.Strings.From_UTF_16_Wide_String (Unit); end if; Result.Append ("."); Result.Append (League.Strings.From_UTF_16_Wide_String (Func)); return Result; end Intrinsic_Name; -------------------- -- Is_Dispatching -- -------------------- function Is_Dispatching (Engine : access Engines.Contexts.Context; Element : Asis.Declaration; Name : Engines.Boolean_Property) return Boolean is pragma Unreferenced (Engine, Name); Spec : Asis.Declaration := Asis.Declarations.Corresponding_Declaration (Element); begin if Asis.Elements.Is_Nil (Spec) then Spec := Element; end if; -- Controlling result functions are not considered dispatching -- for now. return Asis.Declarations.Is_Dispatching_Operation (Spec) and not Tools.Has_Controlling_Result (Spec); end Is_Dispatching; end Properties.Declarations.Function_Declarations;
reznikmm/matreshka
Ada
5,268
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- 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 qualifier value is not an action. It is an element that identifies -- links. It gives a single qualifier within a link end data specification. ------------------------------------------------------------------------------ with AMF.UML.Elements; limited with AMF.UML.Input_Pins; limited with AMF.UML.Properties; package AMF.UML.Qualifier_Values is pragma Preelaborate; type UML_Qualifier_Value is limited interface and AMF.UML.Elements.UML_Element; type UML_Qualifier_Value_Access is access all UML_Qualifier_Value'Class; for UML_Qualifier_Value_Access'Storage_Size use 0; not overriding function Get_Qualifier (Self : not null access constant UML_Qualifier_Value) return AMF.UML.Properties.UML_Property_Access is abstract; -- Getter of QualifierValue::qualifier. -- -- Attribute representing the qualifier for which the value is to be -- specified. not overriding procedure Set_Qualifier (Self : not null access UML_Qualifier_Value; To : AMF.UML.Properties.UML_Property_Access) is abstract; -- Setter of QualifierValue::qualifier. -- -- Attribute representing the qualifier for which the value is to be -- specified. not overriding function Get_Value (Self : not null access constant UML_Qualifier_Value) return AMF.UML.Input_Pins.UML_Input_Pin_Access is abstract; -- Getter of QualifierValue::value. -- -- Input pin from which the specified value for the qualifier is taken. not overriding procedure Set_Value (Self : not null access UML_Qualifier_Value; To : AMF.UML.Input_Pins.UML_Input_Pin_Access) is abstract; -- Setter of QualifierValue::value. -- -- Input pin from which the specified value for the qualifier is taken. end AMF.UML.Qualifier_Values;
AdaCore/libadalang
Ada
1,704
adb
with Ada.Text_IO; use Ada.Text_IO; with Libadalang.Analysis; use Libadalang.Analysis; with Libadalang.Common; use Libadalang.Common; with Support; use Support; procedure Main is procedure Process (Filename : String); -- Parse the Filename source file and display its diagnostics. If there are -- none, resolve all identifiers in it. function Visit (Node : Ada_Node'Class) return Visit_Status; -- If Node is an identifier, try to print its referenced decl. Return Into -- in any case. Ctx : constant Analysis_Context := Create_Context (File_Reader => Create_My_FR); ------------- -- Process -- ------------- procedure Process (Filename : String) is Unit : constant Analysis_Unit := Get_From_File (Ctx, Filename); begin Put_Line ("== " & Filename & " =="); New_Line; if Unit.Has_Diagnostics then for D of Unit.Diagnostics loop Put_Line (Unit.Format_GNU_Diagnostic (D)); end loop; New_Line; return; end if; Unit.Root.Traverse (Visit'Access); New_Line; end Process; ----------- -- Visit -- ----------- function Visit (Node : Ada_Node'Class) return Visit_Status is begin if Node.Kind = Ada_Identifier then Put ("Resolving " & Node.Image & ": "); declare Decl : Basic_Decl; begin Decl := Node.As_Identifier.P_Referenced_Decl; Put_Line (Decl.Image); exception when Property_Error => Put_Line ("Property_Error"); end; end if; return Into; end Visit; begin Process ("test.adb"); Process ("foo.adb"); end Main;
charlie5/cBound
Ada
1,997
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_create_window_request_t is -- Item -- type Item is record major_opcode : aliased Interfaces.Unsigned_8; depth : aliased Interfaces.Unsigned_8; length : aliased Interfaces.Unsigned_16; wid : aliased xcb.xcb_window_t; parent : aliased xcb.xcb_window_t; x : aliased Interfaces.Integer_16; y : aliased Interfaces.Integer_16; width : aliased Interfaces.Unsigned_16; height : aliased Interfaces.Unsigned_16; border_width : aliased Interfaces.Unsigned_16; a_class : aliased Interfaces.Unsigned_16; visual : aliased xcb.xcb_visualid_t; value_mask : aliased Interfaces.Unsigned_32; end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_create_window_request_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_create_window_request_t.Item, Element_Array => xcb.xcb_create_window_request_t.Item_Array, Default_Terminator => (others => <>)); subtype Pointer is C_Pointers.Pointer; -- Pointer_Array -- type Pointer_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_create_window_request_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_create_window_request_t.Pointer, Element_Array => xcb.xcb_create_window_request_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_create_window_request_t;
AdaCore/libadalang
Ada
69
ads
package Pkg.Foo is procedure Bar; end Pkg.Foo; pragma Test_Block;
io7m/coreland-lua-ada
Ada
1,857
adb
-- Lua userdata handling package body Lua.User_Data is use type System.Address; package C_Bindings is function New_User_Data (State : Lua.State_t; Size : Lua.IC.size_t) return System.Address; pragma Import (C, New_User_Data, "lua_newuserdata"); function To_User_Data (State : Lua.State_t; Index : Lua.Integer_t) return System.Address; pragma Import (C, To_User_Data, "lua_touserdata"); end C_Bindings; procedure Register (State : Lua.State_t) is Dummy : Boolean; begin Lua.Lib.Open_Library (State, Class_Name, Method_Table, 0); Dummy := Lua.Lib.New_Metatable (State, Class_Name); if not Dummy then return; end if; Lua.Lib.Open_Library (State, "", Meta_Table, 0); Lua.Push_String (State, "__index"); Lua.Push_Value (State, -3); Lua.Raw_Set (State, -3); Lua.Push_String (State, "__metatable"); Lua.Push_Value (State, -3); Lua.Raw_Set (State, -3); Lua.Pop (State, 1); end Register; procedure Push (State : Lua.State_t; Item : User_Data_t) is UD_Access : User_Data_Access_t; Error : Lua.Error_t; begin UD_Access := User_Data_Access_t (Convert.To_Pointer (C_Bindings.New_User_Data (State => State, Size => Lua.IC.size_t (User_Data_t'Size / System.Storage_Unit)))); UD_Access.all := Item; Lua.Push_String (State, Class_Name); Lua.Raw_Get (State, Lua.Registry_Index); Error := Lua.Set_Metatable (State, -2); if Error /= Lua.Lua_Error_None then return; end if; end Push; function Get (State : Lua.State_t; Index : Integer := 1) return User_Data_t is Address : constant System.Address := C_Bindings.To_User_Data (State, Lua.Integer_t (Index)); begin return Convert.To_Pointer (Address).all; end Get; end Lua.User_Data;
godunko/adawebpack
Ada
3,792
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Web API Definition -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014-2020, Vadim Godunko <[email protected]> -- -- 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: 5324 $ $Date: 2015-05-20 16:26:45 +0300 (Wed, 20 May 2015) $ ------------------------------------------------------------------------------ -- with Web.DOM.Child_Nodes; with Web.DOM.Nodes; -- with Web.DOM.Non_Document_Type_Child_Nodes; package Web.DOM.Character_Datas is pragma Preelaborate; type Character_Data is new Web.DOM.Nodes.Node -- and WebAPI.DOM.Child_Nodes.Child_Node -- and WebAPI.DOM.Non_Document_Type_Child_Nodes.Non_Document_Type_Child_Node; with null record; end Web.DOM.Character_Datas;
AdaCore/libadalang
Ada
122
adb
package body Foo is procedure P (Value : T); procedure P (Value : T) is null; procedure Dummy is null; end Foo;
kjseefried/coreland-cgbc
Ada
775
adb
with BHT_Support; with Test; procedure T_BHT_03 is package BST4 renames BHT_Support.String_Tables4; TC : Test.Context_t; Inserted : Boolean; begin Test.Initialize (Test_Context => TC, Program => "t_bht_03", Test_DB => "TEST_DB", Test_Results => "TEST_RESULTS"); BST4.Insert (Container => BHT_Support.Map, Key => BHT_Support.Keys (1), Element => 1, Inserted => Inserted); pragma Assert (Inserted); BST4.Insert (Container => BHT_Support.Map, Key => BHT_Support.Keys (1), Element => 1, Inserted => Inserted); Test.Check (Test_Context => TC, Test => 7, Condition => Inserted = False, Statement => "Inserted = False"); end T_BHT_03;
SSOCsoft/Log_Reporter
Ada
189
ads
With NSO.Types; -- Section_Vector returns the names of the sections; empty-name excluded. Function INI.Section_Vector( Object : in Instance ) return NSO.Types.String_Vector.Vector;
zhmu/ananas
Ada
17,287
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . S T R I N G S . W I D E _ U N B O U N D E D -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2022, 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 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 is supported on: -- - all Alpha platforms -- - all ia64 platforms -- - all PowerPC platforms -- - all SPARC V9 platforms -- - all x86 platforms -- - all x86_64 platforms with Ada.Strings.Wide_Maps; private with Ada.Finalization; private with System.Atomic_Counters; package Ada.Strings.Wide_Unbounded is pragma Preelaborate; type Unbounded_Wide_String is private; pragma Preelaborable_Initialization (Unbounded_Wide_String); Null_Unbounded_Wide_String : constant Unbounded_Wide_String; function Length (Source : Unbounded_Wide_String) return Natural; type Wide_String_Access is access all Wide_String; procedure Free (X : in out Wide_String_Access); -------------------------------------------------------- -- Conversion, Concatenation, and Selection Functions -- -------------------------------------------------------- function To_Unbounded_Wide_String (Source : Wide_String) return Unbounded_Wide_String; function To_Unbounded_Wide_String (Length : Natural) return Unbounded_Wide_String; function To_Wide_String (Source : Unbounded_Wide_String) return Wide_String; procedure Set_Unbounded_Wide_String (Target : out Unbounded_Wide_String; Source : Wide_String); pragma Ada_05 (Set_Unbounded_Wide_String); procedure Append (Source : in out Unbounded_Wide_String; New_Item : Unbounded_Wide_String); procedure Append (Source : in out Unbounded_Wide_String; New_Item : Wide_String); procedure Append (Source : in out Unbounded_Wide_String; New_Item : Wide_Character); function "&" (Left : Unbounded_Wide_String; Right : Unbounded_Wide_String) return Unbounded_Wide_String; function "&" (Left : Unbounded_Wide_String; Right : Wide_String) return Unbounded_Wide_String; function "&" (Left : Wide_String; Right : Unbounded_Wide_String) return Unbounded_Wide_String; function "&" (Left : Unbounded_Wide_String; Right : Wide_Character) return Unbounded_Wide_String; function "&" (Left : Wide_Character; Right : Unbounded_Wide_String) return Unbounded_Wide_String; function Element (Source : Unbounded_Wide_String; Index : Positive) return Wide_Character; procedure Replace_Element (Source : in out Unbounded_Wide_String; Index : Positive; By : Wide_Character); function Slice (Source : Unbounded_Wide_String; Low : Positive; High : Natural) return Wide_String; function Unbounded_Slice (Source : Unbounded_Wide_String; Low : Positive; High : Natural) return Unbounded_Wide_String; pragma Ada_05 (Unbounded_Slice); procedure Unbounded_Slice (Source : Unbounded_Wide_String; Target : out Unbounded_Wide_String; Low : Positive; High : Natural); pragma Ada_05 (Unbounded_Slice); function "=" (Left : Unbounded_Wide_String; Right : Unbounded_Wide_String) return Boolean; function "=" (Left : Unbounded_Wide_String; Right : Wide_String) return Boolean; function "=" (Left : Wide_String; Right : Unbounded_Wide_String) return Boolean; function "<" (Left : Unbounded_Wide_String; Right : Unbounded_Wide_String) return Boolean; function "<" (Left : Unbounded_Wide_String; Right : Wide_String) return Boolean; function "<" (Left : Wide_String; Right : Unbounded_Wide_String) return Boolean; function "<=" (Left : Unbounded_Wide_String; Right : Unbounded_Wide_String) return Boolean; function "<=" (Left : Unbounded_Wide_String; Right : Wide_String) return Boolean; function "<=" (Left : Wide_String; Right : Unbounded_Wide_String) return Boolean; function ">" (Left : Unbounded_Wide_String; Right : Unbounded_Wide_String) return Boolean; function ">" (Left : Unbounded_Wide_String; Right : Wide_String) return Boolean; function ">" (Left : Wide_String; Right : Unbounded_Wide_String) return Boolean; function ">=" (Left : Unbounded_Wide_String; Right : Unbounded_Wide_String) return Boolean; function ">=" (Left : Unbounded_Wide_String; Right : Wide_String) return Boolean; function ">=" (Left : Wide_String; Right : Unbounded_Wide_String) return Boolean; ------------------------ -- Search Subprograms -- ------------------------ function Index (Source : Unbounded_Wide_String; Pattern : Wide_String; Going : Direction := Forward; Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity) return Natural; function Index (Source : Unbounded_Wide_String; Pattern : Wide_String; Going : Direction := Forward; Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural; function Index (Source : Unbounded_Wide_String; Set : Wide_Maps.Wide_Character_Set; Test : Membership := Inside; Going : Direction := Forward) return Natural; function Index (Source : Unbounded_Wide_String; Pattern : Wide_String; From : Positive; Going : Direction := Forward; Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity) return Natural; pragma Ada_05 (Index); function Index (Source : Unbounded_Wide_String; Pattern : Wide_String; From : Positive; Going : Direction := Forward; Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural; pragma Ada_05 (Index); function Index (Source : Unbounded_Wide_String; Set : Wide_Maps.Wide_Character_Set; From : Positive; Test : Membership := Inside; Going : Direction := Forward) return Natural; pragma Ada_05 (Index); function Index_Non_Blank (Source : Unbounded_Wide_String; Going : Direction := Forward) return Natural; function Index_Non_Blank (Source : Unbounded_Wide_String; From : Positive; Going : Direction := Forward) return Natural; pragma Ada_05 (Index_Non_Blank); function Count (Source : Unbounded_Wide_String; Pattern : Wide_String; Mapping : Wide_Maps.Wide_Character_Mapping := Wide_Maps.Identity) return Natural; function Count (Source : Unbounded_Wide_String; Pattern : Wide_String; Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Natural; function Count (Source : Unbounded_Wide_String; Set : Wide_Maps.Wide_Character_Set) return Natural; procedure Find_Token (Source : Unbounded_Wide_String; Set : Wide_Maps.Wide_Character_Set; From : Positive; Test : Membership; First : out Positive; Last : out Natural); pragma Ada_2012 (Find_Token); procedure Find_Token (Source : Unbounded_Wide_String; Set : Wide_Maps.Wide_Character_Set; Test : Membership; First : out Positive; Last : out Natural); ------------------------------------ -- String Translation Subprograms -- ------------------------------------ function Translate (Source : Unbounded_Wide_String; Mapping : Wide_Maps.Wide_Character_Mapping) return Unbounded_Wide_String; procedure Translate (Source : in out Unbounded_Wide_String; Mapping : Wide_Maps.Wide_Character_Mapping); function Translate (Source : Unbounded_Wide_String; Mapping : Wide_Maps.Wide_Character_Mapping_Function) return Unbounded_Wide_String; procedure Translate (Source : in out Unbounded_Wide_String; Mapping : Wide_Maps.Wide_Character_Mapping_Function); --------------------------------------- -- String Transformation Subprograms -- --------------------------------------- function Replace_Slice (Source : Unbounded_Wide_String; Low : Positive; High : Natural; By : Wide_String) return Unbounded_Wide_String; procedure Replace_Slice (Source : in out Unbounded_Wide_String; Low : Positive; High : Natural; By : Wide_String); function Insert (Source : Unbounded_Wide_String; Before : Positive; New_Item : Wide_String) return Unbounded_Wide_String; procedure Insert (Source : in out Unbounded_Wide_String; Before : Positive; New_Item : Wide_String); function Overwrite (Source : Unbounded_Wide_String; Position : Positive; New_Item : Wide_String) return Unbounded_Wide_String; procedure Overwrite (Source : in out Unbounded_Wide_String; Position : Positive; New_Item : Wide_String); function Delete (Source : Unbounded_Wide_String; From : Positive; Through : Natural) return Unbounded_Wide_String; procedure Delete (Source : in out Unbounded_Wide_String; From : Positive; Through : Natural); function Trim (Source : Unbounded_Wide_String; Side : Trim_End) return Unbounded_Wide_String; procedure Trim (Source : in out Unbounded_Wide_String; Side : Trim_End); function Trim (Source : Unbounded_Wide_String; Left : Wide_Maps.Wide_Character_Set; Right : Wide_Maps.Wide_Character_Set) return Unbounded_Wide_String; procedure Trim (Source : in out Unbounded_Wide_String; Left : Wide_Maps.Wide_Character_Set; Right : Wide_Maps.Wide_Character_Set); function Head (Source : Unbounded_Wide_String; Count : Natural; Pad : Wide_Character := Wide_Space) return Unbounded_Wide_String; procedure Head (Source : in out Unbounded_Wide_String; Count : Natural; Pad : Wide_Character := Wide_Space); function Tail (Source : Unbounded_Wide_String; Count : Natural; Pad : Wide_Character := Wide_Space) return Unbounded_Wide_String; procedure Tail (Source : in out Unbounded_Wide_String; Count : Natural; Pad : Wide_Character := Wide_Space); function "*" (Left : Natural; Right : Wide_Character) return Unbounded_Wide_String; function "*" (Left : Natural; Right : Wide_String) return Unbounded_Wide_String; function "*" (Left : Natural; Right : Unbounded_Wide_String) return Unbounded_Wide_String; private pragma Inline (Length); package AF renames Ada.Finalization; type Shared_Wide_String (Max_Length : Natural) is limited record Counter : System.Atomic_Counters.Atomic_Counter; -- Reference counter Last : Natural := 0; Data : Wide_String (1 .. Max_Length); -- Last is the index of last significant element of the Data. All -- elements with larger indexes are just extra room for expansion. end record; type Shared_Wide_String_Access is access all Shared_Wide_String; procedure Reference (Item : not null Shared_Wide_String_Access); -- Increment reference counter. procedure Unreference (Item : not null Shared_Wide_String_Access); -- Decrement reference counter. Deallocate Item when ref counter is zero function Can_Be_Reused (Item : Shared_Wide_String_Access; Length : Natural) return Boolean; -- Returns True if Shared_Wide_String can be reused. There are two criteria -- when Shared_Wide_String can be reused: its reference counter must be one -- (thus Shared_Wide_String is owned exclusively) and its size is -- sufficient to store string with specified length effectively. function Allocate (Max_Length : Natural) return Shared_Wide_String_Access; -- Allocates new Shared_Wide_String with at least specified maximum length. -- Actual maximum length of the allocated Shared_Wide_String can be -- slightly greater. Returns reference to Empty_Shared_Wide_String when -- requested length is zero. Empty_Shared_Wide_String : aliased Shared_Wide_String (0); function To_Unbounded (S : Wide_String) return Unbounded_Wide_String renames To_Unbounded_Wide_String; -- This renames are here only to be used in the pragma Stream_Convert type Unbounded_Wide_String is new AF.Controlled with record Reference : Shared_Wide_String_Access := Empty_Shared_Wide_String'Access; end record; -- The Unbounded_Wide_String uses several techniques to increase speed of -- the application: -- - implicit sharing or copy-on-write. Unbounded_Wide_String contains -- only the reference to the data which is shared between several -- instances. The shared data is reallocated only when its value is -- changed and the object mutation can't be used or it is inefficient to -- use it; -- - object mutation. Shared data object can be reused without memory -- reallocation when all of the following requirements are meat: -- - shared data object don't used anywhere longer; -- - its size is sufficient to store new value; -- - the gap after reuse is less than some threshold. -- - memory preallocation. Most of used memory allocation algorithms -- aligns allocated segment on the some boundary, thus some amount of -- additional memory can be preallocated without any impact. Such -- preallocated memory can used later by Append/Insert operations -- without reallocation. -- Reference counting uses GCC builtin atomic operations, which allows safe -- sharing of internal data between Ada tasks. Nevertheless, this does not -- make objects of Unbounded_String thread-safe: an instance cannot be -- accessed by several tasks simultaneously. pragma Stream_Convert (Unbounded_Wide_String, To_Unbounded, To_Wide_String); -- Provide stream routines without dragging in Ada.Streams pragma Finalize_Storage_Only (Unbounded_Wide_String); -- Finalization is required only for freeing storage overriding procedure Initialize (Object : in out Unbounded_Wide_String); overriding procedure Adjust (Object : in out Unbounded_Wide_String); overriding procedure Finalize (Object : in out Unbounded_Wide_String); pragma Inline (Initialize, Adjust); Null_Unbounded_Wide_String : constant Unbounded_Wide_String := (AF.Controlled with Reference => Empty_Shared_Wide_String'Access); end Ada.Strings.Wide_Unbounded;
stcarrez/ada-asf
Ada
1,289
ads
----------------------------------------------------------------------- -- security-filters-oauth -- OAuth Security filter -- Copyright (C) 2017, 2018 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- 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 Servlet.Security.Filters.OAuth; -- The <b>ASF.Security.Filters.OAuth</b> package provides a servlet filter that -- implements the RFC 6749 "Accessing Protected Resources" part: it extracts the OAuth -- access token, verifies the grant and the permission. The servlet filter implements -- the RFC 6750 "OAuth 2.0 Bearer Token Usage". -- package ASF.Security.Filters.OAuth renames Servlet.Security.Filters.OAuth;
reznikmm/matreshka
Ada
10,321
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- 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.CMOF.Associations; with AMF.CMOF.Classes; with AMF.CMOF.Data_Types; with AMF.Factories.Utp_Factories; with AMF.Links; with AMF.Utp.Coding_Rules; with AMF.Utp.Data_Partitions; with AMF.Utp.Data_Pools; with AMF.Utp.Data_Selectors; with AMF.Utp.Default_Applications; with AMF.Utp.Defaults; with AMF.Utp.Determ_Alts; with AMF.Utp.Finish_Actions; with AMF.Utp.Get_Timezone_Actions; with AMF.Utp.Literal_Anies; with AMF.Utp.Literal_Any_Or_Nulls; with AMF.Utp.Log_Actions; with AMF.Utp.Managed_Elements; with AMF.Utp.Read_Timer_Actions; with AMF.Utp.SUTs; with AMF.Utp.Set_Timezone_Actions; with AMF.Utp.Start_Timer_Actions; with AMF.Utp.Stop_Timer_Actions; with AMF.Utp.Test_Cases; with AMF.Utp.Test_Components; with AMF.Utp.Test_Contexts; with AMF.Utp.Test_Log_Applications; with AMF.Utp.Test_Logs; with AMF.Utp.Test_Objectives; with AMF.Utp.Test_Suites; with AMF.Utp.Time_Out_Actions; with AMF.Utp.Time_Out_Messages; with AMF.Utp.Time_Outs; with AMF.Utp.Timer_Running_Actions; with AMF.Utp.Validation_Actions; with League.Holders; package AMF.Internals.Factories.Utp_Factories is type Utp_Factory is limited new AMF.Internals.Factories.Metamodel_Factory_Base and AMF.Factories.Utp_Factories.Utp_Factory with null record; overriding function Convert_To_String (Self : not null access Utp_Factory; Data_Type : not null access AMF.CMOF.Data_Types.CMOF_Data_Type'Class; Value : League.Holders.Holder) return League.Strings.Universal_String; overriding function Create (Self : not null access Utp_Factory; Meta_Class : not null access AMF.CMOF.Classes.CMOF_Class'Class) return not null AMF.Elements.Element_Access; overriding function Create_From_String (Self : not null access Utp_Factory; Data_Type : not null access AMF.CMOF.Data_Types.CMOF_Data_Type'Class; Image : League.Strings.Universal_String) return League.Holders.Holder; overriding function Create_Link (Self : not null access Utp_Factory; Association : not null access AMF.CMOF.Associations.CMOF_Association'Class; First_Element : not null AMF.Elements.Element_Access; Second_Element : not null AMF.Elements.Element_Access) return not null AMF.Links.Link_Access; overriding function Get_Package (Self : not null access constant Utp_Factory) return AMF.CMOF.Packages.Collections.Set_Of_CMOF_Package; function Constructor (Extent : AMF.Internals.AMF_Extent) return not null AMF.Factories.Factory_Access; function Get_Package return not null AMF.CMOF.Packages.CMOF_Package_Access; function Create_Coding_Rule (Self : not null access Utp_Factory) return AMF.Utp.Coding_Rules.Utp_Coding_Rule_Access; function Create_Data_Partition (Self : not null access Utp_Factory) return AMF.Utp.Data_Partitions.Utp_Data_Partition_Access; function Create_Data_Pool (Self : not null access Utp_Factory) return AMF.Utp.Data_Pools.Utp_Data_Pool_Access; function Create_Data_Selector (Self : not null access Utp_Factory) return AMF.Utp.Data_Selectors.Utp_Data_Selector_Access; function Create_Default (Self : not null access Utp_Factory) return AMF.Utp.Defaults.Utp_Default_Access; function Create_Default_Application (Self : not null access Utp_Factory) return AMF.Utp.Default_Applications.Utp_Default_Application_Access; function Create_Determ_Alt (Self : not null access Utp_Factory) return AMF.Utp.Determ_Alts.Utp_Determ_Alt_Access; function Create_Finish_Action (Self : not null access Utp_Factory) return AMF.Utp.Finish_Actions.Utp_Finish_Action_Access; function Create_Get_Timezone_Action (Self : not null access Utp_Factory) return AMF.Utp.Get_Timezone_Actions.Utp_Get_Timezone_Action_Access; function Create_Literal_Any (Self : not null access Utp_Factory) return AMF.Utp.Literal_Anies.Utp_Literal_Any_Access; function Create_Literal_Any_Or_Null (Self : not null access Utp_Factory) return AMF.Utp.Literal_Any_Or_Nulls.Utp_Literal_Any_Or_Null_Access; function Create_Log_Action (Self : not null access Utp_Factory) return AMF.Utp.Log_Actions.Utp_Log_Action_Access; function Create_Managed_Element (Self : not null access Utp_Factory) return AMF.Utp.Managed_Elements.Utp_Managed_Element_Access; function Create_Read_Timer_Action (Self : not null access Utp_Factory) return AMF.Utp.Read_Timer_Actions.Utp_Read_Timer_Action_Access; function Create_SUT (Self : not null access Utp_Factory) return AMF.Utp.SUTs.Utp_SUT_Access; function Create_Set_Timezone_Action (Self : not null access Utp_Factory) return AMF.Utp.Set_Timezone_Actions.Utp_Set_Timezone_Action_Access; function Create_Start_Timer_Action (Self : not null access Utp_Factory) return AMF.Utp.Start_Timer_Actions.Utp_Start_Timer_Action_Access; function Create_Stop_Timer_Action (Self : not null access Utp_Factory) return AMF.Utp.Stop_Timer_Actions.Utp_Stop_Timer_Action_Access; function Create_Test_Case (Self : not null access Utp_Factory) return AMF.Utp.Test_Cases.Utp_Test_Case_Access; function Create_Test_Component (Self : not null access Utp_Factory) return AMF.Utp.Test_Components.Utp_Test_Component_Access; function Create_Test_Context (Self : not null access Utp_Factory) return AMF.Utp.Test_Contexts.Utp_Test_Context_Access; function Create_Test_Log (Self : not null access Utp_Factory) return AMF.Utp.Test_Logs.Utp_Test_Log_Access; function Create_Test_Log_Application (Self : not null access Utp_Factory) return AMF.Utp.Test_Log_Applications.Utp_Test_Log_Application_Access; function Create_Test_Objective (Self : not null access Utp_Factory) return AMF.Utp.Test_Objectives.Utp_Test_Objective_Access; function Create_Test_Suite (Self : not null access Utp_Factory) return AMF.Utp.Test_Suites.Utp_Test_Suite_Access; function Create_Time_Out (Self : not null access Utp_Factory) return AMF.Utp.Time_Outs.Utp_Time_Out_Access; function Create_Time_Out_Action (Self : not null access Utp_Factory) return AMF.Utp.Time_Out_Actions.Utp_Time_Out_Action_Access; function Create_Time_Out_Message (Self : not null access Utp_Factory) return AMF.Utp.Time_Out_Messages.Utp_Time_Out_Message_Access; function Create_Timer_Running_Action (Self : not null access Utp_Factory) return AMF.Utp.Timer_Running_Actions.Utp_Timer_Running_Action_Access; function Create_Validation_Action (Self : not null access Utp_Factory) return AMF.Utp.Validation_Actions.Utp_Validation_Action_Access; end AMF.Internals.Factories.Utp_Factories;
Fabien-Chouteau/GESTE
Ada
12,226
ads
pragma Ada_2005; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; limited with SDL_SDL_version_h; with Interfaces.C.Strings; with System; limited with SDL_SDL_rwops_h; with SDL_SDL_stdinc_h; with SDL_SDL_video_h; package SDL_SDL_ttf_h is SDL_TTF_MAJOR_VERSION : constant := 2; -- ../include/SDL/SDL_ttf.h:40 SDL_TTF_MINOR_VERSION : constant := 0; -- ../include/SDL/SDL_ttf.h:41 SDL_TTF_PATCHLEVEL : constant := 11; -- ../include/SDL/SDL_ttf.h:42 -- arg-macro: procedure SDL_TTF_VERSION (X) -- { (X).major := SDL_TTF_MAJOR_VERSION; (X).minor := SDL_TTF_MINOR_VERSION; (X).patch := SDL_TTF_PATCHLEVEL; } -- unsupported macro: TTF_MAJOR_VERSION SDL_TTF_MAJOR_VERSION -- unsupported macro: TTF_MINOR_VERSION SDL_TTF_MINOR_VERSION -- unsupported macro: TTF_PATCHLEVEL SDL_TTF_PATCHLEVEL -- arg-macro: procedure TTF_VERSION (X) -- SDL_TTF_VERSION(X) UNICODE_BOM_NATIVE : constant := 16#FEFF#; -- ../include/SDL/SDL_ttf.h:67 UNICODE_BOM_SWAPPED : constant := 16#FFFE#; -- ../include/SDL/SDL_ttf.h:68 TTF_STYLE_NORMAL : constant := 16#00#; -- ../include/SDL/SDL_ttf.h:92 TTF_STYLE_BOLD : constant := 16#01#; -- ../include/SDL/SDL_ttf.h:93 TTF_STYLE_ITALIC : constant := 16#02#; -- ../include/SDL/SDL_ttf.h:94 TTF_STYLE_UNDERLINE : constant := 16#04#; -- ../include/SDL/SDL_ttf.h:95 TTF_STYLE_STRIKETHROUGH : constant := 16#08#; -- ../include/SDL/SDL_ttf.h:96 TTF_HINTING_NORMAL : constant := 0; -- ../include/SDL/SDL_ttf.h:103 TTF_HINTING_LIGHT : constant := 1; -- ../include/SDL/SDL_ttf.h:104 TTF_HINTING_MONO : constant := 2; -- ../include/SDL/SDL_ttf.h:105 TTF_HINTING_NONE : constant := 3; -- ../include/SDL/SDL_ttf.h:106 -- arg-macro: procedure TTF_RenderText (font, text, fg,TTF_RenderText_Shaded(font, text, fg, bg) -- TTF_RenderText_Shaded(font, text, fg, bg) -- arg-macro: procedure TTF_RenderUTF8 (font, text, fg,TTF_RenderUTF8_Shaded(font, text, fg, bg) -- TTF_RenderUTF8_Shaded(font, text, fg, bg) -- arg-macro: procedure TTF_RenderUNICODE (font, text, fg,TTF_RenderUNICODE_Shaded(font, text, fg, bg) -- TTF_RenderUNICODE_Shaded(font, text, fg, bg) -- unsupported macro: TTF_SetError SDL_SetError -- unsupported macro: TTF_GetError SDL_GetError function TTF_Linked_Version return access constant SDL_SDL_version_h.SDL_version; -- ../include/SDL/SDL_ttf.h:64 pragma Import (C, TTF_Linked_Version, "TTF_Linked_Version"); procedure TTF_ByteSwappedUNICODE (swapped : int); -- ../include/SDL/SDL_ttf.h:74 pragma Import (C, TTF_ByteSwappedUNICODE, "TTF_ByteSwappedUNICODE"); -- skipped empty struct u_TTF_Font -- skipped empty struct TTF_Font function TTF_Init return int; -- ../include/SDL/SDL_ttf.h:80 pragma Import (C, TTF_Init, "TTF_Init"); function TTF_OpenFont (file : Interfaces.C.Strings.chars_ptr; ptsize : int) return System.Address; -- ../include/SDL/SDL_ttf.h:86 pragma Import (C, TTF_OpenFont, "TTF_OpenFont"); function TTF_OpenFontIndex (file : Interfaces.C.Strings.chars_ptr; ptsize : int; index : long) return System.Address; -- ../include/SDL/SDL_ttf.h:87 pragma Import (C, TTF_OpenFontIndex, "TTF_OpenFontIndex"); function TTF_OpenFontRW (src : access SDL_SDL_rwops_h.SDL_RWops; freesrc : int; ptsize : int) return System.Address; -- ../include/SDL/SDL_ttf.h:88 pragma Import (C, TTF_OpenFontRW, "TTF_OpenFontRW"); function TTF_OpenFontIndexRW (src : access SDL_SDL_rwops_h.SDL_RWops; freesrc : int; ptsize : int; index : long) return System.Address; -- ../include/SDL/SDL_ttf.h:89 pragma Import (C, TTF_OpenFontIndexRW, "TTF_OpenFontIndexRW"); function TTF_GetFontStyle (font : System.Address) return int; -- ../include/SDL/SDL_ttf.h:97 pragma Import (C, TTF_GetFontStyle, "TTF_GetFontStyle"); procedure TTF_SetFontStyle (font : System.Address; style : int); -- ../include/SDL/SDL_ttf.h:98 pragma Import (C, TTF_SetFontStyle, "TTF_SetFontStyle"); function TTF_GetFontOutline (font : System.Address) return int; -- ../include/SDL/SDL_ttf.h:99 pragma Import (C, TTF_GetFontOutline, "TTF_GetFontOutline"); procedure TTF_SetFontOutline (font : System.Address; outline : int); -- ../include/SDL/SDL_ttf.h:100 pragma Import (C, TTF_SetFontOutline, "TTF_SetFontOutline"); function TTF_GetFontHinting (font : System.Address) return int; -- ../include/SDL/SDL_ttf.h:107 pragma Import (C, TTF_GetFontHinting, "TTF_GetFontHinting"); procedure TTF_SetFontHinting (font : System.Address; hinting : int); -- ../include/SDL/SDL_ttf.h:108 pragma Import (C, TTF_SetFontHinting, "TTF_SetFontHinting"); function TTF_FontHeight (font : System.Address) return int; -- ../include/SDL/SDL_ttf.h:111 pragma Import (C, TTF_FontHeight, "TTF_FontHeight"); function TTF_FontAscent (font : System.Address) return int; -- ../include/SDL/SDL_ttf.h:116 pragma Import (C, TTF_FontAscent, "TTF_FontAscent"); function TTF_FontDescent (font : System.Address) return int; -- ../include/SDL/SDL_ttf.h:121 pragma Import (C, TTF_FontDescent, "TTF_FontDescent"); function TTF_FontLineSkip (font : System.Address) return int; -- ../include/SDL/SDL_ttf.h:124 pragma Import (C, TTF_FontLineSkip, "TTF_FontLineSkip"); function TTF_GetFontKerning (font : System.Address) return int; -- ../include/SDL/SDL_ttf.h:127 pragma Import (C, TTF_GetFontKerning, "TTF_GetFontKerning"); procedure TTF_SetFontKerning (font : System.Address; allowed : int); -- ../include/SDL/SDL_ttf.h:128 pragma Import (C, TTF_SetFontKerning, "TTF_SetFontKerning"); function TTF_FontFaces (font : System.Address) return long; -- ../include/SDL/SDL_ttf.h:131 pragma Import (C, TTF_FontFaces, "TTF_FontFaces"); function TTF_FontFaceIsFixedWidth (font : System.Address) return int; -- ../include/SDL/SDL_ttf.h:134 pragma Import (C, TTF_FontFaceIsFixedWidth, "TTF_FontFaceIsFixedWidth"); function TTF_FontFaceFamilyName (font : System.Address) return Interfaces.C.Strings.chars_ptr; -- ../include/SDL/SDL_ttf.h:135 pragma Import (C, TTF_FontFaceFamilyName, "TTF_FontFaceFamilyName"); function TTF_FontFaceStyleName (font : System.Address) return Interfaces.C.Strings.chars_ptr; -- ../include/SDL/SDL_ttf.h:136 pragma Import (C, TTF_FontFaceStyleName, "TTF_FontFaceStyleName"); function TTF_GlyphIsProvided (font : System.Address; ch : SDL_SDL_stdinc_h.Uint16) return int; -- ../include/SDL/SDL_ttf.h:139 pragma Import (C, TTF_GlyphIsProvided, "TTF_GlyphIsProvided"); function TTF_GlyphMetrics (font : System.Address; ch : SDL_SDL_stdinc_h.Uint16; minx : access int; maxx : access int; miny : access int; maxy : access int; advance : access int) return int; -- ../include/SDL/SDL_ttf.h:145 pragma Import (C, TTF_GlyphMetrics, "TTF_GlyphMetrics"); function TTF_SizeText (font : System.Address; text : Interfaces.C.Strings.chars_ptr; w : access int; h : access int) return int; -- ../include/SDL/SDL_ttf.h:150 pragma Import (C, TTF_SizeText, "TTF_SizeText"); function TTF_SizeUTF8 (font : System.Address; text : Interfaces.C.Strings.chars_ptr; w : access int; h : access int) return int; -- ../include/SDL/SDL_ttf.h:151 pragma Import (C, TTF_SizeUTF8, "TTF_SizeUTF8"); function TTF_SizeUNICODE (font : System.Address; text : access SDL_SDL_stdinc_h.Uint16; w : access int; h : access int) return int; -- ../include/SDL/SDL_ttf.h:152 pragma Import (C, TTF_SizeUNICODE, "TTF_SizeUNICODE"); function TTF_RenderText_Solid (font : System.Address; text : Interfaces.C.Strings.chars_ptr; fg : SDL_SDL_video_h.SDL_Color) return access SDL_SDL_video_h.SDL_Surface; -- ../include/SDL/SDL_ttf.h:160 pragma Import (C, TTF_RenderText_Solid, "TTF_RenderText_Solid"); function TTF_RenderUTF8_Solid (font : System.Address; text : Interfaces.C.Strings.chars_ptr; fg : SDL_SDL_video_h.SDL_Color) return access SDL_SDL_video_h.SDL_Surface; -- ../include/SDL/SDL_ttf.h:162 pragma Import (C, TTF_RenderUTF8_Solid, "TTF_RenderUTF8_Solid"); function TTF_RenderUNICODE_Solid (font : System.Address; text : access SDL_SDL_stdinc_h.Uint16; fg : SDL_SDL_video_h.SDL_Color) return access SDL_SDL_video_h.SDL_Surface; -- ../include/SDL/SDL_ttf.h:164 pragma Import (C, TTF_RenderUNICODE_Solid, "TTF_RenderUNICODE_Solid"); function TTF_RenderGlyph_Solid (font : System.Address; ch : SDL_SDL_stdinc_h.Uint16; fg : SDL_SDL_video_h.SDL_Color) return access SDL_SDL_video_h.SDL_Surface; -- ../include/SDL/SDL_ttf.h:174 pragma Import (C, TTF_RenderGlyph_Solid, "TTF_RenderGlyph_Solid"); function TTF_RenderText_Shaded (font : System.Address; text : Interfaces.C.Strings.chars_ptr; fg : SDL_SDL_video_h.SDL_Color; bg : SDL_SDL_video_h.SDL_Color) return access SDL_SDL_video_h.SDL_Surface; -- ../include/SDL/SDL_ttf.h:182 pragma Import (C, TTF_RenderText_Shaded, "TTF_RenderText_Shaded"); function TTF_RenderUTF8_Shaded (font : System.Address; text : Interfaces.C.Strings.chars_ptr; fg : SDL_SDL_video_h.SDL_Color; bg : SDL_SDL_video_h.SDL_Color) return access SDL_SDL_video_h.SDL_Surface; -- ../include/SDL/SDL_ttf.h:184 pragma Import (C, TTF_RenderUTF8_Shaded, "TTF_RenderUTF8_Shaded"); function TTF_RenderUNICODE_Shaded (font : System.Address; text : access SDL_SDL_stdinc_h.Uint16; fg : SDL_SDL_video_h.SDL_Color; bg : SDL_SDL_video_h.SDL_Color) return access SDL_SDL_video_h.SDL_Surface; -- ../include/SDL/SDL_ttf.h:186 pragma Import (C, TTF_RenderUNICODE_Shaded, "TTF_RenderUNICODE_Shaded"); function TTF_RenderGlyph_Shaded (font : System.Address; ch : SDL_SDL_stdinc_h.Uint16; fg : SDL_SDL_video_h.SDL_Color; bg : SDL_SDL_video_h.SDL_Color) return access SDL_SDL_video_h.SDL_Surface; -- ../include/SDL/SDL_ttf.h:196 pragma Import (C, TTF_RenderGlyph_Shaded, "TTF_RenderGlyph_Shaded"); function TTF_RenderText_Blended (font : System.Address; text : Interfaces.C.Strings.chars_ptr; fg : SDL_SDL_video_h.SDL_Color) return access SDL_SDL_video_h.SDL_Surface; -- ../include/SDL/SDL_ttf.h:203 pragma Import (C, TTF_RenderText_Blended, "TTF_RenderText_Blended"); function TTF_RenderUTF8_Blended (font : System.Address; text : Interfaces.C.Strings.chars_ptr; fg : SDL_SDL_video_h.SDL_Color) return access SDL_SDL_video_h.SDL_Surface; -- ../include/SDL/SDL_ttf.h:205 pragma Import (C, TTF_RenderUTF8_Blended, "TTF_RenderUTF8_Blended"); function TTF_RenderUNICODE_Blended (font : System.Address; text : access SDL_SDL_stdinc_h.Uint16; fg : SDL_SDL_video_h.SDL_Color) return access SDL_SDL_video_h.SDL_Surface; -- ../include/SDL/SDL_ttf.h:207 pragma Import (C, TTF_RenderUNICODE_Blended, "TTF_RenderUNICODE_Blended"); function TTF_RenderGlyph_Blended (font : System.Address; ch : SDL_SDL_stdinc_h.Uint16; fg : SDL_SDL_video_h.SDL_Color) return access SDL_SDL_video_h.SDL_Surface; -- ../include/SDL/SDL_ttf.h:216 pragma Import (C, TTF_RenderGlyph_Blended, "TTF_RenderGlyph_Blended"); procedure TTF_CloseFont (font : System.Address); -- ../include/SDL/SDL_ttf.h:228 pragma Import (C, TTF_CloseFont, "TTF_CloseFont"); procedure TTF_Quit; -- ../include/SDL/SDL_ttf.h:231 pragma Import (C, TTF_Quit, "TTF_Quit"); function TTF_WasInit return int; -- ../include/SDL/SDL_ttf.h:234 pragma Import (C, TTF_WasInit, "TTF_WasInit"); function TTF_GetFontKerningSize (font : System.Address; prev_index : int; index : int) return int; -- ../include/SDL/SDL_ttf.h:237 pragma Import (C, TTF_GetFontKerningSize, "TTF_GetFontKerningSize"); end SDL_SDL_ttf_h;
pombredanne/ravenadm
Ada
68,044
adb
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../License.txt with Unix; with Replicant; with Parameters; with PortScan.Log; with PortScan.Tests; with PortScan.Packager; with File_Operations; with Ada.Directories; with Ada.Characters.Latin_1; package body PortScan.Buildcycle is package LAT renames Ada.Characters.Latin_1; package DIR renames Ada.Directories; package FOP renames File_Operations; package LOG renames PortScan.Log; package PKG renames PortScan.Packager; package TST renames PortScan.Tests; package PM renames Parameters; package REP renames Replicant; -------------------------------------------------------------------------------------------- -- build_package -------------------------------------------------------------------------------------------- function build_package (id : builders; sequence_id : port_id; specification : PSP.Portspecs; interactive : Boolean := False; interphase : String := "") return Boolean is R : Boolean; break_phase : constant phases := valid_test_phase (interphase); run_selftest : constant Boolean := Unix.env_variable_defined (selftest); pkgversion : constant String := HT.USS (all_ports (sequence_id).pkgversion); port_prefix : constant String := get_port_prefix (id); variant : constant String := HT.USS (all_ports (sequence_id).port_variant); begin trackers (id).seq_id := sequence_id; trackers (id).loglines := 0; trackers (id).check_strip := not specification.debugging_is_on; trackers (id).rpath_fatal := specification.rpath_check_errors_are_fatal; if not LOG.initialize_log (log_handle => trackers (id).log_handle, head_time => trackers (id).head_time, seq_id => trackers (id).seq_id, slave_root => get_root (id), UNAME => HT.USS (uname_mrv), BENV => get_environment (id), COPTS => specification.options_summary (variant), PTVAR => get_port_variables (id)) then LOG.finalize_log (trackers (id).log_handle, trackers (id).head_time, trackers (id).tail_time); return False; end if; for phase in phases'Range loop phase_trackers (id) := phase; case phase is when blr_depends => R := exec_phase_depends (specification => specification, phase_name => phase2str (phase), id => id); when fetch => REP.hook_toolchain (id); R := exec_phase_generic (id, phase); when extract | patch => R := exec_phase_generic (id, phase); when configure => if testing then mark_file_system (id, "preconfig"); end if; R := exec_phase_generic (id, phase); when build => R := exec_phase_build (id); when stage => if testing then mark_file_system (id, "prestage"); end if; R := exec_phase_generic (id, phase); when test => if testing and run_selftest then R := exec_phase_generic (id, phase); end if; REP.unhook_toolchain (id); if R and then testing then R := deinstall_all_packages (id); if R then R := install_run_depends (specification, id); end if; end if; when pkg_package => R := PKG.exec_phase_package (specification => specification, log_handle => trackers (id).log_handle, log_name => LOG.log_name (trackers (id).seq_id), phase_name => phase2str (phase), seq_id => trackers (id).seq_id, port_prefix => port_prefix, rootdir => get_root (id)); when install => if testing then R := exec_phase_install (id, pkgversion); end if; when check_plist => if testing then R := TST.exec_check_plist (specification => specification, log_handle => trackers (id).log_handle, phase_name => phase2str (phase), seq_id => trackers (id).seq_id, port_prefix => port_prefix, rootdir => get_root (id)); end if; when deinstall => if testing then R := exec_phase_deinstall (id, pkgversion); end if; end case; exit when R = False; exit when interactive and then phase = break_phase; end loop; LOG.finalize_log (trackers (id).log_handle, trackers (id).head_time, trackers (id).tail_time); if interactive then interact_with_builder (id); end if; return R; end build_package; -------------------------------------------------------------------------------------------- -- last_build_phase -------------------------------------------------------------------------------------------- function last_build_phase (id : builders) return String is begin return phase2str (phase => phase_trackers (id)); end last_build_phase; -------------------------------------------------------------------------------------------- -- max_time_without_output -------------------------------------------------------------------------------------------- function max_time_without_output (phase : phases) return execution_limit is base : Integer; begin case phase is when blr_depends => base := 15; -- octave forge extraction is driver when fetch => return 480; -- 8 hours when extract => base := 20; when patch => base := 3; when configure => base := 15; when build => base := 40; -- for gcc linking, tex, *llvm linking* when stage => base := 15; -- compiling impossible; toolchain removed when test => base := 25; when check_plist => base := 10; -- For packages with thousands of files when pkg_package => base := 80; when install => base := 10; when deinstall => base := 10; end case; declare multiplier_x10 : constant Positive := timeout_multiplier_x10; begin return execution_limit (base * multiplier_x10 / 10); end; end max_time_without_output; -------------------------------------------------------------------------------------------- -- phase2str -------------------------------------------------------------------------------------------- function phase2str (phase : phases) return String is -- Locked into 12-character length limit. Any longer requires modification to -- display package and build_status function. begin case phase is when blr_depends => return "dependencies"; when fetch => return "fetch"; when extract => return "extract"; when patch => return "patch"; when configure => return "configure"; when build => return "build"; when stage => return "stage"; when test => return "test"; when pkg_package => return "package"; when install => return "install"; when deinstall => return "deinstall"; when check_plist => return "check-plist"; end case; end phase2str; -------------------------------------------------------------------------------------------- -- valid_test_phase #1 -------------------------------------------------------------------------------------------- function valid_test_phase (afterphase : String) return phases is begin if afterphase = "extract" then return extract; elsif afterphase = "patch" then return patch; elsif afterphase = "configure" then return configure; elsif afterphase = "build" then return build; elsif afterphase = "stage" then return stage; elsif afterphase = "package" then return pkg_package; elsif afterphase = "install" then return install; elsif afterphase = "deinstall" then return deinstall; else return phases'First; end if; end valid_test_phase; -------------------------------------------------------------------------------------------- -- valid_test_phase #2 -------------------------------------------------------------------------------------------- function valid_test_phase (afterphase : String) return Boolean is begin return afterphase = "extract" or else afterphase = "patch" or else afterphase = "configure" or else afterphase = "build" or else afterphase = "stage" or else afterphase = "install" or else afterphase = "deinstall"; end valid_test_phase; -------------------------------------------------------------------------------------------- -- exec_phase_generic -------------------------------------------------------------------------------------------- function exec_phase_generic (id : builders; phase : phases) return Boolean is time_limit : execution_limit := max_time_without_output (phase); begin return exec_phase (id => id, phase => phase, time_limit => time_limit); end exec_phase_generic; -------------------------------------------------------------------------------------------- -- exec_phase_build -------------------------------------------------------------------------------------------- function exec_phase_build (id : builders) return Boolean is time_limit : execution_limit := max_time_without_output (build); passed : Boolean; begin passed := exec_phase (id => id, phase => build, time_limit => time_limit, skip_header => False, skip_footer => True); if testing and then passed then passed := detect_leftovers_and_MIA (id, "preconfig", "between port configure and build"); end if; LOG.log_phase_end (trackers (id).log_handle); return passed; end exec_phase_build; -------------------------------------------------------------------------------------------- -- pkg_install_subroutine -------------------------------------------------------------------------------------------- function pkg_install_subroutine (id : builders; root, env_vars, line : String) return Boolean is timed_out : Boolean; time_limit : execution_limit := max_time_without_output (install); PKG_ADD : constant String := "/usr/bin/pkg-static add "; portkey : constant String := convert_depend_origin_to_portkey (line); ptid : constant port_id := ports_keys (HT.SUS (portkey)); pkgname : constant String := HT.replace_all (line, LAT.Colon, LAT.Hyphen); pkgversion : constant String := HT.USS (all_ports (ptid).pkgversion); pkgfile : constant String := pkgname & LAT.Hyphen & pkgversion & arc_ext; fullpath : constant String := HT.USS (PM.configuration.dir_repository) & "/" & pkgfile; command : constant String := chroot & root & env_vars & PKG_ADD & "/packages/All/" & pkgfile; still_good : Boolean := True; begin if DIR.Exists (fullpath) then TIO.Put_Line (trackers (id).log_handle, "===> Installing " & pkgname & " package"); TIO.Close (trackers (id).log_handle); still_good := generic_execute (id, command, timed_out, time_limit); TIO.Open (File => trackers (id).log_handle, Mode => TIO.Append_File, Name => LOG.log_name (trackers (id).seq_id)); if timed_out then TIO.Put_Line (trackers (id).log_handle, watchdog_message (time_limit)); end if; else still_good := False; TIO.Put_Line (trackers (id).log_handle, "Dependency package not found: " & pkgfile); end if; return still_good; end pkg_install_subroutine; -------------------------------------------------------------------------------------------- -- exec_phase_depends -------------------------------------------------------------------------------------------- function exec_phase_depends (specification : PSP.Portspecs; phase_name : String; id : builders) return Boolean is root : constant String := get_root (id); env_vars : constant String := environment_override (id); still_good : Boolean := True; markers : HT.Line_Markers; block : constant String := specification.combined_dependency_origins (include_run => not testing, limit_to_run => False); begin LOG.log_phase_begin (trackers (id).log_handle, phase_name); HT.initialize_markers (block, markers); loop exit when not still_good; exit when not HT.next_line_present (block, markers); declare line : constant String := HT.extract_line (block, markers); begin still_good := pkg_install_subroutine (id, root, env_vars, line); end; end loop; LOG.log_phase_end (trackers (id).log_handle); return still_good; end exec_phase_depends; -------------------------------------------------------------------------------------------- -- install_run_depends -------------------------------------------------------------------------------------------- function install_run_depends (specification : PSP.Portspecs; id : builders) return Boolean is phase_name : constant String := "test / install run dependencies"; root : constant String := get_root (id); env_vars : constant String := environment_override (id); still_good : Boolean := True; markers : HT.Line_Markers; block : constant String := specification.combined_dependency_origins (include_run => True, limit_to_run => True); begin LOG.log_phase_begin (trackers (id).log_handle, phase_name); HT.initialize_markers (block, markers); loop exit when not still_good; exit when not HT.next_line_present (block, markers); declare line : constant String := HT.extract_line (block, markers); begin still_good := pkg_install_subroutine (id, root, env_vars, line); end; end loop; LOG.log_phase_end (trackers (id).log_handle); return still_good; end install_run_depends; -------------------------------------------------------------------------------------------- -- deinstall_all_packages -------------------------------------------------------------------------------------------- function deinstall_all_packages (id : builders) return Boolean is time_limit : execution_limit := max_time_without_output (test); root : constant String := get_root (id); phase_name : constant String := "test / deinstall all packages"; PKG_RM_ALL : constant String := "/usr/bin/pkg-static delete -a -y "; command : constant String := chroot & root & environment_override (id) & PKG_RM_ALL; still_good : Boolean := True; timed_out : Boolean; begin LOG.log_phase_begin (trackers (id).log_handle, phase_name); TIO.Put_Line (trackers (id).log_handle, "===> Autoremoving orphaned packages"); TIO.Close (trackers (id).log_handle); still_good := generic_execute (id, command, timed_out, time_limit); TIO.Open (File => trackers (id).log_handle, Mode => TIO.Append_File, Name => LOG.log_name (trackers (id).seq_id)); LOG.log_phase_end (trackers (id).log_handle); return still_good; end deinstall_all_packages; -------------------------------------------------------------------------------------------- -- exec_phase_install -------------------------------------------------------------------------------------------- function exec_phase_install (id : builders; pkgversion : String) return Boolean is procedure install_it (position : subpackage_crate.Cursor); time_limit : execution_limit := max_time_without_output (install); root : constant String := get_root (id); namebase : constant String := HT.USS (all_ports (trackers (id).seq_id).port_namebase); PKG_ADD : constant String := "/usr/bin/pkg-static add "; still_good : Boolean := True; timed_out : Boolean; procedure install_it (position : subpackage_crate.Cursor) is rec : subpackage_record renames subpackage_crate.Element (position); subpackage : constant String := HT.USS (rec.subpackage); pkgname : String := calculate_package_name (trackers (id).seq_id, subpackage); PKG_FILE : constant String := "/packages/All/" & pkgname & arc_ext; command : constant String := chroot & root & environment_override (id) & PKG_ADD & PKG_FILE; begin if still_good then TIO.Put_Line (trackers (id).log_handle, "===> Installing " & pkgname & " package"); TIO.Close (trackers (id).log_handle); still_good := generic_execute (id, command, timed_out, time_limit); TIO.Open (File => trackers (id).log_handle, Mode => TIO.Append_File, Name => LOG.log_name (trackers (id).seq_id)); if timed_out then TIO.Put_Line (trackers (id).log_handle, watchdog_message (time_limit)); end if; end if; end install_it; begin LOG.log_phase_begin (trackers (id).log_handle, phase2str (install)); all_ports (trackers (id).seq_id).subpackages.Iterate (install_it'Access); LOG.log_phase_end (trackers (id).log_handle); return still_good; end exec_phase_install; -------------------------------------------------------------------------------------------- -- exec_phase -------------------------------------------------------------------------------------------- function exec_phase (id : builders; phase : phases; time_limit : execution_limit; phaseenv : String := ""; depends_phase : Boolean := False; skip_header : Boolean := False; skip_footer : Boolean := False) return Boolean is root : constant String := get_root (id); pid : port_id := trackers (id).seq_id; result : Boolean; timed_out : Boolean; begin -- Nasty, we have to switch open and close the log file for each -- phase because we have to switch between File_Type and File -- Descriptors. I can't find a safe way to get the File Descriptor -- out of the File type. if not skip_header then LOG.log_phase_begin (trackers (id).log_handle, phase2str (phase)); end if; TIO.Close (trackers (id).log_handle); declare command : constant String := chroot & root & environment_override (id) & phaseenv & chroot_make_program & " -C /port " & phase2str (phase); begin result := generic_execute (id, command, timed_out, time_limit); end; -- Reopen the log. I guess we can leave off the exception check -- since it's been passing before TIO.Open (File => trackers (id).log_handle, Mode => TIO.Append_File, Name => LOG.log_name (trackers (id).seq_id)); if timed_out then TIO.Put_Line (trackers (id).log_handle, watchdog_message (time_limit)); end if; if not skip_footer then LOG.log_phase_end (trackers (id).log_handle); end if; return result; end exec_phase; -------------------------------------------------------------------------------------------- -- get_port_variables -------------------------------------------------------------------------------------------- function get_port_variables (id : builders) return String is root : constant String := get_root (id); command : constant String := chroot & root & environment_override (id) & chroot_make_program & " -C /port -VCONFIGURE_ENV -VCONFIGURE_ARGS" & " -VMAKE_ENV -VMAKE_ARGS -VPLIST_SUB -VSUB_LIST"; begin return generic_system_command (command); exception when others => return discerr; end get_port_variables; -------------------------------------------------------------------------------------------- -- generic_system_command -------------------------------------------------------------------------------------------- function generic_system_command (command : String) return String is content : HT.Text; status : Integer; begin content := Unix.piped_command (command, status); if status /= 0 then declare message : String := command & " (return code =" & status'Img & ")"; projlen : Natural := message'Length + 5; begin if projlen > 200 then raise cycle_cmd_error with "cmd: ..." & message (message'Last - 191 .. message'Last); else raise cycle_cmd_error with "cmd: " & message; end if; end; end if; return HT.USS (content); end generic_system_command; -------------------------------------------------------------------------------------------- -- set_uname_mrv -------------------------------------------------------------------------------------------- procedure set_uname_mrv is command : constant String := HT.USS (PM.configuration.dir_sysroot) & "/usr/bin/uname -mrv"; begin uname_mrv := HT.SUS (generic_system_command (command)); end set_uname_mrv; -------------------------------------------------------------------------------------------- -- get_root -------------------------------------------------------------------------------------------- function get_root (id : builders) return String is suffix : String := "/SL" & HT.zeropad (Integer (id), 2); begin return HT.USS (PM.configuration.dir_buildbase) & suffix; end get_root; -------------------------------------------------------------------------------------------- -- get_environment -------------------------------------------------------------------------------------------- function get_environment (id : builders) return String is root : constant String := get_root (id); command : constant String := chroot & root & environment_override (id); begin return generic_system_command (command); exception when others => return discerr; end get_environment; -------------------------------------------------------------------------------------------- -- environment_override -------------------------------------------------------------------------------------------- function environment_override (id : builders; enable_tty : Boolean := False) return String is function set_terminal (enable_tty : Boolean) return String; function toolchain_path return String; localbase : constant String := HT.USS (PM.configuration.dir_localbase); function set_terminal (enable_tty : Boolean) return String is begin if enable_tty then return "TERM=cons25 "; end if; return "TERM=dumb "; end set_terminal; function toolchain_path return String is begin if phases'Pos (phase_trackers (id)) < phases'Pos (stage) or else phase_trackers (id) = test then return localbase & "/toolchain/" & default_compiler & "/bin:"; else return ""; end if; end toolchain_path; PATH : constant String := "PATH=/bin:/usr/bin:" & toolchain_path & localbase & "/toolchain/bin:" & localbase & "/sbin:" & localbase & "/bin "; TERM : constant String := set_terminal (enable_tty); USER : constant String := "USER=root "; HOME : constant String := "HOME=/root "; LANG : constant String := "LANG=C "; RAVN : constant String := "RAVENADM=building "; PKG8 : constant String := "PKG_DBDIR=/var/db/pkg8 " & "PKG_CACHEDIR=/var/cache/pkg8 "; CENV : constant String := HT.USS (customenv); begin return " /usr/bin/env -i " & CENV & LANG & TERM & USER & HOME & RAVN & PKG8 & PATH; end environment_override; -------------------------------------------------------------------------------------------- -- obtain_custom_environment -------------------------------------------------------------------------------------------- procedure obtain_custom_environment is target_name : constant String := PM.raven_confdir & "/" & HT.USS (PM.configuration.profile) & "-environment"; begin customenv := HT.blank; if not DIR.Exists (target_name) then return; end if; declare contents : String := FOP.get_file_contents (target_name); markers : HT.Line_Markers; begin HT.initialize_markers (contents, markers); loop exit when not HT.next_line_present (contents, markers); declare line : constant String := HT.extract_line (contents, markers); begin if HT.contains (line, "=") then HT.SU.Append (customenv, HT.trim (line) & " "); end if; end; end loop; end; end obtain_custom_environment; -------------------------------------------------------------------------------------------- -- initialize -------------------------------------------------------------------------------------------- procedure initialize (test_mode : Boolean) is begin set_uname_mrv; testing := test_mode; declare logdir : constant String := HT.USS (PM.configuration.dir_logs); begin if not DIR.Exists (logdir) then DIR.Create_Path (New_Directory => logdir); end if; exception when error : others => raise scan_log_error with "failed to create " & logdir; end; obtain_custom_environment; end initialize; -------------------------------------------------------------------------------------------- -- initialize -------------------------------------------------------------------------------------------- function exec_phase_deinstall (id : builders; pkgversion : String) return Boolean is procedure deinstall_it (position : subpackage_crate.Cursor); time_limit : execution_limit := max_time_without_output (deinstall); root : constant String := get_root (id); namebase : constant String := HT.USS (all_ports (trackers (id).seq_id).port_namebase); PKG_DELETE : constant String := "/usr/bin/pkg-static delete -f -y "; still_good : Boolean := True; dyn_good : Boolean; timed_out : Boolean; procedure deinstall_it (position : subpackage_crate.Cursor) is rec : subpackage_record renames subpackage_crate.Element (position); subpackage : constant String := HT.USS (rec.subpackage); pkgname : String := calculate_package_name (trackers (id).seq_id, subpackage); command : constant String := chroot & root & environment_override (id) & PKG_DELETE & pkgname; begin if still_good then TIO.Put_Line (trackers (id).log_handle, "===> Deinstalling " & pkgname & " package"); TIO.Close (trackers (id).log_handle); still_good := generic_execute (id, command, timed_out, time_limit); TIO.Open (File => trackers (id).log_handle, Mode => TIO.Append_File, Name => LOG.log_name (trackers (id).seq_id)); if timed_out then TIO.Put_Line (trackers (id).log_handle, watchdog_message (time_limit)); end if; end if; end deinstall_it; begin LOG.log_phase_begin (trackers (id).log_handle, phase2str (deinstall)); dyn_good := log_linked_libraries (id, pkgversion); all_ports (trackers (id).seq_id).subpackages.Iterate (deinstall_it'Access); if still_good then still_good := detect_leftovers_and_MIA (id, "prestage", "between staging and package deinstallation"); end if; LOG.log_phase_end (trackers (id).log_handle); return still_good and then dyn_good; end exec_phase_deinstall; -------------------------------------------------------------------------------------------- -- stack_linked_libraries -------------------------------------------------------------------------------------------- procedure stack_linked_libraries (id : builders; base, filename : String) is objdump : String := "/usr/bin/objdump-sysroot"; command : String := chroot & base & environment_override (id) & objdump & " -p " & filename; begin declare comres : String := generic_system_command (command); markers : HT.Line_Markers; pathstr : HT.Text := HT.blank; initial : String := " NEEDED"; runpath : String := " RUNPATH"; rpath : String := " RPATH"; begin HT.initialize_markers (comres, markers); if HT.next_line_with_content_present (comres, runpath, markers) then declare line : constant String := HT.extract_line (comres, markers); begin pathstr := HT.SUS (HT.trim (HT.part_2 (line, runpath))); end; else HT.initialize_markers (comres, markers); if HT.next_line_with_content_present (comres, rpath, markers) then declare line : constant String := HT.extract_line (comres, markers); begin pathstr := HT.SUS (HT.trim (HT.part_2 (line, rpath))); end; end if; end if; HT.initialize_markers (comres, markers); loop exit when not HT.next_line_with_content_present (comres, initial, markers); declare line : constant String := HT.extract_line (comres, markers); shlib : constant String := " " & HT.trim (HT.part_2 (line, initial)); shpayload : HT.Text := HT.SUS (HT.USS (pathstr) & shlib); line_text : HT.Text := HT.SUS (line); begin if not trackers (id).dynlink.Contains (line_text) then trackers (id).dynlink.Append (line_text); end if; if not trackers (id).runpaths.Contains (shpayload) then trackers (id).runpaths.Append (shpayload); end if; end; end loop; end; exception -- the command result was not zero, so it was an expected format -- or static file. Just skip it. (Should never happen) when bad_result : others => null; end stack_linked_libraries; -------------------------------------------------------------------------------------------- -- log_linked_libraries -------------------------------------------------------------------------------------------- function log_linked_libraries (id : builders; pkgversion : String) return Boolean is procedure log_dump (position : string_crate.Cursor); procedure check_package (position : subpackage_crate.Cursor); root : constant String := get_root (id); namebase : constant String := HT.USS (all_ports (trackers (id).seq_id).port_namebase); result : Boolean := True; procedure log_dump (position : string_crate.Cursor) is info : String := " " & HT.USS (string_crate.Element (position)); begin TIO.Put_Line (trackers (id).log_handle, info); end log_dump; procedure check_package (position : subpackage_crate.Cursor) is rec : subpackage_record renames subpackage_crate.Element (position); subpackage : constant String := HT.USS (rec.subpackage); pkgname : String := calculate_package_name (trackers (id).seq_id, subpackage); command : constant String := chroot & root & environment_override (id) & "/usr/bin/pkg-static query %Fp " & pkgname; comres : String := generic_system_command (command); markers : HT.Line_Markers; begin trackers (id).dynlink.Clear; trackers (id).runpaths.Clear; trackers (id).checkpaths.Clear; trackers (id).goodpaths.Clear; HT.initialize_markers (comres, markers); loop exit when not HT.next_line_present (comres, markers); declare filename : constant String := HT.extract_line (comres, markers); unstripped : Boolean; begin if dynamically_linked (base => root, filename => filename, strip_check => trackers (id).check_strip, unstripped => unstripped) then stack_linked_libraries (id, root, filename); if not passed_runpath_check (id) then result := False; end if; end if; if unstripped then TIO.Put_Line (trackers (id).log_handle, "### WARNING ### " & filename & " is not stripped. " & "See Ravenporter's guide."); end if; end; end loop; if not trackers (id).dynlink.Is_Empty then TIO.Put_Line (trackers (id).log_handle, "===> " & pkgname & " subpackage:"); trackers (id).dynlink.Iterate (log_dump'Access); end if; exception when others => null; end check_package; begin TIO.Put_Line (trackers (id).log_handle, "=> Checking shared library dependencies"); all_ports (trackers (id).seq_id).subpackages.Iterate (check_package'Access); return result; end log_linked_libraries; -------------------------------------------------------------------------------------------- -- dynamically_linked -------------------------------------------------------------------------------------------- function dynamically_linked (base : String; filename : String; strip_check : Boolean; unstripped : out Boolean) return Boolean is command : String := chroot & base & " /usr/bin/file -b -L -e ascii -e encoding -e tar -e compress " & "-m /usr/share/file/magic.mgc " & LAT.Quotation & filename & LAT.Quotation; dynlinked : Boolean; statlinked : Boolean; begin unstripped := False; declare comres : constant String := generic_system_command (command); begin dynlinked := HT.contains (comres, "dynamically linked"); if dynlinked then statlinked := False; else statlinked := HT.contains (comres, "statically linked"); end if; if strip_check then if dynlinked or else statlinked then if HT.contains (comres, ", not stripped") then unstripped := True; end if; end if; end if; return dynlinked; end; exception when others => return False; end dynamically_linked; -------------------------------------------------------------------------------------------- -- passed_runpath_check -------------------------------------------------------------------------------------------- function passed_runpath_check (id : builders) return Boolean is procedure scan (position : string_crate.Cursor); function errmsg_prefix return String; result : Boolean := True; root : constant String := get_root (id); fail_result : Boolean := not trackers (id).rpath_fatal; function errmsg_prefix return String is begin if trackers (id).rpath_fatal then return "### FATAL ERROR ### "; else return "### WARNING ### "; end if; end errmsg_prefix; procedure scan (position : string_crate.Cursor) is procedure squawk; function get_system_lib_level_1 return String; function get_system_lib_level_2 return String; line : String := HT.USS (string_crate.Element (position)); paths : constant String := HT.part_1 (line, " "); library : constant String := HT.part_2 (line, " "); numfields : constant Natural := HT.count_char (paths, LAT.Colon) + 1; attempted : Boolean := False; function get_system_lib_level_1 return String is begin if platform_type = linux then return "/lib/x86_64-linux-gnu"; else return "/lib"; end if; end get_system_lib_level_1; function get_system_lib_level_2 return String is begin if platform_type = linux then return "/usr/lib/x86_64-linux-gnu"; else return "/usr/lib"; end if; end get_system_lib_level_2; systemdir_1 : constant String := get_system_lib_level_1; systemdir_2 : constant String := get_system_lib_level_2; systemlib_1 : constant String := systemdir_1 & "/" & library; systemlib_2 : constant String := systemdir_2 & "/" & library; syslib_1txt : HT.Text := HT.SUS (systemlib_1); syslib_2txt : HT.Text := HT.SUS (systemlib_2); procedure squawk is begin TIO.Put_Line (trackers (id).log_handle, errmsg_prefix & library & " is not in located in " & systemdir_1 & ", " & systemdir_2 & " or within the RPATH/RUNPATH"); end squawk; begin -- Check system library paths first if trackers (id).goodpaths.Contains (syslib_1txt) or else trackers (id).goodpaths.Contains (syslib_2txt) then return; end if; if not trackers (id).checkpaths.Contains (syslib_1txt) then if DIR.Exists (root & systemlib_1) then trackers (id).goodpaths.Append (syslib_1txt); return; end if; trackers (id).checkpaths.Append (syslib_1txt); attempted := True; end if; if not trackers (id).checkpaths.Contains (syslib_2txt) then if DIR.Exists (root & systemlib_2) then trackers (id).goodpaths.Append (syslib_2txt); return; end if; trackers (id).checkpaths.Append (syslib_2txt); attempted := True; end if; if HT.IsBlank (paths) then squawk; result := fail_result; return; end if; for n in 1 .. numfields loop declare testpath : String := HT.specific_field (paths, n, ":"); test_library : String := testpath & "/" & library; test_lib_txt : HT.Text := HT.SUS (test_library); begin if trackers (id).goodpaths.Contains (test_lib_txt) then return; end if; if not trackers (id).checkpaths.Contains (test_lib_txt) then if DIR.Exists (root & test_library) then trackers (id).goodpaths.Append (test_lib_txt); return; end if; trackers (id).checkpaths.Append (test_lib_txt); attempted := True; end if; end; end loop; if attempted then squawk; result := fail_result; end if; end scan; begin trackers (id).runpaths.Iterate (scan'Access); return result; end passed_runpath_check; -------------------------------------------------------------------------------------------- -- timeout_multiplier_x10 -------------------------------------------------------------------------------------------- function timeout_multiplier_x10 return Positive is average5 : constant Float := load_core (instant_load => False); avefloat : constant Float := average5 / Float (PM.configuration.number_cores); begin if avefloat <= 1.0 then return 10; else return Integer (avefloat * 10.0); end if; exception when others => return 10; end timeout_multiplier_x10; -------------------------------------------------------------------------------------------- -- load_core -------------------------------------------------------------------------------------------- function load_core (instant_load : Boolean) return Float is function probe_load return String; ----------------- 123456789-123456789-123456789- -- DFLY/FreeBSD: vm.loadavg: { 0.00 0.00 0.00 } -- NetBSD: vm.loadavg: 0.00 0.00 0.00 -- Darwin: vm.loadavg: { 1.21 1.07 1.15 } -- Linux: 0.00 0.01 0.05 3/382 15409 -- Solaris: [~42 chars]load average: 0.01, 0.01, 0.01 zero : constant Float := 0.0; lo : Integer; function probe_load return String is bsd : constant String := "/usr/bin/env LANG=C /sbin/sysctl vm.loadavg"; lin : constant String := "/bin/cat /proc/loadavg"; sol : constant String := "/usr/bin/uptime"; begin case platform_type is when dragonfly | freebsd | macos => lo := 14; return generic_system_command (bsd); when netbsd | openbsd => lo := 12; return generic_system_command (bsd); when linux => lo := 0; return generic_system_command (lin); when sunos => return generic_system_command (sol); end case; end probe_load; comres : constant String := probe_load; begin case platform_type is when dragonfly | freebsd | netbsd | openbsd | linux | macos => declare stripped : constant String := comres (comres'First + lo .. comres'Last); begin if instant_load then return Float'Value (HT.specific_field (stripped, 1, " ")); else return Float'Value (HT.specific_field (stripped, 2, " ")); end if; end; when sunos => declare stripped : constant String := HT.part_2 (comres, "load average: "); begin if instant_load then return Float'Value (HT.specific_field (stripped, 1, ", ")); else return Float'Value (HT.specific_field (stripped, 2, ", ")); end if; end; end case; exception when others => return zero; end load_core; -------------------------------------------------------------------------------------------- -- builder_status -------------------------------------------------------------------------------------------- function builder_status (id : builders; shutdown : Boolean := False; idle : Boolean := False) return Display.builder_rec is phasestr : constant String := phase2str (phase_trackers (id)); result : Display.builder_rec; orilimit : constant Positive := Display.fld_origin'Length; orishort : constant Natural := orilimit - 1; begin -- 123456789 123456789 123456789 123456789 1234 -- SL elapsed phase lines origin -- 01 00:00:00 extract-depends 9999999 www/joe result.id := id; result.slavid := HT.zeropad (Natural (id), 2); result.LLines := (others => ' '); result.phase := (others => ' '); result.origin := (others => ' '); result.shutdown := False; result.idle := False; if shutdown then -- Overrides "idle" if both Shutdown and Idle are True result.Elapsed := "Shutdown"; result.shutdown := True; return result; end if; if idle then result.Elapsed := "Idle "; result.idle := True; return result; end if; declare catport : constant String := get_port_variant (all_ports (trackers (id).seq_id)); numlines : constant String := format_loglines (trackers (id).loglines); linehead : constant Natural := 8 - numlines'Length; begin result.Elapsed := LOG.elapsed_HH_MM_SS (start => trackers (id).head_time, stop => CAL.Clock); result.LLines (linehead .. 7) := numlines; result.phase (1 .. phasestr'Length) := phasestr; if catport'Length > orilimit then result.origin (1 .. orishort) := catport (catport'First .. catport'First + orishort); result.origin (orilimit) := LAT.Asterisk; else result.origin (1 .. catport'Length) := catport; end if; end; return result; end builder_status; -------------------------------------------------------------------------------------------- -- format_loglines -------------------------------------------------------------------------------------------- function format_loglines (numlines : Natural) return String is begin if numlines < 10000000 then -- 10 million return HT.int2str (numlines); end if; declare kilo : constant Natural := numlines / 1000; kilotxt : constant String := HT.int2str (kilo); begin if numlines < 100000000 then -- 100 million return kilotxt (1 .. 2) & "." & kilotxt (3 .. 5) & 'M'; elsif numlines < 1000000000 then -- 1 billion return kilotxt (1 .. 3) & "." & kilotxt (3 .. 4) & 'M'; else return kilotxt (1 .. 4) & "." & kilotxt (3 .. 3) & 'M'; end if; end; end format_loglines; -------------------------------------------------------------------------------------------- -- mark_file_system -------------------------------------------------------------------------------------------- procedure mark_file_system (id : builders; action : String) is function attributes (action : String) return String; root : constant String := get_root (id); mtfile : constant String := "/etc/mtree." & action & ".exclude"; resfile : TIO.File_Type; function attributes (action : String) return String is core : constant String := "uid,gid,mode,sha1digest"; begin if action = "preconfig" then return core & ",time"; else return core; end if; end attributes; command : constant String := chroot & root & environment_override (id) & " /usr/bin/mtree -X " & mtfile & " -cn -k " & attributes (action) & " -p /"; filename : constant String := root & "/tmp/mtree." & action; begin TIO.Create (File => resfile, Mode => TIO.Out_File, Name => filename); TIO.Put (resfile, generic_system_command (command)); TIO.Close (resfile); exception when others => if TIO.Is_Open (resfile) then TIO.Close (resfile); end if; end mark_file_system; -------------------------------------------------------------------------------------------- -- interact_with_builder -------------------------------------------------------------------------------------------- procedure interact_with_builder (id : builders) is function shell return String; root : constant String := get_root (id); result : Boolean; function shell return String is begin case platform_type is when linux => return "/bin/bash"; when others => return "/bin/sh"; end case; end shell; command : String := chroot & root & environment_override (id, True) & shell; begin TIO.Put_Line ("Entering interactive test mode at the builder root directory."); TIO.Put_Line ("Type 'exit' when done exploring."); result := Unix.external_command (command); end interact_with_builder; -------------------------------------------------------------------------------------------- -- detect_leftovers_and_MIA -------------------------------------------------------------------------------------------- function detect_leftovers_and_MIA (id : builders; action : String; description : String) return Boolean is package crate is new CON.Vectors (Index_Type => Positive, Element_Type => HT.Text, "=" => HT.SU."="); package local_sorter is new crate.Generic_Sorting ("<" => HT.SU."<"); function ignore_modifications return Boolean; procedure print (cursor : crate.Cursor); procedure close_active_modifications; root : constant String := get_root (id); mtfile : constant String := "/etc/mtree." & action & ".exclude"; filename : constant String := root & "/tmp/mtree." & action; command : constant String := chroot & root & environment_override (id) & "/usr/bin/mtree -X " & mtfile & " -f " & filename & " -p /"; lbasewrk : constant String := HT.USS (PM.configuration.dir_localbase); lbase : constant String := lbasewrk (lbasewrk'First + 1 .. lbasewrk'Last); lblen : constant Natural := lbase'Length; status : Integer; skiprest : Boolean; passed : Boolean := True; activemod : Boolean := False; modport : HT.Text := HT.blank; reasons : HT.Text := HT.blank; leftover : crate.Vector; missing : crate.Vector; changed : crate.Vector; markers : HT.Line_Markers; -- we can't use generic_system_command because exit code /= 0 normally comres : String := HT.USS (Unix.piped_command (command, status)); function ignore_modifications return Boolean is -- Some modifications need to be ignored -- A) */ls-R -- #ls-R files from texmf are often regenerated -- B) share/xml/catalog.ports -- # xmlcatmgr is constantly updating catalog.ports, ignore -- C) share/octave/octave_packages -- # Octave packages database, blank lines can be inserted -- # between pre-install and post-deinstall -- D) info/dir | */info/dir -- E) lib/gio/modules/giomodule.cache -- # gio modules cache could be modified for any gio modules -- F) etc/gconf/gconf.xml.defaults/%gconf-tree*.xml -- # gconftool-2 --makefile-uninstall-rule is unpredictable -- G) %%PEARDIR%%/.depdb | %%PEARDIR%%/.filemap -- # The is pear database cache -- H) "." with timestamp modification -- # this happens when ./tmp or ./var is used, which is legal filename : constant String := HT.USS (modport); fnlen : constant Natural := filename'Last; begin if filename = lbase & "/share/xml/catalog.ports" or else filename = lbase & "/share/octave/octave_packages" or else filename = lbase & "/share/info/dir" or else filename = lbase & "/lib/gio/modules/giomodule.cache" or else filename = lbase & "/share/pear/.depdb" or else filename = lbase & "/share/pear/.filemap" then return True; end if; if filename = "." and then HT.equivalent (reasons, "modification") then return True; end if; if fnlen > lblen + 7 and then filename (1 .. lblen + 1) = lbase & "/" then if filename (fnlen - 4 .. fnlen) = "/ls-R" or else filename (fnlen - 14 .. fnlen) = "/share/info/dir" then return True; end if; end if; if fnlen > 47 + lblen and then filename (1 .. 30 + lblen) = lbase & "/etc/gconf/gconf.xml.defaults/" and then filename (fnlen - 3 .. fnlen) = ".xml" then if HT.contains (filename, "/%gconf-tree") then return True; end if; end if; return False; end ignore_modifications; procedure close_active_modifications is begin if activemod and then not ignore_modifications then HT.SU.Append (modport, " [ "); HT.SU.Append (modport, reasons); HT.SU.Append (modport, " ]"); if not changed.Contains (modport) then changed.Append (modport); end if; end if; activemod := False; reasons := HT.blank; modport := HT.blank; end close_active_modifications; procedure print (cursor : crate.Cursor) is dossier : constant String := HT.USS (crate.Element (cursor)); begin TIO.Put_Line (trackers (id).log_handle, LAT.HT & dossier); end print; begin HT.initialize_markers (comres, markers); loop skiprest := False; exit when not HT.next_line_present (comres, markers); declare line : constant String := HT.extract_line (comres, markers); linelen : constant Natural := line'Length; begin if not skiprest and then linelen > 6 then declare caboose : constant String := line (line'Last - 5 .. line'Last); filename : HT.Text := HT.SUS (line (line'First .. line'Last - 6)); begin if caboose = " extra" then close_active_modifications; if not leftover.Contains (filename) then leftover.Append (filename); end if; skiprest := True; end if; end; end if; if not skiprest and then linelen > 7 then declare canopy : constant String := line (line'First .. line'First + 6); filename : HT.Text := HT.SUS (line (line'First + 7 .. line'Last)); begin if canopy = "extra: " then close_active_modifications; if not leftover.Contains (filename) then leftover.Append (filename); end if; skiprest := True; end if; end; end if; if not skiprest and then linelen > 10 then declare caboose : constant String := line (line'Last - 7 .. line'Last); filename : HT.Text := HT.SUS (line (line'First + 2 .. line'Last - 8)); begin if caboose = " missing" then close_active_modifications; if not missing.Contains (filename) then missing.Append (filename); end if; skiprest := True; end if; end; end if; if not skiprest then declare blank8 : constant String := " "; begin if linelen > 5 and then line (line'First) = LAT.HT then -- reason, but only valid if modification is active if activemod then if not HT.IsBlank (reasons) then HT.SU.Append (reasons, " | "); end if; HT.SU.Append (reasons, HT.part_1 (line (line'First + 1 .. line'Last), " ")); end if; skiprest := True; end if; if not skiprest and then line (line'Last) = LAT.Colon then close_active_modifications; activemod := True; modport := HT.SUS (line (line'First .. line'Last - 1)); skiprest := True; end if; if not skiprest and then line (line'Last - 7 .. line'Last) = " changed" then close_active_modifications; activemod := True; modport := HT.SUS (line (line'First .. line'Last - 8)); skiprest := True; end if; end; end if; end; end loop; close_active_modifications; local_sorter.Sort (Container => changed); local_sorter.Sort (Container => missing); local_sorter.Sort (Container => leftover); TIO.Put_Line (trackers (id).log_handle, LAT.LF & "=> Checking for system changes " & description); if not leftover.Is_Empty then passed := False; TIO.Put_Line (trackers (id).log_handle, LAT.LF & " Left over files/directories:"); leftover.Iterate (Process => print'Access); end if; if not missing.Is_Empty then passed := False; TIO.Put_Line (trackers (id).log_handle, LAT.LF & " Missing files/directories:"); missing.Iterate (Process => print'Access); end if; if not changed.Is_Empty then passed := False; TIO.Put_Line (trackers (id).log_handle, LAT.LF & " Modified files/directories:"); changed.Iterate (Process => print'Access); end if; if passed then TIO.Put_Line (trackers (id).log_handle, "Everything is fine."); end if; return passed; end detect_leftovers_and_MIA; -------------------------------------------------------------------------------------------- -- generic_execute -------------------------------------------------------------------------------------------- function generic_execute (id : builders; command : String; dogbite : out Boolean; time_limit : execution_limit) return Boolean is subtype time_cycle is execution_limit range 1 .. time_limit; subtype one_minute is Positive range 1 .. 230; -- lose 10 in rounding type dim_watchdog is array (time_cycle) of Natural; use type Unix.process_exit; watchdog : dim_watchdog; squirrel : time_cycle := time_cycle'First; cycle_done : Boolean := False; pid : Unix.pid_t; status : Unix.process_exit; lock_lines : Natural; quartersec : one_minute := one_minute'First; hangmonitor : constant Boolean := True; truecommand : constant String := ravenexec & " " & LOG.log_name (trackers (id).seq_id) & " " & command; begin dogbite := False; watchdog (squirrel) := trackers (id).loglines; pid := Unix.launch_process (truecommand); if Unix.fork_failed (pid) then return False; end if; loop delay 0.25; if quartersec = one_minute'Last then quartersec := one_minute'First; -- increment squirrel if squirrel = time_cycle'Last then squirrel := time_cycle'First; cycle_done := True; else squirrel := squirrel + 1; end if; if hangmonitor then lock_lines := trackers (id).loglines; if cycle_done then if watchdog (squirrel) = lock_lines then -- Log hasn't advanced in a full cycle so bail out dogbite := True; Unix.kill_process_tree (process_group => pid); delay 5.0; -- Give some time for error to write to log return False; end if; end if; watchdog (squirrel) := lock_lines; end if; else quartersec := quartersec + 1; end if; status := Unix.process_status (pid); if status = Unix.exited_normally then return True; end if; if status = Unix.exited_with_error then return False; end if; end loop; end generic_execute; -------------------------------------------------------------------------------------------- -- watchdog_message -------------------------------------------------------------------------------------------- function watchdog_message (minutes : execution_limit) return String is begin return "### Watchdog killed runaway process! (no activity for" & minutes'Img & " minutes) ###"; end watchdog_message; -------------------------------------------------------------------------------------------- -- assemble_history_record -------------------------------------------------------------------------------------------- function assemble_history_record (slave : builders; pid : port_id; action : Display.history_action) return Display.history_rec is HR : Display.history_rec; HOLast : constant Natural := Display.history_origin'Last; catport : String := get_port_variant (pid); hyphens : constant Display.history_elapsed := "--:--:--"; begin HR.id := slave; HR.slavid := HT.zeropad (Integer (slave), 2); HR.established := True; HR.action := action; HR.origin := (others => ' '); HR.run_elapsed := LOG.elapsed_now; if action = Display.action_shutdown then HR.pkg_elapsed := hyphens; else if action = Display.action_skipped or else action = Display.action_ignored then HR.pkg_elapsed := hyphens; else HR.pkg_elapsed := LOG.elapsed_HH_MM_SS (start => trackers (slave).head_time, stop => trackers (slave).tail_time); end if; if catport'Last > HOLast then HR.origin (1 .. HOLast - 1) := catport (1 .. HOLast - 1); HR.origin (HOLast) := LAT.Asterisk; else HR.origin (1 .. catport'Last) := catport; end if; end if; return HR; end assemble_history_record; -------------------------------------------------------------------------------------------- -- set_log_lines -------------------------------------------------------------------------------------------- procedure set_log_lines (id : builders) is log_path : constant String := LOG.log_name (trackers (id).seq_id); command : constant String := HT.USS (PM.configuration.dir_sysroot) & "/usr/bin/wc -l " & log_path; begin declare numtext : constant String := HT.part_1 (S => HT.trim (generic_system_command (command)), separator => " "); begin trackers (id).loglines := Natural'Value (numtext); end; exception when others => null; -- just skip this cycle end set_log_lines; -------------------------------------------------------------------------------------------- -- elapsed_build -------------------------------------------------------------------------------------------- function elapsed_build (id : builders) return String is begin return LOG.elapsed_HH_MM_SS (start => trackers (id).head_time, stop => trackers (id).tail_time); end elapsed_build; -------------------------------------------------------------------------------------------- -- run_makesum -------------------------------------------------------------------------------------------- procedure run_makesum (id : builders) is root : constant String := get_root (id); command : constant String := chroot & root & environment_override (id) & chroot_make_program & " -C /port makesum"; distinfo : constant String := root & "/port/distinfo"; result : constant String := generic_system_command (command); begin TIO.Put_Line (result); if DIR.Exists (distinfo) then TIO.Put_Line ("Copying " & distinfo & " to current directory"); DIR.Copy_File (distinfo, "distinfo"); end if; end run_makesum; -------------------------------------------------------------------------------------------- -- get_port_prefix -------------------------------------------------------------------------------------------- function get_port_prefix (id : builders) return String is root : constant String := get_root (id); command : constant String := chroot & root & environment_override (id) & chroot_make_program & " -C /port -V PREFIX"; result : constant String := generic_system_command (command); begin return HT.first_line (result); end get_port_prefix; end PortScan.Buildcycle;
zhmu/ananas
Ada
209
ads
package Opt59_Pkg is type Boolean_Vector is array (1 .. 8) of Boolean; function Get_BV1 return Boolean_Vector; function Get_BV2 return Boolean_Vector; procedure Test (B : Boolean); end Opt59_Pkg;
reznikmm/matreshka
Ada
3,679
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- 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$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Meta_Date_String_Elements is pragma Preelaborate; type ODF_Meta_Date_String is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Meta_Date_String_Access is access all ODF_Meta_Date_String'Class with Storage_Size => 0; end ODF.DOM.Meta_Date_String_Elements;
Gabriel-Degret/adalib
Ada
948
ads
-- Standard Ada library specification -- Copyright (c) 2003-2018 Maxim Reznik <[email protected]> -- Copyright (c) 2004-2016 AXE Consultants -- Copyright (c) 2004, 2005, 2006 Ada-Europe -- Copyright (c) 2000 The MITRE Corporation, Inc. -- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc. -- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual --------------------------------------------------------------------------- generic type T (<>) is abstract tagged limited private; type Parameters (<>) is limited private; with function Constructor (Params : not null access Parameters) return T is abstract; function Ada.Tags.Generic_Dispatching_Constructor (The_Tag : in Tag; Params : not null access Parameters) return T'Class; pragma Preelaborate (Ada.Tags.Generic_Dispatching_Constructor); pragma Convention (Intrinsic, Ada.Tags.Generic_Dispatching_Constructor);
tj800x/SPARKNaCl
Ada
1,366
ads
package SPARKNaCl.MAC with SPARK_Mode => On is -- Limited, so no assignment or comparison, and always -- pass-by-reference. type Poly_1305_Key is limited private; function Construct (K : in Bytes_32) return Poly_1305_Key with Global => null; procedure Construct (K : out Poly_1305_Key; X : in Bytes_32) with Global => null; function Serialize (K : in Poly_1305_Key) return Bytes_32 with Global => null; procedure Sanitize (K : out Poly_1305_Key) with Global => null; -------------------------------------------------------- -- One-time authentication -------------------------------------------------------- procedure Onetimeauth (Output : out Bytes_16; M : in Byte_Seq; K : in Poly_1305_Key) with Global => null, Pre => M'First = 0; function Onetimeauth_Verify (H : in Bytes_16; M : in Byte_Seq; K : in Poly_1305_Key) return Boolean with Global => null, Pre => M'First = 0; private -- Note - also limited here in the full view to ensure -- no assignment and pass-by-reference in the body. type Poly_1305_Key is limited record F : Bytes_32; end record; end SPARKNaCl.MAC;
sf17k/sdlada
Ada
1,480
adb
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2014-2015 Luke A. Guest -- -- 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. -------------------------------------------------------------------------------------------------------------------- package body SDL.Platform is -- Bring in the platform specific version for each build of the library. It's also defined as inline so -- that the compiler can eliminate redundant code in the static expressions that use this function. function Get return Platforms is separate; end SDL.Platform;
reznikmm/matreshka
Ada
3,714
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- 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$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Style_Rel_Width_Attributes is pragma Preelaborate; type ODF_Style_Rel_Width_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Style_Rel_Width_Attribute_Access is access all ODF_Style_Rel_Width_Attribute'Class with Storage_Size => 0; end ODF.DOM.Style_Rel_Width_Attributes;
AdaCore/Ada_Drivers_Library
Ada
8,360
ads
-- This spec has been automatically generated from STM32F40x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.SYSCFG is pragma Preelaborate; --------------- -- Registers -- --------------- subtype MEMRM_MEM_MODE_Field is HAL.UInt2; -- memory remap register type MEMRM_Register is record -- MEM_MODE MEM_MODE : MEMRM_MEM_MODE_Field := 16#0#; -- unspecified Reserved_2_31 : HAL.UInt30 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MEMRM_Register use record MEM_MODE at 0 range 0 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; -- peripheral mode configuration register type PMC_Register is record -- unspecified Reserved_0_22 : HAL.UInt23 := 16#0#; -- Ethernet PHY interface selection MII_RMII_SEL : Boolean := False; -- unspecified Reserved_24_31 : HAL.UInt8 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for PMC_Register use record Reserved_0_22 at 0 range 0 .. 22; MII_RMII_SEL at 0 range 23 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; -- EXTICR1_EXTI array element subtype EXTICR1_EXTI_Element is HAL.UInt4; -- EXTICR1_EXTI array type EXTICR1_EXTI_Field_Array is array (0 .. 3) of EXTICR1_EXTI_Element with Component_Size => 4, Size => 16; -- Type definition for EXTICR1_EXTI type EXTICR1_EXTI_Field (As_Array : Boolean := False) is record case As_Array is when False => -- EXTI as a value Val : HAL.UInt16; when True => -- EXTI as an array Arr : EXTICR1_EXTI_Field_Array; end case; end record with Unchecked_Union, Size => 16; for EXTICR1_EXTI_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- external interrupt configuration register 1 type EXTICR1_Register is record -- EXTI x configuration (x = 0 to 3) EXTI : EXTICR1_EXTI_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for EXTICR1_Register use record EXTI at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -- EXTICR2_EXTI array element subtype EXTICR2_EXTI_Element is HAL.UInt4; -- EXTICR2_EXTI array type EXTICR2_EXTI_Field_Array is array (4 .. 7) of EXTICR2_EXTI_Element with Component_Size => 4, Size => 16; -- Type definition for EXTICR2_EXTI type EXTICR2_EXTI_Field (As_Array : Boolean := False) is record case As_Array is when False => -- EXTI as a value Val : HAL.UInt16; when True => -- EXTI as an array Arr : EXTICR2_EXTI_Field_Array; end case; end record with Unchecked_Union, Size => 16; for EXTICR2_EXTI_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- external interrupt configuration register 2 type EXTICR2_Register is record -- EXTI x configuration (x = 4 to 7) EXTI : EXTICR2_EXTI_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for EXTICR2_Register use record EXTI at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -- EXTICR3_EXTI array element subtype EXTICR3_EXTI_Element is HAL.UInt4; -- EXTICR3_EXTI array type EXTICR3_EXTI_Field_Array is array (8 .. 11) of EXTICR3_EXTI_Element with Component_Size => 4, Size => 16; -- Type definition for EXTICR3_EXTI type EXTICR3_EXTI_Field (As_Array : Boolean := False) is record case As_Array is when False => -- EXTI as a value Val : HAL.UInt16; when True => -- EXTI as an array Arr : EXTICR3_EXTI_Field_Array; end case; end record with Unchecked_Union, Size => 16; for EXTICR3_EXTI_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- external interrupt configuration register 3 type EXTICR3_Register is record -- EXTI x configuration (x = 8 to 11) EXTI : EXTICR3_EXTI_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for EXTICR3_Register use record EXTI at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -- EXTICR4_EXTI array element subtype EXTICR4_EXTI_Element is HAL.UInt4; -- EXTICR4_EXTI array type EXTICR4_EXTI_Field_Array is array (12 .. 15) of EXTICR4_EXTI_Element with Component_Size => 4, Size => 16; -- Type definition for EXTICR4_EXTI type EXTICR4_EXTI_Field (As_Array : Boolean := False) is record case As_Array is when False => -- EXTI as a value Val : HAL.UInt16; when True => -- EXTI as an array Arr : EXTICR4_EXTI_Field_Array; end case; end record with Unchecked_Union, Size => 16; for EXTICR4_EXTI_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- external interrupt configuration register 4 type EXTICR4_Register is record -- EXTI x configuration (x = 12 to 15) EXTI : EXTICR4_EXTI_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for EXTICR4_Register use record EXTI at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -- Compensation cell control register type CMPCR_Register is record -- Read-only. Compensation cell power-down CMP_PD : Boolean; -- unspecified Reserved_1_7 : HAL.UInt7; -- Read-only. READY READY : Boolean; -- unspecified Reserved_9_31 : HAL.UInt23; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CMPCR_Register use record CMP_PD at 0 range 0 .. 0; Reserved_1_7 at 0 range 1 .. 7; READY at 0 range 8 .. 8; Reserved_9_31 at 0 range 9 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- System configuration controller type SYSCFG_Peripheral is record -- memory remap register MEMRM : aliased MEMRM_Register; -- peripheral mode configuration register PMC : aliased PMC_Register; -- external interrupt configuration register 1 EXTICR1 : aliased EXTICR1_Register; -- external interrupt configuration register 2 EXTICR2 : aliased EXTICR2_Register; -- external interrupt configuration register 3 EXTICR3 : aliased EXTICR3_Register; -- external interrupt configuration register 4 EXTICR4 : aliased EXTICR4_Register; -- Compensation cell control register CMPCR : aliased CMPCR_Register; end record with Volatile; for SYSCFG_Peripheral use record MEMRM at 16#0# range 0 .. 31; PMC at 16#4# range 0 .. 31; EXTICR1 at 16#8# range 0 .. 31; EXTICR2 at 16#C# range 0 .. 31; EXTICR3 at 16#10# range 0 .. 31; EXTICR4 at 16#14# range 0 .. 31; CMPCR at 16#20# range 0 .. 31; end record; -- System configuration controller SYSCFG_Periph : aliased SYSCFG_Peripheral with Import, Address => System'To_Address (16#40013800#); end STM32_SVD.SYSCFG;
AaronC98/PlaneSystem
Ada
8,466
adb
------------------------------------------------------------------------------ -- Ada Web Server -- -- -- -- Copyright (C) 2004-2012, AdaCore -- -- -- -- 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. -- -- -- -- -- -- -- -- -- -- -- -- 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/>. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ------------------------------------------------------------------------------ with Ada.Characters.Handling; with Ada.Strings.Fixed; with AWS.Services.Split_Pages.Shared; package body AWS.Services.Split_Pages.Alpha is use Ada; --------------------- -- Get_Page_Ranges -- --------------------- overriding function Get_Page_Ranges (This : Splitter; Table : Templates.Translate_Set) return Ranges_Table is use Templates; procedure Set_Entry (C : Character; Index : Natural); -- Set index for character C entry Self : Splitter renames Splitter (This.Self.all); Key_Vec : constant Tag := Shared.Associated_Vector (Table, To_String (Self.Key)); Result : Ranges_Table (1 .. 26 + 2); Res_Inx : Natural := Natural'Last; Initial : Character; --------------- -- Set_Entry -- --------------- procedure Set_Entry (C : Character; Index : Natural) is begin if C < Initial then -- Not sorted raise Splitter_Error; end if; case C is when ' ' => Self.Index (1) := Index; when '0' .. '9' => Self.Index (2) := Index; when 'A' .. 'Z' => Self.Index (Alpha_Value (C)) := Index; when others => -- Not an empty field, numeric or letter raise Splitter_Error; end case; end Set_Entry; begin -- Clear context from (possible) previous runs Clear (Self.HREFS_V); Clear (Self.INDEXES_V); Self.Index := (others => 0); -- Build table -- Initialize iteration with the first item declare use Ada.Characters.Handling; use Ada.Strings.Fixed; Name : constant String := Trim (Item (Key_Vec, 1), Strings.Left); begin if Name = "" then Initial := ' '; else Initial := To_Upper (Name (Name'First)); end if; Set_Entry (Initial, 1); Result (1).First := 1; Res_Inx := 1; end; -- For all other items for I in 2 .. Size (Key_Vec) loop declare use Ada.Characters.Handling; use Ada.Strings.Fixed; Name : constant String := Trim (Item (Key_Vec, I), Strings.Left); New_Initial : Character; begin if Name = "" then New_Initial := ' '; else New_Initial := To_Upper (Name (Name'First)); end if; if New_Initial /= Initial and then (Initial not in '0' .. '9' or else New_Initial not in '0' .. '9') then -- This is a new entry, record the last item for previous entry Result (Res_Inx).Last := I - 1; -- Initialize new entry Res_Inx := Res_Inx + 1; Result (Res_Inx).First := I; Set_Entry (New_Initial, Res_Inx); Initial := New_Initial; end if; end; end loop; -- Last item for the last entry Result (Res_Inx).Last := Size (Key_Vec); return Result (1 .. Res_Inx); end Get_Page_Ranges; ---------------------- -- Get_Translations -- ---------------------- overriding function Get_Translations (This : Splitter; Page : Positive; URIs : URI_Table; Ranges : Ranges_Table) return Templates.Translate_Set is use Templates; pragma Unreferenced (Ranges); procedure Add_Entry (Index : Natural); -- Append entry for the given index into the hrefs vector Self : Splitter renames Splitter (This.Self.all); Previous : Natural; Next : Natural; Page_Inx : Alpha_Index := Alpha_Index'Last; --------------- -- Add_Entry -- --------------- procedure Add_Entry (Index : Natural) is begin if Index = 0 then -- This entry has no element Self.HREFS_V := Self.HREFS_V & Self.Default_Href; else Self.HREFS_V := Self.HREFS_V & URIs (Index); end if; end Add_Entry; begin if Size (Self.HREFS_V) = 0 then -- Not yet built Self.INDEXES_V := +"<>"; Add_Entry (Self.Index (1)); Self.INDEXES_V := Self.INDEXES_V & "0..9"; Add_Entry (Self.Index (2)); for C in Character range 'A' .. 'Z' loop Self.INDEXES_V := Self.INDEXES_V & C; Add_Entry (Self.Index (Alpha_Value (C))); end loop; end if; -- Compute page index for I in reverse Alpha_Index loop if Self.Index (I) /= 0 and then Self.Index (I) <= Page then Page_Inx := I; exit; end if; end loop; -- Compute Previous and Next, we need to find the previous/next non -- empty entry. Previous := 0; for P in reverse 1 .. Page_Inx - 1 loop if Self.Index (P) /= 0 then Previous := Self.Index (P); exit; end if; end loop; Next := 0; for P in Page_Inx + 1 .. Alpha_Index'Last loop if Self.Index (P) /= 0 then Next := Self.Index (P); exit; end if; end loop; return To_Set ((Assoc ("PREVIOUS", Shared.Safe_URI (URIs, Previous)), Assoc ("NEXT", Shared.Safe_URI (URIs, Next)), Assoc ("FIRST", URIs (URIs'First)), Assoc ("LAST", URIs (URIs'Last)), Assoc ("PAGE_INDEX", Positive (Page_Inx)), Assoc ("HREFS_V", Self.HREFS_V), Assoc ("INDEXES_V", Self.INDEXES_V))); end Get_Translations; ---------------------- -- Set_Default_Href -- ---------------------- procedure Set_Default_Href (This : in out Splitter; Href : String) is begin This.Default_Href := To_Unbounded_String (Href); end Set_Default_Href; ------------- -- Set_Key -- ------------- procedure Set_Key (This : in out Splitter; Key : String) is begin This.Key := To_Unbounded_String (Key); end Set_Key; end AWS.Services.Split_Pages.Alpha;
zhmu/ananas
Ada
4,344
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . I O -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2022, 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. -- -- -- ------------------------------------------------------------------------------ package body System.IO is Current_Out : File_Type := Stdout; pragma Atomic (Current_Out); -- Current output file (modified by Set_Output) -------------- -- New_Line -- -------------- procedure New_Line (Spacing : Positive := 1) is begin for J in 1 .. Spacing loop Put (ASCII.LF); end loop; end New_Line; --------- -- Put -- --------- procedure Put (X : Integer) is procedure Put_Int (X : Integer); pragma Import (C, Put_Int, "put_int"); procedure Put_Int_Err (X : Integer); pragma Import (C, Put_Int_Err, "put_int_stderr"); begin case Current_Out is when Stdout => Put_Int (X); when Stderr => Put_Int_Err (X); end case; end Put; procedure Put (C : Character) is procedure Put_Char (C : Integer); pragma Import (C, Put_Char, "put_char"); procedure Put_Char_Stderr (C : Integer); pragma Import (C, Put_Char_Stderr, "put_char_stderr"); begin case Current_Out is when Stdout => Put_Char (Character'Pos (C)); when Stderr => Put_Char_Stderr (Character'Pos (C)); end case; end Put; procedure Put (S : String) is begin for J in S'Range loop Put (S (J)); end loop; end Put; -------------- -- Put_Line -- -------------- procedure Put_Line (S : String) is begin Put (S); New_Line; end Put_Line; --------------------- -- Standard_Output -- --------------------- function Standard_Output return File_Type is begin return Stdout; end Standard_Output; -------------------- -- Standard_Error -- -------------------- function Standard_Error return File_Type is begin return Stderr; end Standard_Error; ---------------- -- Set_Output -- ---------------- procedure Set_Output (File : File_Type) is begin Current_Out := File; end Set_Output; end System.IO;
VMika/DES_Ada
Ada
4,264
adb
with P_StructuralTypes; use P_StructuralTypes; with Ada.Text_IO; use Ada.Text_IO; with Ada.Sequential_IO; with Ada.Characters.Handling; use Ada.Characters.Handling; with Ada.Strings.Unbounded.Text_IO; with Ada.Streams; use Ada.Streams; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Calendar; use Ada.Calendar; package body P_deshandler is procedure Process (Self : in out DesHandler) is InputLink : aliased InputHandler; IPLink : aliased IPHandler; KeyGenLink : aliased KeyHandler; FeistelLink : aliased FeistelHandler; ReverseIPLink : aliased ReverseIPHandler; OutputLink : aliased OutputHandler; Start : Time; Finish : Time; Final_Time : Duration; begin Self.Process_Request; Start := Clock; InputLink := Make (InputLink,Self.Input_Name); IPLink := Make (IPLink); KeyGenLink := Make (KeyGenLink); FeistelLink := Make (FeistelLink); FeistelLink.Set_Mode(Self.Mode); ReverseIPLink := Make (ReverseIPLink); OutputLink := Make (OutputLink); OutputLink.Set_Output_Name(Self.Output_Name); Self.InputLink := InputLink; Self.IPLink := IPLink; Self.KeyGenLink := KeyGenLink; Self.FeistelLink := FeistelLink; Self.ReverseIPLink := ReverseIPLink; Self.OutputLink := OutputLink; Self.Handle; Finish := Clock; Final_Time := Finish - Start; Put_Line (Final_Time'Image); end; procedure Handle (Self : in out DesHandler) is begin Put("Container created") ; New_Line; Self.Create_Binary_Data_Container; Put("Handlers order set") ; New_Line; Self.Set_Handlers_Order; Put("Handlers containers set") ; New_Line; Self.Set_Handlers_Container; Self.InputLink.Handle; end; procedure Create_Binary_Data_Container (Self : in out DesHandler) is begin declare Ptr_BinaryContainer : constant BinaryContainer_Access := new T_BinaryContainer(1..Self.InputLink.Get_Input_Size); begin Self.Ptr_Container := Ptr_BinaryContainer; end; end; procedure Process_Request (Self : in out DesHandler) is Tmp_Mode : Character := ' '; Tmp_Key : Unbounded_String; begin while (Tmp_Mode /= 'D' and Tmp_Mode /= 'E') loop Put ("Choose mode of algorithm (E for encryption, D for deciphering) : "); Tmp_Mode := To_String(Ada.Strings.Unbounded.Text_IO.Get_Line)(1); end loop; Self.Mode := Tmp_Mode; Put ("Choose the input file : "); Self.Input_Name := Ada.Strings.Unbounded.Text_IO.Get_Line; New_Line; Put ("Choose the output file (a new file will be created) : "); Self.Output_Name := Ada.Strings.Unbounded.Text_IO.Get_Line; while Length(Tmp_Key) /= 8 loop Put ("Choose a key (must be exactly 8 characters long) : "); Tmp_Key := Ada.Strings.Unbounded.Text_IO.Get_Line; New_Line; end loop; Self.Ptr_Key.all := To_String(Tmp_Key); end; procedure Set_Handlers_Order (Self : in out DesHandler) is begin Self.InputLink.Set_NextHandler(Self.IPLink'Unchecked_Access); Self.IPLink.Set_NextHandler(Self.KeyGenLink'Unchecked_Access); Self.KeyGenLink.Set_NextHandler(Self.FeistelLink'Unchecked_Access); Self.FeistelLink.Set_NextHandler(Self.ReverseIPLink'Unchecked_Access); Self.ReverseIPLink.Set_NextHandler(Self.OutputLink'Unchecked_Access); end; procedure Set_Handlers_Container (Self : in out DesHandler) is begin Self.InputLink.Set_BinaryContainer(Self.Ptr_Container); Self.IPLink.Set_BinaryContainer(Self.Ptr_Container); Self.FeistelLink.Set_BinaryContainer(Self.Ptr_Container); Self.ReverseIPLink.Set_BinaryContainer(Self.Ptr_Container); Self.OutputLink.Set_BinaryContainer(Self.Ptr_Container); Self.KeyGenLink.Set_KeyAccess(Self.Ptr_Key); Self.KeyGenLink.Set_SubKeyArrayAccess(Self.Ptr_SubKey_Array); Self.FeistelLink.Set_SubKeyArrayAccess(Self.Ptr_SubKey_Array); end; end P_deshandler;
sparre/Command-Line-Parser-Generator
Ada
178
adb
with Ada.Text_IO; package body Subtype_Chains_3 is procedure Run (Even : in Two) is begin Ada.Text_IO.Put_Line (Two'Image (Even)); end Run; end Subtype_Chains_3;
onox/orka
Ada
29,596
adb
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2016 onox <[email protected]> -- -- 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 System; with Ada.Containers.Indefinite_Hashed_Maps; with Ada.Directories; with Ada.Strings.Hash; with Ada.Unchecked_Deallocation; with JSON.Parsers; with GL.Types.Indirect; with Orka.glTF.Buffers; with Orka.glTF.Accessors; with Orka.glTF.Meshes; with Orka.glTF.Scenes; with Orka.OS; with Orka.Jobs; with Orka.Logging.Default; with Orka.Resources.Locations; with Orka.Strings; with Orka.Types; package body Orka.Resources.Models.glTF is use all type Orka.Logging.Default_Module; use all type Orka.Logging.Severity; procedure Log is new Orka.Logging.Default.Generic_Log (Resource_Loader); Default_Root_Name : constant String := "root"; package String_Maps is new Ada.Containers.Indefinite_Hashed_Maps (Key_Type => String, Element_Type => Natural, Hash => Ada.Strings.Hash, Equivalent_Keys => "="); ----------------------------------------------------------------------------- type Time_Kind is (Time_Reading, Time_Parsing, Time_Processing, Time_Buffers, Time_Views, Time_Accessors, Time_Meshes, Time_Nodes, Time_Scenes, Time_Scene_Tree, Time_Write_Buffers); type Times_Data is array (Time_Kind) of Duration; type GLTF_Data (Maximum_Nodes, Maximum_Accessors : Natural) is limited record Directory : SU.Unbounded_String; Location : Locations.Location_Ptr; Buffers : Orka.glTF.Buffers.Buffer_Vectors.Vector (Capacity => 8); Views : Orka.glTF.Buffers.Buffer_View_Vectors.Vector (Capacity => Maximum_Accessors); Accessors : Orka.glTF.Accessors.Accessor_Vectors.Vector (Capacity => Maximum_Accessors); Meshes : Orka.glTF.Meshes.Mesh_Vectors.Vector (Capacity => Maximum_Nodes); Nodes : Orka.glTF.Scenes.Node_Vectors.Vector (Capacity => Maximum_Nodes); Scenes : Orka.glTF.Scenes.Scene_Vectors.Vector (Capacity => 8); Default_Scene : Long_Integer; Times : Times_Data := (others => 0.0); Start_Time : Time; Manager : Managers.Manager_Ptr; end record; type GLTF_Data_Access is access GLTF_Data; procedure Free_Data is new Ada.Unchecked_Deallocation (Object => GLTF_Data, Name => GLTF_Data_Access); package GLTF_Data_Pointers is new Orka.Smart_Pointers (GLTF_Data, GLTF_Data_Access, Free_Data); ----------------------------------------------------------------------------- type GLTF_Parse_Job is new Jobs.Abstract_Job with record Data : Loaders.Resource_Data; Manager : Managers.Manager_Ptr; Location : Locations.Location_Ptr; end record; type GLTF_Finish_Processing_Job is new Jobs.Abstract_Job with record Data : GLTF_Data_Pointers.Mutable_Pointer; Path : SU.Unbounded_String; end record; type GLTF_Create_Model_Job is new Jobs.Abstract_Job and Jobs.GPU_Job with record Data : GLTF_Data_Pointers.Mutable_Pointer; Path : SU.Unbounded_String; Scene : Model_Scene_Ptr; Vertices, Indices : Natural; end record; type GLTF_Write_Buffers_Job is new Jobs.Abstract_Job with record Data : GLTF_Data_Pointers.Mutable_Pointer; Model : Model_Ptr; end record; type GLTF_Finish_Loading_Job is new Jobs.Abstract_Job and Jobs.GPU_Job with record Data : GLTF_Data_Pointers.Mutable_Pointer; Path : SU.Unbounded_String; Model : Model_Ptr; Parts, Vertices, Indices : Natural; Start_Time : Time; end record; ----------------------------------------------------------------------------- -- EXECUTE PROCEDURES -- ----------------------------------------------------------------------------- overriding procedure Execute (Object : GLTF_Parse_Job; Context : Jobs.Execution_Context'Class); overriding procedure Execute (Object : GLTF_Finish_Processing_Job; Context : Jobs.Execution_Context'Class); overriding procedure Execute (Object : GLTF_Create_Model_Job; Context : Jobs.Execution_Context'Class); overriding procedure Execute (Object : GLTF_Write_Buffers_Job; Context : Jobs.Execution_Context'Class); overriding procedure Execute (Object : GLTF_Finish_Loading_Job; Context : Jobs.Execution_Context'Class); ----------------------------------------------------------------------------- procedure Add_Nodes (Scene : in out Trees.Tree; Parts : in out String_Maps.Map; Nodes : in out Orka.glTF.Scenes.Node_Vectors.Vector; Parents : Orka.glTF.Scenes.Natural_Vectors.Vector) is Current_Parents, Next_Parents : Orka.glTF.Scenes.Natural_Vectors.Vector; begin -- Initialize Current_Parents with the elements in Parents for Parent_Index of Parents loop Current_Parents.Append (Parent_Index); end loop; -- Add the children of Current_Parents, and then the -- children of those children, etc. etc. loop for Parent_Index of Current_Parents loop declare Parent_Node : Orka.glTF.Scenes.Node renames Nodes (Parent_Index); Parent_Name : String renames Orka.glTF.To_String (Parent_Node.Name); use type Orka.glTF.Scenes.Transform_Kind; begin -- Use "matrix" or TRS for the local transform if Parent_Node.Transform = Orka.glTF.Scenes.Matrix then Scene.Set_Local_Transform (Scene.To_Cursor (Parent_Name), Parent_Node.Matrix); else declare PN : Orka.glTF.Scenes.Node renames Parent_Node; use Transforms; begin Scene.Set_Local_Transform (Scene.To_Cursor (Parent_Name), T (PN.Translation) * R (PN.Rotation) * S (PN.Scale)); end; end if; -- Add the children to the scene as nodes for Child_Index of Parent_Node.Children loop Scene.Add_Node (Orka.glTF.To_String (Nodes (Child_Index).Name), Parent_Name); Next_Parents.Append (Child_Index); end loop; -- Add mesh as MDI part by mapping the parent (a node) to the mesh index if Parent_Node.Mesh /= Orka.glTF.Undefined then Parts.Insert (Parent_Name, Parent_Node.Mesh); end if; end; end loop; exit when Next_Parents.Is_Empty; Current_Parents := Next_Parents; Next_Parents.Clear; end loop; end Add_Nodes; function Mesh_Node_Cursors (Parts : String_Maps.Map; Scene : Trees.Tree) return Cursor_Array_Holder.Holder is Shapes : Cursor_Array (1 .. Positive (Parts.Length)); procedure Set_Name (Position : String_Maps.Cursor) is Mesh_Index : Natural renames String_Maps.Element (Position); Node_Name : String renames String_Maps.Key (Position); begin Shapes (Mesh_Index + 1) := Scene.To_Cursor (Node_Name); end Set_Name; begin Parts.Iterate (Set_Name'Access); return Cursor_Array_Holder.To_Holder (Shapes); end Mesh_Node_Cursors; function Bounds_List (Accessors : Orka.glTF.Accessors.Accessor_Vectors.Vector; Meshes : in out Orka.glTF.Meshes.Mesh_Vectors.Vector) return Orka.Types.Singles.Vector4_Array is use Orka.glTF.Accessors; use all type Orka.glTF.Meshes.Attribute_Kind; Mesh_Index : GL.Types.Size := 1; begin return Result : Orka.Types.Singles.Vector4_Array (1 .. GL.Types.Size (Meshes.Length) * 2) do for Mesh of Meshes loop declare First_Primitive : Orka.glTF.Meshes.Primitive renames Mesh.Primitives; Attribute_Position : constant Natural := First_Primitive.Attributes (Position); Accessor_Position : Accessor renames Accessors (Attribute_Position); pragma Assert (Accessor_Position.Bounds); begin Result (Mesh_Index + 0) := Accessor_Position.Min_Bounds; Result (Mesh_Index + 1) := Accessor_Position.Max_Bounds; Mesh_Index := Mesh_Index + 2; end; end loop; end return; end Bounds_List; generic type Target_Type is private; type Target_Array is array (GL.Types.Size range <>) of aliased Target_Type; type Target_Array_Access is access Target_Array; package Buffer_View_Conversions is generic type Source_Type is private; type Source_Array is array (GL.Types.Size range <>) of aliased Source_Type; with procedure Cast (Value : Source_Type; Result : out Target_Type); procedure Convert_Array (Elements : Source_Array; Result : out Target_Array); generic type Source_Type is private; type Source_Array is array (GL.Types.Size range <>) of aliased Source_Type; with procedure Convert_Array (Elements : Source_Array; Result : out Target_Array); procedure Get_Array (Accessor : Orka.glTF.Accessors.Accessor; Buffers : Orka.glTF.Buffers.Buffer_Vectors.Vector; View : Orka.glTF.Buffers.Buffer_View; Target : not null Target_Array_Access); end Buffer_View_Conversions; package body Buffer_View_Conversions is procedure Convert_Array (Elements : Source_Array; Result : out Target_Array) is begin for Index in Elements'Range loop Cast (Elements (Index), Result (Index)); end loop; end Convert_Array; procedure Get_Array (Accessor : Orka.glTF.Accessors.Accessor; Buffers : Orka.glTF.Buffers.Buffer_Vectors.Vector; View : Orka.glTF.Buffers.Buffer_View; Target : not null Target_Array_Access) is use Orka.glTF.Accessors; Count : constant Positive := Attribute_Length (Accessor.Kind) * Accessor.Count; Bytes_Per_Element : constant Positive := Bytes_Element (Accessor.Component); pragma Assert (View.Length / Bytes_Per_Element = Count); pragma Assert (Source_Type'Size / System.Storage_Unit = Bytes_Per_Element); procedure Extract is new Orka.glTF.Buffers.Extract_From_Buffer (Source_Type, Source_Array); type Source_Array_Access is access Source_Array; procedure Free_Array is new Ada.Unchecked_Deallocation (Object => Source_Array, Name => Source_Array_Access); Source : Source_Array_Access := new Source_Array (Target.all'Range); begin Extract (Buffers, View, Source.all); Convert_Array (Source.all, Target.all); Free_Array (Source); end Get_Array; end Buffer_View_Conversions; procedure Count_Parts (Index_Kind : GL.Types.Index_Type; Accessors : Orka.glTF.Accessors.Accessor_Vectors.Vector; Meshes : in out Orka.glTF.Meshes.Mesh_Vectors.Vector; Vertices, Indices : out Natural) is use type Orka.glTF.Accessors.Component_Kind; use type GL.Types.Index_Type; use Orka.glTF.Accessors; use all type Orka.glTF.Meshes.Attribute_Kind; Count_Vertices : Natural := 0; Count_Indices : Natural := 0; begin for Mesh of Meshes loop declare Mesh_Name : String renames Orka.glTF.To_String (Mesh.Name); First_Primitive : Orka.glTF.Meshes.Primitive renames Mesh.Primitives; Attribute_Position : constant Natural := First_Primitive.Attributes (Position); Attribute_Normal : constant Natural := First_Primitive.Attributes (Normal); Attribute_UV : constant Natural := First_Primitive.Attributes (Texcoord_0); pragma Assert (First_Primitive.Indices /= Orka.glTF.Undefined); Attribute_Index : constant Natural := First_Primitive.Indices; Accessor_Position : Accessor renames Accessors (Attribute_Position); Accessor_Normal : Accessor renames Accessors (Attribute_Normal); Accessor_UV : Accessor renames Accessors (Attribute_UV); pragma Assert (Accessor_Position.Component = Orka.glTF.Accessors.Float and then Accessor_Normal.Component = Orka.glTF.Accessors.Float and then Accessor_UV.Component = Orka.glTF.Accessors.Float); pragma Assert (Accessor_Position.Kind = Orka.glTF.Accessors.Vector3 and then Accessor_Normal.Kind = Orka.glTF.Accessors.Vector3 and then Accessor_UV.Kind = Orka.glTF.Accessors.Vector2); pragma Assert (Accessor_Position.Count = Accessor_Normal.Count and then Accessor_Position.Count = Accessor_UV.Count); Accessor_Index : Accessor renames Accessors (Attribute_Index); pragma Assert (Accessor_Index.Kind = Orka.glTF.Accessors.Scalar); pragma Assert (Unsigned_Type (Accessor_Index.Component) <= Index_Kind, "Index of mesh " & Mesh_Name & " has type " & GL.Types.Index_Type'Image (Unsigned_Type (Accessor_Index.Component)) & " but expected " & Index_Kind'Image & " or lower"); begin Count_Vertices := Count_Vertices + Accessor_Position.Count; Count_Indices := Count_Indices + Accessor_Index.Count; end; end loop; Vertices := Count_Vertices; Indices := Count_Indices; end Count_Parts; procedure Add_Parts (Batch : in out Rendering.Buffers.MDI.Batch; Buffers : Orka.glTF.Buffers.Buffer_Vectors.Vector; Views : Orka.glTF.Buffers.Buffer_View_Vectors.Vector; Accessors : Orka.glTF.Accessors.Accessor_Vectors.Vector; Meshes : in out Orka.glTF.Meshes.Mesh_Vectors.Vector) is use GL.Types; use Orka.glTF.Accessors; use Orka.glTF.Buffers; use all type Orka.glTF.Meshes.Attribute_Kind; package Index_Conversions is new Buffer_View_Conversions (Unsigned_32, Unsigned_32_Array, Indirect.UInt_Array_Access); package Vertex_Conversions is new Buffer_View_Conversions (Float_16, Float_16_Array, Indirect.Half_Array_Access); procedure Get_Singles is new Vertex_Conversions.Get_Array (Float_32, Orka.Float_32_Array, Orka.Types.Convert); procedure Cast (Value : UShort; Result : out Unsigned_32) is begin Result := Unsigned_32 (Value); end Cast; procedure Cast (Value : Unsigned_32; Result : out Unsigned_32) is begin Result := Value; end Cast; procedure Convert is new Index_Conversions.Convert_Array (UShort, UShort_Array, Cast); procedure Convert is new Index_Conversions.Convert_Array (Unsigned_32, Unsigned_32_Array, Cast); procedure Get_UShorts is new Index_Conversions.Get_Array (UShort, UShort_Array, Convert); procedure Get_UInts is new Index_Conversions.Get_Array (Unsigned_32, Unsigned_32_Array, Convert); begin for Mesh of Meshes loop declare First_Primitive : Orka.glTF.Meshes.Primitive renames Mesh.Primitives; Attribute_Position : constant Natural := First_Primitive.Attributes (Position); Attribute_Normal : constant Natural := First_Primitive.Attributes (Normal); Attribute_UV : constant Natural := First_Primitive.Attributes (Texcoord_0); Attribute_Index : constant Natural := First_Primitive.Indices; Accessor_Position : Accessor renames Accessors (Attribute_Position); Accessor_Normal : Accessor renames Accessors (Attribute_Normal); Accessor_UV : Accessor renames Accessors (Attribute_UV); Accessor_Index : Accessor renames Accessors (Attribute_Index); View_Position : Buffer_View renames Views (Accessor_Position.View); View_Normal : Buffer_View renames Views (Accessor_Normal.View); View_UV : Buffer_View renames Views (Accessor_UV.View); View_Index : Buffer_View renames Views (Accessor_Index.View); Positions : Indirect.Half_Array_Access := new Float_16_Array (1 .. Int (Accessor_Position.Count * Attribute_Length (Accessor_Position.Kind))); Normals : Indirect.Half_Array_Access := new Float_16_Array (1 .. Int (Accessor_Normal.Count * Attribute_Length (Accessor_Normal.Kind))); UVs : Indirect.Half_Array_Access := new Float_16_Array (1 .. Int (Accessor_UV.Count * Attribute_Length (Accessor_UV.Kind))); Indices : Indirect.UInt_Array_Access := new Unsigned_32_Array (1 .. Int (Accessor_Index.Count)); -- TODO Use Conversions.Target_Array? begin -- Convert attributes Get_Singles (Accessor_Position, Buffers, View_Position, Positions); Get_Singles (Accessor_Normal, Buffers, View_Normal, Normals); Get_Singles (Accessor_UV, Buffers, View_UV, UVs); -- Convert indices case Unsigned_Type (Accessor_Index.Component) is when GL.Types.UShort_Type => Get_UShorts (Accessor_Index, Buffers, View_Index, Indices); when GL.Types.UInt_Type => Get_UInts (Accessor_Index, Buffers, View_Index, Indices); end case; Batch.Append (Positions, Normals, UVs, Indices); -- Deallocate buffers after use Indirect.Free_Array (Positions); Indirect.Free_Array (Normals); Indirect.Free_Array (UVs); Indirect.Free_Array (Indices); end; end loop; end Add_Parts; ----------------------------------------------------------------------------- -- Loader -- ----------------------------------------------------------------------------- type GLTF_Loader is limited new Loaders.Loader with record Manager : Managers.Manager_Ptr; end record; overriding function Extension (Object : GLTF_Loader) return Loaders.Extension_String is ("gltf"); overriding procedure Load (Object : GLTF_Loader; Data : Loaders.Resource_Data; Enqueue : not null access procedure (Element : Jobs.Job_Ptr); Location : Locations.Location_Ptr) is Job : constant Jobs.Job_Ptr := new GLTF_Parse_Job' (Jobs.Abstract_Job with Data => Data, Manager => Object.Manager, Location => Location); begin Enqueue (Job); end Load; function Create_Loader (Manager : Managers.Manager_Ptr) return Loaders.Loader_Ptr is (new GLTF_Loader'(Manager => Manager)); ----------------------------------------------------------------------------- package Parsers is new JSON.Parsers (Orka.glTF.Types); overriding procedure Execute (Object : GLTF_Parse_Job; Context : Jobs.Execution_Context'Class) is use Orka.glTF.Types; use Orka.Strings; Path : constant String := +Object.Data.Path; Parser : Parsers.Parser := Parsers.Create (Object.Data.Bytes.Get.Value); begin declare T1 : constant Duration := Orka.OS.Monotonic_Clock; JSON : constant Orka.glTF.Types.JSON_Value := Parser.Parse; T2 : constant Duration := Orka.OS.Monotonic_Clock; Buffers : constant JSON_Value := JSON ("buffers"); Views : constant JSON_Value := JSON ("bufferViews"); Accessors : constant JSON_Value := JSON ("accessors"); Meshes : constant JSON_Value := JSON ("meshes"); Nodes : constant JSON_Value := JSON ("nodes"); Scenes : constant JSON_Value := JSON ("scenes"); Maximum_Nodes : constant Natural := Nodes.Length; -- Tokenize and parse JSON data Data : constant GLTF_Data_Access := new GLTF_Data' (Maximum_Nodes => Maximum_Nodes, Maximum_Accessors => Maximum_Nodes * 4, Directory => +Ada.Directories.Containing_Directory (Path), Location => Object.Location, Manager => Object.Manager, Start_Time => Object.Data.Start_Time, others => <>); Asset : constant JSON_Value := JSON ("asset"); Scene : constant JSON_Value := JSON ("scene"); function Load_Data (Path : String) return Byte_Array_Pointers.Pointer is begin return Data.Location.Read_Data (+Data.Directory & Locations.Path_Separator & Path); end Load_Data; Pointer : GLTF_Data_Pointers.Mutable_Pointer; T3, T4, T5, T6, T7, T8, T9 : Duration; begin -- Require glTF 2.x if Asset.Get ("version").Value /= "2.0" then raise Model_Load_Error with "glTF file '" & Path & "' does not use glTF 2.0"; end if; -- TODO Check minVersion -- Process buffers, nodes, meshes, and scenes T3 := Orka.OS.Monotonic_Clock; Data.Buffers.Append (Orka.glTF.Buffers.Get_Buffers (Buffers, Load_Data'Access)); T4 := Orka.OS.Monotonic_Clock; Data.Views.Append (Orka.glTF.Buffers.Get_Buffer_Views (Data.Buffers, Views)); T5 := Orka.OS.Monotonic_Clock; Data.Accessors.Append (Orka.glTF.Accessors.Get_Accessors (Accessors)); T6 := Orka.OS.Monotonic_Clock; Data.Meshes.Append (Orka.glTF.Meshes.Get_Meshes (Meshes)); T7 := Orka.OS.Monotonic_Clock; Data.Nodes.Append (Orka.glTF.Scenes.Get_Nodes (Nodes)); T8 := Orka.OS.Monotonic_Clock; Data.Scenes.Append (Orka.glTF.Scenes.Get_Scenes (Scenes)); T9 := Orka.OS.Monotonic_Clock; Data.Times (Time_Buffers) := T4 - T3; Data.Times (Time_Views) := T5 - T4; Data.Times (Time_Accessors) := T6 - T5; Data.Times (Time_Meshes) := T7 - T6; Data.Times (Time_Nodes) := T8 - T7; Data.Times (Time_Scenes) := T9 - T8; Data.Default_Scene := Scene.Value; Data.Times (Time_Reading) := Object.Data.Reading_Time; Data.Times (Time_Parsing) := T2 - T1; Data.Times (Time_Processing) := Orka.OS.Monotonic_Clock - T2; Pointer.Set (Data); declare Finish_Job : constant Jobs.Job_Ptr := new GLTF_Finish_Processing_Job' (Jobs.Abstract_Job with Data => Pointer, Path => Object.Data.Path); begin Context.Enqueue (Finish_Job); end; end; end Execute; overriding procedure Execute (Object : GLTF_Finish_Processing_Job; Context : Jobs.Execution_Context'Class) is Data : GLTF_Data renames Object.Data.Get; -- TODO Textures, Images, Samplers, Materials, Cameras Default_Scene_Index : constant Long_Integer := Data.Default_Scene; Default_Scene : constant Orka.glTF.Scenes.Scene := Data.Scenes (Natural (Default_Scene_Index)); -- Cannot be "renames" because freeing Object.Data results in cursor tampering Path : String renames SU.To_String (Object.Path); begin if Default_Scene.Nodes.Is_Empty then raise Model_Load_Error with "glTF file '" & Path & "' has an empty scene"; end if; declare Scene_Data : constant Model_Scene_Ptr := new Model_Scene' (Scene => Trees.Create_Tree (Default_Root_Name), others => <>); Scene : Trees.Tree renames Scene_Data.Scene; Parts : String_Maps.Map; Start_Time : constant Duration := Orka.OS.Monotonic_Clock; Vertices, Indices : Natural; begin -- Link the nodes in the default scene to the root node and -- then add all the other nodes that are reachable for Node_Index of Default_Scene.Nodes loop Scene.Add_Node (Orka.glTF.To_String (Data.Nodes (Node_Index).Name), Scene.Root_Name); end loop; Add_Nodes (Scene, Parts, Data.Nodes, Default_Scene.Nodes); -- Collect an array of cursors to nodes in the scene for nodes -- that have a corresponding mesh part. This is needed so that, -- after updating the whole scene tree, the world transforms of -- these nodes can be copied to a GPU buffer before rendering. Scene_Data.Shapes := Mesh_Node_Cursors (Parts, Scene); if Scene_Data.Shapes.Element'Length = 0 then -- TODO Free Scene_Data raise Model_Load_Error with "glTF file '" & Path & "' has no mesh parts"; end if; Data.Times (Time_Scene_Tree) := Orka.OS.Monotonic_Clock - Start_Time; -- Count total number of vertices and indices Count_Parts (GL.Types.UInt_Type, Data.Accessors, Data.Meshes, Vertices, Indices); declare Create_Job : constant Jobs.Job_Ptr := new GLTF_Create_Model_Job' (Jobs.Abstract_Job with Data => Object.Data, Path => Object.Path, Scene => Scene_Data, Vertices => Vertices, Indices => Indices); begin Context.Enqueue (Create_Job); end; end; end Execute; overriding procedure Execute (Object : GLTF_Create_Model_Job; Context : Jobs.Execution_Context'Class) is Data : GLTF_Data renames Object.Data.Get; Parts : constant Positive := Object.Scene.Shapes.Element'Length; Start_Time : constant Time := Orka.OS.Monotonic_Clock; Model_Data : constant Model_Ptr := new Model' (Scene => Object.Scene, Batch => Rendering.Buffers.MDI.Create_Batch (Parts, Object.Vertices, Object.Indices), -- Bounding boxes for culling Bounds => Rendering.Buffers.Create_Buffer (Flags => (others => False), Data => Bounds_List (Data.Accessors, Data.Meshes))); Buffers_Job : constant Jobs.Job_Ptr := new GLTF_Write_Buffers_Job' (Jobs.Abstract_Job with Data => Object.Data, Model => Model_Data); Finish_Job : constant Jobs.Job_Ptr := new GLTF_Finish_Loading_Job' (Jobs.Abstract_Job with Data => Object.Data, Path => Object.Path, Model => Model_Data, Start_Time => Start_Time, Parts => Parts, Vertices => Object.Vertices, Indices => Object.Indices); begin Orka.Jobs.Chain ((Buffers_Job, Finish_Job)); Context.Enqueue (Buffers_Job); end Execute; overriding procedure Execute (Object : GLTF_Write_Buffers_Job; Context : Jobs.Execution_Context'Class) is Data : GLTF_Data renames Object.Data.Get; begin Add_Parts (Object.Model.Batch, Data.Buffers, Data.Views, Data.Accessors, Data.Meshes); end Execute; overriding procedure Execute (Object : GLTF_Finish_Loading_Job; Context : Jobs.Execution_Context'Class) is Data : GLTF_Data renames Object.Data.Get; Path : String renames SU.To_String (Object.Path); begin Object.Model.Batch.Finish_Batch; Data.Times (Time_Write_Buffers) := Orka.OS.Monotonic_Clock - Object.Start_Time; -- Register the model at the resource manager Data.Manager.Add_Resource (Path, Resource_Ptr (Object.Model)); declare Times : Times_Data renames Data.Times; begin Log (Info, "Loaded model " & Path & " in " & Logging.Trim (Logging.Image (Orka.OS.Monotonic_Clock - Data.Start_Time))); Log (Info, " " & Object.Parts'Image & " parts," & Object.Vertices'Image & " vertices," & Object.Indices'Image & " indices"); Log (Debug, " timing:"); Log (Debug, " reading file: " & Logging.Image (Times (Time_Reading))); Log (Debug, " parsing JSON: " & Logging.Image (Times (Time_Parsing))); Log (Debug, " processing glTF: " & Logging.Image (Times (Time_Processing))); Log (Debug, " buffers: " & Logging.Image (Times (Time_Buffers))); Log (Debug, " views: " & Logging.Image (Times (Time_Views))); Log (Debug, " accessors: " & Logging.Image (Times (Time_Accessors))); Log (Debug, " meshes: " & Logging.Image (Times (Time_Meshes))); Log (Debug, " nodes: " & Logging.Image (Times (Time_Nodes))); Log (Debug, " scenes: " & Logging.Image (Times (Time_Scenes))); Log (Debug, " scene tree: " & Logging.Image (Times (Time_Scene_Tree))); Log (Debug, " buffers: " & Logging.Image (Times (Time_Write_Buffers))); end; end Execute; end Orka.Resources.Models.glTF;
sparre/ALSA-binding
Ada
8,595
adb
-- The Beer-Ware License (revision 42) -- -- Jacob Sparre Andersen <[email protected]> wrote this. As long as you -- retain this notice you can do whatever you want with this stuff. If we meet -- some day, and you think this stuff is worth it, you can buy me a beer in -- return. -- -- Jacob Sparre Andersen with Interfaces.C.Strings; package body Sound.Mono is procedure Close (Line : in out Line_Type) is use type Interfaces.C.int; Error : Interfaces.C.int; begin Error := snd_pcm_close (Line); if Error /= 0 then raise Program_Error with "snd_pcm_close failed: " & Error'Img; end if; end Close; function Is_Open (Line : in Line_Type) return Boolean is use Sound.ALSA; begin case snd_pcm_state (Line) is when Prepared | Running => return True; when Open | Setup | XRun | Draining | Paused | Suspended | Disconnected => return False; end case; end Is_Open; procedure Open (Line : in out Line_Type; Mode : in Line_Mode; Resolution : in out Sample_Frequency; Buffer_Size : in out Duration; Period : in out Duration) is use Interfaces.C, Interfaces.C.Strings, Sound.ALSA; Name : aliased char_array := To_C ("plughw:0,0"); Error : Interfaces.C.int; Local_Line : aliased Line_Type := Line; Settings : aliased Sound.ALSA.snd_pcm_hw_params_t; begin Error := snd_pcm_open (pcmp => Local_Line'Access, name => To_Chars_Ptr (Name'Unchecked_Access), stream => Sound.ALSA.Value (Mode), mode => 0); if Error /= 0 then raise Program_Error with "Error code (snd_pcm_open): " & Error'Img; end if; Clear_Settings : begin Error := snd_pcm_hw_params_any (pcm => Local_Line, params => Settings'Access); if Error /= 0 then raise Program_Error with "Error code (snd_pcm_hw_params_any): " & Error'Img; end if; end Clear_Settings; Set_Resampling_Rate : begin Error := snd_pcm_hw_params_set_rate_resample (pcm => Local_Line, params => Settings'Access, val => False); if Error /= 0 then raise Program_Error with "Error code (snd_pcm_hw_params_set_rate_resample): " & Error'Img; end if; end Set_Resampling_Rate; Set_Sampling_Layout : begin Error := snd_pcm_hw_params_set_access (pcm => Local_Line, params => Settings'Access, val => Read_Write_Interleaved); if Error /= 0 then raise Program_Error with "Error code (snd_pcm_hw_params_set_access): " & Error'Img; end if; end Set_Sampling_Layout; Set_Recording_Format : begin Error := snd_pcm_hw_params_set_format (pcm => Local_Line, params => Settings'Access, format => Sound.ALSA.Signed_16_Bit); if Error /= 0 then raise Program_Error with "Error code (snd_pcm_hw_params_set_format): " & Error'Img; end if; end Set_Recording_Format; Set_Channel_Count : begin Error := snd_pcm_hw_params_set_channels (pcm => Local_Line, params => Settings'Access, val => 1); if Error /= 0 then raise Program_Error with "Error code (snd_pcm_hw_params_set_channels): " & Error'Img; end if; end Set_Channel_Count; Set_Sample_Frequency : declare Sample_Rate : aliased Interfaces.C.unsigned := Interfaces.C.unsigned (Resolution); Approximation : aliased Sound.ALSA.Approximation_Direction := 0; begin Error := snd_pcm_hw_params_set_rate_near (pcm => Local_Line, params => Settings'Access, val => Sample_Rate'Access, dir => Approximation'Access); if Error /= 0 then raise Program_Error with "Error code (snd_pcm_hw_params_set_rate_near): " & Error'Img; end if; Resolution := Sample_Frequency (Sample_Rate); end Set_Sample_Frequency; Set_Buffer_Time : declare Buffer_Time : aliased Interfaces.C.unsigned := Interfaces.C.unsigned (1_000_000 * Buffer_Size); Approximation : aliased Sound.ALSA.Approximation_Direction := 0; begin Error := snd_pcm_hw_params_set_buffer_time_near (pcm => Local_Line, params => Settings'Access, val => Buffer_Time'Access, dir => Approximation'Access); if Error /= 0 then raise Program_Error with "Error code (snd_pcm_hw_params_set_buffer_time_near): " & Error'Img; end if; Buffer_Size := Duration (Buffer_Time) / 1_000_000.0; end Set_Buffer_Time; Set_Period : declare Period_Time : aliased Interfaces.C.unsigned := Interfaces.C.unsigned (1_000_000 * Period); Approximation : aliased Sound.ALSA.Approximation_Direction := 0; begin Error := snd_pcm_hw_params_set_period_time_near (pcm => Local_Line, params => Settings'Access, val => Period_Time'Access, dir => Approximation'Access); if Error /= 0 then raise Program_Error with "Error code (snd_pcm_hw_params_set_period_time_near): " & Error'Img; end if; Period := Duration (Period_Time) / 1_000_000.0; end Set_Period; Register_Settings : begin Error := snd_pcm_hw_params (pcm => Local_Line, params => Settings'Access); if Error /= 0 then raise Program_Error with "Error code (snd_pcm_hw_params): " & Error'Img; end if; end Register_Settings; Line := Local_Line; end Open; procedure Read (Line : in Line_Type; Item : out Frame_Array; Last : out Natural) is pragma Unmodified (Item); -- As we cheat with "function snd_pcm_readi". function snd_pcm_readi (pcm : in Line_Type; buffer : in Frame_Array; -- actually "out" size : in ALSA.snd_pcm_uframes_t) return ALSA.snd_pcm_sframes_t; pragma Import (C, snd_pcm_readi); use type Sound.ALSA.snd_pcm_sframes_t; Received_Frame_Count : Sound.ALSA.snd_pcm_sframes_t; begin Received_Frame_Count := snd_pcm_readi (pcm => Line, buffer => Item, size => Item'Length); if Received_Frame_Count < 0 then raise Program_Error with "snd_pcm_readi failed: " & Received_Frame_Count'Img; else Last := Item'First - 1 + Natural (Received_Frame_Count); end if; end Read; procedure Write (Line : in Line_Type; Item : in Frame_Array; Last : out Natural) is function snd_pcm_writei (pcm : in Line_Type; buffer : in Frame_Array; size : in ALSA.snd_pcm_uframes_t) return ALSA.snd_pcm_sframes_t; pragma Import (C, snd_pcm_writei); use type Sound.ALSA.snd_pcm_sframes_t; Written_Frame_Count : Sound.ALSA.snd_pcm_sframes_t; begin Written_Frame_Count := snd_pcm_writei (pcm => Line, buffer => Item, size => Item'Length); if Written_Frame_Count < 0 then raise Program_Error with "snd_pcm_writei failed: " & Written_Frame_Count'Img; else Last := Item'First - 1 + Natural (Written_Frame_Count); end if; end Write; end Sound.Mono;
reznikmm/matreshka
Ada
4,009
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- 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$ ------------------------------------------------------------------------------ with ODF.DOM.Text_Time_Adjust_Attributes; package Matreshka.ODF_Text.Time_Adjust_Attributes is type Text_Time_Adjust_Attribute_Node is new Matreshka.ODF_Text.Abstract_Text_Attribute_Node and ODF.DOM.Text_Time_Adjust_Attributes.ODF_Text_Time_Adjust_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Text_Time_Adjust_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Text_Time_Adjust_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Text.Time_Adjust_Attributes;