repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
peterfrankjohnson/kernel
Ada
50
ads
package Device.Timer.PIT is end Device.Timer.PIT;
zhmu/ananas
Ada
3,890
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . D O U B L E _ R E A L . P R O D U C T -- -- -- -- B o d y -- -- -- -- Copyright (C) 2021-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. -- -- -- ------------------------------------------------------------------------------ -- This is the version of the separate package body for targets with an FMA separate (System.Double_Real) package body Product is function Fused_Multiply_Add (A, B, C : Num) return Num; -- Return the result of A * B + C without intermediate rounding ------------------------ -- Fused_Multiply_Add -- ------------------------ function Fused_Multiply_Add (A, B, C : Num) return Num is begin case Num'Size is when 32 => declare function Do_FMA (A, B, C : Num) return Num; pragma Import (Intrinsic, Do_FMA, "__builtin_fmaf"); begin return Do_FMA (A, B, C); end; when 64 => declare function Do_FMA (A, B, C : Num) return Num; pragma Import (Intrinsic, Do_FMA, "__builtin_fma"); begin return Do_FMA (A, B, C); end; when others => raise Program_Error; end case; end Fused_Multiply_Add; -------------- -- Two_Prod -- -------------- function Two_Prod (A, B : Num) return Double_T is P : constant Num := A * B; E : Num; begin if Is_Infinity (P) or else Is_Zero (P) then return (P, 0.0); else E := Fused_Multiply_Add (A, B, -P); return (P, E); end if; end Two_Prod; ------------- -- Two_Sqr -- ------------- function Two_Sqr (A : Num) return Double_T is (Two_Prod (A, A)); end Product;
AdaCore/Ada_Drivers_Library
Ada
2,494
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2020, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with STM32_H405.LED; procedure Main is begin loop STM32_H405.LED.Toggle; delay 0.5; end loop; end Main;
reznikmm/matreshka
Ada
4,566
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_Svg.Origin_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Svg_Origin_Attribute_Node is begin return Self : Svg_Origin_Attribute_Node do Matreshka.ODF_Svg.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Svg_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Svg_Origin_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Origin_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Svg_URI, Matreshka.ODF_String_Constants.Origin_Attribute, Svg_Origin_Attribute_Node'Tag); end Matreshka.ODF_Svg.Origin_Attributes;
mmarx/lovelace
Ada
381
ads
generic type Parameter_Type (<>) is limited private; package Timings.Benchmarks is type Benchmarkable is access procedure (Parameters : in Parameter_Type); procedure Benchmark (What : in Benchmarkable; Name : in String; Parameters : in Parameter_Type; Who : in Usage_Who := Self); end Timings.Benchmarks;
zhmu/ananas
Ada
203
ads
with Ada.Finalization; use Ada.Finalization; package BIP_Case_Expr_Pkg is type Lim_Ctrl is new Limited_Controlled with null record; function Make_Lim_Ctrl return Lim_Ctrl; end BIP_Case_Expr_Pkg;
AdaCore/langkit
Ada
9,049
adb
with Ada.Command_Line; use Ada.Command_Line; with Ada.Containers.Hashed_Maps; with Ada.Directories; use Ada.Directories; with Ada.Exceptions; with Ada.Strings.Fixed; use Ada.Strings.Fixed; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Text_IO; use Ada.Text_IO; with GNAT.Traceback.Symbolic; with GNATCOLL.Opt_Parse; use GNATCOLL.Opt_Parse; with GNATCOLL.Traces; with Liblktlang_Support.Diagnostics; use Liblktlang_Support.Diagnostics; with Liblktlang_Support.Diagnostics.Output; use Liblktlang_Support.Diagnostics.Output; with Liblktlang_Support.Slocs; use Liblktlang_Support.Slocs; with Liblktlang_Support.Text; use Liblktlang_Support.Text; with Liblktlang.Analysis; use Liblktlang.Analysis; with Liblktlang.Common; procedure Lkt_Toolbox is package Arg is Parser : Argument_Parser := Create_Argument_Parser (Help => "Lkt toolbox. Toolbox like command line frontend for the " & "LKT langkit library."); package Files is new Parse_Positional_Arg_List (Parser => Parser, Name => "files", Arg_Type => Unbounded_String, Help => "The files to parse"); package Check_Only is new Parse_Flag (Parser => Parser, Short => "-C", Long => "--check-only", Help => "Only output the errors"); package Flag_Invalid is new Parse_Flag (Parser => Parser, Short => "-I", Long => "--check-invalid-decls", Help => "Flag decls that generate errors that are not annotated" & " with the @invalid annotation. Also flag decls" & " annotated with @invalid that don't trigger any errors"); end Arg; use Liblktlang; package Invalid_Decl_Maps is new Ada.Containers.Hashed_Maps (Key_Type => Analysis.Lkt_Node, Element_Type => Boolean, Hash => Analysis.Hash, Equivalent_Keys => "="); procedure Print_Semantic_Result (S : Analysis.Semantic_Result; Unit : Analysis.Analysis_Unit); -- Print a semantic result function Format_Node (Decl_Node : Decl'Class) return String; -- Format node for semantic result printing procedure Print_Lkt_Toolbox_Diagnostic (Node : Lkt_Node'Class; Message : Wide_Wide_String); -- Internal wrapper to ``Print_Diagnostic`` used by lkt_toolbox to print -- additional diagnostics. function Populate_Invalid_Decl_Map (Node : Analysis.Lkt_Node'Class) return Common.Visit_Status; -- Populate ``Invalid_Decl_Map`` and reject declarations with ``@invalid`` -- annotations that are nested in another declaration annotated with -- ``@invalid``. Invalid_Decl_Map : Invalid_Decl_Maps.Map; -- Map of declarations annotated with ``@invalid``. The boolean elements of -- the map are initialized to ``False`` and set to ``True`` whenever a -- diagnostic is emitted for the related declaration. Therefore, this map -- is used to check that at least one diagnostic has been emitted for each -- declaration annotated with ``@invalid``. ----------------- -- Format_Node -- ----------------- function Format_Node (Decl_Node : Decl'Class) return String is begin -- Remove rebindings information as there is no easy way to filter -- out/format rebindings information involving prelude declarations. return Decl_Node.P_As_Bare_Decl.Image; end Format_Node; ---------------------------------- -- Print_Lkt_Toolbox_Diagnostic -- ---------------------------------- procedure Print_Lkt_Toolbox_Diagnostic (Node : Lkt_Node'Class; Message : Wide_Wide_String) is Sloc_Range : constant Source_Location_Range := Node.Sloc_Range; Unit : constant Analysis.Analysis_Unit := Node.Unit; Path : constant String := Simple_Name (Unit.Get_Filename); begin Print_Diagnostic ((Sloc_Range, To_Unbounded_Text (Message)), Unit, Path); end Print_Lkt_Toolbox_Diagnostic; --------------------------- -- Print_Semantic_Result -- --------------------------- procedure Print_Semantic_Result (S : Analysis.Semantic_Result; Unit : Analysis.Analysis_Unit) is Node : constant Lkt_Node'Class := Analysis.Node (S); begin if Analysis.Error_Message (S) /= "" then declare Diag : constant Diagnostic := (Node.Sloc_Range, To_Unbounded_Text (Analysis.Error_Message (S))); begin if Arg.Flag_Invalid.Get then -- Emit an error if the declaration including ``Node`` has no -- ``@invalid`` annotation. Update ``Invalid_Decl_Map`` -- otherwise. if Node.P_Topmost_Invalid_Decl.Is_Null then Set_Exit_Status (1); Print_Lkt_Toolbox_Diagnostic (Node, "unexpected diagnostic, is @invalid annotation missing?"); else Invalid_Decl_Map (Node.P_Topmost_Invalid_Decl) := True; end if; end if; Print_Diagnostic (Diag, Unit, Simple_Name (Node.Unit.Get_Filename)); end; elsif not Arg.Check_Only.Get and then not Analysis.Result_Type (S).Is_Null then Put_Line ("Expr " & Node.Image); Put_Line (" has type " & Analysis.Result_Type (S).Image); New_Line; elsif not Arg.Check_Only.Get and then not Analysis.Result_Decl (S).Is_Null then Put_Line ("Id " & Node.Image); Put_Line (" references " & Format_Node (Analysis.Result_Decl (S))); New_Line; end if; end Print_Semantic_Result; ------------------------------- -- Populate_Invalid_Decl_Map -- ------------------------------- function Populate_Invalid_Decl_Map (Node : Analysis.Lkt_Node'Class) return Common.Visit_Status is use type Common.Lkt_Node_Kind_Type; begin -- Populate ``Invalid_Decl_Map`` with declarations annotated with -- ``@invalid``. if Node.Kind = Common.Lkt_Full_Decl and then Node.As_Full_Decl.P_Has_Annotation (To_Unbounded_Text ("invalid")) then -- ``P_Topmost_Invalid_Decl`` should return the same node. In that -- case, include this node in the map, otherwise nested ``@invalid`` -- declarations have been detected: emit a diagnostic. if Invalid_Decl_Map.Contains (Node.P_Topmost_Invalid_Decl) then Set_Exit_Status (1); Print_Lkt_Toolbox_Diagnostic (Node, "nested @invalid declaration"); else Invalid_Decl_Map.Include (Node.As_Lkt_Node, False); end if; end if; return Common.Into; end Populate_Invalid_Decl_Map; Ctx : constant Analysis.Analysis_Context := Analysis.Create_Context; begin GNATCOLL.Traces.Parse_Config_File; if Arg.Parser.Parse then for File_Name of Arg.Files.Get loop declare File_Name_Str : constant String := To_String (File_Name); Unit : constant Analysis.Analysis_Unit := Ctx.Get_From_File (File_Name_Str); begin if not Arg.Check_Only.Get then Put_Line ("Resolving " & File_Name_Str); Put_Line ((File_Name_Str'Length + 10) * "="); end if; if Unit.Diagnostics'Length > 0 then for Diagnostic of Unit.Diagnostics loop Print_Diagnostic (Diagnostic, Unit, Simple_Name (Unit.Get_Filename)); end loop; return; end if; if Arg.Flag_Invalid.Get then Unit.Root.Traverse (Populate_Invalid_Decl_Map'Access); end if; declare Diags : constant Analysis.Tree_Semantic_Result := Unit.Root.As_Langkit_Root.P_Check_Semantic; begin for D of Analysis.Results (Diags) loop Print_Semantic_Result (D, Unit); end loop; end; if Arg.Flag_Invalid.Get then -- Ensure that all ``@invalid`` declarations in the map have -- corresponding diagnostics. Otherwise, emit an error. for E in Invalid_Decl_Map.Iterate loop if not Invalid_Decl_Maps.Element (E) then Set_Exit_Status (1); Print_Lkt_Toolbox_Diagnostic (Invalid_Decl_Maps.Key (E), "@invalid declaration without diagnostic"); end if; end loop; end if; end; end loop; end if; exception when E : Common.Property_Error => Put_Line (Ada.Exceptions.Exception_Message (E)); Put_Line (GNAT.Traceback.Symbolic.Symbolic_Traceback (E)); end Lkt_Toolbox;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
20,506
ads
pragma Style_Checks (Off); -- This spec has been automatically generated from STM32L0x1.svd pragma Restrictions (No_Elaboration_Code); with System; package STM32_SVD.DMA is pragma Preelaborate; --------------- -- Registers -- --------------- subtype ISR_GIF1_Field is STM32_SVD.Bit; subtype ISR_TCIF1_Field is STM32_SVD.Bit; subtype ISR_HTIF1_Field is STM32_SVD.Bit; subtype ISR_TEIF1_Field is STM32_SVD.Bit; subtype ISR_GIF2_Field is STM32_SVD.Bit; subtype ISR_TCIF2_Field is STM32_SVD.Bit; subtype ISR_HTIF2_Field is STM32_SVD.Bit; subtype ISR_TEIF2_Field is STM32_SVD.Bit; subtype ISR_GIF3_Field is STM32_SVD.Bit; subtype ISR_TCIF3_Field is STM32_SVD.Bit; subtype ISR_HTIF3_Field is STM32_SVD.Bit; subtype ISR_TEIF3_Field is STM32_SVD.Bit; subtype ISR_GIF4_Field is STM32_SVD.Bit; subtype ISR_TCIF4_Field is STM32_SVD.Bit; subtype ISR_HTIF4_Field is STM32_SVD.Bit; subtype ISR_TEIF4_Field is STM32_SVD.Bit; subtype ISR_GIF5_Field is STM32_SVD.Bit; subtype ISR_TCIF5_Field is STM32_SVD.Bit; subtype ISR_HTIF5_Field is STM32_SVD.Bit; subtype ISR_TEIF5_Field is STM32_SVD.Bit; subtype ISR_GIF6_Field is STM32_SVD.Bit; subtype ISR_TCIF6_Field is STM32_SVD.Bit; subtype ISR_HTIF6_Field is STM32_SVD.Bit; subtype ISR_TEIF6_Field is STM32_SVD.Bit; subtype ISR_GIF7_Field is STM32_SVD.Bit; subtype ISR_TCIF7_Field is STM32_SVD.Bit; subtype ISR_HTIF7_Field is STM32_SVD.Bit; subtype ISR_TEIF7_Field is STM32_SVD.Bit; -- interrupt status register type ISR_Register is record -- Read-only. Channel x global interrupt flag (x = 1 ..7) GIF1 : ISR_GIF1_Field; -- Read-only. Channel x transfer complete flag (x = 1 ..7) TCIF1 : ISR_TCIF1_Field; -- Read-only. Channel x half transfer flag (x = 1 ..7) HTIF1 : ISR_HTIF1_Field; -- Read-only. Channel x transfer error flag (x = 1 ..7) TEIF1 : ISR_TEIF1_Field; -- Read-only. Channel x global interrupt flag (x = 1 ..7) GIF2 : ISR_GIF2_Field; -- Read-only. Channel x transfer complete flag (x = 1 ..7) TCIF2 : ISR_TCIF2_Field; -- Read-only. Channel x half transfer flag (x = 1 ..7) HTIF2 : ISR_HTIF2_Field; -- Read-only. Channel x transfer error flag (x = 1 ..7) TEIF2 : ISR_TEIF2_Field; -- Read-only. Channel x global interrupt flag (x = 1 ..7) GIF3 : ISR_GIF3_Field; -- Read-only. Channel x transfer complete flag (x = 1 ..7) TCIF3 : ISR_TCIF3_Field; -- Read-only. Channel x half transfer flag (x = 1 ..7) HTIF3 : ISR_HTIF3_Field; -- Read-only. Channel x transfer error flag (x = 1 ..7) TEIF3 : ISR_TEIF3_Field; -- Read-only. Channel x global interrupt flag (x = 1 ..7) GIF4 : ISR_GIF4_Field; -- Read-only. Channel x transfer complete flag (x = 1 ..7) TCIF4 : ISR_TCIF4_Field; -- Read-only. Channel x half transfer flag (x = 1 ..7) HTIF4 : ISR_HTIF4_Field; -- Read-only. Channel x transfer error flag (x = 1 ..7) TEIF4 : ISR_TEIF4_Field; -- Read-only. Channel x global interrupt flag (x = 1 ..7) GIF5 : ISR_GIF5_Field; -- Read-only. Channel x transfer complete flag (x = 1 ..7) TCIF5 : ISR_TCIF5_Field; -- Read-only. Channel x half transfer flag (x = 1 ..7) HTIF5 : ISR_HTIF5_Field; -- Read-only. Channel x transfer error flag (x = 1 ..7) TEIF5 : ISR_TEIF5_Field; -- Read-only. Channel x global interrupt flag (x = 1 ..7) GIF6 : ISR_GIF6_Field; -- Read-only. Channel x transfer complete flag (x = 1 ..7) TCIF6 : ISR_TCIF6_Field; -- Read-only. Channel x half transfer flag (x = 1 ..7) HTIF6 : ISR_HTIF6_Field; -- Read-only. Channel x transfer error flag (x = 1 ..7) TEIF6 : ISR_TEIF6_Field; -- Read-only. Channel x global interrupt flag (x = 1 ..7) GIF7 : ISR_GIF7_Field; -- Read-only. Channel x transfer complete flag (x = 1 ..7) TCIF7 : ISR_TCIF7_Field; -- Read-only. Channel x half transfer flag (x = 1 ..7) HTIF7 : ISR_HTIF7_Field; -- Read-only. Channel x transfer error flag (x = 1 ..7) TEIF7 : ISR_TEIF7_Field; -- unspecified Reserved_28_31 : STM32_SVD.UInt4; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ISR_Register use record GIF1 at 0 range 0 .. 0; TCIF1 at 0 range 1 .. 1; HTIF1 at 0 range 2 .. 2; TEIF1 at 0 range 3 .. 3; GIF2 at 0 range 4 .. 4; TCIF2 at 0 range 5 .. 5; HTIF2 at 0 range 6 .. 6; TEIF2 at 0 range 7 .. 7; GIF3 at 0 range 8 .. 8; TCIF3 at 0 range 9 .. 9; HTIF3 at 0 range 10 .. 10; TEIF3 at 0 range 11 .. 11; GIF4 at 0 range 12 .. 12; TCIF4 at 0 range 13 .. 13; HTIF4 at 0 range 14 .. 14; TEIF4 at 0 range 15 .. 15; GIF5 at 0 range 16 .. 16; TCIF5 at 0 range 17 .. 17; HTIF5 at 0 range 18 .. 18; TEIF5 at 0 range 19 .. 19; GIF6 at 0 range 20 .. 20; TCIF6 at 0 range 21 .. 21; HTIF6 at 0 range 22 .. 22; TEIF6 at 0 range 23 .. 23; GIF7 at 0 range 24 .. 24; TCIF7 at 0 range 25 .. 25; HTIF7 at 0 range 26 .. 26; TEIF7 at 0 range 27 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; subtype IFCR_CGIF1_Field is STM32_SVD.Bit; subtype IFCR_CTCIF1_Field is STM32_SVD.Bit; subtype IFCR_CHTIF1_Field is STM32_SVD.Bit; subtype IFCR_CTEIF1_Field is STM32_SVD.Bit; subtype IFCR_CGIF2_Field is STM32_SVD.Bit; subtype IFCR_CTCIF2_Field is STM32_SVD.Bit; subtype IFCR_CHTIF2_Field is STM32_SVD.Bit; subtype IFCR_CTEIF2_Field is STM32_SVD.Bit; subtype IFCR_CGIF3_Field is STM32_SVD.Bit; subtype IFCR_CTCIF3_Field is STM32_SVD.Bit; subtype IFCR_CHTIF3_Field is STM32_SVD.Bit; subtype IFCR_CTEIF3_Field is STM32_SVD.Bit; subtype IFCR_CGIF4_Field is STM32_SVD.Bit; subtype IFCR_CTCIF4_Field is STM32_SVD.Bit; subtype IFCR_CHTIF4_Field is STM32_SVD.Bit; subtype IFCR_CTEIF4_Field is STM32_SVD.Bit; subtype IFCR_CGIF5_Field is STM32_SVD.Bit; subtype IFCR_CTCIF5_Field is STM32_SVD.Bit; subtype IFCR_CHTIF5_Field is STM32_SVD.Bit; subtype IFCR_CTEIF5_Field is STM32_SVD.Bit; subtype IFCR_CGIF6_Field is STM32_SVD.Bit; subtype IFCR_CTCIF6_Field is STM32_SVD.Bit; subtype IFCR_CHTIF6_Field is STM32_SVD.Bit; subtype IFCR_CTEIF6_Field is STM32_SVD.Bit; subtype IFCR_CGIF7_Field is STM32_SVD.Bit; subtype IFCR_CTCIF7_Field is STM32_SVD.Bit; subtype IFCR_CHTIF7_Field is STM32_SVD.Bit; subtype IFCR_CTEIF7_Field is STM32_SVD.Bit; -- interrupt flag clear register type IFCR_Register is record -- Write-only. Channel x global interrupt clear (x = 1 ..7) CGIF1 : IFCR_CGIF1_Field := 16#0#; -- Write-only. Channel x transfer complete clear (x = 1 ..7) CTCIF1 : IFCR_CTCIF1_Field := 16#0#; -- Write-only. Channel x half transfer clear (x = 1 ..7) CHTIF1 : IFCR_CHTIF1_Field := 16#0#; -- Write-only. Channel x transfer error clear (x = 1 ..7) CTEIF1 : IFCR_CTEIF1_Field := 16#0#; -- Write-only. Channel x global interrupt clear (x = 1 ..7) CGIF2 : IFCR_CGIF2_Field := 16#0#; -- Write-only. Channel x transfer complete clear (x = 1 ..7) CTCIF2 : IFCR_CTCIF2_Field := 16#0#; -- Write-only. Channel x half transfer clear (x = 1 ..7) CHTIF2 : IFCR_CHTIF2_Field := 16#0#; -- Write-only. Channel x transfer error clear (x = 1 ..7) CTEIF2 : IFCR_CTEIF2_Field := 16#0#; -- Write-only. Channel x global interrupt clear (x = 1 ..7) CGIF3 : IFCR_CGIF3_Field := 16#0#; -- Write-only. Channel x transfer complete clear (x = 1 ..7) CTCIF3 : IFCR_CTCIF3_Field := 16#0#; -- Write-only. Channel x half transfer clear (x = 1 ..7) CHTIF3 : IFCR_CHTIF3_Field := 16#0#; -- Write-only. Channel x transfer error clear (x = 1 ..7) CTEIF3 : IFCR_CTEIF3_Field := 16#0#; -- Write-only. Channel x global interrupt clear (x = 1 ..7) CGIF4 : IFCR_CGIF4_Field := 16#0#; -- Write-only. Channel x transfer complete clear (x = 1 ..7) CTCIF4 : IFCR_CTCIF4_Field := 16#0#; -- Write-only. Channel x half transfer clear (x = 1 ..7) CHTIF4 : IFCR_CHTIF4_Field := 16#0#; -- Write-only. Channel x transfer error clear (x = 1 ..7) CTEIF4 : IFCR_CTEIF4_Field := 16#0#; -- Write-only. Channel x global interrupt clear (x = 1 ..7) CGIF5 : IFCR_CGIF5_Field := 16#0#; -- Write-only. Channel x transfer complete clear (x = 1 ..7) CTCIF5 : IFCR_CTCIF5_Field := 16#0#; -- Write-only. Channel x half transfer clear (x = 1 ..7) CHTIF5 : IFCR_CHTIF5_Field := 16#0#; -- Write-only. Channel x transfer error clear (x = 1 ..7) CTEIF5 : IFCR_CTEIF5_Field := 16#0#; -- Write-only. Channel x global interrupt clear (x = 1 ..7) CGIF6 : IFCR_CGIF6_Field := 16#0#; -- Write-only. Channel x transfer complete clear (x = 1 ..7) CTCIF6 : IFCR_CTCIF6_Field := 16#0#; -- Write-only. Channel x half transfer clear (x = 1 ..7) CHTIF6 : IFCR_CHTIF6_Field := 16#0#; -- Write-only. Channel x transfer error clear (x = 1 ..7) CTEIF6 : IFCR_CTEIF6_Field := 16#0#; -- Write-only. Channel x global interrupt clear (x = 1 ..7) CGIF7 : IFCR_CGIF7_Field := 16#0#; -- Write-only. Channel x transfer complete clear (x = 1 ..7) CTCIF7 : IFCR_CTCIF7_Field := 16#0#; -- Write-only. Channel x half transfer clear (x = 1 ..7) CHTIF7 : IFCR_CHTIF7_Field := 16#0#; -- Write-only. Channel x transfer error clear (x = 1 ..7) CTEIF7 : IFCR_CTEIF7_Field := 16#0#; -- unspecified Reserved_28_31 : STM32_SVD.UInt4 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for IFCR_Register use record CGIF1 at 0 range 0 .. 0; CTCIF1 at 0 range 1 .. 1; CHTIF1 at 0 range 2 .. 2; CTEIF1 at 0 range 3 .. 3; CGIF2 at 0 range 4 .. 4; CTCIF2 at 0 range 5 .. 5; CHTIF2 at 0 range 6 .. 6; CTEIF2 at 0 range 7 .. 7; CGIF3 at 0 range 8 .. 8; CTCIF3 at 0 range 9 .. 9; CHTIF3 at 0 range 10 .. 10; CTEIF3 at 0 range 11 .. 11; CGIF4 at 0 range 12 .. 12; CTCIF4 at 0 range 13 .. 13; CHTIF4 at 0 range 14 .. 14; CTEIF4 at 0 range 15 .. 15; CGIF5 at 0 range 16 .. 16; CTCIF5 at 0 range 17 .. 17; CHTIF5 at 0 range 18 .. 18; CTEIF5 at 0 range 19 .. 19; CGIF6 at 0 range 20 .. 20; CTCIF6 at 0 range 21 .. 21; CHTIF6 at 0 range 22 .. 22; CTEIF6 at 0 range 23 .. 23; CGIF7 at 0 range 24 .. 24; CTCIF7 at 0 range 25 .. 25; CHTIF7 at 0 range 26 .. 26; CTEIF7 at 0 range 27 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; subtype CCR_EN_Field is STM32_SVD.Bit; subtype CCR_TCIE_Field is STM32_SVD.Bit; subtype CCR_HTIE_Field is STM32_SVD.Bit; subtype CCR_TEIE_Field is STM32_SVD.Bit; subtype CCR_DIR_Field is STM32_SVD.Bit; subtype CCR_CIRC_Field is STM32_SVD.Bit; subtype CCR_PINC_Field is STM32_SVD.Bit; subtype CCR_MINC_Field is STM32_SVD.Bit; subtype CCR_PSIZE_Field is STM32_SVD.UInt2; subtype CCR_MSIZE_Field is STM32_SVD.UInt2; subtype CCR_PL_Field is STM32_SVD.UInt2; subtype CCR_MEM2MEM_Field is STM32_SVD.Bit; -- channel x configuration register type CCR_Register is record -- Channel enable EN : CCR_EN_Field := 16#0#; -- Transfer complete interrupt enable TCIE : CCR_TCIE_Field := 16#0#; -- Half transfer interrupt enable HTIE : CCR_HTIE_Field := 16#0#; -- Transfer error interrupt enable TEIE : CCR_TEIE_Field := 16#0#; -- Data transfer direction DIR : CCR_DIR_Field := 16#0#; -- Circular mode CIRC : CCR_CIRC_Field := 16#0#; -- Peripheral increment mode PINC : CCR_PINC_Field := 16#0#; -- Memory increment mode MINC : CCR_MINC_Field := 16#0#; -- Peripheral size PSIZE : CCR_PSIZE_Field := 16#0#; -- Memory size MSIZE : CCR_MSIZE_Field := 16#0#; -- Channel priority level PL : CCR_PL_Field := 16#0#; -- Memory to memory mode MEM2MEM : CCR_MEM2MEM_Field := 16#0#; -- unspecified Reserved_15_31 : STM32_SVD.UInt17 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CCR_Register use record EN at 0 range 0 .. 0; TCIE at 0 range 1 .. 1; HTIE at 0 range 2 .. 2; TEIE at 0 range 3 .. 3; DIR at 0 range 4 .. 4; CIRC at 0 range 5 .. 5; PINC at 0 range 6 .. 6; MINC at 0 range 7 .. 7; PSIZE at 0 range 8 .. 9; MSIZE at 0 range 10 .. 11; PL at 0 range 12 .. 13; MEM2MEM at 0 range 14 .. 14; Reserved_15_31 at 0 range 15 .. 31; end record; subtype CNDTR_NDT_Field is STM32_SVD.UInt16; -- channel x number of data register type CNDTR_Register is record -- Number of data to transfer NDT : CNDTR_NDT_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CNDTR_Register use record NDT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype CSELR_C1S_Field is STM32_SVD.UInt4; subtype CSELR_C2S_Field is STM32_SVD.UInt4; subtype CSELR_C3S_Field is STM32_SVD.UInt4; subtype CSELR_C4S_Field is STM32_SVD.UInt4; subtype CSELR_C5S_Field is STM32_SVD.UInt4; subtype CSELR_C6S_Field is STM32_SVD.UInt4; subtype CSELR_C7S_Field is STM32_SVD.UInt4; -- channel selection register type CSELR_Register is record -- DMA channel 1 selection C1S : CSELR_C1S_Field := 16#0#; -- DMA channel 2 selection C2S : CSELR_C2S_Field := 16#0#; -- DMA channel 3 selection C3S : CSELR_C3S_Field := 16#0#; -- DMA channel 4 selection C4S : CSELR_C4S_Field := 16#0#; -- DMA channel 5 selection C5S : CSELR_C5S_Field := 16#0#; -- DMA channel 6 selection C6S : CSELR_C6S_Field := 16#0#; -- DMA channel 7 selection C7S : CSELR_C7S_Field := 16#0#; -- unspecified Reserved_28_31 : STM32_SVD.UInt4 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CSELR_Register use record C1S at 0 range 0 .. 3; C2S at 0 range 4 .. 7; C3S at 0 range 8 .. 11; C4S at 0 range 12 .. 15; C5S at 0 range 16 .. 19; C6S at 0 range 20 .. 23; C7S at 0 range 24 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Direct memory access controller type DMA1_Peripheral is record -- interrupt status register ISR : aliased ISR_Register; -- interrupt flag clear register IFCR : aliased IFCR_Register; -- channel x configuration register CCR1 : aliased CCR_Register; -- channel x number of data register CNDTR1 : aliased CNDTR_Register; -- channel x peripheral address register CPAR1 : aliased STM32_SVD.UInt32; -- channel x memory address register CMAR1 : aliased STM32_SVD.UInt32; -- channel x configuration register CCR2 : aliased CCR_Register; -- channel x number of data register CNDTR2 : aliased CNDTR_Register; -- channel x peripheral address register CPAR2 : aliased STM32_SVD.UInt32; -- channel x memory address register CMAR2 : aliased STM32_SVD.UInt32; -- channel x configuration register CCR3 : aliased CCR_Register; -- channel x number of data register CNDTR3 : aliased CNDTR_Register; -- channel x peripheral address register CPAR3 : aliased STM32_SVD.UInt32; -- channel x memory address register CMAR3 : aliased STM32_SVD.UInt32; -- channel x configuration register CCR4 : aliased CCR_Register; -- channel x number of data register CNDTR4 : aliased CNDTR_Register; -- channel x peripheral address register CPAR4 : aliased STM32_SVD.UInt32; -- channel x memory address register CMAR4 : aliased STM32_SVD.UInt32; -- channel x configuration register CCR5 : aliased CCR_Register; -- channel x number of data register CNDTR5 : aliased CNDTR_Register; -- channel x peripheral address register CPAR5 : aliased STM32_SVD.UInt32; -- channel x memory address register CMAR5 : aliased STM32_SVD.UInt32; -- channel x configuration register CCR6 : aliased CCR_Register; -- channel x number of data register CNDTR6 : aliased CNDTR_Register; -- channel x peripheral address register CPAR6 : aliased STM32_SVD.UInt32; -- channel x memory address register CMAR6 : aliased STM32_SVD.UInt32; -- channel x configuration register CCR7 : aliased CCR_Register; -- channel x number of data register CNDTR7 : aliased CNDTR_Register; -- channel x peripheral address register CPAR7 : aliased STM32_SVD.UInt32; -- channel x memory address register CMAR7 : aliased STM32_SVD.UInt32; -- channel selection register CSELR : aliased CSELR_Register; end record with Volatile; for DMA1_Peripheral use record ISR at 16#0# range 0 .. 31; IFCR at 16#4# range 0 .. 31; CCR1 at 16#8# range 0 .. 31; CNDTR1 at 16#C# range 0 .. 31; CPAR1 at 16#10# range 0 .. 31; CMAR1 at 16#14# range 0 .. 31; CCR2 at 16#1C# range 0 .. 31; CNDTR2 at 16#20# range 0 .. 31; CPAR2 at 16#24# range 0 .. 31; CMAR2 at 16#28# range 0 .. 31; CCR3 at 16#30# range 0 .. 31; CNDTR3 at 16#34# range 0 .. 31; CPAR3 at 16#38# range 0 .. 31; CMAR3 at 16#3C# range 0 .. 31; CCR4 at 16#44# range 0 .. 31; CNDTR4 at 16#48# range 0 .. 31; CPAR4 at 16#4C# range 0 .. 31; CMAR4 at 16#50# range 0 .. 31; CCR5 at 16#58# range 0 .. 31; CNDTR5 at 16#5C# range 0 .. 31; CPAR5 at 16#60# range 0 .. 31; CMAR5 at 16#64# range 0 .. 31; CCR6 at 16#6C# range 0 .. 31; CNDTR6 at 16#70# range 0 .. 31; CPAR6 at 16#74# range 0 .. 31; CMAR6 at 16#78# range 0 .. 31; CCR7 at 16#80# range 0 .. 31; CNDTR7 at 16#84# range 0 .. 31; CPAR7 at 16#88# range 0 .. 31; CMAR7 at 16#8C# range 0 .. 31; CSELR at 16#A8# range 0 .. 31; end record; -- Direct memory access controller DMA1_Periph : aliased DMA1_Peripheral with Import, Address => DMA1_Base; end STM32_SVD.DMA;
jhumphry/parse_args
Ada
3,294
adb
-- simple_example -- A simple example of the use of parse_args -- Copyright (c) 2014, James Humphry -- -- Permission to use, copy, modify, and/or distribute this software for any -- purpose with or without fee is hereby granted, provided that the above -- copyright notice and this permission notice appear in all copies. -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -- PERFORMANCE OF THIS SOFTWARE. with Parse_Args; use Parse_Args; with Parse_Args.Integer_Array_Options; with Ada.Text_IO; use Ada.Text_IO; procedure Simple_Example is AP : Argument_Parser; begin AP.Add_Option(Make_Boolean_Option(False), "help", 'h', Usage => "Display this help text"); AP.Add_Option(Make_Boolean_Option(False), "foo", 'f', Usage => "The foo option"); AP.Add_Option(Make_Boolean_Option(True), "bar", 'b', Usage => "The bar option"); AP.Add_Option(Make_Repeated_Option(0), "baz", 'z', Usage => "The baz option (can be repeated for more baz)"); AP.Add_Option(Make_Boolean_Option(False), "long-only", Long_Option => "long-only", Usage => "The --long-only option has no short version"); AP.Add_Option(Make_Boolean_Option(False), "short-only", Short_Option => 'x', Long_Option => "-", Usage => "The -x option has no long version"); AP.Add_Option(Make_Natural_Option(0), "natural", 'n', Usage => "Specify a natural number argument"); AP.Add_Option(Make_Integer_Option(-1), "integer", 'i', Usage => "Specify an integer argument"); AP.Add_Option(Make_String_Option(""), "string", 's', Usage => "Specify a string argument"); AP.Add_Option(Integer_Array_Options.Make_Option, "array", 'a', Usage => "Specify a comma-separated integer array argument"); AP.Append_Positional(Make_String_Option("INFILE"), "INFILE"); AP.Allow_Tail_Arguments("TAIL-ARGUMENTS"); AP.Set_Prologue("A demonstration of the basic features of the Parse_Args library."); AP.Parse_Command_Line; if AP.Parse_Success and then AP.Boolean_Value("help") then AP.Usage; elsif AP.Parse_Success then Put_Line("Command name is: " & AP.Command_Name); New_Line; for I in AP.Iterate loop Put_Line("Option "& Option_Name(I) & " was " & (if AP(I).Set then "" else "not ") & "set on the command line. Value: " & AP(I).Image); end loop; New_Line; Put_Line("There were: " & Integer'Image(Integer(AP.Tail.Length)) & " tail arguments."); declare I : Integer := 1; begin for J of AP.Tail loop Put_Line("Argument" & Integer'Image(I) & " is: " & J); I := I + 1; end loop; end; else Put_Line("Error while parsing command-line arguments: " & AP.Parse_Message); end if; end Simple_Example;
reznikmm/matreshka
Ada
3,919
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.Svg_D_Attributes; package Matreshka.ODF_Svg.D_Attributes is type Svg_D_Attribute_Node is new Matreshka.ODF_Svg.Abstract_Svg_Attribute_Node and ODF.DOM.Svg_D_Attributes.ODF_Svg_D_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Svg_D_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Svg_D_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Svg.D_Attributes;
zhmu/ananas
Ada
780
adb
-- { dg-do run } -- { dg-options "-gnatws" } procedure Tfren is type R; type Ar is access all R; type R is record F1: Integer; F2: Ar; end record; for R use record F1 at 1 range 0..31; F2 at 5 range 0..63; end record; procedure Foo (RR1, RR2: Ar); procedure Foo (RR1, RR2 : Ar) is begin if RR2.all.F1 /= 55 then raise program_error; end if; end; R3: aliased R := (55, Null); R2: aliased R := (44, R3'Access); R1: aliased R := (22, R2'Access); P: Ar := R1'Access; X: Ar renames P.all.F2; Y: Ar renames X.all.F2; begin P := R2'Access; R1.F2 := R1'Access; Foo (X, Y); Y.F1 := -111; if Y.F1 /= -111 then raise Constraint_Error; end if; end Tfren;
zhmu/ananas
Ada
7,621
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . D I R E C T _ I O -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ with Ada.IO_Exceptions; with System.Direct_IO; with Interfaces.C_Streams; generic type Element_Type is private; package Ada.Direct_IO is pragma Compile_Time_Warning (Element_Type'Has_Access_Values, "Element_Type for Direct_IO instance has access values"); pragma Compile_Time_Warning (Element_Type'Has_Tagged_Values, "Element_Type for Direct_IO instance has tagged values"); type File_Type is limited private with Default_Initial_Condition; type File_Mode is (In_File, Inout_File, Out_File); -- The following representation clause allows the use of unchecked -- conversion for rapid translation between the File_Mode type -- used in this package and System.File_IO. for File_Mode use (In_File => 0, -- System.File_IO.File_Mode'Pos (In_File) Inout_File => 1, -- System.File_IO.File_Mode'Pos (Inout_File); Out_File => 2); -- System.File_IO.File_Mode'Pos (Out_File) type Count is range 0 .. System.Direct_IO.Count'Last; subtype Positive_Count is Count range 1 .. Count'Last; --------------------- -- File Management -- --------------------- procedure Create (File : in out File_Type; Mode : File_Mode := Inout_File; Name : String := ""; Form : String := ""); procedure Open (File : in out File_Type; Mode : File_Mode; Name : String; Form : String := ""); procedure Close (File : in out File_Type); procedure Delete (File : in out File_Type); procedure Reset (File : in out File_Type; Mode : File_Mode); procedure Reset (File : in out File_Type); function Mode (File : File_Type) return File_Mode; function Name (File : File_Type) return String; function Form (File : File_Type) return String; function Is_Open (File : File_Type) return Boolean; procedure Flush (File : File_Type); --------------------------------- -- Input and Output Operations -- --------------------------------- procedure Read (File : File_Type; Item : out Element_Type; From : Positive_Count); procedure Read (File : File_Type; Item : out Element_Type); procedure Write (File : File_Type; Item : Element_Type; To : Positive_Count); procedure Write (File : File_Type; Item : Element_Type); procedure Set_Index (File : File_Type; To : Positive_Count); function Index (File : File_Type) return Positive_Count; function Size (File : File_Type) return Count; function End_Of_File (File : File_Type) return Boolean; ---------------- -- Exceptions -- ---------------- Status_Error : exception renames IO_Exceptions.Status_Error; Mode_Error : exception renames IO_Exceptions.Mode_Error; Name_Error : exception renames IO_Exceptions.Name_Error; Use_Error : exception renames IO_Exceptions.Use_Error; Device_Error : exception renames IO_Exceptions.Device_Error; End_Error : exception renames IO_Exceptions.End_Error; Data_Error : exception renames IO_Exceptions.Data_Error; private -- The following procedures have a File_Type formal of mode IN OUT because -- they may close the original file. The Close operation may raise an -- exception, but in that case we want any assignment to the formal to -- be effective anyway, so it must be passed by reference (or the caller -- will be left with a dangling pointer). pragma Export_Procedure (Internal => Close, External => "", Mechanism => Reference); pragma Export_Procedure (Internal => Delete, External => "", Mechanism => Reference); pragma Export_Procedure (Internal => Reset, External => "", Parameter_Types => (File_Type), Mechanism => Reference); pragma Export_Procedure (Internal => Reset, External => "", Parameter_Types => (File_Type, File_Mode), Mechanism => (File => Reference)); type File_Type is new System.Direct_IO.File_Type; Bytes : constant Interfaces.C_Streams.size_t := Interfaces.C_Streams.size_t'Max (1, Element_Type'Max_Size_In_Storage_Elements); -- Size of an element in storage units. The Max operation here is to ensure -- that we allocate a single byte for zero-sized elements. It's a bit weird -- to instantiate Direct_IO with zero sized elements, but it is legal and -- this adjustment ensures that we don't get anomalous behavior. pragma Inline (Close); pragma Inline (Create); pragma Inline (Delete); pragma Inline (End_Of_File); pragma Inline (Form); pragma Inline (Index); pragma Inline (Is_Open); pragma Inline (Mode); pragma Inline (Name); pragma Inline (Open); pragma Inline (Read); pragma Inline (Reset); pragma Inline (Set_Index); pragma Inline (Size); pragma Inline (Write); end Ada.Direct_IO;
shintakezou/drake
Ada
35,215
adb
-- diff (Ada.Exceptions.Finally) with Ada.Unchecked_Conversion; with Ada.Unchecked_Deallocation; with Ada.Streams; -- [gcc-4.7] can not search in private with with System; package body Ada.Containers.Ordered_Sets is use type Binary_Trees.Node_Access; use type Copy_On_Write.Data_Access; function Upcast is new Unchecked_Conversion (Cursor, Binary_Trees.Node_Access); function Downcast is new Unchecked_Conversion (Binary_Trees.Node_Access, Cursor); function Upcast is new Unchecked_Conversion (Data_Access, Copy_On_Write.Data_Access); function Downcast is new Unchecked_Conversion (Copy_On_Write.Data_Access, Data_Access); -- diff (Free) procedure Free is new Unchecked_Deallocation (Node, Cursor); function Compare_Elements (Left, Right : Element_Type) return Integer; function Compare_Elements (Left, Right : Element_Type) return Integer is begin if Left < Right then return -1; elsif Right < Left then return 1; else return 0; end if; end Compare_Elements; type Context_Type is limited record Left : not null access Element_Type; end record; pragma Suppress_Initialization (Context_Type); function Compare_Element ( Position : not null Binary_Trees.Node_Access; Params : System.Address) return Integer; function Compare_Element ( Position : not null Binary_Trees.Node_Access; Params : System.Address) return Integer is Context : Context_Type; for Context'Address use Params; begin return Compare_Elements ( Context.Left.all, Downcast (Position).Element); end Compare_Element; function Compare_Node (Left, Right : not null Binary_Trees.Node_Access) return Integer; function Compare_Node (Left, Right : not null Binary_Trees.Node_Access) return Integer is begin return Compare_Elements ( Downcast (Left).Element, Downcast (Right).Element); end Compare_Node; -- diff (Allocate_Element) -- -- -- -- -- -- -- -- procedure Allocate_Node (Item : out Cursor; New_Item : Element_Type); procedure Allocate_Node (Item : out Cursor; New_Item : Element_Type) is -- diff -- diff -- diff begin Item := new Node'(Super => <>, Element => New_Item); -- diff -- diff -- diff end Allocate_Node; procedure Copy_Node ( Target : out Binary_Trees.Node_Access; Source : not null Binary_Trees.Node_Access); procedure Copy_Node ( Target : out Binary_Trees.Node_Access; Source : not null Binary_Trees.Node_Access) is New_Node : Cursor; begin Allocate_Node (New_Node, Downcast (Source).Element); Target := Upcast (New_Node); end Copy_Node; procedure Free_Node (Object : in out Binary_Trees.Node_Access); procedure Free_Node (Object : in out Binary_Trees.Node_Access) is X : Cursor := Downcast (Object); begin -- diff Free (X); Object := null; end Free_Node; procedure Allocate_Data ( Target : out not null Copy_On_Write.Data_Access; New_Length : Count_Type; Capacity : Count_Type); procedure Allocate_Data ( Target : out not null Copy_On_Write.Data_Access; New_Length : Count_Type; Capacity : Count_Type) is pragma Unreferenced (New_Length); pragma Unreferenced (Capacity); New_Data : constant Data_Access := new Data'(Super => <>, Root => null, Length => 0); begin Target := Upcast (New_Data); end Allocate_Data; procedure Copy_Data ( Target : out not null Copy_On_Write.Data_Access; Source : not null Copy_On_Write.Data_Access; Length : Count_Type; New_Length : Count_Type; Capacity : Count_Type); procedure Copy_Data ( Target : out not null Copy_On_Write.Data_Access; Source : not null Copy_On_Write.Data_Access; Length : Count_Type; New_Length : Count_Type; Capacity : Count_Type) is pragma Unreferenced (Length); pragma Unreferenced (New_Length); pragma Unreferenced (Capacity); begin Allocate_Data (Target, 0, 0); Base.Copy ( Downcast (Target).Root, Downcast (Target).Length, Source => Downcast (Source).Root, Copy => Copy_Node'Access); end Copy_Data; procedure Free is new Unchecked_Deallocation (Data, Data_Access); procedure Free_Data (Data : in out Copy_On_Write.Data_Access); procedure Free_Data (Data : in out Copy_On_Write.Data_Access) is X : Data_Access := Downcast (Data); begin Binary_Trees.Free (X.Root, X.Length, Free => Free_Node'Access); Free (X); Data := null; end Free_Data; procedure Unique (Container : in out Set; To_Update : Boolean); procedure Unique (Container : in out Set; To_Update : Boolean) is begin if Copy_On_Write.Shared (Container.Super.Data) then Copy_On_Write.Unique ( Target => Container.Super'Access, To_Update => To_Update, Allocate => Allocate_Data'Access, Move => Copy_Data'Access, Copy => Copy_Data'Access, Free => Free_Data'Access); end if; end Unique; function Equivalent_Sets ( Left, Right : Set; Equivalent : not null access function ( Left, Right : not null Binary_Trees.Node_Access) return Boolean) return Boolean; function Equivalent_Sets ( Left, Right : Set; Equivalent : not null access function ( Left, Right : not null Binary_Trees.Node_Access) return Boolean) return Boolean is Left_Length : constant Count_Type := Length (Left); Right_Length : constant Count_Type := Length (Right); begin if Left_Length /= Right_Length then return False; elsif Left_Length = 0 or else Left.Super.Data = Right.Super.Data then return True; else Unique (Left'Unrestricted_Access.all, False); -- private Unique (Right'Unrestricted_Access.all, False); -- private return Binary_Trees.Equivalent ( Downcast (Left.Super.Data).Root, Downcast (Right.Super.Data).Root, Equivalent => Equivalent); end if; end Equivalent_Sets; -- implementation function Equivalent_Elements (Left, Right : Element_Type) return Boolean is begin return Compare_Elements (Left, Right) = 0; end Equivalent_Elements; function Empty_Set return Set is begin return (Finalization.Controlled with Super => (null, null)); end Empty_Set; function Has_Element (Position : Cursor) return Boolean is begin return Position /= No_Element; end Has_Element; overriding function "=" (Left, Right : Set) return Boolean is function Equivalent (Left, Right : not null Binary_Trees.Node_Access) return Boolean; function Equivalent (Left, Right : not null Binary_Trees.Node_Access) return Boolean is begin return Downcast (Left).Element = Downcast (Right).Element; end Equivalent; begin return Equivalent_Sets (Left, Right, Equivalent => Equivalent'Access); end "="; function Equivalent_Sets (Left, Right : Set) return Boolean is function Equivalent (Left, Right : not null Binary_Trees.Node_Access) return Boolean; function Equivalent (Left, Right : not null Binary_Trees.Node_Access) return Boolean is begin return Equivalent_Elements ( Downcast (Left).Element, Downcast (Right).Element); end Equivalent; begin return Equivalent_Sets (Left, Right, Equivalent => Equivalent'Access); end Equivalent_Sets; function To_Set (New_Item : Element_Type) return Set is begin return Result : Set do Insert (Result, New_Item); end return; end To_Set; function Generic_Array_To_Set (S : Element_Array) return Set is begin return Result : Set do for I in S'Range loop Include (Result, S (I)); end loop; end return; end Generic_Array_To_Set; function Length (Container : Set) return Count_Type is Data : constant Data_Access := Downcast (Container.Super.Data); begin if Data = null then return 0; else return Data.Length; end if; end Length; function Is_Empty (Container : Set) return Boolean is Data : constant Data_Access := Downcast (Container.Super.Data); begin return Data = null or else Data.Root = null; end Is_Empty; procedure Clear (Container : in out Set) is begin Copy_On_Write.Clear (Container.Super'Access, Free => Free_Data'Access); end Clear; function Element (Position : Cursor) return Element_Type is begin return Position.Element; end Element; procedure Replace_Element ( Container : in out Set; Position : Cursor; New_Item : Element_Type) is begin Unique (Container, True); -- diff Position.Element := New_Item; end Replace_Element; procedure Query_Element ( Position : Cursor; Process : not null access procedure (Element : Element_Type)) is begin Process (Position.Element); end Query_Element; function Constant_Reference (Container : aliased Set; Position : Cursor) return Constant_Reference_Type is pragma Unreferenced (Container); begin return (Element => Position.all.Element'Access); -- [gcc-6] .all end Constant_Reference; procedure Assign (Target : in out Set; Source : Set) is begin Copy_On_Write.Assign ( Target.Super'Access, Source.Super'Access, Free => Free_Data'Access); end Assign; function Copy (Source : Set) return Set is begin return Result : Set do Copy_On_Write.Copy ( Result.Super'Access, Source.Super'Access, Allocate => Allocate_Data'Access, Copy => Copy_Data'Access); end return; end Copy; procedure Move (Target : in out Set; Source : in out Set) is begin Copy_On_Write.Move ( Target.Super'Access, Source.Super'Access, Free => Free_Data'Access); -- diff -- diff -- diff end Move; procedure Insert ( Container : in out Set; New_Item : Element_Type; Position : out Cursor; Inserted : out Boolean) is -- diff -- diff -- diff Before : constant Cursor := Ceiling (Container, New_Item); begin -- diff Inserted := Before = null or else New_Item < Before.Element; if Inserted then Unique (Container, True); Allocate_Node (Position, New_Item); declare Data : constant Data_Access := Downcast (Container.Super.Data); begin Base.Insert ( Data.Root, Data.Length, Upcast (Before), Upcast (Position)); end; else Position := Before; end if; end Insert; procedure Insert ( Container : in out Set; New_Item : Element_Type) is Position : Cursor; Inserted : Boolean; begin Insert (Container, New_Item, Position, Inserted); if not Inserted then raise Constraint_Error; end if; end Insert; procedure Include (Container : in out Set; New_Item : Element_Type) is Position : Cursor; Inserted : Boolean; begin Insert (Container, New_Item, Position, Inserted); if not Inserted then Replace_Element (Container, Position, New_Item); end if; end Include; procedure Replace (Container : in out Set; New_Item : Element_Type) is begin Replace_Element (Container, Find (Container, New_Item), New_Item); end Replace; procedure Exclude (Container : in out Set; Item : Element_Type) is Position : Cursor := Find (Container, Item); begin if Position /= null then Delete (Container, Position); end if; end Exclude; procedure Delete (Container : in out Set; Item : Element_Type) is Position : Cursor := Find (Container, Item); begin Delete (Container, Position); end Delete; procedure Delete (Container : in out Set; Position : in out Cursor) is Position_2 : Binary_Trees.Node_Access := Upcast (Position); begin Unique (Container, True); declare Data : constant Data_Access := Downcast (Container.Super.Data); begin Base.Remove (Data.Root, Data.Length, Position_2); end; Free_Node (Position_2); Position := null; end Delete; procedure Delete_First (Container : in out Set'Class) is Position : Cursor := First (Set (Container)); begin Delete (Set (Container), Position); end Delete_First; procedure Delete_Last (Container : in out Set'Class) is Position : Cursor := Last (Set (Container)); begin Delete (Set (Container), Position); end Delete_Last; procedure Union (Target : in out Set; Source : Set) is begin if Is_Empty (Source) or else Target.Super.Data = Source.Super.Data then null; elsif Is_Empty (Target) then Assign (Target, Source); else Unique (Target, True); Unique (Source'Unrestricted_Access.all, False); -- private declare Target_Data : constant Data_Access := Downcast (Target.Super.Data); begin Base.Merge ( Target_Data.Root, Target_Data.Length, Downcast (Source.Super.Data).Root, (others => True), Compare => Compare_Node'Access, Copy => Copy_Node'Access, Free => Free_Node'Access); end; end if; end Union; function Union (Left, Right : Set) return Set is begin return Result : Set do if Is_Empty (Right) or else Left.Super.Data = Right.Super.Data then Assign (Result, Left); elsif Is_Empty (Left) then Assign (Result, Right); else Unique (Result, True); Unique (Left'Unrestricted_Access.all, False); -- private Unique (Right'Unrestricted_Access.all, False); -- private declare Result_Data : constant Data_Access := Downcast (Result.Super.Data); begin Base.Copying_Merge ( Result_Data.Root, Result_Data.Length, Downcast (Left.Super.Data).Root, Downcast (Right.Super.Data).Root, (others => True), Compare => Compare_Node'Access, Copy => Copy_Node'Access); end; end if; end return; end Union; procedure Intersection (Target : in out Set; Source : Set) is begin if Is_Empty (Target) or else Is_Empty (Source) then Clear (Target); elsif Target.Super.Data = Source.Super.Data then null; else Unique (Target, True); Unique (Source'Unrestricted_Access.all, False); -- private declare Target_Data : constant Data_Access := Downcast (Target.Super.Data); begin Base.Merge ( Target_Data.Root, Target_Data.Length, Downcast (Source.Super.Data).Root, (Binary_Trees.In_Both => True, others => False), Compare => Compare_Node'Access, Copy => Copy_Node'Access, Free => Free_Node'Access); end; end if; end Intersection; function Intersection (Left, Right : Set) return Set is begin return Result : Set do if Is_Empty (Left) or else Is_Empty (Right) then null; -- Empty_Set elsif Left.Super.Data = Right.Super.Data then Assign (Result, Left); else Unique (Result, True); Unique (Left'Unrestricted_Access.all, False); -- private Unique (Right'Unrestricted_Access.all, False); -- private declare Result_Data : constant Data_Access := Downcast (Result.Super.Data); begin Base.Copying_Merge ( Result_Data.Root, Result_Data.Length, Downcast (Left.Super.Data).Root, Downcast (Right.Super.Data).Root, (Binary_Trees.In_Both => True, others => False), Compare => Compare_Node'Access, Copy => Copy_Node'Access); end; end if; end return; end Intersection; procedure Difference (Target : in out Set; Source : Set) is begin if Is_Empty (Target) or else Target.Super.Data = Source.Super.Data then Clear (Target); elsif Is_Empty (Source) then null; else Unique (Target, True); Unique (Source'Unrestricted_Access.all, False); -- private declare Target_Data : constant Data_Access := Downcast (Target.Super.Data); begin Base.Merge ( Target_Data.Root, Target_Data.Length, Downcast (Source.Super.Data).Root, (Binary_Trees.In_Only_Left => True, others => False), Compare => Compare_Node'Access, Copy => Copy_Node'Access, Free => Free_Node'Access); end; end if; end Difference; function Difference (Left, Right : Set) return Set is begin return Result : Set do if Is_Empty (Left) or else Left.Super.Data = Right.Super.Data then null; -- Empty_Set elsif Is_Empty (Right) then Assign (Result, Left); else Unique (Result, True); Unique (Left'Unrestricted_Access.all, False); -- private Unique (Right'Unrestricted_Access.all, False); -- private declare Result_Data : constant Data_Access := Downcast (Result.Super.Data); begin Base.Copying_Merge ( Result_Data.Root, Result_Data.Length, Downcast (Left.Super.Data).Root, Downcast (Right.Super.Data).Root, (Binary_Trees.In_Only_Left => True, others => False), Compare => Compare_Node'Access, Copy => Copy_Node'Access); end; end if; end return; end Difference; procedure Symmetric_Difference (Target : in out Set; Source : Set) is begin if Target.Super.Data = Source.Super.Data then Clear (Target); elsif Is_Empty (Source) then null; elsif Is_Empty (Target) then Assign (Target, Source); else Unique (Target, True); Unique (Source'Unrestricted_Access.all, False); -- private declare Target_Data : constant Data_Access := Downcast (Target.Super.Data); begin Base.Merge ( Target_Data.Root, Target_Data.Length, Downcast (Source.Super.Data).Root, (Binary_Trees.In_Both => False, others => True), Compare => Compare_Node'Access, Copy => Copy_Node'Access, Free => Free_Node'Access); end; end if; end Symmetric_Difference; function Symmetric_Difference (Left, Right : Set) return Set is begin return Result : Set do if Left.Super.Data = Right.Super.Data then null; -- Empty_Set elsif Is_Empty (Right) then Assign (Result, Left); elsif Is_Empty (Left) then Assign (Result, Right); else Unique (Result, True); Unique (Left'Unrestricted_Access.all, False); -- private Unique (Right'Unrestricted_Access.all, False); -- private declare Result_Data : constant Data_Access := Downcast (Result.Super.Data); begin Base.Copying_Merge ( Result_Data.Root, Result_Data.Length, Downcast (Left.Super.Data).Root, Downcast (Right.Super.Data).Root, (Binary_Trees.In_Both => False, others => True), Compare => Compare_Node'Access, Copy => Copy_Node'Access); end; end if; end return; end Symmetric_Difference; function Overlap (Left, Right : Set) return Boolean is begin if Is_Empty (Left) or else Is_Empty (Right) then return False; elsif Left.Super.Data = Right.Super.Data then return True; else Unique (Left'Unrestricted_Access.all, False); -- private Unique (Right'Unrestricted_Access.all, False); -- private return Binary_Trees.Overlap ( Downcast (Left.Super.Data).Root, Downcast (Right.Super.Data).Root, Compare => Compare_Node'Access); end if; end Overlap; function Is_Subset (Subset : Set; Of_Set : Set) return Boolean is begin if Is_Empty (Subset) or else Subset.Super.Data = Of_Set.Super.Data then return True; elsif Is_Empty (Of_Set) then return False; else Unique (Subset'Unrestricted_Access.all, False); -- private Unique (Of_Set'Unrestricted_Access.all, False); -- private return Binary_Trees.Is_Subset ( Downcast (Subset.Super.Data).Root, Downcast (Of_Set.Super.Data).Root, Compare => Compare_Node'Access); end if; end Is_Subset; function First (Container : Set) return Cursor is begin if Is_Empty (Container) then return null; else Unique (Container'Unrestricted_Access.all, False); return Downcast (Binary_Trees.First ( Downcast (Container.Super.Data).Root)); end if; end First; function First_Element (Container : Set'Class) return Element_Type is begin return Element (First (Set (Container))); end First_Element; function Last (Container : Set) return Cursor is begin if Is_Empty (Container) then return null; else Unique (Container'Unrestricted_Access.all, False); return Downcast (Binary_Trees.Last ( Downcast (Container.Super.Data).Root)); end if; end Last; function Last_Element (Container : Set'Class) return Element_Type is begin return Element (Last (Set (Container))); end Last_Element; function Next (Position : Cursor) return Cursor is begin return Downcast (Binary_Trees.Next (Upcast (Position))); end Next; procedure Next (Position : in out Cursor) is begin Position := Downcast (Binary_Trees.Next (Upcast (Position))); end Next; function Previous (Position : Cursor) return Cursor is begin return Downcast (Binary_Trees.Previous (Upcast (Position))); end Previous; procedure Previous (Position : in out Cursor) is begin Position := Downcast (Binary_Trees.Previous (Upcast (Position))); end Previous; function Find (Container : Set; Item : Element_Type) return Cursor is begin if Is_Empty (Container) then return null; else Unique (Container'Unrestricted_Access.all, False); declare Context : Context_Type := (Left => Item'Unrestricted_Access); begin return Downcast (Binary_Trees.Find ( Downcast (Container.Super.Data).Root, Binary_Trees.Just, Context'Address, Compare => Compare_Element'Access)); end; end if; end Find; function Floor (Container : Set; Item : Element_Type) return Cursor is begin if Is_Empty (Container) then return null; else Unique (Container'Unrestricted_Access.all, False); declare Context : Context_Type := (Left => Item'Unrestricted_Access); begin return Downcast (Binary_Trees.Find ( Downcast (Container.Super.Data).Root, Binary_Trees.Floor, Context'Address, Compare => Compare_Element'Access)); end; end if; end Floor; function Ceiling (Container : Set; Item : Element_Type) return Cursor is begin if Is_Empty (Container) then return null; else Unique (Container'Unrestricted_Access.all, False); declare Context : Context_Type := (Left => Item'Unrestricted_Access); begin return Downcast (Binary_Trees.Find ( Downcast (Container.Super.Data).Root, Binary_Trees.Ceiling, Context'Address, Compare => Compare_Element'Access)); end; end if; end Ceiling; function Contains (Container : Set; Item : Element_Type) return Boolean is begin return Find (Container, Item) /= null; end Contains; function "<" (Left, Right : Cursor) return Boolean is begin return Left /= Right and then Left.Element < Right.Element; end "<"; function ">" (Left, Right : Cursor) return Boolean is begin return Right < Left; end ">"; function "<" (Left : Cursor; Right : Element_Type) return Boolean is begin return Left.Element < Right; end "<"; function ">" (Left : Cursor; Right : Element_Type) return Boolean is begin return Right < Left; end ">"; function "<" (Left : Element_Type; Right : Cursor) return Boolean is begin return Left < Right.Element; end "<"; function ">" (Left : Element_Type; Right : Cursor) return Boolean is begin return Right < Left; end ">"; procedure Iterate ( Container : Set'Class; Process : not null access procedure (Position : Cursor)) is type P1 is access procedure (Position : Cursor); type P2 is access procedure (Position : Binary_Trees.Node_Access); function Cast is new Unchecked_Conversion (P1, P2); begin if not Is_Empty (Set (Container)) then Unique (Set (Container)'Unrestricted_Access.all, False); Binary_Trees.Iterate ( Downcast (Container.Super.Data).Root, Cast (Process)); end if; end Iterate; procedure Reverse_Iterate ( Container : Set'Class; Process : not null access procedure (Position : Cursor)) is type P1 is access procedure (Position : Cursor); type P2 is access procedure (Position : Binary_Trees.Node_Access); function Cast is new Unchecked_Conversion (P1, P2); begin if not Is_Empty (Set (Container)) then Unique (Set (Container)'Unrestricted_Access.all, False); Binary_Trees.Reverse_Iterate ( Downcast (Container.Super.Data).Root, Cast (Process)); end if; end Reverse_Iterate; function Iterate (Container : Set'Class) return Set_Iterator_Interfaces.Reversible_Iterator'Class is begin return Set_Iterator'( First => First (Set (Container)), Last => Last (Set (Container))); end Iterate; function Iterate (Container : Set'Class; First, Last : Cursor) return Set_Iterator_Interfaces.Reversible_Iterator'Class is pragma Unreferenced (Container); Actual_First : Cursor := First; Actual_Last : Cursor := Last; begin if Actual_First = No_Element or else Actual_Last = No_Element or else Actual_Last < Actual_First then Actual_First := No_Element; Actual_Last := No_Element; end if; return Set_Iterator'(First => Actual_First, Last => Actual_Last); end Iterate; overriding procedure Adjust (Object : in out Set) is begin Copy_On_Write.Adjust (Object.Super'Access); end Adjust; overriding function First (Object : Set_Iterator) return Cursor is begin return Object.First; end First; overriding function Next (Object : Set_Iterator; Position : Cursor) return Cursor is begin if Position = Object.Last then return No_Element; else return Next (Position); end if; end Next; overriding function Last (Object : Set_Iterator) return Cursor is begin return Object.Last; end Last; overriding function Previous (Object : Set_Iterator; Position : Cursor) return Cursor is begin if Position = Object.First then return No_Element; else return Previous (Position); end if; end Previous; package body Generic_Keys is type Context_Type is limited record Left : not null access Key_Type; end record; pragma Suppress_Initialization (Context_Type); function Compare_Key ( Position : not null Binary_Trees.Node_Access; Params : System.Address) return Integer; function Compare_Key ( Position : not null Binary_Trees.Node_Access; Params : System.Address) return Integer is Context : Context_Type; for Context'Address use Params; Left : Key_Type renames Context.Left.all; Right : Key_Type renames Key (Downcast (Position).Element); begin if Left < Right then return -1; elsif Right < Left then return 1; else return 0; end if; end Compare_Key; function Equivalent_Keys (Left, Right : Key_Type) return Boolean is begin return not (Left < Right) and then not (Right < Left); end Equivalent_Keys; function Key (Position : Cursor) return Key_Type is begin return Key (Position.Element); end Key; function Element (Container : Set; Key : Key_Type) return Element_Type is begin return Element (Find (Container, Key)); end Element; procedure Replace ( Container : in out Set; Key : Key_Type; New_Item : Element_Type) is begin Replace_Element (Container, Find (Container, Key), New_Item); end Replace; procedure Exclude (Container : in out Set; Key : Key_Type) is Position : Cursor := Find (Container, Key); begin if Position /= null then Delete (Container, Position); end if; end Exclude; procedure Delete (Container : in out Set; Key : Key_Type) is Position : Cursor := Find (Container, Key); begin Delete (Container, Position); end Delete; function Find (Container : Set; Key : Key_Type) return Cursor is begin if Is_Empty (Container) then return null; else Unique (Container'Unrestricted_Access.all, False); declare Context : Context_Type := (Left => Key'Unrestricted_Access); begin return Downcast (Binary_Trees.Find ( Downcast (Container.Super.Data).Root, Binary_Trees.Just, Context'Address, Compare => Compare_Key'Access)); end; end if; end Find; function Floor (Container : Set; Key : Key_Type) return Cursor is begin if Is_Empty (Container) then return null; else Unique (Container'Unrestricted_Access.all, False); declare Context : Context_Type := (Left => Key'Unrestricted_Access); begin return Downcast (Binary_Trees.Find ( Downcast (Container.Super.Data).Root, Binary_Trees.Floor, Context'Address, Compare => Compare_Key'Access)); end; end if; end Floor; function Ceiling (Container : Set; Key : Key_Type) return Cursor is begin if Is_Empty (Container) then return null; else Unique (Container'Unrestricted_Access.all, False); declare Context : Context_Type := (Left => Key'Unrestricted_Access); begin return Downcast (Binary_Trees.Find ( Downcast (Container.Super.Data).Root, Binary_Trees.Ceiling, Context'Address, Compare => Compare_Key'Access)); end; end if; end Ceiling; function Contains (Container : Set; Key : Key_Type) return Boolean is begin return Find (Container, Key) /= null; end Contains; procedure Update_Element_Preserving_Key ( Container : in out Set; Position : Cursor; Process : not null access procedure ( Element : in out Element_Type)) is begin Process (Reference_Preserving_Key (Container, Position).Element.all); end Update_Element_Preserving_Key; function Reference_Preserving_Key ( Container : aliased in out Set; Position : Cursor) return Reference_Type is begin Unique (Container, True); -- diff return (Element => Position.all.Element'Access); -- [gcc-6] .all end Reference_Preserving_Key; function Constant_Reference (Container : aliased Set; Key : Key_Type) return Constant_Reference_Type is begin return Constant_Reference (Container, Find (Container, Key)); end Constant_Reference; function Reference_Preserving_Key ( Container : aliased in out Set; Key : Key_Type) return Reference_Type is begin return Reference_Preserving_Key (Container, Find (Container, Key)); end Reference_Preserving_Key; end Generic_Keys; package body Streaming is procedure Read ( Stream : not null access Streams.Root_Stream_Type'Class; Item : out Set) is Length : Count_Type'Base; begin Count_Type'Base'Read (Stream, Length); Clear (Item); for I in 1 .. Length loop declare New_Item : Element_Type; begin Element_Type'Read (Stream, New_Item); Include (Item, New_Item); end; end loop; end Read; procedure Write ( Stream : not null access Streams.Root_Stream_Type'Class; Item : Set) is Length : constant Count_Type := Ordered_Sets.Length (Item); begin Count_Type'Write (Stream, Length); if Length > 0 then declare Position : Cursor := First (Item); begin while Position /= null loop Element_Type'Write (Stream, Position.Element); Next (Position); end loop; end; end if; end Write; end Streaming; end Ada.Containers.Ordered_Sets;
AdaCore/Ada_Drivers_Library
Ada
23,231
ads
-- Copyright (c) 2013, Nordic Semiconductor ASA -- 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 Nordic Semiconductor ASA 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. -- -- This spec has been automatically generated from nrf51.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package NRF_SVD.RTC is pragma Preelaborate; --------------- -- Registers -- --------------- -- Compare event on CC[n] match. -- Compare event on CC[n] match. type EVENTS_COMPARE_Registers is array (0 .. 3) of HAL.UInt32; -- Enable interrupt on TICK event. type INTENSET_TICK_Field is (-- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENSET_TICK_Field use (Disabled => 0, Enabled => 1); -- Enable interrupt on TICK event. type INTENSET_TICK_Field_1 is (-- Reset value for the field Intenset_Tick_Field_Reset, -- Enable interrupt on write. Set) with Size => 1; for INTENSET_TICK_Field_1 use (Intenset_Tick_Field_Reset => 0, Set => 1); -- Enable interrupt on OVRFLW event. type INTENSET_OVRFLW_Field is (-- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENSET_OVRFLW_Field use (Disabled => 0, Enabled => 1); -- Enable interrupt on OVRFLW event. type INTENSET_OVRFLW_Field_1 is (-- Reset value for the field Intenset_Ovrflw_Field_Reset, -- Enable interrupt on write. Set) with Size => 1; for INTENSET_OVRFLW_Field_1 use (Intenset_Ovrflw_Field_Reset => 0, Set => 1); -- Enable interrupt on COMPARE[0] event. type INTENSET_COMPARE0_Field is (-- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENSET_COMPARE0_Field use (Disabled => 0, Enabled => 1); -- Enable interrupt on COMPARE[0] event. type INTENSET_COMPARE0_Field_1 is (-- Reset value for the field Intenset_Compare0_Field_Reset, -- Enable interrupt on write. Set) with Size => 1; for INTENSET_COMPARE0_Field_1 use (Intenset_Compare0_Field_Reset => 0, Set => 1); -- INTENSET_COMPARE array type INTENSET_COMPARE_Field_Array is array (0 .. 3) of INTENSET_COMPARE0_Field_1 with Component_Size => 1, Size => 4; -- Type definition for INTENSET_COMPARE type INTENSET_COMPARE_Field (As_Array : Boolean := False) is record case As_Array is when False => -- COMPARE as a value Val : HAL.UInt4; when True => -- COMPARE as an array Arr : INTENSET_COMPARE_Field_Array; end case; end record with Unchecked_Union, Size => 4; for INTENSET_COMPARE_Field use record Val at 0 range 0 .. 3; Arr at 0 range 0 .. 3; end record; -- Interrupt enable set register. type INTENSET_Register is record -- Enable interrupt on TICK event. TICK : INTENSET_TICK_Field_1 := Intenset_Tick_Field_Reset; -- Enable interrupt on OVRFLW event. OVRFLW : INTENSET_OVRFLW_Field_1 := Intenset_Ovrflw_Field_Reset; -- unspecified Reserved_2_15 : HAL.UInt14 := 16#0#; -- Enable interrupt on COMPARE[0] event. COMPARE : INTENSET_COMPARE_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_20_31 : HAL.UInt12 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INTENSET_Register use record TICK at 0 range 0 .. 0; OVRFLW at 0 range 1 .. 1; Reserved_2_15 at 0 range 2 .. 15; COMPARE at 0 range 16 .. 19; Reserved_20_31 at 0 range 20 .. 31; end record; -- Disable interrupt on TICK event. type INTENCLR_TICK_Field is (-- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENCLR_TICK_Field use (Disabled => 0, Enabled => 1); -- Disable interrupt on TICK event. type INTENCLR_TICK_Field_1 is (-- Reset value for the field Intenclr_Tick_Field_Reset, -- Disable interrupt on write. Clear) with Size => 1; for INTENCLR_TICK_Field_1 use (Intenclr_Tick_Field_Reset => 0, Clear => 1); -- Disable interrupt on OVRFLW event. type INTENCLR_OVRFLW_Field is (-- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENCLR_OVRFLW_Field use (Disabled => 0, Enabled => 1); -- Disable interrupt on OVRFLW event. type INTENCLR_OVRFLW_Field_1 is (-- Reset value for the field Intenclr_Ovrflw_Field_Reset, -- Disable interrupt on write. Clear) with Size => 1; for INTENCLR_OVRFLW_Field_1 use (Intenclr_Ovrflw_Field_Reset => 0, Clear => 1); -- Disable interrupt on COMPARE[0] event. type INTENCLR_COMPARE0_Field is (-- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENCLR_COMPARE0_Field use (Disabled => 0, Enabled => 1); -- Disable interrupt on COMPARE[0] event. type INTENCLR_COMPARE0_Field_1 is (-- Reset value for the field Intenclr_Compare0_Field_Reset, -- Disable interrupt on write. Clear) with Size => 1; for INTENCLR_COMPARE0_Field_1 use (Intenclr_Compare0_Field_Reset => 0, Clear => 1); -- INTENCLR_COMPARE array type INTENCLR_COMPARE_Field_Array is array (0 .. 3) of INTENCLR_COMPARE0_Field_1 with Component_Size => 1, Size => 4; -- Type definition for INTENCLR_COMPARE type INTENCLR_COMPARE_Field (As_Array : Boolean := False) is record case As_Array is when False => -- COMPARE as a value Val : HAL.UInt4; when True => -- COMPARE as an array Arr : INTENCLR_COMPARE_Field_Array; end case; end record with Unchecked_Union, Size => 4; for INTENCLR_COMPARE_Field use record Val at 0 range 0 .. 3; Arr at 0 range 0 .. 3; end record; -- Interrupt enable clear register. type INTENCLR_Register is record -- Disable interrupt on TICK event. TICK : INTENCLR_TICK_Field_1 := Intenclr_Tick_Field_Reset; -- Disable interrupt on OVRFLW event. OVRFLW : INTENCLR_OVRFLW_Field_1 := Intenclr_Ovrflw_Field_Reset; -- unspecified Reserved_2_15 : HAL.UInt14 := 16#0#; -- Disable interrupt on COMPARE[0] event. COMPARE : INTENCLR_COMPARE_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_20_31 : HAL.UInt12 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INTENCLR_Register use record TICK at 0 range 0 .. 0; OVRFLW at 0 range 1 .. 1; Reserved_2_15 at 0 range 2 .. 15; COMPARE at 0 range 16 .. 19; Reserved_20_31 at 0 range 20 .. 31; end record; -- TICK event enable. type EVTEN_TICK_Field is (-- Event disabled. Disabled, -- Event enabled. Enabled) with Size => 1; for EVTEN_TICK_Field use (Disabled => 0, Enabled => 1); -- OVRFLW event enable. type EVTEN_OVRFLW_Field is (-- Event disabled. Disabled, -- Event enabled. Enabled) with Size => 1; for EVTEN_OVRFLW_Field use (Disabled => 0, Enabled => 1); -- COMPARE[0] event enable. type EVTEN_COMPARE0_Field is (-- Event disabled. Disabled, -- Event enabled. Enabled) with Size => 1; for EVTEN_COMPARE0_Field use (Disabled => 0, Enabled => 1); -- EVTEN_COMPARE array type EVTEN_COMPARE_Field_Array is array (0 .. 3) of EVTEN_COMPARE0_Field with Component_Size => 1, Size => 4; -- Type definition for EVTEN_COMPARE type EVTEN_COMPARE_Field (As_Array : Boolean := False) is record case As_Array is when False => -- COMPARE as a value Val : HAL.UInt4; when True => -- COMPARE as an array Arr : EVTEN_COMPARE_Field_Array; end case; end record with Unchecked_Union, Size => 4; for EVTEN_COMPARE_Field use record Val at 0 range 0 .. 3; Arr at 0 range 0 .. 3; end record; -- Configures event enable routing to PPI for each RTC event. type EVTEN_Register is record -- TICK event enable. TICK : EVTEN_TICK_Field := NRF_SVD.RTC.Disabled; -- OVRFLW event enable. OVRFLW : EVTEN_OVRFLW_Field := NRF_SVD.RTC.Disabled; -- unspecified Reserved_2_15 : HAL.UInt14 := 16#0#; -- COMPARE[0] event enable. COMPARE : EVTEN_COMPARE_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_20_31 : HAL.UInt12 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for EVTEN_Register use record TICK at 0 range 0 .. 0; OVRFLW at 0 range 1 .. 1; Reserved_2_15 at 0 range 2 .. 15; COMPARE at 0 range 16 .. 19; Reserved_20_31 at 0 range 20 .. 31; end record; -- Enable routing to PPI of TICK event. type EVTENSET_TICK_Field is (-- Event disabled. Disabled, -- Event enabled. Enabled) with Size => 1; for EVTENSET_TICK_Field use (Disabled => 0, Enabled => 1); -- Enable routing to PPI of TICK event. type EVTENSET_TICK_Field_1 is (-- Reset value for the field Evtenset_Tick_Field_Reset, -- Enable event on write. Set) with Size => 1; for EVTENSET_TICK_Field_1 use (Evtenset_Tick_Field_Reset => 0, Set => 1); -- Enable routing to PPI of OVRFLW event. type EVTENSET_OVRFLW_Field is (-- Event disabled. Disabled, -- Event enabled. Enabled) with Size => 1; for EVTENSET_OVRFLW_Field use (Disabled => 0, Enabled => 1); -- Enable routing to PPI of OVRFLW event. type EVTENSET_OVRFLW_Field_1 is (-- Reset value for the field Evtenset_Ovrflw_Field_Reset, -- Enable event on write. Set) with Size => 1; for EVTENSET_OVRFLW_Field_1 use (Evtenset_Ovrflw_Field_Reset => 0, Set => 1); -- Enable routing to PPI of COMPARE[0] event. type EVTENSET_COMPARE0_Field is (-- Event disabled. Disabled, -- Event enabled. Enabled) with Size => 1; for EVTENSET_COMPARE0_Field use (Disabled => 0, Enabled => 1); -- Enable routing to PPI of COMPARE[0] event. type EVTENSET_COMPARE0_Field_1 is (-- Reset value for the field Evtenset_Compare0_Field_Reset, -- Enable event on write. Set) with Size => 1; for EVTENSET_COMPARE0_Field_1 use (Evtenset_Compare0_Field_Reset => 0, Set => 1); -- EVTENSET_COMPARE array type EVTENSET_COMPARE_Field_Array is array (0 .. 3) of EVTENSET_COMPARE0_Field_1 with Component_Size => 1, Size => 4; -- Type definition for EVTENSET_COMPARE type EVTENSET_COMPARE_Field (As_Array : Boolean := False) is record case As_Array is when False => -- COMPARE as a value Val : HAL.UInt4; when True => -- COMPARE as an array Arr : EVTENSET_COMPARE_Field_Array; end case; end record with Unchecked_Union, Size => 4; for EVTENSET_COMPARE_Field use record Val at 0 range 0 .. 3; Arr at 0 range 0 .. 3; end record; -- Enable events routing to PPI. The reading of this register gives the -- value of EVTEN. type EVTENSET_Register is record -- Enable routing to PPI of TICK event. TICK : EVTENSET_TICK_Field_1 := Evtenset_Tick_Field_Reset; -- Enable routing to PPI of OVRFLW event. OVRFLW : EVTENSET_OVRFLW_Field_1 := Evtenset_Ovrflw_Field_Reset; -- unspecified Reserved_2_15 : HAL.UInt14 := 16#0#; -- Enable routing to PPI of COMPARE[0] event. COMPARE : EVTENSET_COMPARE_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_20_31 : HAL.UInt12 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for EVTENSET_Register use record TICK at 0 range 0 .. 0; OVRFLW at 0 range 1 .. 1; Reserved_2_15 at 0 range 2 .. 15; COMPARE at 0 range 16 .. 19; Reserved_20_31 at 0 range 20 .. 31; end record; -- Disable routing to PPI of TICK event. type EVTENCLR_TICK_Field is (-- Event disabled. Disabled, -- Event enabled. Enabled) with Size => 1; for EVTENCLR_TICK_Field use (Disabled => 0, Enabled => 1); -- Disable routing to PPI of TICK event. type EVTENCLR_TICK_Field_1 is (-- Reset value for the field Evtenclr_Tick_Field_Reset, -- Disable event on write. Clear) with Size => 1; for EVTENCLR_TICK_Field_1 use (Evtenclr_Tick_Field_Reset => 0, Clear => 1); -- Disable routing to PPI of OVRFLW event. type EVTENCLR_OVRFLW_Field is (-- Event disabled. Disabled, -- Event enabled. Enabled) with Size => 1; for EVTENCLR_OVRFLW_Field use (Disabled => 0, Enabled => 1); -- Disable routing to PPI of OVRFLW event. type EVTENCLR_OVRFLW_Field_1 is (-- Reset value for the field Evtenclr_Ovrflw_Field_Reset, -- Disable event on write. Clear) with Size => 1; for EVTENCLR_OVRFLW_Field_1 use (Evtenclr_Ovrflw_Field_Reset => 0, Clear => 1); -- Disable routing to PPI of COMPARE[0] event. type EVTENCLR_COMPARE0_Field is (-- Event disabled. Disabled, -- Event enabled. Enabled) with Size => 1; for EVTENCLR_COMPARE0_Field use (Disabled => 0, Enabled => 1); -- Disable routing to PPI of COMPARE[0] event. type EVTENCLR_COMPARE0_Field_1 is (-- Reset value for the field Evtenclr_Compare0_Field_Reset, -- Disable event on write. Clear) with Size => 1; for EVTENCLR_COMPARE0_Field_1 use (Evtenclr_Compare0_Field_Reset => 0, Clear => 1); -- EVTENCLR_COMPARE array type EVTENCLR_COMPARE_Field_Array is array (0 .. 3) of EVTENCLR_COMPARE0_Field_1 with Component_Size => 1, Size => 4; -- Type definition for EVTENCLR_COMPARE type EVTENCLR_COMPARE_Field (As_Array : Boolean := False) is record case As_Array is when False => -- COMPARE as a value Val : HAL.UInt4; when True => -- COMPARE as an array Arr : EVTENCLR_COMPARE_Field_Array; end case; end record with Unchecked_Union, Size => 4; for EVTENCLR_COMPARE_Field use record Val at 0 range 0 .. 3; Arr at 0 range 0 .. 3; end record; -- Disable events routing to PPI. The reading of this register gives the -- value of EVTEN. type EVTENCLR_Register is record -- Disable routing to PPI of TICK event. TICK : EVTENCLR_TICK_Field_1 := Evtenclr_Tick_Field_Reset; -- Disable routing to PPI of OVRFLW event. OVRFLW : EVTENCLR_OVRFLW_Field_1 := Evtenclr_Ovrflw_Field_Reset; -- unspecified Reserved_2_15 : HAL.UInt14 := 16#0#; -- Disable routing to PPI of COMPARE[0] event. COMPARE : EVTENCLR_COMPARE_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_20_31 : HAL.UInt12 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for EVTENCLR_Register use record TICK at 0 range 0 .. 0; OVRFLW at 0 range 1 .. 1; Reserved_2_15 at 0 range 2 .. 15; COMPARE at 0 range 16 .. 19; Reserved_20_31 at 0 range 20 .. 31; end record; subtype COUNTER_COUNTER_Field is HAL.UInt24; -- Current COUNTER value. type COUNTER_Register is record -- Read-only. Counter value. COUNTER : COUNTER_COUNTER_Field; -- unspecified Reserved_24_31 : HAL.UInt8; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for COUNTER_Register use record COUNTER at 0 range 0 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; subtype PRESCALER_PRESCALER_Field is HAL.UInt12; -- 12-bit prescaler for COUNTER frequency (32768/(PRESCALER+1)). Must be -- written when RTC is STOPed. type PRESCALER_Register is record -- RTC PRESCALER value. PRESCALER : PRESCALER_PRESCALER_Field := 16#0#; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for PRESCALER_Register use record PRESCALER at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; subtype CC_COMPARE_Field is HAL.UInt24; -- Capture/compare registers. type CC_Register is record -- Compare value. COMPARE : CC_COMPARE_Field := 16#0#; -- unspecified Reserved_24_31 : HAL.UInt8 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CC_Register use record COMPARE at 0 range 0 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; -- Capture/compare registers. type CC_Registers is array (0 .. 3) of CC_Register; -- Peripheral power control. type POWER_POWER_Field is (-- Module power disabled. Disabled, -- Module power enabled. Enabled) with Size => 1; for POWER_POWER_Field use (Disabled => 0, Enabled => 1); -- Peripheral power control. type POWER_Register is record -- Peripheral power control. POWER : POWER_POWER_Field := NRF_SVD.RTC.Disabled; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for POWER_Register use record POWER at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Real time counter 0. type RTC_Peripheral is record -- Start RTC Counter. TASKS_START : aliased HAL.UInt32; -- Stop RTC Counter. TASKS_STOP : aliased HAL.UInt32; -- Clear RTC Counter. TASKS_CLEAR : aliased HAL.UInt32; -- Set COUNTER to 0xFFFFFFF0. TASKS_TRIGOVRFLW : aliased HAL.UInt32; -- Event on COUNTER increment. EVENTS_TICK : aliased HAL.UInt32; -- Event on COUNTER overflow. EVENTS_OVRFLW : aliased HAL.UInt32; -- Compare event on CC[n] match. EVENTS_COMPARE : aliased EVENTS_COMPARE_Registers; -- Interrupt enable set register. INTENSET : aliased INTENSET_Register; -- Interrupt enable clear register. INTENCLR : aliased INTENCLR_Register; -- Configures event enable routing to PPI for each RTC event. EVTEN : aliased EVTEN_Register; -- Enable events routing to PPI. The reading of this register gives the -- value of EVTEN. EVTENSET : aliased EVTENSET_Register; -- Disable events routing to PPI. The reading of this register gives the -- value of EVTEN. EVTENCLR : aliased EVTENCLR_Register; -- Current COUNTER value. COUNTER : aliased COUNTER_Register; -- 12-bit prescaler for COUNTER frequency (32768/(PRESCALER+1)). Must be -- written when RTC is STOPed. PRESCALER : aliased PRESCALER_Register; -- Capture/compare registers. CC : aliased CC_Registers; -- Peripheral power control. POWER : aliased POWER_Register; end record with Volatile; for RTC_Peripheral use record TASKS_START at 16#0# range 0 .. 31; TASKS_STOP at 16#4# range 0 .. 31; TASKS_CLEAR at 16#8# range 0 .. 31; TASKS_TRIGOVRFLW at 16#C# range 0 .. 31; EVENTS_TICK at 16#100# range 0 .. 31; EVENTS_OVRFLW at 16#104# range 0 .. 31; EVENTS_COMPARE at 16#140# range 0 .. 127; INTENSET at 16#304# range 0 .. 31; INTENCLR at 16#308# range 0 .. 31; EVTEN at 16#340# range 0 .. 31; EVTENSET at 16#344# range 0 .. 31; EVTENCLR at 16#348# range 0 .. 31; COUNTER at 16#504# range 0 .. 31; PRESCALER at 16#508# range 0 .. 31; CC at 16#540# range 0 .. 127; POWER at 16#FFC# range 0 .. 31; end record; -- Real time counter 0. RTC0_Periph : aliased RTC_Peripheral with Import, Address => RTC0_Base; -- Real time counter 1. RTC1_Periph : aliased RTC_Peripheral with Import, Address => RTC1_Base; end NRF_SVD.RTC;
onedigitallife-net/Byron
Ada
2,216
ads
Pragma Ada_2012; Pragma Assertion_Policy( Check ); With Unchecked_Conversion; Generic Type Token_ID is (<>); Package Lexington.Parameters is --with Pure is Pragma Pure( Lexington.Parameters ); Pragma SPARK_Mode( On ); ------------- -- TOKEN -- ------------- Type Token is new Lexington.Token; Function "+" ( Item : Lexington.Token ) return Token; Function "+" ( Item : Token ) return Lexington.Token; Function Make_Token ( ID : Token_ID; Value : Wide_Wide_String ) return Token; Function ID ( Item : Token ) return Token_ID; Function Print ( Item : Token ) return Wide_Wide_String; Private Pragma Assert( Token_ID'Size = Natural'Size, "Token_ID MUST be the same width as Natural." ); Package L renames Ada.Characters.Wide_Wide_Latin_1; Function Convert is new Unchecked_Conversion( Token_ID, Natural ); Function Convert is new Unchecked_Conversion( Natural, Token_ID ); Function Make_Token( ID : Token_ID; Value : Wide_Wide_String ) return Token is ( Make_Token(Convert(ID), Value) ); Function ID( Item : Token ) return Token_ID is ( Convert( Item.ID ) ); --Token_ID'Val(Lexington.ID( Lexington.Token(Item))) ); Space : Wide_Wide_character renames Ada.Strings.Wide_Wide_Space; Open_Paren : Wide_Wide_Character renames L.Left_Parenthesis; Close_Paren : Wide_Wide_character renames L.Right_Parenthesis; Open_Bracket : Wide_Wide_character renames L.Left_Square_Bracket; Close_Bracket : Wide_Wide_character renames L.Right_Square_Bracket; CRLF : Constant Wide_Wide_String := L.CR & L.LF; TAB : Constant Wide_Wide_String := (1 => L.HT); Function Print( Item : Token ) return Wide_Wide_String is ( Open_Paren & Natural'Wide_Wide_Image( Item.ID ) & Space & Close_Paren & TAB & Token_ID' Wide_Wide_Image(ID(Item)) & CRLF & Tab & Open_Bracket & Lexeme(Item) & Close_Bracket ); Function "+" ( Item : Lexington.Token ) return Token is ( Token(Item) ); Function "+" ( Item : Token ) return Lexington.Token is ( Lexington.Token(Item) ); End Lexington.Parameters;
zhmu/ananas
Ada
199
adb
-- { dg-do compile } -- { dg-options "-gnatwa" } with Text_IO; use Text_IO; package body Warn29 is procedure P (X : T; Y : Integer) is begin Put_Line ("hello"); end P; end Warn29;
reznikmm/matreshka
Ada
3,784
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.Table_Data_Cell_Range_Address_Attributes is pragma Preelaborate; type ODF_Table_Data_Cell_Range_Address_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Table_Data_Cell_Range_Address_Attribute_Access is access all ODF_Table_Data_Cell_Range_Address_Attribute'Class with Storage_Size => 0; end ODF.DOM.Table_Data_Cell_Range_Address_Attributes;
reznikmm/matreshka
Ada
3,749
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.Number_Automatic_Order_Attributes is pragma Preelaborate; type ODF_Number_Automatic_Order_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Number_Automatic_Order_Attribute_Access is access all ODF_Number_Automatic_Order_Attribute'Class with Storage_Size => 0; end ODF.DOM.Number_Automatic_Order_Attributes;
msrLi/portingSources
Ada
791
ads
-- Copyright (C) 2011-2014 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. package Pck is function Ident (I : Integer) return Integer; end Pck;
stcarrez/ada-ado
Ada
30,176
ads
----------------------------------------------------------------------- -- ADO Mysql -- Mysql Interface -- Copyright (C) 2009, 2010 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 Interfaces.C; use Interfaces.C; with System; with Interfaces.C.Strings; package Mysql.Com is pragma Preelaborate; pragma Warnings (Off); pragma Style_Checks ("N"); subtype my_socket is int; -- /usr/include/mysql/mysql.h:66:13 NAME_LEN : constant := 64; -- /usr/include/mysql/mysql_com.h:23 HOSTNAME_LENGTH : constant := 60; -- /usr/include/mysql/mysql_com.h:24 USERNAME_LENGTH : constant := 16; -- /usr/include/mysql/mysql_com.h:25 SERVER_VERSION_LENGTH : constant := 60; -- /usr/include/mysql/mysql_com.h:26 SQLSTATE_LENGTH : constant := 5; -- /usr/include/mysql/mysql_com.h:27 -- unsupported macro: USER_HOST_BUFF_SIZE HOSTNAME_LENGTH + USERNAME_LENGTH + 2 LOCAL_HOST : aliased constant String := "localhost" & ASCII.NUL; -- /usr/include/mysql/mysql_com.h:37 LOCAL_HOST_NAMEDPIPE : aliased constant String := "." & ASCII.NUL; -- /usr/include/mysql/mysql_com.h:38 SCRAMBLE_LENGTH : constant := 20; -- /usr/include/mysql/mysql_com.h:71 SCRAMBLE_LENGTH_323 : constant := 8; -- /usr/include/mysql/mysql_com.h:72 -- unsupported macro: SCRAMBLED_PASSWORD_CHAR_LENGTH (SCRAMBLE_LENGTH*2+1) -- unsupported macro: SCRAMBLED_PASSWORD_CHAR_LENGTH_323 (SCRAMBLE_LENGTH_323*2) NOT_NULL_FLAG : constant := 1; -- /usr/include/mysql/mysql_com.h:78 PRI_KEY_FLAG : constant := 2; -- /usr/include/mysql/mysql_com.h:79 UNIQUE_KEY_FLAG : constant := 4; -- /usr/include/mysql/mysql_com.h:80 MULTIPLE_KEY_FLAG : constant := 8; -- /usr/include/mysql/mysql_com.h:81 BLOB_FLAG : constant := 16; -- /usr/include/mysql/mysql_com.h:82 UNSIGNED_FLAG : constant := 32; -- /usr/include/mysql/mysql_com.h:83 ZEROFILL_FLAG : constant := 64; -- /usr/include/mysql/mysql_com.h:84 BINARY_FLAG : constant := 128; -- /usr/include/mysql/mysql_com.h:85 ENUM_FLAG : constant := 256; -- /usr/include/mysql/mysql_com.h:88 AUTO_INCREMENT_FLAG : constant := 512; -- /usr/include/mysql/mysql_com.h:89 TIMESTAMP_FLAG : constant := 1024; -- /usr/include/mysql/mysql_com.h:90 SET_FLAG : constant := 2048; -- /usr/include/mysql/mysql_com.h:91 NO_DEFAULT_VALUE_FLAG : constant := 4096; -- /usr/include/mysql/mysql_com.h:92 NUM_FLAG : constant := 32768; -- /usr/include/mysql/mysql_com.h:93 PART_KEY_FLAG : constant := 16384; -- /usr/include/mysql/mysql_com.h:94 GROUP_FLAG : constant := 32768; -- /usr/include/mysql/mysql_com.h:95 UNIQUE_FLAG : constant := 65536; -- /usr/include/mysql/mysql_com.h:96 BINCMP_FLAG : constant := 131072; -- /usr/include/mysql/mysql_com.h:97 REFRESH_GRANT : constant := 1; -- /usr/include/mysql/mysql_com.h:99 REFRESH_LOG : constant := 2; -- /usr/include/mysql/mysql_com.h:100 REFRESH_TABLES : constant := 4; -- /usr/include/mysql/mysql_com.h:101 REFRESH_HOSTS : constant := 8; -- /usr/include/mysql/mysql_com.h:102 REFRESH_STATUS : constant := 16; -- /usr/include/mysql/mysql_com.h:103 REFRESH_THREADS : constant := 32; -- /usr/include/mysql/mysql_com.h:104 REFRESH_SLAVE : constant := 64; -- /usr/include/mysql/mysql_com.h:105 REFRESH_MASTER : constant := 128; -- /usr/include/mysql/mysql_com.h:107 REFRESH_READ_LOCK : constant := 16384; -- /usr/include/mysql/mysql_com.h:111 REFRESH_FAST : constant := 32768; -- /usr/include/mysql/mysql_com.h:112 REFRESH_QUERY_CACHE : constant := 65536; -- /usr/include/mysql/mysql_com.h:115 REFRESH_QUERY_CACHE_FREE : constant := 16#20000#; -- /usr/include/mysql/mysql_com.h:116 REFRESH_DES_KEY_FILE : constant := 16#40000#; -- /usr/include/mysql/mysql_com.h:117 REFRESH_USER_RESOURCES : constant := 16#80000#; -- /usr/include/mysql/mysql_com.h:118 CLIENT_LONG_PASSWORD : constant := 1; -- /usr/include/mysql/mysql_com.h:120 CLIENT_FOUND_ROWS : constant := 2; -- /usr/include/mysql/mysql_com.h:121 CLIENT_LONG_FLAG : constant := 4; -- /usr/include/mysql/mysql_com.h:122 CLIENT_CONNECT_WITH_DB : constant := 8; -- /usr/include/mysql/mysql_com.h:123 CLIENT_NO_SCHEMA : constant := 16; -- /usr/include/mysql/mysql_com.h:124 CLIENT_COMPRESS : constant := 32; -- /usr/include/mysql/mysql_com.h:125 CLIENT_ODBC : constant := 64; -- /usr/include/mysql/mysql_com.h:126 CLIENT_LOCAL_FILES : constant := 128; -- /usr/include/mysql/mysql_com.h:127 CLIENT_IGNORE_SPACE : constant := 256; -- /usr/include/mysql/mysql_com.h:128 CLIENT_PROTOCOL_41 : constant := 512; -- /usr/include/mysql/mysql_com.h:129 CLIENT_INTERACTIVE : constant := 1024; -- /usr/include/mysql/mysql_com.h:130 CLIENT_SSL : constant := 2048; -- /usr/include/mysql/mysql_com.h:131 CLIENT_IGNORE_SIGPIPE : constant := 4096; -- /usr/include/mysql/mysql_com.h:132 CLIENT_TRANSACTIONS : constant := 8192; -- /usr/include/mysql/mysql_com.h:133 CLIENT_RESERVED : constant := 16384; -- /usr/include/mysql/mysql_com.h:134 CLIENT_SECURE_CONNECTION : constant := 32768; -- /usr/include/mysql/mysql_com.h:135 CLIENT_MULTI_STATEMENTS : constant := (1 ** 16); -- /usr/include/mysql/mysql_com.h:136 CLIENT_MULTI_RESULTS : constant := (1 ** 17); -- /usr/include/mysql/mysql_com.h:137 CLIENT_SSL_VERIFY_SERVER_CERT : constant := (1 ** 30); -- /usr/include/mysql/mysql_com.h:139 CLIENT_REMEMBER_OPTIONS : constant := (1 ** 31); -- /usr/include/mysql/mysql_com.h:140 SERVER_STATUS_IN_TRANS : constant := 1; -- /usr/include/mysql/mysql_com.h:142 SERVER_STATUS_AUTOCOMMIT : constant := 2; -- /usr/include/mysql/mysql_com.h:143 SERVER_MORE_RESULTS_EXISTS : constant := 8; -- /usr/include/mysql/mysql_com.h:144 SERVER_QUERY_NO_GOOD_INDEX_USED : constant := 16; -- /usr/include/mysql/mysql_com.h:145 SERVER_QUERY_NO_INDEX_USED : constant := 32; -- /usr/include/mysql/mysql_com.h:146 SERVER_STATUS_CURSOR_EXISTS : constant := 64; -- /usr/include/mysql/mysql_com.h:152 SERVER_STATUS_LAST_ROW_SENT : constant := 128; -- /usr/include/mysql/mysql_com.h:157 SERVER_STATUS_DB_DROPPED : constant := 256; -- /usr/include/mysql/mysql_com.h:158 SERVER_STATUS_NO_BACKSLASH_ESCAPES : constant := 512; -- /usr/include/mysql/mysql_com.h:159 MYSQL_ERRMSG_SIZE : constant := 512; -- /usr/include/mysql/mysql_com.h:161 NET_READ_TIMEOUT : constant := 30; -- /usr/include/mysql/mysql_com.h:162 NET_WRITE_TIMEOUT : constant := 60; -- /usr/include/mysql/mysql_com.h:163 -- unsupported macro: NET_WAIT_TIMEOUT 8*60*60 ONLY_KILL_QUERY : constant := 1; -- /usr/include/mysql/mysql_com.h:166 MAX_TINYINT_WIDTH : constant := 3; -- /usr/include/mysql/mysql_com.h:171 MAX_SMALLINT_WIDTH : constant := 5; -- /usr/include/mysql/mysql_com.h:172 MAX_MEDIUMINT_WIDTH : constant := 8; -- /usr/include/mysql/mysql_com.h:173 MAX_INT_WIDTH : constant := 10; -- /usr/include/mysql/mysql_com.h:174 MAX_BIGINT_WIDTH : constant := 20; -- /usr/include/mysql/mysql_com.h:175 MAX_CHAR_WIDTH : constant := 255; -- /usr/include/mysql/mysql_com.h:176 MAX_BLOB_WIDTH : constant := 8192; -- /usr/include/mysql/mysql_com.h:177 -- unsupported macro: packet_error (~(unsigned long) 0) -- unsupported macro: CLIENT_MULTI_QUERIES CLIENT_MULTI_STATEMENTS -- unsupported macro: FIELD_TYPE_DECIMAL MYSQL_TYPE_DECIMAL -- unsupported macro: FIELD_TYPE_NEWDECIMAL MYSQL_TYPE_NEWDECIMAL -- unsupported macro: FIELD_TYPE_TINY MYSQL_TYPE_TINY -- unsupported macro: FIELD_TYPE_SHORT MYSQL_TYPE_SHORT -- unsupported macro: FIELD_TYPE_LONG MYSQL_TYPE_LONG -- unsupported macro: FIELD_TYPE_FLOAT MYSQL_TYPE_FLOAT -- unsupported macro: FIELD_TYPE_DOUBLE MYSQL_TYPE_DOUBLE -- unsupported macro: FIELD_TYPE_NULL MYSQL_TYPE_NULL -- unsupported macro: FIELD_TYPE_TIMESTAMP MYSQL_TYPE_TIMESTAMP -- unsupported macro: FIELD_TYPE_LONGLONG MYSQL_TYPE_LONGLONG -- unsupported macro: FIELD_TYPE_INT24 MYSQL_TYPE_INT24 -- unsupported macro: FIELD_TYPE_DATE MYSQL_TYPE_DATE -- unsupported macro: FIELD_TYPE_TIME MYSQL_TYPE_TIME -- unsupported macro: FIELD_TYPE_DATETIME MYSQL_TYPE_DATETIME -- unsupported macro: FIELD_TYPE_YEAR MYSQL_TYPE_YEAR -- unsupported macro: FIELD_TYPE_NEWDATE MYSQL_TYPE_NEWDATE -- unsupported macro: FIELD_TYPE_ENUM MYSQL_TYPE_ENUM -- unsupported macro: FIELD_TYPE_SET MYSQL_TYPE_SET -- unsupported macro: FIELD_TYPE_TINY_BLOB MYSQL_TYPE_TINY_BLOB -- unsupported macro: FIELD_TYPE_MEDIUM_BLOB MYSQL_TYPE_MEDIUM_BLOB -- unsupported macro: FIELD_TYPE_LONG_BLOB MYSQL_TYPE_LONG_BLOB -- unsupported macro: FIELD_TYPE_BLOB MYSQL_TYPE_BLOB -- unsupported macro: FIELD_TYPE_VAR_STRING MYSQL_TYPE_VAR_STRING -- unsupported macro: FIELD_TYPE_STRING MYSQL_TYPE_STRING -- unsupported macro: FIELD_TYPE_CHAR MYSQL_TYPE_TINY -- unsupported macro: FIELD_TYPE_INTERVAL MYSQL_TYPE_ENUM -- unsupported macro: FIELD_TYPE_GEOMETRY MYSQL_TYPE_GEOMETRY -- unsupported macro: FIELD_TYPE_BIT MYSQL_TYPE_BIT -- unsupported macro: MYSQL_SHUTDOWN_KILLABLE_CONNECT (unsigned char)(1 << 0) -- unsupported macro: MYSQL_SHUTDOWN_KILLABLE_TRANS (unsigned char)(1 << 1) -- unsupported macro: MYSQL_SHUTDOWN_KILLABLE_LOCK_TABLE (unsigned char)(1 << 2) -- unsupported macro: MYSQL_SHUTDOWN_KILLABLE_UPDATE (unsigned char)(1 << 3) -- arg-macro: function net_new_transaction (net) -- return (net).pkt_nr:=0; NET_HEADER_SIZE : constant := 4; -- /usr/include/mysql/mysql_com.h:402 COMP_HEADER_SIZE : constant := 3; -- /usr/include/mysql/mysql_com.h:403 -- unsupported macro: NULL_LENGTH ((unsigned long) ~0) MYSQL_STMT_HEADER : constant := 4; -- /usr/include/mysql/mysql_com.h:464 MYSQL_LONG_DATA_HEADER : constant := 6; -- /usr/include/mysql/mysql_com.h:465 -- Copyright (C) 2000 MySQL AB -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; version 2 of the License. -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA --** Common definition between mysql server & client -- -- USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain -- username and hostname parts of the user identifier with trailing zero in -- MySQL standard format: -- user_name_part@host_name_part\0 -- -- You should add new commands to the end of this list, otherwise old -- servers won't be able to handle them as 'unsupported'. -- subtype enum_server_command is unsigned; COM_SLEEP : constant enum_server_command := 0; COM_QUIT : constant enum_server_command := 1; COM_INIT_DB : constant enum_server_command := 2; COM_QUERY : constant enum_server_command := 3; COM_FIELD_LIST : constant enum_server_command := 4; COM_CREATE_DB : constant enum_server_command := 5; COM_DROP_DB : constant enum_server_command := 6; COM_REFRESH : constant enum_server_command := 7; COM_SHUTDOWN : constant enum_server_command := 8; COM_STATISTICS : constant enum_server_command := 9; COM_PROCESS_INFO : constant enum_server_command := 10; COM_CONNECT : constant enum_server_command := 11; COM_PROCESS_KILL : constant enum_server_command := 12; COM_DEBUG : constant enum_server_command := 13; COM_PING : constant enum_server_command := 14; COM_TIME : constant enum_server_command := 15; COM_DELAYED_INSERT : constant enum_server_command := 16; COM_CHANGE_USER : constant enum_server_command := 17; COM_BINLOG_DUMP : constant enum_server_command := 18; COM_TABLE_DUMP : constant enum_server_command := 19; COM_CONNECT_OUT : constant enum_server_command := 20; COM_REGISTER_SLAVE : constant enum_server_command := 21; COM_STMT_PREPARE : constant enum_server_command := 22; COM_STMT_EXECUTE : constant enum_server_command := 23; COM_STMT_SEND_LONG_DATA : constant enum_server_command := 24; COM_STMT_CLOSE : constant enum_server_command := 25; COM_STMT_RESET : constant enum_server_command := 26; COM_SET_OPTION : constant enum_server_command := 27; COM_STMT_FETCH : constant enum_server_command := 28; COM_END : constant enum_server_command := 29; -- /usr/include/mysql/mysql_com.h:52:1 -- don't forget to update const char *command_name[] in sql_parse.cc -- Must be last -- Length of random string sent by server on handshake; this is also length of -- obfuscated password, recieved from client -- -- length of password stored in the db: new passwords are preceeded with '*' -- The following are only sent to new clients -- The following can't be set with mysql_refresh() -- RESET (remove all queries) from query cache -- The server was able to fulfill the clients request and opened a -- read-only non-scrollable cursor for a query. This flag comes -- in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands. -- -- This flag is sent when a read-only cursor is exhausted, in reply to -- COM_STMT_FETCH command. -- -- Only C -- skipped empty struct st_vio -- skipped empty struct Vio type anon1416_anon1442_array is array (0 .. 511) of aliased char; type anon1416_anon1443_array is array (0 .. 5) of aliased char; type st_net is record the_vio : System.Address; -- /usr/include/mysql/mysql_com.h:181:8 buff : access unsigned_char; -- /usr/include/mysql/mysql_com.h:182:18 buff_end : access unsigned_char; -- /usr/include/mysql/mysql_com.h:182:24 write_pos : access unsigned_char; -- /usr/include/mysql/mysql_com.h:182:34 read_pos : access unsigned_char; -- /usr/include/mysql/mysql_com.h:182:45 fd : aliased my_socket; -- /usr/include/mysql/mysql_com.h:183:13 max_packet : aliased unsigned_long; -- /usr/include/mysql/mysql_com.h:184:17 max_packet_size : aliased unsigned_long; -- /usr/include/mysql/mysql_com.h:184:28 pkt_nr : aliased unsigned; -- /usr/include/mysql/mysql_com.h:185:16 compress_pkt_nr : aliased unsigned; -- /usr/include/mysql/mysql_com.h:185:23 write_timeout : aliased unsigned; -- /usr/include/mysql/mysql_com.h:186:16 read_timeout : aliased unsigned; -- /usr/include/mysql/mysql_com.h:186:31 retry_count : aliased unsigned; -- /usr/include/mysql/mysql_com.h:186:45 fcntl : aliased int; -- /usr/include/mysql/mysql_com.h:187:7 compress : aliased char; -- /usr/include/mysql/mysql_com.h:188:11 remain_in_buf : aliased unsigned_long; -- /usr/include/mysql/mysql_com.h:194:17 length : aliased unsigned_long; -- /usr/include/mysql/mysql_com.h:194:31 buf_length : aliased unsigned_long; -- /usr/include/mysql/mysql_com.h:194:39 where_b : aliased unsigned_long; -- /usr/include/mysql/mysql_com.h:194:51 return_status : access unsigned; -- /usr/include/mysql/mysql_com.h:195:17 reading_or_writing : aliased unsigned_char; -- /usr/include/mysql/mysql_com.h:196:17 save_char : aliased char; -- /usr/include/mysql/mysql_com.h:197:8 no_send_ok : aliased char; -- /usr/include/mysql/mysql_com.h:198:11 no_send_eof : aliased char; -- /usr/include/mysql/mysql_com.h:199:11 no_send_error : aliased char; -- /usr/include/mysql/mysql_com.h:204:11 last_error : aliased anon1416_anon1442_array; -- /usr/include/mysql/mysql_com.h:210:8 sqlstate : aliased anon1416_anon1443_array; -- /usr/include/mysql/mysql_com.h:210:39 last_errno : aliased unsigned; -- /usr/include/mysql/mysql_com.h:211:16 error : aliased unsigned_char; -- /usr/include/mysql/mysql_com.h:212:17 query_cache_query : Interfaces.C.Strings.chars_ptr; -- mysql_mysql_h.gptr; -- /usr/include/mysql/mysql_com.h:218:8 report_error : aliased char; -- /usr/include/mysql/mysql_com.h:220:11 return_errno : aliased char; -- /usr/include/mysql/mysql_com.h:221:11 end record; pragma Convention (C, st_net); -- /usr/include/mysql/mysql_com.h:179:16 -- For Perl DBI/dbd -- The following variable is set if we are doing several queries in one -- command ( as in LOAD TABLE ... FROM MASTER ), -- and do not want to confuse the client with OK at the wrong time -- -- For SPs and other things that do multiple stmts -- For SPs' first version read-only cursors -- Set if OK packet is already sent, and we do not need to send error -- messages -- -- Pointer to query object in query cache, do not equal NULL (0) for -- queries in cache that have not stored its results yet -- -- 'query_cache_query' should be accessed only via query cache -- functions and methods to maintain proper locking. -- -- We should report error (we have unreported error) subtype NET is st_net; subtype enum_field_types is unsigned; MYSQL_TYPE_DECIMAL : constant enum_field_types := 0; MYSQL_TYPE_TINY : constant enum_field_types := 1; MYSQL_TYPE_SHORT : constant enum_field_types := 2; MYSQL_TYPE_LONG : constant enum_field_types := 3; MYSQL_TYPE_FLOAT : constant enum_field_types := 4; MYSQL_TYPE_DOUBLE : constant enum_field_types := 5; MYSQL_TYPE_NULL : constant enum_field_types := 6; MYSQL_TYPE_TIMESTAMP : constant enum_field_types := 7; MYSQL_TYPE_LONGLONG : constant enum_field_types := 8; MYSQL_TYPE_INT24 : constant enum_field_types := 9; MYSQL_TYPE_DATE : constant enum_field_types := 10; MYSQL_TYPE_TIME : constant enum_field_types := 11; MYSQL_TYPE_DATETIME : constant enum_field_types := 12; MYSQL_TYPE_YEAR : constant enum_field_types := 13; MYSQL_TYPE_NEWDATE : constant enum_field_types := 14; MYSQL_TYPE_VARCHAR : constant enum_field_types := 15; MYSQL_TYPE_BIT : constant enum_field_types := 16; MYSQL_TYPE_NEWDECIMAL : constant enum_field_types := 246; MYSQL_TYPE_ENUM : constant enum_field_types := 247; MYSQL_TYPE_SET : constant enum_field_types := 248; MYSQL_TYPE_TINY_BLOB : constant enum_field_types := 249; MYSQL_TYPE_MEDIUM_BLOB : constant enum_field_types := 250; MYSQL_TYPE_LONG_BLOB : constant enum_field_types := 251; MYSQL_TYPE_BLOB : constant enum_field_types := 252; MYSQL_TYPE_VAR_STRING : constant enum_field_types := 253; MYSQL_TYPE_STRING : constant enum_field_types := 254; MYSQL_TYPE_GEOMETRY : constant enum_field_types := 255; -- /usr/include/mysql/mysql_com.h:226:6 -- For backward compatibility -- Shutdown/kill enums and constants -- Bits for THD::killable. subtype mysql_enum_shutdown_level is unsigned; SHUTDOWN_DEFAULT : constant mysql_enum_shutdown_level := 0; SHUTDOWN_WAIT_CONNECTIONS : constant mysql_enum_shutdown_level := 1; SHUTDOWN_WAIT_TRANSACTIONS : constant mysql_enum_shutdown_level := 2; SHUTDOWN_WAIT_UPDATES : constant mysql_enum_shutdown_level := 8; SHUTDOWN_WAIT_ALL_BUFFERS : constant mysql_enum_shutdown_level := 16; SHUTDOWN_WAIT_CRITICAL_BUFFERS : constant mysql_enum_shutdown_level := 17; KILL_QUERY : constant mysql_enum_shutdown_level := 254; KILL_CONNECTION : constant mysql_enum_shutdown_level := 255; -- /usr/include/mysql/mysql_com.h:288:6 -- We want levels to be in growing order of hardness (because we use number -- comparisons). Note that DEFAULT does not respect the growing property, but -- it's ok. -- -- wait for existing connections to finish -- wait for existing trans to finish -- wait for existing updates to finish (=> no partial MyISAM update) -- flush InnoDB buffers and other storage engines' buffers -- don't flush InnoDB buffers, flush other storage engines' buffers -- Now the 2 levels of the KILL command subtype enum_cursor_type is unsigned; CURSOR_TYPE_NO_CURSOR : constant enum_cursor_type := 0; CURSOR_TYPE_READ_ONLY : constant enum_cursor_type := 1; CURSOR_TYPE_FOR_UPDATE : constant enum_cursor_type := 2; CURSOR_TYPE_SCROLLABLE : constant enum_cursor_type := 4; -- /usr/include/mysql/mysql_com.h:314:1 -- options for mysql_set_option subtype enum_mysql_set_option is unsigned; MYSQL_OPTION_MULTI_STATEMENTS_ON : constant enum_mysql_set_option := 0; MYSQL_OPTION_MULTI_STATEMENTS_OFF : constant enum_mysql_set_option := 1; -- /usr/include/mysql/mysql_com.h:324:1 function my_net_init (arg1 : access st_net; arg2 : System.Address) return char; -- /usr/include/mysql/mysql_com.h:335:9 pragma Import (C, my_net_init, "my_net_init"); procedure my_net_local_init (arg1 : access st_net); -- /usr/include/mysql/mysql_com.h:336:6 pragma Import (C, my_net_local_init, "my_net_local_init"); procedure net_end (arg1 : access st_net); -- /usr/include/mysql/mysql_com.h:337:6 pragma Import (C, net_end, "net_end"); procedure net_clear (arg1 : access st_net); -- /usr/include/mysql/mysql_com.h:338:6 pragma Import (C, net_clear, "net_clear"); function net_realloc (arg1 : access st_net; arg2 : unsigned_long) return char; -- /usr/include/mysql/mysql_com.h:339:9 pragma Import (C, net_realloc, "net_realloc"); function net_flush (arg1 : access st_net) return char; -- /usr/include/mysql/mysql_com.h:340:9 pragma Import (C, net_flush, "net_flush"); function my_net_write (arg1 : access st_net; arg2 : Interfaces.C.Strings.chars_ptr; arg3 : unsigned_long) return char; -- /usr/include/mysql/mysql_com.h:341:9 pragma Import (C, my_net_write, "my_net_write"); function net_write_command (arg1 : access st_net; arg2 : unsigned_char; arg3 : Interfaces.C.Strings.chars_ptr; arg4 : unsigned_long; arg5 : Interfaces.C.Strings.chars_ptr; arg6 : unsigned_long) return char; -- /usr/include/mysql/mysql_com.h:342:9 pragma Import (C, net_write_command, "net_write_command"); function net_real_write (arg1 : access st_net; arg2 : Interfaces.C.Strings.chars_ptr; arg3 : unsigned_long) return int; -- /usr/include/mysql/mysql_com.h:345:5 pragma Import (C, net_real_write, "net_real_write"); function my_net_read (arg1 : access st_net) return unsigned_long; -- /usr/include/mysql/mysql_com.h:346:15 pragma Import (C, my_net_read, "my_net_read"); -- The following function is not meant for normal usage -- Currently it's used internally by manager.c -- -- skipped empty struct sockaddr function my_connect (arg1 : my_socket; arg2 : System.Address; arg3 : unsigned; arg4 : unsigned) return int; -- /usr/include/mysql/mysql_com.h:358:5 pragma Import (C, my_connect, "my_connect"); type rand_struct is record seed1 : aliased unsigned_long; seed2 : aliased unsigned_long; max_value : aliased unsigned_long; max_value_dbl : aliased double; end record; pragma Convention (C, rand_struct); -- The following is for user defined functions subtype Item_result is unsigned; STRING_RESULT : constant Item_result := 0; REAL_RESULT : constant Item_result := 1; INT_RESULT : constant Item_result := 2; ROW_RESULT : constant Item_result := 3; DECIMAL_RESULT : constant Item_result := 4; -- Number of arguments type st_udf_args is record arg_count : aliased unsigned; arg_type : access Item_result; args : System.Address; lengths : access unsigned_long; maybe_null : Interfaces.C.Strings.chars_ptr; attributes : System.Address; attribute_lengths : access unsigned_long; end record; pragma Convention (C, st_udf_args); -- Pointer to item_results -- Pointer to argument -- Length of string arguments -- Set to 1 for all maybe_null args -- Pointer to attribute name -- Length of attribute arguments subtype UDF_ARGS is st_udf_args; -- This holds information about the result -- 1 if function can return NULL type st_udf_init is record maybe_null : aliased char; decimals : aliased unsigned; max_length : aliased unsigned_long; ptr : Interfaces.C.Strings.chars_ptr; const_item : aliased char; end record; pragma Convention (C, st_udf_init); -- for real functions -- For string functions -- free pointer for function data -- 1 if function always returns the same value subtype UDF_INIT is st_udf_init; -- -- TODO: add a notion for determinism of the UDF. -- See Item_udf_func::update_used_tables () -- -- Constants when using compression -- Prototypes to password functions -- These functions are used for authentication by client and server and -- implemented in sql/password.c -- procedure randominit (arg1 : access rand_struct; arg2 : unsigned_long; arg3 : unsigned_long); pragma Import (C, randominit, "randominit"); function my_rnd (arg1 : access rand_struct) return double; pragma Import (C, my_rnd, "my_rnd"); procedure create_random_string (arg1 : Interfaces.C.Strings.chars_ptr; arg2 : unsigned; arg3 : access rand_struct); pragma Import (C, create_random_string, "create_random_string"); procedure hash_password (arg1 : access unsigned_long; arg2 : Interfaces.C.Strings.chars_ptr; arg3 : unsigned); pragma Import (C, hash_password, "hash_password"); procedure Make_Scrambled_Password_323 (Arg1 : Interfaces.C.Strings.chars_ptr; arg2 : Interfaces.C.Strings.chars_ptr); pragma Import (C, make_scrambled_password_323, "make_scrambled_password_323"); procedure scramble_323 (arg1 : Interfaces.C.Strings.chars_ptr; arg2 : Interfaces.C.Strings.chars_ptr; arg3 : Interfaces.C.Strings.chars_ptr); pragma Import (C, scramble_323, "scramble_323"); function check_scramble_323 (arg1 : Interfaces.C.Strings.chars_ptr; arg2 : Interfaces.C.Strings.chars_ptr; arg3 : access unsigned_long) return char; pragma Import (C, check_scramble_323, "check_scramble_323"); procedure Get_Salt_From_Password_323 (Arg1 : access Unsigned_Long; arg2 : Interfaces.C.Strings.chars_ptr); pragma Import (C, get_salt_from_password_323, "get_salt_from_password_323"); procedure Make_Password_From_Salt_323 (Arg1 : Interfaces.C.Strings.chars_ptr; arg2 : access unsigned_long); pragma Import (C, make_password_from_salt_323, "make_password_from_salt_323"); procedure Make_Scrambled_Password (Arg1 : Interfaces.C.Strings.chars_ptr; arg2 : Interfaces.C.Strings.chars_ptr); pragma Import (C, make_scrambled_password, "make_scrambled_password"); procedure scramble (arg1 : Interfaces.C.Strings.chars_ptr; arg2 : Interfaces.C.Strings.chars_ptr; arg3 : Interfaces.C.Strings.chars_ptr); pragma Import (C, scramble, "scramble"); function check_scramble (arg1 : Interfaces.C.Strings.chars_ptr; arg2 : Interfaces.C.Strings.chars_ptr; arg3 : access unsigned_char) return char; pragma Import (C, check_scramble, "check_scramble"); procedure Get_Salt_From_Password (Arg1 : access Unsigned_Char; arg2 : Interfaces.C.Strings.chars_ptr); pragma Import (C, get_salt_from_password, "get_salt_from_password"); procedure Make_Password_From_Salt (Arg1 : Interfaces.C.Strings.chars_ptr; arg2 : access unsigned_char); pragma Import (C, make_password_from_salt, "make_password_from_salt"); function octet2hex (arg1 : Interfaces.C.Strings.chars_ptr; arg2 : Interfaces.C.Strings.chars_ptr; arg3 : unsigned) return Interfaces.C.Strings.chars_ptr; pragma Import (C, octet2hex, "octet2hex"); -- end of password.c function Get_Tty_Password (Arg1 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr; pragma Import (C, get_tty_password, "get_tty_password"); function mysql_errno_to_sqlstate (arg1 : unsigned) return Interfaces.C.Strings.chars_ptr; pragma Import (C, mysql_errno_to_sqlstate, "mysql_errno_to_sqlstate"); -- Some other useful functions function my_init return char; pragma Import (C, my_init, "my_init"); function modify_defaults_file (arg1 : Interfaces.C.Strings.chars_ptr; arg2 : Interfaces.C.Strings.chars_ptr; arg3 : Interfaces.C.Strings.chars_ptr; arg4 : Interfaces.C.Strings.chars_ptr; arg5 : int) return int; pragma Import (C, modify_defaults_file, "modify_defaults_file"); function load_defaults (arg1 : Interfaces.C.Strings.chars_ptr; arg2 : System.Address; arg3 : access int; arg4 : System.Address) return int; pragma Import (C, load_defaults, "load_defaults"); function my_thread_init return char; pragma Import (C, my_thread_init, "my_thread_init"); procedure my_thread_end; pragma Import (C, my_thread_end, "my_thread_end"); end Mysql.Com ;
Heziode/lsystem-editor
Ada
8,231
adb
------------------------------------------------------------------------------- -- LSE -- L-System Editor -- Author: Heziode -- -- License: -- MIT License -- -- Copyright (c) 2018 Quentin Dauprat (Heziode) <[email protected]> -- -- 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.Characters.Latin_1; with Ada.Float_Text_IO; with Ada.Strings; with LSE.Model.Grammar.Symbol; package body LSE.Model.L_System.L_System is package L renames Ada.Characters.Latin_1; package Symbol_List renames LSE.Model.Grammar.Symbol_Utils.P_List; procedure Initialize (This : out Instance; Axiom : LSE.Model.Grammar.Symbol_Utils.P_List.List; Angle : LSE.Utils.Angle.Angle; Rules : LSE.Model.L_System.Growth_Rule_Utils.P_List.List; Turtle : LSE.Model.IO.Turtle_Utils.Holder) is begin This := Instance '(State => 0, Current_State => 0, Axiom => Axiom, Angle => Angle, Rules => Rules, Current_Value => Axiom, Turtle => Turtle); end Initialize; function Get_State (This : Instance) return Natural is begin return This.State; end Get_State; procedure Set_State (This : out Instance; Value : Natural) is begin This.State := Value; end Set_State; function Get_LSystem (This : Instance) return String is use Ada.Strings; use Ada.Float_Text_IO; use LSE.Model.Grammar.Symbol; ------------------------ -- Methods prototype -- ------------------------ function Get_Rules (This : LSE.Model.L_System.Growth_Rule_Utils.P_List.List) return Unbounded_String; ----------------------------- -- Declaration of methods -- ----------------------------- function Get_Rules (This : LSE.Model.L_System.Growth_Rule_Utils.P_List.List) return Unbounded_String is Result : Unbounded_String := To_Unbounded_String (""); begin for Rule of This loop Result := Result & L.LF & To_Unbounded_String (Get_Representation (Rule.Get_Head) & "") & L.Space & Get_Symbol_List (Rule.Get_Body); end loop; return Result; end Get_Rules; --------------- -- Variables -- --------------- Angle_Str : String (1 .. LSE.Utils.Angle.Angle'Digits); begin Put (To => Angle_Str, Item => Float (This.Angle), Aft => 2, Exp => 0); return To_String (Trim (To_Unbounded_String (Angle_Str), Both) & L.LF & Get_Symbol_List (This.Axiom) & Get_Rules (This.Rules)); end Get_LSystem; function Get_Value (This : Instance) return String is begin return To_String (Get_Symbol_List (This.Current_Value)); end Get_Value; function Get_Value (This : Instance) return LSE.Model.Grammar.Symbol_Utils.P_List.List is begin return This.Current_Value; end Get_Value; function Get_Turtle (This : Instance) return LSE.Model.IO.Turtle_Utils.Holder is begin return This.Turtle; end Get_Turtle; procedure Set_Turtle (This : out Instance; Value : LSE.Model.IO.Turtle_Utils.Holder) is begin This.Turtle := Value; end Set_Turtle; procedure Develop (This : out Instance) is use LSE.Model.Grammar.Symbol; Position : Symbol_List.Cursor := Symbol_List.No_Element; Found : Boolean := False; Tmp_Index : Symbol_List.Cursor; Rule_Item : LSE.Model.Grammar.Symbol_Utils.Ptr.Holder; Item : LSE.Model.Grammar.Symbol_Utils.Ptr.Holder; begin if This.Current_State = This.State then if This.Turtle.Element.Get_Max_X = 0.0 and This.Turtle.Element.Get_Min_X = 0.0 then -- Get L-System dimensions This.Compute_Dimension; end if; return; elsif This.Current_State > This.State then This.Current_State := 0; This.Current_Value := This.Axiom; end if; while This.Current_State < This.State loop This.Current_State := This.Current_State + 1; Position := This.Current_Value.First; while Symbol_List.Has_Element (Position) loop Item := Symbol_List.Element (Position); for Rule of This.Rules loop Rule_Item := Rule.Get_Head; if Item.Element.Get_Representation = Rule_Item.Element.Get_Representation then for S of Rule.Get_Body loop Symbol_List.Insert (This.Current_Value, Position, S); end loop; Found := True; end if; end loop; Symbol_List.Next (Position); if Found then if Symbol_List.Has_Element (Position) then Tmp_Index := Symbol_List.Previous (Position); else Tmp_Index := Symbol_List.Last (This.Current_Value); end if; Symbol_List.Delete (This.Current_Value, Tmp_Index); Found := False; end if; end loop; end loop; -- Get L-System dimensions This.Compute_Dimension; end Develop; function Get_Symbol_List (This : LSE.Model.Grammar.Symbol_Utils.P_List.List) return Unbounded_String is Result : Unbounded_String := To_Unbounded_String (""); begin for S of This loop Result := Result & To_Unbounded_String (LSE.Model.Grammar.Symbol.Get_Representation ( LSE.Model.Grammar.Symbol_Utils .Ptr.Element (S)) & ""); end loop; return Result; end Get_Symbol_List; procedure Interpret (This : in out Instance; T : in out Holder) is begin if This.Get_LSystem'Length = 0 then return; end if; T.Reference.Set_Angle (This.Angle); T.Reference.Set_Max_X (This.Turtle.Element.Get_Max_X); T.Reference.Set_Max_Y (This.Turtle.Element.Get_Max_Y); T.Reference.Set_Min_X (This.Turtle.Element.Get_Min_X); T.Reference.Set_Min_Y (This.Turtle.Element.Get_Min_Y); T.Reference.Configure; for Item of This.Current_Value loop Item.Reference.Interpret (T); end loop; T.Reference.Draw; end Interpret; procedure Compute_Dimension (This : in out Instance) is begin This.Turtle.Reference.Set_Dry_Run (True); This.Interpret (This.Turtle); This.Turtle.Reference.Set_Dry_Run (False); end Compute_Dimension; end LSE.Model.L_System.L_System;
charlie5/aIDE
Ada
1,646
adb
with AdaM.Factory; package body AdaM.Compilation is -- Storage Pool -- record_Version : constant := 1; pool_Size : constant := 5_000; package Pool is new AdaM.Factory.Pools (".adam-store", "compilations", pool_Size, record_Version, Compilation.item, Compilation.view); -- Forge -- procedure define (Self : in out Item) is begin null; end define; procedure destruct (Self : in out Item) is begin null; end destruct; function new_Subprogram return View is new_View : constant Compilation.view := Pool.new_Item; begin define (Compilation.item (new_View.all)); return new_View; end new_Subprogram; procedure free (Self : in out Compilation.view) is begin destruct (Compilation.item (Self.all)); Pool.free (Self); end free; -- Attributes -- overriding function Id (Self : access Item) return AdaM.Id is begin return Pool.to_Id (Self); end Id; -- Streams -- procedure View_write (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : in View) renames Pool.View_write; procedure View_read (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : out View) renames Pool.View_read; end AdaM.Compilation;
sungyeon/drake
Ada
313
ads
pragma License (Unrestricted); -- implementation unit required by compiler with System.Exponentiations; package System.Exp_Int is pragma Pure; -- required for "**" with checking by compiler (s-expint.ads) function Exp_Integer is new Exponentiations.Generic_Exp_Integer (Integer); end System.Exp_Int;
onox/orka
Ada
2,437
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2012 Felix Krause <[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.Finalization; with GL.Types.Debug; package GL.Objects is pragma Preelaborate; use GL.Types; type GL_Object is abstract new Ada.Finalization.Controlled with private; overriding procedure Initialize (Object : in out GL_Object); -- Create the object in OpenGL memory. overriding procedure Adjust (Object : in out GL_Object); -- Increase reference count. overriding procedure Finalize (Object : in out GL_Object); -- Decrease reference count. Deletes the GL object when it reaches zero. procedure Initialize_Id (Object : in out GL_Object) is abstract; -- Create an OpenGL ID for this object. This has to be done before -- the object is used in any way. After calling this procedure, -- Initialized will be true. procedure Delete_Id (Object : in out GL_Object) is abstract; -- Delete the ID of an object. After calling this procedure, -- Initialized will be false. function Raw_Id (Object : GL_Object) return UInt with Inline; -- This getter is provided for low-level access. Its primary use is to -- interact with other C interfaces (e.g. OpenCL) function Identifier (Object : GL_Object) return Types.Debug.Identifier is abstract; -- Return the namespace identifier of the object. Used to annotate -- the object in GL.Debug. overriding function "=" (Left, Right : GL_Object) return Boolean; private type GL_Object_Reference is record GL_Id : UInt; Reference_Count : Natural; end record; type GL_Object_Reference_Access is access all GL_Object_Reference; type GL_Object is abstract new Ada.Finalization.Controlled with record Reference : GL_Object_Reference_Access; end record; use type UInt; end GL.Objects;
google-code/ada-util
Ada
11,242
adb
----------------------------------------------------------------------- -- util-processes -- Process creation and control -- Copyright (C) 2011 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.Unchecked_Deallocation; with Util.Log.Loggers; with Util.Strings; with Util.Processes.Os; package body Util.Processes is use Util.Log; use Ada.Strings.Unbounded; -- The logger Log : constant Loggers.Logger := Loggers.Create ("Util.Processes"); procedure Free is new Ada.Unchecked_Deallocation (Object => Util.Processes.System_Process'Class, Name => Util.Processes.System_Process_Access); -- ------------------------------ -- Before launching the process, redirect the input stream of the process -- to the specified file. -- ------------------------------ procedure Set_Input_Stream (Proc : in out Process; File : in String) is begin if Proc.Is_Running then Log.Error ("Cannot set input stream to {0} while process is running", File); raise Invalid_State with "Process is running"; end if; Proc.In_File := To_Unbounded_String (File); end Set_Input_Stream; -- ------------------------------ -- Set the output stream of the process. -- ------------------------------ procedure Set_Output_Stream (Proc : in out Process; File : in String; Append : in Boolean := False) is begin if Proc.Is_Running then Log.Error ("Cannot set output stream to {0} while process is running", File); raise Invalid_State with "Process is running"; end if; Proc.Out_File := To_Unbounded_String (File); Proc.Out_Append := Append; end Set_Output_Stream; -- ------------------------------ -- Set the error stream of the process. -- ------------------------------ procedure Set_Error_Stream (Proc : in out Process; File : in String; Append : in Boolean := False) is begin if Proc.Is_Running then Log.Error ("Cannot set error stream to {0} while process is running", File); raise Invalid_State with "Process is running"; end if; Proc.Err_File := To_Unbounded_String (File); Proc.Err_Append := Append; end Set_Error_Stream; -- ------------------------------ -- Set the working directory that the process will use once it is created. -- The directory must exist or the <b>Invalid_Directory</b> exception will be raised. -- ------------------------------ procedure Set_Working_Directory (Proc : in out Process; Path : in String) is begin if Proc.Is_Running then Log.Error ("Cannot set working directory to {0} while process is running", Path); raise Invalid_State with "Process is running"; end if; Proc.Dir := To_Unbounded_String (Path); end Set_Working_Directory; -- ------------------------------ -- Append the argument to the current process argument list. -- Raises <b>Invalid_State</b> if the process is running. -- ------------------------------ procedure Append_Argument (Proc : in out Process; Arg : in String) is begin if Proc.Is_Running then Log.Error ("Cannot add argument '{0}' while process is running", Arg); raise Invalid_State with "Process is running"; end if; Proc.Sys.Append_Argument (Arg); end Append_Argument; -- ------------------------------ -- Spawn a new process with the given command and its arguments. The standard input, output -- and error streams are either redirected to a file or to a stream object. -- ------------------------------ procedure Spawn (Proc : in out Process; Command : in String; Arguments : in Argument_List) is begin if Is_Running (Proc) then raise Invalid_State with "A process is running"; end if; Log.Info ("Starting process {0}", Command); if Proc.Sys /= null then Proc.Sys.Finalize; Free (Proc.Sys); end if; Proc.Sys := new Util.Processes.Os.System_Process; -- Build the argc/argv table, terminate by NULL for I in Arguments'Range loop Proc.Sys.Append_Argument (Arguments (I).all); end loop; -- Prepare to redirect the input/output/error streams. Proc.Sys.Set_Streams (Input => To_String (Proc.In_File), Output => To_String (Proc.Out_File), Error => To_String (Proc.Err_File), Append_Output => Proc.Out_Append, Append_Error => Proc.Err_Append); -- System specific spawn Proc.Exit_Value := -1; Proc.Sys.Spawn (Proc); end Spawn; -- ------------------------------ -- Spawn a new process with the given command and its arguments. The standard input, output -- and error streams are either redirected to a file or to a stream object. -- ------------------------------ procedure Spawn (Proc : in out Process; Command : in String; Mode : in Pipe_Mode := NONE) is Pos : Natural := Command'First; N : Natural; begin if Is_Running (Proc) then raise Invalid_State with "A process is running"; end if; Log.Info ("Starting process {0}", Command); if Proc.Sys /= null then Proc.Sys.Finalize; Free (Proc.Sys); end if; Proc.Sys := new Util.Processes.Os.System_Process; -- Build the argc/argv table while Pos <= Command'Last loop N := Util.Strings.Index (Command, ' ', Pos); if N = 0 then N := Command'Last + 1; end if; Proc.Sys.Append_Argument (Command (Pos .. N - 1)); Pos := N + 1; end loop; -- Prepare to redirect the input/output/error streams. -- The pipe mode takes precedence and will override these redirections. Proc.Sys.Set_Streams (Input => To_String (Proc.In_File), Output => To_String (Proc.Out_File), Error => To_String (Proc.Err_File), Append_Output => Proc.Out_Append, Append_Error => Proc.Err_Append); -- System specific spawn Proc.Exit_Value := -1; Proc.Sys.Spawn (Proc, Mode); end Spawn; -- ------------------------------ -- Wait for the process to terminate. -- ------------------------------ procedure Wait (Proc : in out Process) is begin if not Is_Running (Proc) then return; end if; Log.Info ("Waiting for process {0}", Process_Identifier'Image (Proc.Pid)); Proc.Sys.Wait (Proc, -1.0); end Wait; -- ------------------------------ -- Terminate the process by sending a signal on Unix and exiting the process on Windows. -- This operation is not portable and has a different behavior between Unix and Windows. -- Its intent is to stop the process. -- ------------------------------ procedure Stop (Proc : in out Process; Signal : in Positive := 15) is begin if Is_Running (Proc) then Proc.Sys.Stop (Proc, Signal); end if; end Stop; -- ------------------------------ -- Get the process exit status. -- ------------------------------ function Get_Exit_Status (Proc : in Process) return Integer is begin return Proc.Exit_Value; end Get_Exit_Status; -- ------------------------------ -- Get the process identifier. -- ------------------------------ function Get_Pid (Proc : in Process) return Process_Identifier is begin return Proc.Pid; end Get_Pid; -- ------------------------------ -- Returns True if the process is running. -- ------------------------------ function Is_Running (Proc : in Process) return Boolean is begin return Proc.Pid > 0 and Proc.Exit_Value < 0; end Is_Running; -- ------------------------------ -- Get the process input stream allowing to write on the process standard input. -- ------------------------------ function Get_Input_Stream (Proc : in Process) return Util.Streams.Output_Stream_Access is begin return Proc.Input; end Get_Input_Stream; -- ------------------------------ -- Get the process output stream allowing to read the process standard output. -- ------------------------------ function Get_Output_Stream (Proc : in Process) return Util.Streams.Input_Stream_Access is begin return Proc.Output; end Get_Output_Stream; -- ------------------------------ -- Get the process error stream allowing to read the process standard output. -- ------------------------------ function Get_Error_Stream (Proc : in Process) return Util.Streams.Input_Stream_Access is begin return Proc.Error; end Get_Error_Stream; -- ------------------------------ -- Initialize the process instance. -- ------------------------------ overriding procedure Initialize (Proc : in out Process) is begin Proc.Sys := new Util.Processes.Os.System_Process; end Initialize; -- ------------------------------ -- Deletes the process instance. -- ------------------------------ overriding procedure Finalize (Proc : in out Process) is procedure Free is new Ada.Unchecked_Deallocation (Object => Util.Streams.Input_Stream'Class, Name => Util.Streams.Input_Stream_Access); procedure Free is new Ada.Unchecked_Deallocation (Object => Util.Streams.Output_Stream'Class, Name => Util.Streams.Output_Stream_Access); begin if Proc.Sys /= null then Proc.Sys.Finalize; Free (Proc.Sys); end if; Free (Proc.Input); Free (Proc.Output); Free (Proc.Error); end Finalize; end Util.Processes;
AdaCore/gpr
Ada
182
ads
package p4_2 is function p4_2_0 (Item : Integer) return Integer; function p4_2_1 (Item : Integer) return Integer; function p4_2_2 (Item : Integer) return Integer; end p4_2;
reznikmm/matreshka
Ada
4,703
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 directed relationship represents a relationship between a collection of -- source model elements and a collection of target model elements. ------------------------------------------------------------------------------ limited with AMF.UML.Elements.Collections; with AMF.UML.Relationships; package AMF.UML.Directed_Relationships is pragma Preelaborate; type UML_Directed_Relationship is limited interface and AMF.UML.Relationships.UML_Relationship; type UML_Directed_Relationship_Access is access all UML_Directed_Relationship'Class; for UML_Directed_Relationship_Access'Storage_Size use 0; not overriding function Get_Source (Self : not null access constant UML_Directed_Relationship) return AMF.UML.Elements.Collections.Set_Of_UML_Element is abstract; -- Getter of DirectedRelationship::source. -- -- Specifies the sources of the DirectedRelationship. not overriding function Get_Target (Self : not null access constant UML_Directed_Relationship) return AMF.UML.Elements.Collections.Set_Of_UML_Element is abstract; -- Getter of DirectedRelationship::target. -- -- Specifies the targets of the DirectedRelationship. end AMF.UML.Directed_Relationships;
AdaCore/gpr
Ada
182
ads
package p0_3 is function p0_3_0 (Item : Integer) return Integer; function p0_3_1 (Item : Integer) return Integer; function p0_3_2 (Item : Integer) return Integer; end p0_3;
jrcarter/Ada_GUI
Ada
14,096
adb
-- An Ada-oriented GUI library -- Implementation derived from Gnoga -- -- Copyright (C) 2022 by PragmAda Software Engineering -- -- Released under the terms of the 3-Clause BSD License. See https://opensource.org/licenses/BSD-3-Clause with Ada.Containers.Indefinite_Ordered_Sets; with Ada.Directories; separate (Ada_GUI) package body Dialogs is procedure Set_Up (Background : out Gnoga.Gui.View.View_Type; Frame : out Gnoga.Gui.View.View_Type; View : out Gnoga.Gui.View.View_Type); -- Sets up Background, Frame, and View for a dialog -- Background should be passed to Clean_Up before the dialog returns -- View is where the dialog sets up its widgets procedure Center (Background : in out Gnoga.Gui.View.View_Type; Frame : in out Gnoga.Gui.View.View_Type); -- After adding widgets to the View from Set_Up, pass the Background and Frame to center the frame in the window procedure Clean_Up (Background : in out Gnoga.Gui.View.View_Type; Dialog_Exists : in Boolean); -- Cleans up a dialog before returning -- Background should have been set up as the Background parameter to Set_Up -- Dialog_Exists should be False if the user has closed the window; True otherwise -- Empties the event queue -- Allows other dialogs or Next_Event to proceed -- If Dialog_Exists, removes Background, else adds a window-closed event to the queue function Selected_File (Initial_Directory : in String := ".") return File_Result_Info is Directory_Tag : constant String := " (directory)"; procedure Fill_List (Directory : in String; List : in out Gnoga.Gui.Element.Form.Selection_Type); -- Clears List, then adds the files in Directory to it, directories first, in alphabetical order procedure File_Selected; -- User clicked on a file in the file list package Name_Lists is new Ada.Containers.Indefinite_Ordered_Sets (Element_Type => String); use Ada.Strings.Unbounded; procedure Fill_List (Directory : in String; List : in out Gnoga.Gui.Element.Form.Selection_Type) is procedure Add_Dir (Position : in Name_Lists.Cursor); -- Adds the Name at Position to List with Directory_Tag added to the end procedure Add_File (Position : in Name_Lists.Cursor); -- Adds the name at Position to List procedure Add_Dir (Position : in Name_Lists.Cursor) is Name : constant String := Name_Lists.Element (Position) & Directory_Tag; begin -- Add_Dir List.Add_Option (Value => Name, Text => Name); end Add_Dir; procedure Add_File (Position : in Name_Lists.Cursor) is Name : constant String := Name_Lists.Element (Position); begin -- Add_File List.Add_Option (Value => Name, Text => Name); end Add_File; Search_Info : Ada.Directories.Search_Type; File_Info : Ada.Directories.Directory_Entry_Type; Dir_List : Name_Lists.Set; File_List : Name_Lists.Set; Index : Natural; begin -- Fill_List Ada.Directories.Start_Search (Search => Search_Info, Directory => Directory, Pattern => "*", Filter => (Ada.Directories.Special_File => False, others => True) ); All_Entries : loop exit All_Entries when not Ada.Directories.More_Entries (Search_Info); Ada.Directories.Get_Next_Entry (Search => Search_Info, Directory_Entry => File_Info); case Ada.Directories.Kind (File_Info) is when Ada.Directories.Directory => Get_Name : declare Name : constant String := Ada.Directories.Simple_Name (File_Info); begin -- Get_Name if Name /= "." and Name /= ".." then Dir_List.Insert (New_Item => Name); end if; end Get_Name; when Ada.Directories.Ordinary_File => File_List.Insert (New_Item => Ada.Directories.Simple_Name (File_Info) ); when Ada.Directories.Special_File => null; end case; end loop All_Entries; Index := List.Selected_Index; List.Visible (Value => False); List.Empty_Options; Dir_List.Iterate (Process => Add_Dir'Access); File_List.Iterate (Process => Add_File'Access); if Index /= 0 then List.Selected (Index => Index); end if; List.Visible (Value => True); end Fill_List; Result : File_Result_Info; Current_Dir : Unbounded_String := To_Unbounded_String (Ada.Directories.Full_Name (Initial_Directory) ); File_List : Gnoga.Gui.Element.Form.Selection_Type; File_Input : Gnoga.Gui.Element.Form.Text_Type; procedure File_Selected is Index : constant Natural := File_List.Selected_Index; begin -- File_Selected if Index = 0 then return; end if; Get_Name : declare Name : constant String := File_List.Value (Index); begin -- Get_Name if Name'Length <= Directory_Tag'Length or else Name (Name'Last - Directory_Tag'Length + 1 .. Name'Last) /= Directory_Tag then -- Normal file File_Input.Value (Value => Name); else -- Directory Current_Dir := To_Unbounded_String (Ada.Directories.Compose (To_String (Current_Dir), Name (Name'First .. Name'Last - Directory_Tag'Length) ) ); File_Input.Value (Value => ""); end if; end Get_Name; end File_Selected; Background : Gnoga.Gui.View.View_Type; Frame : Gnoga.Gui.View.View_Type; View : Gnoga.Gui.View.View_Type; Form : Gnoga.Gui.Element.Form.Form_Type; Dir_Line : Gnoga.Gui.Element.Form.Text_Type; Up : Gnoga.Gui.Element.Common.Button_Type; Cancel : Gnoga.Gui.Element.Common.Button_Type; OK : Gnoga.Gui.Element.Common.Button_Type; Event : Gnoga.Gui.Event_Info; Exists : Boolean := False; begin -- Selected_File if Dialog_Control.Ongoing then return (Picked => False); end if; Dialog_Control.Set_Ongoing (Value => True); Set_Up (Background => Background, Frame => Frame, View => View); Exists := True; Form.Create (Parent => View); Dir_Line.Create (Form => Form, Size => 100); Dir_Line.Read_Only; Up.Create (Parent => Form, Content => "Up"); Form.New_Line; File_List.Create (Form => Form, Visible_Lines => 20); Form.New_Line; File_Input.Create (Form => Form, Size => 50); Cancel.Create (Parent => Form, Content => "Cancel"); OK.Create (Parent => Form, Content => "OK"); Center (Background => Background, Frame => Frame); All_Events : loop Dir_Line.Value (Value => To_String (Current_Dir) ); Fill_List (Directory => To_String (Current_Dir), List => File_List); Gnoga.Gui.Event_Queue.Dequeue (Element => Event); if Event.Event = Closed_Text then Result := (Picked => False); Exists := False; exit All_Events; elsif Event.Event = "click" then if Event.Object.Unique_ID = Up.Unique_ID then Current_Dir := To_Unbounded_String (Ada.Directories.Containing_Directory (To_String (Current_Dir) ) ); elsif Event.Object.Unique_ID = File_List.Unique_ID then File_Selected; elsif Event.Object.Unique_ID = Cancel.Unique_ID then Result := (Picked => False); exit All_Events; elsif Event.Object.Unique_ID = OK.Unique_ID then Get_Name : declare Name : constant String := File_Input.Value; begin -- Get_Name if Name /= "" then Result := (Picked => True, Value => To_Unbounded_String (Ada.Directories.Compose (To_String (Current_Dir), Name) ) ); exit All_Events; end if; end Get_Name; else null; end if; else null; end if; end loop All_Events; Clean_Up (Background => Background, Dialog_Exists => Exists); return Result; exception -- Selected_File when E : others => Gnoga.Log (Message => "Dialogs.Selected_File: " & Ada.Exceptions.Exception_Information (E) ); Clean_Up (Background => Background, Dialog_Exists => Exists); return (Picked => False); end Selected_File; function Selected_Button (Title : in String; Text : in String; Button : in Text_List) return String is type Button_List is array (Button'Range) of Gnoga.Gui.Element.Common.Button_Type; Background : Gnoga.Gui.View.View_Type; Frame : Gnoga.Gui.View.View_Type; View : Gnoga.Gui.View.View_Type; Title_View : Gnoga.Gui.View.View_Type; Text_View : Gnoga.Gui.View.View_Type; Button_View : Gnoga.Gui.View.View_Type; Control : Button_List; Exists : Boolean := False; Event : Gnoga.Gui.Event_Info; Result : Unbounded_String; begin -- Selected_Button if Dialog_Control.Ongoing then return ""; end if; Dialog_Control.Set_Ongoing (Value => True); Set_Up (Background => Background, Frame => Frame, View => View); Exists := True; Title_View.Create (Parent => View); Title_View.Text_Alignment (Value => Gnoga.Gui.Element.Center); Title_View.Background_Color (Enum => Gnoga.Colors.Light_Blue); Title_View.Put (Message => Title); View.New_Line; Text_View.Create (Parent => View); Text_View.Text_Alignment (Value => Gnoga.Gui.Element.Left); Text_View.Put (Message => Text); View.New_Line; Button_View.Create (Parent => View); Button_View.Text_Alignment (Value => Gnoga.Gui.Element.Right); Button_View.Background_Color (Enum => Gnoga.Colors.Light_Blue); Create_Buttons : for I in Control'Range loop Control (I).Create (Parent => Button_View, Content => To_String (Button (I) ) ); end loop Create_Buttons; Center (Background => Background, Frame => Frame); All_Events : loop Gnoga.Gui.Event_Queue.Dequeue (Element => Event); if Event.Event = Closed_Text then Result := Null_Unbounded_String; Exists := False; exit All_Events; elsif Event.Event = "click" then Find_Button : for I in Control'Range loop if Event.Object.Unique_ID = Control (I).Unique_ID then Result := Button (I); exit All_Events; end if; end loop Find_Button; else null; end if; end loop All_Events; Clean_Up (Background => Background, Dialog_Exists => Exists); return To_String (Result); exception -- Selected_Button when E : others => Gnoga.Log (Message => "Dialogs.Selected_Button: " & Ada.Exceptions.Exception_Information (E) ); Clean_Up (Background => Background, Dialog_Exists => Exists); return ""; end Selected_Button; procedure Set_Up (Background : out Gnoga.Gui.View.View_Type; Frame : out Gnoga.Gui.View.View_Type; View : out Gnoga.Gui.View.View_Type) is Old_View : constant Gnoga.Gui.Pointer_To_Base_Class := Window.Get_View; use type Gnoga.Gui.Pointer_To_Base_Class; begin -- Set_Up -- Create the Dialog Background view Background.Create (Parent => Window); -- Creating a view using Window as the parent sets the view as Window's main view. This sets it back to the original. if Old_View /= null then Window.Set_View (Object => Old_View.all); end if; -- Configure the Modal Background Background.Fill_Parent; Background.Background_Color (Value => "Grey"); Background.Opacity (Alpha => 1.0); Background.Z_Index (Value => Integer'Last); -- Create the containing view of the dialog Frame.Create (Parent => Background); Frame.Position (Value => Gnoga.Gui.Element.Fixed); View.Create (Parent => Frame); View.Background_Color (Value => "White"); exception -- Set_Up when E : others => Gnoga.Log (Message => "Dialogs.Set_Up: " & Ada.Exceptions.Exception_Information (E) ); end Set_Up; procedure Center (Background : in out Gnoga.Gui.View.View_Type; Frame : in out Gnoga.Gui.View.View_Type) is Top_Offset : Integer := Integer'Max (Background.Height / 2 - Frame.Height / 2, 0); Left_Offset : Integer := Integer'Max (Background.Width / 2 - Frame.Width / 2, 0); begin -- Center Frame.Top (Value => Background.Offset_From_Top + Top_Offset); Frame.Left (Value => Background.Offset_From_Left + Left_Offset); exception -- Center when E : others => Gnoga.Log (Message => "Dialogs.Center: " & Ada.Exceptions.Exception_Information (E) ); end Center; procedure Clean_Up (Background : in out Gnoga.Gui.View.View_Type; Dialog_Exists : in Boolean) is Event : Gnoga.Gui.Event_Info; use type Ada.Containers.Count_Type; begin -- Clean_Up Empty : loop exit Empty when Gnoga.Gui.Event_Queue.Current_Use = 0; Gnoga.Gui.Event_Queue.Dequeue (Element => Event); end loop Empty; Dialog_Control.Set_Ongoing (Value => False); if Dialog_Exists then Background.Remove; else Gnoga.Gui.Event_Queue.Enqueue (New_Item => (Event => To_Unbounded_String (Closed_Text), others => <>) ); end if; exception -- Clean_Up when E : others => Gnoga.Log (Message => "Dialogs.Clean_Up: " & Ada.Exceptions.Exception_Information (E) ); end Clean_Up; end Dialogs;
charlie5/cBound
Ada
1,773
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_expose_event_t is -- Item -- type Item is record response_type : aliased Interfaces.Unsigned_8; pad0 : aliased Interfaces.Unsigned_8; sequence : aliased Interfaces.Unsigned_16; window : aliased xcb.xcb_window_t; x : aliased Interfaces.Unsigned_16; y : aliased Interfaces.Unsigned_16; width : aliased Interfaces.Unsigned_16; height : aliased Interfaces.Unsigned_16; count : aliased Interfaces.Unsigned_16; pad1 : aliased swig.int8_t_Array (0 .. 1); end record; -- Item_Array -- type Item_Array is array (Interfaces.C.size_t range <>) of aliased xcb.xcb_expose_event_t.Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_expose_event_t.Item, Element_Array => xcb.xcb_expose_event_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_expose_event_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_expose_event_t.Pointer, Element_Array => xcb.xcb_expose_event_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_expose_event_t;
wookey-project/ewok-legacy
Ada
1,428
ads
-- -- Copyright 2018 The wookey project team <[email protected]> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- 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 ewok.tasks_shared; package ewok.syscalls.cfg.dev with spark_mode => off is procedure dev_map (caller_id : in ewok.tasks_shared.t_task_id; params : in out t_parameters; mode : in ewok.tasks_shared.t_task_mode); procedure dev_unmap (caller_id : in ewok.tasks_shared.t_task_id; params : in out t_parameters; mode : in ewok.tasks_shared.t_task_mode); procedure dev_release (caller_id : in ewok.tasks_shared.t_task_id; params : in out t_parameters; mode : in ewok.tasks_shared.t_task_mode); end ewok.syscalls.cfg.dev;
MinimSecure/unum-sdk
Ada
836
adb
-- Copyright 2018-2019 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. package body Pack is procedure Do_Nothing (A : System.Address) is begin null; end Do_Nothing; end Pack;
zhmu/ananas
Ada
2,790
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- G N A T . S O C K E T S . L I N K E R _ O P T I O N S -- -- -- -- S p e c -- -- -- -- Copyright (C) 2001-2022, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package is used to provide target specific linker_options for the -- support of sockets as required by the package GNAT.Sockets. -- This is the Solaris version of this package -- This package should not be directly with'ed by an application program package GNAT.Sockets.Linker_Options is private pragma Linker_Options ("-lnsl"); pragma Linker_Options ("-lsocket"); end GNAT.Sockets.Linker_Options;
Rodeo-McCabe/orka
Ada
982
ads
-- 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 GL.Types; package Orka.SIMD.AVX.Doubles is pragma Pure; type m256d is array (Index_Homogeneous) of GL.Types.Double with Alignment => 32; pragma Machine_Attribute (m256d, "vector_type"); type m256d_Array is array (Index_Homogeneous) of m256d with Alignment => 32; end Orka.SIMD.AVX.Doubles;
rveenker/sdlada
Ada
5,386
ads
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2013-2020, 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. -------------------------------------------------------------------------------------------------------------------- -- SDL -- -- Ada 2012 bindings to the SDL 2.x.y library. -------------------------------------------------------------------------------------------------------------------- with Interfaces.C; package SDL is package C renames Interfaces.C; use type C.int; type Init_Flags is mod 2 ** 32 with Convention => C; Null_Init_Flags : constant Init_Flags := 16#0000_0000#; Enable_Timer : constant Init_Flags := 16#0000_0001#; Enable_Audio : constant Init_Flags := 16#0000_0010#; Enable_Screen : constant Init_Flags := 16#0000_0020#; Enable_Joystick : constant Init_Flags := 16#0000_0200#; Enable_Haptic : constant Init_Flags := 16#0000_1000#; Enable_Game_Controller : constant Init_Flags := 16#0000_2000#; Enable_Events : constant Init_Flags := 16#0000_4000#; Enable_No_Parachute : constant Init_Flags := 16#0010_0000#; Enable_Everything : constant Init_Flags := Enable_Timer or Enable_Audio or Enable_Screen or Enable_Joystick or Enable_Haptic or Enable_Game_Controller or Enable_Events or Enable_No_Parachute; -- Coordinates are for positioning things. subtype Coordinate is C.int; subtype Natural_Coordinate is Coordinate range 0 .. Coordinate'Last; subtype Positive_Coordinate is Coordinate range 1 .. Coordinate'Last; Centre_Coordinate : constant Coordinate := 0; type Coordinates is record X : SDL.Coordinate; Y : SDL.Coordinate; end record with Convention => C; Zero_Coordinate : constant Coordinates := (others => 0); subtype Natural_Coordinates is Coordinates with Dynamic_Predicate => Natural_Coordinates.X >= Natural_Coordinate'First and Natural_Coordinates.Y >= Natural_Coordinate'First; subtype Positive_Coordinates is Coordinates with Dynamic_Predicate => Positive_Coordinates.X >= Positive_Coordinate'First and Positive_Coordinates.Y >= Positive_Coordinate'First; -- Dimensions are for sizing things. subtype Dimension is C.int; subtype Natural_Dimension is Dimension range 0 .. Dimension'Last; subtype Positive_Dimension is Dimension range 1 .. Dimension'Last; type Sizes is record Width : Dimension; Height : Dimension; end record with Convention => C; Zero_Size : constant Sizes := (others => Natural_Dimension'First); subtype Natural_Sizes is Sizes with Dynamic_Predicate => Natural_Sizes.Width >= 0 and Natural_Sizes.Height >= 0; subtype Positive_Sizes is Sizes with Dynamic_Predicate => Positive_Sizes.Width >= 1 and Positive_Sizes.Height >= 1; function "*" (Left : in Sizes; Scale : in Positive_Dimension) return Sizes is (Sizes'(Width => Left.Width * Scale, Height => Left.Height * Scale)); function "/" (Left : in Sizes; Scale : in Positive_Dimension) return Sizes is (Sizes'(Width => Left.Width / Scale, Height => Left.Height / Scale)); function Initialise (Flags : in Init_Flags := Enable_Everything) return Boolean; procedure Finalise with Import => True, Convention => C, External_Name => "SDL_Quit"; function Initialise_Sub_System (Flags : in Init_Flags) return Boolean; procedure Finalise_Sub_System (Flags : in Init_Flags) with Import => True, Convention => C, External_Name => "SDL_QuitSubSystem"; -- Get which sub-systems were initialised. function Was_Initialised return Init_Flags; -- Check whether a set of sub-systems were initialised. function Was_Initialised (Flags : in Init_Flags) return Boolean; private Success : constant Interfaces.C.int := 0; type SDL_Bool is (SDL_False, SDL_True) with Convention => C; -- The next value is used in mapping the Ada types onto the C types, it is the word size used for all data -- in SDL, i.e. all data is 4 byte aligned so it works with 32-bit architectures. Word : constant := 4; -- These constants are internal to the events system. SDL_Query : constant C.int := -1; SDL_Ignore : constant C.int := 0; SDL_Disable : constant C.int := 0; SDL_Enable : constant C.int := 1; end SDL;
reznikmm/matreshka
Ada
8,470
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-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$ ------------------------------------------------------------------------------ package body Matreshka.SIMD.ARM.NEON is function builtin_neon_vaddv8qi (A : int8x8_t; B : int8x8_t; C : Interfaces.Integer_32) return int8x8_t; pragma Import (Intrinsic, builtin_neon_vaddv8qi, "__builtin_neon_vaddv8qi"); function builtin_neon_vaddv4hi (A : int16x4_t; B : int16x4_t; C : Interfaces.Integer_32) return int16x4_t; pragma Import (Intrinsic, builtin_neon_vaddv4hi, "__builtin_neon_vaddv4hi"); function builtin_neon_vaddv2si (A : int32x2_t; B : int32x2_t; C : Interfaces.Integer_32) return int32x2_t; pragma Import (Intrinsic, builtin_neon_vaddv2si, "__builtin_neon_vaddv2si"); function builtin_neon_vadddi (A : int64x1_t; B : int64x1_t; C : Interfaces.Integer_32) return int64x1_t; pragma Import (Intrinsic, builtin_neon_vadddi, "__builtin_neon_vadddi"); function builtin_neon_vaddv2sf (A : float32x2_t; B : float32x2_t; C : Interfaces.Integer_32) return float32x2_t; pragma Import (Intrinsic, builtin_neon_vaddv2sf, "__builtin_neon_vaddv2sf"); function builtin_neon_vaddv16qi (A : int8x16_t; B : int8x16_t; C : Interfaces.Integer_32) return int8x16_t; pragma Import (Intrinsic, builtin_neon_vaddv16qi, "__builtin_neon_vaddv16qi"); function builtin_neon_vaddv8hi (A : int16x8_t; B : int16x8_t; C : Interfaces.Integer_32) return int16x8_t; pragma Import (Intrinsic, builtin_neon_vaddv8hi, "__builtin_neon_vaddv8hi"); function builtin_neon_vaddv4si (A : int32x4_t; B : int32x4_t; C : Interfaces.Integer_32) return int32x4_t; pragma Import (Intrinsic, builtin_neon_vaddv4si, "__builtin_neon_vaddv4si"); function builtin_neon_vaddv2di (A : int64x2_t; B : int64x2_t; C : Interfaces.Integer_32) return int64x2_t; pragma Import (Intrinsic, builtin_neon_vaddv2di, "__builtin_neon_vaddv2di"); function builtin_neon_vaddv4sf (A : float32x4_t; B : float32x4_t; C : Interfaces.Integer_32) return float32x4_t; pragma Import (Intrinsic, builtin_neon_vaddv4sf, "__builtin_neon_vaddv4sf"); -------------- -- vadd_f32 -- -------------- function vadd_f32 (A : float32x2_t; B : float32x2_t) return float32x2_t is begin return builtin_neon_vaddv2sf (A, B, 3); end vadd_f32; -------------- -- vadd_s16 -- -------------- function vadd_s16 (A : int16x4_t; B : int16x4_t) return int16x4_t is begin return builtin_neon_vaddv4hi (A, B, 1); end vadd_s16; -------------- -- vadd_s32 -- -------------- function vadd_s32 (A : int32x2_t; B : int32x2_t) return int32x2_t is begin return builtin_neon_vaddv2si (A, B, 1); end vadd_s32; -------------- -- vadd_s64 -- -------------- -- function vadd_s64 (A : int64x1_t; B : int64x1_t) return int64x1_t is -- begin -- return builtin_neon_vadddi (A, B, 1); -- end vadd_s64; ------------- -- vadd_s8 -- ------------- function vadd_s8 (A : int8x8_t; B : int8x8_t) return int8x8_t is begin return builtin_neon_vaddv8qi (A, B, 1); end vadd_s8; -------------- -- vadd_u16 -- -------------- function vadd_u16 (A : uint16x4_t; B : uint16x4_t) return uint16x4_t is begin return To_uint16x4_t (builtin_neon_vaddv4hi (To_int16x4_t (A), To_int16x4_t (B), 0)); end vadd_u16; -------------- -- vadd_u32 -- -------------- function vadd_u32 (A : uint32x2_t; B : uint32x2_t) return uint32x2_t is begin return To_uint32x2_t (builtin_neon_vaddv2si (To_int32x2_t (A), To_int32x2_t (B), 0)); end vadd_u32; -------------- -- vadd_u64 -- -------------- function vadd_u64 (A : uint64x1_t; B : uint64x1_t) return uint64x1_t is begin return To_uint64x1_t (builtin_neon_vadddi (To_int64x1_t (A), To_int64x1_t (B), 0)); end vadd_u64; ------------- -- vadd_u8 -- ------------- function vadd_u8 (A : uint8x8_t; B : uint8x8_t) return uint8x8_t is begin return To_uint8x8_t (builtin_neon_vaddv8qi (To_int8x8_t (A), To_int8x8_t (B), 0)); end vadd_u8; --------------- -- vaddq_f32 -- --------------- function vaddq_f32 (A : float32x4_t; B : float32x4_t) return float32x4_t is begin return builtin_neon_vaddv4sf (A, B, 3); end vaddq_f32; --------------- -- vaddq_s16 -- --------------- function vaddq_s16 (A : int16x8_t; B : int16x8_t) return int16x8_t is begin return builtin_neon_vaddv8hi (A, B, 1); end vaddq_s16; --------------- -- vaddq_s32 -- --------------- function vaddq_s32 (A : int32x4_t; B : int32x4_t) return int32x4_t is begin return builtin_neon_vaddv4si (A, B, 1); end vaddq_s32; --------------- -- vaddq_s64 -- --------------- function vaddq_s64 (A : int64x2_t; B : int64x2_t) return int64x2_t is begin return builtin_neon_vaddv2di (A, B, 1); end vaddq_s64; -------------- -- vaddq_s8 -- -------------- function vaddq_s8 (A : int8x16_t; B : int8x16_t) return int8x16_t is begin return builtin_neon_vaddv16qi (A, B, 1); end vaddq_s8; end Matreshka.SIMD.ARM.NEON;
apple-oss-distributions/old_ncurses
Ada
3,008
ads
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- ncurses -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 2000 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: Eugene V. Melaragno <[email protected]> 2000 -- Version Control -- $Revision: 1.1.1.1 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ procedure ncurses2.acs_display;
reznikmm/matreshka
Ada
4,043
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.Style_Rotation_Align_Attributes; package Matreshka.ODF_Style.Rotation_Align_Attributes is type Style_Rotation_Align_Attribute_Node is new Matreshka.ODF_Style.Abstract_Style_Attribute_Node and ODF.DOM.Style_Rotation_Align_Attributes.ODF_Style_Rotation_Align_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Rotation_Align_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Style_Rotation_Align_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Style.Rotation_Align_Attributes;
AaronC98/PlaneSystem
Ada
9,415
ads
------------------------------------------------------------------------------ -- Ada Web Server -- -- -- -- Copyright (C) 2004-2017, 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/>. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ------------------------------------------------------------------------------ pragma Ada_2012; with Ada.Strings.Unbounded; with AWS.Headers; with AWS.MIME; with AWS.Net; private with Ada.Containers.Vectors; package AWS.Attachments is use Ada.Strings.Unbounded; type Element is private; type List is tagged private; Empty_List : constant List; type Content is private; type Encoding is (None, Base64); function File (Filename : String; Encode : Encoding := None; Content_Id : String := ""; Content_Type : String := MIME.Text_Plain) return Content; -- A filename as content, if Encode is set to Base64 the file content will -- be base64 encoded. function Value (Data : Unbounded_String; Name : String := ""; Encode : Encoding := None; Content_Id : String := ""; Content_Type : String := MIME.Text_Plain) return Content; -- An unbounded string as content function Value (Data : String; Name : String := ""; Encode : Encoding := None; Content_Id : String := ""; Content_Type : String := MIME.Text_Plain) return Content is (Value (To_Unbounded_String (Data), Name, Encode, Content_Id, Content_Type)); -- A string as content type Attachment_Kind is (Data, Alternative); -- Data : for a standard MIME attachment -- Alternative : for a set of alternative content procedure Add (Attachments : in out List; Filename : String; Content_Id : String; Headers : AWS.Headers.List := AWS.Headers.Empty_List; Name : String := ""; Encode : Encoding := None) with Post => Count (Attachments) = Count (Attachments'Old) + 1; -- Adds an Attachment to the list. -- Note that the encoding will overwrite the corresponding entry in -- headers. procedure Add (Attachments : in out List; Filename : String; Headers : AWS.Headers.List; Name : String := ""; Encode : Encoding := None) with Post => Count (Attachments) = Count (Attachments'Old) + 1; -- Adds an Attachment to the list. -- Note that the encoding will overwrite the corresponding entry in -- headers. procedure Add (Attachments : in out List; Name : String; Data : Content; Headers : AWS.Headers.List := AWS.Headers.Empty_List) with Post => Count (Attachments) = Count (Attachments'Old) + 1; -- Adds an Attachment to the list. -- Note that the encoding and content type attached to Data will -- overwrite the corresponding entry in headers. -- Alternatives content type Alternatives is private; procedure Add (Parts : in out Alternatives; Data : Content); -- Add an alternative content procedure Add (Attachments : in out List; Parts : Alternatives); -- Add an alternative group to the current attachment list procedure Reset (Attachments : in out List; Delete_Files : Boolean) with Post => Count (Attachments) = 0; -- Reset the list to be empty. If Delete_Files is set to true the -- attached files are removed from the file system. function Count (Attachments : List) return Natural with Inline; -- Returns the number of Attachments in the data function Get (Attachments : List; Index : Positive) return Element with Pre => Index <= Count (Attachments); -- Returns specified Attachment function Get (Attachments : List; Content_Id : String) return Element with Pre => (for some K in 1 .. Count (Attachments) => AWS.Attachments.Content_Id (Get (Attachments, K)) = Content_Id); -- Returns the Attachment with the Content Id generic with procedure Action (Attachment : Element; Index : Positive; Quit : in out Boolean); procedure For_Every_Attachment (Attachments : List); -- Calls action for every Attachment in Message. Stop iterator if Quit is -- set to True, Quit is set to False by default. procedure Iterate (Attachments : List; Process : not null access procedure (Attachment : Element)); -- Calls Process for every Attachment in Message function Headers (Attachment : Element) return AWS.Headers.List with Inline; -- Returns the list of header lines for the attachment function Content_Type (Attachment : Element) return String; -- Get value for "Content-Type:" header function Content_Id (Attachment : Element) return String; -- Returns Attachment's content id function Local_Filename (Attachment : Element) return String; -- Returns the local filename of the Attachment. -- Local filename is the name the receiver used when extracting the -- Attachment into a file. function Filename (Attachment : Element) return String; -- Original filename on the server side. This is generally encoded on the -- content-type or content-disposition header. function Kind (Attachment : Element) return Attachment_Kind with Inline; -- Returns the kind of the given attachment function Length (Attachments : List; Boundary : String) return Positive with Post => Length'Result > 8; -- Returns the complete size of all attachments including the surrounding -- boundaries. procedure Send_MIME_Header (Socket : Net.Socket_Type'Class; Attachments : List; Boundary : out Unbounded_String; Alternative : Boolean := False); -- Output MIME header, returns the boundary for the content procedure Send (Socket : AWS.Net.Socket_Type'Class; Attachments : List; Boundary : String); -- Send all Attachments, including the surrounding boundarys, in the list -- to the socket. type Root_MIME_Kind is (Multipart_Mixed, Multipart_Alternative); function Root_MIME (Attachments : List) return Root_MIME_Kind; -- Returns the root MIME kind for the given attachment list private use Ada; type Content_Kind is (File, Data); type Content (Kind : Content_Kind := File) is record Length : Natural; Content_Id : Unbounded_String; Content_Type : Unbounded_String; Filename : Unbounded_String; Encode : Encoding; case Kind is when File => null; when Data => Content : Unbounded_String; end case; end record; package Alternative_Table is new Containers.Vectors (Positive, Content); type Element (Kind : Attachment_Kind := Data) is record Headers : AWS.Headers.List; Total_Length : Natural; case Kind is when Data => Data : Content; when Alternative => Parts : Alternative_Table.Vector; end case; end record; type Alternatives is new Element (Kind => Alternative); package Attachment_Table is new Ada.Containers.Vectors (Positive, Element); type List is tagged record Vector : Attachment_Table.Vector; end record; Empty_List : constant List := (Vector => Attachment_Table.Empty_Vector); end AWS.Attachments;
faelys/ada-syslog
Ada
1,537
ads
------------------------------------------------------------------------------ -- Copyright (c) 2014, Natacha Porté -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Syslog.Guess.App_Name procedure sets App_Name internal value using -- -- Ada.Command_Line package. -- ------------------------------------------------------------------------------ procedure Syslog.Guess.App_Name;
ptrebuc/ewok-kernel
Ada
3,285
ads
-- -- Copyright 2018 The wookey project team <[email protected]> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- 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 ewok.tasks_shared; use ewok.tasks_shared; with ewok.devices_shared; use ewok.devices_shared; with ewok.exported.devices; with ewok.exported.interrupts; with m4.mpu; with soc.interrupts; with soc.devmap; package ewok.devices with spark_mode => off is type t_device_type is (DEV_TYPE_USER, DEV_TYPE_KERNEL); type t_device_state is -- FIXME (DEV_STATE_UNUSED, DEV_STATE_RESERVED, DEV_STATE_REGISTERED, DEV_STATE_ENABLED); type t_checked_user_device is new ewok.exported.devices.t_user_device; type t_checked_user_device_access is access all t_checked_user_device; type t_device is record udev : aliased t_checked_user_device; task_id : t_task_id; periph_id : soc.devmap.t_periph_id; status : t_device_state; end record; registered_device : array (t_device_id range ID_DEV1 .. ID_DEV18) of t_device; procedure init; procedure get_registered_device_entry (dev_id : out t_device_id; success : out boolean); procedure release_registered_device_entry (dev_id : t_device_id); function get_task_from_id(dev_id : t_device_id) return t_task_id; function get_user_device (dev_id : t_device_id) return t_checked_user_device_access; function get_user_device_size (dev_id : t_device_id) return unsigned_32; function get_user_device_addr (dev_id : t_device_id) return system_address; function is_user_device_region_ro (dev_id : t_device_id) return boolean; function get_user_device_subregions_mask (dev_id : t_device_id) return unsigned_8; function get_interrupt_config_from_interrupt (interrupt : soc.interrupts.t_interrupt) return ewok.exported.interrupts.t_interrupt_config_access; procedure register_device (task_id : in t_task_id; udev : in ewok.exported.devices.t_user_device_access; dev_id : out t_device_id; success : out boolean); procedure release_device (task_id : in t_task_id; dev_id : in t_device_id; success : out boolean); procedure enable_device (dev_id : in t_device_id; success : out boolean); function sanitize_user_defined_device (udev : in ewok.exported.devices.t_user_device_access; task_id : in t_task_id) return boolean; procedure mpu_mapping_device (dev_id : in t_device_id; region : in m4.mpu.t_region_number; success : out boolean); end ewok.devices;
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.Elements; package ODF.DOM.Db_Component_Collection_Elements is pragma Preelaborate; type ODF_Db_Component_Collection is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Db_Component_Collection_Access is access all ODF_Db_Component_Collection'Class with Storage_Size => 0; end ODF.DOM.Db_Component_Collection_Elements;
Gabriel-Degret/adalib
Ada
711
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 --------------------------------------------------------------------------- with Ada.Streams; package Ada.Wide_Wide_Text_IO.Text_Streams is type Stream_Access is access all Streams.Root_Stream_Type'Class; function Stream (File : in File_Type) return Stream_Access; end Ada.Wide_Wide_Text_IO.Text_Streams;
sungyeon/drake
Ada
36
ads
../machine-apple-darwin/s-nacoli.ads
buotex/BICEPS
Ada
4,332
ads
---------------------------------------------------------------- -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- -- -- -- Open source license information is in the zlib.ads file. -- ---------------------------------------------------------------- -- $Id: zlib-streams.ads,v 1.1 2008/06/11 20:00:39 chambers Exp $ package ZLib.Streams is type Stream_Mode is (In_Stream, Out_Stream, Duplex); type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class; type Stream_Type is new Ada.Streams.Root_Stream_Type with private; procedure Read (Stream : in out Stream_Type; Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); procedure Write (Stream : in out Stream_Type; Item : in Ada.Streams.Stream_Element_Array); procedure Flush (Stream : in out Stream_Type; Mode : in Flush_Mode := Sync_Flush); -- Flush the written data to the back stream, -- all data placed to the compressor is flushing to the Back stream. -- Should not be used untill necessary, becouse it is decreasing -- compression. function Read_Total_In (Stream : in Stream_Type) return Count; pragma Inline (Read_Total_In); -- Return total number of bytes read from back stream so far. function Read_Total_Out (Stream : in Stream_Type) return Count; pragma Inline (Read_Total_Out); -- Return total number of bytes read so far. function Write_Total_In (Stream : in Stream_Type) return Count; pragma Inline (Write_Total_In); -- Return total number of bytes written so far. function Write_Total_Out (Stream : in Stream_Type) return Count; pragma Inline (Write_Total_Out); -- Return total number of bytes written to the back stream. procedure Create (Stream : out Stream_Type; Mode : in Stream_Mode; Back : in Stream_Access; Back_Compressed : in Boolean; Level : in Compression_Level := Default_Compression; Strategy : in Strategy_Type := Default_Strategy; Header : in Header_Type := Default; Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset := Default_Buffer_Size; Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset := Default_Buffer_Size); -- Create the Comression/Decompression stream. -- If mode is In_Stream then Write operation is disabled. -- If mode is Out_Stream then Read operation is disabled. -- If Back_Compressed is true then -- Data written to the Stream is compressing to the Back stream -- and data read from the Stream is decompressed data from the Back stream. -- If Back_Compressed is false then -- Data written to the Stream is decompressing to the Back stream -- and data read from the Stream is compressed data from the Back stream. -- !!! When the Need_Header is False ZLib-Ada is using undocumented -- ZLib 1.1.4 functionality to do not create/wait for ZLib headers. function Is_Open (Stream : Stream_Type) return Boolean; procedure Close (Stream : in out Stream_Type); private use Ada.Streams; type Buffer_Access is access all Stream_Element_Array; type Stream_Type is new Root_Stream_Type with record Mode : Stream_Mode; Buffer : Buffer_Access; Rest_First : Stream_Element_Offset; Rest_Last : Stream_Element_Offset; -- Buffer for Read operation. -- We need to have this buffer in the record -- becouse not all read data from back stream -- could be processed during the read operation. Buffer_Size : Stream_Element_Offset; -- Buffer size for write operation. -- We do not need to have this buffer -- in the record becouse all data could be -- processed in the write operation. Back : Stream_Access; Reader : Filter_Type; Writer : Filter_Type; end record; end ZLib.Streams;
jrmarino/AdaBase
Ada
660
adb
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../../License.txt with Ada.Text_IO.Unbounded_IO; package body AdaBase.Logger.Base.Screen is package TIO renames Ada.Text_IO; package UIO renames Ada.Text_IO.Unbounded_IO; overriding procedure reaction (listener : Screen_Logger) is begin if listener.is_error then UIO.Put_Line (File => TIO.Standard_Error, Item => listener.composite); else UIO.Put_Line (File => TIO.Standard_Output, Item => listener.composite); end if; end reaction; end AdaBase.Logger.Base.Screen;
reznikmm/matreshka
Ada
5,130
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.Generic_Collections; package AMF.Utp.Time_Out_Actions.Collections is pragma Preelaborate; package Utp_Time_Out_Action_Collections is new AMF.Generic_Collections (Utp_Time_Out_Action, Utp_Time_Out_Action_Access); type Set_Of_Utp_Time_Out_Action is new Utp_Time_Out_Action_Collections.Set with null record; Empty_Set_Of_Utp_Time_Out_Action : constant Set_Of_Utp_Time_Out_Action; type Ordered_Set_Of_Utp_Time_Out_Action is new Utp_Time_Out_Action_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_Utp_Time_Out_Action : constant Ordered_Set_Of_Utp_Time_Out_Action; type Bag_Of_Utp_Time_Out_Action is new Utp_Time_Out_Action_Collections.Bag with null record; Empty_Bag_Of_Utp_Time_Out_Action : constant Bag_Of_Utp_Time_Out_Action; type Sequence_Of_Utp_Time_Out_Action is new Utp_Time_Out_Action_Collections.Sequence with null record; Empty_Sequence_Of_Utp_Time_Out_Action : constant Sequence_Of_Utp_Time_Out_Action; private Empty_Set_Of_Utp_Time_Out_Action : constant Set_Of_Utp_Time_Out_Action := (Utp_Time_Out_Action_Collections.Set with null record); Empty_Ordered_Set_Of_Utp_Time_Out_Action : constant Ordered_Set_Of_Utp_Time_Out_Action := (Utp_Time_Out_Action_Collections.Ordered_Set with null record); Empty_Bag_Of_Utp_Time_Out_Action : constant Bag_Of_Utp_Time_Out_Action := (Utp_Time_Out_Action_Collections.Bag with null record); Empty_Sequence_Of_Utp_Time_Out_Action : constant Sequence_Of_Utp_Time_Out_Action := (Utp_Time_Out_Action_Collections.Sequence with null record); end AMF.Utp.Time_Out_Actions.Collections;
davidkristola/vole
Ada
3,677
ads
with Ada.Finalization; with Interfaces; with kv.avm.References; with kv.avm.Registers; with kv.avm.Instructions; limited with kv.avm.Tuples; with kv.avm.Actor_References.Sets; package kv.avm.Memories is type Register_Set_Type is array (Interfaces.Unsigned_32 range <>) of aliased kv.avm.Registers.Register_Type; type Register_Set_Access is access all Register_Set_Type; function Reachable(Registers : Register_Set_Access) return kv.avm.Actor_References.Sets.Set; type Register_Array_Type is new Ada.Finalization.Controlled with private; overriding procedure Initialize (Self : in out Register_Array_Type); overriding procedure Adjust (Self : in out Register_Array_Type); overriding procedure Finalize (Self : in out Register_Array_Type); procedure Initialize(Self : in out Register_Array_Type; Data : Register_Set_Type); procedure Initialize(Self : in out Register_Array_Type; Tuple : kv.avm.Tuples.Tuple_Type); function Is_Set(Self : Register_Array_Type) return Boolean; function Get(Self : Register_Array_Type) return Register_Set_Access; procedure Set(Self : in out Register_Array_Type; Registers : in Register_Set_Access); procedure Write(Self : in out Register_Array_Type; Where : kv.avm.References.Offset_Type; Data : kv.avm.Registers.Register_Type); function Read(Self : Register_Array_Type; Where : kv.avm.References.Offset_Type) return kv.avm.Registers.Register_Type; procedure Allocate(Self : in out Register_Array_Type; Count : in Positive); procedure Deallocate(Self : in out Register_Array_Type); procedure Find_Future (Self : in Register_Array_Type; Future : in Interfaces.Unsigned_32; Found : out Boolean; Location : out kv.avm.References.Offset_Type); function Reachable(Self : Register_Array_Type) return kv.avm.Actor_References.Sets.Set; type Memory_Type is tagged private; procedure Set(Self : in out Memory_Type; Bank : kv.avm.references.Register_Bank_Type; Registers : Register_Array_Type'CLASS); function Get(Self : Memory_Type; Bank : kv.avm.references.Register_Bank_Type) return Register_Array_Type'CLASS; procedure Write(Self : in out Memory_Type; Where : kv.avm.References.Reference_Type; Data : kv.avm.Registers.Register_Type); function Read(Self : Memory_Type; Where : kv.avm.References.Reference_Type) return kv.avm.Registers.Register_Type; procedure Find_Future (Self : in Memory_Type; Bank : in kv.avm.References.Register_Bank_Type; Future : in Interfaces.Unsigned_32; Found : out Boolean; Location : out kv.avm.References.Reference_Type); function Reachable(Self : Memory_Type; Bank : kv.avm.References.Register_Bank_Type) return kv.avm.Actor_References.Sets.Set; procedure Deallocate(Self : in out Memory_Type); function To_String(Registers : Register_Set_Type) return String; function Instruction_Image(Inst : kv.avm.Instructions.Instruction_Type; M : Memory_Type) return String; private type Register_Array_Reference_Counter_Type; type Register_Array_Reference_Counter_Access is access all Register_Array_Reference_Counter_Type; type Register_Array_Type is new Ada.Finalization.Controlled with record Ref : Register_Array_Reference_Counter_Access; end record; type Memory_Set_Type is array (kv.avm.References.Register_Bank_Type) of Register_Array_Type; type Memory_Type is tagged record vq : aliased Memory_Set_Type; --!@#$ "vq" is simply a short unique sequence for use in a wide refactoring. It will be gone when done. end record; end kv.avm.Memories;
ptrebuc/ewok-kernel
Ada
3,845
ads
-- -- Copyright 2018 The wookey project team <[email protected]> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- 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 m4.mpu; with m4.scb; package ewok.mpu with spark_mode => on is type t_region_type is (REGION_TYPE_KERN_CODE, REGION_TYPE_KERN_DATA, REGION_TYPE_KERN_DEVICES, REGION_TYPE_USER_CODE, REGION_TYPE_USER_DATA, REGION_TYPE_USER_DEV, REGION_TYPE_USER_DEV_RO, REGION_TYPE_ISR_STACK) with size => 32; KERN_CODE_REGION : constant m4.mpu.t_region_number := 0; KERN_DEVICES_REGION : constant m4.mpu.t_region_number := 1; KERN_DATA_REGION : constant m4.mpu.t_region_number := 2; USER_DATA_REGION : constant m4.mpu.t_region_number := 3; -- USER_RAM USER_CODE_REGION : constant m4.mpu.t_region_number := 4; -- USER_TXT USER_ISR_STACK_REGION : constant m4.mpu.t_region_number := 5; USER_DEV1_REGION : constant m4.mpu.t_region_number := 5; USER_ISR_DEVICE_REGION : constant m4.mpu.t_region_number := 6; USER_DEV2_REGION : constant m4.mpu.t_region_number := 6; USER_SHARED_REGION : constant m4.mpu.t_region_number := 7; -- How many devices can be mapped in memory MAX_DEVICE_REGIONS : constant := 2; device_regions : constant array (unsigned_8 range 1 .. MAX_DEVICE_REGIONS) of m4.mpu.t_region_number := (USER_DEV1_REGION, USER_DEV2_REGION); --------------- -- Functions -- --------------- pragma assertion_policy (pre => IGNORE, post => IGNORE, assert => IGNORE); -- Initialize the MPU procedure init (success : out boolean) with global => (in_out => (m4.mpu.MPU, m4.scb.SCB)); -- -- Utilities so that the kernel can temporary access the whole memory space -- procedure enable_unrestricted_kernel_access with global => (in_out => (m4.mpu.MPU)); procedure disable_unrestricted_kernel_access with global => (in_out => (m4.mpu.MPU)); -- That function is only used by SPARK prover function get_region_size_mask (size : m4.mpu.t_region_size) return unsigned_32 is (2**(natural (size) + 1) - 1) with ghost; pragma warnings (off, "condition can only be False if invalid values present"); procedure set_region (region_number : in m4.mpu.t_region_number; addr : in system_address; size : in m4.mpu.t_region_size; region_type : in t_region_type; subregion_mask : in unsigned_8) with global => (in_out => (m4.mpu.MPU)), pre => (region_number < 8 and (addr and 2#11111#) = 0 and size >= 4 and (addr and get_region_size_mask(size)) = 0); pragma warnings (on); procedure update_subregions (region_number : in m4.mpu.t_region_number; subregion_mask : in unsigned_8) with global => (in_out => (m4.mpu.MPU)); procedure bytes_to_region_size (bytes : in unsigned_32; region_size : out m4.mpu.t_region_size; success : out boolean) with global => null; end ewok.mpu;
DrenfongWong/tkm-rpc
Ada
1,218
adb
with Tkmrpc.Servers.Ike; with Tkmrpc.Results; with Tkmrpc.Request.Ike.Dh_Generate_Key.Convert; with Tkmrpc.Response.Ike.Dh_Generate_Key.Convert; package body Tkmrpc.Operation_Handlers.Ike.Dh_Generate_Key is ------------------------------------------------------------------------- procedure Handle (Req : Request.Data_Type; Res : out Response.Data_Type) is Specific_Req : Request.Ike.Dh_Generate_Key.Request_Type; Specific_Res : Response.Ike.Dh_Generate_Key.Response_Type; begin Specific_Res := Response.Ike.Dh_Generate_Key.Null_Response; Specific_Req := Request.Ike.Dh_Generate_Key.Convert.From_Request (S => Req); if Specific_Req.Data.Dh_Id'Valid and Specific_Req.Data.Pubvalue.Size'Valid then Servers.Ike.Dh_Generate_Key (Result => Specific_Res.Header.Result, Dh_Id => Specific_Req.Data.Dh_Id, Pubvalue => Specific_Req.Data.Pubvalue); Res := Response.Ike.Dh_Generate_Key.Convert.To_Response (S => Specific_Res); else Res.Header.Result := Results.Invalid_Parameter; end if; end Handle; end Tkmrpc.Operation_Handlers.Ike.Dh_Generate_Key;
reznikmm/matreshka
Ada
3,699
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_Mirror_Attributes is pragma Preelaborate; type ODF_Style_Mirror_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Style_Mirror_Attribute_Access is access all ODF_Style_Mirror_Attribute'Class with Storage_Size => 0; end ODF.DOM.Style_Mirror_Attributes;
flyx/OpenGLAda
Ada
1,582
ads
-- part of OpenGLAda, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "COPYING" generic type Base (<>) is new Texture_Proxy with private; package GL.Objects.Textures.With_2D_Loader is pragma Preelaborate; type Target is new Base with null record; procedure Load_Empty_Texture (Object : Target; Level : Mipmap_Level; Internal_Format : Pixels.Internal_Format; Width, Height : Types.Size); procedure Storage (Object : Target; Number_Of_Levels : Types.Size; Internal_Format : Pixels.Internal_Format; Width, Height : Types.Size); type Fillable_Target is new Target with null record; procedure Load_From_Data (Object : Fillable_Target; Level : Mipmap_Level; Internal_Format : Pixels.Internal_Format; Width, Height : Types.Size; Source_Format : Pixels.Data_Format; Source_Type : Pixels.Data_Type; Source : Image_Source); procedure Load_Sub_Image_From_Data (Object : Fillable_Target; Level : Mipmap_Level; X_Offset, Y_Offset : Int; Width, Height : Size; Format : Pixels.Data_Format; Data_Type : Pixels.Data_Type; Source : Image_Source); procedure Load_Compressed (Object : Fillable_Target; Level : Mipmap_Level; Internal_Format : Pixels.Internal_Format; Width, Height, Image_Size : Types.Size; Source : Image_Source); end GL.Objects.Textures.With_2D_Loader;
albinjal/ada_basic
Ada
398
adb
with Ada.Text_IO; use Ada.Text_IO; with Ada.Float_Text_IO; use Ada.Float_Text_IO; procedure lab1 is FP, LP, Steps, Moms: Float; begin FP := 10.0; LP := 15.0; Steps := 0.5; Moms := 10.0; Put("=== Momstabell ==="); New_Line(1); Put("Pris utan moms Moms Pris med moms"); while FP < LP loop Put(FP,2,2,0); FP := FP + Steps; end loop; end Lab1;
reznikmm/matreshka
Ada
3,603
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.Elements.Generic_Hash; function AMF.OCL.State_Exps.Hash is new AMF.Elements.Generic_Hash (OCL_State_Exp, OCL_State_Exp_Access);
Gabriel-Degret/adalib
Ada
760
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 --------------------------------------------------------------------------- with Ada.Numerics.Complex_Types; with Ada.Numerics.Generic_Complex_Arrays; with Ada.Numerics.Real_Arrays; package Ada.Numerics.Complex_Arrays is new Ada.Numerics.Generic_Complex_Arrays (Ada.Numerics.Real_Arrays, Ada.Numerics.Complex_Types);
eqcola/ada-ado
Ada
1,784
ads
----------------------------------------------------------------------- -- ADO Statements -- Database statements -- Copyright (C) 2009, 2010, 2011, 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. ----------------------------------------------------------------------- package ADO.Statements.Create is -- Create the query statement function Create_Statement (Proxy : in Query_Statement_Access; Expander : in ADO.Parameters.Expander_Access := null) return Query_Statement; -- Create the delete statement function Create_Statement (Proxy : in Delete_Statement_Access; Expander : in ADO.Parameters.Expander_Access := null) return Delete_Statement; -- Create an update statement function Create_Statement (Proxy : in Update_Statement_Access; Expander : in ADO.Parameters.Expander_Access := null) return Update_Statement; -- Create the insert statement. function Create_Statement (Proxy : in Update_Statement_Access; Expander : in ADO.Parameters.Expander_Access := null) return Insert_Statement; end ADO.Statements.Create;
DrenfongWong/tkm-rpc
Ada
266
ads
with Tkmrpc.Request; with Tkmrpc.Response; package Tkmrpc.Operation_Handlers.Ike.Esa_Create is procedure Handle (Req : Request.Data_Type; Res : out Response.Data_Type); -- Handler for the esa_create operation. end Tkmrpc.Operation_Handlers.Ike.Esa_Create;
reznikmm/matreshka
Ada
3,618
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.Elements.Generic_Hash; function AMF.OCL.Ocl_Expressions.Hash is new AMF.Elements.Generic_Hash (OCL_Ocl_Expression, OCL_Ocl_Expression_Access);
AdaCore/gpr
Ada
2,090
adb
-- -- Copyright (C) 2021-2023, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 -- with Ada.Text_IO; with GPR2.Context; with GPR2.Log; with GPR2.Path_Name; with GPR2.Project.Tree; with GPR2.Project.View; procedure Main is Tree : GPR2.Project.Tree.Object; Context : GPR2.Context.Object; use GPR2; procedure Print_Messages is begin if Tree.Has_Messages then for C in Tree.Log_Messages.Iterate (False, True, True, True, True) loop Ada.Text_IO.Put_Line (GPR2.Log.Element (C).Format); end loop; end if; end Print_Messages; function Get_Aggregated (View : GPR2.Project.View.Object; Name : Simple_Name) return GPR2.Project.View.Object is begin for V of View.Aggregated loop if V.Path_Name.Simple_Name = Name then return V; end if; end loop; return GPR2.Project.View.Undefined; end Get_Aggregated; procedure Test (View : GPR2.Project.View.Object) is A : GPR2.Project.View.Object; B : GPR2.Project.View.Object; begin Ada.Text_IO.Put_Line ("testing " & String (View.Path_Name.Simple_Name)); A := Get_Aggregated (View, "a.gpr"); B := Get_Aggregated (View, "b.gpr"); Ada.Text_IO.Put_Line ("A.Object_Dir:" & A.Object_Directory.Value); Ada.Text_IO.Put_Line ("B.Object_Dir:" & B.Object_Directory.Value); exception when Project_Error => Print_Messages; end Test; procedure Load (Project_Name : GPR2.Filename_Type) is begin Ada.Text_IO.Put_Line ("loading " & String (Project_Name)); Tree.Unload; Tree.Load_Autoconf (Filename => GPR2.Path_Name.Create_File (GPR2.Project.Ensure_Extension (Project_Name), GPR2.Path_Name.No_Resolution), Context => Context); exception when Project_Error => Print_Messages; end Load; begin Load ("files/aggl1.gpr"); Test (Tree.Root_Project); Load ("files/aggl.gpr"); Test (Get_Aggregated (Tree.Root_Project, "aggl1.gpr")); end Main;
DrenfongWong/tkm-rpc
Ada
1,029
ads
with Tkmrpc.Types; with Tkmrpc.Operations.Ike; package Tkmrpc.Response.Ike.Isa_Auth is Data_Size : constant := 0; Padding_Size : constant := Response.Body_Size - Data_Size; subtype Padding_Range is Natural range 1 .. Padding_Size; subtype Padding_Type is Types.Byte_Sequence (Padding_Range); type Response_Type is record Header : Response.Header_Type; Padding : Padding_Type; end record; for Response_Type use record Header at 0 range 0 .. (Response.Header_Size * 8) - 1; Padding at Response.Header_Size + Data_Size range 0 .. (Padding_Size * 8) - 1; end record; for Response_Type'Size use Response.Response_Size * 8; Null_Response : constant Response_Type := Response_Type' (Header => Response.Header_Type'(Operation => Operations.Ike.Isa_Auth, Result => Results.Invalid_Operation, Request_Id => 0), Padding => Padding_Type'(others => 0)); end Tkmrpc.Response.Ike.Isa_Auth;
charlie5/cBound
Ada
1,809
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces; with swig; with xcb.xcb_render_color_t; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_render_fill_rectangles_request_t is -- Item -- type Item is record major_opcode : aliased Interfaces.Unsigned_8; minor_opcode : aliased Interfaces.Unsigned_8; length : aliased Interfaces.Unsigned_16; op : aliased Interfaces.Unsigned_8; pad0 : aliased swig.int8_t_Array (0 .. 2); dst : aliased xcb.xcb_render_picture_t; color : aliased xcb.xcb_render_color_t.Item; end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_render_fill_rectangles_request_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_render_fill_rectangles_request_t.Item, Element_Array => xcb.xcb_render_fill_rectangles_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_render_fill_rectangles_request_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_render_fill_rectangles_request_t.Pointer, Element_Array => xcb.xcb_render_fill_rectangles_request_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_render_fill_rectangles_request_t;
reznikmm/acme-ada
Ada
23,495
adb
-- SPDX-FileCopyrightText: 2020 Max Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT ---------------------------------------------------------------- with Ada.Text_IO; with Ada.Wide_Wide_Text_IO; with GNAT.SHA256; with AWS.Client; with AWS.Default; with AWS.Messages; with AWS.Response; with JWS; with JWS.RS256; pragma Unreferenced (JWS.RS256); -- Enable RS256 with JWS.To_Base_64_URL; with League.Calendars.ISO_8601; with League.JSON.Arrays; with League.JSON.Documents; with League.JSON.Values; package body ACME is function "+" (V : Wide_Wide_String) return League.Strings.Universal_String renames League.Strings.To_Universal_String; function "-" (V : Wide_Wide_String) return League.JSON.Values.JSON_Value is (League.JSON.Values.To_JSON_Value (+V)); function "-" (V : League.Strings.Universal_String) return League.JSON.Values.JSON_Value is (League.JSON.Values.To_JSON_Value (V)); User_Agent : constant String := AWS.Default.User_Agent & " acme-ada 0.0.1"; procedure Get_Nonce (Self : in out Context'Class; Nonce : out League.Strings.Universal_String); ------------------------ -- Challenge_Complete -- ------------------------ procedure Challenge_Complete (Self : in out Context'Class; Account_URL : League.Strings.Universal_String; Private_Key : League.Stream_Element_Vectors.Stream_Element_Vector; Challenge : ACME.Challenge) is URL : constant League.Strings.Universal_String := Challenge.URL; Nonce : League.Strings.Universal_String; JWT : JWS.JSON_Web_Signature; Header : JWS.JOSE_Header; Result : AWS.Response.Data; begin Self.Get_Nonce (Nonce); Ada.Wide_Wide_Text_IO.Put ("Nonce="); Ada.Wide_Wide_Text_IO.Put_Line (Nonce.To_Wide_Wide_String); Header.Set_Algorithm (+"RS256"); Header.Insert (+"nonce", -Nonce); Header.Insert (+"url", -URL); Header.Insert (+"kid", -Account_URL); JWT.Create (Header => Header, Payload => League.JSON.Objects.Empty_JSON_Object. To_JSON_Document.To_JSON.To_Stream_Element_Array, Secret => Private_Key.To_Stream_Element_Array); Ada.Wide_Wide_Text_IO.Put_Line (JWT.Flattened_Serialization. To_JSON_Document.To_JSON.To_Wide_Wide_String); Result := AWS.Client.Post (URL => URL.To_UTF_8_String, Data => JWT.Flattened_Serialization. To_JSON_Document.To_JSON.To_UTF_8_String, Content_Type => "application/jose+json", User_Agent => User_Agent); Ada.Text_IO.Put_Line (AWS.Response.Status_Code (Result)'Img); Ada.Text_IO.Put_Line (AWS.Response.Message_Body (Result)); pragma Assert (AWS.Response.Status_Code (Result) in AWS.Messages.Success); if AWS.Response.Has_Header (Result, "Replay-Nonce") then Self.Nonce := League.Strings.From_UTF_8_String (AWS.Response.Header (Result, "Replay-Nonce", 1)); end if; end Challenge_Complete; ---------------------- -- Challenge_Status -- ---------------------- procedure Challenge_Status (Self : in out Context'Class; Account_URL : League.Strings.Universal_String; Private_Key : League.Stream_Element_Vectors.Stream_Element_Vector; Challenge : ACME.Challenge; Status : out League.Strings.Universal_String) is URL : constant League.Strings.Universal_String := Challenge.URL; Doc : League.JSON.Documents.JSON_Document; Nonce : League.Strings.Universal_String; JWT : JWS.JSON_Web_Signature; Header : JWS.JOSE_Header; Result : AWS.Response.Data; begin Self.Get_Nonce (Nonce); Ada.Wide_Wide_Text_IO.Put ("Nonce="); Ada.Wide_Wide_Text_IO.Put_Line (Nonce.To_Wide_Wide_String); Header.Set_Algorithm (+"RS256"); Header.Insert (+"nonce", -Nonce); Header.Insert (+"url", -URL); Header.Insert (+"kid", -Account_URL); JWT.Create (Header => Header, Payload => (1 .. 0 => <>), Secret => Private_Key.To_Stream_Element_Array); Result := AWS.Client.Post (URL => URL.To_UTF_8_String, Data => JWT.Flattened_Serialization. To_JSON_Document.To_JSON.To_UTF_8_String, Content_Type => "application/jose+json", User_Agent => User_Agent); Ada.Text_IO.Put_Line (AWS.Response.Status_Code (Result)'Img); Ada.Text_IO.Put_Line (AWS.Response.Message_Body (Result)); pragma Assert (AWS.Response.Status_Code (Result) in AWS.Messages.Success); if AWS.Response.Has_Header (Result, "Replay-Nonce") then Self.Nonce := League.Strings.From_UTF_8_String (AWS.Response.Header (Result, "Replay-Nonce", 1)); end if; Doc := League.JSON.Documents.From_JSON (AWS.Response.Message_Body (Result)); Status := Doc.To_JSON_Object.Value (+"status").To_String; end Challenge_Status; -------------------- -- Create_Account -- -------------------- procedure Create_Account (Self : in out Context'Class; Public_Key : League.JSON.Objects.JSON_Object; Private_Key : League.Stream_Element_Vectors.Stream_Element_Vector; Contact : League.String_Vectors.Universal_String_Vector; TOS_Agreed : Boolean := True; Only_Existing : Boolean := False; Account_URL : out League.Strings.Universal_String) is URL : constant League.Strings.Universal_String := Self.Directory.Value (+"newAccount").To_String; Account : League.JSON.Objects.JSON_Object; Nonce : League.Strings.Universal_String; Meta : constant League.JSON.Objects.JSON_Object := Self.Directory.Value (+"meta").To_Object; JWT : JWS.JSON_Web_Signature; Header : JWS.JOSE_Header; Result : AWS.Response.Data; begin Self.Get_Nonce (Nonce); Ada.Wide_Wide_Text_IO.Put ("Nonce="); Ada.Wide_Wide_Text_IO.Put_Line (Nonce.To_Wide_Wide_String); if not Contact.Is_Empty then declare List : League.JSON.Arrays.JSON_Array; begin for J in 1 .. Contact.Length loop List.Append (-Contact (J)); end loop; Account.Insert (+"contact", List.To_JSON_Value); end; end if; if Meta.Contains (+"termsOfService") then Account.Insert (+"termsOfServiceAgreed", League.JSON.Values.To_JSON_Value (TOS_Agreed)); end if; if Only_Existing then Account.Insert (+"onlyReturnExisting", League.JSON.Values.To_JSON_Value (True)); end if; Header.Set_Algorithm (+"RS256"); Header.Insert (+"nonce", -Nonce); Header.Insert (+"url", -URL); Header.Insert (+"jwk", Public_Key.To_JSON_Value); JWT.Create (Header => Header, Payload => Account.To_JSON_Document.To_JSON.To_Stream_Element_Array, Secret => Private_Key.To_Stream_Element_Array); Result := AWS.Client.Post (URL => URL.To_UTF_8_String, Data => JWT.Flattened_Serialization. To_JSON_Document.To_JSON.To_UTF_8_String, Content_Type => "application/jose+json", User_Agent => User_Agent); Ada.Text_IO.Put_Line (AWS.Response.Status_Code (Result)'Img); Ada.Text_IO.Put_Line (AWS.Response.Message_Body (Result)); pragma Assert (AWS.Response.Status_Code (Result) in AWS.Messages.Success); Account_URL := League.Strings.From_UTF_8_String (AWS.Response.Header (Result, "Location", 1)); if AWS.Response.Has_Header (Result, "Replay-Nonce") then Self.Nonce := League.Strings.From_UTF_8_String (AWS.Response.Header (Result, "Replay-Nonce", 1)); end if; end Create_Account; ------------------ -- Create_Order -- ------------------ procedure Create_Order (Self : in out Context'Class; Account_URL : League.Strings.Universal_String; Private_Key : League.Stream_Element_Vectors.Stream_Element_Vector; DNS_Id_List : League.String_Vectors.Universal_String_Vector; Not_Before : Optional_Date_Time := (Is_Set => False); Not_After : Optional_Date_Time := (Is_Set => False); Auth_List : out League.String_Vectors.Universal_String_Vector; Finalize : out League.Strings.Universal_String; Order_URL : out League.Strings.Universal_String) is Format : constant League.Strings.Universal_String := +"yyyy-MM-ddTHH:mm:ss+04:00Z"; URL : constant League.Strings.Universal_String := Self.Directory.Value (+"newOrder").To_String; Doc : League.JSON.Documents.JSON_Document; Order : League.JSON.Objects.JSON_Object; Nonce : League.Strings.Universal_String; JWT : JWS.JSON_Web_Signature; Header : JWS.JOSE_Header; Result : AWS.Response.Data; List : League.JSON.Arrays.JSON_Array; begin Self.Get_Nonce (Nonce); Ada.Wide_Wide_Text_IO.Put ("Nonce="); Ada.Wide_Wide_Text_IO.Put_Line (Nonce.To_Wide_Wide_String); Header.Set_Algorithm (+"RS256"); Header.Insert (+"nonce", -Nonce); Header.Insert (+"url", -URL); Header.Insert (+"kid", -Account_URL); for J in 1 .. DNS_Id_List.Length loop declare DNS : League.JSON.Objects.JSON_Object; begin DNS.Insert (+"type", -"dns"); DNS.Insert (+"value", -DNS_Id_List (J)); List.Append (DNS.To_JSON_Value); end; end loop; Order.Insert (+"identifiers", List.To_JSON_Value); if Not_Before.Is_Set then Order.Insert (+"notBefore", -League.Calendars.ISO_8601.Image (Format, Not_Before.Value)); end if; if Not_After.Is_Set then Order.Insert (+"notAfter", -League.Calendars.ISO_8601.Image (Format, Not_After.Value)); end if; JWT.Create (Header => Header, Payload => Order.To_JSON_Document.To_JSON.To_Stream_Element_Array, Secret => Private_Key.To_Stream_Element_Array); Ada.Wide_Wide_Text_IO.Put_Line (JWT.Flattened_Serialization. To_JSON_Document.To_JSON.To_Wide_Wide_String); Result := AWS.Client.Post (URL => URL.To_UTF_8_String, Data => JWT.Flattened_Serialization. To_JSON_Document.To_JSON.To_UTF_8_String, Content_Type => "application/jose+json", User_Agent => User_Agent); Ada.Text_IO.Put_Line (AWS.Response.Status_Code (Result)'Img); Ada.Text_IO.Put_Line (AWS.Response.Message_Body (Result)); Doc := League.JSON.Documents.From_JSON (AWS.Response.Message_Body (Result)); pragma Assert (AWS.Response.Status_Code (Result) in AWS.Messages.Success); Order := Doc.To_JSON_Object; declare Vector : constant League.JSON.Arrays.JSON_Array := Order.Value (+"authorizations").To_Array; begin for J in 1 .. Vector.Length loop Auth_List.Append (Vector (J).To_String); end loop; end; Finalize := Order.Value (+"finalize").To_String; Order_URL := League.Strings.From_UTF_8_String (AWS.Response.Header (Result, "Location", 1)); if AWS.Response.Has_Header (Result, "Replay-Nonce") then Self.Nonce := League.Strings.From_UTF_8_String (AWS.Response.Header (Result, "Replay-Nonce", 1)); end if; end Create_Order; -------------------- -- Finalize_Order -- -------------------- procedure Finalize_Order (Self : in out Context'Class; Account_URL : League.Strings.Universal_String; Private_Key : League.Stream_Element_Vectors.Stream_Element_Vector; Finalize : League.Strings.Universal_String; CSR : League.Stream_Element_Vectors.Stream_Element_Vector) is URL : constant League.Strings.Universal_String := Finalize; Object : League.JSON.Objects.JSON_Object; Nonce : League.Strings.Universal_String; JWT : JWS.JSON_Web_Signature; Header : JWS.JOSE_Header; Result : AWS.Response.Data; begin Self.Get_Nonce (Nonce); Ada.Wide_Wide_Text_IO.Put ("Nonce="); Ada.Wide_Wide_Text_IO.Put_Line (Nonce.To_Wide_Wide_String); Header.Set_Algorithm (+"RS256"); Header.Insert (+"nonce", -Nonce); Header.Insert (+"url", -URL); Header.Insert (+"kid", -Account_URL); Object.Insert (+"csr", -JWS.To_Base_64_URL (CSR)); JWT.Create (Header => Header, Payload => Object.To_JSON_Document.To_JSON.To_Stream_Element_Array, Secret => Private_Key.To_Stream_Element_Array); Ada.Wide_Wide_Text_IO.Put_Line (JWT.Flattened_Serialization. To_JSON_Document.To_JSON.To_Wide_Wide_String); Result := AWS.Client.Post (URL => URL.To_UTF_8_String, Data => JWT.Flattened_Serialization. To_JSON_Document.To_JSON.To_UTF_8_String, Content_Type => "application/jose+json", User_Agent => User_Agent); Ada.Text_IO.Put_Line (AWS.Response.Status_Code (Result)'Img); Ada.Text_IO.Put_Line (AWS.Response.Message_Body (Result)); pragma Assert (AWS.Response.Status_Code (Result) in AWS.Messages.Success); if AWS.Response.Has_Header (Result, "Replay-Nonce") then Self.Nonce := League.Strings.From_UTF_8_String (AWS.Response.Header (Result, "Replay-Nonce", 1)); end if; end Finalize_Order; ----------------------- -- Get_Authorization -- ----------------------- procedure Get_Challenges (Self : in out Context'Class; Account_URL : League.Strings.Universal_String; Private_Key : League.Stream_Element_Vectors.Stream_Element_Vector; Auth_URL : League.Strings.Universal_String; HTTP : out Challenge; DNS : out Challenge) is URL : constant League.Strings.Universal_String := Auth_URL; Doc : League.JSON.Documents.JSON_Document; Auth : League.JSON.Objects.JSON_Object; Nonce : League.Strings.Universal_String; JWT : JWS.JSON_Web_Signature; Header : JWS.JOSE_Header; Result : AWS.Response.Data; begin Self.Get_Nonce (Nonce); Ada.Wide_Wide_Text_IO.Put ("Nonce="); Ada.Wide_Wide_Text_IO.Put_Line (Nonce.To_Wide_Wide_String); Header.Set_Algorithm (+"RS256"); Header.Insert (+"nonce", -Nonce); Header.Insert (+"url", -URL); Header.Insert (+"kid", -Account_URL); JWT.Create (Header => Header, Payload => (1 .. 0 => <>), Secret => Private_Key.To_Stream_Element_Array); Result := AWS.Client.Post (URL => URL.To_UTF_8_String, Data => JWT.Flattened_Serialization. To_JSON_Document.To_JSON.To_UTF_8_String, Content_Type => "application/jose+json", User_Agent => User_Agent); Ada.Text_IO.Put_Line (AWS.Response.Status_Code (Result)'Img); Ada.Text_IO.Put_Line (AWS.Response.Message_Body (Result)); pragma Assert (AWS.Response.Status_Code (Result) in AWS.Messages.Success); Doc := League.JSON.Documents.From_JSON (AWS.Response.Message_Body (Result)); Auth := Doc.To_JSON_Object; declare Vector : constant League.JSON.Arrays.JSON_Array := Auth.Value (+"challenges").To_Array; begin for J in 1 .. Vector.Length loop declare use type League.Strings.Universal_String; Item : constant League.JSON.Objects.JSON_Object := Vector (J).To_Object; begin if Item.Value (+"type").To_String = +"http-01" then HTTP.URL := Item.Value (+"url").To_String; HTTP.Token := Item.Value (+"token").To_String; elsif Item.Value (+"type").To_String = +"dns-01" then DNS.URL := Item.Value (+"url").To_String; DNS.Token := Item.Value (+"token").To_String; end if; end; end loop; end; if AWS.Response.Has_Header (Result, "Replay-Nonce") then Self.Nonce := League.Strings.From_UTF_8_String (AWS.Response.Header (Result, "Replay-Nonce", 1)); end if; end Get_Challenges; procedure Get_Certificate (Self : in out Context'Class; Account_URL : League.Strings.Universal_String; Private_Key : League.Stream_Element_Vectors.Stream_Element_Vector; Certificate : League.Strings.Universal_String; Text : out League.Strings.Universal_String) is URL : constant League.Strings.Universal_String := Certificate; Nonce : League.Strings.Universal_String; JWT : JWS.JSON_Web_Signature; Header : JWS.JOSE_Header; Headers : AWS.Client.Header_List; Result : AWS.Response.Data; begin Self.Get_Nonce (Nonce); Header.Set_Algorithm (+"RS256"); Header.Insert (+"nonce", -Nonce); Header.Insert (+"url", -URL); Header.Insert (+"kid", -Account_URL); JWT.Create (Header => Header, Payload => (1 .. 0 => <>), Secret => Private_Key.To_Stream_Element_Array); Headers.Add ("Accept", "application/pem-certificate-chain"); Result := AWS.Client.Post (URL => URL.To_UTF_8_String, Data => JWT.Flattened_Serialization. To_JSON_Document.To_JSON.To_UTF_8_String, Content_Type => "application/jose+json", Headers => Headers, User_Agent => User_Agent); Ada.Text_IO.Put_Line (AWS.Response.Status_Code (Result)'Img); Ada.Text_IO.Put_Line (AWS.Response.Message_Body (Result)); pragma Assert (AWS.Response.Status_Code (Result) in AWS.Messages.Success); if AWS.Response.Has_Header (Result, "Replay-Nonce") then Self.Nonce := League.Strings.From_UTF_8_String (AWS.Response.Header (Result, "Replay-Nonce", 1)); end if; Text := League.Strings.From_UTF_8_String (AWS.Response.Message_Body (Result)); end Get_Certificate; --------------- -- Get_Nonce -- --------------- procedure Get_Nonce (Self : in out Context'Class; Nonce : out League.Strings.Universal_String) is Result : AWS.Response.Data; URL : League.Strings.Universal_String; begin if Self.Nonce.Is_Empty then URL := Self.Directory.Value (+"newNonce").To_String; Result := AWS.Client.Head (URL => URL.To_UTF_8_String, User_Agent => User_Agent); pragma Assert (AWS.Response.Has_Header (Result, "Replay-Nonce")); Self.Nonce := League.Strings.From_UTF_8_String (AWS.Response.Header (Result, "Replay-Nonce", 1)); end if; Nonce := Self.Nonce; end Get_Nonce; procedure Get_Order_Status (Self : in out Context'Class; Account_URL : League.Strings.Universal_String; Private_Key : League.Stream_Element_Vectors.Stream_Element_Vector; Order_URL : League.Strings.Universal_String; Certificate : out League.Strings.Universal_String; Status : out League.Strings.Universal_String) is URL : constant League.Strings.Universal_String := Order_URL; Doc : League.JSON.Documents.JSON_Document; Nonce : League.Strings.Universal_String; JWT : JWS.JSON_Web_Signature; Header : JWS.JOSE_Header; Result : AWS.Response.Data; begin Self.Get_Nonce (Nonce); Header.Set_Algorithm (+"RS256"); Header.Insert (+"nonce", -Nonce); Header.Insert (+"url", -URL); Header.Insert (+"kid", -Account_URL); JWT.Create (Header => Header, Payload => (1 .. 0 => <>), Secret => Private_Key.To_Stream_Element_Array); Result := AWS.Client.Post (URL => URL.To_UTF_8_String, Data => JWT.Flattened_Serialization. To_JSON_Document.To_JSON.To_UTF_8_String, Content_Type => "application/jose+json", User_Agent => User_Agent); Ada.Text_IO.Put_Line (AWS.Response.Status_Code (Result)'Img); Ada.Text_IO.Put_Line (AWS.Response.Message_Body (Result)); pragma Assert (AWS.Response.Status_Code (Result) in AWS.Messages.Success); if AWS.Response.Has_Header (Result, "Replay-Nonce") then Self.Nonce := League.Strings.From_UTF_8_String (AWS.Response.Header (Result, "Replay-Nonce", 1)); end if; Doc := League.JSON.Documents.From_JSON (AWS.Response.Message_Body (Result)); Status := Doc.To_JSON_Object.Value (+"status").To_String; Certificate := Doc.To_JSON_Object.Value (+"certificate").To_String; end Get_Order_Status; ---------------- -- Initialize -- ---------------- procedure Initialize (Self : in out Context'Class; Directory_URL : League.Strings.Universal_String; Terms_Of_Service : out League.Strings.Universal_String) is Doc : League.JSON.Documents.JSON_Document; Meta : League.JSON.Objects.JSON_Object; Result : AWS.Response.Data; URL : constant League.Strings.Universal_String := Directory_URL; begin Result := AWS.Client.Get (URL => URL.To_UTF_8_String, Follow_Redirection => True, User_Agent => User_Agent); pragma Assert (AWS.Response.Status_Code (Result) in AWS.Messages.Success); Doc := League.JSON.Documents.From_JSON (AWS.Response.Message_Body (Result)); Self.Directory := Doc.To_JSON_Object; pragma Assert (Self.Directory.Contains (+"newNonce")); pragma Assert (Self.Directory.Contains (+"newAccount")); pragma Assert (Self.Directory.Contains (+"newOrder")); pragma Assert (Self.Directory.Contains (+"revokeCert")); pragma Assert (Self.Directory.Contains (+"keyChange")); Meta := Self.Directory.Value (+"meta").To_Object; Terms_Of_Service := Meta.Value (+"termsOfService").To_String; end Initialize; ----------------------- -- Key_Authorization -- ----------------------- function Key_Authorization (Token : League.Strings.Universal_String; Public_Key : League.JSON.Objects.JSON_Object) return League.Strings.Universal_String is SHA256 : constant GNAT.SHA256.Binary_Message_Digest := GNAT.SHA256.Digest (JWS.Thumbprint (Public_Key)); Vector : League.Stream_Element_Vectors.Stream_Element_Vector; Result : League.Strings.Universal_String; begin Vector.Append (SHA256); Result.Append (Token); Result.Append ('.'); Result.Append (JWS.To_Base_64_URL (Vector)); return Result; end Key_Authorization; end ACME;
stcarrez/dynamo
Ada
5,760
ads
------------------------------------------------------------------------------ -- -- -- ASIS-for-GNAT IMPLEMENTATION COMPONENTS -- -- -- -- A 4 G . Q U E R I E S -- -- -- -- S p e c -- -- -- -- Copyright (c) 1995-2006, Free Software Foundation, Inc. -- -- -- -- ASIS-for-GNAT is free software; you can redistribute it and/or modify it -- -- under terms of the GNU General Public License as published by the Free -- -- Software Foundation; either version 2, or (at your option) any later -- -- version. ASIS-for-GNAT is distributed in the hope that it will be use- -- -- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- -- -- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -- -- Public License for more details. You should have received a copy of the -- -- GNU General Public License distributed with ASIS-for-GNAT; see file -- -- COPYING. If not, write to the Free Software Foundation, 51 Franklin -- -- Street, Fifth Floor, Boston, MA 02110-1301, USA. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the -- -- Software Engineering Laboratory of the Swiss Federal Institute of -- -- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the -- -- Scientific Research Computer Center of Moscow State University (SRCC -- -- MSU), Russia, with funding partially provided by grants from the Swiss -- -- National Science Foundation and the Swiss Academy of Engineering -- -- Sciences. ASIS-for-GNAT is now maintained by AdaCore -- -- (http://www.adaccore.com). -- -- -- -- The original version of this component has been developed by Jean-Charles-- -- Marteau ([email protected]) and Serge Reboul -- -- ([email protected]), ENSIMAG High School Graduates (Computer -- -- sciences) Grenoble, France in Sema Group Grenoble, France. Now this -- -- component is maintained by the ASIS team -- -- -- ------------------------------------------------------------------------------ with Asis; use Asis; ---------------------------------------------------------- -- The goal of this package is, when we have an element -- -- to let us have ALL the possible queries for that -- -- element that return its children. -- ---------------------------------------------------------- package A4G.Queries is -- There is 3 kinds of queries in Asis : type Query_Kinds is (Bug, -- just for the discriminant default expression Single_Element_Query, -- Queries taking an element and returning an element. Element_List_Query, -- Queries taking an element and returning a list of elements. Element_List_Query_With_Boolean -- Queries taking an element and a boolean and returning a list -- of elements. ); type A_Single_Element_Query is access function (Elem : Asis.Element) return Asis.Element; type A_Element_List_Query is access function (Elem : Asis.Element) return Asis.Element_List; type A_Element_List_Query_With_Boolean is access function (Elem : Asis.Element; Bool : Boolean) return Asis.Element_List; -- Discriminant record that can access any type of query. type Func_Elem (Query_Kind : Query_Kinds := Bug) is record case Query_Kind is when Bug => null; when Single_Element_Query => Func_Simple : A_Single_Element_Query; when Element_List_Query => Func_List : A_Element_List_Query; when Element_List_Query_With_Boolean => Func_List_Boolean : A_Element_List_Query_With_Boolean; Bool : Boolean; end case; end record; type Query_Array is array (Positive range <>) of Func_Elem; -- an empty array, when the element is a terminal No_Query : Query_Array (1 .. 0); ---------------------------------------------------- -- This function returns a Query_Array containing -- -- all the existing queries for that element. -- -- If an element has no children, No_Query is -- -- returned. -- ---------------------------------------------------- function Appropriate_Queries (Element : Asis.Element) return Query_Array; end A4G.Queries;
charlie5/lace
Ada
14,403
adb
with openGL.Geometry.lit_colored, openGL.Texture, openGL.Primitive.indexed; package body openGL.Model.capsule.lit_colored is --------- --- Forge -- function new_Capsule (Radius : in Real; Height : in Real; Color : in lucid_Color) return View is Self : constant View := new Item; begin Self.Radius := Radius; Self.Height := Height; Self.Color := +Color; return Self; end new_Capsule; -------------- --- Attributes -- overriding function to_GL_Geometries (Self : access Item; Textures : access Texture.name_Map_of_texture'Class; Fonts : in Font.font_id_Map_of_font) return Geometry.views is pragma unreferenced (Textures, Fonts); use Geometry, Geometry.lit_colored, real_Functions; Length : constant Real := Self.Height; Radius : constant Real := Self.Radius; quality_Level : constant Index_t := 4; sides_Count : constant Index_t := Index_t (quality_Level * 4); -- Number of sides to the cylinder (divisible by 4): type Edge is -- A 'shaft' edge. record Fore : Site; Aft : Site; end record; type Edges is array (Index_t range 1 .. sides_Count) of Edge; type arch_Edges is array (Index_t range 1 .. quality_Level) of Sites (1 .. sides_Count); tmp, nx, ny, nz, start_nx, start_ny : Real; a : constant Real := Pi * 2.0 / Real (sides_Count); ca : constant Real := Cos (a); sa : constant Real := Sin (a); L : constant Real := Length * 0.5; the_Edges : Edges; the_shaft_Geometry : constant Geometry.lit_colored.view := Geometry.lit_colored.new_Geometry; cap_1_Geometry : Geometry.lit_colored.view; cap_2_Geometry : Geometry.lit_colored.view; begin -- Define capsule shaft, -- declare vertex_Count : constant Index_t := Index_t (sides_Count * 2 + 2); -- 2 triangles per side plus 2 since we cannot share the first and last edge. indices_Count : constant long_Index_t := long_Index_t (sides_Count * 2 * 3); -- 2 triangles per side with 3 vertices per triangle. the_Vertices : aliased Geometry.lit_colored.Vertex_array := (1 .. vertex_Count => <>); the_Indices : aliased Indices := (1 .. indices_Count => <>); begin ny := 1.0; nz := 0.0; -- Normal vector = (0.0, ny, nz) -- Set vertices. -- declare use linear_Algebra; S : Real := 0.0; S_delta : constant Real := 1.0 / Real (sides_Count); i : Index_t := 1; begin for Each in 1 .. Index_t (Edges'Length) loop the_Edges (Each).Fore (1) := ny * Radius; the_Edges (Each).Fore (2) := nz * Radius; the_Edges (Each).Fore (3) := L; the_Edges (Each).Aft (1) := ny * Radius; the_Edges (Each).Aft (2) := nz * Radius; the_Edges (Each).Aft (3) := -L; -- Rotate ny, nz. -- tmp := ca * ny - sa * nz; nz := sa * ny + ca * nz; ny := tmp; the_Vertices (i).Site := the_Edges (Each).Fore; the_Vertices (i).Normal := Normalised ((the_Vertices (i).Site (1), the_Vertices (i).Site (2), 0.0)); the_Vertices (i).Color := Self.Color; the_Vertices (i).Shine := 0.5; i := i + 1; the_Vertices (i).Site := the_Edges (Each).Aft; the_Vertices (i).Normal := the_Vertices (i - 1).Normal; the_Vertices (i).Color := Self.Color; the_Vertices (i).Shine := 0.5; i := i + 1; S := S + S_delta; end loop; the_Vertices (i).Site := the_Edges (1).Fore; the_Vertices (i).Normal := Normalised ((the_Vertices (i).Site (1), the_Vertices (i).Site (2), 0.0)); the_Vertices (i).Color := Self.Color; the_Vertices (i).Shine := 0.5; i := i + 1; the_Vertices (i).Site := the_Edges (1).Aft; the_Vertices (i).Normal := the_Vertices (i - 1).Normal; the_Vertices (i).Color := Self.Color; the_Vertices (i).Shine := 0.5; end; -- Set indices. -- declare i : long_Index_t := 1; Start : Index_t := 1; begin for Each in 1 .. long_Index_t (sides_Count) loop the_Indices (i) := Start; i := i + 1; the_Indices (i) := Start + 1; i := i + 1; the_Indices (i) := Start + 2; i := i + 1; the_Indices (i) := Start + 1; i := i + 1; the_Indices (i) := Start + 3; i := i + 1; the_Indices (i) := Start + 2; i := i + 1; Start := Start + 2; end loop; end; Vertices_are (the_shaft_Geometry.all, the_Vertices); declare the_Primitive : constant Primitive.indexed.view := Primitive.indexed.new_Primitive (primitive.Triangles, the_Indices); begin the_shaft_Geometry.add (Primitive.view (the_Primitive)); end; end; declare function new_Cap (is_Fore : Boolean) return Geometry.lit_colored.view is use linear_Algebra; cap_Geometry : constant Geometry.lit_colored.view := Geometry.lit_colored.new_Geometry; hoop_Count : constant Index_t := quality_Level; vertex_Count : constant Index_t := Index_t (Edges'Length * hoop_Count + 1); -- A vertex for each edge of each hoop, + 1 for the pole. indices_Count : constant long_Index_t := long_Index_t ( (hoop_count - 1) * sides_Count * 2 * 3 -- For each hoop, 2 triangles per side with 3 vertices per triangle + sides_Count * 3); -- plus the extra indices for the pole triangles. the_Vertices : aliased Geometry.lit_colored.Vertex_array := (1 .. vertex_Count => <>); the_Indices : aliased Indices := (1 .. indices_Count => <>); the_arch_Edges : arch_Edges; i : Index_t := 1; pole_Site : constant Site := (if is_Fore then (0.0, 0.0, L + Radius) else (0.0, 0.0, -L - Radius)); Degrees_90 : constant := Pi / 2.0; Degrees_360 : constant := Pi * 2.0; latitude_Count : constant := hoop_Count + 1; longitude_Count : constant := Edges'Length; latitude_Spacing : constant Real := Degrees_90 / Real (latitude_Count - 1); longitude_Spacing : constant Real := Degrees_360 / Real (longitude_Count); a, b : Real := 0.0; -- Angular 'cursors' used to track lat/long for texture coords. begin if not is_Fore then a := Degrees_360; end if; -- Set the vertices. -- start_nx := 0.0; start_ny := 1.0; for each_Hoop in 1 .. quality_Level loop -- Get n=start_n. -- nx := start_nx; ny := start_ny; nz := 0.0; for Each in 1 .. sides_Count loop the_arch_Edges (each_Hoop) (Each) (1) := ny * Radius; the_arch_Edges (each_Hoop) (Each) (2) := nz * Radius; the_arch_Edges (each_Hoop) (Each) (3) := (if is_Fore then nx * Radius + L else nx * Radius - L); -- Rotate ny, nz. -- tmp := ca * ny - sa * nz; nz := sa * ny + ca * nz; ny := tmp; the_Vertices (i).Site := the_arch_Edges (each_Hoop) (Each); the_Vertices (i).Normal := Normalised ((the_Vertices (i).Site (1), the_Vertices (i).Site (2), (if is_Fore then the_Vertices (i).Site (3) - L else the_Vertices (i).Site (3) + L))); the_Vertices (i).Color := Self.Color; the_Vertices (i).Shine := 0.5; i := i + 1; a := (if is_Fore then a + longitude_Spacing else a - longitude_Spacing); end loop; declare tmp : constant Real := start_nx; begin if is_Fore then start_nx := ca * start_nx + sa * start_ny; start_ny := -sa * tmp + ca * start_ny; else start_nx := ca * start_nx - sa * start_ny; start_ny := sa * tmp + ca * start_ny; end if; end; a := (if is_Fore then 0.0 else Degrees_360); b := b + latitude_Spacing; end loop; -- Add pole vertex. -- the_Vertices (i).Site := pole_Site; the_Vertices (i).Normal := Normalised (pole_Site); the_Vertices (i).Color := Self.Color; the_Vertices (i).Shine := 0.5; -- Set indices. -- declare i : long_Index_t := 1; Start : Index_t := 1; hoop_Start : Index_t := 1; pole_Index : constant Index_t := vertex_Count; begin for each_Hoop in 1 .. quality_Level loop for Each in 1 .. sides_Count loop declare function next_hoop_Vertex return Index_t is begin if Each = sides_Count then return hoop_Start; else return Start + 1; end if; end next_hoop_Vertex; begin if each_Hoop = quality_Level then if is_Fore then the_Indices (i) := Start; i := i + 1; the_Indices (i) := next_hoop_Vertex; i := i + 1; the_Indices (i) := pole_Index; i := i + 1; else the_Indices (i) := Start; i := i + 1; the_Indices (i) := pole_Index; i := i + 1; the_Indices (i) := next_hoop_Vertex; i := i + 1; end if; else declare v1 : constant Index_t := Start; v2 : constant Index_t := next_hoop_Vertex; v3 : constant Index_t := v1 + sides_Count; v4 : constant Index_t := v2 + sides_Count; begin if is_Fore then the_Indices (i) := v1; i := i + 1; the_Indices (i) := v2; i := i + 1; the_Indices (i) := v3; i := i + 1; the_Indices (i) := v2; i := i + 1; the_Indices (i) := v4; i := i + 1; the_Indices (i) := v3; i := i + 1; else the_Indices (i) := v1; i := i + 1; the_Indices (i) := v3; i := i + 1; the_Indices (i) := v2; i := i + 1; the_Indices (i) := v2; i := i + 1; the_Indices (i) := v3; i := i + 1; the_Indices (i) := v4; i := i + 1; end if; end; end if; Start := Start + 1; end; end loop; hoop_Start := hoop_Start + sides_Count; end loop; Vertices_are (cap_Geometry.all, the_Vertices); declare the_Primitive : constant Primitive.indexed.view := Primitive.indexed.new_Primitive (Primitive.Triangles, the_Indices); begin cap_Geometry.add (Primitive.view (the_Primitive)); end; end; return cap_Geometry; end new_Cap; begin cap_1_Geometry := new_Cap (is_Fore => True); cap_2_Geometry := new_Cap (is_Fore => False); end; return (1 => the_shaft_Geometry.all'Access, 2 => cap_1_Geometry.all'Access, 3 => cap_2_Geometry.all'Access); end to_GL_Geometries; end openGL.Model.capsule.lit_colored;
skill-lang/adaCommon
Ada
30,591
adb
-- ___ _ ___ _ _ -- -- / __| |/ (_) | | Common SKilL implementation -- -- \__ \ ' <| | | |__ file writer implementation -- -- |___/_|\_\_|_|____| by: Timm Felden -- -- -- pragma Ada_2012; with Ada.Text_IO; with Ada.Unchecked_Conversion; with Interfaces; with Skill.Containers.Vectors; with Skill.Field_Types.Builtin; with Skill.Field_Types.Builtin.String_Type_P; with Skill.Field_Declarations; use Skill.Field_Declarations; with Skill.Internal.Parts; with Skill.Streams.Reader; with Skill.Synchronization; with Skill.String_Pools; with Skill.Types.Pools; with Skill.Tasks; with Skill.Iterators.Type_Order; -- documentation can be found in java common -- this is a combination of serialization functions, write and append package body Skill.Internal.File_Writers is use type Types.Pools.Pool; -- offset calculation closure type Cl_Offset is new Tasks.Closure_T with record F : Skill.Field_Declarations.Field_Declaration; end record; type Cx_Offset is not null access Cl_Offset; function Cast is new Ada.Unchecked_Conversion (Skill.Tasks.Closure, Cx_Offset); -- write field closure type Cl_Write is new Tasks.Closure_T with record F : Skill.Field_Declarations.Field_Declaration; Map : Streams.Writer.Sub_Stream; end record; type Cx_Write is not null access Cl_Write; function Convert is new Ada.Unchecked_Conversion (Skill.Tasks.Closure, Cx_Write); -- write a file to disk procedure Write (State : Skill.Files.File; Output : Skill.Streams.Writer.Output_Stream) is String_Type : Skill.Field_Types.Builtin.String_Type_P.Field_Type := State.String_Type; Job_Failed_Concurrently : Boolean := False; procedure Make_LBPO_Map (P : Types.Pools.Pool; Lbpo_Map : in out Lbpo_Map_T; Next : Integer) is Pool : Types.Pools.Pool := P; Result : Integer := Next; begin while Pool /= null loop Lbpo_Map (Pool.Pool_Offset) := Result; Result := Result + Pool.Static_Size_With_Deleted; Pool := Pool.Next; end loop; end Make_LBPO_Map; procedure String (S : Types.String_Access) is begin Output.V64 (Types.v64 (String_Type.String_IDs.Element (S))); end String; procedure Write_Type (T : Field_Types.Field_Type) is begin Output.V64 (Types.v64 (T.ID)); case T.ID is when 0 => declare type X is access all Skill.Field_Types.Builtin.Constant_I8 .Field_Type; function Cast is new Ada.Unchecked_Conversion (Field_Types.Field_Type, X); begin Output.I8 (Cast (T).Value); end; when 1 => declare type X is access all Skill.Field_Types.Builtin.Constant_I16 .Field_Type; function Cast is new Ada.Unchecked_Conversion (Field_Types.Field_Type, X); begin Output.I16 (Cast (T).Value); end; when 2 => declare type X is access all Skill.Field_Types.Builtin.Constant_I32 .Field_Type; function Cast is new Ada.Unchecked_Conversion (Field_Types.Field_Type, X); begin Output.I32 (Cast (T).Value); end; when 3 => declare type X is access all Skill.Field_Types.Builtin.Constant_I64 .Field_Type; function Cast is new Ada.Unchecked_Conversion (Field_Types.Field_Type, X); begin Output.I64 (Cast (T).Value); end; when 4 => declare type X is access all Skill.Field_Types.Builtin.Constant_V64 .Field_Type; function Cast is new Ada.Unchecked_Conversion (Field_Types.Field_Type, X); begin Output.V64 (Cast (T).Value); end; when 15 => declare function Cast is new Ada.Unchecked_Conversion (Field_Types.Field_Type, Skill.Field_Types.Builtin.Const_Arrays_P.Field_Type); begin Output.V64 (Cast (T).Length); Write_Type (Cast (T).Base); end; when 17 => declare function Cast is new Ada.Unchecked_Conversion (Field_Types.Field_Type, Skill.Field_Types.Builtin.Var_Arrays_P.Field_Type); begin Write_Type (Cast (T).Base); end; when 18 => declare function Cast is new Ada.Unchecked_Conversion (Field_Types.Field_Type, Skill.Field_Types.Builtin.List_Type_P.Field_Type); begin Write_Type (Cast (T).Base); end; when 19 => declare function Cast is new Ada.Unchecked_Conversion (Field_Types.Field_Type, Skill.Field_Types.Builtin.Set_Type_P.Field_Type); begin Write_Type (Cast (T).Base); end; when 20 => declare function Cast is new Ada.Unchecked_Conversion (Field_Types.Field_Type, Skill.Field_Types.Builtin.Map_Type_P.Field_Type); begin Write_Type (Cast (T).Key); Write_Type (Cast (T).Value); end; when others => null; end case; end Write_Type; procedure Restrictions (S : Types.Pools.Pool) is begin -- todo Output.V64 (0); end Restrictions; procedure Restrictions (F : Field_Declaration) is begin -- todo Output.V64 (0); end Restrictions; -- index → bpo -- @note pools.par would not be possible if it were an actual Lbpo_Map : Lbpo_Map_T (0 .. Natural (State.Types.Length) - 1); -- barrier used for parallel processing Write_Barrier : Skill.Synchronization.Barrier; begin ---------------------- -- PHASE 1: Collect -- ---------------------- -- collect String instances from known string types; this is required, -- because we use plain strings -- @note this is a O(σ) operation:) -- @note we do not use generation time type info, because we want to treat -- generic fields as well declare Strings : Skill.String_Pools.Pool := State.Strings; procedure Add (This : Skill.Types.Pools.Pool) is procedure Add_Field (F : Field_Declarations.Field_Declaration) is Iter : aliased Skill.Iterators.Type_Order.Iterator; begin Strings.Add (F.Name); -- add string data if F.T.ID = 14 then Iter.Init (This); while Iter.Has_Next loop Strings.Add (Field_Types.Builtin.String_Type_P.Unboxed (Iter.Next.Dynamic.Reflective_Get (F))); end loop; end if; end Add_Field; begin Strings.Add (This.Skill_Name); This.Data_Fields.Foreach (Add_Field'Access); end Add; begin State.Types.Foreach (Add'Access); end; ------------------------------ -- PHASE 2: Check & Reorder -- ------------------------------ -- check consistency of the state, now that we aggregated all instances State.Check; -- make lbpo map, update data map to contain dynamic instances and create -- skill IDs for serialization declare procedure Make (This : Types.Pools.Pool) is function Cast is new Ada.Unchecked_Conversion (Types.Pools.Pool, Types.Pools.Base_Pool); begin if null = This.Super then This.Fixed (True); Make_LBPO_Map (This, Lbpo_Map, 0); Cast (This).Compress (Lbpo_Map); end if; end Make; begin State.Types.Foreach (Make'Access); end; -------------------- -- PHASE 3: Write -- -------------------- -- write string block State.Strings.Prepare_And_Write (Output, State.String_Type.String_IDs'Access); -- Calculate Offsets -- @note this has top happen after string IDs have been updated declare procedure Make (F : Field_Declaration) is procedure Calculate (C : Tasks.Closure) is begin Cast (C).F.Offset; Write_Barrier.Complete; exception when E : others => Job_Failed_Concurrently := True; Write_Barrier.Complete; Ada.Text_IO.Put_Line (Ada.Text_IO.Current_Error, "A task crashed during offset calculation: " & Cast (C).F.Name.all); end Calculate; T : Skill.Tasks.Run (Calculate'Access); C : Skill.Tasks.Closure := new Cl_Offset'(F => F); begin Write_Barrier.Start; T.Start (C); end Make; procedure Off (This : Types.Pools.Pool) is begin This.Data_Fields.Foreach (Make'Access); end Off; begin State.Types.Foreach (Off'Access); end; -- write count of the type block Output.V64 (Types.v64 (State.Types.Length)); -- write types declare use type Types.Pools.Pool; use type Interfaces.Integer_64; package A1 renames Field_Declarations.Field_Vector_P; Field_Queue : A1.Vector := A1.Empty_Vector; procedure Write_Type (This : Types.Pools.Pool) is Lcount : Types.v64 := Types.v64 (This.Blocks.Last_Element.Dynamic_Count); begin String (This.Skill_Name); Output.V64 (Lcount); Restrictions (This); if null = This.Super then Output.I8 (0); else Output.V64 (Types.v64 (This.Super.Pool_Offset + 1)); if 0 /= Lcount then Output.V64 (Types.v64 (Lbpo_Map (This.Pool_Offset))); end if; end if; Output.V64 (Types.v64 (This.Data_Fields.Length)); Field_Queue.Append_All (This.Data_Fields); end Write_Type; begin State.Types.Foreach (Write_Type'Access); -- await offsets before we can write fields Write_Barrier.Await; if Job_Failed_Concurrently then raise Program_Error with "internal error during offset calculation"; end if; -- write fields declare -- ArrayList<Task> data = new ArrayList<>(); End_Offset, Offset : Types.v64 := 0; procedure Write_Field (F : Field_Declaration) is P : Types.Pools.Pool := F.Owner.To_Pool; begin -- write info Output.V64 (Types.v64 (F.Index)); String (F.Name); Write_Type (F.T); Restrictions (F); End_Offset := Offset + F.Future_Offset; Output.V64 (End_Offset); -- update chunks and prepare write data F.Data_Chunks.Clear; F.Data_Chunks.Append (new Chunk_Entry_T' (C => new Skill.Internal.Parts.Bulk_Chunk' (Offset, 0, P.Size, 1), Input => Skill.Streams.Reader.Empty_Sub_Stream)); Offset := End_Offset; end Write_Field; begin Field_Queue.Foreach (Write_Field'Access); -- map field data Output.Begin_Block_Map (Offset); end; -- write field data declare procedure Write_Field (F : Field_Declarations.Field_Declaration) is procedure Job (C : Skill.Tasks.Closure) is begin Convert (C).F.Write (Convert (C).Map); Write_Barrier.Complete; pragma Assert (Convert (C).Map.Eof); Convert (C).Map.Close; exception when E : others => Job_Failed_Concurrently := True; Write_Barrier.Complete; Ada.Text_IO.Put_Line (Ada.Text_IO.Current_Error, "A task crashed during write data: " & Convert (C).F.Name.all); end Job; T : Skill.Tasks.Run (Job'Access); C : Skill.Tasks.Closure := new Cl_Write'(F => F, Map => Output.Map (F.Future_Offset)); begin Write_Barrier.Start; T.Start (C); end Write_Field; begin Field_Queue.Foreach (Write_Field'Access); -- await writing of actual field data Write_Barrier.Await; Output.End_Block_Map; if Job_Failed_Concurrently then raise Program_Error with "internal error during field write"; end if; end; end; -- we are done Output.Close; ----------------------- -- PHASE 4: Cleaning -- ----------------------- -- release data structures State.String_Type.String_IDs.Clear; -- unfix pools -- for (StoragePool<?, ?> p : state.types) { -- p.fixed(false); -- } -- } end Write; -------------------------------------------------------------------------------- ---------------------------------- APPEND -------------------------------------- -------------------------------------------------------------------------------- -- append a file to an existing one procedure Append (State : Skill.Files.File; Output : Skill.Streams.Writer.Output_Stream) is String_Type : Skill.Field_Types.Builtin.String_Type_P.Field_Type := State.String_Type; Job_Failed_Concurrently : Boolean := False; function Make_LBPO_Map (P : Types.Pools.Pool; Lbpo_Map : in out Lbpo_Map_T; Next : Integer) return Integer is Result : Integer := Next + P.Dynamic.New_Objects_Size; procedure Children (sub : Types.Pools.Sub_Pool) is begin Result := Make_LBPO_Map (sub.To_Pool, Lbpo_Map, Result); end Children; begin Lbpo_Map (P.Pool_Offset) := Next; P.Sub_Pools.Foreach (Children'Access); return Result; end Make_LBPO_Map; procedure String (S : Types.String_Access) is begin Output.V64 (Types.v64 (String_Type.String_IDs.Element (S))); end String; procedure Write_Type (T : Field_Types.Field_Type) is begin Output.V64 (Types.v64 (T.ID)); case T.ID is when 0 => declare type X is access all Skill.Field_Types.Builtin.Constant_I8 .Field_Type; function Cast is new Ada.Unchecked_Conversion (Field_Types.Field_Type, X); begin Output.I8 (Cast (T).Value); end; when 1 => declare type X is access all Skill.Field_Types.Builtin.Constant_I16 .Field_Type; function Cast is new Ada.Unchecked_Conversion (Field_Types.Field_Type, X); begin Output.I16 (Cast (T).Value); end; when 2 => declare type X is access all Skill.Field_Types.Builtin.Constant_I32 .Field_Type; function Cast is new Ada.Unchecked_Conversion (Field_Types.Field_Type, X); begin Output.I32 (Cast (T).Value); end; when 3 => declare type X is access all Skill.Field_Types.Builtin.Constant_I64 .Field_Type; function Cast is new Ada.Unchecked_Conversion (Field_Types.Field_Type, X); begin Output.I64 (Cast (T).Value); end; when 4 => declare type X is access all Skill.Field_Types.Builtin.Constant_V64 .Field_Type; function Cast is new Ada.Unchecked_Conversion (Field_Types.Field_Type, X); begin Output.V64 (Cast (T).Value); end; when 15 => declare function Cast is new Ada.Unchecked_Conversion (Field_Types.Field_Type, Skill.Field_Types.Builtin.Const_Arrays_P.Field_Type); begin Output.V64 (Cast (T).Length); Write_Type (Cast (T).Base); end; when 17 => declare function Cast is new Ada.Unchecked_Conversion (Field_Types.Field_Type, Skill.Field_Types.Builtin.Var_Arrays_P.Field_Type); begin Write_Type (Cast (T).Base); end; when 18 => declare function Cast is new Ada.Unchecked_Conversion (Field_Types.Field_Type, Skill.Field_Types.Builtin.List_Type_P.Field_Type); begin Write_Type (Cast (T).Base); end; when 19 => declare function Cast is new Ada.Unchecked_Conversion (Field_Types.Field_Type, Skill.Field_Types.Builtin.Set_Type_P.Field_Type); begin Write_Type (Cast (T).Base); end; when 20 => declare function Cast is new Ada.Unchecked_Conversion (Field_Types.Field_Type, Skill.Field_Types.Builtin.Map_Type_P.Field_Type); begin Write_Type (Cast (T).Key); Write_Type (Cast (T).Value); end; when others => null; end case; end Write_Type; procedure Restrictions (S : Types.Pools.Pool) is begin -- todo Output.V64 (0); end Restrictions; procedure Restrictions (F : Field_Declaration) is begin -- todo Output.V64 (0); end Restrictions; -- index of the first new pool New_Pool_Index : Natural := 0; -- index → bpo -- @note pools.par would not be possible if it were an actual Lbpo_Map : Lbpo_Map_T (0 .. Natural (State.Types.Length) - 1); Chunk_Map : Field_Declarations.Chunk_Map := new Chunk_Map_P.Map; -- relevant pools R_Pools : Skill.Types.Pools.Type_Vector := Types.Pools.P_Type_Vector.Empty_Vector; -- barrier used for parallel processing Write_Barrier : Skill.Synchronization.Barrier; begin ---------------------- -- PHASE 1: Collect -- ---------------------- -- collect String instances from known string types; this is required, -- because we use plain strings -- @note this is a O(σ) operation:) -- @note we do not use generation time type info, because we want to treat -- generic fields as well declare Strings : Skill.String_Pools.Pool := State.Strings; procedure Add (This : Skill.Types.Pools.Pool) is procedure Add_Field (F : Field_Declarations.Field_Declaration) is Iter : aliased Skill.Iterators.Type_Order.Iterator; begin Strings.Add (F.Name); -- add string data if F.T.ID = 14 then Iter.Init (This); while Iter.Has_Next loop Strings.Add (Field_Types.Builtin.String_Type_P.Unboxed (Iter.Next.Dynamic.Reflective_Get (F))); end loop; end if; end Add_Field; begin Strings.Add (This.Skill_Name); This.Data_Fields.Foreach (Add_Field'Access); end Add; begin State.Types.Foreach (Add'Access); end; ------------------------------ -- PHASE 2: Check & Reorder -- ------------------------------ -- check consistency of the state, now that we aggregated all instances State.Check; -- save the index of the first new pool declare T : Skill.Types.Pools.Type_Vector := State.Types; begin for I in 1 .. T.Length - 1 loop exit when T.Element (I - 1).Blocks.Is_Empty; New_Pool_Index := New_Pool_Index + 1; end loop; if not T.Last_Element.Blocks.Is_Empty then New_Pool_Index := Natural'Last; end if; end; -- make lbpo map, update data map to contain dynamic instances and create -- skill IDs for serialization declare procedure Make (This : Types.Pools.Pool) is function Cast is new Ada.Unchecked_Conversion (Types.Pools.Pool, Types.Pools.Base_Pool); R : Integer; begin if This.Dynamic.all in Types.Pools.Base_Pool_T'Class then This.Fixed (True); R := Make_LBPO_Map (This, Lbpo_Map, 0); Cast (This).Prepare_Append (Chunk_Map); end if; end Make; begin State.Types.Foreach (Make'Access); end; -- locate relevant pools R_Pools.Ensure_Index (State.Types.Length); declare procedure Find (P : Types.Pools.Pool) is begin -- new index? if P.Pool_Offset >= New_Pool_Index then R_Pools.Append (P); -- new instance or field? elsif P.Size > 0 then declare Ex : Boolean := False; procedure Exist (F : Field_Declaration) is begin if not Ex and then Chunk_Map.Contains (F) then Ex := True; end if; end Exist; begin P.Data_Fields.Foreach (Exist'Access); if Ex then R_Pools.Append (P); end if; end; end if; end Find; begin State.Types.Foreach (Find'Access); end; -------------------- -- PHASE 3: Write -- -------------------- -- write string block State.Strings.Prepare_And_Append (Output, State.String_Type.String_IDs'Access); -- Calculate Offsets -- @note this has top happen after string IDs have been updated declare procedure Make (F : Field_Declaration) is procedure Calculate (C : Tasks.Closure) is begin Cast (C).F.Offset; Write_Barrier.Complete; exception when E : others => Job_Failed_Concurrently := True; Write_Barrier.Complete; Ada.Text_IO.Put_Line (Ada.Text_IO.Current_Error, "A task crashed during offset calculation: " & Cast (C).F.Name.all); end Calculate; T : Skill.Tasks.Run (Calculate'Access); C : Skill.Tasks.Closure := new Cl_Offset'(F => F); begin Write_Barrier.Start; T.Start (C); end Make; use Chunk_Map_P; procedure Off (P : Cursor) is begin Make (Key (P)); end Off; begin Chunk_Map.Iterate (Off'Access); end; -- write count of the type block Output.V64 (Types.v64 (R_Pools.Length)); -- write types declare use type Types.Pools.Pool; use type Interfaces.Integer_64; package A1 renames Field_Declarations.Field_Vector_P; Field_Queue : A1.Vector := A1.Empty_Vector; procedure Write_Type (This : Types.Pools.Pool) is New_Pool : constant Boolean := This.Pool_Offset >= New_Pool_Index; Fields : Field_Vector := Field_Vector_P.Empty_Vector; Lcount : Types.v64 := Types.v64 (This.Blocks.Last_Element.Dynamic_Count); procedure Add (F : Field_Declaration) is begin if Chunk_Map.Contains (F) then Fields.Append (F); end if; end Add; begin Fields.Ensure_Index (This.Data_Fields.Length); This.Data_Fields.Foreach (Add'Access); if New_Pool or else (0 /= This.Data_Fields.Length and then This.Size > 0) then String (This.Skill_Name); Output.V64 (Lcount); if New_Pool then Restrictions (This); if null = This.Super then Output.I8 (0); else Output.V64 (Types.v64 (This.Super.Pool_Offset + 1)); if 0 /= Lcount then Output.V64 (Types.v64 (Lbpo_Map (This.Pool_Offset))); end if; end if; elsif null /= This.Super and then 0 /= Lcount then Output.V64 (Types.v64 (Lbpo_Map (This.Pool_Offset))); end if; if New_Pool and then 0 = Lcount then Output.I8 (0); else Output.V64 (Types.v64 (This.Data_Fields.Length)); Field_Queue.Append_All (This.Data_Fields); end if; end if; end Write_Type; begin R_Pools.Foreach (Write_Type'Access); -- await offsets before we can write fields Write_Barrier.Await; if Job_Failed_Concurrently then raise Program_Error with "internal error during offset calculation"; end if; -- write fields declare -- ArrayList<Task> data = new ArrayList<>(); End_Offset, Offset : Types.v64 := 0; procedure Write_Field (F : Field_Declaration) is P : Types.Pools.Pool := F.Owner.To_Pool; begin -- write info Output.V64 (Types.v64 (F.Index)); if F.Data_Chunks.Last_Element.C.all in Skill.Internal.Parts.Bulk_Chunk then String (F.Name); Write_Type (F.T); Restrictions (F); end if; End_Offset := Offset + F.Future_Offset; Output.V64 (End_Offset); Offset := End_Offset; end Write_Field; begin Field_Queue.Foreach (Write_Field'Access); -- map field data Output.Begin_Block_Map (Offset); end; -- write field data declare procedure Write_Field (F : Field_Declarations.Field_Declaration) is procedure Job (C : Skill.Tasks.Closure) is begin Convert (C).F.Write (Convert (C).Map); Write_Barrier.Complete; pragma Assert (Convert (C).Map.Eof); Convert (C).Map.Close; exception when E : others => Job_Failed_Concurrently := True; Write_Barrier.Complete; Ada.Text_IO.Put_Line (Ada.Text_IO.Current_Error, "A task crashed during write data: " & Convert (C).F.Name.all); end Job; T : Skill.Tasks.Run (Job'Access); C : Skill.Tasks.Closure := new Cl_Write'(F => F, Map => Output.Map (F.Future_Offset)); begin Write_Barrier.Start; T.Start (C); end Write_Field; begin Field_Queue.Foreach (Write_Field'Access); -- await writing of actual field data Write_Barrier.Await; Output.End_Block_Map; if Job_Failed_Concurrently then raise Program_Error with "internal error during field write"; end if; end; end; -- we are done Output.Close; ----------------------- -- PHASE 4: Cleaning -- ----------------------- -- release data structures State.String_Type.String_IDs.Clear; -- unfix pools -- for (StoragePool<?, ?> p : state.types) { -- p.fixed(false); -- } -- } end Append; end Skill.Internal.File_Writers;
AdaCore/gpr
Ada
1,921
adb
-- -- Copyright (C) 2019-2023, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 -- with Ada.Directories; with Ada.Text_IO; with Ada.Strings.Fixed; with GPR2.Project.View; with GPR2.Project.Tree; with GPR2.Project.Attribute.Set; with GPR2.Project.Variable.Set; with GPR2.Context; procedure Main is use Ada; use GPR2; use GPR2.Project; procedure Display (Prj : Project.View.Object; Full : Boolean := True); ------------- -- Display -- ------------- procedure Display (Prj : Project.View.Object; Full : Boolean := True) is use GPR2.Project.Attribute.Set; use GPR2.Project.Variable.Set.Set; begin Text_IO.Put (String (Prj.Name) & " "); Text_IO.Set_Col (10); Text_IO.Put_Line (Prj.Qualifier'Img); if Full then for A of Prj.Attributes (With_Defaults => False) loop Text_IO.Put ("A: " & Image (A.Name.Id.Attr)); Text_IO.Put (" ->"); for V of A.Values loop Text_IO.Put (" " & '"' & V.Text & '"'); end loop; Text_IO.New_Line; end loop; if Prj.Has_Variables then for V in Prj.Variables.Iterate loop Text_IO.Put ("V: " & String (Key (V))); Text_IO.Put (" ->"); for Val of Element (V).Values loop Text_IO.Put (" " & '"' & Val.Text & '"'); end loop; Text_IO.New_Line; end loop; end if; end if; end Display; Prj : Project.Tree.Object; Ctx : Context.Object; begin Project.Tree.Load (Prj, Create ("demo.gpr"), Ctx); Display (Prj.Root_Project); exception when GPR2.Project_Error => if Prj.Has_Messages then Text_IO.Put_Line ("Messages found:"); for M of Prj.Log_Messages.all loop Text_IO.Put_Line (M.Format); end loop; end if; end Main;
ytomino/vampire
Ada
768
adb
-- The Village of Vampire by YT, このソースコードはNYSLです with Ada.Streams.Stream_IO; with Serialization.YAML; with YAML.Streams; with Tabula.Casts.Cast_IO; function Tabula.Casts.Load (Name : String) return Cast_Collection is begin return Result : Cast_Collection do declare File : Ada.Streams.Stream_IO.File_Type := Ada.Streams.Stream_IO.Open (Ada.Streams.Stream_IO.In_File, Name => Name); begin declare Parser : aliased YAML.Parser := YAML.Streams.Create (Ada.Streams.Stream_IO.Stream (File)); begin Cast_IO.IO ( Serialization.YAML.Reading (Parser'Access, Cast_IO.Yaml_Type).Serializer, Result); YAML.Finish (Parser); end; Ada.Streams.Stream_IO.Close (File); end; end return; end Tabula.Casts.Load;
zhmu/ananas
Ada
393
ads
package Bit_Packed_Array6_Pkg is type Project_Kind is (K_Configuration, K_Abstract, K_Standard, K_Library, K_Aggregate, K_Aggregate_Library); type Projects_Kind is array (Project_Kind) of Boolean with Pack, Dynamic_Predicate => Projects_Kind /= (Project_Kind => False); Everywhere : constant Projects_Kind := (others => True); end Bit_Packed_Array6_Pkg;
charlie5/lace
Ada
2,281
adb
with openGL.Model, openGL.Visual, openGL.Light, openGL.Demo; procedure launch_render_Screenshot -- -- Take a screenshot. -- is use openGL, openGL.Math, openGL.linear_Algebra_3d; begin Demo.print_Usage ("Use 't' or 'T' to take a screenshot."); Demo.define ("openGL 'Render Screenshot' Demo"); Demo.Camera.Position_is ([0.0, 2.0, 10.0], y_Rotation_from (to_Radians (0.0))); declare the_Light : openGL.Light.item := Demo.Renderer.new_Light; begin the_Light.Site_is ([5_000.0, 2_000.0, 5_000.0]); Demo.Renderer.set (the_Light); end; declare -- The models. -- the_Models : constant openGL.Model.views := openGL.Demo.Models; -- The visuals. -- use openGL.Visual.Forge; the_Visuals : openGL.Visual.views (the_Models'Range); Current : Integer := the_Visuals'First; begin for i in the_Visuals'Range loop the_Visuals (i) := new_Visual (the_Models (i)); end loop; -- Main loop. -- while not Demo.Done loop Demo.Dolly.evolve; Demo.Done := Demo.Dolly.quit_Requested; declare Command : Character; Avail : Boolean; begin Demo.Dolly.get_last_Character (Command, Avail); if Avail then case Command is when ' ' => if Current = the_Visuals'Last then Current := the_Visuals'First; else Current := Current + 1; end if; when 't' | 'T' => Demo.Renderer.Screenshot ("sshot.bmp"); when others => null; end case; end if; end; -- Render all visuals. -- Demo.Camera.render ([1 => the_Visuals (Current)]); while not Demo.Camera.cull_Completed loop delay Duration'Small; end loop; Demo.Renderer.render; Demo.FPS_Counter.increment; -- Frames per second display. end loop; end; Demo.destroy; end launch_render_Screenshot;
MinimSecure/unum-sdk
Ada
1,218
ads
-- Copyright 2013-2019 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. package Pck is Global_Float : Float := 0.0; Global_Double : Long_Float := 0.0; Global_Long_Double : Long_Long_Float := 0.0; type Small_Struct is record I : Integer; end record; Global_Small_Struct : Small_Struct := (I => 0); procedure Set_Float (F : Float); procedure Set_Double (Dummy : Integer; D : Long_Float); procedure Set_Long_Double (Dummy : Integer; DS: Small_Struct; LD : Long_Long_Float); end Pck;
mgrojo/smk
Ada
7,727
adb
-- ----------------------------------------------------------------------------- -- smk, the smart make -- © 2018 Lionel Draghi <[email protected]> -- SPDX-License-Identifier: APSL-2.0 -- ----------------------------------------------------------------------------- -- 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: Smk.Makefiles body -- -- Implementation Notes: -- -- Portability Issues: -- -- Anticipated Changes: -- ----------------------------------------------------------------------------- with Ada.Characters.Latin_1; with Ada.Directories; with Ada.Strings.Fixed; with Ada.Strings.Maps.Constants; with Ada.Text_IO; use Ada.Text_IO; with Smk.IO; package body Smk.Makefiles is Debug : constant Boolean := False; Prefix : constant String := " smk-makefile.adb "; use Ada.Strings; use Ada.Strings.Fixed; Current_Section : Run_Files.Section_Names := Run_Files.Default_Section; use Ada.Strings.Maps; use Ada.Strings.Maps.Constants; Whitespace_Set : constant Ada.Strings.Maps.Character_Set := Ada.Strings.Maps.To_Set (Ada.Characters.Latin_1.HT & Ada.Characters.Latin_1.Space & "@"); Identifier_Set : constant Ada.Strings.Maps.Character_Set := Alphanumeric_Set or To_Set (".-_"); -- -------------------------------------------------------------------------- function Is_Empty (Line : in String) return Boolean is (Index_Non_Blank (Line) = 0); -- -------------------------------------------------------------------------- function Is_A_Comment (Line : in String) return Boolean is begin return Head (Line, Count => 1) = "#" or else -- Shell style comment Head (Line, Count => 2) = "--" or else -- Ada style comment Head (Line, Count => 2) = "//"; -- Java style comment end Is_A_Comment; -- -------------------------------------------------------------------------- function Is_A_Section (Line : in String) return Boolean is -- A section line is an identifier followed by a semicolon. -- NB: this function updates the global Current_Section variable First : Positive; Last : Natural; begin Find_Token (Source => Line, Set => Identifier_Set, Test => Inside, First => First, Last => Last); if Last = 0 then return False; -- The line don't start with an identifier, can't be a section else IO.Put_Debug_Line (Line (First .. Last) & "<", Debug, Prefix); if Index (Source => Line, Pattern => ":", From => Last + 1, Going => Forward) /= 0 then Current_Section := +(Line (First .. Last)); return True; else return False; end if; end if; end Is_A_Section; -- -------------------------------------------------------------------------- procedure Analyze (Makefile_Name : in String; Line_List : out Makefile) is Make_Fl : Ada.Text_IO.File_Type; Entry_List : Makefile_Entry_Lists.List; begin Open (Make_Fl, Mode => In_File, Name => Makefile_Name); Analysis : while not End_Of_File (Make_Fl) loop declare --Line : constant String := Trim (Get_Line (Make_Fl), Side => Both); Raw_Line : constant String := Get_Line (Make_Fl); First_Non_Blank : constant Natural := Index (Source => Raw_Line, Set => Whitespace_Set, Test => Outside); Line : constant String := Raw_Line (Natural'Max (1, First_Non_Blank) .. Raw_Line'Last); -- Line = Get_Line, but heading blanks or tabs character are removed -- If there is not heading blank, First_Non_Blank will be null, -- and Line will start at 1. Line_Nb : constant Integer := Integer (Ada.Text_IO.Line (Make_Fl)); begin if Is_A_Comment (Line) then IO.Put_Debug_Line (Line & "<", Debug => Debug, Prefix => Prefix & "Comment >", File => Makefile_Name, Line => Line_Nb); elsif Is_Empty (Line) then IO.Put_Debug_Line (Line & "<", Debug => Debug, Prefix => Prefix & "Empty line >", File => Makefile_Name, Line => Line_Nb); elsif Is_A_Section (Line) then IO.Put_Debug_Line (+Current_Section & "<", Debug => Debug, Prefix => Prefix & "Section >", File => Makefile_Name, Line => Line_Nb); else -- Last but not least, it's a command line. declare -- First : Positive; -- Last : Natural; begin -- -- Let's go to the first Identifier -- Find_Token (Source => Line, -- Set => Whitespace_Set, -- Test => Outside, -- First => First, -- Last => Last); IO.Put_Debug_Line (Line -- (First .. Line'Last) & "<", Debug => Debug, Prefix => Prefix & "Command >", File => Makefile_Name, Line => Line_Nb); Entry_List.Append ((Line => Line_Nb - 1, -- why -1 ??? Section => Current_Section, Command => +(Line), -- (First .. Line'Last)), Already_Run => False)); end; end if; end; end loop Analysis; Close (Make_Fl); declare use Ada.Directories; begin Line_List := (Name => +Makefile_Name, Time_Tag => Modification_Time (Makefile_Name), Entries => Entry_List); end; end Analyze; -- -------------------------------------------------------------------------- procedure Dump (The_Make_File : in Makefile) is Time_Tag : constant String := IO.Image (The_Make_File.Time_Tag); begin IO.Put_Line (+The_Make_File.Name & " (" & Time_Tag & ") :"); for E of The_Make_File.Entries loop IO.Put_Line (Trim (Positive'Image (E.Line), Left) & ": [" & (+E.Section) & "] " & (+E.Command)); end loop; end Dump; end Smk.Makefiles;
AdaCore/training_material
Ada
702
adb
with Ada.Text_IO; use Ada.Text_IO; procedure Main is -- hard-coded filename Filename : constant String := "main.adb"; File : File_Type; Line : String (1 .. 100); Last : Natural; -- store object names here Comments : Natural := 0; Semicolons : Natural := 0; begin Open (File, In_File, Filename); while not End_Of_File (File) loop Get_Line (File, Line, Last); -- Count comments -- Count semicolons -- Store the object name if one is found end loop; Close (File); Put_Line ("Comments: " & Integer'image (Comments)); Put_Line ("Semi-colons: " & Integer'image (Semicolons)); Put_Line ("Objects: "); -- Print objects end Main;
flyx/OpenGLAda
Ada
256
ads
-- part of OpenGLAda, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "COPYING" function GL.API.Subprogram_Reference (Function_Name : String) return System.Address; pragma Preelaborate (GL.API.Subprogram_Reference);
reznikmm/matreshka
Ada
11,879
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$ ------------------------------------------------------------------------------ with AMF.Internals.UML_Named_Elements; with AMF.UML.Classifiers.Collections; with AMF.UML.Dependencies.Collections; with AMF.UML.Extension_Points; with AMF.UML.Named_Elements; with AMF.UML.Namespaces; with AMF.UML.Packages.Collections; with AMF.UML.Redefinable_Elements.Collections; with AMF.UML.String_Expressions; with AMF.UML.Use_Cases; with AMF.Visitors; package AMF.Internals.UML_Extension_Points is type UML_Extension_Point_Proxy is limited new AMF.Internals.UML_Named_Elements.UML_Named_Element_Proxy and AMF.UML.Extension_Points.UML_Extension_Point with null record; overriding function Get_Use_Case (Self : not null access constant UML_Extension_Point_Proxy) return AMF.UML.Use_Cases.UML_Use_Case_Access; -- Getter of ExtensionPoint::useCase. -- -- References the use case that owns this extension point. overriding procedure Set_Use_Case (Self : not null access UML_Extension_Point_Proxy; To : AMF.UML.Use_Cases.UML_Use_Case_Access); -- Setter of ExtensionPoint::useCase. -- -- References the use case that owns this extension point. overriding function Get_Is_Leaf (Self : not null access constant UML_Extension_Point_Proxy) return Boolean; -- Getter of RedefinableElement::isLeaf. -- -- Indicates whether it is possible to further redefine a -- RedefinableElement. If the value is true, then it is not possible to -- further redefine the RedefinableElement. Note that this property is -- preserved through package merge operations; that is, the capability to -- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in -- the resulting RedefinableElement of a package merge operation where a -- RedefinableElement with isLeaf=false is merged with a matching -- RedefinableElement with isLeaf=true: the resulting RedefinableElement -- will have isLeaf=false. Default value is false. overriding procedure Set_Is_Leaf (Self : not null access UML_Extension_Point_Proxy; To : Boolean); -- Setter of RedefinableElement::isLeaf. -- -- Indicates whether it is possible to further redefine a -- RedefinableElement. If the value is true, then it is not possible to -- further redefine the RedefinableElement. Note that this property is -- preserved through package merge operations; that is, the capability to -- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in -- the resulting RedefinableElement of a package merge operation where a -- RedefinableElement with isLeaf=false is merged with a matching -- RedefinableElement with isLeaf=true: the resulting RedefinableElement -- will have isLeaf=false. Default value is false. overriding function Get_Redefined_Element (Self : not null access constant UML_Extension_Point_Proxy) return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element; -- Getter of RedefinableElement::redefinedElement. -- -- The redefinable element that is being redefined by this element. overriding function Get_Redefinition_Context (Self : not null access constant UML_Extension_Point_Proxy) return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier; -- Getter of RedefinableElement::redefinitionContext. -- -- References the contexts that this element may be redefined from. overriding function Get_Client_Dependency (Self : not null access constant UML_Extension_Point_Proxy) return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency; -- Getter of NamedElement::clientDependency. -- -- Indicates the dependencies that reference the client. overriding function Get_Name_Expression (Self : not null access constant UML_Extension_Point_Proxy) return AMF.UML.String_Expressions.UML_String_Expression_Access; -- Getter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding procedure Set_Name_Expression (Self : not null access UML_Extension_Point_Proxy; To : AMF.UML.String_Expressions.UML_String_Expression_Access); -- Setter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding function Get_Namespace (Self : not null access constant UML_Extension_Point_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Getter of NamedElement::namespace. -- -- Specifies the namespace that owns the NamedElement. overriding function Get_Qualified_Name (Self : not null access constant UML_Extension_Point_Proxy) return AMF.Optional_String; -- Getter of NamedElement::qualifiedName. -- -- A name which allows the NamedElement to be identified within a -- hierarchy of nested Namespaces. It is constructed from the names of the -- containing namespaces starting at the root of the hierarchy and ending -- with the name of the NamedElement itself. overriding function Is_Consistent_With (Self : not null access constant UML_Extension_Point_Proxy; Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access) return Boolean; -- Operation RedefinableElement::isConsistentWith. -- -- The query isConsistentWith() specifies, for any two RedefinableElements -- in a context in which redefinition is possible, whether redefinition -- would be logically consistent. By default, this is false; this -- operation must be overridden for subclasses of RedefinableElement to -- define the consistency conditions. overriding function Is_Redefinition_Context_Valid (Self : not null access constant UML_Extension_Point_Proxy; Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access) return Boolean; -- Operation RedefinableElement::isRedefinitionContextValid. -- -- The query isRedefinitionContextValid() specifies whether the -- redefinition contexts of this RedefinableElement are properly related -- to the redefinition contexts of the specified RedefinableElement to -- allow this element to redefine the other. By default at least one of -- the redefinition contexts of this element must be a specialization of -- at least one of the redefinition contexts of the specified element. overriding function All_Owning_Packages (Self : not null access constant UML_Extension_Point_Proxy) return AMF.UML.Packages.Collections.Set_Of_UML_Package; -- Operation NamedElement::allOwningPackages. -- -- The query allOwningPackages() returns all the directly or indirectly -- owning packages. overriding function Is_Distinguishable_From (Self : not null access constant UML_Extension_Point_Proxy; N : AMF.UML.Named_Elements.UML_Named_Element_Access; Ns : AMF.UML.Namespaces.UML_Namespace_Access) return Boolean; -- Operation NamedElement::isDistinguishableFrom. -- -- The query isDistinguishableFrom() determines whether two NamedElements -- may logically co-exist within a Namespace. By default, two named -- elements are distinguishable if (a) they have unrelated types or (b) -- they have related types but different names. overriding function Namespace (Self : not null access constant UML_Extension_Point_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Operation NamedElement::namespace. -- -- Missing derivation for NamedElement::/namespace : Namespace overriding procedure Enter_Element (Self : not null access constant UML_Extension_Point_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Leave_Element (Self : not null access constant UML_Extension_Point_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Visit_Element (Self : not null access constant UML_Extension_Point_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of iterator interface. end AMF.Internals.UML_Extension_Points;
kontena/ruby-packer
Ada
7,874
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- Sample.Function_Key_Setting -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998-2009,2011 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, 1996 -- Version Control -- $Revision: 1.15 $ -- $Date: 2011/03/23 00:44:12 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ with Ada.Unchecked_Deallocation; with Sample.Manifest; use Sample.Manifest; -- This package implements a simple stack of function key label environments. -- package body Sample.Function_Key_Setting is Max_Label_Length : constant Positive := 8; Number_Of_Keys : Label_Number := Label_Number'Last; Justification : Label_Justification := Left; subtype Label is String (1 .. Max_Label_Length); type Label_Array is array (Label_Number range <>) of Label; type Key_Environment (N : Label_Number := Label_Number'Last); type Env_Ptr is access Key_Environment; pragma Controlled (Env_Ptr); type String_Access is access String; pragma Controlled (String_Access); Active_Context : String_Access := new String'("MAIN"); Active_Notepad : Panel := Null_Panel; type Key_Environment (N : Label_Number := Label_Number'Last) is record Prev : Env_Ptr; Help : String_Access; Notepad : Panel; Labels : Label_Array (1 .. N); end record; procedure Release_String is new Ada.Unchecked_Deallocation (String, String_Access); procedure Release_Environment is new Ada.Unchecked_Deallocation (Key_Environment, Env_Ptr); Top_Of_Stack : Env_Ptr := null; procedure Push_Environment (Key : String; Reset : Boolean := True) is P : constant Env_Ptr := new Key_Environment (Number_Of_Keys); begin -- Store the current labels in the environment for I in 1 .. Number_Of_Keys loop Get_Soft_Label_Key (I, P.all.Labels (I)); if Reset then Set_Soft_Label_Key (I, " "); end if; end loop; P.all.Prev := Top_Of_Stack; -- now store active help context and notepad P.all.Help := Active_Context; P.all.Notepad := Active_Notepad; -- The notepad must now vanish and the new notepad is empty. if P.all.Notepad /= Null_Panel then Hide (P.all.Notepad); Update_Panels; end if; Active_Notepad := Null_Panel; Active_Context := new String'(Key); Top_Of_Stack := P; if Reset then Refresh_Soft_Label_Keys_Without_Update; end if; end Push_Environment; procedure Pop_Environment is P : Env_Ptr := Top_Of_Stack; begin if Top_Of_Stack = null then raise Function_Key_Stack_Error; else for I in 1 .. Number_Of_Keys loop Set_Soft_Label_Key (I, P.all.Labels (I), Justification); end loop; pragma Assert (Active_Context /= null); Release_String (Active_Context); Active_Context := P.all.Help; Refresh_Soft_Label_Keys_Without_Update; Notepad_To_Context (P.all.Notepad); Top_Of_Stack := P.all.Prev; Release_Environment (P); end if; end Pop_Environment; function Context return String is begin if Active_Context /= null then return Active_Context.all; else return ""; end if; end Context; function Find_Context (Key : String) return Boolean is P : Env_Ptr := Top_Of_Stack; begin if Active_Context.all = Key then return True; else loop exit when P = null; if P.all.Help.all = Key then return True; else P := P.all.Prev; end if; end loop; return False; end if; end Find_Context; procedure Notepad_To_Context (Pan : Panel) is W : Window; begin if Active_Notepad /= Null_Panel then W := Get_Window (Active_Notepad); Clear (W); Delete (Active_Notepad); Delete (W); end if; Active_Notepad := Pan; if Pan /= Null_Panel then Top (Pan); end if; Update_Panels; Update_Screen; end Notepad_To_Context; procedure Initialize (Mode : Soft_Label_Key_Format := PC_Style; Just : Label_Justification := Left) is begin case Mode is when PC_Style .. PC_Style_With_Index => Number_Of_Keys := 12; when others => Number_Of_Keys := 8; end case; Init_Soft_Label_Keys (Mode); Justification := Just; end Initialize; procedure Default_Labels is begin Set_Soft_Label_Key (FKEY_QUIT, "Quit"); Set_Soft_Label_Key (FKEY_HELP, "Help"); Set_Soft_Label_Key (FKEY_EXPLAIN, "Keys"); Refresh_Soft_Label_Keys_Without_Update; end Default_Labels; function Notepad_Window return Window is begin if Active_Notepad /= Null_Panel then return Get_Window (Active_Notepad); else return Null_Window; end if; end Notepad_Window; end Sample.Function_Key_Setting;
adamnemecek/GA_Ada
Ada
2,754
adb
with Ada.Exceptions; use Ada.Exceptions; with Ada.Text_IO; use Ada.Text_IO; with E3GA; with GA_Maths; with Multivector_Type; package body Multivector_Analyze_C3GA is procedure Analyze (theAnalysis : in out MV_Analysis; MV : Multivector.Multivector; Probe : C3GA.Normalized_Point; Flags : Flag_Type := (Flag_Invalid, false); Epsilon : float := Default_Epsilon) is use Multivector_Analyze; use Multivector_Type; use GA_Maths; MV_X : Multivector.Multivector := MV; -- MV_Info : E2GA.MV_Type; MV_Info : Multivector_Type.MV_Type_Record; Analysis : MV_Analysis; procedure Classify is -- OP_Nix : Boolean; begin null; end Classify; begin Analysis.M_Flags.Valid := True; Analysis.Epsilon := Epsilon; Analysis.M_Type.Model_Kind := Multivector_Analyze.Conformal_Model; if Flags.Dual then Put_Line ("Multivector_Analyze_C3GA.Analyze Is Dual."); Analysis.M_Flags.Dual := True; -- MV_X := C3GA.Dual (MV_X); end if; -- MV_Info := C3GA.Init (MV_X, Epsilon); MV_Info := Init (MV_X); Analysis.M_MV_Type := MV_Info; -- Analysis.M_Type.Multivector_Kind := MV_Info.M_Type; -- Check for zero blade -- if Analysis.M_MV_Type.M_Zero then if Zero (Analysis.M_MV_Type) then Put_Line ("Multivector_Analyze_E2GA.Analyze Zero_Blade."); Analysis.M_Type.Blade_Class := Zero_Blade; Analysis.M_Scalors (1) := 0.0; elsif MV_Kind (Analysis.M_MV_Type) = Versor_MV then Put_Line ("Multivector_Analyze_C3GA.Analyze Versor_Object 2."); Analysis.M_Type.Blade_Subclass := Even_Versor_Subclass; Analysis.M_Vectors (1) := E3GA.e1; elsif Grade_Use (Analysis.M_MV_Type) = 1 then -- Grade 0 Put_Line ("Multivector_Analyze_E2GA.Analyze Grade_Use = 1."); Analysis.M_Type.Blade_Class := Scalar_Blade; Analysis.M_Type.M_Grade := 1; -- Analysis.M_Scalors (1) := MV_X.Coordinates (1); elsif Grade_Use (Analysis.M_MV_Type) = 6 then -- Grade 5 Put_Line ("Multivector_Analyze_E2GA.Analyze Grade_Use = 6."); Analysis.M_Type.Blade_Class := Scalar_Blade; Analysis.M_Type.M_Grade := 6; Analysis.M_Scalors (1) := C3GA.NO_E1_E2_E3_NI (MV); else Classify; -- TO BE COMPLETED Put_Line ("Multivector_Analyze_C3GA.Analyze Multivector Type."); end if; exception when anError : others => Put_Line ("An exception occurred in Multivector_Analyze_C3GA.Analyze."); raise; end Analyze; end Multivector_Analyze_C3GA;
burratoo/Acton
Ada
3,138
ads
------------------------------------------------------------------------------------------ -- -- -- OAK CORE SUPPORT PACKAGE -- -- ARM ARM7TDMI -- -- -- -- ISA.ARM.ARM7TDMI -- -- -- -- Copyright (C) 2014-2021, Patrick Bernardi -- -- -- ------------------------------------------------------------------------------------------ package ISA.ARM.ARM7TDMI with Pure is type Instruction_Mode is (ARM, Thumb); type Mode_Bits is (User, FIQ, IRQ, Supervisor, Abort_Mode, Undefined, System_Mode); type Status_Type is record Mode : Mode_Bits; State : Instruction_Mode; FIQ_Disable : Boolean; IRQ_Disable : Boolean; Overflow : Boolean; Carry : Boolean; Zero : Boolean; Negative_Less_Than : Boolean; end record; for Mode_Bits use (User => 2#10000#, FIQ => 2#10001#, IRQ => 2#10010#, Supervisor => 2#10011#, Abort_Mode => 2#10111#, Undefined => 2#11011#, System_Mode => 2#11111#); for Status_Type use record Mode at 0 range 0 .. 4; State at 0 range 5 .. 5; FIQ_Disable at 0 range 6 .. 6; IRQ_Disable at 0 range 7 .. 7; Overflow at 0 range 28 .. 28; Carry at 0 range 29 .. 29; Zero at 0 range 30 .. 30; Negative_Less_Than at 0 range 31 .. 31; end record; -- Ensure these are inlined procedure Set_Mode (New_Mode : Mode_Bits) with Inline_Always; function Current_Program_Status_Register return Status_Type with Inline_Always; function Saved_Program_Status_Register return Status_Type with Inline_Always; procedure Set_Current_Program_Status_Register (New_Value : in Status_Type) with Inline_Always; procedure Switch_To_Supervisor_Mode with Inline_Always; -- Switches to Supervisor Mode with interrupts disabled procedure Switch_To_System_Mode with Inline_Always; -- Switches to System Mode with interrupts disabled procedure Switch_To_IRQ_Mode with Inline_Always; -- Switches to IRQ Mode with interrupts disabled procedure Switch_To_FIQ_Mode with Inline_Always; -- Switches to FIQ Mode with interrupts disabled -- Ensure these are not inlined procedure Disable_All_Interrupts; procedure Enable_All_Interrupts; end ISA.ARM.ARM7TDMI;
stcarrez/ada-util
Ada
17,654
adb
----------------------------------------------------------------------- -- util-serialize-io-csv -- CSV Serialization Driver -- Copyright (C) 2011, 2015, 2016, 2017, 2021, 2022 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.Strings.Unbounded; with Ada.Characters.Latin_1; with Ada.IO_Exceptions; with Ada.Containers; with Util.Strings; with Util.Dates.ISO8601; package body Util.Serialize.IO.CSV is -- ------------------------------ -- Set the field separator. The default field separator is the comma (','). -- ------------------------------ procedure Set_Field_Separator (Stream : in out Output_Stream; Separator : in Character) is begin Stream.Separator := Separator; end Set_Field_Separator; -- ------------------------------ -- Enable or disable the double quotes by default for strings. -- ------------------------------ procedure Set_Quotes (Stream : in out Output_Stream; Enable : in Boolean) is begin Stream.Quote := Enable; end Set_Quotes; -- ------------------------------ -- Write the value as a CSV cell. Special characters are escaped using the CSV -- escape rules. -- ------------------------------ procedure Write_Cell (Stream : in out Output_Stream; Value : in String) is begin if Stream.Column > 1 then Stream.Write (Stream.Separator); end if; Stream.Column := Stream.Column + 1; if Stream.Quote then Stream.Write ('"'); end if; for I in Value'Range loop if Value (I) = '"' then Stream.Write (""""""); else Stream.Write (Value (I)); end if; end loop; if Stream.Quote then Stream.Write ('"'); end if; end Write_Cell; procedure Write_Cell (Stream : in out Output_Stream; Value : in Integer) is begin if Stream.Column > 1 then Stream.Write (Stream.Separator); end if; Stream.Column := Stream.Column + 1; Stream.Write (Util.Strings.Image (Value)); end Write_Cell; procedure Write_Cell (Stream : in out Output_Stream; Value : in Boolean) is begin if Stream.Column > 1 then Stream.Write (Stream.Separator); end if; Stream.Column := Stream.Column + 1; if Value then Stream.Write ("true"); else Stream.Write ("false"); end if; end Write_Cell; procedure Write_Cell (Stream : in out Output_Stream; Value : in Util.Beans.Objects.Object) is use Util.Beans.Objects; begin case Util.Beans.Objects.Get_Type (Value) is when TYPE_NULL => if Stream.Column > 1 then Stream.Write (Stream.Separator); end if; Stream.Column := Stream.Column + 1; if Stream.Quote then Stream.Write ("""null"""); else Stream.Write ("null"); end if; when TYPE_BOOLEAN => if Stream.Column > 1 then Stream.Write (Stream.Separator); end if; Stream.Column := Stream.Column + 1; if Util.Beans.Objects.To_Boolean (Value) then Stream.Write ("true"); else Stream.Write ("false"); end if; when TYPE_INTEGER => if Stream.Column > 1 then Stream.Write (Stream.Separator); end if; Stream.Column := Stream.Column + 1; -- Stream.Write ('"'); Stream.Write (Util.Beans.Objects.To_Long_Long_Integer (Value)); -- Stream.Write ('"'); when others => Stream.Write_Cell (Util.Beans.Objects.To_String (Value)); end case; end Write_Cell; -- ------------------------------ -- Start a new row. -- ------------------------------ procedure New_Row (Stream : in out Output_Stream) is begin while Stream.Column < Stream.Max_Columns loop Stream.Write (Stream.Separator); Stream.Column := Stream.Column + 1; end loop; Stream.Write (ASCII.CR); Stream.Write (ASCII.LF); Stream.Column := 1; Stream.Row := Stream.Row + 1; end New_Row; -- ----------------------- -- Write the attribute name/value pair. -- ----------------------- overriding procedure Write_Attribute (Stream : in out Output_Stream; Name : in String; Value : in String) is pragma Unreferenced (Name); begin Stream.Write_Cell (Value); end Write_Attribute; overriding procedure Write_Wide_Attribute (Stream : in out Output_Stream; Name : in String; Value : in Wide_Wide_String) is begin null; end Write_Wide_Attribute; overriding procedure Write_Attribute (Stream : in out Output_Stream; Name : in String; Value : in Integer) is pragma Unreferenced (Name); begin Stream.Write_Cell (Value); end Write_Attribute; overriding procedure Write_Attribute (Stream : in out Output_Stream; Name : in String; Value : in Boolean) is pragma Unreferenced (Name); begin Stream.Write_Cell (Value); end Write_Attribute; overriding procedure Write_Attribute (Stream : in out Output_Stream; Name : in String; Value : in Util.Beans.Objects.Object) is pragma Unreferenced (Name); begin Stream.Write_Cell (Value); end Write_Attribute; overriding procedure Write_Entity (Stream : in out Output_Stream; Name : in String; Value : in Util.Beans.Objects.Object) is pragma Unreferenced (Name); begin Stream.Write_Cell (Value); end Write_Entity; -- ----------------------- -- Write the entity value. -- ----------------------- overriding procedure Write_Entity (Stream : in out Output_Stream; Name : in String; Value : in String) is pragma Unreferenced (Name); begin Stream.Write_Cell (Value); end Write_Entity; overriding procedure Write_Wide_Entity (Stream : in out Output_Stream; Name : in String; Value : in Wide_Wide_String) is begin null; end Write_Wide_Entity; overriding procedure Write_Entity (Stream : in out Output_Stream; Name : in String; Value : in Boolean) is pragma Unreferenced (Name); begin Stream.Write_Cell (Value); end Write_Entity; overriding procedure Write_Entity (Stream : in out Output_Stream; Name : in String; Value : in Integer) is pragma Unreferenced (Name); begin Stream.Write_Cell (Value); end Write_Entity; overriding procedure Write_Entity (Stream : in out Output_Stream; Name : in String; Value : in Ada.Calendar.Time) is begin Stream.Write_Entity (Name, Util.Dates.ISO8601.Image (Value, Util.Dates.ISO8601.SUBSECOND)); end Write_Entity; overriding procedure Write_Long_Entity (Stream : in out Output_Stream; Name : in String; Value : in Long_Long_Integer) is begin Stream.Write_Entity (Name, Long_Long_Integer'Image (Value)); end Write_Long_Entity; overriding procedure Write_Long_Entity (Stream : in out Output_Stream; Name : in String; Value : in Long_Long_Float) is begin Stream.Write_Entity (Name, Long_Long_Float'Image (Value)); end Write_Long_Entity; overriding procedure Write_Enum_Entity (Stream : in out Output_Stream; Name : in String; Value : in String) is begin Stream.Write_Entity (Name, Value); end Write_Enum_Entity; -- ------------------------------ -- Write the attribute with a null value. -- ------------------------------ overriding procedure Write_Null_Attribute (Stream : in out Output_Stream; Name : in String) is begin Stream.Write_Entity (Name, ""); end Write_Null_Attribute; -- ------------------------------ -- Write an entity with a null value. -- ------------------------------ overriding procedure Write_Null_Entity (Stream : in out Output_Stream; Name : in String) is begin Stream.Write_Null_Attribute (Name); end Write_Null_Entity; -- ------------------------------ -- Get the header name for the given column. -- If there was no header line, build a default header for the column. -- ------------------------------ function Get_Header_Name (Handler : in Parser; Column : in Column_Type) return String is use type Ada.Containers.Count_Type; Default_Header : constant String := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; Result : String (1 .. 10); N, R : Natural; Pos : Positive := Result'Last; begin if Handler.Headers.Length >= Ada.Containers.Count_Type (Column) then return Handler.Headers.Element (Positive (Column)); end if; N := Natural (Column - 1); loop R := N mod 26; N := N / 26; Result (Pos) := Default_Header (R + 1); exit when N = 0; Pos := Pos - 1; end loop; return Result (Pos .. Result'Last); end Get_Header_Name; -- ------------------------------ -- Set the cell value at the given row and column. -- The default implementation finds the column header name and -- invokes <b>Write_Entity</b> with the header name and the value. -- ------------------------------ procedure Set_Cell (Handler : in out Parser; Value : in String; Row : in Row_Type; Column : in Column_Type) is use Ada.Containers; begin if Row = 0 then -- Build the headers table. declare Missing : constant Integer := Integer (Column) - Integer (Handler.Headers.Length); begin if Missing > 0 then Handler.Headers.Set_Length (Handler.Headers.Length + Count_Type (Missing)); end if; Handler.Headers.Replace_Element (Positive (Column), Value); end; else declare Name : constant String := Handler.Get_Header_Name (Column); begin -- Detect a new row. Close the current object and start a new one. if Handler.Row /= Row then if Row > 1 then Handler.Sink.Finish_Object ("", Handler); else Handler.Sink.Start_Array ("", Handler); end if; Handler.Sink.Start_Object ("", Handler); end if; Handler.Row := Row; Handler.Sink.Set_Member (Name, Util.Beans.Objects.To_Object (Value), Handler); end; end if; end Set_Cell; -- ------------------------------ -- Set the field separator. The default field separator is the comma (','). -- ------------------------------ procedure Set_Field_Separator (Handler : in out Parser; Separator : in Character) is begin Handler.Separator := Separator; end Set_Field_Separator; -- ------------------------------ -- Get the field separator. -- ------------------------------ function Get_Field_Separator (Handler : in Parser) return Character is begin return Handler.Separator; end Get_Field_Separator; -- ------------------------------ -- Set the comment separator. When a comment separator is defined, a line which starts -- with the comment separator will be ignored. The row number will not be incremented. -- ------------------------------ procedure Set_Comment_Separator (Handler : in out Parser; Separator : in Character) is begin Handler.Comment := Separator; end Set_Comment_Separator; -- ------------------------------ -- Get the comment separator. Returns ASCII.NUL if comments are not supported. -- ------------------------------ function Get_Comment_Separator (Handler : in Parser) return Character is begin return Handler.Comment; end Get_Comment_Separator; -- ------------------------------ -- Setup the CSV parser and mapper to use the default column header names. -- When activated, the first row is assumed to contain the first item to de-serialize. -- ------------------------------ procedure Set_Default_Headers (Handler : in out Parser; Mode : in Boolean := True) is begin Handler.Use_Default_Headers := Mode; end Set_Default_Headers; -- ------------------------------ -- Parse the stream using the CSV parser. -- Call <b>Set_Cell</b> for each cell that has been parsed indicating the row and -- column numbers as well as the cell value. -- ------------------------------ overriding procedure Parse (Handler : in out Parser; Stream : in out Util.Streams.Buffered.Input_Buffer_Stream'Class; Sink : in out Reader'Class) is use Ada.Strings.Unbounded; C : Character; Token : Unbounded_String; Column : Column_Type := 1; Row : Row_Type := 0; In_Quote_Token : Boolean := False; In_Escape : Boolean := False; Ignore_Row : Boolean := False; begin if Handler.Use_Default_Headers then Row := 1; end if; Handler.Headers.Clear; Handler.Sink := Sink'Unchecked_Access; loop Stream.Read (Char => C); if C = Ada.Characters.Latin_1.CR or else C = Ada.Characters.Latin_1.LF then if C = Ada.Characters.Latin_1.LF then Handler.Line_Number := Handler.Line_Number + 1; end if; if not Ignore_Row then if In_Quote_Token and then not In_Escape then Append (Token, C); elsif Column > 1 or else Length (Token) > 0 then Parser'Class (Handler).Set_Cell (To_String (Token), Row, Column); Set_Unbounded_String (Token, ""); Row := Row + 1; Column := 1; In_Quote_Token := False; In_Escape := False; end if; else Ignore_Row := False; end if; elsif C = Handler.Separator and then not Ignore_Row then if In_Quote_Token and then not In_Escape then Append (Token, C); else Parser'Class (Handler).Set_Cell (To_String (Token), Row, Column); Set_Unbounded_String (Token, ""); Column := Column + 1; In_Quote_Token := False; In_Escape := False; end if; elsif C = '"' and then not Ignore_Row then if In_Quote_Token then In_Escape := True; elsif In_Escape then Append (Token, C); In_Escape := False; elsif Ada.Strings.Unbounded.Length (Token) = 0 then In_Quote_Token := True; else Append (Token, C); end if; elsif C = Handler.Comment and then Handler.Comment /= ASCII.NUL and then Column = 1 and then Length (Token) = 0 then Ignore_Row := True; elsif not Ignore_Row then Append (Token, C); In_Escape := False; end if; end loop; exception when Ada.IO_Exceptions.Data_Error => Parser'Class (Handler).Set_Cell (To_String (Token), Row, Column); Handler.Sink := null; return; end Parse; -- ------------------------------ -- Get the current location (file and line) to report an error message. -- ------------------------------ overriding function Get_Location (Handler : in Parser) return String is begin return Util.Strings.Image (Handler.Line_Number); end Get_Location; end Util.Serialize.IO.CSV;
gonma95/RealTimeSystem_CarDistrations
Ada
1,016
ads
-- Gonzalo Martin Rodriguez -- Ivan Fernandez Samaniego with Priorities; use Priorities; with devices; use devices; with Ada.Interrupts.Names; with System; use System; package State is task Display is pragma Priority (Display_Priority); end Display; task Risks is pragma Priority (Risk_Priority); end Risks; task Sporadic_Task is pragma Priority (Sporadic_Priority); end Sporadic_Task; protected Operation_Mode is pragma Priority (Risk_Priority); procedure Write_Mode (Value: in integer); procedure Read_Mode (Value: out integer); private Mode: integer := 1; end Operation_Mode; protected Interruption_Handler is pragma Priority (System.Interrupt_Priority'First + 10); procedure Validate_Entry; pragma Attach_Handler (Validate_Entry, Ada.Interrupts.Names.External_Interrupt_2); entry Change_Mode; private Enter: Boolean := False; end Interruption_Handler; end State;
AdaCore/gpr
Ada
52
ads
package Pack12 is procedure Dummy; end Pack12;
sparre/Command-Line-Parser-Generator
Ada
579
adb
package body Good_Optional_Help_With_Private_Part is procedure Debug (To : Ada.Text_IO.File_Type) is begin Ada.Text_IO.Put_Line (File => To, Item => "<debug>"); end Debug; procedure Reset (File : in out Ada.Text_IO.File_Type) is begin Ada.Text_IO.Reset (File => File); end Reset; procedure Run (Help : in Boolean := False) is begin if Help then Ada.Text_IO.Put_Line ("<help>"); else Ada.Text_IO.Put_Line ("<run>"); end if; end Run; end Good_Optional_Help_With_Private_Part;
zhmu/ananas
Ada
61,362
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . S T R I N G S . W I D E _ W I D E _ U N B O U N D E D -- -- -- -- 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.Strings.Wide_Wide_Search; with Ada.Unchecked_Deallocation; package body Ada.Strings.Wide_Wide_Unbounded is use Ada.Strings.Wide_Wide_Maps; Growth_Factor : constant := 32; -- The growth factor controls how much extra space is allocated when -- we have to increase the size of an allocated unbounded string. By -- allocating extra space, we avoid the need to reallocate on every -- append, particularly important when a string is built up by repeated -- append operations of small pieces. This is expressed as a factor so -- 32 means add 1/32 of the length of the string as growth space. Min_Mul_Alloc : constant := Standard'Maximum_Alignment; -- Allocation will be done by a multiple of Min_Mul_Alloc. This causes -- no memory loss as most (all?) malloc implementations are obliged to -- align the returned memory on the maximum alignment as malloc does not -- know the target alignment. function Aligned_Max_Length (Max_Length : Natural) return Natural; -- Returns recommended length of the shared string which is greater or -- equal to specified length. Calculation take in sense alignment of -- the allocated memory segments to use memory effectively by -- Append/Insert/etc operations. --------- -- "&" -- --------- function "&" (Left : Unbounded_Wide_Wide_String; Right : Unbounded_Wide_Wide_String) return Unbounded_Wide_Wide_String is LR : constant Shared_Wide_Wide_String_Access := Left.Reference; RR : constant Shared_Wide_Wide_String_Access := Right.Reference; DL : constant Natural := LR.Last + RR.Last; DR : Shared_Wide_Wide_String_Access; begin -- Result is an empty string, reuse shared empty string if DL = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); DR := Empty_Shared_Wide_Wide_String'Access; -- Left string is empty, return Right string elsif LR.Last = 0 then Reference (RR); DR := RR; -- Right string is empty, return Left string elsif RR.Last = 0 then Reference (LR); DR := LR; -- Overwise, allocate new shared string and fill data else DR := Allocate (DL); DR.Data (1 .. LR.Last) := LR.Data (1 .. LR.Last); DR.Data (LR.Last + 1 .. DL) := RR.Data (1 .. RR.Last); DR.Last := DL; end if; return (AF.Controlled with Reference => DR); end "&"; function "&" (Left : Unbounded_Wide_Wide_String; Right : Wide_Wide_String) return Unbounded_Wide_Wide_String is LR : constant Shared_Wide_Wide_String_Access := Left.Reference; DL : constant Natural := LR.Last + Right'Length; DR : Shared_Wide_Wide_String_Access; begin -- Result is an empty string, reuse shared empty string if DL = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); DR := Empty_Shared_Wide_Wide_String'Access; -- Right is an empty string, return Left string elsif Right'Length = 0 then Reference (LR); DR := LR; -- Otherwise, allocate new shared string and fill it else DR := Allocate (DL); DR.Data (1 .. LR.Last) := LR.Data (1 .. LR.Last); DR.Data (LR.Last + 1 .. DL) := Right; DR.Last := DL; end if; return (AF.Controlled with Reference => DR); end "&"; function "&" (Left : Wide_Wide_String; Right : Unbounded_Wide_Wide_String) return Unbounded_Wide_Wide_String is RR : constant Shared_Wide_Wide_String_Access := Right.Reference; DL : constant Natural := Left'Length + RR.Last; DR : Shared_Wide_Wide_String_Access; begin -- Result is an empty string, reuse shared one if DL = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); DR := Empty_Shared_Wide_Wide_String'Access; -- Left is empty string, return Right string elsif Left'Length = 0 then Reference (RR); DR := RR; -- Otherwise, allocate new shared string and fill it else DR := Allocate (DL); DR.Data (1 .. Left'Length) := Left; DR.Data (Left'Length + 1 .. DL) := RR.Data (1 .. RR.Last); DR.Last := DL; end if; return (AF.Controlled with Reference => DR); end "&"; function "&" (Left : Unbounded_Wide_Wide_String; Right : Wide_Wide_Character) return Unbounded_Wide_Wide_String is LR : constant Shared_Wide_Wide_String_Access := Left.Reference; DL : constant Natural := LR.Last + 1; DR : Shared_Wide_Wide_String_Access; begin DR := Allocate (DL); DR.Data (1 .. LR.Last) := LR.Data (1 .. LR.Last); DR.Data (DL) := Right; DR.Last := DL; return (AF.Controlled with Reference => DR); end "&"; function "&" (Left : Wide_Wide_Character; Right : Unbounded_Wide_Wide_String) return Unbounded_Wide_Wide_String is RR : constant Shared_Wide_Wide_String_Access := Right.Reference; DL : constant Natural := 1 + RR.Last; DR : Shared_Wide_Wide_String_Access; begin DR := Allocate (DL); DR.Data (1) := Left; DR.Data (2 .. DL) := RR.Data (1 .. RR.Last); DR.Last := DL; return (AF.Controlled with Reference => DR); end "&"; --------- -- "*" -- --------- function "*" (Left : Natural; Right : Wide_Wide_Character) return Unbounded_Wide_Wide_String is DR : Shared_Wide_Wide_String_Access; begin -- Result is an empty string, reuse shared empty string if Left = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); DR := Empty_Shared_Wide_Wide_String'Access; -- Otherwise, allocate new shared string and fill it else DR := Allocate (Left); for J in 1 .. Left loop DR.Data (J) := Right; end loop; DR.Last := Left; end if; return (AF.Controlled with Reference => DR); end "*"; function "*" (Left : Natural; Right : Wide_Wide_String) return Unbounded_Wide_Wide_String is DL : constant Natural := Left * Right'Length; DR : Shared_Wide_Wide_String_Access; K : Positive; begin -- Result is an empty string, reuse shared empty string if DL = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); DR := Empty_Shared_Wide_Wide_String'Access; -- Otherwise, allocate new shared string and fill it else DR := Allocate (DL); K := 1; for J in 1 .. Left loop DR.Data (K .. K + Right'Length - 1) := Right; K := K + Right'Length; end loop; DR.Last := DL; end if; return (AF.Controlled with Reference => DR); end "*"; function "*" (Left : Natural; Right : Unbounded_Wide_Wide_String) return Unbounded_Wide_Wide_String is RR : constant Shared_Wide_Wide_String_Access := Right.Reference; DL : constant Natural := Left * RR.Last; DR : Shared_Wide_Wide_String_Access; K : Positive; begin -- Result is an empty string, reuse shared empty string if DL = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); DR := Empty_Shared_Wide_Wide_String'Access; -- Coefficient is one, just return string itself elsif Left = 1 then Reference (RR); DR := RR; -- Otherwise, allocate new shared string and fill it else DR := Allocate (DL); K := 1; for J in 1 .. Left loop DR.Data (K .. K + RR.Last - 1) := RR.Data (1 .. RR.Last); K := K + RR.Last; end loop; DR.Last := DL; end if; return (AF.Controlled with Reference => DR); end "*"; --------- -- "<" -- --------- function "<" (Left : Unbounded_Wide_Wide_String; Right : Unbounded_Wide_Wide_String) return Boolean is LR : constant Shared_Wide_Wide_String_Access := Left.Reference; RR : constant Shared_Wide_Wide_String_Access := Right.Reference; begin return LR.Data (1 .. LR.Last) < RR.Data (1 .. RR.Last); end "<"; function "<" (Left : Unbounded_Wide_Wide_String; Right : Wide_Wide_String) return Boolean is LR : constant Shared_Wide_Wide_String_Access := Left.Reference; begin return LR.Data (1 .. LR.Last) < Right; end "<"; function "<" (Left : Wide_Wide_String; Right : Unbounded_Wide_Wide_String) return Boolean is RR : constant Shared_Wide_Wide_String_Access := Right.Reference; begin return Left < RR.Data (1 .. RR.Last); end "<"; ---------- -- "<=" -- ---------- function "<=" (Left : Unbounded_Wide_Wide_String; Right : Unbounded_Wide_Wide_String) return Boolean is LR : constant Shared_Wide_Wide_String_Access := Left.Reference; RR : constant Shared_Wide_Wide_String_Access := Right.Reference; begin -- LR = RR means two strings shares shared string, thus they are equal return LR = RR or else LR.Data (1 .. LR.Last) <= RR.Data (1 .. RR.Last); end "<="; function "<=" (Left : Unbounded_Wide_Wide_String; Right : Wide_Wide_String) return Boolean is LR : constant Shared_Wide_Wide_String_Access := Left.Reference; begin return LR.Data (1 .. LR.Last) <= Right; end "<="; function "<=" (Left : Wide_Wide_String; Right : Unbounded_Wide_Wide_String) return Boolean is RR : constant Shared_Wide_Wide_String_Access := Right.Reference; begin return Left <= RR.Data (1 .. RR.Last); end "<="; --------- -- "=" -- --------- function "=" (Left : Unbounded_Wide_Wide_String; Right : Unbounded_Wide_Wide_String) return Boolean is LR : constant Shared_Wide_Wide_String_Access := Left.Reference; RR : constant Shared_Wide_Wide_String_Access := Right.Reference; begin return LR = RR or else LR.Data (1 .. LR.Last) = RR.Data (1 .. RR.Last); -- LR = RR means two strings shares shared string, thus they are equal end "="; function "=" (Left : Unbounded_Wide_Wide_String; Right : Wide_Wide_String) return Boolean is LR : constant Shared_Wide_Wide_String_Access := Left.Reference; begin return LR.Data (1 .. LR.Last) = Right; end "="; function "=" (Left : Wide_Wide_String; Right : Unbounded_Wide_Wide_String) return Boolean is RR : constant Shared_Wide_Wide_String_Access := Right.Reference; begin return Left = RR.Data (1 .. RR.Last); end "="; --------- -- ">" -- --------- function ">" (Left : Unbounded_Wide_Wide_String; Right : Unbounded_Wide_Wide_String) return Boolean is LR : constant Shared_Wide_Wide_String_Access := Left.Reference; RR : constant Shared_Wide_Wide_String_Access := Right.Reference; begin return LR.Data (1 .. LR.Last) > RR.Data (1 .. RR.Last); end ">"; function ">" (Left : Unbounded_Wide_Wide_String; Right : Wide_Wide_String) return Boolean is LR : constant Shared_Wide_Wide_String_Access := Left.Reference; begin return LR.Data (1 .. LR.Last) > Right; end ">"; function ">" (Left : Wide_Wide_String; Right : Unbounded_Wide_Wide_String) return Boolean is RR : constant Shared_Wide_Wide_String_Access := Right.Reference; begin return Left > RR.Data (1 .. RR.Last); end ">"; ---------- -- ">=" -- ---------- function ">=" (Left : Unbounded_Wide_Wide_String; Right : Unbounded_Wide_Wide_String) return Boolean is LR : constant Shared_Wide_Wide_String_Access := Left.Reference; RR : constant Shared_Wide_Wide_String_Access := Right.Reference; begin -- LR = RR means two strings shares shared string, thus they are equal return LR = RR or else LR.Data (1 .. LR.Last) >= RR.Data (1 .. RR.Last); end ">="; function ">=" (Left : Unbounded_Wide_Wide_String; Right : Wide_Wide_String) return Boolean is LR : constant Shared_Wide_Wide_String_Access := Left.Reference; begin return LR.Data (1 .. LR.Last) >= Right; end ">="; function ">=" (Left : Wide_Wide_String; Right : Unbounded_Wide_Wide_String) return Boolean is RR : constant Shared_Wide_Wide_String_Access := Right.Reference; begin return Left >= RR.Data (1 .. RR.Last); end ">="; ------------ -- Adjust -- ------------ procedure Adjust (Object : in out Unbounded_Wide_Wide_String) is begin Reference (Object.Reference); end Adjust; ------------------------ -- Aligned_Max_Length -- ------------------------ function Aligned_Max_Length (Max_Length : Natural) return Natural is Static_Size : constant Natural := Empty_Shared_Wide_Wide_String'Size / Standard'Storage_Unit; -- Total size of all static components Element_Size : constant Natural := Wide_Wide_Character'Size / Standard'Storage_Unit; begin return (((Static_Size + Max_Length * Element_Size - 1) / Min_Mul_Alloc + 2) * Min_Mul_Alloc - Static_Size) / Element_Size; end Aligned_Max_Length; -------------- -- Allocate -- -------------- function Allocate (Max_Length : Natural) return Shared_Wide_Wide_String_Access is begin -- Empty string requested, return shared empty string if Max_Length = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); return Empty_Shared_Wide_Wide_String'Access; -- Otherwise, allocate requested space (and probably some more room) else return new Shared_Wide_Wide_String (Aligned_Max_Length (Max_Length)); end if; end Allocate; ------------ -- Append -- ------------ procedure Append (Source : in out Unbounded_Wide_Wide_String; New_Item : Unbounded_Wide_Wide_String) is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; NR : constant Shared_Wide_Wide_String_Access := New_Item.Reference; DL : constant Natural := SR.Last + NR.Last; DR : Shared_Wide_Wide_String_Access; begin -- Source is an empty string, reuse New_Item data if SR.Last = 0 then Reference (NR); Source.Reference := NR; Unreference (SR); -- New_Item is empty string, nothing to do elsif NR.Last = 0 then null; -- Try to reuse existent shared string elsif Can_Be_Reused (SR, DL) then SR.Data (SR.Last + 1 .. DL) := NR.Data (1 .. NR.Last); SR.Last := DL; -- Otherwise, allocate new one and fill it else DR := Allocate (DL + DL / Growth_Factor); DR.Data (1 .. SR.Last) := SR.Data (1 .. SR.Last); DR.Data (SR.Last + 1 .. DL) := NR.Data (1 .. NR.Last); DR.Last := DL; Source.Reference := DR; Unreference (SR); end if; end Append; procedure Append (Source : in out Unbounded_Wide_Wide_String; New_Item : Wide_Wide_String) is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; DL : constant Natural := SR.Last + New_Item'Length; DR : Shared_Wide_Wide_String_Access; begin -- New_Item is an empty string, nothing to do if New_Item'Length = 0 then null; -- Try to reuse existing shared string elsif Can_Be_Reused (SR, DL) then SR.Data (SR.Last + 1 .. DL) := New_Item; SR.Last := DL; -- Otherwise, allocate new one and fill it else DR := Allocate (DL + DL / Growth_Factor); DR.Data (1 .. SR.Last) := SR.Data (1 .. SR.Last); DR.Data (SR.Last + 1 .. DL) := New_Item; DR.Last := DL; Source.Reference := DR; Unreference (SR); end if; end Append; procedure Append (Source : in out Unbounded_Wide_Wide_String; New_Item : Wide_Wide_Character) is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; DL : constant Natural := SR.Last + 1; DR : Shared_Wide_Wide_String_Access; begin -- Try to reuse existing shared string if Can_Be_Reused (SR, SR.Last + 1) then SR.Data (SR.Last + 1) := New_Item; SR.Last := SR.Last + 1; -- Otherwise, allocate new one and fill it else DR := Allocate (DL + DL / Growth_Factor); DR.Data (1 .. SR.Last) := SR.Data (1 .. SR.Last); DR.Data (DL) := New_Item; DR.Last := DL; Source.Reference := DR; Unreference (SR); end if; end Append; ------------------- -- Can_Be_Reused -- ------------------- function Can_Be_Reused (Item : Shared_Wide_Wide_String_Access; Length : Natural) return Boolean is begin return System.Atomic_Counters.Is_One (Item.Counter) and then Item.Max_Length >= Length and then Item.Max_Length <= Aligned_Max_Length (Length + Length / Growth_Factor); end Can_Be_Reused; ----------- -- Count -- ----------- function Count (Source : Unbounded_Wide_Wide_String; Pattern : Wide_Wide_String; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping := Wide_Wide_Maps.Identity) return Natural is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; begin return Wide_Wide_Search.Count (SR.Data (1 .. SR.Last), Pattern, Mapping); end Count; function Count (Source : Unbounded_Wide_Wide_String; Pattern : Wide_Wide_String; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function) return Natural is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; begin return Wide_Wide_Search.Count (SR.Data (1 .. SR.Last), Pattern, Mapping); end Count; function Count (Source : Unbounded_Wide_Wide_String; Set : Wide_Wide_Maps.Wide_Wide_Character_Set) return Natural is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; begin return Wide_Wide_Search.Count (SR.Data (1 .. SR.Last), Set); end Count; ------------ -- Delete -- ------------ function Delete (Source : Unbounded_Wide_Wide_String; From : Positive; Through : Natural) return Unbounded_Wide_Wide_String is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; DL : Natural; DR : Shared_Wide_Wide_String_Access; begin -- Empty slice is deleted, use the same shared string if From > Through then Reference (SR); DR := SR; -- Index is out of range elsif Through > SR.Last then raise Index_Error; -- Compute size of the result else DL := SR.Last - (Through - From + 1); -- Result is an empty string, reuse shared empty string if DL = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); DR := Empty_Shared_Wide_Wide_String'Access; -- Otherwise, allocate new shared string and fill it else DR := Allocate (DL); DR.Data (1 .. From - 1) := SR.Data (1 .. From - 1); DR.Data (From .. DL) := SR.Data (Through + 1 .. SR.Last); DR.Last := DL; end if; end if; return (AF.Controlled with Reference => DR); end Delete; procedure Delete (Source : in out Unbounded_Wide_Wide_String; From : Positive; Through : Natural) is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; DL : Natural; DR : Shared_Wide_Wide_String_Access; begin -- Nothing changed, return if From > Through then null; -- Through is outside of the range elsif Through > SR.Last then raise Index_Error; else DL := SR.Last - (Through - From + 1); -- Result is empty, reuse shared empty string if DL = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); Source.Reference := Empty_Shared_Wide_Wide_String'Access; Unreference (SR); -- Try to reuse existent shared string elsif Can_Be_Reused (SR, DL) then SR.Data (From .. DL) := SR.Data (Through + 1 .. SR.Last); SR.Last := DL; -- Otherwise, allocate new shared string else DR := Allocate (DL); DR.Data (1 .. From - 1) := SR.Data (1 .. From - 1); DR.Data (From .. DL) := SR.Data (Through + 1 .. SR.Last); DR.Last := DL; Source.Reference := DR; Unreference (SR); end if; end if; end Delete; ------------- -- Element -- ------------- function Element (Source : Unbounded_Wide_Wide_String; Index : Positive) return Wide_Wide_Character is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; begin if Index <= SR.Last then return SR.Data (Index); else raise Index_Error; end if; end Element; -------------- -- Finalize -- -------------- procedure Finalize (Object : in out Unbounded_Wide_Wide_String) is SR : constant Shared_Wide_Wide_String_Access := Object.Reference; begin if SR /= null then -- The same controlled object can be finalized several times for -- some reason. As per 7.6.1(24) this should have no ill effect, -- so we need to add a guard for the case of finalizing the same -- object twice. Object.Reference := null; Unreference (SR); end if; end Finalize; ---------------- -- Find_Token -- ---------------- procedure Find_Token (Source : Unbounded_Wide_Wide_String; Set : Wide_Wide_Maps.Wide_Wide_Character_Set; From : Positive; Test : Strings.Membership; First : out Positive; Last : out Natural) is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; begin Wide_Wide_Search.Find_Token (SR.Data (From .. SR.Last), Set, Test, First, Last); end Find_Token; procedure Find_Token (Source : Unbounded_Wide_Wide_String; Set : Wide_Wide_Maps.Wide_Wide_Character_Set; Test : Strings.Membership; First : out Positive; Last : out Natural) is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; begin Wide_Wide_Search.Find_Token (SR.Data (1 .. SR.Last), Set, Test, First, Last); end Find_Token; ---------- -- Free -- ---------- procedure Free (X : in out Wide_Wide_String_Access) is procedure Deallocate is new Ada.Unchecked_Deallocation (Wide_Wide_String, Wide_Wide_String_Access); begin Deallocate (X); end Free; ---------- -- Head -- ---------- function Head (Source : Unbounded_Wide_Wide_String; Count : Natural; Pad : Wide_Wide_Character := Wide_Wide_Space) return Unbounded_Wide_Wide_String is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; DR : Shared_Wide_Wide_String_Access; begin -- Result is empty, reuse shared empty string if Count = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); DR := Empty_Shared_Wide_Wide_String'Access; -- Length of the string is the same as requested, reuse source shared -- string. elsif Count = SR.Last then Reference (SR); DR := SR; -- Otherwise, allocate new shared string and fill it else DR := Allocate (Count); -- Length of the source string is more than requested, copy -- corresponding slice. if Count < SR.Last then DR.Data (1 .. Count) := SR.Data (1 .. Count); -- Length of the source string is less than requested, copy all -- contents and fill others by Pad character. else DR.Data (1 .. SR.Last) := SR.Data (1 .. SR.Last); for J in SR.Last + 1 .. Count loop DR.Data (J) := Pad; end loop; end if; DR.Last := Count; end if; return (AF.Controlled with Reference => DR); end Head; procedure Head (Source : in out Unbounded_Wide_Wide_String; Count : Natural; Pad : Wide_Wide_Character := Wide_Wide_Space) is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; DR : Shared_Wide_Wide_String_Access; begin -- Result is empty, reuse empty shared string if Count = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); Source.Reference := Empty_Shared_Wide_Wide_String'Access; Unreference (SR); -- Result is same with source string, reuse source shared string elsif Count = SR.Last then null; -- Try to reuse existent shared string elsif Can_Be_Reused (SR, Count) then if Count > SR.Last then for J in SR.Last + 1 .. Count loop SR.Data (J) := Pad; end loop; end if; SR.Last := Count; -- Otherwise, allocate new shared string and fill it else DR := Allocate (Count); -- Length of the source string is greater than requested, copy -- corresponding slice. if Count < SR.Last then DR.Data (1 .. Count) := SR.Data (1 .. Count); -- Length of the source string is less than requested, copy all -- exists data and fill others by Pad character. else DR.Data (1 .. SR.Last) := SR.Data (1 .. SR.Last); for J in SR.Last + 1 .. Count loop DR.Data (J) := Pad; end loop; end if; DR.Last := Count; Source.Reference := DR; Unreference (SR); end if; end Head; ----------- -- Index -- ----------- function Index (Source : Unbounded_Wide_Wide_String; Pattern : Wide_Wide_String; Going : Strings.Direction := Strings.Forward; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping := Wide_Wide_Maps.Identity) return Natural is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; begin return Wide_Wide_Search.Index (SR.Data (1 .. SR.Last), Pattern, Going, Mapping); end Index; function Index (Source : Unbounded_Wide_Wide_String; Pattern : Wide_Wide_String; Going : Direction := Forward; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function) return Natural is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; begin return Wide_Wide_Search.Index (SR.Data (1 .. SR.Last), Pattern, Going, Mapping); end Index; function Index (Source : Unbounded_Wide_Wide_String; Set : Wide_Wide_Maps.Wide_Wide_Character_Set; Test : Strings.Membership := Strings.Inside; Going : Strings.Direction := Strings.Forward) return Natural is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; begin return Wide_Wide_Search.Index (SR.Data (1 .. SR.Last), Set, Test, Going); end Index; function Index (Source : Unbounded_Wide_Wide_String; Pattern : Wide_Wide_String; From : Positive; Going : Direction := Forward; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping := Wide_Wide_Maps.Identity) return Natural is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; begin return Wide_Wide_Search.Index (SR.Data (1 .. SR.Last), Pattern, From, Going, Mapping); end Index; function Index (Source : Unbounded_Wide_Wide_String; Pattern : Wide_Wide_String; From : Positive; Going : Direction := Forward; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function) return Natural is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; begin return Wide_Wide_Search.Index (SR.Data (1 .. SR.Last), Pattern, From, Going, Mapping); end Index; function Index (Source : Unbounded_Wide_Wide_String; Set : Wide_Wide_Maps.Wide_Wide_Character_Set; From : Positive; Test : Membership := Inside; Going : Direction := Forward) return Natural is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; begin return Wide_Wide_Search.Index (SR.Data (1 .. SR.Last), Set, From, Test, Going); end Index; --------------------- -- Index_Non_Blank -- --------------------- function Index_Non_Blank (Source : Unbounded_Wide_Wide_String; Going : Strings.Direction := Strings.Forward) return Natural is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; begin return Wide_Wide_Search.Index_Non_Blank (SR.Data (1 .. SR.Last), Going); end Index_Non_Blank; function Index_Non_Blank (Source : Unbounded_Wide_Wide_String; From : Positive; Going : Direction := Forward) return Natural is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; begin return Wide_Wide_Search.Index_Non_Blank (SR.Data (1 .. SR.Last), From, Going); end Index_Non_Blank; ---------------- -- Initialize -- ---------------- procedure Initialize (Object : in out Unbounded_Wide_Wide_String) is begin Reference (Object.Reference); end Initialize; ------------ -- Insert -- ------------ function Insert (Source : Unbounded_Wide_Wide_String; Before : Positive; New_Item : Wide_Wide_String) return Unbounded_Wide_Wide_String is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; DL : constant Natural := SR.Last + New_Item'Length; DR : Shared_Wide_Wide_String_Access; begin -- Check index first if Before > SR.Last + 1 then raise Index_Error; end if; -- Result is empty, reuse empty shared string if DL = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); DR := Empty_Shared_Wide_Wide_String'Access; -- Inserted string is empty, reuse source shared string elsif New_Item'Length = 0 then Reference (SR); DR := SR; -- Otherwise, allocate new shared string and fill it else DR := Allocate (DL + DL / Growth_Factor); DR.Data (1 .. Before - 1) := SR.Data (1 .. Before - 1); DR.Data (Before .. Before + New_Item'Length - 1) := New_Item; DR.Data (Before + New_Item'Length .. DL) := SR.Data (Before .. SR.Last); DR.Last := DL; end if; return (AF.Controlled with Reference => DR); end Insert; procedure Insert (Source : in out Unbounded_Wide_Wide_String; Before : Positive; New_Item : Wide_Wide_String) is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; DL : constant Natural := SR.Last + New_Item'Length; DR : Shared_Wide_Wide_String_Access; begin -- Check bounds if Before > SR.Last + 1 then raise Index_Error; end if; -- Result is empty string, reuse empty shared string if DL = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); Source.Reference := Empty_Shared_Wide_Wide_String'Access; Unreference (SR); -- Inserted string is empty, nothing to do elsif New_Item'Length = 0 then null; -- Try to reuse existent shared string first elsif Can_Be_Reused (SR, DL) then SR.Data (Before + New_Item'Length .. DL) := SR.Data (Before .. SR.Last); SR.Data (Before .. Before + New_Item'Length - 1) := New_Item; SR.Last := DL; -- Otherwise, allocate new shared string and fill it else DR := Allocate (DL + DL / Growth_Factor); DR.Data (1 .. Before - 1) := SR.Data (1 .. Before - 1); DR.Data (Before .. Before + New_Item'Length - 1) := New_Item; DR.Data (Before + New_Item'Length .. DL) := SR.Data (Before .. SR.Last); DR.Last := DL; Source.Reference := DR; Unreference (SR); end if; end Insert; ------------ -- Length -- ------------ function Length (Source : Unbounded_Wide_Wide_String) return Natural is begin return Source.Reference.Last; end Length; --------------- -- Overwrite -- --------------- function Overwrite (Source : Unbounded_Wide_Wide_String; Position : Positive; New_Item : Wide_Wide_String) return Unbounded_Wide_Wide_String is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; DL : Natural; DR : Shared_Wide_Wide_String_Access; begin -- Check bounds if Position > SR.Last + 1 then raise Index_Error; end if; DL := Integer'Max (SR.Last, Position + New_Item'Length - 1); -- Result is empty string, reuse empty shared string if DL = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); DR := Empty_Shared_Wide_Wide_String'Access; -- Result is same with source string, reuse source shared string elsif New_Item'Length = 0 then Reference (SR); DR := SR; -- Otherwise, allocate new shared string and fill it else DR := Allocate (DL); DR.Data (1 .. Position - 1) := SR.Data (1 .. Position - 1); DR.Data (Position .. Position + New_Item'Length - 1) := New_Item; DR.Data (Position + New_Item'Length .. DL) := SR.Data (Position + New_Item'Length .. SR.Last); DR.Last := DL; end if; return (AF.Controlled with Reference => DR); end Overwrite; procedure Overwrite (Source : in out Unbounded_Wide_Wide_String; Position : Positive; New_Item : Wide_Wide_String) is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; DL : Natural; DR : Shared_Wide_Wide_String_Access; begin -- Bounds check if Position > SR.Last + 1 then raise Index_Error; end if; DL := Integer'Max (SR.Last, Position + New_Item'Length - 1); -- Result is empty string, reuse empty shared string if DL = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); Source.Reference := Empty_Shared_Wide_Wide_String'Access; Unreference (SR); -- String unchanged, nothing to do elsif New_Item'Length = 0 then null; -- Try to reuse existent shared string elsif Can_Be_Reused (SR, DL) then SR.Data (Position .. Position + New_Item'Length - 1) := New_Item; SR.Last := DL; -- Otherwise allocate new shared string and fill it else DR := Allocate (DL); DR.Data (1 .. Position - 1) := SR.Data (1 .. Position - 1); DR.Data (Position .. Position + New_Item'Length - 1) := New_Item; DR.Data (Position + New_Item'Length .. DL) := SR.Data (Position + New_Item'Length .. SR.Last); DR.Last := DL; Source.Reference := DR; Unreference (SR); end if; end Overwrite; --------------- -- Reference -- --------------- procedure Reference (Item : not null Shared_Wide_Wide_String_Access) is begin System.Atomic_Counters.Increment (Item.Counter); end Reference; --------------------- -- Replace_Element -- --------------------- procedure Replace_Element (Source : in out Unbounded_Wide_Wide_String; Index : Positive; By : Wide_Wide_Character) is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; DR : Shared_Wide_Wide_String_Access; begin -- Bounds check if Index <= SR.Last then -- Try to reuse existent shared string if Can_Be_Reused (SR, SR.Last) then SR.Data (Index) := By; -- Otherwise allocate new shared string and fill it else DR := Allocate (SR.Last); DR.Data (1 .. SR.Last) := SR.Data (1 .. SR.Last); DR.Data (Index) := By; DR.Last := SR.Last; Source.Reference := DR; Unreference (SR); end if; else raise Index_Error; end if; end Replace_Element; ------------------- -- Replace_Slice -- ------------------- function Replace_Slice (Source : Unbounded_Wide_Wide_String; Low : Positive; High : Natural; By : Wide_Wide_String) return Unbounded_Wide_Wide_String is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; DL : Natural; DR : Shared_Wide_Wide_String_Access; begin -- Check bounds if Low > SR.Last + 1 then raise Index_Error; end if; -- Do replace operation when removed slice is not empty if High >= Low then DL := By'Length + SR.Last + Low - Integer'Min (High, SR.Last) - 1; -- This is the number of characters remaining in the string after -- replacing the slice. -- Result is empty string, reuse empty shared string if DL = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); DR := Empty_Shared_Wide_Wide_String'Access; -- Otherwise allocate new shared string and fill it else DR := Allocate (DL); DR.Data (1 .. Low - 1) := SR.Data (1 .. Low - 1); DR.Data (Low .. Low + By'Length - 1) := By; DR.Data (Low + By'Length .. DL) := SR.Data (High + 1 .. SR.Last); DR.Last := DL; end if; return (AF.Controlled with Reference => DR); -- Otherwise just insert string else return Insert (Source, Low, By); end if; end Replace_Slice; procedure Replace_Slice (Source : in out Unbounded_Wide_Wide_String; Low : Positive; High : Natural; By : Wide_Wide_String) is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; DL : Natural; DR : Shared_Wide_Wide_String_Access; begin -- Bounds check if Low > SR.Last + 1 then raise Index_Error; end if; -- Do replace operation only when replaced slice is not empty if High >= Low then DL := By'Length + SR.Last + Low - Integer'Min (High, SR.Last) - 1; -- This is the number of characters remaining in the string after -- replacing the slice. -- Result is empty string, reuse empty shared string if DL = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); Source.Reference := Empty_Shared_Wide_Wide_String'Access; Unreference (SR); -- Try to reuse existent shared string elsif Can_Be_Reused (SR, DL) then SR.Data (Low + By'Length .. DL) := SR.Data (High + 1 .. SR.Last); SR.Data (Low .. Low + By'Length - 1) := By; SR.Last := DL; -- Otherwise allocate new shared string and fill it else DR := Allocate (DL); DR.Data (1 .. Low - 1) := SR.Data (1 .. Low - 1); DR.Data (Low .. Low + By'Length - 1) := By; DR.Data (Low + By'Length .. DL) := SR.Data (High + 1 .. SR.Last); DR.Last := DL; Source.Reference := DR; Unreference (SR); end if; -- Otherwise just insert item else Insert (Source, Low, By); end if; end Replace_Slice; ------------------------------- -- Set_Unbounded_Wide_Wide_String -- ------------------------------- procedure Set_Unbounded_Wide_Wide_String (Target : out Unbounded_Wide_Wide_String; Source : Wide_Wide_String) is TR : constant Shared_Wide_Wide_String_Access := Target.Reference; DR : Shared_Wide_Wide_String_Access; begin -- In case of empty string, reuse empty shared string if Source'Length = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); Target.Reference := Empty_Shared_Wide_Wide_String'Access; else -- Try to reuse existent shared string if Can_Be_Reused (TR, Source'Length) then Reference (TR); DR := TR; -- Otherwise allocate new shared string else DR := Allocate (Source'Length); Target.Reference := DR; end if; DR.Data (1 .. Source'Length) := Source; DR.Last := Source'Length; end if; Unreference (TR); end Set_Unbounded_Wide_Wide_String; ----------- -- Slice -- ----------- function Slice (Source : Unbounded_Wide_Wide_String; Low : Positive; High : Natural) return Wide_Wide_String is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; begin -- Note: test of High > Length is in accordance with AI95-00128 if Low > SR.Last + 1 or else High > SR.Last then raise Index_Error; else return SR.Data (Low .. High); end if; end Slice; ---------- -- Tail -- ---------- function Tail (Source : Unbounded_Wide_Wide_String; Count : Natural; Pad : Wide_Wide_Character := Wide_Wide_Space) return Unbounded_Wide_Wide_String is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; DR : Shared_Wide_Wide_String_Access; begin -- For empty result reuse empty shared string if Count = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); DR := Empty_Shared_Wide_Wide_String'Access; -- Result is hole source string, reuse source shared string elsif Count = SR.Last then Reference (SR); DR := SR; -- Otherwise allocate new shared string and fill it else DR := Allocate (Count); if Count < SR.Last then DR.Data (1 .. Count) := SR.Data (SR.Last - Count + 1 .. SR.Last); else for J in 1 .. Count - SR.Last loop DR.Data (J) := Pad; end loop; DR.Data (Count - SR.Last + 1 .. Count) := SR.Data (1 .. SR.Last); end if; DR.Last := Count; end if; return (AF.Controlled with Reference => DR); end Tail; procedure Tail (Source : in out Unbounded_Wide_Wide_String; Count : Natural; Pad : Wide_Wide_Character := Wide_Wide_Space) is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; DR : Shared_Wide_Wide_String_Access; procedure Common (SR : Shared_Wide_Wide_String_Access; DR : Shared_Wide_Wide_String_Access; Count : Natural); -- Common code of tail computation. SR/DR can point to the same object ------------ -- Common -- ------------ procedure Common (SR : Shared_Wide_Wide_String_Access; DR : Shared_Wide_Wide_String_Access; Count : Natural) is begin if Count < SR.Last then DR.Data (1 .. Count) := SR.Data (SR.Last - Count + 1 .. SR.Last); else DR.Data (Count - SR.Last + 1 .. Count) := SR.Data (1 .. SR.Last); for J in 1 .. Count - SR.Last loop DR.Data (J) := Pad; end loop; end if; DR.Last := Count; end Common; begin -- Result is empty string, reuse empty shared string if Count = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); Source.Reference := Empty_Shared_Wide_Wide_String'Access; Unreference (SR); -- Length of the result is the same with length of the source string, -- reuse source shared string. elsif Count = SR.Last then null; -- Try to reuse existent shared string elsif Can_Be_Reused (SR, Count) then Common (SR, SR, Count); -- Otherwise allocate new shared string and fill it else DR := Allocate (Count); Common (SR, DR, Count); Source.Reference := DR; Unreference (SR); end if; end Tail; ------------------------- -- To_Wide_Wide_String -- ------------------------- function To_Wide_Wide_String (Source : Unbounded_Wide_Wide_String) return Wide_Wide_String is begin return Source.Reference.Data (1 .. Source.Reference.Last); end To_Wide_Wide_String; ----------------------------------- -- To_Unbounded_Wide_Wide_String -- ----------------------------------- function To_Unbounded_Wide_Wide_String (Source : Wide_Wide_String) return Unbounded_Wide_Wide_String is DR : Shared_Wide_Wide_String_Access; begin if Source'Length = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); DR := Empty_Shared_Wide_Wide_String'Access; else DR := Allocate (Source'Length); DR.Data (1 .. Source'Length) := Source; DR.Last := Source'Length; end if; return (AF.Controlled with Reference => DR); end To_Unbounded_Wide_Wide_String; function To_Unbounded_Wide_Wide_String (Length : Natural) return Unbounded_Wide_Wide_String is DR : Shared_Wide_Wide_String_Access; begin if Length = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); DR := Empty_Shared_Wide_Wide_String'Access; else DR := Allocate (Length); DR.Last := Length; end if; return (AF.Controlled with Reference => DR); end To_Unbounded_Wide_Wide_String; --------------- -- Translate -- --------------- function Translate (Source : Unbounded_Wide_Wide_String; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping) return Unbounded_Wide_Wide_String is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; DR : Shared_Wide_Wide_String_Access; begin -- Nothing to translate, reuse empty shared string if SR.Last = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); DR := Empty_Shared_Wide_Wide_String'Access; -- Otherwise, allocate new shared string and fill it else DR := Allocate (SR.Last); for J in 1 .. SR.Last loop DR.Data (J) := Value (Mapping, SR.Data (J)); end loop; DR.Last := SR.Last; end if; return (AF.Controlled with Reference => DR); end Translate; procedure Translate (Source : in out Unbounded_Wide_Wide_String; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping) is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; DR : Shared_Wide_Wide_String_Access; begin -- Nothing to translate if SR.Last = 0 then null; -- Try to reuse shared string elsif Can_Be_Reused (SR, SR.Last) then for J in 1 .. SR.Last loop SR.Data (J) := Value (Mapping, SR.Data (J)); end loop; -- Otherwise, allocate new shared string else DR := Allocate (SR.Last); for J in 1 .. SR.Last loop DR.Data (J) := Value (Mapping, SR.Data (J)); end loop; DR.Last := SR.Last; Source.Reference := DR; Unreference (SR); end if; end Translate; function Translate (Source : Unbounded_Wide_Wide_String; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function) return Unbounded_Wide_Wide_String is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; DR : Shared_Wide_Wide_String_Access; begin -- Nothing to translate, reuse empty shared string if SR.Last = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); DR := Empty_Shared_Wide_Wide_String'Access; -- Otherwise, allocate new shared string and fill it else DR := Allocate (SR.Last); for J in 1 .. SR.Last loop DR.Data (J) := Mapping.all (SR.Data (J)); end loop; DR.Last := SR.Last; end if; return (AF.Controlled with Reference => DR); exception when others => Unreference (DR); raise; end Translate; procedure Translate (Source : in out Unbounded_Wide_Wide_String; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function) is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; DR : Shared_Wide_Wide_String_Access; begin -- Nothing to translate if SR.Last = 0 then null; -- Try to reuse shared string elsif Can_Be_Reused (SR, SR.Last) then for J in 1 .. SR.Last loop SR.Data (J) := Mapping.all (SR.Data (J)); end loop; -- Otherwise allocate new shared string and fill it else DR := Allocate (SR.Last); for J in 1 .. SR.Last loop DR.Data (J) := Mapping.all (SR.Data (J)); end loop; DR.Last := SR.Last; Source.Reference := DR; Unreference (SR); end if; exception when others => if DR /= null then Unreference (DR); end if; raise; end Translate; ---------- -- Trim -- ---------- function Trim (Source : Unbounded_Wide_Wide_String; Side : Trim_End) return Unbounded_Wide_Wide_String is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; DL : Natural; DR : Shared_Wide_Wide_String_Access; Low : Natural; High : Natural; begin Low := Index_Non_Blank (Source, Forward); -- All blanks, reuse empty shared string if Low = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); DR := Empty_Shared_Wide_Wide_String'Access; else case Side is when Left => High := SR.Last; DL := SR.Last - Low + 1; when Right => Low := 1; High := Index_Non_Blank (Source, Backward); DL := High; when Both => High := Index_Non_Blank (Source, Backward); DL := High - Low + 1; end case; -- Length of the result is the same as length of the source string, -- reuse source shared string. if DL = SR.Last then Reference (SR); DR := SR; -- Otherwise, allocate new shared string else DR := Allocate (DL); DR.Data (1 .. DL) := SR.Data (Low .. High); DR.Last := DL; end if; end if; return (AF.Controlled with Reference => DR); end Trim; procedure Trim (Source : in out Unbounded_Wide_Wide_String; Side : Trim_End) is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; DL : Natural; DR : Shared_Wide_Wide_String_Access; Low : Natural; High : Natural; begin Low := Index_Non_Blank (Source, Forward); -- All blanks, reuse empty shared string if Low = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); Source.Reference := Empty_Shared_Wide_Wide_String'Access; Unreference (SR); else case Side is when Left => High := SR.Last; DL := SR.Last - Low + 1; when Right => Low := 1; High := Index_Non_Blank (Source, Backward); DL := High; when Both => High := Index_Non_Blank (Source, Backward); DL := High - Low + 1; end case; -- Length of the result is the same as length of the source string, -- nothing to do. if DL = SR.Last then null; -- Try to reuse existent shared string elsif Can_Be_Reused (SR, DL) then SR.Data (1 .. DL) := SR.Data (Low .. High); SR.Last := DL; -- Otherwise, allocate new shared string else DR := Allocate (DL); DR.Data (1 .. DL) := SR.Data (Low .. High); DR.Last := DL; Source.Reference := DR; Unreference (SR); end if; end if; end Trim; function Trim (Source : Unbounded_Wide_Wide_String; Left : Wide_Wide_Maps.Wide_Wide_Character_Set; Right : Wide_Wide_Maps.Wide_Wide_Character_Set) return Unbounded_Wide_Wide_String is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; DL : Natural; DR : Shared_Wide_Wide_String_Access; Low : Natural; High : Natural; begin Low := Index (Source, Left, Outside, Forward); -- Source includes only characters from Left set, reuse empty shared -- string. if Low = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); DR := Empty_Shared_Wide_Wide_String'Access; else High := Index (Source, Right, Outside, Backward); DL := Integer'Max (0, High - Low + 1); -- Source includes only characters from Right set or result string -- is empty, reuse empty shared string. if High = 0 or else DL = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); DR := Empty_Shared_Wide_Wide_String'Access; -- Otherwise, allocate new shared string and fill it else DR := Allocate (DL); DR.Data (1 .. DL) := SR.Data (Low .. High); DR.Last := DL; end if; end if; return (AF.Controlled with Reference => DR); end Trim; procedure Trim (Source : in out Unbounded_Wide_Wide_String; Left : Wide_Wide_Maps.Wide_Wide_Character_Set; Right : Wide_Wide_Maps.Wide_Wide_Character_Set) is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; DL : Natural; DR : Shared_Wide_Wide_String_Access; Low : Natural; High : Natural; begin Low := Index (Source, Left, Outside, Forward); -- Source includes only characters from Left set, reuse empty shared -- string. if Low = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); Source.Reference := Empty_Shared_Wide_Wide_String'Access; Unreference (SR); else High := Index (Source, Right, Outside, Backward); DL := Integer'Max (0, High - Low + 1); -- Source includes only characters from Right set or result string -- is empty, reuse empty shared string. if High = 0 or else DL = 0 then Reference (Empty_Shared_Wide_Wide_String'Access); Source.Reference := Empty_Shared_Wide_Wide_String'Access; Unreference (SR); -- Try to reuse existent shared string elsif Can_Be_Reused (SR, DL) then SR.Data (1 .. DL) := SR.Data (Low .. High); SR.Last := DL; -- Otherwise, allocate new shared string and fill it else DR := Allocate (DL); DR.Data (1 .. DL) := SR.Data (Low .. High); DR.Last := DL; Source.Reference := DR; Unreference (SR); end if; end if; end Trim; --------------------- -- Unbounded_Slice -- --------------------- function Unbounded_Slice (Source : Unbounded_Wide_Wide_String; Low : Positive; High : Natural) return Unbounded_Wide_Wide_String is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; DL : Natural; DR : Shared_Wide_Wide_String_Access; begin -- Check bounds if Low > SR.Last + 1 or else High > SR.Last then raise Index_Error; -- Result is empty slice, reuse empty shared string elsif Low > High then Reference (Empty_Shared_Wide_Wide_String'Access); DR := Empty_Shared_Wide_Wide_String'Access; -- Otherwise, allocate new shared string and fill it else DL := High - Low + 1; DR := Allocate (DL); DR.Data (1 .. DL) := SR.Data (Low .. High); DR.Last := DL; end if; return (AF.Controlled with Reference => DR); end Unbounded_Slice; procedure Unbounded_Slice (Source : Unbounded_Wide_Wide_String; Target : out Unbounded_Wide_Wide_String; Low : Positive; High : Natural) is SR : constant Shared_Wide_Wide_String_Access := Source.Reference; TR : constant Shared_Wide_Wide_String_Access := Target.Reference; DL : Natural; DR : Shared_Wide_Wide_String_Access; begin -- Check bounds if Low > SR.Last + 1 or else High > SR.Last then raise Index_Error; -- Result is empty slice, reuse empty shared string elsif Low > High then Reference (Empty_Shared_Wide_Wide_String'Access); Target.Reference := Empty_Shared_Wide_Wide_String'Access; Unreference (TR); else DL := High - Low + 1; -- Try to reuse existent shared string if Can_Be_Reused (TR, DL) then TR.Data (1 .. DL) := SR.Data (Low .. High); TR.Last := DL; -- Otherwise, allocate new shared string and fill it else DR := Allocate (DL); DR.Data (1 .. DL) := SR.Data (Low .. High); DR.Last := DL; Target.Reference := DR; Unreference (TR); end if; end if; end Unbounded_Slice; ----------------- -- Unreference -- ----------------- procedure Unreference (Item : not null Shared_Wide_Wide_String_Access) is procedure Free is new Ada.Unchecked_Deallocation (Shared_Wide_Wide_String, Shared_Wide_Wide_String_Access); Aux : Shared_Wide_Wide_String_Access := Item; begin if System.Atomic_Counters.Decrement (Aux.Counter) then -- Reference counter of Empty_Shared_Wide_Wide_String must never -- reach zero. pragma Assert (Aux /= Empty_Shared_Wide_Wide_String'Access); Free (Aux); end if; end Unreference; end Ada.Strings.Wide_Wide_Unbounded;
AdaCore/gpr
Ada
20
ads
package Y is end Y;
persan/AdaYaml
Ada
5,555
ads
-- part of AdaYaml, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "copying.txt" private with Ada.Containers.Hashed_Maps; with Yaml.Events.Store; package Yaml.Events.Context is type Reference is tagged private; type Cursor is private; type Local_Scope_Cursor is private; type Generated_Store_Cursor is private; type Symbol_Cursor is private; type Location_Type is (Generated, Local, Document, Stream, External, None); function Create (External : Store.Reference := Store.New_Store) return Reference; function External_Store (Object : Reference) return Store.Accessor; function Stream_Store (Object : Reference) return Store.Accessor; function Document_Store (Object : Reference) return Store.Accessor; function Transformed_Store (Object : Reference) return Store.Accessor; function Local_Store (Object : Reference; Position : Local_Scope_Cursor) return Store.Accessor; function Local_Store_Ref (Object : Reference; Position : Local_Scope_Cursor) return Store.Optional_Reference; function Generated_Store (Object : Reference; Position : Generated_Store_Cursor) return Store.Accessor; function Generated_Store_Ref (Object : Reference; Position : Generated_Store_Cursor) return Store.Optional_Reference; function Position (Object : Reference; Alias : Text.Reference) return Cursor; function Location (Position : Cursor) return Location_Type; procedure Create_Local_Store (Object : Reference; Position : out Local_Scope_Cursor); procedure Create_Local_Symbol_Scope (Object : Reference; Position : out Local_Scope_Cursor); procedure Release_Local_Store (Object : Reference; Position : Local_Scope_Cursor); procedure Create_Generated_Store (Object : Reference; Position : out Generated_Store_Cursor); procedure Release_Generated_Store (Object : Reference; Position : Generated_Store_Cursor); procedure Create_Symbol (Object : Reference; Scope : Local_Scope_Cursor; Name : Text.Reference; Position : out Symbol_Cursor); procedure Update_Symbol (Object : Reference; Scope : Local_Scope_Cursor; Position : Symbol_Cursor; New_Value : Cursor); function Symbol_Name (Position : Symbol_Cursor) return Text.Reference; No_Element : constant Cursor; No_Local_Store : constant Local_Scope_Cursor; function Is_Anchored (Pos : Cursor) return Boolean; function Retrieve (Pos : Cursor) return Store.Stream_Reference with Pre => Pos /= No_Element; function First (Pos : Cursor) return Event with Pre => Pos /= No_Element; function Exists_In_Ouput (Position : Cursor) return Boolean; procedure Set_Exists_In_Output (Position : in out Cursor); procedure Get_Store_And_Cursor (Position : Cursor; Target : out Store.Optional_Reference; Element_Position : out Events.Store.Element_Cursor); function To_Cursor (Object : Reference; Parent : Store.Optional_Reference; Element_Position : Events.Store.Element_Cursor) return Cursor; private type Cursor is record Target : Store.Optional_Reference; Anchored_Position : Events.Store.Anchor_Cursor; Element_Position : Events.Store.Element_Cursor; Target_Location : Location_Type; end record; package Symbol_Tables is new Ada.Containers.Hashed_Maps (Text.Reference, Cursor, Text.Hash, Text."="); type Symbol_Table_Pointer is access Symbol_Tables.Map; type Local_Scope is record Events : Store.Optional_Reference; Symbols : Symbol_Table_Pointer; end record; type Scope_Array is array (Positive range <>) of Local_Scope; type Scope_Array_Pointer is access Scope_Array; type Data_Array is array (Positive range <>) of Store.Optional_Reference; type Data_Array_Pointer is access Data_Array; type Instance is limited new Refcount_Base with record Generated_Data : Data_Array_Pointer; Document_Data, Stream_Data, External_Data, Transformed_Data : Store.Reference; Local_Scopes : Scope_Array_Pointer := null; Local_Scope_Count, Generated_Data_Count : Natural := 0; end record; type Instance_Access is access all Instance; overriding procedure Finalize (Object : in out Instance); type Local_Scope_Cursor is new Natural; type Generated_Store_Cursor is new Natural; type Symbol_Cursor is new Symbol_Tables.Cursor; type Reference is new Ada.Finalization.Controlled with record Data : not null Instance_Access := raise Constraint_Error with "uninitialized context instance!"; end record; overriding procedure Adjust (Object : in out Reference); overriding procedure Finalize (Object : in out Reference); No_Element : constant Cursor := (Target => Store.Null_Reference, Element_Position => Events.Store.No_Element, Anchored_Position => Events.Store.No_Anchor, Target_Location => None); No_Local_Store : constant Local_Scope_Cursor := 0; end Yaml.Events.Context;
zhmu/ananas
Ada
11,062
adb
------------------------------------------------------------------------------ -- -- -- GNAT SYSTEM UTILITIES -- -- -- -- X S N A M E S T -- -- -- -- 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. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This utility is used to make a new version of the Snames package when new -- names are added. This version reads a template file from snames.ads-tmpl in -- which the numbers are all written as $, and generates a new version of the -- spec file snames.ads (written to snames.ns). It also reads snames.adb-tmpl -- and generates an updated body (written to snames.nb), and snames.h-tmpl and -- generates an updated C header file (written to snames.nh). with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Strings.Unbounded.Text_IO; use Ada.Strings.Unbounded.Text_IO; with Ada.Strings.Maps; use Ada.Strings.Maps; with Ada.Strings.Maps.Constants; use Ada.Strings.Maps.Constants; with Ada.Text_IO; use Ada.Text_IO; with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO; with GNAT.Spitbol; use GNAT.Spitbol; with GNAT.Spitbol.Patterns; use GNAT.Spitbol.Patterns; with XUtil; use XUtil; procedure XSnamesT is subtype VString is GNAT.Spitbol.VString; InS : Ada.Text_IO.File_Type; InB : Ada.Text_IO.File_Type; InH : Ada.Text_IO.File_Type; OutS : Ada.Streams.Stream_IO.File_Type; OutB : Ada.Streams.Stream_IO.File_Type; OutH : Ada.Streams.Stream_IO.File_Type; A, B : VString := Nul; Line : VString := Nul; Name0 : VString := Nul; Name1 : VString := Nul; Name2 : VString := Nul; Oval : VString := Nul; Restl : VString := Nul; Name_Ref : constant Pattern := Span (' ') * A & Break (' ') * Name0 & Span (' ') * B & ": constant Name_Id := N + $;" & Rest * Restl; Get_Name : constant Pattern := "Name_" & Rest * Name1; Chk_Low : constant Pattern := Pos (0) & Any (Lower_Set) & Rest & Pos (1); Findu : constant Pattern := Span ('u') * A; Is_Conv : constant Pattern := "Convention_" & Rest; Val : Natural; Xlate_U_Und : constant Character_Mapping := To_Mapping ("u", "_"); M : Match_Result; type Header_Symbol is (None, Name, Attr, Conv, Prag); -- A symbol in the header file procedure Output_Header_Line (S : Header_Symbol); -- Output header line Header_Name : aliased String := "Name"; Header_Attr : aliased String := "Attr"; Header_Conv : aliased String := "Convention"; Header_Prag : aliased String := "Pragma"; -- Prefixes used in the header file type String_Ptr is access all String; Header_Prefix : constant array (Header_Symbol) of String_Ptr := (null, Header_Name'Access, Header_Attr'Access, Header_Conv'Access, Header_Prag'Access); -- Patterns used in the spec file Get_Attr : constant Pattern := Span (' ') & "Attribute_" & Break (",)") * Name1; Get_Conv : constant Pattern := Span (' ') & "Convention_" & Break (",)") * Name1; Get_Prag : constant Pattern := Span (' ') & "Pragma_" & Break (",)") * Name1; Get_Subt1 : constant Pattern := Span (' ') & "subtype " & Break (' ') * Name1 & " is " & Rest * Name2; Get_Subt2 : constant Pattern := Span (' ') & "range " & Break (' ') * Name1 & " .. " & Break (";") * Name2; type Header_Symbol_Counter is array (Header_Symbol) of Natural; Header_Counter : Header_Symbol_Counter := (0, 0, 0, 0, 0); Header_Current_Symbol : Header_Symbol := None; Header_Pending_Line : VString := Nul; ------------------------ -- Output_Header_Line -- ------------------------ procedure Output_Header_Line (S : Header_Symbol) is function Make_Value (V : Integer) return String; -- Build the definition for the current macro (Names are integers -- offset to N, while other items are enumeration values). ---------------- -- Make_Value -- ---------------- function Make_Value (V : Integer) return String is begin if S = Name then return "(First_Name_Id + 256 + " & V & ")"; else return "" & V; end if; end Make_Value; -- Start of processing for Output_Header_Line begin -- Skip all the #define for S-prefixed symbols in the header. -- Of course we are making implicit assumptions: -- (1) No newline between symbols with the same prefix. -- (2) Prefix order is the same as in snames.ads. if Header_Current_Symbol /= S then declare Pat : constant Pattern := "#define " & Header_Prefix (S).all & Break (' ') * Name2; In_Pat : Boolean := False; begin if Header_Current_Symbol /= None then Put_Line (OutH, Header_Pending_Line); end if; loop Line := Get_Line (InH); if Match (Line, Pat) then In_Pat := True; elsif In_Pat then Header_Pending_Line := Line; exit; else Put_Line (OutH, Line); end if; end loop; Header_Current_Symbol := S; end; end if; -- Now output the line -- Note that we must ensure at least one space between macro name and -- parens, otherwise the parenthesized value gets treated as an argument -- specification. Put_Line (OutH, "#define " & Header_Prefix (S).all & "_" & Name1 & (30 - Natural'Min (29, Length (Name1))) * ' ' & Make_Value (Header_Counter (S))); Header_Counter (S) := Header_Counter (S) + 1; end Output_Header_Line; -- Start of processing for XSnames begin Open (InS, In_File, "snames.ads-tmpl"); Open (InB, In_File, "snames.adb-tmpl"); Open (InH, In_File, "snames.h-tmpl"); -- Note that we do not generate snames.{ads,adb,h} directly. Instead -- we output them to snames.n{s,b,h} so that Makefiles can use -- move-if-change to not touch previously generated files if the -- new ones are identical. Create (OutS, Out_File, "snames.ns"); Create (OutB, Out_File, "snames.nb"); Create (OutH, Out_File, "snames.nh"); Put_Line (OutH, "#ifdef __cplusplus"); Put_Line (OutH, "extern ""C"" {"); Put_Line (OutH, "#endif"); Anchored_Mode := True; Val := 0; loop Line := Get_Line (InB); exit when Match (Line, " Preset_Names"); Put_Line (OutB, Line); end loop; Put_Line (OutB, Line); LoopN : while not End_Of_File (InS) loop Line := Get_Line (InS); if not Match (Line, Name_Ref) then Put_Line (OutS, Line); if Match (Line, Get_Attr) then Output_Header_Line (Attr); elsif Match (Line, Get_Conv) then Output_Header_Line (Conv); elsif Match (Line, Get_Prag) then Output_Header_Line (Prag); elsif Match (Line, Get_Subt1) and then Match (Name2, Is_Conv) then New_Line (OutH); Put_Line (OutH, "SUBTYPE (" & Name1 & ", " & Name2 & ", "); elsif Match (Line, Get_Subt2) and then Match (Name1, Is_Conv) then Put_Line (OutH, " " & Name1 & ", " & Name2 & ')'); end if; else if Match (Name0, "Last_") then Oval := Lpad (V (Val - 1), 3, '0'); else Oval := Lpad (V (Val), 3, '0'); end if; Put_Line (OutS, A & Name0 & B & ": constant Name_Id := N + " & Oval & ';' & Restl); if Match (Name0, Get_Name) then Name0 := Name1; Val := Val + 1; if Match (Name0, Findu, M) then Replace (M, Translate (A, Xlate_U_Und)); Translate (Name0, Lower_Case_Map); elsif Match (Name0, "UP_", "") then Translate (Name0, Upper_Case_Map); elsif Match (Name0, "Op_", "") then Name0 := 'O' & Translate (Name0, Lower_Case_Map); else Translate (Name0, Lower_Case_Map); end if; if not Match (Name0, Chk_Low) then Put_Line (OutB, " """ & Name0 & "#"" &"); end if; Output_Header_Line (Name); end if; end if; end loop LoopN; loop Line := Get_Line (InB); exit when Match (Line, " ""#"";"); end loop; Put_Line (OutB, Line); while not End_Of_File (InB) loop Line := Get_Line (InB); Put_Line (OutB, Line); end loop; Put_Line (OutH, Header_Pending_Line); while not End_Of_File (InH) loop Line := Get_Line (InH); Put_Line (OutH, Line); end loop; Put_Line (OutH, "#ifdef __cplusplus"); Put_Line (OutH, "}"); Put_Line (OutH, "#endif"); end XSnamesT;
docandrew/troodon
Ada
349
ads
with xcb; use xcb; with xcb_ewmh; use xcb_ewmh; with Compositor; with Render; package Events is type eventPtr is access all xcb_generic_event_t; procedure eventLoop (connection : access xcb_connection_t; rend : render.Renderer; mode : Compositor.CompositeMode); end Events;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
5,920
ads
-- This spec has been automatically generated from STM32F411xx.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with Interfaces; use Interfaces; with System; -- STM32F411xx package STM32_SVD is pragma Preelaborate; --------------- -- Base type -- --------------- type UInt32 is new Interfaces.Unsigned_32; type UInt16 is new Interfaces.Unsigned_16; type Byte is new Interfaces.Unsigned_8; type Bit is mod 2**1 with Size => 1; type UInt2 is mod 2**2 with Size => 2; type UInt3 is mod 2**3 with Size => 3; type UInt4 is mod 2**4 with Size => 4; type UInt5 is mod 2**5 with Size => 5; type UInt6 is mod 2**6 with Size => 6; type UInt7 is mod 2**7 with Size => 7; type UInt9 is mod 2**9 with Size => 9; type UInt10 is mod 2**10 with Size => 10; type UInt11 is mod 2**11 with Size => 11; type UInt12 is mod 2**12 with Size => 12; type UInt13 is mod 2**13 with Size => 13; type UInt14 is mod 2**14 with Size => 14; type UInt15 is mod 2**15 with Size => 15; type UInt17 is mod 2**17 with Size => 17; type UInt18 is mod 2**18 with Size => 18; type UInt19 is mod 2**19 with Size => 19; type UInt20 is mod 2**20 with Size => 20; type UInt21 is mod 2**21 with Size => 21; type UInt22 is mod 2**22 with Size => 22; type UInt23 is mod 2**23 with Size => 23; type UInt24 is mod 2**24 with Size => 24; type UInt25 is mod 2**25 with Size => 25; type UInt26 is mod 2**26 with Size => 26; type UInt27 is mod 2**27 with Size => 27; type UInt28 is mod 2**28 with Size => 28; type UInt29 is mod 2**29 with Size => 29; type UInt30 is mod 2**30 with Size => 30; type UInt31 is mod 2**31 with Size => 31; -------------------- -- Base addresses -- -------------------- ADC_Common_Base : constant System.Address := System'To_Address (16#40012300#); ADC1_Base : constant System.Address := System'To_Address (16#40012000#); CRC_Base : constant System.Address := System'To_Address (16#40023000#); DBG_Base : constant System.Address := System'To_Address (16#E0042000#); EXTI_Base : constant System.Address := System'To_Address (16#40013C00#); FLASH_Base : constant System.Address := System'To_Address (16#40023C00#); IWDG_Base : constant System.Address := System'To_Address (16#40003000#); OTG_FS_DEVICE_Base : constant System.Address := System'To_Address (16#50000800#); OTG_FS_GLOBAL_Base : constant System.Address := System'To_Address (16#50000000#); OTG_FS_HOST_Base : constant System.Address := System'To_Address (16#50000400#); OTG_FS_PWRCLK_Base : constant System.Address := System'To_Address (16#50000E00#); PWR_Base : constant System.Address := System'To_Address (16#40007000#); RCC_Base : constant System.Address := System'To_Address (16#40023800#); RTC_Base : constant System.Address := System'To_Address (16#40002800#); SDIO_Base : constant System.Address := System'To_Address (16#40012C00#); SYSCFG_Base : constant System.Address := System'To_Address (16#40013800#); TIM1_Base : constant System.Address := System'To_Address (16#40010000#); TIM8_Base : constant System.Address := System'To_Address (16#40010400#); TIM10_Base : constant System.Address := System'To_Address (16#40014400#); TIM11_Base : constant System.Address := System'To_Address (16#40014800#); TIM2_Base : constant System.Address := System'To_Address (16#40000000#); TIM3_Base : constant System.Address := System'To_Address (16#40000400#); TIM4_Base : constant System.Address := System'To_Address (16#40000800#); TIM5_Base : constant System.Address := System'To_Address (16#40000C00#); TIM9_Base : constant System.Address := System'To_Address (16#40014000#); USART1_Base : constant System.Address := System'To_Address (16#40011000#); USART2_Base : constant System.Address := System'To_Address (16#40004400#); USART6_Base : constant System.Address := System'To_Address (16#40011400#); WWDG_Base : constant System.Address := System'To_Address (16#40002C00#); DMA2_Base : constant System.Address := System'To_Address (16#40026400#); DMA1_Base : constant System.Address := System'To_Address (16#40026000#); GPIOH_Base : constant System.Address := System'To_Address (16#40021C00#); GPIOE_Base : constant System.Address := System'To_Address (16#40021000#); GPIOD_Base : constant System.Address := System'To_Address (16#40020C00#); GPIOC_Base : constant System.Address := System'To_Address (16#40020800#); GPIOB_Base : constant System.Address := System'To_Address (16#40020400#); GPIOA_Base : constant System.Address := System'To_Address (16#40020000#); I2C3_Base : constant System.Address := System'To_Address (16#40005C00#); I2C2_Base : constant System.Address := System'To_Address (16#40005800#); I2C1_Base : constant System.Address := System'To_Address (16#40005400#); I2S2ext_Base : constant System.Address := System'To_Address (16#40003400#); I2S3ext_Base : constant System.Address := System'To_Address (16#40004000#); SPI1_Base : constant System.Address := System'To_Address (16#40013000#); SPI2_Base : constant System.Address := System'To_Address (16#40003800#); SPI3_Base : constant System.Address := System'To_Address (16#40003C00#); SPI4_Base : constant System.Address := System'To_Address (16#40013400#); SPI5_Base : constant System.Address := System'To_Address (16#40015000#); NVIC_Base : constant System.Address := System'To_Address (16#E000E000#); end STM32_SVD;
charlie5/cBound
Ada
1,510
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces.C; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_glx_get_color_table_parameteriv_cookie_t is -- Item -- type Item is record sequence : aliased Interfaces.C.unsigned; end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb .xcb_glx_get_color_table_parameteriv_cookie_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_color_table_parameteriv_cookie_t.Item, Element_Array => xcb.xcb_glx_get_color_table_parameteriv_cookie_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_glx_get_color_table_parameteriv_cookie_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_color_table_parameteriv_cookie_t.Pointer, Element_Array => xcb.xcb_glx_get_color_table_parameteriv_cookie_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_glx_get_color_table_parameteriv_cookie_t;
stcarrez/ada-util
Ada
1,660
ads
----------------------------------------------------------------------- -- util-encoders-kdf-hotp -- HMAC-based One-Time Password, RFC 4226. -- Copyright (C) 2023 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. ----------------------------------------------------------------------- -- HMAC-based One-Time Password, RFC 4226. The counter value encoded -- in big-endiang as 8-bytes is hashed using the given algorithm. Then -- the HMAC result is truncated to keep a 31-bit value (See RFC 4226 for -- the truncation algorithm) and `Count` digits are kept from the 31-bit -- value and returned in `Result`. generic Length : Stream_Element_Offset; with procedure Hash (Key : in Ada.Streams.Stream_Element_Array; Data : in Ada.Streams.Stream_Element_Array; Into : out Ada.Streams.Stream_Element_Array); function Util.Encoders.HMAC.HOTP (Secret : in Secret_Key; Counter : in Interfaces.Unsigned_64; Count : in Positive) return Natural;
Rodeo-McCabe/orka
Ada
3,139
adb
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2020 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 Ahven; use Ahven; with GL.Types; with Orka.SIMD.AVX.Doubles; with Orka.SIMD.FMA.Doubles.Arithmetic; package body Test_SIMD_FMA_Doubles_Arithmetic is use GL.Types; use Orka; use Orka.SIMD.AVX.Doubles; use Orka.SIMD.FMA.Doubles.Arithmetic; overriding procedure Initialize (T : in out Test) is begin T.Set_Name ("Arithmetic"); T.Add_Test_Routine (Test_Multiply_Vector'Access, "Test '*' operator on matrix and vector"); T.Add_Test_Routine (Test_Multiply_Matrices'Access, "Test '*' operator on matrices"); end Initialize; procedure Test_Multiply_Vector is -- Matrix is an array of columns Left : constant m256d_Array := ((1.0, 5.0, 9.0, 13.0), (2.0, 6.0, 10.0, 14.0), (3.0, 7.0, 11.0, 15.0), (4.0, 8.0, 12.0, 16.0)); Right : constant m256d := (2.0, 1.0, 1.0, 1.0); Expected : constant m256d := (11.0, 31.0, 51.0, 71.0); Result : constant m256d := Left * Right; begin for I in Index_Homogeneous loop Assert (Expected (I) = Result (I), "Unexpected Double at " & Index_Homogeneous'Image (I)); end loop; end Test_Multiply_Vector; procedure Test_Multiply_Matrices is -- Each matrix is an array of columns Left : constant m256d_Array := ((1.0, 5.0, 9.0, 13.0), (2.0, 6.0, 10.0, 14.0), (3.0, 7.0, 11.0, 15.0), (4.0, 8.0, 12.0, 16.0)); Right : constant m256d_Array := ((2.0, 1.0, 1.0, 1.0), (1.0, 2.0, 1.0, 1.0), (1.0, 1.0, 2.0, 1.0), (1.0, 1.0, 1.0, 2.0)); Expected : constant m256d_Array := ((11.0, 31.0, 51.0, 71.0), (12.0, 32.0, 52.0, 72.0), (13.0, 33.0, 53.0, 73.0), (14.0, 34.0, 54.0, 74.0)); Result : constant m256d_Array := Left * Right; begin for I in Index_Homogeneous loop for J in Index_Homogeneous loop Assert (Expected (I) (J) = Result (I) (J), "Unexpected Double at " & Index_Homogeneous'Image (I)); end loop; end loop; end Test_Multiply_Matrices; end Test_SIMD_FMA_Doubles_Arithmetic;
mirror/ncurses
Ada
3,082
ads
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- ncurses -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright 2020 Thomas E. Dickey -- -- Copyright 2000 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: Eugene V. Melaragno <[email protected]> 2000 -- Version Control -- $Revision: 1.2 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ procedure ncurses2.color_edit;
ytomino/vampire
Ada
9,058
adb
-- The Village of Vampire by YT, このソースコードはNYSLです with Ada.Characters.Conversions; with Ada.Hierarchical_File_Names; with Ada.Strings.Functions.Maps; with Ada.Strings.Maps.Constants; with Ada.Strings.Maps.Naked; with Ada.Strings.Naked_Maps.General_Category; package body Vampire.Forms is use type Ada.Strings.Maps.Character_Set; use type Ada.Strings.Unbounded.Unbounded_String; function Self return String is begin -- "http://.../vampire/" -> "" -- "http://localhost/vampire.cgi" -> "vampire.cgi" return Ada.Hierarchical_File_Names.Unchecked_Simple_Name ( Web.Request_Path); end Self; function Parameters_To_Base_Page ( Form : Root_Form_Type'Class; Base_Page : Forms.Base_Page; Village_Id : Villages.Village_Id; User_Id : String; User_Password : String) return Web.Query_Strings is begin case Base_Page is when Index_Page => return Form.Parameters_To_Index_Page ( User_Id => User_Id, User_Password => User_Password); when User_Page => return Form.Parameters_To_User_Page ( User_Id => User_Id, User_Password => User_Password); when Forms.User_List_Page => raise Program_Error with "unimplemented"; when Forms.Village_Page => return Form.Parameters_To_Village_Page ( Village_Id => Village_Id, User_Id => User_Id, User_Password => User_Password); end case; end Parameters_To_Base_Page; procedure Write_Attribute_Name ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Name : in String) is begin String'Write (Stream, Name); Character'Write (Stream, '='); end Write_Attribute_Name; procedure Write_Attribute_Open ( Stream : not null access Ada.Streams.Root_Stream_Type'Class) is begin Character'Write (Stream, '"'); end Write_Attribute_Open; procedure Write_Attribute_Close ( Stream : not null access Ada.Streams.Root_Stream_Type'Class) renames Write_Attribute_Open; procedure Write_Link ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Form : in Root_Form_Type'Class; Current_Directory : in String; Resource : in String; Parameters : in Web.Query_Strings := Web.String_Maps.Empty_Map) is Relative : constant String := Ada.Hierarchical_File_Names.Relative_Name ( Name => Resource, From => Current_Directory); begin Write_Attribute_Open (Stream); if Parameters.Is_Empty then if Relative'Length = 0 or else Ada.Hierarchical_File_Names.Is_Current_Directory_Name (Relative) then Web.HTML.Write_In_Attribute (Stream, Form.HTML_Version, "./"); else Web.HTML.Write_In_Attribute (Stream, Form.HTML_Version, Relative); end if; else Web.HTML.Write_In_Attribute (Stream, Form.HTML_Version, Relative); Web.HTML.Write_Query_In_Attribute ( Stream, Form.HTML_Version, Parameters); -- Parameters should contain ASCII only end if; Write_Attribute_Close (Stream); end Write_Link; procedure Write_Link_To_Village_Page ( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Form : in Root_Form_Type'Class; Current_Directory : in String; HTML_Directory : in String; Log : in Boolean; Village_Id : Tabula.Villages.Village_Id; Day : Integer := -1; First : Tabula.Villages.Speech_Index'Base := -1; Last : Tabula.Villages.Speech_Index'Base := -1; Latest : Tabula.Villages.Speech_Positive_Count'Base := -1; User_Id : in String; User_Password : in String) is begin if Log then Write_Link ( Stream, Form, Current_Directory => Current_Directory, Resource => Ada.Hierarchical_File_Names.Compose ( Directory => HTML_Directory, Relative_Name => Village_Id & "-" & Image (Integer'Max (0, Day)), Extension => "html")); else Write_Link ( Stream, Form, Current_Directory => Current_Directory, Resource => Self, Parameters => Form.Parameters_To_Village_Page ( Village_Id => Village_Id, Day => Day, First => First, Last => Last, Latest => Latest, User_Id => User_Id, User_Password => User_Password)); end if; end Write_Link_To_Village_Page; function Get_New_User_Id ( Form : Root_Form_Type'Class; Inputs : Web.Query_Strings) return String is begin return Web.Element (Inputs, "id"); end Get_New_User_Id; function Get_New_User_Password ( Form : Root_Form_Type'Class; Inputs : Web.Query_Strings) return String is begin return Web.Element (Inputs, "password"); end Get_New_User_Password; function Get_New_User_Confirmation_Password ( Form : Root_Form_Type'Class; Inputs : Web.Query_Strings) return String is begin return Web.Element (Inputs, "password2"); end Get_New_User_Confirmation_Password; function Get_Base_Page ( Form : Root_Form_Type'Class; Query_Strings : Web.Query_Strings; Cookie : Web.Cookie) return Base_Page is begin if Form.Get_Village_Id (Query_Strings) /= Tabula.Villages.Invalid_Village_Id then return Village_Page; elsif Form.Is_User_Page (Query_Strings, Cookie) then return User_Page; elsif Form.Is_User_List_Page (Query_Strings) then return User_List_Page; else return Index_Page; end if; end Get_Base_Page; function Is_User_List_Page ( Form : Root_Form_Type'Class; Query_Strings : Web.Query_Strings) return Boolean is begin return Web.Element (Query_Strings, "users") = "all"; end Is_User_List_Page; function Get_Command ( Form : Root_Form_Type'Class; Inputs : Web.Query_Strings) return String is begin return Web.Element (Inputs, "cmd"); end Get_Command; function Get_Group ( Form : Root_Form_Type; Inputs : Web.Query_Strings) return Integer is begin return Integer'Value (Web.Element (Inputs, "group")); end Get_Group; function Get_Joining ( Form : Root_Form_Type; Inputs : Web.Query_Strings) return Joining is begin return ( Work_Index => Integer'Value (Web.Element (Inputs, "work")), Name_Index => Natural'Value (Web.Element (Inputs, "name")), Request => +Web.Element (Inputs, "request")); end Get_Joining; function Get_Answered ( Form : Root_Form_Type; Inputs : Web.Query_Strings) return Mark is begin declare X : constant Integer := Integer'Value (Web.Element (Inputs, "x")); Y : constant Integer := Integer'Value (Web.Element (Inputs, "y")); Z : constant Integer := Integer'Value (Web.Element (Inputs, "z")); begin if X + Y = Z then return OK; else return NG; end if; end; exception when Constraint_Error => return Missing; end Get_Answered; function Get_Reedit_Kind ( Form : Root_Form_Type'Class; Inputs : Web.Query_Strings) return String is begin return Web.Element (Inputs, "kind"); end Get_Reedit_Kind; function Get_Action ( Form : Root_Form_Type'Class; Inputs : Web.Query_Strings) return String is begin return Web.Element (Inputs, "action"); end Get_Action; function Get_Target ( Form : Root_Form_Type'Class; Inputs : Web.Query_Strings) return Villages.Person_Index'Base is begin return Villages.Person_Index'Base'Value (Web.Element (Inputs, "target")); end Get_Target; function Get_Special ( Form : Root_Form_Type'Class; Inputs : Web.Query_Strings) return Boolean is begin return Web.HTML.Checkbox_Value (Web.Element (Inputs, "special")); end Get_Special; procedure Set_Rule ( Form : in Root_Form_Type'Class; Village : in out Tabula.Villages.Village_Type'Class; Inputs : in Web.Query_Strings) is procedure Process (Item : in Tabula.Villages.Root_Option_Item'Class) is begin Tabula.Villages.Change (Village, Item, Web.Element (Inputs, Item.Name)); end Process; begin Tabula.Villages.Iterate_Options (Village, Process'Access); end Set_Rule; -- implementation of private function Spacing_Set return Ada.Strings.Maps.Character_Set is function Space_Separator_Set is new Ada.Strings.Maps.Naked.To_Set ( Ada.Strings.Naked_Maps.General_Category.Space_Separator); begin return Space_Separator_Set or Ada.Strings.Maps.Constants.Control_Set; end Spacing_Set; function Trim_Name (S : String) return String is Set : Ada.Strings.Maps.Character_Set renames Spacing_Set; begin return Ada.Strings.Functions.Maps.Trim (S, Left => Set, Right => Set); end Trim_Name; function Trim_Text (S : String) return String is First : Positive; Last : Natural; begin declare Set : Ada.Strings.Maps.Character_Set renames Spacing_Set; begin Ada.Strings.Functions.Maps.Trim (S, Left => Set, Right => Set, First => First, Last => Last); end; while First > S'First loop declare I : Positive; C : Wide_Wide_Character; Is_Illegal_Sequence : Boolean; begin Ada.Characters.Conversions.Get_Reverse ( S (S'First .. First - 1), First => I, Value => C, Is_Illegal_Sequence => Is_Illegal_Sequence); exit when Is_Illegal_Sequence or else Ada.Strings.Maps.Overloaded_Is_In ( C, Ada.Strings.Maps.Constants.Control_Set); First := I; end; end loop; return S (First .. Last); end Trim_Text; end Vampire.Forms;
nerilex/ada-util
Ada
2,216
ads
----------------------------------------------------------------------- -- util-encodes-tests - Test for encoding -- Copyright (C) 2009, 2010, 2011, 2012, 2016 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.Tests; package Util.Encoders.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new Util.Tests.Test with null record; procedure Test_Hex (T : in out Test); procedure Test_Base64_Encode (T : in out Test); procedure Test_Base64_Decode (T : in out Test); procedure Test_Base64_URL_Encode (T : in out Test); procedure Test_Base64_URL_Decode (T : in out Test); procedure Test_Encoder (T : in out Test; C : in out Util.Encoders.Encoder); procedure Test_Base64_Benchmark (T : in out Test); procedure Test_SHA1_Encode (T : in out Test); -- Benchmark test for SHA1 procedure Test_SHA1_Benchmark (T : in out Test); -- Test HMAC-SHA1 procedure Test_HMAC_SHA1_RFC2202_T1 (T : in out Test); procedure Test_HMAC_SHA1_RFC2202_T2 (T : in out Test); procedure Test_HMAC_SHA1_RFC2202_T3 (T : in out Test); procedure Test_HMAC_SHA1_RFC2202_T4 (T : in out Test); procedure Test_HMAC_SHA1_RFC2202_T5 (T : in out Test); procedure Test_HMAC_SHA1_RFC2202_T6 (T : in out Test); procedure Test_HMAC_SHA1_RFC2202_T7 (T : in out Test); -- Test encoding leb128. procedure Test_LEB128 (T : in out Test); -- Test encoding leb128 + base64url. procedure Test_Base64_LEB128 (T : in out Test); end Util.Encoders.Tests;
optikos/oasis
Ada
577
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Elements.Clauses; package Program.Elements.Representation_Clauses is pragma Pure (Program.Elements.Representation_Clauses); type Representation_Clause is limited interface and Program.Elements.Clauses.Clause; type Representation_Clause_Access is access all Representation_Clause'Class with Storage_Size => 0; end Program.Elements.Representation_Clauses;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
969
adb
with STM32_SVD; use STM32_SVD; package body Drivers.Si7060 is function Init return Boolean is begin return I2C.Write_Register (Address, 16#C4#, 2#0000_0001#); end Init; function Temperature_x100 (R : out Temperature_Type) return Boolean is M, LSB, MSB : Byte; begin if not I2C.Test (Address) then return False; end if; if I2C.Write_Register (Address, 16#C4#, 2#0000_0100#) and then I2C.Read_Register (Address, 16#C4#, M) and then (M and 2#0000_0010#) /= 0 and then I2C.Read_Register (Address, 16#C1#, MSB) and then I2C.Read_Register (Address, 16#C2#, LSB) and then I2C.Write_Register (Address, 16#C4#, 2#0000_0001#) then R := Temperature_Type ( 5500 + (Integer (MSB and 2#0111_1111#) * 256 + Integer (LSB) - 16384) * 10 / 16); return True; end if; return False; end Temperature_x100; end Drivers.Si7060;
jscparker/math_packages
Ada
3,226
adb
----------------------------------------------------------------------- -- package body Binary_Rank, routines for Marsaglia's Rank Test. -- Copyright (C) 1995-2018 Jonathan S. Parker -- -- Permission to use, copy, modify, and/or distribute this software for any -- purpose with or without fee is hereby granted, provided that the above -- copyright notice and this permission notice appear in all copies. -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ------------------------------------------------------------------------------- package body Binary_Rank is -------------- -- Get_Rank -- -------------- procedure Get_Rank (r : in out Binary_Matrix; Max_Row : in Matrix_Index; Max_Col : in Matrix_Index; Rank : out Integer) is tmp : Vector; j : Matrix_Index := Max_Col; -- essential init. i : Matrix_Index := Matrix_Index'First; -- essential init. ----------------------------- -- Vector_has_a_1_at_Index -- ----------------------------- function Vector_has_a_1_at_Index (j : Matrix_Index; V : Vector) return Boolean is Result : Boolean := False; Segment_id : Segments; Bit_id : Matrix_Index; begin Segment_id := 1 + (j-1) / Bits_per_Segment; Bit_id := 1 + (j-1) - (Segment_id-1) * Bits_per_Segment; if (V(Segment_id) AND Bit_is_1_at(Bit_id)) > 0 then Result := True; end if; return Result; end; begin Rank := 0; <<Reduce_Matrix_Rank_by_1>> -- Start at row i, the current row. -- Find row ii = i, i+1, ... that has a 1 in column j. -- Then move this row to position i. (Swap ii with i.) -- Reduce rank of matrix by 1 (by xor'ing row(i) with succeeding rows). -- Increment i, Decrement j. -- Repeat until no more i's or j's left. Row_Finder: for ii in i .. Max_Row loop if Vector_has_a_1_at_Index (j, r(ii)) then Rank := Rank + 1; if i /= ii then tmp := r(ii); r(ii) := r(i); r(i) := tmp; end if; for k in i+1 .. Max_Row loop if Vector_has_a_1_at_Index (j, r(k)) then for Seg_id in Segments loop r(k)(Seg_id) := r(k)(Seg_id) XOR r(i)(Seg_id); end loop; end if; end loop; if i = Max_Row then return; end if; i := i + 1; if j = Matrix_Index'First then return; end if; j := j - 1; goto Reduce_Matrix_Rank_by_1; end if; end loop Row_Finder; -- ii loop if j = Matrix_Index'First then return; end if; j := j - 1; goto Reduce_Matrix_Rank_by_1; end Get_Rank; end Binary_Rank;
AdaCore/libadalang
Ada
985
adb
with Ada.Text_IO; use Ada.Text_IO; with Langkit_Support.Text; use Langkit_Support.Text; with Libadalang.Analysis; use Libadalang.Analysis; with Libadalang.Common; use Libadalang.Common; with Libadalang.Iterators; use Libadalang.Iterators; procedure Main is Ctx : constant Analysis_Context := Create_Context; Unit : constant Analysis_Unit := Get_From_File (Ctx, "pkg.ads"); Type_Defs : constant Ada_Node_Array := Find (Unit.Root, Kind_In (Ada_Concrete_Type_Decl, Ada_Formal_Type_Decl)).Consume; begin for T of Type_Defs loop declare TD : constant Type_Decl := T.As_Type_Decl; RTD : constant Record_Type_Def := TD.F_Type_Def.As_Record_Type_Def; Name : constant Text_Type := TD.F_Name.Text; begin Put_Line (Image (Name) & " is abstract: " & Boolean'Image (RTD.F_Has_Abstract)); end; end loop; Put_Line ("Done."); end Main;
seL4/isabelle
Ada
261
ads
package Greatest_Common_Divisor is --# function Gcd(A, B: Natural) return Natural; procedure G_C_D(M, N: in Natural; G: out Natural); --# derives G from M, N; --# pre M >= 0 and N > 0; --# post G = Gcd(M,N); end Greatest_Common_Divisor;
stcarrez/ada-util
Ada
3,709
ads
----------------------------------------------------------------------- -- util-concurrent-pools -- Concurrent Pools -- Copyright (C) 2011, 2015, 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 Ada.Finalization; -- The <b>Util.Concurrent.Pools</b> generic defines a pool of objects which -- can be shared by multiple threads. First, the pool is configured to have -- a number of objects by using the <b>Set_Size</b> procedure. Then, a thread -- that needs an object uses the <b>Get_Instance</b> to get an object. -- The object is removed from the pool. As soon as the thread has finished, -- it puts back the object in the pool using the <b>Release</b> procedure. -- -- The <b>Get_Instance</b> entry will block until an object is available. generic type Element_Type is private; package Util.Concurrent.Pools is pragma Preelaborate; FOREVER : constant Duration := -1.0; -- Exception raised if the Get_Instance timeout exceeded. Timeout : exception; -- Pool of objects type Pool is limited new Ada.Finalization.Limited_Controlled with private; -- Get an element instance from the pool. -- Wait until one instance gets available. procedure Get_Instance (From : in out Pool; Item : out Element_Type; Wait : in Duration := FOREVER); -- Put the element back to the pool. procedure Release (Into : in out Pool; Item : in Element_Type); -- Set the pool size. procedure Set_Size (Into : in out Pool; Capacity : in Positive); -- Get the number of available elements in the pool. procedure Get_Available (From : in out Pool; Available : out Natural); -- Release the pool elements. overriding procedure Finalize (Object : in out Pool); private -- To store the pool elements, we use an array which is allocated dynamically -- by the <b>Set_Size</b> protected operation. The generated code is smaller -- compared to the use of Ada vectors container. type Element_Array is array (Positive range <>) of Element_Type; type Element_Array_Access is access all Element_Array; Null_Element_Array : constant Element_Array_Access := null; -- Pool of objects protected type Protected_Pool is -- Get an element instance from the pool. -- Wait until one instance gets available. entry Get_Instance (Item : out Element_Type); -- Put the element back to the pool. procedure Release (Item : in Element_Type); -- Set the pool size. procedure Set_Size (Capacity : in Natural); -- Get the number of available elements. function Get_Available return Natural; private Available : Natural := 0; Elements : Element_Array_Access := Null_Element_Array; end Protected_Pool; type Pool is limited new Ada.Finalization.Limited_Controlled with record List : Protected_Pool; end record; end Util.Concurrent.Pools;
reznikmm/matreshka
Ada
3,704
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.Text_Ref_Name_Attributes is pragma Preelaborate; type ODF_Text_Ref_Name_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Text_Ref_Name_Attribute_Access is access all ODF_Text_Ref_Name_Attribute'Class with Storage_Size => 0; end ODF.DOM.Text_Ref_Name_Attributes;