repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
zrmyers/VulkanAda
Ada
1,907
ads
-------------------------------------------------------------------------------- -- MIT License -- -- Copyright (c) 2021 Zane Myers -- -- Permission is hereby granted, free of charge, to any person obtaining a copy -- of this software and associated documentation files (the "Software"), to deal -- in the Software without restriction, including without limitation the rights -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -- copies of the Software, and to permit persons to whom the Software is -- furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in all -- copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -- SOFTWARE. -------------------------------------------------------------------------------- with Vulkan.Math.Dmat2x2; use Vulkan.Math.Dmat2x2; -------------------------------------------------------------------------------- --< @group Vulkan Math Basic Types -------------------------------------------------------------------------------- --< @summary --< This package provides a double precision floating point matrix with 2 rows --< and 2 columns. -------------------------------------------------------------------------------- package Vulkan.Math.Dmat2x2.Test is -- Test Harness for Dmat2x2 regression tests procedure Test_Dmat2x2; end Vulkan.Math.Dmat2x2.Test;
Heziode/lsystem-editor
Ada
1,552
ads
------------------------------------------------------------------------------- -- 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. ------------------------------------------------------------------------------- -- @description -- This package encompass all packages related to Input/Output. -- package LSE.Model.IO is pragma Pure; end LSE.Model.IO;
AdaCore/libadalang
Ada
189
ads
package Pkg is type Rec is record I : Integer; end record; R : constant Rec := (I => 1); I : constant Integer := R.I; --% node.f_default_expr.p_eval_as_int end Pkg;
Heziode/lsystem-editor
Ada
4,345
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.Directories; package body LSE.Model.IO.Text_File is package L renames Ada.Characters.Latin_1; procedure Open_File (File : in out File_Type; Mode : File_Mode; Path : String; Auto : Boolean := True) is use Ada.Directories; -- The parameter "wcem=8" indicates that we want to open a file in -- UTF-8 format (which can therefore contain accents) FILE_FORM : constant String := "wcem=8"; begin if Exists (Path) then Open (File, Mode, Path, FILE_FORM); else if Auto then Create (File, Mode, Path, FILE_FORM); else raise Ada.Directories.Name_Error; end if; end if; end Open_File; procedure Close_File (File : in out File_Type) is begin Close (File); end Close_File; procedure Read (File : File_Type; Result : out Unbounded_String) is begin Result := To_Unbounded_String (""); loop exit when End_Of_File (File); if End_Of_Line (File) then Skip_Line (File); elsif End_Of_Page (File) then Skip_Page (File); else Result := Result & To_Unbounded_String (Get_Line (File)) & L.LF; end if; end loop; end Read; procedure Write (File : in out File_Type; Item : String) is begin Put_Line (File, Item); end Write; function Read_LSystem (File : File_Type; Builder : in out LSE.Model.L_System.Concrete_Builder.Instance; Turtle : LSE.Model.IO.Turtle_Utils.Holder; LS : in out LSE.Model.L_System.L_System.Instance) return Boolean is Item : Unbounded_String; begin Read (File, Item); if Builder.Make (To_String (Item)) then LS := Builder.Get_Product (Turtle); return True; else return False; end if; end Read_LSystem; procedure Write_LSystem (File : in out File_Type; LS : LSE.Model.L_System.L_System.Instance) is begin Put_Line (File, LS.Get_LSystem); end Write_LSystem; procedure Save_To_File (File_Path : String; Content : String) is File : File_Type; begin Open_File (File, Out_File, File_Path); Write (File, Content); Close_File (File); end Save_To_File; function Read_From_File (File_Path : String) return String is File : File_Type; Item : Unbounded_String; begin Open_File (File, In_File, File_Path); Read (File, Item); Close_File (File); return To_String (Item); end Read_From_File; end LSE.Model.IO.Text_File;
zhmu/ananas
Ada
458
ads
with Generic_Inst3_Kafka_Lib.Topic; with Generic_Inst3_Traits.Encodables; package Generic_Inst3_Markets is type Data_Type is null record; function Image (D : Data_Type) return String is (""); package Data_Encodables is new Generic_Inst3_Traits.Encodables (Data_Type, Image); package Data_Topic is new Generic_Inst3_Kafka_Lib.Topic (Keys => Data_Encodables, Values => Data_Encodables, Topic_Name => "bla"); end Generic_Inst3_Markets;
jscparker/math_packages
Ada
2,620
ads
-- package Tridiagonal_LU -- -- The package implements Crout's method for LU decomposition of -- tri-diagonal matrices. Matrix A is input in the form of three -- diagonals: the central diagonal of A, indexed by 0, and the -- two side diagonals indexed by -1 and 1. -- -- The LU form of A can then be used to solve simultaneous linear -- equations of the form A * X = B. The column vector B is input -- into procedure Solve, and the solution is returned as X. generic type Real is digits <>; type Index is range <>; package Tridiagonal_LU is type Diagonal is array(Index) of Real; D : constant := 1; type DiagonalID is range -D..D; -- The lower diagonal is the -1; The upper diagonal is the +1. type Matrix is array(DiagonalID) of Diagonal; -- Row major form is appropriate for Matrix*ColumnVector -- operations, which dominate the algorithm in procedure -- Solve. -- The lower diagonal is the -1; The upper diagonal is the +1. procedure LU_Decompose (A : in out Matrix; Index_Start : in Index := Index'First; Index_Finish : in Index := Index'Last); -- In the output matrix A, the lower triangular matrix L is stored -- in the lower triangular region of A, and the upper, U, is stored -- in the upper triangular region of A. -- The diagonal of U is assumed to be entirely 1.0, hence the output -- matrix A stores the diagonal elements of L along its diagonal. -- The matrix to be decomposed is (M X M) where -- M = Index_Finish - Index'First + 1. The Matrix A will be much larger -- if Index'Last > Index_Finish, but all values of A with row or column -- greater than Index_Finish are ignored. subtype Column is Diagonal; procedure Solve (X : out Column; A : in Matrix; B : in Column; Index_Start : in Index := Index'First; Index_Finish : in Index := Index'Last); -- Solve for X in the equation A X = B. The matrix A is input -- in LU form. Its top triangular part is U, and its lower triangular -- is L, where L*U = A. The diagonal elements of A hold the diagonal -- elements of U, not L. The diagonal elements of L are assumed to -- equal 1.0. The output of LU_Decompose is in suitable form for "Solve". matrix_is_singular : exception; Epsilon : Real := 16.0 * Real'Safe_Small; Set_Zero_Valued_Pivots_To_Epsilon : constant Boolean := False; -- If set to true then the pivot is given the value -- epsilon, and no exception is raised when matrix is singular. end Tridiagonal_LU;
reznikmm/matreshka
Ada
4,526
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.X_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Svg_X_Attribute_Node is begin return Self : Svg_X_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_X_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.X_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Svg_URI, Matreshka.ODF_String_Constants.X_Attribute, Svg_X_Attribute_Node'Tag); end Matreshka.ODF_Svg.X_Attributes;
optikos/oasis
Ada
13,630
adb
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package body Program.Nodes.Function_Body_Declarations is function Create (Not_Token : Program.Lexical_Elements.Lexical_Element_Access; Overriding_Token : Program.Lexical_Elements.Lexical_Element_Access; Function_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Name : not null Program.Elements.Defining_Names .Defining_Name_Access; Left_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access; Parameters : Program.Elements.Parameter_Specifications .Parameter_Specification_Vector_Access; Right_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access; Return_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Not_Token_2 : Program.Lexical_Elements.Lexical_Element_Access; Null_Token : Program.Lexical_Elements.Lexical_Element_Access; Result_Subtype : not null Program.Elements.Element_Access; With_Token : Program.Lexical_Elements.Lexical_Element_Access; Aspects : Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access; Is_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Declarations : Program.Element_Vectors.Element_Vector_Access; Begin_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Statements : not null Program.Element_Vectors .Element_Vector_Access; Exception_Token : Program.Lexical_Elements.Lexical_Element_Access; Exception_Handlers : Program.Elements.Exception_Handlers .Exception_Handler_Vector_Access; End_Token : not null Program.Lexical_Elements .Lexical_Element_Access; End_Name : Program.Elements.Expressions.Expression_Access; Semicolon_Token : not null Program.Lexical_Elements .Lexical_Element_Access) return Function_Body_Declaration is begin return Result : Function_Body_Declaration := (Not_Token => Not_Token, Overriding_Token => Overriding_Token, Function_Token => Function_Token, Name => Name, Left_Bracket_Token => Left_Bracket_Token, Parameters => Parameters, Right_Bracket_Token => Right_Bracket_Token, Return_Token => Return_Token, Not_Token_2 => Not_Token_2, Null_Token => Null_Token, Result_Subtype => Result_Subtype, With_Token => With_Token, Aspects => Aspects, Is_Token => Is_Token, Declarations => Declarations, Begin_Token => Begin_Token, Statements => Statements, Exception_Token => Exception_Token, Exception_Handlers => Exception_Handlers, End_Token => End_Token, End_Name => End_Name, Semicolon_Token => Semicolon_Token, Enclosing_Element => null) do Initialize (Result); end return; end Create; function Create (Name : not null Program.Elements.Defining_Names .Defining_Name_Access; Parameters : Program.Elements.Parameter_Specifications .Parameter_Specification_Vector_Access; Result_Subtype : not null Program.Elements.Element_Access; Aspects : Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access; Declarations : Program.Element_Vectors.Element_Vector_Access; Statements : not null Program.Element_Vectors .Element_Vector_Access; Exception_Handlers : Program.Elements.Exception_Handlers .Exception_Handler_Vector_Access; End_Name : Program.Elements.Expressions.Expression_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False; Has_Not : Boolean := False; Has_Overriding : Boolean := False; Has_Not_Null : Boolean := False) return Implicit_Function_Body_Declaration is begin return Result : Implicit_Function_Body_Declaration := (Name => Name, Parameters => Parameters, Result_Subtype => Result_Subtype, Aspects => Aspects, Declarations => Declarations, Statements => Statements, Exception_Handlers => Exception_Handlers, End_Name => End_Name, Is_Part_Of_Implicit => Is_Part_Of_Implicit, Is_Part_Of_Inherited => Is_Part_Of_Inherited, Is_Part_Of_Instance => Is_Part_Of_Instance, Has_Not => Has_Not, Has_Overriding => Has_Overriding, Has_Not_Null => Has_Not_Null, Enclosing_Element => null) do Initialize (Result); end return; end Create; overriding function Name (Self : Base_Function_Body_Declaration) return not null Program.Elements.Defining_Names.Defining_Name_Access is begin return Self.Name; end Name; overriding function Parameters (Self : Base_Function_Body_Declaration) return Program.Elements.Parameter_Specifications .Parameter_Specification_Vector_Access is begin return Self.Parameters; end Parameters; overriding function Result_Subtype (Self : Base_Function_Body_Declaration) return not null Program.Elements.Element_Access is begin return Self.Result_Subtype; end Result_Subtype; overriding function Aspects (Self : Base_Function_Body_Declaration) return Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access is begin return Self.Aspects; end Aspects; overriding function Declarations (Self : Base_Function_Body_Declaration) return Program.Element_Vectors.Element_Vector_Access is begin return Self.Declarations; end Declarations; overriding function Statements (Self : Base_Function_Body_Declaration) return not null Program.Element_Vectors.Element_Vector_Access is begin return Self.Statements; end Statements; overriding function Exception_Handlers (Self : Base_Function_Body_Declaration) return Program.Elements.Exception_Handlers .Exception_Handler_Vector_Access is begin return Self.Exception_Handlers; end Exception_Handlers; overriding function End_Name (Self : Base_Function_Body_Declaration) return Program.Elements.Expressions.Expression_Access is begin return Self.End_Name; end End_Name; overriding function Not_Token (Self : Function_Body_Declaration) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Not_Token; end Not_Token; overriding function Overriding_Token (Self : Function_Body_Declaration) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Overriding_Token; end Overriding_Token; overriding function Function_Token (Self : Function_Body_Declaration) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Function_Token; end Function_Token; overriding function Left_Bracket_Token (Self : Function_Body_Declaration) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Left_Bracket_Token; end Left_Bracket_Token; overriding function Right_Bracket_Token (Self : Function_Body_Declaration) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Right_Bracket_Token; end Right_Bracket_Token; overriding function Return_Token (Self : Function_Body_Declaration) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Return_Token; end Return_Token; overriding function Not_Token_2 (Self : Function_Body_Declaration) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Not_Token_2; end Not_Token_2; overriding function Null_Token (Self : Function_Body_Declaration) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Null_Token; end Null_Token; overriding function With_Token (Self : Function_Body_Declaration) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.With_Token; end With_Token; overriding function Is_Token (Self : Function_Body_Declaration) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Is_Token; end Is_Token; overriding function Begin_Token (Self : Function_Body_Declaration) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Begin_Token; end Begin_Token; overriding function Exception_Token (Self : Function_Body_Declaration) return Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Exception_Token; end Exception_Token; overriding function End_Token (Self : Function_Body_Declaration) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.End_Token; end End_Token; overriding function Semicolon_Token (Self : Function_Body_Declaration) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Semicolon_Token; end Semicolon_Token; overriding function Has_Not (Self : Function_Body_Declaration) return Boolean is begin return Self.Not_Token.Assigned; end Has_Not; overriding function Has_Overriding (Self : Function_Body_Declaration) return Boolean is begin return Self.Overriding_Token.Assigned; end Has_Overriding; overriding function Has_Not_Null (Self : Function_Body_Declaration) return Boolean is begin return Self.Null_Token.Assigned; end Has_Not_Null; overriding function Is_Part_Of_Implicit (Self : Implicit_Function_Body_Declaration) return Boolean is begin return Self.Is_Part_Of_Implicit; end Is_Part_Of_Implicit; overriding function Is_Part_Of_Inherited (Self : Implicit_Function_Body_Declaration) return Boolean is begin return Self.Is_Part_Of_Inherited; end Is_Part_Of_Inherited; overriding function Is_Part_Of_Instance (Self : Implicit_Function_Body_Declaration) return Boolean is begin return Self.Is_Part_Of_Instance; end Is_Part_Of_Instance; overriding function Has_Not (Self : Implicit_Function_Body_Declaration) return Boolean is begin return Self.Has_Not; end Has_Not; overriding function Has_Overriding (Self : Implicit_Function_Body_Declaration) return Boolean is begin return Self.Has_Overriding; end Has_Overriding; overriding function Has_Not_Null (Self : Implicit_Function_Body_Declaration) return Boolean is begin return Self.Has_Not_Null; end Has_Not_Null; procedure Initialize (Self : aliased in out Base_Function_Body_Declaration'Class) is begin Set_Enclosing_Element (Self.Name, Self'Unchecked_Access); for Item in Self.Parameters.Each_Element loop Set_Enclosing_Element (Item.Element, Self'Unchecked_Access); end loop; Set_Enclosing_Element (Self.Result_Subtype, Self'Unchecked_Access); for Item in Self.Aspects.Each_Element loop Set_Enclosing_Element (Item.Element, Self'Unchecked_Access); end loop; for Item in Self.Declarations.Each_Element loop Set_Enclosing_Element (Item.Element, Self'Unchecked_Access); end loop; for Item in Self.Statements.Each_Element loop Set_Enclosing_Element (Item.Element, Self'Unchecked_Access); end loop; for Item in Self.Exception_Handlers.Each_Element loop Set_Enclosing_Element (Item.Element, Self'Unchecked_Access); end loop; if Self.End_Name.Assigned then Set_Enclosing_Element (Self.End_Name, Self'Unchecked_Access); end if; null; end Initialize; overriding function Is_Function_Body_Declaration_Element (Self : Base_Function_Body_Declaration) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Function_Body_Declaration_Element; overriding function Is_Declaration_Element (Self : Base_Function_Body_Declaration) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Declaration_Element; overriding procedure Visit (Self : not null access Base_Function_Body_Declaration; Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is begin Visitor.Function_Body_Declaration (Self); end Visit; overriding function To_Function_Body_Declaration_Text (Self : aliased in out Function_Body_Declaration) return Program.Elements.Function_Body_Declarations .Function_Body_Declaration_Text_Access is begin return Self'Unchecked_Access; end To_Function_Body_Declaration_Text; overriding function To_Function_Body_Declaration_Text (Self : aliased in out Implicit_Function_Body_Declaration) return Program.Elements.Function_Body_Declarations .Function_Body_Declaration_Text_Access is pragma Unreferenced (Self); begin return null; end To_Function_Body_Declaration_Text; end Program.Nodes.Function_Body_Declarations;
zhmu/ananas
Ada
1,325
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- ADA.NUMERICS.LONG_LONG_ELEMENTARY_FUNCTIONS -- -- -- -- S p e c -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- -- copy and modify this specification, provided that if you redistribute a -- -- modified version, any changes that you have made are clearly indicated. -- -- -- ------------------------------------------------------------------------------ with Ada.Numerics.Generic_Elementary_Functions; package Ada.Numerics.Long_Long_Elementary_Functions is new Ada.Numerics.Generic_Elementary_Functions (Long_Long_Float); pragma Pure (Long_Long_Elementary_Functions);
AdaCore/Ada_Drivers_Library
Ada
11,300
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-2017, 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 Ada.Unchecked_Conversion; with HAL.UART; use HAL.UART; with HAL.Bitmap; use HAL.Bitmap; package body AdaFruit.Thermal_Printer is function To_Char is new Ada.Unchecked_Conversion (Source => UInt8, Target => Character); function To_UInt8 is new Ada.Unchecked_Conversion (Source => Character, Target => UInt8); procedure Write (This : in out TP_Device; Cmd : String); procedure Read (This : in out TP_Device; Str : out String); ----------- -- Write -- ----------- procedure Write (This : in out TP_Device; Cmd : String) is Status : UART_Status; Data : UART_Data_8b (Cmd'Range); begin for Index in Cmd'Range loop Data (Index) := To_UInt8 (Cmd (Index)); end loop; This.Port.Transmit (Data, Status); if Status /= Ok then -- No error handling... raise Program_Error; end if; -- This.Time.Delay_Microseconds ((11 * 1000000 / 19_2000) + Cmd'Length); end Write; ---------- -- Read -- ---------- procedure Read (This : in out TP_Device; Str : out String) is Status : UART_Status; Data : UART_Data_8b (Str'Range); begin This.Port.Receive (Data, Status); if Status /= Ok then -- No error handling... raise Program_Error; end if; for Index in Str'Range loop Str (Index) := To_Char (Data (Index)); end loop; end Read; ---------------------- -- Set_Line_Spacing -- ---------------------- procedure Set_Line_Spacing (This : in out TP_Device; Spacing : UInt8) is begin Write (This, ASCII.ESC & '3' & To_Char (Spacing)); end Set_Line_Spacing; --------------- -- Set_Align -- --------------- procedure Set_Align (This : in out TP_Device; Align : Text_Align) is Mode : Character; begin case Align is when Left => Mode := '0'; when Center => Mode := '1'; when Right => Mode := '2'; end case; Write (This, ASCII.ESC & 'a' & Mode); end Set_Align; ---------------------- -- Set_Font_Enlarge -- ---------------------- procedure Set_Font_Enlarge (This : in out TP_Device; Height, Width : Boolean) is Data : UInt8 := 0; begin if Height then Data := Data or 16#01#; end if; if Width then Data := Data or 16#10#; end if; Write (This, ASCII.GS & '!' & To_Char (Data)); end Set_Font_Enlarge; -------------- -- Set_Bold -- -------------- procedure Set_Bold (This : in out TP_Device; Bold : Boolean) is begin Write (This, ASCII.ESC & 'E' & To_Char (if Bold then 1 else 0)); end Set_Bold; ---------------------- -- Set_Double_Width -- ---------------------- procedure Set_Double_Width (This : in out TP_Device; Double : Boolean) is begin if Double then Write (This, ASCII.ESC & ASCII.SO); else Write (This, ASCII.ESC & ASCII.DC4); end if; end Set_Double_Width; ---------------- -- Set_UpDown -- ---------------- procedure Set_UpDown (This : in out TP_Device; UpDown : Boolean) is begin Write (This, ASCII.ESC & '{' & To_Char (if UpDown then 1 else 0)); end Set_UpDown; ------------------ -- Set_Reversed -- ------------------ procedure Set_Reversed (This : in out TP_Device; Reversed : Boolean) is begin Write (This, ASCII.GS & 'B' & To_Char (if Reversed then 1 else 0)); end Set_Reversed; -------------------------- -- Set_Underline_Height -- -------------------------- procedure Set_Underline_Height (This : in out TP_Device; Height : Underline_Height) is begin Write (This, ASCII.ESC & '-' & To_Char (Height)); end Set_Underline_Height; ----------------------- -- Set_Character_Set -- ----------------------- procedure Set_Character_Set (This : in out TP_Device; Set : Character_Set) is begin Write (This, ASCII.ESC & 't' & To_Char (Character_Set'Pos (Set))); end Set_Character_Set; ---------- -- Feed -- ---------- procedure Feed (This : in out TP_Device; Rows : UInt8) is begin Write (This, ASCII.ESC & 'd' & To_Char (Rows)); end Feed; ------------------ -- Print_Bitmap -- ------------------ procedure Print_Bitmap (This : in out TP_Device; BM : Thermal_Printer_Bitmap) is Nbr_Of_Rows : constant Natural := BM'Length (2); Nbr_Of_Columns : constant Natural := BM'Length (1); Str : String (1 .. Nbr_Of_Columns / 8); begin Write (This, ASCII.DC2 & 'v' & To_Char (UInt8 (Nbr_Of_Rows rem 256)) & To_Char (UInt8 (Nbr_Of_Rows / 256))); for Row in 0 .. Nbr_Of_Rows - 1 loop for Colum in 0 .. (Nbr_Of_Columns / 8) - 1 loop declare BM_Index : constant Natural := BM'First (1) + Colum * 8; Str_Index : constant Natural := Str'First + Colum; B : UInt8 := 0; begin for X in 0 .. 7 loop B := B or (if BM (BM_Index + X, BM'First (2) + Row) then 2**X else 0); end loop; Str (Str_Index) := To_Char (B); end; end loop; Write (This, Str); This.Time.Delay_Microseconds (600 * Str'Length); end loop; end Print_Bitmap; ------------------ -- Print_Bitmap -- ------------------ procedure Print_Bitmap (This : in out TP_Device; BM : not null HAL.Bitmap.Any_Bitmap_Buffer) is Nbr_Of_Rows : constant Natural := BM.Height; Nbr_Of_Columns : constant Natural := BM.Width; Str : String (1 .. Nbr_Of_Columns / 8); begin Write (This, ASCII.DC2 & 'v' & To_Char (UInt8 (Nbr_Of_Rows rem 256)) & To_Char (UInt8 (Nbr_Of_Rows / 256))); for Row in 0 .. Nbr_Of_Rows - 1 loop for Colum in 0 .. (Nbr_Of_Columns / 8) - 1 loop declare B : UInt8 := 0; Str_Index : constant Natural := Str'First + Colum; begin for X in 0 .. 7 loop B := B or (if BM.Pixel (((Colum * 8) + X, Row)).Red < 127 then 2**X else 0); end loop; Str (Str_Index) := To_Char (B); end; end loop; Write (This, Str); This.Time.Delay_Microseconds (600 * Str'Length); end loop; end Print_Bitmap; ---------- -- Wake -- ---------- procedure Wake (This : in out TP_Device) is begin Write (This, ASCII.ESC & '@'); end Wake; ----------- -- Reset -- ----------- procedure Reset (This : in out TP_Device) is begin Write (This, "" & To_Char (16#FF#)); This.Time.Delay_Milliseconds (50); Write (This, ASCII.ESC & '8' & ASCII.NUL & ASCII.NUL); for X in 1 .. 10 loop This.Time.Delay_Microseconds (10_000); Write (This, "" & ASCII.NUL); end loop; end Reset; ----------- -- Print -- ----------- procedure Print (This : in out TP_Device; Text : String) is begin Write (This, Text); end Print; ---------------- -- Get_Status -- ---------------- function Get_Status (This : in out TP_Device) return Printer_Status is Ret : Printer_Status; Status : String := "P1V72T30"; begin Ret.Paper := False; Ret.Voltage := 0; Ret.Temperature := 0; Write (This, ASCII.ESC & 'v'); Read (This, Status); -- Parse status here -- P<Paper>V<Voltage>T<Degree> -- Example: P1V72T30 Mean:Paper Ready,Current voltage 7.2V,Printer degree:30 return Ret; end Get_Status; -------------------------- -- Set_Printer_Settings -- -------------------------- procedure Set_Printer_Settings (This : in out TP_Device; Settings : Printer_Settings) is begin Write (This, ASCII.ESC & '7' & To_Char (Settings.Max_Printing_Dots) & To_Char (if Settings.Heating_Time < 3 then 3 else Settings.Heating_Time) & To_Char (Settings.Heating_Interval)); end Set_Printer_Settings; ----------------- -- Set_Density -- ----------------- procedure Set_Density (This : in out TP_Device; Density, Breaktime : UInt8) is begin Write (This, ASCII.DC2 & '#' & To_Char (Shift_Left (Breaktime, 5) or Density)); end Set_Density; --------------------- -- Print_Test_Page -- --------------------- procedure Print_Test_Page (This : in out TP_Device) is begin Write (This, ASCII.DC2 & 'T'); end Print_Test_Page; end AdaFruit.Thermal_Printer;
kisom/rover-mk1
Ada
56
ads
pragma Profile (Ravenscar); package ROSA is end ROSA;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
71,069
ads
-- This spec has been automatically generated from STM32F103.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with System; package STM32_SVD.TIM is pragma Preelaborate; --------------- -- Registers -- --------------- subtype CR1_CEN_Field is STM32_SVD.Bit; subtype CR1_UDIS_Field is STM32_SVD.Bit; subtype CR1_URS_Field is STM32_SVD.Bit; subtype CR1_OPM_Field is STM32_SVD.Bit; subtype CR1_DIR_Field is STM32_SVD.Bit; subtype CR1_CMS_Field is STM32_SVD.UInt2; subtype CR1_ARPE_Field is STM32_SVD.Bit; subtype CR1_CKD_Field is STM32_SVD.UInt2; -- control register 1 type CR1_Register is record -- Counter enable CEN : CR1_CEN_Field := 16#0#; -- Update disable UDIS : CR1_UDIS_Field := 16#0#; -- Update request source URS : CR1_URS_Field := 16#0#; -- One-pulse mode OPM : CR1_OPM_Field := 16#0#; -- Direction DIR : CR1_DIR_Field := 16#0#; -- Center-aligned mode selection CMS : CR1_CMS_Field := 16#0#; -- Auto-reload preload enable ARPE : CR1_ARPE_Field := 16#0#; -- Clock division CKD : CR1_CKD_Field := 16#0#; -- unspecified Reserved_10_31 : STM32_SVD.UInt22 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR1_Register use record CEN at 0 range 0 .. 0; UDIS at 0 range 1 .. 1; URS at 0 range 2 .. 2; OPM at 0 range 3 .. 3; DIR at 0 range 4 .. 4; CMS at 0 range 5 .. 6; ARPE at 0 range 7 .. 7; CKD at 0 range 8 .. 9; Reserved_10_31 at 0 range 10 .. 31; end record; subtype CR2_CCPC_Field is STM32_SVD.Bit; subtype CR2_CCUS_Field is STM32_SVD.Bit; subtype CR2_CCDS_Field is STM32_SVD.Bit; subtype CR2_MMS_Field is STM32_SVD.UInt3; subtype CR2_TI1S_Field is STM32_SVD.Bit; subtype CR2_OIS1_Field is STM32_SVD.Bit; subtype CR2_OIS1N_Field is STM32_SVD.Bit; subtype CR2_OIS2_Field is STM32_SVD.Bit; subtype CR2_OIS2N_Field is STM32_SVD.Bit; subtype CR2_OIS3_Field is STM32_SVD.Bit; subtype CR2_OIS3N_Field is STM32_SVD.Bit; subtype CR2_OIS4_Field is STM32_SVD.Bit; -- control register 2 type CR2_Register is record -- Capture/compare preloaded control CCPC : CR2_CCPC_Field := 16#0#; -- unspecified Reserved_1_1 : STM32_SVD.Bit := 16#0#; -- Capture/compare control update selection CCUS : CR2_CCUS_Field := 16#0#; -- Capture/compare DMA selection CCDS : CR2_CCDS_Field := 16#0#; -- Master mode selection MMS : CR2_MMS_Field := 16#0#; -- TI1 selection TI1S : CR2_TI1S_Field := 16#0#; -- Output Idle state 1 OIS1 : CR2_OIS1_Field := 16#0#; -- Output Idle state 1 OIS1N : CR2_OIS1N_Field := 16#0#; -- Output Idle state 2 OIS2 : CR2_OIS2_Field := 16#0#; -- Output Idle state 2 OIS2N : CR2_OIS2N_Field := 16#0#; -- Output Idle state 3 OIS3 : CR2_OIS3_Field := 16#0#; -- Output Idle state 3 OIS3N : CR2_OIS3N_Field := 16#0#; -- Output Idle state 4 OIS4 : CR2_OIS4_Field := 16#0#; -- unspecified Reserved_15_31 : STM32_SVD.UInt17 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR2_Register use record CCPC at 0 range 0 .. 0; Reserved_1_1 at 0 range 1 .. 1; CCUS at 0 range 2 .. 2; CCDS at 0 range 3 .. 3; MMS at 0 range 4 .. 6; TI1S at 0 range 7 .. 7; OIS1 at 0 range 8 .. 8; OIS1N at 0 range 9 .. 9; OIS2 at 0 range 10 .. 10; OIS2N at 0 range 11 .. 11; OIS3 at 0 range 12 .. 12; OIS3N at 0 range 13 .. 13; OIS4 at 0 range 14 .. 14; Reserved_15_31 at 0 range 15 .. 31; end record; subtype SMCR_SMS_Field is STM32_SVD.UInt3; subtype SMCR_TS_Field is STM32_SVD.UInt3; subtype SMCR_MSM_Field is STM32_SVD.Bit; subtype SMCR_ETF_Field is STM32_SVD.UInt4; subtype SMCR_ETPS_Field is STM32_SVD.UInt2; subtype SMCR_ECE_Field is STM32_SVD.Bit; subtype SMCR_ETP_Field is STM32_SVD.Bit; -- slave mode control register type SMCR_Register is record -- Slave mode selection SMS : SMCR_SMS_Field := 16#0#; -- unspecified Reserved_3_3 : STM32_SVD.Bit := 16#0#; -- Trigger selection TS : SMCR_TS_Field := 16#0#; -- Master/Slave mode MSM : SMCR_MSM_Field := 16#0#; -- External trigger filter ETF : SMCR_ETF_Field := 16#0#; -- External trigger prescaler ETPS : SMCR_ETPS_Field := 16#0#; -- External clock enable ECE : SMCR_ECE_Field := 16#0#; -- External trigger polarity ETP : SMCR_ETP_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SMCR_Register use record SMS at 0 range 0 .. 2; Reserved_3_3 at 0 range 3 .. 3; TS at 0 range 4 .. 6; MSM at 0 range 7 .. 7; ETF at 0 range 8 .. 11; ETPS at 0 range 12 .. 13; ECE at 0 range 14 .. 14; ETP at 0 range 15 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype DIER_UIE_Field is STM32_SVD.Bit; subtype DIER_CC1IE_Field is STM32_SVD.Bit; subtype DIER_CC2IE_Field is STM32_SVD.Bit; subtype DIER_CC3IE_Field is STM32_SVD.Bit; subtype DIER_CC4IE_Field is STM32_SVD.Bit; subtype DIER_COMIE_Field is STM32_SVD.Bit; subtype DIER_TIE_Field is STM32_SVD.Bit; subtype DIER_BIE_Field is STM32_SVD.Bit; subtype DIER_UDE_Field is STM32_SVD.Bit; subtype DIER_CC1DE_Field is STM32_SVD.Bit; subtype DIER_CC2DE_Field is STM32_SVD.Bit; subtype DIER_CC3DE_Field is STM32_SVD.Bit; subtype DIER_CC4DE_Field is STM32_SVD.Bit; subtype DIER_COMDE_Field is STM32_SVD.Bit; subtype DIER_TDE_Field is STM32_SVD.Bit; -- DMA/Interrupt enable register type DIER_Register is record -- Update interrupt enable UIE : DIER_UIE_Field := 16#0#; -- Capture/Compare 1 interrupt enable CC1IE : DIER_CC1IE_Field := 16#0#; -- Capture/Compare 2 interrupt enable CC2IE : DIER_CC2IE_Field := 16#0#; -- Capture/Compare 3 interrupt enable CC3IE : DIER_CC3IE_Field := 16#0#; -- Capture/Compare 4 interrupt enable CC4IE : DIER_CC4IE_Field := 16#0#; -- COM interrupt enable COMIE : DIER_COMIE_Field := 16#0#; -- Trigger interrupt enable TIE : DIER_TIE_Field := 16#0#; -- Break interrupt enable BIE : DIER_BIE_Field := 16#0#; -- Update DMA request enable UDE : DIER_UDE_Field := 16#0#; -- Capture/Compare 1 DMA request enable CC1DE : DIER_CC1DE_Field := 16#0#; -- Capture/Compare 2 DMA request enable CC2DE : DIER_CC2DE_Field := 16#0#; -- Capture/Compare 3 DMA request enable CC3DE : DIER_CC3DE_Field := 16#0#; -- Capture/Compare 4 DMA request enable CC4DE : DIER_CC4DE_Field := 16#0#; -- COM DMA request enable COMDE : DIER_COMDE_Field := 16#0#; -- Trigger DMA request enable TDE : DIER_TDE_Field := 16#0#; -- unspecified Reserved_15_31 : STM32_SVD.UInt17 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DIER_Register use record UIE at 0 range 0 .. 0; CC1IE at 0 range 1 .. 1; CC2IE at 0 range 2 .. 2; CC3IE at 0 range 3 .. 3; CC4IE at 0 range 4 .. 4; COMIE at 0 range 5 .. 5; TIE at 0 range 6 .. 6; BIE at 0 range 7 .. 7; UDE at 0 range 8 .. 8; CC1DE at 0 range 9 .. 9; CC2DE at 0 range 10 .. 10; CC3DE at 0 range 11 .. 11; CC4DE at 0 range 12 .. 12; COMDE at 0 range 13 .. 13; TDE at 0 range 14 .. 14; Reserved_15_31 at 0 range 15 .. 31; end record; subtype SR_UIF_Field is STM32_SVD.Bit; subtype SR_CC1IF_Field is STM32_SVD.Bit; subtype SR_CC2IF_Field is STM32_SVD.Bit; subtype SR_CC3IF_Field is STM32_SVD.Bit; subtype SR_CC4IF_Field is STM32_SVD.Bit; subtype SR_COMIF_Field is STM32_SVD.Bit; subtype SR_TIF_Field is STM32_SVD.Bit; subtype SR_BIF_Field is STM32_SVD.Bit; subtype SR_CC1OF_Field is STM32_SVD.Bit; subtype SR_CC2OF_Field is STM32_SVD.Bit; subtype SR_CC3OF_Field is STM32_SVD.Bit; subtype SR_CC4OF_Field is STM32_SVD.Bit; -- status register type SR_Register is record -- Update interrupt flag UIF : SR_UIF_Field := 16#0#; -- Capture/compare 1 interrupt flag CC1IF : SR_CC1IF_Field := 16#0#; -- Capture/Compare 2 interrupt flag CC2IF : SR_CC2IF_Field := 16#0#; -- Capture/Compare 3 interrupt flag CC3IF : SR_CC3IF_Field := 16#0#; -- Capture/Compare 4 interrupt flag CC4IF : SR_CC4IF_Field := 16#0#; -- COM interrupt flag COMIF : SR_COMIF_Field := 16#0#; -- Trigger interrupt flag TIF : SR_TIF_Field := 16#0#; -- Break interrupt flag BIF : SR_BIF_Field := 16#0#; -- unspecified Reserved_8_8 : STM32_SVD.Bit := 16#0#; -- Capture/Compare 1 overcapture flag CC1OF : SR_CC1OF_Field := 16#0#; -- Capture/compare 2 overcapture flag CC2OF : SR_CC2OF_Field := 16#0#; -- Capture/Compare 3 overcapture flag CC3OF : SR_CC3OF_Field := 16#0#; -- Capture/Compare 4 overcapture flag CC4OF : SR_CC4OF_Field := 16#0#; -- unspecified Reserved_13_31 : STM32_SVD.UInt19 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SR_Register use record UIF at 0 range 0 .. 0; CC1IF at 0 range 1 .. 1; CC2IF at 0 range 2 .. 2; CC3IF at 0 range 3 .. 3; CC4IF at 0 range 4 .. 4; COMIF at 0 range 5 .. 5; TIF at 0 range 6 .. 6; BIF at 0 range 7 .. 7; Reserved_8_8 at 0 range 8 .. 8; CC1OF at 0 range 9 .. 9; CC2OF at 0 range 10 .. 10; CC3OF at 0 range 11 .. 11; CC4OF at 0 range 12 .. 12; Reserved_13_31 at 0 range 13 .. 31; end record; subtype EGR_UG_Field is STM32_SVD.Bit; subtype EGR_CC1G_Field is STM32_SVD.Bit; subtype EGR_CC2G_Field is STM32_SVD.Bit; subtype EGR_CC3G_Field is STM32_SVD.Bit; subtype EGR_CC4G_Field is STM32_SVD.Bit; subtype EGR_COMG_Field is STM32_SVD.Bit; subtype EGR_TG_Field is STM32_SVD.Bit; subtype EGR_BG_Field is STM32_SVD.Bit; -- event generation register type EGR_Register is record -- Write-only. Update generation UG : EGR_UG_Field := 16#0#; -- Write-only. Capture/compare 1 generation CC1G : EGR_CC1G_Field := 16#0#; -- Write-only. Capture/compare 2 generation CC2G : EGR_CC2G_Field := 16#0#; -- Write-only. Capture/compare 3 generation CC3G : EGR_CC3G_Field := 16#0#; -- Write-only. Capture/compare 4 generation CC4G : EGR_CC4G_Field := 16#0#; -- Write-only. Capture/Compare control update generation COMG : EGR_COMG_Field := 16#0#; -- Write-only. Trigger generation TG : EGR_TG_Field := 16#0#; -- Write-only. Break generation BG : EGR_BG_Field := 16#0#; -- unspecified Reserved_8_31 : STM32_SVD.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for EGR_Register use record UG at 0 range 0 .. 0; CC1G at 0 range 1 .. 1; CC2G at 0 range 2 .. 2; CC3G at 0 range 3 .. 3; CC4G at 0 range 4 .. 4; COMG at 0 range 5 .. 5; TG at 0 range 6 .. 6; BG at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype CCMR1_Output_CC1S_Field is STM32_SVD.UInt2; subtype CCMR1_Output_OC1FE_Field is STM32_SVD.Bit; subtype CCMR1_Output_OC1PE_Field is STM32_SVD.Bit; subtype CCMR1_Output_OC1M_Field is STM32_SVD.UInt3; subtype CCMR1_Output_OC1CE_Field is STM32_SVD.Bit; subtype CCMR1_Output_CC2S_Field is STM32_SVD.UInt2; subtype CCMR1_Output_OC2FE_Field is STM32_SVD.Bit; subtype CCMR1_Output_OC2PE_Field is STM32_SVD.Bit; subtype CCMR1_Output_OC2M_Field is STM32_SVD.UInt3; subtype CCMR1_Output_OC2CE_Field is STM32_SVD.Bit; -- capture/compare mode register (output mode) type CCMR1_Output_Register is record -- Capture/Compare 1 selection CC1S : CCMR1_Output_CC1S_Field := 16#0#; -- Output Compare 1 fast enable OC1FE : CCMR1_Output_OC1FE_Field := 16#0#; -- Output Compare 1 preload enable OC1PE : CCMR1_Output_OC1PE_Field := 16#0#; -- Output Compare 1 mode OC1M : CCMR1_Output_OC1M_Field := 16#0#; -- Output Compare 1 clear enable OC1CE : CCMR1_Output_OC1CE_Field := 16#0#; -- Capture/Compare 2 selection CC2S : CCMR1_Output_CC2S_Field := 16#0#; -- Output Compare 2 fast enable OC2FE : CCMR1_Output_OC2FE_Field := 16#0#; -- Output Compare 2 preload enable OC2PE : CCMR1_Output_OC2PE_Field := 16#0#; -- Output Compare 2 mode OC2M : CCMR1_Output_OC2M_Field := 16#0#; -- Output Compare 2 clear enable OC2CE : CCMR1_Output_OC2CE_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CCMR1_Output_Register use record CC1S at 0 range 0 .. 1; OC1FE at 0 range 2 .. 2; OC1PE at 0 range 3 .. 3; OC1M at 0 range 4 .. 6; OC1CE at 0 range 7 .. 7; CC2S at 0 range 8 .. 9; OC2FE at 0 range 10 .. 10; OC2PE at 0 range 11 .. 11; OC2M at 0 range 12 .. 14; OC2CE at 0 range 15 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype CCMR1_Input_CC1S_Field is STM32_SVD.UInt2; subtype CCMR1_Input_ICPCS_Field is STM32_SVD.UInt2; subtype CCMR1_Input_IC1F_Field is STM32_SVD.UInt4; subtype CCMR1_Input_CC2S_Field is STM32_SVD.UInt2; subtype CCMR1_Input_IC2PCS_Field is STM32_SVD.UInt2; subtype CCMR1_Input_IC2F_Field is STM32_SVD.UInt4; -- capture/compare mode register 1 (input mode) type CCMR1_Input_Register is record -- Capture/Compare 1 selection CC1S : CCMR1_Input_CC1S_Field := 16#0#; -- Input capture 1 prescaler ICPCS : CCMR1_Input_ICPCS_Field := 16#0#; -- Input capture 1 filter IC1F : CCMR1_Input_IC1F_Field := 16#0#; -- Capture/Compare 2 selection CC2S : CCMR1_Input_CC2S_Field := 16#0#; -- Input capture 2 prescaler IC2PCS : CCMR1_Input_IC2PCS_Field := 16#0#; -- Input capture 2 filter IC2F : CCMR1_Input_IC2F_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CCMR1_Input_Register use record CC1S at 0 range 0 .. 1; ICPCS at 0 range 2 .. 3; IC1F at 0 range 4 .. 7; CC2S at 0 range 8 .. 9; IC2PCS at 0 range 10 .. 11; IC2F at 0 range 12 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype CCMR2_Output_CC3S_Field is STM32_SVD.UInt2; subtype CCMR2_Output_OC3FE_Field is STM32_SVD.Bit; subtype CCMR2_Output_OC3PE_Field is STM32_SVD.Bit; subtype CCMR2_Output_OC3M_Field is STM32_SVD.UInt3; subtype CCMR2_Output_OC3CE_Field is STM32_SVD.Bit; subtype CCMR2_Output_CC4S_Field is STM32_SVD.UInt2; subtype CCMR2_Output_OC4FE_Field is STM32_SVD.Bit; subtype CCMR2_Output_OC4PE_Field is STM32_SVD.Bit; subtype CCMR2_Output_OC4M_Field is STM32_SVD.UInt3; subtype CCMR2_Output_OC4CE_Field is STM32_SVD.Bit; -- capture/compare mode register (output mode) type CCMR2_Output_Register is record -- Capture/Compare 3 selection CC3S : CCMR2_Output_CC3S_Field := 16#0#; -- Output compare 3 fast enable OC3FE : CCMR2_Output_OC3FE_Field := 16#0#; -- Output compare 3 preload enable OC3PE : CCMR2_Output_OC3PE_Field := 16#0#; -- Output compare 3 mode OC3M : CCMR2_Output_OC3M_Field := 16#0#; -- Output compare 3 clear enable OC3CE : CCMR2_Output_OC3CE_Field := 16#0#; -- Capture/Compare 4 selection CC4S : CCMR2_Output_CC4S_Field := 16#0#; -- Output compare 4 fast enable OC4FE : CCMR2_Output_OC4FE_Field := 16#0#; -- Output compare 4 preload enable OC4PE : CCMR2_Output_OC4PE_Field := 16#0#; -- Output compare 4 mode OC4M : CCMR2_Output_OC4M_Field := 16#0#; -- Output compare 4 clear enable OC4CE : CCMR2_Output_OC4CE_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CCMR2_Output_Register use record CC3S at 0 range 0 .. 1; OC3FE at 0 range 2 .. 2; OC3PE at 0 range 3 .. 3; OC3M at 0 range 4 .. 6; OC3CE at 0 range 7 .. 7; CC4S at 0 range 8 .. 9; OC4FE at 0 range 10 .. 10; OC4PE at 0 range 11 .. 11; OC4M at 0 range 12 .. 14; OC4CE at 0 range 15 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype CCMR2_Input_CC3S_Field is STM32_SVD.UInt2; subtype CCMR2_Input_IC3PSC_Field is STM32_SVD.UInt2; subtype CCMR2_Input_IC3F_Field is STM32_SVD.UInt4; subtype CCMR2_Input_CC4S_Field is STM32_SVD.UInt2; subtype CCMR2_Input_IC4PSC_Field is STM32_SVD.UInt2; subtype CCMR2_Input_IC4F_Field is STM32_SVD.UInt4; -- capture/compare mode register 2 (input mode) type CCMR2_Input_Register is record -- Capture/compare 3 selection CC3S : CCMR2_Input_CC3S_Field := 16#0#; -- Input capture 3 prescaler IC3PSC : CCMR2_Input_IC3PSC_Field := 16#0#; -- Input capture 3 filter IC3F : CCMR2_Input_IC3F_Field := 16#0#; -- Capture/Compare 4 selection CC4S : CCMR2_Input_CC4S_Field := 16#0#; -- Input capture 4 prescaler IC4PSC : CCMR2_Input_IC4PSC_Field := 16#0#; -- Input capture 4 filter IC4F : CCMR2_Input_IC4F_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CCMR2_Input_Register use record CC3S at 0 range 0 .. 1; IC3PSC at 0 range 2 .. 3; IC3F at 0 range 4 .. 7; CC4S at 0 range 8 .. 9; IC4PSC at 0 range 10 .. 11; IC4F at 0 range 12 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype CCER_CC1E_Field is STM32_SVD.Bit; subtype CCER_CC1P_Field is STM32_SVD.Bit; subtype CCER_CC1NE_Field is STM32_SVD.Bit; subtype CCER_CC1NP_Field is STM32_SVD.Bit; subtype CCER_CC2E_Field is STM32_SVD.Bit; subtype CCER_CC2P_Field is STM32_SVD.Bit; subtype CCER_CC2NE_Field is STM32_SVD.Bit; subtype CCER_CC2NP_Field is STM32_SVD.Bit; subtype CCER_CC3E_Field is STM32_SVD.Bit; subtype CCER_CC3P_Field is STM32_SVD.Bit; subtype CCER_CC3NE_Field is STM32_SVD.Bit; subtype CCER_CC3NP_Field is STM32_SVD.Bit; subtype CCER_CC4E_Field is STM32_SVD.Bit; subtype CCER_CC4P_Field is STM32_SVD.Bit; -- capture/compare enable register type CCER_Register is record -- Capture/Compare 1 output enable CC1E : CCER_CC1E_Field := 16#0#; -- Capture/Compare 1 output Polarity CC1P : CCER_CC1P_Field := 16#0#; -- Capture/Compare 1 complementary output enable CC1NE : CCER_CC1NE_Field := 16#0#; -- Capture/Compare 1 output Polarity CC1NP : CCER_CC1NP_Field := 16#0#; -- Capture/Compare 2 output enable CC2E : CCER_CC2E_Field := 16#0#; -- Capture/Compare 2 output Polarity CC2P : CCER_CC2P_Field := 16#0#; -- Capture/Compare 2 complementary output enable CC2NE : CCER_CC2NE_Field := 16#0#; -- Capture/Compare 2 output Polarity CC2NP : CCER_CC2NP_Field := 16#0#; -- Capture/Compare 3 output enable CC3E : CCER_CC3E_Field := 16#0#; -- Capture/Compare 3 output Polarity CC3P : CCER_CC3P_Field := 16#0#; -- Capture/Compare 3 complementary output enable CC3NE : CCER_CC3NE_Field := 16#0#; -- Capture/Compare 3 output Polarity CC3NP : CCER_CC3NP_Field := 16#0#; -- Capture/Compare 4 output enable CC4E : CCER_CC4E_Field := 16#0#; -- Capture/Compare 3 output Polarity CC4P : CCER_CC4P_Field := 16#0#; -- unspecified Reserved_14_31 : STM32_SVD.UInt18 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CCER_Register use record CC1E at 0 range 0 .. 0; CC1P at 0 range 1 .. 1; CC1NE at 0 range 2 .. 2; CC1NP at 0 range 3 .. 3; CC2E at 0 range 4 .. 4; CC2P at 0 range 5 .. 5; CC2NE at 0 range 6 .. 6; CC2NP at 0 range 7 .. 7; CC3E at 0 range 8 .. 8; CC3P at 0 range 9 .. 9; CC3NE at 0 range 10 .. 10; CC3NP at 0 range 11 .. 11; CC4E at 0 range 12 .. 12; CC4P at 0 range 13 .. 13; Reserved_14_31 at 0 range 14 .. 31; end record; subtype CNT_CNT_Field is STM32_SVD.UInt16; -- counter type CNT_Register is record -- counter value CNT : CNT_CNT_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CNT_Register use record CNT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype PSC_PSC_Field is STM32_SVD.UInt16; -- prescaler type PSC_Register is record -- Prescaler value PSC : PSC_PSC_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for PSC_Register use record PSC at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype ARR_ARR_Field is STM32_SVD.UInt16; -- auto-reload register type ARR_Register is record -- Auto-reload value ARR : ARR_ARR_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ARR_Register use record ARR at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype RCR_REP_Field is STM32_SVD.Byte; -- repetition counter register type RCR_Register is record -- Repetition counter value REP : RCR_REP_Field := 16#0#; -- unspecified Reserved_8_31 : STM32_SVD.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for RCR_Register use record REP at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype CCR1_CCR1_Field is STM32_SVD.UInt16; -- capture/compare register 1 type CCR1_Register is record -- Capture/Compare 1 value CCR1 : CCR1_CCR1_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CCR1_Register use record CCR1 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype CCR2_CCR2_Field is STM32_SVD.UInt16; -- capture/compare register 2 type CCR2_Register is record -- Capture/Compare 2 value CCR2 : CCR2_CCR2_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CCR2_Register use record CCR2 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype CCR3_CCR3_Field is STM32_SVD.UInt16; -- capture/compare register 3 type CCR3_Register is record -- Capture/Compare value CCR3 : CCR3_CCR3_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CCR3_Register use record CCR3 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype CCR4_CCR4_Field is STM32_SVD.UInt16; -- capture/compare register 4 type CCR4_Register is record -- Capture/Compare value CCR4 : CCR4_CCR4_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CCR4_Register use record CCR4 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype BDTR_DTG_Field is STM32_SVD.Byte; subtype BDTR_LOCK_Field is STM32_SVD.UInt2; subtype BDTR_OSSI_Field is STM32_SVD.Bit; subtype BDTR_OSSR_Field is STM32_SVD.Bit; subtype BDTR_BKE_Field is STM32_SVD.Bit; subtype BDTR_BKP_Field is STM32_SVD.Bit; subtype BDTR_AOE_Field is STM32_SVD.Bit; subtype BDTR_MOE_Field is STM32_SVD.Bit; -- break and dead-time register type BDTR_Register is record -- Dead-time generator setup DTG : BDTR_DTG_Field := 16#0#; -- Lock configuration LOCK : BDTR_LOCK_Field := 16#0#; -- Off-state selection for Idle mode OSSI : BDTR_OSSI_Field := 16#0#; -- Off-state selection for Run mode OSSR : BDTR_OSSR_Field := 16#0#; -- Break enable BKE : BDTR_BKE_Field := 16#0#; -- Break polarity BKP : BDTR_BKP_Field := 16#0#; -- Automatic output enable AOE : BDTR_AOE_Field := 16#0#; -- Main output enable MOE : BDTR_MOE_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for BDTR_Register use record DTG at 0 range 0 .. 7; LOCK at 0 range 8 .. 9; OSSI at 0 range 10 .. 10; OSSR at 0 range 11 .. 11; BKE at 0 range 12 .. 12; BKP at 0 range 13 .. 13; AOE at 0 range 14 .. 14; MOE at 0 range 15 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype DCR_DBA_Field is STM32_SVD.UInt5; subtype DCR_DBL_Field is STM32_SVD.UInt5; -- DMA control register type DCR_Register is record -- DMA base address DBA : DCR_DBA_Field := 16#0#; -- unspecified Reserved_5_7 : STM32_SVD.UInt3 := 16#0#; -- DMA burst length DBL : DCR_DBL_Field := 16#0#; -- unspecified Reserved_13_31 : STM32_SVD.UInt19 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DCR_Register use record DBA at 0 range 0 .. 4; Reserved_5_7 at 0 range 5 .. 7; DBL at 0 range 8 .. 12; Reserved_13_31 at 0 range 13 .. 31; end record; subtype DMAR_DMAB_Field is STM32_SVD.UInt16; -- DMA address for full transfer type DMAR_Register is record -- DMA register for burst accesses DMAB : DMAR_DMAB_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DMAR_Register use record DMAB at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -- control register 2 type CR2_Register_1 is record -- unspecified Reserved_0_2 : STM32_SVD.UInt3 := 16#0#; -- Capture/compare DMA selection CCDS : CR2_CCDS_Field := 16#0#; -- Master mode selection MMS : CR2_MMS_Field := 16#0#; -- TI1 selection TI1S : CR2_TI1S_Field := 16#0#; -- unspecified Reserved_8_31 : STM32_SVD.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR2_Register_1 use record Reserved_0_2 at 0 range 0 .. 2; CCDS at 0 range 3 .. 3; MMS at 0 range 4 .. 6; TI1S at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; -- DMA/Interrupt enable register type DIER_Register_1 is record -- Update interrupt enable UIE : DIER_UIE_Field := 16#0#; -- Capture/Compare 1 interrupt enable CC1IE : DIER_CC1IE_Field := 16#0#; -- Capture/Compare 2 interrupt enable CC2IE : DIER_CC2IE_Field := 16#0#; -- Capture/Compare 3 interrupt enable CC3IE : DIER_CC3IE_Field := 16#0#; -- Capture/Compare 4 interrupt enable CC4IE : DIER_CC4IE_Field := 16#0#; -- unspecified Reserved_5_5 : STM32_SVD.Bit := 16#0#; -- Trigger interrupt enable TIE : DIER_TIE_Field := 16#0#; -- unspecified Reserved_7_7 : STM32_SVD.Bit := 16#0#; -- Update DMA request enable UDE : DIER_UDE_Field := 16#0#; -- Capture/Compare 1 DMA request enable CC1DE : DIER_CC1DE_Field := 16#0#; -- Capture/Compare 2 DMA request enable CC2DE : DIER_CC2DE_Field := 16#0#; -- Capture/Compare 3 DMA request enable CC3DE : DIER_CC3DE_Field := 16#0#; -- Capture/Compare 4 DMA request enable CC4DE : DIER_CC4DE_Field := 16#0#; -- unspecified Reserved_13_13 : STM32_SVD.Bit := 16#0#; -- Trigger DMA request enable TDE : DIER_TDE_Field := 16#0#; -- unspecified Reserved_15_31 : STM32_SVD.UInt17 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DIER_Register_1 use record UIE at 0 range 0 .. 0; CC1IE at 0 range 1 .. 1; CC2IE at 0 range 2 .. 2; CC3IE at 0 range 3 .. 3; CC4IE at 0 range 4 .. 4; Reserved_5_5 at 0 range 5 .. 5; TIE at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; UDE at 0 range 8 .. 8; CC1DE at 0 range 9 .. 9; CC2DE at 0 range 10 .. 10; CC3DE at 0 range 11 .. 11; CC4DE at 0 range 12 .. 12; Reserved_13_13 at 0 range 13 .. 13; TDE at 0 range 14 .. 14; Reserved_15_31 at 0 range 15 .. 31; end record; -- status register type SR_Register_1 is record -- Update interrupt flag UIF : SR_UIF_Field := 16#0#; -- Capture/compare 1 interrupt flag CC1IF : SR_CC1IF_Field := 16#0#; -- Capture/Compare 2 interrupt flag CC2IF : SR_CC2IF_Field := 16#0#; -- Capture/Compare 3 interrupt flag CC3IF : SR_CC3IF_Field := 16#0#; -- Capture/Compare 4 interrupt flag CC4IF : SR_CC4IF_Field := 16#0#; -- unspecified Reserved_5_5 : STM32_SVD.Bit := 16#0#; -- Trigger interrupt flag TIF : SR_TIF_Field := 16#0#; -- unspecified Reserved_7_8 : STM32_SVD.UInt2 := 16#0#; -- Capture/Compare 1 overcapture flag CC1OF : SR_CC1OF_Field := 16#0#; -- Capture/compare 2 overcapture flag CC2OF : SR_CC2OF_Field := 16#0#; -- Capture/Compare 3 overcapture flag CC3OF : SR_CC3OF_Field := 16#0#; -- Capture/Compare 4 overcapture flag CC4OF : SR_CC4OF_Field := 16#0#; -- unspecified Reserved_13_31 : STM32_SVD.UInt19 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SR_Register_1 use record UIF at 0 range 0 .. 0; CC1IF at 0 range 1 .. 1; CC2IF at 0 range 2 .. 2; CC3IF at 0 range 3 .. 3; CC4IF at 0 range 4 .. 4; Reserved_5_5 at 0 range 5 .. 5; TIF at 0 range 6 .. 6; Reserved_7_8 at 0 range 7 .. 8; CC1OF at 0 range 9 .. 9; CC2OF at 0 range 10 .. 10; CC3OF at 0 range 11 .. 11; CC4OF at 0 range 12 .. 12; Reserved_13_31 at 0 range 13 .. 31; end record; -- event generation register type EGR_Register_1 is record -- Write-only. Update generation UG : EGR_UG_Field := 16#0#; -- Write-only. Capture/compare 1 generation CC1G : EGR_CC1G_Field := 16#0#; -- Write-only. Capture/compare 2 generation CC2G : EGR_CC2G_Field := 16#0#; -- Write-only. Capture/compare 3 generation CC3G : EGR_CC3G_Field := 16#0#; -- Write-only. Capture/compare 4 generation CC4G : EGR_CC4G_Field := 16#0#; -- unspecified Reserved_5_5 : STM32_SVD.Bit := 16#0#; -- Write-only. Trigger generation TG : EGR_TG_Field := 16#0#; -- unspecified Reserved_7_31 : STM32_SVD.UInt25 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for EGR_Register_1 use record UG at 0 range 0 .. 0; CC1G at 0 range 1 .. 1; CC2G at 0 range 2 .. 2; CC3G at 0 range 3 .. 3; CC4G at 0 range 4 .. 4; Reserved_5_5 at 0 range 5 .. 5; TG at 0 range 6 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; subtype CCMR1_Input_IC1PSC_Field is STM32_SVD.UInt2; subtype CCMR1_Input_IC2PSC_Field is STM32_SVD.UInt2; -- capture/compare mode register 1 (input mode) type CCMR1_Input_Register_1 is record -- Capture/Compare 1 selection CC1S : CCMR1_Input_CC1S_Field := 16#0#; -- Input capture 1 prescaler IC1PSC : CCMR1_Input_IC1PSC_Field := 16#0#; -- Input capture 1 filter IC1F : CCMR1_Input_IC1F_Field := 16#0#; -- Capture/compare 2 selection CC2S : CCMR1_Input_CC2S_Field := 16#0#; -- Input capture 2 prescaler IC2PSC : CCMR1_Input_IC2PSC_Field := 16#0#; -- Input capture 2 filter IC2F : CCMR1_Input_IC2F_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CCMR1_Input_Register_1 use record CC1S at 0 range 0 .. 1; IC1PSC at 0 range 2 .. 3; IC1F at 0 range 4 .. 7; CC2S at 0 range 8 .. 9; IC2PSC at 0 range 10 .. 11; IC2F at 0 range 12 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype CCMR2_Output_O24CE_Field is STM32_SVD.Bit; -- capture/compare mode register 2 (output mode) type CCMR2_Output_Register_1 is record -- Capture/Compare 3 selection CC3S : CCMR2_Output_CC3S_Field := 16#0#; -- Output compare 3 fast enable OC3FE : CCMR2_Output_OC3FE_Field := 16#0#; -- Output compare 3 preload enable OC3PE : CCMR2_Output_OC3PE_Field := 16#0#; -- Output compare 3 mode OC3M : CCMR2_Output_OC3M_Field := 16#0#; -- Output compare 3 clear enable OC3CE : CCMR2_Output_OC3CE_Field := 16#0#; -- Capture/Compare 4 selection CC4S : CCMR2_Output_CC4S_Field := 16#0#; -- Output compare 4 fast enable OC4FE : CCMR2_Output_OC4FE_Field := 16#0#; -- Output compare 4 preload enable OC4PE : CCMR2_Output_OC4PE_Field := 16#0#; -- Output compare 4 mode OC4M : CCMR2_Output_OC4M_Field := 16#0#; -- Output compare 4 clear enable O24CE : CCMR2_Output_O24CE_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CCMR2_Output_Register_1 use record CC3S at 0 range 0 .. 1; OC3FE at 0 range 2 .. 2; OC3PE at 0 range 3 .. 3; OC3M at 0 range 4 .. 6; OC3CE at 0 range 7 .. 7; CC4S at 0 range 8 .. 9; OC4FE at 0 range 10 .. 10; OC4PE at 0 range 11 .. 11; OC4M at 0 range 12 .. 14; O24CE at 0 range 15 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -- capture/compare enable register type CCER_Register_1 is record -- Capture/Compare 1 output enable CC1E : CCER_CC1E_Field := 16#0#; -- Capture/Compare 1 output Polarity CC1P : CCER_CC1P_Field := 16#0#; -- unspecified Reserved_2_3 : STM32_SVD.UInt2 := 16#0#; -- Capture/Compare 2 output enable CC2E : CCER_CC2E_Field := 16#0#; -- Capture/Compare 2 output Polarity CC2P : CCER_CC2P_Field := 16#0#; -- unspecified Reserved_6_7 : STM32_SVD.UInt2 := 16#0#; -- Capture/Compare 3 output enable CC3E : CCER_CC3E_Field := 16#0#; -- Capture/Compare 3 output Polarity CC3P : CCER_CC3P_Field := 16#0#; -- unspecified Reserved_10_11 : STM32_SVD.UInt2 := 16#0#; -- Capture/Compare 4 output enable CC4E : CCER_CC4E_Field := 16#0#; -- Capture/Compare 3 output Polarity CC4P : CCER_CC4P_Field := 16#0#; -- unspecified Reserved_14_31 : STM32_SVD.UInt18 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CCER_Register_1 use record CC1E at 0 range 0 .. 0; CC1P at 0 range 1 .. 1; Reserved_2_3 at 0 range 2 .. 3; CC2E at 0 range 4 .. 4; CC2P at 0 range 5 .. 5; Reserved_6_7 at 0 range 6 .. 7; CC3E at 0 range 8 .. 8; CC3P at 0 range 9 .. 9; Reserved_10_11 at 0 range 10 .. 11; CC4E at 0 range 12 .. 12; CC4P at 0 range 13 .. 13; Reserved_14_31 at 0 range 14 .. 31; end record; -- control register 1 type CR1_Register_1 is record -- Counter enable CEN : CR1_CEN_Field := 16#0#; -- Update disable UDIS : CR1_UDIS_Field := 16#0#; -- Update request source URS : CR1_URS_Field := 16#0#; -- One-pulse mode OPM : CR1_OPM_Field := 16#0#; -- unspecified Reserved_4_6 : STM32_SVD.UInt3 := 16#0#; -- Auto-reload preload enable ARPE : CR1_ARPE_Field := 16#0#; -- unspecified Reserved_8_31 : STM32_SVD.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR1_Register_1 use record CEN at 0 range 0 .. 0; UDIS at 0 range 1 .. 1; URS at 0 range 2 .. 2; OPM at 0 range 3 .. 3; Reserved_4_6 at 0 range 4 .. 6; ARPE at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; -- control register 2 type CR2_Register_2 is record -- unspecified Reserved_0_3 : STM32_SVD.UInt4 := 16#0#; -- Master mode selection MMS : CR2_MMS_Field := 16#0#; -- unspecified Reserved_7_31 : STM32_SVD.UInt25 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR2_Register_2 use record Reserved_0_3 at 0 range 0 .. 3; MMS at 0 range 4 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; -- DMA/Interrupt enable register type DIER_Register_2 is record -- Update interrupt enable UIE : DIER_UIE_Field := 16#0#; -- unspecified Reserved_1_7 : STM32_SVD.UInt7 := 16#0#; -- Update DMA request enable UDE : DIER_UDE_Field := 16#0#; -- unspecified Reserved_9_31 : STM32_SVD.UInt23 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DIER_Register_2 use record UIE at 0 range 0 .. 0; Reserved_1_7 at 0 range 1 .. 7; UDE at 0 range 8 .. 8; Reserved_9_31 at 0 range 9 .. 31; end record; -- status register type SR_Register_2 is record -- Update interrupt flag UIF : SR_UIF_Field := 16#0#; -- unspecified Reserved_1_31 : STM32_SVD.UInt31 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SR_Register_2 use record UIF at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; -- event generation register type EGR_Register_2 is record -- Write-only. Update generation UG : EGR_UG_Field := 16#0#; -- unspecified Reserved_1_31 : STM32_SVD.UInt31 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for EGR_Register_2 use record UG at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; -- control register 1 type CR1_Register_2 is record -- Counter enable CEN : CR1_CEN_Field := 16#0#; -- Update disable UDIS : CR1_UDIS_Field := 16#0#; -- Update request source URS : CR1_URS_Field := 16#0#; -- One-pulse mode OPM : CR1_OPM_Field := 16#0#; -- unspecified Reserved_4_6 : STM32_SVD.UInt3 := 16#0#; -- Auto-reload preload enable ARPE : CR1_ARPE_Field := 16#0#; -- Clock division CKD : CR1_CKD_Field := 16#0#; -- unspecified Reserved_10_31 : STM32_SVD.UInt22 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR1_Register_2 use record CEN at 0 range 0 .. 0; UDIS at 0 range 1 .. 1; URS at 0 range 2 .. 2; OPM at 0 range 3 .. 3; Reserved_4_6 at 0 range 4 .. 6; ARPE at 0 range 7 .. 7; CKD at 0 range 8 .. 9; Reserved_10_31 at 0 range 10 .. 31; end record; -- slave mode control register type SMCR_Register_1 is record -- Slave mode selection SMS : SMCR_SMS_Field := 16#0#; -- unspecified Reserved_3_3 : STM32_SVD.Bit := 16#0#; -- Trigger selection TS : SMCR_TS_Field := 16#0#; -- Master/Slave mode MSM : SMCR_MSM_Field := 16#0#; -- unspecified Reserved_8_31 : STM32_SVD.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SMCR_Register_1 use record SMS at 0 range 0 .. 2; Reserved_3_3 at 0 range 3 .. 3; TS at 0 range 4 .. 6; MSM at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; -- DMA/Interrupt enable register type DIER_Register_3 is record -- Update interrupt enable UIE : DIER_UIE_Field := 16#0#; -- Capture/Compare 1 interrupt enable CC1IE : DIER_CC1IE_Field := 16#0#; -- Capture/Compare 2 interrupt enable CC2IE : DIER_CC2IE_Field := 16#0#; -- unspecified Reserved_3_5 : STM32_SVD.UInt3 := 16#0#; -- Trigger interrupt enable TIE : DIER_TIE_Field := 16#0#; -- unspecified Reserved_7_31 : STM32_SVD.UInt25 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DIER_Register_3 use record UIE at 0 range 0 .. 0; CC1IE at 0 range 1 .. 1; CC2IE at 0 range 2 .. 2; Reserved_3_5 at 0 range 3 .. 5; TIE at 0 range 6 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; -- status register type SR_Register_3 is record -- Update interrupt flag UIF : SR_UIF_Field := 16#0#; -- Capture/compare 1 interrupt flag CC1IF : SR_CC1IF_Field := 16#0#; -- Capture/Compare 2 interrupt flag CC2IF : SR_CC2IF_Field := 16#0#; -- unspecified Reserved_3_5 : STM32_SVD.UInt3 := 16#0#; -- Trigger interrupt flag TIF : SR_TIF_Field := 16#0#; -- unspecified Reserved_7_8 : STM32_SVD.UInt2 := 16#0#; -- Capture/Compare 1 overcapture flag CC1OF : SR_CC1OF_Field := 16#0#; -- Capture/compare 2 overcapture flag CC2OF : SR_CC2OF_Field := 16#0#; -- unspecified Reserved_11_31 : STM32_SVD.UInt21 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SR_Register_3 use record UIF at 0 range 0 .. 0; CC1IF at 0 range 1 .. 1; CC2IF at 0 range 2 .. 2; Reserved_3_5 at 0 range 3 .. 5; TIF at 0 range 6 .. 6; Reserved_7_8 at 0 range 7 .. 8; CC1OF at 0 range 9 .. 9; CC2OF at 0 range 10 .. 10; Reserved_11_31 at 0 range 11 .. 31; end record; -- event generation register type EGR_Register_3 is record -- Write-only. Update generation UG : EGR_UG_Field := 16#0#; -- Write-only. Capture/compare 1 generation CC1G : EGR_CC1G_Field := 16#0#; -- Write-only. Capture/compare 2 generation CC2G : EGR_CC2G_Field := 16#0#; -- unspecified Reserved_3_5 : STM32_SVD.UInt3 := 16#0#; -- Write-only. Trigger generation TG : EGR_TG_Field := 16#0#; -- unspecified Reserved_7_31 : STM32_SVD.UInt25 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for EGR_Register_3 use record UG at 0 range 0 .. 0; CC1G at 0 range 1 .. 1; CC2G at 0 range 2 .. 2; Reserved_3_5 at 0 range 3 .. 5; TG at 0 range 6 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; -- capture/compare mode register 1 (output mode) type CCMR1_Output_Register_1 is record -- Capture/Compare 1 selection CC1S : CCMR1_Output_CC1S_Field := 16#0#; -- Output Compare 1 fast enable OC1FE : CCMR1_Output_OC1FE_Field := 16#0#; -- Output Compare 1 preload enable OC1PE : CCMR1_Output_OC1PE_Field := 16#0#; -- Output Compare 1 mode OC1M : CCMR1_Output_OC1M_Field := 16#0#; -- unspecified Reserved_7_7 : STM32_SVD.Bit := 16#0#; -- Capture/Compare 2 selection CC2S : CCMR1_Output_CC2S_Field := 16#0#; -- Output Compare 2 fast enable OC2FE : CCMR1_Output_OC2FE_Field := 16#0#; -- Output Compare 2 preload enable OC2PE : CCMR1_Output_OC2PE_Field := 16#0#; -- Output Compare 2 mode OC2M : CCMR1_Output_OC2M_Field := 16#0#; -- unspecified Reserved_15_31 : STM32_SVD.UInt17 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CCMR1_Output_Register_1 use record CC1S at 0 range 0 .. 1; OC1FE at 0 range 2 .. 2; OC1PE at 0 range 3 .. 3; OC1M at 0 range 4 .. 6; Reserved_7_7 at 0 range 7 .. 7; CC2S at 0 range 8 .. 9; OC2FE at 0 range 10 .. 10; OC2PE at 0 range 11 .. 11; OC2M at 0 range 12 .. 14; Reserved_15_31 at 0 range 15 .. 31; end record; -- capture/compare enable register type CCER_Register_2 is record -- Capture/Compare 1 output enable CC1E : CCER_CC1E_Field := 16#0#; -- Capture/Compare 1 output Polarity CC1P : CCER_CC1P_Field := 16#0#; -- unspecified Reserved_2_2 : STM32_SVD.Bit := 16#0#; -- Capture/Compare 1 output Polarity CC1NP : CCER_CC1NP_Field := 16#0#; -- Capture/Compare 2 output enable CC2E : CCER_CC2E_Field := 16#0#; -- Capture/Compare 2 output Polarity CC2P : CCER_CC2P_Field := 16#0#; -- unspecified Reserved_6_6 : STM32_SVD.Bit := 16#0#; -- Capture/Compare 2 output Polarity CC2NP : CCER_CC2NP_Field := 16#0#; -- unspecified Reserved_8_31 : STM32_SVD.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CCER_Register_2 use record CC1E at 0 range 0 .. 0; CC1P at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; CC1NP at 0 range 3 .. 3; CC2E at 0 range 4 .. 4; CC2P at 0 range 5 .. 5; Reserved_6_6 at 0 range 6 .. 6; CC2NP at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; -- control register 1 type CR1_Register_3 is record -- Counter enable CEN : CR1_CEN_Field := 16#0#; -- Update disable UDIS : CR1_UDIS_Field := 16#0#; -- Update request source URS : CR1_URS_Field := 16#0#; -- unspecified Reserved_3_6 : STM32_SVD.UInt4 := 16#0#; -- Auto-reload preload enable ARPE : CR1_ARPE_Field := 16#0#; -- Clock division CKD : CR1_CKD_Field := 16#0#; -- unspecified Reserved_10_31 : STM32_SVD.UInt22 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR1_Register_3 use record CEN at 0 range 0 .. 0; UDIS at 0 range 1 .. 1; URS at 0 range 2 .. 2; Reserved_3_6 at 0 range 3 .. 6; ARPE at 0 range 7 .. 7; CKD at 0 range 8 .. 9; Reserved_10_31 at 0 range 10 .. 31; end record; -- DMA/Interrupt enable register type DIER_Register_4 is record -- Update interrupt enable UIE : DIER_UIE_Field := 16#0#; -- Capture/Compare 1 interrupt enable CC1IE : DIER_CC1IE_Field := 16#0#; -- unspecified Reserved_2_31 : STM32_SVD.UInt30 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DIER_Register_4 use record UIE at 0 range 0 .. 0; CC1IE at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; -- status register type SR_Register_4 is record -- Update interrupt flag UIF : SR_UIF_Field := 16#0#; -- Capture/compare 1 interrupt flag CC1IF : SR_CC1IF_Field := 16#0#; -- unspecified Reserved_2_8 : STM32_SVD.UInt7 := 16#0#; -- Capture/Compare 1 overcapture flag CC1OF : SR_CC1OF_Field := 16#0#; -- unspecified Reserved_10_31 : STM32_SVD.UInt22 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SR_Register_4 use record UIF at 0 range 0 .. 0; CC1IF at 0 range 1 .. 1; Reserved_2_8 at 0 range 2 .. 8; CC1OF at 0 range 9 .. 9; Reserved_10_31 at 0 range 10 .. 31; end record; -- event generation register type EGR_Register_4 is record -- Write-only. Update generation UG : EGR_UG_Field := 16#0#; -- Write-only. Capture/compare 1 generation CC1G : EGR_CC1G_Field := 16#0#; -- unspecified Reserved_2_31 : STM32_SVD.UInt30 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for EGR_Register_4 use record UG at 0 range 0 .. 0; CC1G at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; -- capture/compare mode register (output mode) type CCMR1_Output_Register_2 is record -- Capture/Compare 1 selection CC1S : CCMR1_Output_CC1S_Field := 16#0#; -- unspecified Reserved_2_2 : STM32_SVD.Bit := 16#0#; -- Output Compare 1 preload enable OC1PE : CCMR1_Output_OC1PE_Field := 16#0#; -- Output Compare 1 mode OC1M : CCMR1_Output_OC1M_Field := 16#0#; -- unspecified Reserved_7_31 : STM32_SVD.UInt25 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CCMR1_Output_Register_2 use record CC1S at 0 range 0 .. 1; Reserved_2_2 at 0 range 2 .. 2; OC1PE at 0 range 3 .. 3; OC1M at 0 range 4 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; -- capture/compare mode register (input mode) type CCMR1_Input_Register_2 is record -- Capture/Compare 1 selection CC1S : CCMR1_Input_CC1S_Field := 16#0#; -- Input capture 1 prescaler IC1PSC : CCMR1_Input_IC1PSC_Field := 16#0#; -- Input capture 1 filter IC1F : CCMR1_Input_IC1F_Field := 16#0#; -- unspecified Reserved_8_31 : STM32_SVD.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CCMR1_Input_Register_2 use record CC1S at 0 range 0 .. 1; IC1PSC at 0 range 2 .. 3; IC1F at 0 range 4 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; -- capture/compare enable register type CCER_Register_3 is record -- Capture/Compare 1 output enable CC1E : CCER_CC1E_Field := 16#0#; -- Capture/Compare 1 output Polarity CC1P : CCER_CC1P_Field := 16#0#; -- unspecified Reserved_2_2 : STM32_SVD.Bit := 16#0#; -- Capture/Compare 1 output Polarity CC1NP : CCER_CC1NP_Field := 16#0#; -- unspecified Reserved_4_31 : STM32_SVD.UInt28 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CCER_Register_3 use record CC1E at 0 range 0 .. 0; CC1P at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; CC1NP at 0 range 3 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; ----------------- -- Peripherals -- ----------------- type TIM1_Disc is ( Output, Input); -- Advanced timer type TIM1_Peripheral (Discriminent : TIM1_Disc := Output) is record -- control register 1 CR1 : aliased CR1_Register; -- control register 2 CR2 : aliased CR2_Register; -- slave mode control register SMCR : aliased SMCR_Register; -- DMA/Interrupt enable register DIER : aliased DIER_Register; -- status register SR : aliased SR_Register; -- event generation register EGR : aliased EGR_Register; -- capture/compare enable register CCER : aliased CCER_Register; -- counter CNT : aliased CNT_Register; -- prescaler PSC : aliased PSC_Register; -- auto-reload register ARR : aliased ARR_Register; -- repetition counter register RCR : aliased RCR_Register; -- capture/compare register 1 CCR1 : aliased CCR1_Register; -- capture/compare register 2 CCR2 : aliased CCR2_Register; -- capture/compare register 3 CCR3 : aliased CCR3_Register; -- capture/compare register 4 CCR4 : aliased CCR4_Register; -- break and dead-time register BDTR : aliased BDTR_Register; -- DMA control register DCR : aliased DCR_Register; -- DMA address for full transfer DMAR : aliased DMAR_Register; case Discriminent is when Output => -- capture/compare mode register (output mode) CCMR1_Output : aliased CCMR1_Output_Register; -- capture/compare mode register (output mode) CCMR2_Output : aliased CCMR2_Output_Register; when Input => -- capture/compare mode register 1 (input mode) CCMR1_Input : aliased CCMR1_Input_Register; -- capture/compare mode register 2 (input mode) CCMR2_Input : aliased CCMR2_Input_Register; end case; end record with Unchecked_Union, Volatile; for TIM1_Peripheral use record CR1 at 16#0# range 0 .. 31; CR2 at 16#4# range 0 .. 31; SMCR at 16#8# range 0 .. 31; DIER at 16#C# range 0 .. 31; SR at 16#10# range 0 .. 31; EGR at 16#14# range 0 .. 31; CCER at 16#20# range 0 .. 31; CNT at 16#24# range 0 .. 31; PSC at 16#28# range 0 .. 31; ARR at 16#2C# range 0 .. 31; RCR at 16#30# range 0 .. 31; CCR1 at 16#34# range 0 .. 31; CCR2 at 16#38# range 0 .. 31; CCR3 at 16#3C# range 0 .. 31; CCR4 at 16#40# range 0 .. 31; BDTR at 16#44# range 0 .. 31; DCR at 16#48# range 0 .. 31; DMAR at 16#4C# range 0 .. 31; CCMR1_Output at 16#18# range 0 .. 31; CCMR2_Output at 16#1C# range 0 .. 31; CCMR1_Input at 16#18# range 0 .. 31; CCMR2_Input at 16#1C# range 0 .. 31; end record; -- Advanced timer TIM1_Periph : aliased TIM1_Peripheral with Import, Address => System'To_Address (16#40012C00#); -- Advanced timer TIM8_Periph : aliased TIM1_Peripheral with Import, Address => System'To_Address (16#40013400#); type TIM2_Disc is ( Output, Input); -- General purpose timer type TIM2_Peripheral (Discriminent : TIM2_Disc := Output) is record -- control register 1 CR1 : aliased CR1_Register; -- control register 2 CR2 : aliased CR2_Register_1; -- slave mode control register SMCR : aliased SMCR_Register; -- DMA/Interrupt enable register DIER : aliased DIER_Register_1; -- status register SR : aliased SR_Register_1; -- event generation register EGR : aliased EGR_Register_1; -- capture/compare enable register CCER : aliased CCER_Register_1; -- counter CNT : aliased CNT_Register; -- prescaler PSC : aliased PSC_Register; -- auto-reload register ARR : aliased ARR_Register; -- capture/compare register 1 CCR1 : aliased CCR1_Register; -- capture/compare register 2 CCR2 : aliased CCR2_Register; -- capture/compare register 3 CCR3 : aliased CCR3_Register; -- capture/compare register 4 CCR4 : aliased CCR4_Register; -- DMA control register DCR : aliased DCR_Register; -- DMA address for full transfer DMAR : aliased DMAR_Register; case Discriminent is when Output => -- capture/compare mode register 1 (output mode) CCMR1_Output : aliased CCMR1_Output_Register; -- capture/compare mode register 2 (output mode) CCMR2_Output : aliased CCMR2_Output_Register_1; when Input => -- capture/compare mode register 1 (input mode) CCMR1_Input : aliased CCMR1_Input_Register_1; -- capture/compare mode register 2 (input mode) CCMR2_Input : aliased CCMR2_Input_Register; end case; end record with Unchecked_Union, Volatile; for TIM2_Peripheral use record CR1 at 16#0# range 0 .. 31; CR2 at 16#4# range 0 .. 31; SMCR at 16#8# range 0 .. 31; DIER at 16#C# range 0 .. 31; SR at 16#10# range 0 .. 31; EGR at 16#14# range 0 .. 31; CCER at 16#20# range 0 .. 31; CNT at 16#24# range 0 .. 31; PSC at 16#28# range 0 .. 31; ARR at 16#2C# range 0 .. 31; CCR1 at 16#34# range 0 .. 31; CCR2 at 16#38# range 0 .. 31; CCR3 at 16#3C# range 0 .. 31; CCR4 at 16#40# range 0 .. 31; DCR at 16#48# range 0 .. 31; DMAR at 16#4C# range 0 .. 31; CCMR1_Output at 16#18# range 0 .. 31; CCMR2_Output at 16#1C# range 0 .. 31; CCMR1_Input at 16#18# range 0 .. 31; CCMR2_Input at 16#1C# range 0 .. 31; end record; -- General purpose timer TIM2_Periph : aliased TIM2_Peripheral with Import, Address => System'To_Address (16#40000000#); -- General purpose timer TIM3_Periph : aliased TIM2_Peripheral with Import, Address => System'To_Address (16#40000400#); -- General purpose timer TIM4_Periph : aliased TIM2_Peripheral with Import, Address => System'To_Address (16#40000800#); -- General purpose timer TIM5_Periph : aliased TIM2_Peripheral with Import, Address => System'To_Address (16#40000C00#); -- Basic timer type TIM6_Peripheral is record -- control register 1 CR1 : aliased CR1_Register_1; -- control register 2 CR2 : aliased CR2_Register_2; -- DMA/Interrupt enable register DIER : aliased DIER_Register_2; -- status register SR : aliased SR_Register_2; -- event generation register EGR : aliased EGR_Register_2; -- counter CNT : aliased CNT_Register; -- prescaler PSC : aliased PSC_Register; -- auto-reload register ARR : aliased ARR_Register; end record with Volatile; for TIM6_Peripheral use record CR1 at 16#0# range 0 .. 31; CR2 at 16#4# range 0 .. 31; DIER at 16#C# range 0 .. 31; SR at 16#10# range 0 .. 31; EGR at 16#14# range 0 .. 31; CNT at 16#24# range 0 .. 31; PSC at 16#28# range 0 .. 31; ARR at 16#2C# range 0 .. 31; end record; -- Basic timer TIM6_Periph : aliased TIM6_Peripheral with Import, Address => System'To_Address (16#40001000#); -- Basic timer TIM7_Periph : aliased TIM6_Peripheral with Import, Address => System'To_Address (16#40001400#); type TIM9_Disc is ( Output, Input); -- General purpose timer type TIM9_Peripheral (Discriminent : TIM9_Disc := Output) is record -- control register 1 CR1 : aliased CR1_Register_2; -- control register 2 CR2 : aliased CR2_Register_2; -- slave mode control register SMCR : aliased SMCR_Register_1; -- DMA/Interrupt enable register DIER : aliased DIER_Register_3; -- status register SR : aliased SR_Register_3; -- event generation register EGR : aliased EGR_Register_3; -- capture/compare enable register CCER : aliased CCER_Register_2; -- counter CNT : aliased CNT_Register; -- prescaler PSC : aliased PSC_Register; -- auto-reload register ARR : aliased ARR_Register; -- capture/compare register 1 CCR1 : aliased CCR1_Register; -- capture/compare register 2 CCR2 : aliased CCR2_Register; case Discriminent is when Output => -- capture/compare mode register 1 (output mode) CCMR1_Output : aliased CCMR1_Output_Register_1; when Input => -- capture/compare mode register 1 (input mode) CCMR1_Input : aliased CCMR1_Input_Register_1; end case; end record with Unchecked_Union, Volatile; for TIM9_Peripheral use record CR1 at 16#0# range 0 .. 31; CR2 at 16#4# range 0 .. 31; SMCR at 16#8# range 0 .. 31; DIER at 16#C# range 0 .. 31; SR at 16#10# range 0 .. 31; EGR at 16#14# range 0 .. 31; CCER at 16#20# range 0 .. 31; CNT at 16#24# range 0 .. 31; PSC at 16#28# range 0 .. 31; ARR at 16#2C# range 0 .. 31; CCR1 at 16#34# range 0 .. 31; CCR2 at 16#38# range 0 .. 31; CCMR1_Output at 16#18# range 0 .. 31; CCMR1_Input at 16#18# range 0 .. 31; end record; -- General purpose timer TIM9_Periph : aliased TIM9_Peripheral with Import, Address => System'To_Address (16#40014C00#); -- General purpose timer TIM12_Periph : aliased TIM9_Peripheral with Import, Address => System'To_Address (16#40001800#); type TIM10_Disc is ( Output, Input); -- General purpose timer type TIM10_Peripheral (Discriminent : TIM10_Disc := Output) is record -- control register 1 CR1 : aliased CR1_Register_3; -- control register 2 CR2 : aliased CR2_Register_2; -- DMA/Interrupt enable register DIER : aliased DIER_Register_4; -- status register SR : aliased SR_Register_4; -- event generation register EGR : aliased EGR_Register_4; -- capture/compare enable register CCER : aliased CCER_Register_3; -- counter CNT : aliased CNT_Register; -- prescaler PSC : aliased PSC_Register; -- auto-reload register ARR : aliased ARR_Register; -- capture/compare register 1 CCR1 : aliased CCR1_Register; case Discriminent is when Output => -- capture/compare mode register (output mode) CCMR1_Output : aliased CCMR1_Output_Register_2; when Input => -- capture/compare mode register (input mode) CCMR1_Input : aliased CCMR1_Input_Register_2; end case; end record with Unchecked_Union, Volatile; for TIM10_Peripheral use record CR1 at 16#0# range 0 .. 31; CR2 at 16#4# range 0 .. 31; DIER at 16#C# range 0 .. 31; SR at 16#10# range 0 .. 31; EGR at 16#14# range 0 .. 31; CCER at 16#20# range 0 .. 31; CNT at 16#24# range 0 .. 31; PSC at 16#28# range 0 .. 31; ARR at 16#2C# range 0 .. 31; CCR1 at 16#34# range 0 .. 31; CCMR1_Output at 16#18# range 0 .. 31; CCMR1_Input at 16#18# range 0 .. 31; end record; -- General purpose timer TIM10_Periph : aliased TIM10_Peripheral with Import, Address => System'To_Address (16#40015000#); -- General purpose timer TIM11_Periph : aliased TIM10_Peripheral with Import, Address => System'To_Address (16#40015400#); -- General purpose timer TIM13_Periph : aliased TIM10_Peripheral with Import, Address => System'To_Address (16#40001C00#); -- General purpose timer TIM14_Periph : aliased TIM10_Peripheral with Import, Address => System'To_Address (16#40002000#); end STM32_SVD.TIM;
pat-rogers/LmcpGen
Ada
227
ads
package -<full_series_name_dots>-.Enumerations is -<list_all_enumeration_types>- type -<series_name>-Enum is ( -<list_all_message_enumeration_names>- ); end -<full_series_name_dots>-.Enumerations;
rogermc2/GA_Ada
Ada
26,855
adb
with Ada.Text_IO; use Ada.Text_IO; with Bits; package body Blade is epsilon : constant Float := 10.0 ** (-6); function GP_OP (BA, BB : Basis_Blade; Outer : Boolean) return Basis_Blade; function Inner_Product_Filter (Grade_1, Grade_2 : Integer; Blades : Blade_List; Cont : Contraction_Type) return Blade_List; function Inner_Product_Filter (Grade_1, Grade_2 : Integer; BB : Basis_Blade; Cont : Contraction_Type) return Basis_Blade; function New_Blade (Weight : Float := 1.0) return Basis_Blade; function To_Eigen_Basis (BB : Basis_Blade; Met : Metric.Metric_Record) return Blade_List; function To_Metric_Basis (BL : Blade_List; Met : Metric.Metric_Record) return Blade_List; function Transform_Basis (BA : Blade.Basis_Blade; Met : GA_Maths.Float_Matrix) return Blade_List; -- ------------------------------------------------------------------------- function "<" (Left, Right : Blade.Basis_Blade) return Boolean is begin return Bitmap (Left) < Bitmap (Right); end "<"; -- ------------------------------------------------------------------------ function "*" (S : Float; BB : Basis_Blade) return Basis_Blade is begin return (BB.Bitmap, S * BB.Weight); end "*"; -- ------------------------------------------------------------------------ function "*" (BB : Basis_Blade; S : Float) return Basis_Blade is begin return S * BB; end "*"; -- ------------------------------------------------------------------------ procedure Add_Blade (Blades : in out Blade_List; BB : Basis_Blade)is begin Blades.Append (BB); end Add_Blade; -- ------------------------------------------------------------------------- procedure Add_Blade (Blades : in out Blade_Vector; Index : Natural; BB : Basis_Blade)is begin Blades.Replace_Element (Index, BB); end Add_Blade; -- ------------------------------------------------------------------------- procedure Add_Blades (Blades : in out Blade_List; More_Blades : Blade_List) is use Blade_List_Package; Curs : Cursor := More_Blades.First; aBlade : Basis_Blade; begin while Has_Element (Curs) loop aBlade := Element (Curs); if Weight (aBlade) /= 0.0 then Blades.Append (aBlade); end if; Next (Curs); end loop; end Add_Blades; -- ------------------------------------------------------------------------- function BB_First (BB_List : Blade_List) return Basis_Blade is begin return BB_List.First_Element; end BB_First; -- ------------------------------------------------------------------------- function BB_Item (BB_List : Blade_List; Index : Integer) return Basis_Blade is use Blade_List_Package; Curs : Cursor := BB_List.First; begin if Index > 1 then for count in 2 .. Index loop Next (Curs); end loop; end if; return Element (Curs); end BB_Item; -- ------------------------------------------------------------------------- function Blade_String (aBlade : Basis_Blade; BV_Names : Basis_Vector_Names) return Ada.Strings.Unbounded.Unbounded_String is use Names_Package; BM : Unsigned_32 := aBlade.Bitmap; Bit_Num : Natural := 1; Scale : constant GA_Maths.float_3 := GA_Maths.float_3 (Weight (aBlade)); Name : Unbounded_String; Val : Unbounded_String; theString : Ada.Strings.Unbounded.Unbounded_String := To_Unbounded_String (""); begin -- Put_Line ("Blade.Blade_String, initial BM: " & Unsigned_32'Image (BM)); if BM = 0 then theString := To_Unbounded_String (GA_Maths.float_3'Image (Scale)); else while BM /= 0 loop -- Put_Line ("Blade.Blade_String, BM, Bit_Num: " & Unsigned_32'Image (BM) & -- ", " & Natural'Image (Bit_Num)); if (BM and 1) /= 0 then -- Put_Line ("Blade.Blade_String, BM bit detected: " & Unsigned_32'Image (BM)); if Length (theString) > 0 then theString := theString & "^"; end if; if Is_Empty (Vector (BV_Names)) or (Bit_Num > Natural (Length (Vector (BV_Names))) or (Bit_Num) < 1) then theString := theString & "e"; Val := To_Unbounded_String (Natural'Image (Bit_Num)); Val := Trim (Val, Ada.Strings.Left); theString := theString & Val; else Name := Element (BV_Names, Bit_Num); theString := theString & Name; end if; -- Put_Line ("Blade.Blade_String, theString: " & To_String (theString)); end if; BM := BM / 2; -- BM >>= 1; Bit_Num := Bit_Num + 1; end loop; if Length (theString) > 0 then theString := GA_Maths.float_3'Image (Scale) & " * " & theString; end if; end if; -- Put_Line ("Blade.Blade_String, final theString: " & To_String (theString)); return theString; exception when others => Put_Line ("An exception occurred in Blade.Blade_String."); raise; end Blade_String; -- ------------------------------------------------------------------------- function Bitmap (BB : Basis_Blade) return Unsigned_32 is begin return BB.Bitmap; end Bitmap; -- ------------------------------------------------------------------------ function Canonical_Reordering_Sign (Map_A, Map_B : Unsigned_32) return float is A : Unsigned_32 := Map_A / 2; Swaps : Natural := 0; begin while A /= 0 loop Swaps := Swaps + Bits.Bit_Count (A and Map_B); A := A / 2; end loop; if Swaps mod 2 = 0 then -- an even number of swaps return 1.0; else -- an odd number of swaps return -1.0; end if; end Canonical_Reordering_Sign; -- ------------------------------------------------------------------------ -- Based on BasisBlade.java geometricProduct(BasisBlade a, BasisBlade b, double[] m) -- wher m is an array of doubles giving the metric for each basis vector. function Geometric_Product (BB : Basis_Blade; Sc : Float) return Basis_Blade is S_Blade : constant Basis_Blade := New_Scalar_Blade (Sc); begin return GP_OP (BB, S_Blade, False); end Geometric_Product; -- ------------------------------------------------------------------------ -- Geometric_Product computes the geometric product of two basis blades. function Geometric_Product (BA, BB : Basis_Blade) return Basis_Blade is begin return GP_OP (BA, BB, False); end Geometric_Product; -- ------------------------------------------------------------------------ -- This Geometric_Product returns an ArrayList because -- the result does not have to be a single BasisBlade. function Geometric_Product (BA, BB : Basis_Blade; Met : Metric.Metric_Record) return Blade_List is use Blade_List_Package; use GA_Maths.Float_Array_Package; List_A : constant Blade_List := To_Eigen_Basis (BA, Met); List_B : constant Blade_List := To_Eigen_Basis (BB, Met); LA_Cursor : Cursor := List_A.First; LB_Cursor : Cursor; Eigen_Vals : constant Real_Vector := Metric.Eigen_Values (Met); -- M.getEigenMetric GP : Basis_Blade; Result : Blade_List; begin -- List_A and List_B needed because To_Eigen_Basis returns an ArrayList -- because its result does not have to be a single BasisBlade. while Has_Element (LA_Cursor) loop LB_Cursor := List_B.First; while Has_Element (LB_Cursor) loop GP := Geometric_Product (Element (LA_Cursor), Element (LB_Cursor), Eigen_Vals); Add_Blade (Result, (GP)); Next (LB_Cursor); end loop; Next (LA_Cursor); end loop; Simplify (Result); Result := To_Metric_Basis (Result, Met); return Result; exception when others => Put_Line ("An exception occurred in Blade.Geometric_Product with Metric."); raise; end Geometric_Product; -- ------------------------------------------------------------------------ function Geometric_Product (BA, BB : Basis_Blade; Eigen_Vals : GA_Maths.Float_Array_Package.Real_Vector) return Basis_Blade is -- Eigen_Vals gives the metric for each basis vector -- BM is the meet (bitmap of annihilated vectors) -- Only retain vectors common to both blades BM : Unsigned_32 := Bitmap (BA) and Bitmap (BB); -- M.getEigenMetric Index : Integer := 1; New_Blade : Basis_Blade := Geometric_Product (BA, BB); -- Euclidean metric begin while BM /= 0 loop if (BM and 1) /= 0 then -- This basis vector is non-zero New_Blade.Weight := New_Blade.Weight * Eigen_Vals (Index); end if; -- Move right to next basis vector indicator -- BM := BM / 2; BM := Shift_Right (BM, 1); Index := Index + 1; end loop; if New_Blade.Weight = 0.0 then New_Blade := New_Basis_Blade; end if; return New_Blade; exception when others => Put_Line ("An exception occurred in Blade.Geometric_Product with Metric."); raise; end Geometric_Product; -- ------------------------------------------------------------------------ function GP_OP (BA, BB : Basis_Blade; Outer : Boolean) return Basis_Blade is OP_Blade : Basis_Blade; Sign : Float; begin if Outer and then (BA.Bitmap and BB.Bitmap) /= 0 then -- BA and BB are parallel; so their volume is zero OP_Blade := New_Basis_Blade (0, 0.0); -- return zero blade else -- compute geometric product -- if BA.Bitmap = BB.Bitmap, xor = 0, so Dot product part of MV -- else xor > 0 so Outer product part of MV Sign := Canonical_Reordering_Sign (BA.Bitmap, BB.Bitmap); OP_Blade := New_Blade (BA.Bitmap xor BB.Bitmap, Sign * BA.Weight * BB.Weight); end if; return OP_Blade; exception when others => Put_Line ("An exception occurred in Blade.GP_OP"); raise; end GP_OP; -- ------------------------------------------------------------------------ function Grade (BB : Basis_Blade) return Integer is begin return Bits.Bit_Count (BB.Bitmap); end Grade; -- ------------------------------------------------------------------------ function Grade_Inversion (B : Basis_Blade) return Basis_Blade is W : constant Float := Float (Minus_1_Power (Grade (B)) * Integer (B.Weight)); begin return New_Blade (B.Bitmap, W); end Grade_Inversion; -- ------------------------------------------------------------------------ function Inner_Product (BA, BB : Basis_Blade; Cont : Contraction_Type) return Basis_Blade is begin return Inner_Product_Filter (Grade (BA), Grade (BB), Geometric_Product (BA, BB), Cont); end Inner_Product; -- ------------------------------------------------------------------------ function Inner_Product (BA, BB : Basis_Blade; Met : Metric.Metric_Record; Cont : Contraction_Type) return Blade_List is GP : constant Blade_List := Geometric_Product (BA, BB, Met); begin return Inner_Product_Filter (Grade (BA), Grade (BB), GP, Cont); end Inner_Product; -- ------------------------------------------------------------------------ function Inner_Product_Filter (Grade_1, Grade_2 : Integer; BB : Basis_Blade; Cont : Contraction_Type) return Basis_Blade is IP_Blade : Basis_Blade; begin case Cont is when Left_Contraction => if (Grade_1 > Grade_2) or (Grade (BB) /= (Grade_2 - Grade_1)) then IP_Blade := New_Basis_Blade; else -- Grade_1 <= Grade_2 and Grade (BB) = Grade_2 - Grade_1 IP_Blade := BB; end if; when Right_Contraction => if (Grade_1 < Grade_2) or (Grade (BB) /= Grade_1 - Grade_2) then IP_Blade := New_Basis_Blade; else IP_Blade := BB; end if; when Hestenes_Inner_Product => if (Grade_1 = 0) or (Grade_2 = 0) then IP_Blade := New_Basis_Blade; elsif Abs (Grade_1 - Grade_2) = Grade (BB) then IP_Blade := BB; end if; when Modified_Hestenes_Inner_Product => if Abs (Grade_1 - Grade_2) = Grade (BB) then IP_Blade := BB; else IP_Blade := New_Basis_Blade; end if; end case; return IP_Blade; exception when others => Put_Line ("An exception occurred in Blade.Inner_Product_Filter"); raise; end Inner_Product_Filter; -- ------------------------------------------------------------------------ function Inner_Product_Filter (Grade_1, Grade_2 : Integer; Blades : Blade_List; Cont : Contraction_Type) return Blade_List is use Blade_List_Package; Blade_Cursor : Cursor := Blades.First; aBlade : Basis_Blade; New_Blades : Blade_List; begin while Has_Element (Blade_Cursor) loop -- Inner_Product_Filter returns either a null blade or Element (Blade_Cursor) aBlade := Inner_Product_Filter (Grade_1, Grade_2, Element (Blade_Cursor), Cont); if Weight (aBlade) /= 0.0 then Add_Blade (New_Blades, (aBlade)); end if; Next (Blade_Cursor); end loop; return New_Blades; exception when others => Put_Line ("An exception occurred in Blade.Inner_Product_Filter"); raise; end Inner_Product_Filter; -- ------------------------------------------------------------------------ function List_Length (Blades : Blade_List) return Integer is begin return Integer (Blades.Length); end List_Length; -- ------------------------------------------------------------------------ function Minus_1_Power (Power : Integer) return Integer is begin return (-1) ** Power; end Minus_1_Power; -- ------------------------------------------------------------------------ function New_Blade (Weight : Float := 1.0) return Basis_Blade is Blade : Basis_Blade; begin Blade.Weight := Weight; return Blade; end New_Blade; -- ------------------------------------------------------------------------ function New_Blade (Bitmap : Unsigned_32; Weight : Float := 1.0) return Basis_Blade is Blade : Basis_Blade; begin if Bitmap < 32 then Blade.Bitmap := Bitmap; Blade.Weight := Weight; else raise Blade_Exception with "Blade.New_Blade, invalid Bitmap" & Unsigned_32'Image (Bitmap); end if; return Blade; end New_Blade; -- ------------------------------------------------------------------------ function New_Basis_Blade (Bitmap : Unsigned_32; Weight : Float := 1.0) return Basis_Blade is Blade : Basis_Blade; begin if Bitmap < 32 then Blade.Bitmap := Bitmap; Blade.Weight := Weight; else raise Blade_Exception with "Blade.New_Basis_Blade, invalid Bitmap" & Unsigned_32'Image (Bitmap); end if; return Blade; end New_Basis_Blade; -- ------------------------------------------------------------------------ function New_Basis_Blade (Weight : Float := 0.0) return Basis_Blade is Blade : Basis_Blade; begin Blade.Bitmap := 0; Blade.Weight := Weight; return Blade; end New_Basis_Blade; -- ------------------------------------------------------------------------ function New_Basis_Blade (Index : BV_Base; Weight : Float := 1.0) return Basis_Blade is begin return (Index'Enum_Rep, Weight); end New_Basis_Blade; -- ------------------------------------------------------------------------ function New_Basis_Blade (Index : E2_Base; Weight : Float := 1.0) return Basis_Blade is begin return (Index'Enum_Rep, Weight); exception when others => Put_Line ("An exception occurred in Blade.New_Basis_Blade"); raise; end New_Basis_Blade; -- ------------------------------------------------------------------------ function New_Basis_Blade (Index : E3_Base; Weight : Float := 1.0) return Basis_Blade is begin return (Index'Enum_Rep, Weight); end New_Basis_Blade; -- ------------------------------------------------------------------------ function New_Basis_Blade (Index : C3_Base; Weight : Float := 1.0) return Basis_Blade is begin return (Index'Enum_Rep, Weight); end New_Basis_Blade; -- ------------------------------------------------------------------------ function New_Complex_Basis_Blade (Index : C3_Base; Weight : GA_Maths.Complex_Types.Complex := (0.0, 1.0)) return Complex_Basis_Blade is begin return (Index'Enum_Rep, Weight); end New_Complex_Basis_Blade; -- ------------------------------------------------------------------------ function New_Scalar_Blade (Weight : Float := 1.0) return Basis_Blade is Blade : Basis_Blade; begin Blade.Bitmap := 0; Blade.Weight := Weight; return Blade; end New_Scalar_Blade; -- ------------------------------------------------------------------------ function New_Zero_Blade return Basis_Blade is Blade : Basis_Blade; begin return Blade; end New_Zero_Blade; -- ------------------------------------------------------------------------ function Outer_Product (BA, BB : Basis_Blade) return Basis_Blade is begin return GP_OP (BA, BB, True); end Outer_Product; -- ------------------------------------------------------------------------ function Reverse_Blade (B : Basis_Blade) return Basis_Blade is G : constant Integer := Grade (B); -- Bit_Count (B.Bitmap) W : constant Float := Float (Minus_1_Power ((G * (G - 1)) / 2)) * B.Weight; begin return (B.Bitmap, W); end Reverse_Blade; -- ------------------------------------------------------------------------ procedure Simplify (Blades : in out Blade_List) is use Blade_List_Package; Current_Blade : Blade.Basis_Blade; Blade_B : Blade.Basis_Blade; Blade_Cursor : Cursor; Result : Blade_List; begin if List (Blades) /= Empty_List then Blade_Cursor := Blades.First; while Has_Element (Blade_Cursor) loop Blade_B := Element (Blade_Cursor); if Weight (Blade_B) = 0.0 then Delete (Blades, Blade_Cursor); else Next (Blade_Cursor); end if; end loop; if List (Blades) /= Empty_List then Blade_Sort_Package.Sort (List (Blades)); Blade_Cursor := Blades.First; Current_Blade := Element (Blade_Cursor); Next (Blade_Cursor); while Has_Element (Blade_Cursor) loop Blade_B := Element (Blade_Cursor); if Bitmap (Blade_B) = Bitmap (Current_Blade) then Current_Blade := New_Blade (Bitmap (Current_Blade), Weight (Current_Blade) + Weight (Blade_B)); else if Abs (Weight (Current_Blade)) > epsilon then Result.Append (Current_Blade); end if; Current_Blade := Blade_B; end if; Next (Blade_Cursor); end loop; if Abs (Weight (Current_Blade)) > epsilon then Result.Append (Current_Blade); end if; Blades := Result; end if; end if; end Simplify; -- ------------------------------------------------------------------------- function To_Eigen_Basis (BB : Basis_Blade; Met : Metric.Metric_Record) return Blade_List is begin return Transform_Basis (BB, GA_Maths.Float_Matrix (Metric.Eigen_Vectors (Met))); end To_Eigen_Basis; -- ------------------------------------------------------------------------ function To_Metric_Basis (BB : Basis_Blade; Met : Metric.Metric_Record) return Blade_List is begin return Transform_Basis (BB, GA_Maths.Float_Matrix (Metric.Inv_Eigen_Matrix (Met))); end To_Metric_Basis; -- ------------------------------------------------------------------------ function To_Metric_Basis (BL : Blade_List; Met : Metric.Metric_Record) return Blade_List is use Blade_List_Package; BL_Cursor : Cursor := BL.First; Tmp_List : Blade_List; TL_Cursor : Cursor; Result : Blade_List; begin -- GA_Utilities.Print_Blade_List ("Blade.To_Metric_Basis BL", BL); while Has_Element (BL_Cursor) loop Tmp_List.Clear; -- GA_Utilities.Print_Blade ("Blade.To_Metric_Basis blade", Element (BL_Cursor)); Tmp_List := To_Metric_Basis (Element (BL_Cursor), Met); -- GA_Utilities.Print_Blade_List ("Blade.To_Metric_Basis Tmp_List", Tmp_List); TL_Cursor := Tmp_List.First; while Has_Element (TL_Cursor) loop Result.Append (Element (TL_Cursor)); Next (TL_Cursor); end loop; Next (BL_Cursor); end loop; Simplify (Result); return Result; exception when others => Put_Line ("An exception occurred in Blade.To_Metric_Basis"); raise; end To_Metric_Basis; -- ------------------------------------------------------------------------ -- Transform_Basis transforms a Basis_Blade to a new basis -- Based on Metric.java ArrayList transform(BasisBlade a, DoubleMatrix2D M) function Transform_Basis (BA : Blade.Basis_Blade; Met : GA_Maths.Float_Matrix) return Blade_List is use Blade_List_Package; List_A : Blade_List; BM : Unsigned_32 := Bitmap (BA); Curs : Cursor; OP : Basis_Blade; Temp : Blade_List; I_Col : Integer := 1; Value : Float; begin -- New_Line; -- GA_Utilities.Print_Matrix ("Blade.Transform_Basis Met", Real_Matrix ((Met))); -- GA_Utilities.Print_Blade ("Blade.Transform_Basis BA", BA); -- Put_Line ("Blade.Transform_Basis Bitmap (BA)" & Unsigned_32'Image (BM)); -- start with just a scalar List_A.Append (New_Blade (Weight (BA))); -- convert each 1 bit to a list of blades -- Put_Line ("Blade.Transform_Basis 1st blade added"); while BM /= 0 loop -- Put_Line ("Blade.Transform_Basis BM" & Unsigned_32'Image (BM)); if (BM and 1) /= 0 then Temp.Clear; for Row in 1 .. Met'Length (1) loop -- Put_Line ("Blade.Transform_Basis Row, I_Col" & -- Integer'Image (Row) & Integer'Image (I_Col)); Value := Met (Row, I_Col); if Value /= 0.0 then -- Wedge column Col of the matrix with List_A Curs := List_A.First; while Has_Element (Curs) loop -- GA_Utilities.Print_Blade ("Blade.Transform_Basis Element (Curs)", Element (Curs)); OP := Outer_Product (Element (Curs), New_Basis_Blade (2 ** (Row - 1), Value)); Temp.Append (OP); Next (Curs); end loop; end if; end loop; -- Row List_A := Temp; end if; -- (BM and 1) /= 0 BM := Shift_Right (BM, 1); I_Col := I_Col + 1; end loop; -- BM /= 0 return List_A; exception when others => Put_Line ("An exception occurred in Blade.Transform_Basis"); raise; end Transform_Basis; -- ------------------------------------------------------------------------ procedure Update_Blade (BB : in out Basis_Blade; Weight : Float) is begin BB.Weight := Weight; exception when others => Put_Line ("An exception occurred in Blade.Update_Blade 1"); raise; end Update_Blade; -- ------------------------------------------------------------------------ procedure Update_Blade (BB : in out Basis_Blade; Bitmap : Unsigned_32) is begin if Bitmap < 32 then BB.Bitmap := Bitmap; else raise Blade_Exception with "Blade.Update_Blade invalid Bitmap."; end if; end Update_Blade; -- ------------------------------------------------------------------------ procedure Update_Blade (BB : in out Basis_Blade; Bitmap : Unsigned_32; Weight : Float) is begin if Bitmap < 32 then BB.Bitmap := Bitmap; BB.Weight := Weight; else raise Blade_Exception with "Blade.Update_Blade invalid Bitmap."; end if; end Update_Blade; -- ------------------------------------------------------------------------ function Weight (BB : Basis_Blade) return Float is begin return BB.Weight; end Weight; -- ------------------------------------------------------------------------ end Blade;
sf17k/sdlada
Ada
4,187
adb
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2014-2015 Luke A. Guest -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- -- 1. The origin of this software must not be misrepresented; you must not -- claim that you wrote the original software. If you use this software -- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- -- 3. This notice may not be removed or altered from any source -- distribution. -------------------------------------------------------------------------------------------------------------------- with Interfaces.C; with Interfaces.C.Strings; with Ada.Text_IO; use Ada.Text_IO; with SDL.Error; package body SDL.Video is package C renames Interfaces.C; use type C.int; function Is_Screen_Saver_Enabled return Boolean is function SDL_Is_Screen_Saver_Enabled return C.int with Import => True, Convention => C, External_Name => "SDL_IsScreenSaverEnabled"; begin return (if SDL_Is_Screen_Saver_Enabled = 1 then True else False); end Is_Screen_Saver_Enabled; function Initialise (Name : in String) return Boolean is function SDL_Video_Init (C_Name : in C.Strings.chars_ptr) return C.int with Import => True, Convention => C, External_Name => "SDL_VideoInit"; C_Str : C.Strings.chars_ptr := C.Strings.Null_Ptr; Result : C.int; begin if Name /= "" then C_Str := C.Strings.New_String (Name); Result := SDL_Video_Init (C_Name => C_Str); C.Strings.Free (C_Str); else Result := SDL_Video_Init (C_Name => C.Strings.Null_Ptr); end if; return (Result = Success); end Initialise; function Total_Drivers return Positive is function SDL_Get_Num_Video_Drivers return C.int with Import => True, Convention => C, External_Name => "SDL_GetNumVideoDrivers"; Num : constant C.int := SDL_Get_Num_Video_Drivers; begin if Num < 0 then raise Video_Error with SDL.Error.Get; end if; return Positive (Num); end Total_Drivers; function Driver_Name (Index : in Positive) return String is function SDL_Get_Video_Driver (I : in C.int) return C.Strings.chars_ptr with Import => True, Convention => C, External_Name => "SDL_GetVideoDriver"; -- Index is zero based, so need to subtract 1 to correct it. C_Str : C.Strings.chars_ptr := SDL_Get_Video_Driver (C.int (Index) - 1); begin return C.Strings.Value (C_Str); end Driver_Name; function Current_Driver_Name return String is function SDL_Get_Current_Video_Driver return C.Strings.chars_ptr with Import => True, Convention => C, External_Name => "SDL_GetCurrentVideoDriver"; C_Str : constant C.Strings.chars_ptr := SDL_Get_Current_Video_Driver; use type C.Strings.chars_ptr; begin if C_Str = C.Strings.Null_Ptr then raise Video_Error with SDL.Error.Get; end if; return C.Strings.Value (C_Str); end Current_Driver_Name; function Total_Displays return Positive is function SDL_Get_Num_Video_Displays return C.int with Import => True, Convention => C, External_Name => "SDL_GetNumVideoDisplays"; Num : constant C.int := SDL_Get_Num_Video_Displays; begin if Num <= 0 then raise Video_Error with SDL.Error.Get; end if; return Positive (Num); end Total_Displays; end SDL.Video;
reznikmm/matreshka
Ada
3,839
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 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$ ------------------------------------------------------------------------------ with Matreshka.ODF_Attributes.Text.Line_Number; package ODF.DOM.Attributes.Text.Line_Number.Internals is function Create (Node : Matreshka.ODF_Attributes.Text.Line_Number.Text_Line_Number_Access) return ODF.DOM.Attributes.Text.Line_Number.ODF_Text_Line_Number; function Wrap (Node : Matreshka.ODF_Attributes.Text.Line_Number.Text_Line_Number_Access) return ODF.DOM.Attributes.Text.Line_Number.ODF_Text_Line_Number; end ODF.DOM.Attributes.Text.Line_Number.Internals;
reznikmm/matreshka
Ada
1,928
ads
-- Copyright (c) 1990 Regents of the University of California. -- All rights reserved. -- -- The primary authors of ayacc were David Taback and Deepak Tolani. -- Enhancements were made by Ronald J. Schmalz. -- -- Send requests for ayacc information to [email protected] -- Send bug reports for ayacc to [email protected] -- -- Redistribution and use in source and binary forms are permitted -- provided that the above copyright notice and this paragraph are -- duplicated in all such forms and that any documentation, -- advertising materials, and other materials related to such -- distribution and use acknowledge that the software was developed -- by the University of California, Irvine. The name of the -- University may not be used to endorse or promote products derived -- from this software without specific prior written permission. -- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR -- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. -- Module : output_file.ada -- Component of : ayacc -- Version : 1.2 -- Date : 11/21/86 12:31:54 -- SCCS File : disk21~/rschm/hasee/sccs/ayacc/sccs/sxoutput_file.ada -- $Header: output_file.a,v 0.1 86/04/01 15:08:21 ada Exp $ -- $Log: output_file.a,v $ -- Revision 0.1 86/04/01 15:08:21 ada -- This version fixes some minor bugs with empty grammars -- and $$ expansion. It also uses vads5.1b enhancements -- such as pragma inline. -- -- -- Revision 0.0 86/02/19 18:37:42 ada -- -- These files comprise the initial version of Ayacc -- designed and implemented by David Taback and Deepak Tolani. -- Ayacc has been compiled and tested under the Verdix Ada compiler -- version 4.06 on a vax 11/750 running Unix 4.2BSD. -- -- Creates the parser package Output_File is procedure Make_Output_File; end Output_File;
wookey-project/ewok-legacy
Ada
2,221
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 system; package soc.flash is ----------------------------------------------- -- Flash access control register (FLASH_ACR) -- -- for STM32F42xxx and STM32F43xxx -- ----------------------------------------------- type t_FLASH_ACR is record LATENCY : bits_4; -- reserved_04_07 PRFTEN : boolean; -- Prefetch enable ICEN : boolean; -- Instruction cache enable DCEN : boolean; -- Data cache enable ICRST : boolean; -- Instruction cache reset DCRST : boolean; -- Data cache reset -- reserved_13_31 end record with volatile_full_access, size => 32; for t_FLASH_ACR use record LATENCY at 0 range 0 .. 3; -- reserved_04_07 PRFTEN at 0 range 8 .. 8; ICEN at 0 range 9 .. 9; DCEN at 0 range 10 .. 10; ICRST at 0 range 11 .. 11; DCRST at 0 range 12 .. 12; -- reserved_13_31 end record; ---------------------- -- FLASH peripheral -- ---------------------- type t_FLASH_peripheral is record ACR : t_FLASH_ACR; end record with volatile; for t_FLASH_peripheral use record ACR at 16#00# range 0 .. 31; end record; FLASH : t_FLASH_peripheral with import, volatile, address => system'to_address(16#4002_3C00#); end soc.flash;
jhumphry/Ada_BinToAsc
Ada
20,837
adb
-- BinToAsc_Suite.Base32_Tests -- Unit tests for BinToAsc -- Copyright (c) 2015, James Humphry - see LICENSE file for details with AUnit.Assertions; with System.Storage_Elements; with Ada.Assertions; with String_To_Storage_Array; with BinToAsc.Base32; package body BinToAsc_Suite.Base32_Tests is use AUnit.Assertions; use System.Storage_Elements; use RFC4648; use type RFC4648.Codec_State; function STSA (X : String) return Storage_Array renames String_To_Storage_Array; -------------------- -- Register_Tests -- -------------------- procedure Register_Tests (T: in out Base32_Test) is use AUnit.Test_Cases.Registration; begin Register_Routine (T, Check_Symmetry'Access, "Check the Base32 Encoder and Decoder are a symmetrical pair"); Register_Routine (T, Check_Length'Access, "Check the Encoder and Decoder handle variable-length input successfully"); Register_Routine (T, Check_Symmetry_Hex'Access, "Check the Base32Hex Encoder and Decoder are a symmetrical pair"); Register_Routine (T, Check_Test_Vectors_To_String'Access, "Check Base32 test vectors from RFC4648, binary -> string"); Register_Routine (T, Check_Test_Vectors_To_String_Hex'Access, "Check Base32Hex test vectors from RFC4648, binary -> string"); Register_Routine (T, Check_Test_Vectors_To_Bin'Access, "Check Base32 test vectors from RFC4648, string -> binary"); Register_Routine (T, Check_Test_Vectors_To_Bin_Hex'Access, "Check Base32Hex test vectors from RFC4648, string -> binary"); Register_Routine (T, Check_Test_Vectors_Incremental_To_String'Access, "Check Base32 test vectors from RFC4648, incrementally, binary -> string"); Register_Routine (T, Check_Test_Vectors_Incremental_To_String_Hex'Access, "Check Base32Hex test vectors from RFC4648, incrementally, binary -> string"); Register_Routine (T, Check_Test_Vectors_Incremental_To_Bin'Access, "Check Base32 test vectors from RFC4648, incrementally, string -> binary"); Register_Routine (T, Check_Test_Vectors_Incremental_To_Bin_Hex'Access, "Check Base32Hex test vectors from RFC4648, incrementally, string -> binary"); Register_Routine (T, Check_Test_Vectors_By_Char_To_String'Access, "Check Base32 test vectors from RFC4648, character-by-character, binary -> string"); Register_Routine (T, Check_Test_Vectors_By_Char_To_String_Hex'Access, "Check Base32Hex test vectors from RFC4648, character-by-character, binary -> string"); Register_Routine (T, Check_Test_Vectors_By_Char_To_Bin'Access, "Check Base32 test vectors from RFC4648, character-by-character, string -> binary"); Register_Routine (T, Check_Test_Vectors_By_Char_To_Bin_Hex'Access, "Check Base32Hex test vectors from RFC4648, character-by-character, string -> binary"); Register_Routine (T, Check_Padding'Access, "Check correct Base32 padding is enforced"); Register_Routine (T, Check_Junk_Rejection'Access, "Check Base32 decoder will reject junk input"); Register_Routine (T, Check_Junk_Rejection_By_Char'Access, "Check Base32 decoder will reject junk input (single character)"); Register_Routine (T, Check_Case_Insensitive'Access, "Check Base32_Case_Insensitive decoder will accept mixed-case input"); Register_Routine (T, Check_Homoglyph'Access, "Check Base32 decoder with Homoglpyh_Allowed set tolerates homoglyphs"); end Register_Tests; ---------- -- Name -- ---------- function Name (T : Base32_Test) return Test_String is pragma Unreferenced (T); begin return Format ("Tests of Base32 and Base32Hex codecs from RFC4648"); end Name; ------------ -- Set_Up -- ------------ procedure Set_Up (T : in out Base32_Test) is begin null; end Set_Up; ------------------- -- Check_Padding -- ------------------- -- These procedures cannot be nested inside Check_Padding due to access -- level restrictions procedure Should_Raise_Exception_Excess_Padding is Discard : Storage_Array(1..6); begin Discard := RFC4648.Base32.To_Bin("MZXW6YTBI======="); end; procedure Should_Raise_Exception_Insufficient_Padding is Discard : Storage_Array(1..6); begin Discard := RFC4648.Base32.To_Bin("MZXW6YTBOI====="); end; procedure Check_Padding (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced (T); Base32_Decoder : RFC4648.Base32.Base32_To_Bin; Result_Bin : Storage_Array(1..20); Result_Length : Storage_Offset; begin Assert_Exception(Should_Raise_Exception_Excess_Padding'Access, "Base32 decoder did not reject excessive padding"); Assert_Exception(Should_Raise_Exception_Insufficient_Padding'Access, "Base32 decoder did not reject insufficient padding"); Base32_Decoder.Reset; Base32_Decoder.Process(Input => "MZXW6YTBI=======", Output => Result_Bin, Output_Length => Result_Length); Assert(Base32_Decoder.State = Failed or Result_Length /= 0, "Base32 decoder did not reject excessive padding"); Base32_Decoder.Reset; Base32_Decoder.Process(Input => "MZXW6YTBI======", Output => Result_Bin, Output_Length => Result_Length); Base32_Decoder.Process(Input => "=", Output => Result_Bin, Output_Length => Result_Length); Assert(Base32_Decoder.State = Failed or Result_Length /= 0, "Base32 decoder did not reject excessive padding when presented " & "as a one-char string after the initial valid input"); Base32_Decoder.Reset; Base32_Decoder.Process(Input => "MZXW6YTBI=====", Output => Result_Bin, Output_Length => Result_Length); Base32_Decoder.Process(Input => "==", Output => Result_Bin, Output_Length => Result_Length); Assert(Base32_Decoder.State = Failed or Result_Length /= 0, "Base32 decoder did not reject excessive padding when presented " & "as a == after the initial valid but incompletely padded " & "input"); Base32_Decoder.Reset; Base32_Decoder.Process(Input => "MZXW6YTBI======", Output => Result_Bin, Output_Length => Result_Length); Base32_Decoder.Process(Input => '=', Output => Result_Bin, Output_Length => Result_Length); Assert(Base32_Decoder.State = Failed or Result_Length /= 0, "Base32 decoder did not reject excessive padding when presented " & "as a separate character after the initial valid input"); Base32_Decoder.Reset; Base32_Decoder.Process(Input => "MZXW6YTBOI=====", Output => Result_Bin, Output_Length => Result_Length); Base32_Decoder.Complete(Output => Result_Bin, Output_Length => Result_Length); Assert(Base32_Decoder.State = Failed or Result_Length /= 0, "Base32 decoder did not reject inadequate padding"); Base32_Decoder.Reset; Base32_Decoder.Process(Input => "MZXW6YTBOI", Output => Result_Bin, Output_Length => Result_Length); Base32_Decoder.Complete(Output => Result_Bin, Output_Length => Result_Length); Assert(Base32_Decoder.State = Failed or Result_Length /= 0, "Base32 decoder did not reject inadequate padding"); Base32_Decoder.Reset; Base32_Decoder.Process(Input => "MZXW6Y==", Output => Result_Bin, Output_Length => Result_Length); Assert(Base32_Decoder.State = Failed or Result_Length /= 0, "Base32 decoder did not reject impossible length 2 padding"); Base32_Decoder.Reset; Base32_Decoder.Process(Input => "MZXW6Y=", Output => Result_Bin, Output_Length => Result_Length); Base32_Decoder.Process(Input => '=', Output => Result_Bin, Output_Length => Result_Length); Assert(Base32_Decoder.State = Failed or Result_Length /= 0, "Base32 decoder did not reject impossible length 2 padding " & "presented via a character"); Base32_Decoder.Reset; Base32_Decoder.Process(Input => "MZX=====", Output => Result_Bin, Output_Length => Result_Length); Assert(Base32_Decoder.State = Failed or Result_Length /= 0, "Base32 decoder did not reject impossible length 5 padding"); Base32_Decoder.Reset; Base32_Decoder.Process(Input => "MZX====", Output => Result_Bin, Output_Length => Result_Length); Base32_Decoder.Process(Input => '=', Output => Result_Bin, Output_Length => Result_Length); Assert(Base32_Decoder.State = Failed or Result_Length /= 0, "Base32 decoder did not reject impossible length 5 padding " & "presented via a character"); Base32_Decoder.Reset; Base32_Decoder.Process(Input => "MZXW6YT=BOI=====", Output => Result_Bin, Output_Length => Result_Length); Assert(Base32_Decoder.State = Failed or Result_Length /= 0, "Base32 decoder did not reject non-padding characters appearing " & " after the first padding Character in a single input"); Base32_Decoder.Reset; Base32_Decoder.Process(Input => "MZXW6YT=", Output => Result_Bin, Output_Length => Result_Length); Base32_Decoder.Process(Input => "BOI=====", Output => Result_Bin, Output_Length => Result_Length); Assert(Base32_Decoder.State = Failed or Result_Length /= 0, "Base32 decoder did not reject non-padding input presented " & " after an initial input ended with padding"); Base32_Decoder.Reset; Base32_Decoder.Process(Input => "MZXW6YT=", Output => Result_Bin, Output_Length => Result_Length); Base32_Decoder.Process(Input => 'B', Output => Result_Bin, Output_Length => Result_Length); Assert(Base32_Decoder.State = Failed or Result_Length /= 0, "Base32 decoder did not reject non-padding input char presented " & " after an initial input ended with padding"); Base32_Decoder.Reset; Base32_Decoder.Process(Input => "MZXW6YT", Output => Result_Bin, Output_Length => Result_Length); Base32_Decoder.Process(Input => '=', Output => Result_Bin, Output_Length => Result_Length); Base32_Decoder.Process(Input => "BOI", Output => Result_Bin, Output_Length => Result_Length); Assert(Base32_Decoder.State = Failed or Result_Length /= 0, "Base32 decoder did not reject non-padding string presented " & " after a padding char presented on its own"); end Check_Padding; -------------------------- -- Check_Junk_Rejection -- -------------------------- -- This procedure cannot be nested inside Check_Junk_Rejection due to access -- level restrictions procedure Should_Raise_Exception_From_Junk is Discard : Storage_Array(1..6); begin Discard := RFC4648.Base32.To_Bin("MZXW:YTB"); end; procedure Check_Junk_Rejection (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced (T); Base32_Decoder : RFC4648.Base32.Base32_To_Bin; Result_Bin : Storage_Array(1..20); Result_Length : Storage_Offset; begin Assert_Exception(Should_Raise_Exception_From_Junk'Access, "Base32 decoder did not reject junk input."); Base32_Decoder.Reset; Base32_Decoder.Process(Input => "MZXW:YTB", Output => Result_Bin, Output_Length => Result_Length); Assert(Base32_Decoder.State = Failed, "Base32 decoder did not reject junk input."); Assert(Result_Length = 0, "Base32 decoder rejected junk input but did not return 0 " & "length output."); begin Base32_Decoder.Process(Input => "MZ", Output => Result_Bin, Output_Length => Result_Length); exception when Ada.Assertions.Assertion_Error => null; -- Preconditions (if active) will not allow Process to be run -- on a codec with state /= Ready. end; Assert(Base32_Decoder.State = Failed, "Base32 decoder reset its state on valid input after junk input."); Assert(Result_Length = 0, "Base32 decoder rejected input after a junk input but did " & "not return 0 length output."); begin Base32_Decoder.Complete(Output => Result_Bin, Output_Length => Result_Length); exception when Ada.Assertions.Assertion_Error => null; -- Preconditions (if active) will not allow Completed to be run -- on a codec with state /= Ready. end; Assert(Base32_Decoder.State = Failed, "Base16 decoder allowed successful completion after junk input."); Assert(Result_Length = 0, "Base32 decoder completed after a junk input did " & "not return 0 length output."); end Check_Junk_Rejection; ---------------------------------- -- Check_Junk_Rejection_By_Char -- ---------------------------------- procedure Check_Junk_Rejection_By_Char (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced (T); Base32_Decoder : RFC4648.Base32.Base32_To_Bin; Result_Bin : Storage_Array(1..20); Result_Length : Storage_Offset; begin Base32_Decoder.Reset; Base32_Decoder.Process(Input => '@', Output => Result_Bin, Output_Length => Result_Length); Assert(Base32_Decoder.State = Failed, "Base32 decoder did not reject junk input character."); Assert(Result_Length = 0, "Base32 decoder rejected junk input but did not return 0 " & "length output."); begin Base32_Decoder.Process(Input => '6', Output => Result_Bin, Output_Length => Result_Length); exception when Ada.Assertions.Assertion_Error => null; -- Preconditions (if active) will not allow Process to be run -- on a codec with state /= Ready. end; Assert(Base32_Decoder.State = Failed, "Base32 decoder reset its state on valid input after junk input " & "character."); Assert(Result_Length = 0, "Base32 decoder rejected input after a junk input char but did " & "not return 0 length output."); begin Base32_Decoder.Complete(Output => Result_Bin, Output_Length => Result_Length); exception when Ada.Assertions.Assertion_Error => null; -- Preconditions (if active) will not allow Completed to be run -- on a codec with state /= Ready. end; Assert(Base32_Decoder.State = Failed, "Base32 decoder allowed successful completion after junk input " & "char."); Assert(Result_Length = 0, "Base32 decoder completed after a junk input char did " & "not return 0 length output."); end Check_Junk_Rejection_By_Char; ---------------------------- -- Check_Case_Insensitive -- ---------------------------- procedure Check_Case_Insensitive (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced(T); Test_Input : constant Storage_Array := STSA("foobar"); Encoded : constant String := "MZXW6YTBOI======"; Encoded_Mixed_Case : constant String := "MZXw6yTBoI======"; Base32_Decoder : RFC4648.Base32.Base32_To_Bin; Buffer : Storage_Array(1..15); Buffer_Used : Storage_Offset; begin Assert(Test_Input = RFC4648.Base32.To_Bin(Encoded), "Base32 case-sensitive decoder not working"); Base32_Decoder.Reset; Base32_Decoder.Process(Encoded_Mixed_Case, Buffer, Buffer_Used); Assert(Base32_Decoder.State = Failed and Buffer_Used = 0, "Base32 case-sensitive decoder did not reject mixed-case input"); Assert(Test_Input = RFC4648.Base32_Case_Insensitive.To_Bin(Encoded_Mixed_Case), "Base32 case-insensitive decoder not working"); end Check_Case_Insensitive; --------------------- -- Check_Homoglyph -- --------------------- procedure Check_Homoglyph (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced (T); package Base32_UC is new RFC4648.BToA.Base32(Alphabet => Base32_Alphabet, Padding => '=', Case_Sensitive => True, Allow_Homoglyphs => True); Base32_Alphabet_LC : constant BToA.Alphabet_32 := "abcdefghijklmnopqrstuvwxyz234567"; package Base32_LC is new RFC4648.BToA.Base32(Alphabet => Base32_Alphabet_LC, Padding => '=', Case_Sensitive => True, Allow_Homoglyphs => True); Binary_Input : Storage_Array(0..255); Encoded_Data : String(1..416); Decoded_Data : Storage_Array(0..255); begin for I in Binary_Input'Range loop Binary_Input(I) := Storage_Element(I - Binary_Input'First); end loop; Encoded_Data := Base32_UC.To_String(Binary_Input); Assert((for some I of Encoded_Data => I = 'O') and (for some I of Encoded_Data => I = 'I'), "Test data does not contain O or I so upper-case homoglyph test cannot be done"); for I in Encoded_Data'Range loop case Encoded_Data(I) is when 'O' => Encoded_Data(I) := '0'; when 'I' => Encoded_Data(I) := '1'; when others => null; end case; end loop; Decoded_Data := Base32_UC.To_Bin(Encoded_Data); Assert((for all I in Decoded_Data'Range => Decoded_Data(I) = Storage_Element(I-Decoded_Data'First)), "Encoder / Decoder pair does not tolerate upper-case homoglyphs"); Encoded_Data := Base32_LC.To_String(Binary_Input); Assert((for some I of Encoded_Data => I = 'o') and (for some I of Encoded_Data => I = 'l'), "Test data does not contain o or l so lower-case homoglyph test cannot be done"); for I in Encoded_Data'Range loop case Encoded_Data(I) is when 'o' => Encoded_Data(I) := '0'; when 'l' => Encoded_Data(I) := '1'; when others => null; end case; end loop; Decoded_Data := Base32_LC.To_Bin(Encoded_Data); Assert((for all I in Decoded_Data'Range => Decoded_Data(I) = Storage_Element(I-Decoded_Data'First)), "Encoder / Decoder pair does not tolerate lower-case homoglyphs"); end Check_Homoglyph; end BinToAsc_Suite.Base32_Tests;
stcarrez/ada-wiki
Ada
1,073
ads
----------------------------------------------------------------------- -- wiki-parsers-creole -- Creole parser operations -- Copyright (C) 2011 - 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. ----------------------------------------------------------------------- private package Wiki.Parsers.Creole with Preelaborate is procedure Parse_Line (Parser : in out Parser_Type; Text : in Wiki.Buffers.Buffer_Access); end Wiki.Parsers.Creole;
zhmu/ananas
Ada
2,598
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- G N A T . T A S K _ L O C K -- -- -- -- B o d y -- -- -- -- Copyright (C) 1997-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 does not require a body, since it is a package renaming. We -- provide a dummy file containing a No_Body pragma so that previous versions -- of the body (which did exist) will not interfere. pragma No_Body;
BrickBot/Bound-T-H8-300
Ada
5,087
adb
-- String_Pool (body) -- -- String storage for symbol tables. -- -- A component of the Bound-T Worst-Case Execution Time Tool. -- ------------------------------------------------------------------------------- -- Copyright (c) 1999 .. 2015 Tidorum Ltd -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- 1. Redistributions of source code must retain the above copyright notice, this -- list of conditions and the following disclaimer. -- 2. Redistributions in binary form must reproduce the above copyright notice, -- this list of conditions and the following disclaimer in the documentation -- and/or other materials provided with the distribution. -- -- This software is provided by the copyright holders and contributors "as is" and -- any express or implied warranties, including, but not limited to, the implied -- warranties of merchantability and fitness for a particular purpose are -- disclaimed. In no event shall the copyright owner or contributors be liable for -- any direct, indirect, incidental, special, exemplary, or consequential damages -- (including, but not limited to, procurement of substitute goods or services; -- loss of use, data, or profits; or business interruption) however caused and -- on any theory of liability, whether in contract, strict liability, or tort -- (including negligence or otherwise) arising in any way out of the use of this -- software, even if advised of the possibility of such damage. -- -- Other modules (files) of this software composition should contain their -- own copyright statements, which may have different copyright and usage -- conditions. The above conditions apply to this file. ------------------------------------------------------------------------------- -- -- $Revision: 1.5 $ -- $Date: 2015/10/24 20:05:52 $ -- -- $Log: string_pool.adb,v $ -- Revision 1.5 2015/10/24 20:05:52 niklas -- Moved to free licence. -- -- Revision 1.4 2011-08-31 04:23:34 niklas -- BT-CH-0222: Option registry. Option -dump. External help files. -- -- Revision 1.3 2009/03/24 07:48:35 niklas -- BT-CH-0166: String_Pool.Item_T for source-file and marker names. -- -- Revision 1.2 2007/04/26 11:28:05 niklas -- BT-CH-0059. -- -- Revision 1.1 2000/05/02 19:41:28 holsti -- String_Pool added, Symbols partly implemented. -- with Hash_G; -- LGL components with Hash_G.Changes_G; -- LGL components with Interfaces; package body String_Pool is function Char_XOR (S : String) return Natural is use Interfaces; Hash : Unsigned_32 := S'Length; begin for I in S'range loop Hash := Rotate_Left (Hash, 8) xor Unsigned_32 (Character'pos(S(I))); end loop; return Natural (Hash mod Unsigned_32(Natural'Last)); end Char_XOR; package String_Hash is new Hash_G ( Key_Type => String, Data_Type => Item_T, Hash => Char_XOR); package String_Hash_Changes is new String_Hash.Changes_G; Initial_Size_C : constant := 1023; -- -- Initial size of the hash table. Size_Increment_C : constant := 511; -- -- Amount by which hash table is grown when it gets full. Pool : String_Hash.Hash_Table_Type := String_Hash.Create (Minimum_Size => Initial_Size_C); -- -- The string pool. -- It will be resized (grown) if necessary. procedure Add_Item (Item : Item_T) -- -- Add the item to the string pool. -- is use String_Hash, String_Hash_Changes; Old_Size, New_Size : Positive; begin if Is_Full (Pool) then Old_Size := Size (Pool); New_Size := Old_Size + Size_Increment_C; Resize ( Hash_Table => Pool, Minimum_Size => New_Size); end if; Insert ( Hash_Table => Pool, Key => Item.all, Data => Item); end Add_Item; function To_Item (S : String) return Item_T is Item : Item_T; -- The value to be returned. use String_Hash; begin Item := Retrieve ( Hash_Table => Pool, Key => S); -- The string is already in the pool. return Item; exception when Key_Not_Found_Error => -- New string, add it to pool. Item := new String'(S); Add_Item (Item); return Item; end To_Item; function To_String (Item : Item_T) return String is begin return Item.all; end To_String; function Length (Item : Item_T) return Natural is begin return Item.all'Length; end Length; function "<" (Left, Right : Item_T) return Boolean is begin return Left.all < Right.all; end "<"; function "=" (Left : String; Right : Item_T) return Boolean is begin return Left = Right.all; end "="; function "=" (Left : Item_T; Right : String) return Boolean is begin return Left.all = Right; end "="; end String_Pool;
reznikmm/matreshka
Ada
4,708
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.Visitors; with ODF.DOM.Table_Previous_Elements; package Matreshka.ODF_Table.Previous_Elements is type Table_Previous_Element_Node is new Matreshka.ODF_Table.Abstract_Table_Element_Node and ODF.DOM.Table_Previous_Elements.ODF_Table_Previous with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Table_Previous_Element_Node; overriding function Get_Local_Name (Self : not null access constant Table_Previous_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Table_Previous_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Leave_Node (Self : not null access Table_Previous_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Visit_Node (Self : not null access Table_Previous_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); end Matreshka.ODF_Table.Previous_Elements;
reznikmm/matreshka
Ada
5,170
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. ------------------------------------------------------------------------------ -- CallAction is an abstract class for actions that invoke behavior and -- receive return values. ------------------------------------------------------------------------------ with AMF.UML.Invocation_Actions; limited with AMF.UML.Output_Pins.Collections; package AMF.UML.Call_Actions is pragma Preelaborate; type UML_Call_Action is limited interface and AMF.UML.Invocation_Actions.UML_Invocation_Action; type UML_Call_Action_Access is access all UML_Call_Action'Class; for UML_Call_Action_Access'Storage_Size use 0; not overriding function Get_Is_Synchronous (Self : not null access constant UML_Call_Action) return Boolean is abstract; -- Getter of CallAction::isSynchronous. -- -- If true, the call is synchronous and the caller waits for completion of -- the invoked behavior. If false, the call is asynchronous and the caller -- proceeds immediately and does not expect a return values. not overriding procedure Set_Is_Synchronous (Self : not null access UML_Call_Action; To : Boolean) is abstract; -- Setter of CallAction::isSynchronous. -- -- If true, the call is synchronous and the caller waits for completion of -- the invoked behavior. If false, the call is asynchronous and the caller -- proceeds immediately and does not expect a return values. not overriding function Get_Result (Self : not null access constant UML_Call_Action) return AMF.UML.Output_Pins.Collections.Ordered_Set_Of_UML_Output_Pin is abstract; -- Getter of CallAction::result. -- -- A list of output pins where the results of performing the invocation -- are placed. end AMF.UML.Call_Actions;
ohenley/ada-util
Ada
22,066
adb
----------------------------------------------------------------------- -- util-properties -- Generic name/value property management -- Copyright (C) 2001 - 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.IO_Exceptions; with Ada.Strings.Fixed; with Ada.Strings.Unbounded.Text_IO; with Ada.Strings.Maps; with Interfaces.C.Strings; with Ada.Unchecked_Deallocation; with Util.Beans.Objects.Maps; package body Util.Properties is use Ada.Text_IO; use Ada.Strings.Unbounded.Text_IO; use Interface_P; use Util.Beans.Objects; procedure Free is new Ada.Unchecked_Deallocation (Object => Interface_P.Manager'Class, Name => Interface_P.Manager_Access); Trim_Chars : constant Ada.Strings.Maps.Character_Set := Ada.Strings.Maps.To_Set (" " & ASCII.HT); type Property_Map is new Interface_P.Manager with record Props : Util.Beans.Objects.Maps.Map_Bean; end record; type Property_Map_Access is access all Property_Map; -- Get the value identified by the name. -- If the name cannot be found, the method should return the Null object. overriding function Get_Value (From : in Property_Map; Name : in String) return Util.Beans.Objects.Object; -- Set the value identified by the name. -- If the map contains the given name, the value changed. -- Otherwise name is added to the map and the value associated with it. overriding procedure Set_Value (From : in out Property_Map; Name : in String; Value : in Util.Beans.Objects.Object); -- Returns TRUE if the property exists. overriding function Exists (Self : in Property_Map; Name : in String) return Boolean; -- Remove the property given its name. overriding procedure Remove (Self : in out Property_Map; Name : in String); -- Iterate over the properties and execute the given procedure passing the -- property name and its value. overriding procedure Iterate (Self : in Property_Map; Process : access procedure (Name : in String; Item : in Util.Beans.Objects.Object)); -- Deep copy of properties stored in 'From' to 'To'. overriding function Create_Copy (Self : in Property_Map) return Interface_P.Manager_Access; -- ------------------------------ -- Get the value identified by the name. -- If the name cannot be found, the method should return the Null object. -- ------------------------------ overriding function Get_Value (From : in Property_Map; Name : in String) return Util.Beans.Objects.Object is begin return From.Props.Get_Value (Name); end Get_Value; -- ------------------------------ -- Set the value identified by the name. -- If the map contains the given name, the value changed. -- Otherwise name is added to the map and the value associated with it. -- ------------------------------ overriding procedure Set_Value (From : in out Property_Map; Name : in String; Value : in Util.Beans.Objects.Object) is begin From.Props.Set_Value (Name, Value); end Set_Value; -- ------------------------------ -- Returns TRUE if the property exists. -- ------------------------------ overriding function Exists (Self : in Property_Map; Name : in String) return Boolean is begin return Self.Props.Contains (Name); end Exists; -- ------------------------------ -- Remove the property given its name. -- ------------------------------ overriding procedure Remove (Self : in out Property_Map; Name : in String) is begin Self.Props.Delete (Name); end Remove; -- ------------------------------ -- Iterate over the properties and execute the given procedure passing the -- property name and its value. -- ------------------------------ overriding procedure Iterate (Self : in Property_Map; Process : access procedure (Name : in String; Item : in Util.Beans.Objects.Object)) is Iter : Util.Beans.Objects.Maps.Cursor := Self.Props.First; begin while Util.Beans.Objects.Maps.Has_Element (Iter) loop Util.Beans.Objects.Maps.Query_Element (Iter, Process); Util.Beans.Objects.Maps.Next (Iter); end loop; end Iterate; -- ------------------------------ -- Deep copy of properties stored in 'From' to 'To'. -- ------------------------------ overriding function Create_Copy (Self : in Property_Map) return Interface_P.Manager_Access is Result : constant Property_Map_Access := new Property_Map; begin -- SCz 2017-07-20: the map assignment is buggy on GNAT 2016 because the copy of the -- object also copies the internal Lock and Busy flags which makes the target copy -- unusable because the Lock and Busy flag prevents modifications. Instead of the -- Ada assignment, we use the Assign procedure which makes the deep copy of the map. -- Result.Props := Self.Props; Result.Props.Assign (Self.Props); return Result.all'Access; end Create_Copy; -- ------------------------------ -- Get the value identified by the name. -- If the name cannot be found, the method should return the Null object. -- ------------------------------ overriding function Get_Value (From : in Manager; Name : in String) return Util.Beans.Objects.Object is begin if From.Impl = null then return Util.Beans.Objects.Null_Object; else return From.Impl.Get_Value (Name); end if; end Get_Value; -- ------------------------------ -- Set the value identified by the name. -- If the map contains the given name, the value changed. -- Otherwise name is added to the map and the value associated with it. -- ------------------------------ overriding procedure Set_Value (From : in out Manager; Name : in String; Value : in Util.Beans.Objects.Object) is begin Check_And_Create_Impl (From); From.Impl.Set_Value (Name, Value); end Set_Value; -- ------------------------------ -- Returns TRUE if the property manager is empty. -- ------------------------------ function Is_Empty (Self : in Manager'Class) return Boolean is begin if Self.Impl = null then return True; else return False; end if; end Is_Empty; function Exists (Self : in Manager'Class; Name : in String) return Boolean is begin -- There is not yet an implementation, no property return Self.Impl /= null and then Self.Impl.Exists (Name); end Exists; function Exists (Self : in Manager'Class; Name : in Unbounded_String) return Boolean is begin -- There is not yet an implementation, no property return Self.Impl /= null and then Self.Impl.Exists (-Name); end Exists; function Get (Self : in Manager'Class; Name : in String) return Unbounded_String is Value : constant Util.Beans.Objects.Object := Self.Get_Value (Name); begin if Util.Beans.Objects.Is_Null (Value) then raise NO_PROPERTY with "No property: '" & Name & "'"; end if; return To_Unbounded_String (Value); end Get; function Get (Self : in Manager'Class; Name : in Unbounded_String) return Unbounded_String is begin return Self.Get (-Name); end Get; function Get (Self : in Manager'Class; Name : in String) return String is begin if Self.Impl = null then raise NO_PROPERTY with "No property: '" & Name & "'"; end if; return To_String (Self.Impl.Get_Value (Name)); end Get; function Get (Self : in Manager'Class; Name : in Unbounded_String) return String is begin return Self.Get (-Name); end Get; function Get (Self : in Manager'Class; Name : in String; Default : in String) return String is begin if Exists (Self, Name) then return Get (Self, Name); else return Default; end if; end Get; -- ------------------------------ -- Returns a property manager that is associated with the given name. -- Raises NO_PROPERTY if there is no such property manager or if a property exists -- but is not a property manager. -- ------------------------------ function Get (Self : in Manager'Class; Name : in String) return Manager is Value : constant Util.Beans.Objects.Object := Self.Get_Value (Name); Bean : constant access Util.Beans.Basic.Readonly_Bean'Class := Util.Beans.Objects.To_Bean (Value); begin if Bean = null or else not (Bean.all in Manager'Class) then raise NO_PROPERTY with "No property '" & Name & "'"; end if; return Manager (Bean.all); end Get; -- ------------------------------ -- Create a property manager and associated it with the given name. -- ------------------------------ function Create (Self : in out Manager'Class; Name : in String) return Manager is Result : Manager_Access; begin Check_And_Create_Impl (Self); -- Create the property manager and make it shared so that it can be populated by -- the caller. Result := new Manager; Check_And_Create_Impl (Result.all); Result.Impl.Shared := True; Self.Impl.Set_Value (Name, Util.Beans.Objects.To_Object (Result.all'Access)); return Manager (Result.all); end Create; procedure Check_And_Create_Impl (Self : in out Manager) is begin if Self.Impl = null then Self.Impl := new Property_Map; Util.Concurrent.Counters.Increment (Self.Impl.Count); elsif not Self.Impl.Shared and Util.Concurrent.Counters.Value (Self.Impl.Count) > 1 then declare Old : Interface_P.Manager_Access := Self.Impl; Is_Zero : Boolean; begin Self.Impl := Create_Copy (Self.Impl.all); Util.Concurrent.Counters.Increment (Self.Impl.Count); Util.Concurrent.Counters.Decrement (Old.Count, Is_Zero); if Is_Zero then Free (Old); end if; end; end if; end Check_And_Create_Impl; -- ------------------------------ -- Set the value of the property. The property is created if it -- does not exists. -- ------------------------------ procedure Set (Self : in out Manager'Class; Name : in String; Item : in String) is begin Self.Set_Value (Name, To_Object (Item)); end Set; -- ------------------------------ -- Set the value of the property. The property is created if it -- does not exists. -- ------------------------------ procedure Set (Self : in out Manager'Class; Name : in String; Item : in Unbounded_String) is begin Self.Set_Value (Name, To_Object (Item)); end Set; -- ------------------------------ -- Set the value of the property. The property is created if it -- does not exists. -- ------------------------------ procedure Set (Self : in out Manager'Class; Name : in Unbounded_String; Item : in Unbounded_String) is begin Self.Set_Value (-Name, To_Object (Item)); end Set; -- ------------------------------ -- Remove the property given its name. -- ------------------------------ procedure Remove (Self : in out Manager'Class; Name : in String) is begin if Self.Impl = null then raise NO_PROPERTY with "No property '" & Name & "'"; end if; Check_And_Create_Impl (Self); Remove (Self.Impl.all, Name); end Remove; -- ------------------------------ -- Remove the property given its name. -- ------------------------------ procedure Remove (Self : in out Manager'Class; Name : in Unbounded_String) is begin Self.Remove (-Name); end Remove; -- ------------------------------ -- Iterate over the properties and execute the given procedure passing the -- property name and its value. -- ------------------------------ procedure Iterate (Self : in Manager'Class; Process : access procedure (Name : in String; Item : in Util.Beans.Objects.Object)) is begin if Self.Impl /= null then Self.Impl.Iterate (Process); end if; end Iterate; -- ------------------------------ -- Get the property manager represented by the item value. -- Raise the Conversion_Error exception if the value is not a property manager. -- ------------------------------ function To_Manager (Item : in Value) return Manager is Bean : constant access Util.Beans.Basic.Readonly_Bean'Class := Util.Beans.Objects.To_Bean (Item); begin if Bean = null or else not (Bean.all in Manager'Class) then raise Util.Beans.Objects.Conversion_Error; end if; return Manager (Bean.all); end To_Manager; -- ------------------------------ -- Returns True if the item value represents a property manager. -- ------------------------------ function Is_Manager (Item : in Value) return Boolean is Bean : constant access Util.Beans.Basic.Readonly_Bean'Class := Util.Beans.Objects.To_Bean (Item); begin return Bean /= null and then (Bean.all in Manager'Class); end Is_Manager; -- ------------------------------ -- Collect the name of the properties defined in the manager. -- When a prefix is specified, only the properties starting with the prefix are -- returned. -- ------------------------------ procedure Get_Names (Self : in Manager; Into : in out Util.Strings.Vectors.Vector; Prefix : in String := "") is procedure Process (Name : in String; Item : in Util.Beans.Objects.Object); procedure Process (Name : in String; Item : in Util.Beans.Objects.Object) is pragma Unreferenced (Item); begin if Prefix'Length = 0 or else Ada.Strings.Fixed.Index (Name, Prefix) = 1 then Into.Append (Name); end if; end Process; begin if Self.Impl /= null then Self.Impl.Iterate (Process'Access); end if; end Get_Names; overriding procedure Adjust (Object : in out Manager) is begin if Object.Impl /= null then Util.Concurrent.Counters.Increment (Object.Impl.Count); end if; end Adjust; overriding procedure Finalize (Object : in out Manager) is Is_Zero : Boolean; begin if Object.Impl /= null then Util.Concurrent.Counters.Decrement (Object.Impl.Count, Is_Zero); if Is_Zero then Free (Object.Impl); end if; end if; end Finalize; procedure Load_Properties (Self : in out Manager'Class; File : in File_Type; Prefix : in String := ""; Strip : in Boolean := False) is pragma Unreferenced (Strip); Line : Unbounded_String; Name : Unbounded_String; Value : Unbounded_String; Current : Manager; Pos : Natural; Len : Natural; Old_Shared : Boolean; begin Check_And_Create_Impl (Self); Current := Manager (Self); Old_Shared := Current.Impl.Shared; Current.Impl.Shared := True; while not End_Of_File (File) loop Line := Get_Line (File); Len := Length (Line); if Len /= 0 then case Element (Line, 1) is when '!' | '#' => null; when '[' => Pos := Index (Line, "]"); if Pos > 0 then Current := Self.Create (To_String (Unbounded_Slice (Line, 2, Pos - 1))); end if; when others => Pos := Index (Line, "="); if Pos > 0 and then Prefix'Length > 0 and then Index (Line, Prefix) = 1 then Name := Unbounded_Slice (Line, Prefix'Length + 1, Pos - 1); Value := Tail (Line, Len - Pos); Trim (Name, Trim_Chars, Trim_Chars); Trim (Value, Trim_Chars, Trim_Chars); Current.Set (Name, Value); elsif Pos > 0 and Prefix'Length = 0 then Name := Head (Line, Pos - 1); Value := Tail (Line, Len - Pos); Trim (Name, Trim_Chars, Trim_Chars); Trim (Value, Trim_Chars, Trim_Chars); Current.Set (Name, Value); end if; end case; end if; end loop; Self.Impl.Shared := Old_Shared; exception when End_Error => return; end Load_Properties; procedure Load_Properties (Self : in out Manager'Class; Path : in String; Prefix : in String := ""; Strip : in Boolean := False) is F : File_Type; begin Open (F, In_File, Path); Load_Properties (Self, F, Prefix, Strip); Close (F); end Load_Properties; -- ------------------------------ -- Save the properties in the given file path. -- ------------------------------ procedure Save_Properties (Self : in out Manager'Class; Path : in String; Prefix : in String := "") is procedure Save_Property (Name : in String; Item : in Util.Beans.Objects.Object); Tmp : constant String := Path & ".tmp"; F : File_Type; procedure Save_Property (Name : in String; Item : in Util.Beans.Objects.Object) is begin if Prefix'Length > 0 then if Name'Length < Prefix'Length then return; end if; if Name (Name'First .. Prefix'Length - 1) /= Prefix then return; end if; end if; Put (F, Name); Put (F, "="); Put (F, Util.Beans.Objects.To_String (Item)); New_Line (F); end Save_Property; -- Rename a file (the Ada.Directories.Rename does not allow to use the -- Unix atomic file rename!) function Sys_Rename (Oldpath : in Interfaces.C.Strings.chars_ptr; Newpath : in Interfaces.C.Strings.chars_ptr) return Integer; pragma Import (C, Sys_Rename, "rename"); Old_Path : Interfaces.C.Strings.chars_ptr; New_Path : Interfaces.C.Strings.chars_ptr; Result : Integer; begin Create (File => F, Name => Tmp); Self.Iterate (Save_Property'Access); Close (File => F); -- Do a system atomic rename of old file in the new file. -- Ada.Directories.Rename does not allow this. Old_Path := Interfaces.C.Strings.New_String (Tmp); New_Path := Interfaces.C.Strings.New_String (Path); Result := Sys_Rename (Old_Path, New_Path); Interfaces.C.Strings.Free (Old_Path); Interfaces.C.Strings.Free (New_Path); if Result /= 0 then raise Ada.IO_Exceptions.Use_Error with "Cannot rename file"; end if; end Save_Properties; -- ------------------------------ -- Copy the properties from FROM which start with a given prefix. -- If the prefix is empty, all properties are copied. When <b>Strip</b> is True, -- the prefix part is removed from the property name. -- ------------------------------ procedure Copy (Self : in out Manager'Class; From : in Manager'Class; Prefix : in String := ""; Strip : in Boolean := False) is procedure Process (Name : in String; Value : in Util.Beans.Objects.Object); procedure Process (Name : in String; Value : in Util.Beans.Objects.Object) is begin if Prefix'Length > 0 then if Name'Length < Prefix'Length then return; end if; if Name (Name'First .. Name'First + Prefix'Length - 1) /= Prefix then return; end if; if Strip then Self.Set_Value (Name (Name'First + Prefix'Length .. Name'Last), Value); return; end if; end if; Self.Set_Value (Name, Value); end Process; begin From.Iterate (Process'Access); end Copy; end Util.Properties;
stcarrez/babel
Ada
64,769
adb
----------------------------------------------------------------------- -- Babel.Base.Models -- Babel.Base.Models ----------------------------------------------------------------------- -- File generated by ada-gen DO NOT MODIFY -- Template used: templates/model/package-body.xhtml -- Ada Generator: https://ada-gen.googlecode.com/svn/trunk Revision 1095 ----------------------------------------------------------------------- -- Copyright (C) 2014 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.Beans.Objects.Time; package body Babel.Base.Models is use type ADO.Objects.Object_Record_Access; use type ADO.Objects.Object_Ref; use type ADO.Objects.Object_Record; function Store_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => STORE_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Store_Key; function Store_Key (Id : in String) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => STORE_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Store_Key; function "=" (Left, Right : Store_Ref'Class) return Boolean is begin return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right); end "="; procedure Set_Field (Object : in out Store_Ref'Class; Impl : out Store_Access) is Result : ADO.Objects.Object_Record_Access; begin Object.Prepare_Modify (Result); Impl := Store_Impl (Result.all)'Access; end Set_Field; -- Internal method to allocate the Object_Record instance procedure Allocate (Object : in out Store_Ref) is Impl : Store_Access; begin Impl := new Store_Impl; ADO.Objects.Set_Object (Object, Impl.all'Access); end Allocate; -- ---------------------------------------- -- Data object: Store -- ---------------------------------------- procedure Set_Id (Object : in out Store_Ref; Value : in ADO.Identifier) is Impl : Store_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value); end Set_Id; function Get_Id (Object : in Store_Ref) return ADO.Identifier is Impl : constant Store_Access := Store_Impl (Object.Get_Object.all)'Access; begin return Impl.Get_Key_Value; end Get_Id; procedure Set_Name (Object : in out Store_Ref; Value : in String) is Impl : Store_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_String (Impl.all, 2, Impl.Name, Value); end Set_Name; procedure Set_Name (Object : in out Store_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String) is Impl : Store_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Unbounded_String (Impl.all, 2, Impl.Name, Value); end Set_Name; function Get_Name (Object : in Store_Ref) return String is begin return Ada.Strings.Unbounded.To_String (Object.Get_Name); end Get_Name; function Get_Name (Object : in Store_Ref) return Ada.Strings.Unbounded.Unbounded_String is Impl : constant Store_Access := Store_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Name; end Get_Name; procedure Set_Parameter (Object : in out Store_Ref; Value : in String) is Impl : Store_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_String (Impl.all, 3, Impl.Parameter, Value); end Set_Parameter; procedure Set_Parameter (Object : in out Store_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String) is Impl : Store_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Unbounded_String (Impl.all, 3, Impl.Parameter, Value); end Set_Parameter; function Get_Parameter (Object : in Store_Ref) return String is begin return Ada.Strings.Unbounded.To_String (Object.Get_Parameter); end Get_Parameter; function Get_Parameter (Object : in Store_Ref) return Ada.Strings.Unbounded.Unbounded_String is Impl : constant Store_Access := Store_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Parameter; end Get_Parameter; procedure Set_Server (Object : in out Store_Ref; Value : in String) is Impl : Store_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_String (Impl.all, 4, Impl.Server, Value); end Set_Server; procedure Set_Server (Object : in out Store_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String) is Impl : Store_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Unbounded_String (Impl.all, 4, Impl.Server, Value); end Set_Server; function Get_Server (Object : in Store_Ref) return String is begin return Ada.Strings.Unbounded.To_String (Object.Get_Server); end Get_Server; function Get_Server (Object : in Store_Ref) return Ada.Strings.Unbounded.Unbounded_String is Impl : constant Store_Access := Store_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Server; end Get_Server; -- Copy of the object. procedure Copy (Object : in Store_Ref; Into : in out Store_Ref) is Result : Store_Ref; begin if not Object.Is_Null then declare Impl : constant Store_Access := Store_Impl (Object.Get_Load_Object.all)'Access; Copy : constant Store_Access := new Store_Impl; begin ADO.Objects.Set_Object (Result, Copy.all'Access); Copy.Copy (Impl.all); Copy.Name := Impl.Name; Copy.Parameter := Impl.Parameter; Copy.Server := Impl.Server; end; end if; Into := Result; end Copy; procedure Find (Object : in out Store_Ref; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Impl : constant Store_Access := new Store_Impl; begin Impl.Find (Session, Query, Found); if Found then ADO.Objects.Set_Object (Object, Impl.all'Access); else ADO.Objects.Set_Object (Object, null); Destroy (Impl); end if; end Find; procedure Load (Object : in out Store_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier) is Impl : constant Store_Access := new Store_Impl; Found : Boolean; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); raise ADO.Objects.NOT_FOUND; end if; ADO.Objects.Set_Object (Object, Impl.all'Access); end Load; procedure Load (Object : in out Store_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier; Found : out Boolean) is Impl : constant Store_Access := new Store_Impl; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); else ADO.Objects.Set_Object (Object, Impl.all'Access); end if; end Load; procedure Save (Object : in out Store_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl = null then Impl := new Store_Impl; ADO.Objects.Set_Object (Object, Impl); end if; if not ADO.Objects.Is_Created (Impl.all) then Impl.Create (Session); else Impl.Save (Session); end if; end Save; procedure Delete (Object : in out Store_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl /= null then Impl.Delete (Session); end if; end Delete; -- -------------------- -- Free the object -- -------------------- procedure Destroy (Object : access Store_Impl) is type Store_Impl_Ptr is access all Store_Impl; procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Store_Impl, Store_Impl_Ptr); pragma Warnings (Off, "*redundant conversion*"); Ptr : Store_Impl_Ptr := Store_Impl (Object.all)'Access; pragma Warnings (On, "*redundant conversion*"); begin Unchecked_Free (Ptr); end Destroy; procedure Find (Object : in out Store_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, STORE_DEF'Access); begin Stmt.Execute; if Stmt.Has_Elements then Object.Load (Stmt, Session); Stmt.Next; Found := not Stmt.Has_Elements; else Found := False; end if; end Find; overriding procedure Load (Object : in out Store_Impl; Session : in out ADO.Sessions.Session'Class) is Found : Boolean; Query : ADO.SQL.Query; Id : constant ADO.Identifier := Object.Get_Key_Value; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Object.Find (Session, Query, Found); if not Found then raise ADO.Objects.NOT_FOUND; end if; end Load; procedure Save (Object : in out Store_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Update_Statement := Session.Create_Statement (STORE_DEF'Access); begin if Object.Is_Modified (1) then Stmt.Save_Field (Name => COL_0_1_NAME, -- id Value => Object.Get_Key); Object.Clear_Modified (1); end if; if Object.Is_Modified (2) then Stmt.Save_Field (Name => COL_1_1_NAME, -- name Value => Object.Name); Object.Clear_Modified (2); end if; if Object.Is_Modified (3) then Stmt.Save_Field (Name => COL_2_1_NAME, -- parameter Value => Object.Parameter); Object.Clear_Modified (3); end if; if Object.Is_Modified (4) then Stmt.Save_Field (Name => COL_3_1_NAME, -- server Value => Object.Server); Object.Clear_Modified (4); end if; if Stmt.Has_Save_Fields then Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); declare Result : Integer; begin Stmt.Execute (Result); if Result /= 1 then if Result /= 0 then raise ADO.Objects.UPDATE_ERROR; end if; end if; end; end if; end Save; procedure Create (Object : in out Store_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Query : ADO.Statements.Insert_Statement := Session.Create_Statement (STORE_DEF'Access); Result : Integer; begin Session.Allocate (Id => Object); Query.Save_Field (Name => COL_0_1_NAME, -- id Value => Object.Get_Key); Query.Save_Field (Name => COL_1_1_NAME, -- name Value => Object.Name); Query.Save_Field (Name => COL_2_1_NAME, -- parameter Value => Object.Parameter); Query.Save_Field (Name => COL_3_1_NAME, -- server Value => Object.Server); Query.Execute (Result); if Result /= 1 then raise ADO.Objects.INSERT_ERROR; end if; ADO.Objects.Set_Created (Object); end Create; procedure Delete (Object : in out Store_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Delete_Statement := Session.Create_Statement (STORE_DEF'Access); begin Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Execute; end Delete; function Get_Value (From : in Store_Ref; Name : in String) return Util.Beans.Objects.Object is Obj : constant ADO.Objects.Object_Record_Access := From.Get_Load_Object; Impl : access Store_Impl; begin if Obj = null then return Util.Beans.Objects.Null_Object; end if; Impl := Store_Impl (Obj.all)'Access; if Name = "id" then return ADO.Objects.To_Object (Impl.Get_Key); elsif Name = "name" then return Util.Beans.Objects.To_Object (Impl.Name); elsif Name = "parameter" then return Util.Beans.Objects.To_Object (Impl.Parameter); elsif Name = "server" then return Util.Beans.Objects.To_Object (Impl.Server); end if; return Util.Beans.Objects.Null_Object; end Get_Value; -- ------------------------------ -- Load the object from current iterator position -- ------------------------------ procedure Load (Object : in out Store_Impl; Stmt : in out ADO.Statements.Query_Statement'Class; Session : in out ADO.Sessions.Session'Class) is pragma Unreferenced (Session); begin Object.Set_Key_Value (Stmt.Get_Identifier (0)); Object.Name := Stmt.Get_Unbounded_String (1); Object.Parameter := Stmt.Get_Unbounded_String (2); Object.Server := Stmt.Get_Unbounded_String (3); ADO.Objects.Set_Created (Object); end Load; function Backup_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => BACKUP_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Backup_Key; function Backup_Key (Id : in String) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => BACKUP_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Backup_Key; function "=" (Left, Right : Backup_Ref'Class) return Boolean is begin return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right); end "="; procedure Set_Field (Object : in out Backup_Ref'Class; Impl : out Backup_Access) is Result : ADO.Objects.Object_Record_Access; begin Object.Prepare_Modify (Result); Impl := Backup_Impl (Result.all)'Access; end Set_Field; -- Internal method to allocate the Object_Record instance procedure Allocate (Object : in out Backup_Ref) is Impl : Backup_Access; begin Impl := new Backup_Impl; Impl.Create_Date := ADO.DEFAULT_TIME; ADO.Objects.Set_Object (Object, Impl.all'Access); end Allocate; -- ---------------------------------------- -- Data object: Backup -- ---------------------------------------- procedure Set_Id (Object : in out Backup_Ref; Value : in ADO.Identifier) is Impl : Backup_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value); end Set_Id; function Get_Id (Object : in Backup_Ref) return ADO.Identifier is Impl : constant Backup_Access := Backup_Impl (Object.Get_Object.all)'Access; begin return Impl.Get_Key_Value; end Get_Id; procedure Set_Create_Date (Object : in out Backup_Ref; Value : in Ada.Calendar.Time) is Impl : Backup_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Time (Impl.all, 2, Impl.Create_Date, Value); end Set_Create_Date; function Get_Create_Date (Object : in Backup_Ref) return Ada.Calendar.Time is Impl : constant Backup_Access := Backup_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Create_Date; end Get_Create_Date; procedure Set_Store (Object : in out Backup_Ref; Value : in Babel.Base.Models.Store_Ref'Class) is Impl : Backup_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Object (Impl.all, 3, Impl.Store, Value); end Set_Store; function Get_Store (Object : in Backup_Ref) return Babel.Base.Models.Store_Ref'Class is Impl : constant Backup_Access := Backup_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Store; end Get_Store; -- Copy of the object. procedure Copy (Object : in Backup_Ref; Into : in out Backup_Ref) is Result : Backup_Ref; begin if not Object.Is_Null then declare Impl : constant Backup_Access := Backup_Impl (Object.Get_Load_Object.all)'Access; Copy : constant Backup_Access := new Backup_Impl; begin ADO.Objects.Set_Object (Result, Copy.all'Access); Copy.Copy (Impl.all); Copy.Create_Date := Impl.Create_Date; Copy.Store := Impl.Store; end; end if; Into := Result; end Copy; procedure Find (Object : in out Backup_Ref; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Impl : constant Backup_Access := new Backup_Impl; begin Impl.Find (Session, Query, Found); if Found then ADO.Objects.Set_Object (Object, Impl.all'Access); else ADO.Objects.Set_Object (Object, null); Destroy (Impl); end if; end Find; procedure Load (Object : in out Backup_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier) is Impl : constant Backup_Access := new Backup_Impl; Found : Boolean; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); raise ADO.Objects.NOT_FOUND; end if; ADO.Objects.Set_Object (Object, Impl.all'Access); end Load; procedure Load (Object : in out Backup_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier; Found : out Boolean) is Impl : constant Backup_Access := new Backup_Impl; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); else ADO.Objects.Set_Object (Object, Impl.all'Access); end if; end Load; procedure Save (Object : in out Backup_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl = null then Impl := new Backup_Impl; ADO.Objects.Set_Object (Object, Impl); end if; if not ADO.Objects.Is_Created (Impl.all) then Impl.Create (Session); else Impl.Save (Session); end if; end Save; procedure Delete (Object : in out Backup_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl /= null then Impl.Delete (Session); end if; end Delete; -- -------------------- -- Free the object -- -------------------- procedure Destroy (Object : access Backup_Impl) is type Backup_Impl_Ptr is access all Backup_Impl; procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Backup_Impl, Backup_Impl_Ptr); pragma Warnings (Off, "*redundant conversion*"); Ptr : Backup_Impl_Ptr := Backup_Impl (Object.all)'Access; pragma Warnings (On, "*redundant conversion*"); begin Unchecked_Free (Ptr); end Destroy; procedure Find (Object : in out Backup_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, BACKUP_DEF'Access); begin Stmt.Execute; if Stmt.Has_Elements then Object.Load (Stmt, Session); Stmt.Next; Found := not Stmt.Has_Elements; else Found := False; end if; end Find; overriding procedure Load (Object : in out Backup_Impl; Session : in out ADO.Sessions.Session'Class) is Found : Boolean; Query : ADO.SQL.Query; Id : constant ADO.Identifier := Object.Get_Key_Value; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Object.Find (Session, Query, Found); if not Found then raise ADO.Objects.NOT_FOUND; end if; end Load; procedure Save (Object : in out Backup_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Update_Statement := Session.Create_Statement (BACKUP_DEF'Access); begin if Object.Is_Modified (1) then Stmt.Save_Field (Name => COL_0_2_NAME, -- id Value => Object.Get_Key); Object.Clear_Modified (1); end if; if Object.Is_Modified (2) then Stmt.Save_Field (Name => COL_1_2_NAME, -- create_date Value => Object.Create_Date); Object.Clear_Modified (2); end if; if Object.Is_Modified (3) then Stmt.Save_Field (Name => COL_2_2_NAME, -- store_id Value => Object.Store); Object.Clear_Modified (3); end if; if Stmt.Has_Save_Fields then Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); declare Result : Integer; begin Stmt.Execute (Result); if Result /= 1 then if Result /= 0 then raise ADO.Objects.UPDATE_ERROR; end if; end if; end; end if; end Save; procedure Create (Object : in out Backup_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Query : ADO.Statements.Insert_Statement := Session.Create_Statement (BACKUP_DEF'Access); Result : Integer; begin Session.Allocate (Id => Object); Query.Save_Field (Name => COL_0_2_NAME, -- id Value => Object.Get_Key); Query.Save_Field (Name => COL_1_2_NAME, -- create_date Value => Object.Create_Date); Query.Save_Field (Name => COL_2_2_NAME, -- store_id Value => Object.Store); Query.Execute (Result); if Result /= 1 then raise ADO.Objects.INSERT_ERROR; end if; ADO.Objects.Set_Created (Object); end Create; procedure Delete (Object : in out Backup_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Delete_Statement := Session.Create_Statement (BACKUP_DEF'Access); begin Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Execute; end Delete; function Get_Value (From : in Backup_Ref; Name : in String) return Util.Beans.Objects.Object is Obj : constant ADO.Objects.Object_Record_Access := From.Get_Load_Object; Impl : access Backup_Impl; begin if Obj = null then return Util.Beans.Objects.Null_Object; end if; Impl := Backup_Impl (Obj.all)'Access; if Name = "id" then return ADO.Objects.To_Object (Impl.Get_Key); elsif Name = "create_date" then return Util.Beans.Objects.Time.To_Object (Impl.Create_Date); end if; return Util.Beans.Objects.Null_Object; end Get_Value; -- ------------------------------ -- Load the object from current iterator position -- ------------------------------ procedure Load (Object : in out Backup_Impl; Stmt : in out ADO.Statements.Query_Statement'Class; Session : in out ADO.Sessions.Session'Class) is begin Object.Set_Key_Value (Stmt.Get_Identifier (0)); Object.Create_Date := Stmt.Get_Time (1); if not Stmt.Is_Null (2) then Object.Store.Set_Key_Value (Stmt.Get_Identifier (2), Session); end if; ADO.Objects.Set_Created (Object); end Load; function FileSet_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => FILESET_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end FileSet_Key; function FileSet_Key (Id : in String) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => FILESET_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end FileSet_Key; function "=" (Left, Right : FileSet_Ref'Class) return Boolean is begin return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right); end "="; procedure Set_Field (Object : in out Fileset_Ref'Class; Impl : out Fileset_Access) is Result : ADO.Objects.Object_Record_Access; begin Object.Prepare_Modify (Result); Impl := Fileset_Impl (Result.all)'Access; end Set_Field; -- Internal method to allocate the Object_Record instance procedure Allocate (Object : in out Fileset_Ref) is Impl : Fileset_Access; begin Impl := new Fileset_Impl; Impl.First_Id := ADO.NO_IDENTIFIER; Impl.Last_Id := ADO.NO_IDENTIFIER; ADO.Objects.Set_Object (Object, Impl.all'Access); end Allocate; -- ---------------------------------------- -- Data object: Fileset -- ---------------------------------------- procedure Set_Id (Object : in out Fileset_Ref; Value : in ADO.Identifier) is Impl : Fileset_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value); end Set_Id; function Get_Id (Object : in Fileset_Ref) return ADO.Identifier is Impl : constant Fileset_Access := Fileset_Impl (Object.Get_Object.all)'Access; begin return Impl.Get_Key_Value; end Get_Id; procedure Set_First_Id (Object : in out Fileset_Ref; Value : in ADO.Identifier) is Impl : Fileset_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Identifier (Impl.all, 2, Impl.First_Id, Value); end Set_First_Id; function Get_First_Id (Object : in Fileset_Ref) return ADO.Identifier is Impl : constant Fileset_Access := Fileset_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.First_Id; end Get_First_Id; procedure Set_Last_Id (Object : in out Fileset_Ref; Value : in ADO.Identifier) is Impl : Fileset_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Identifier (Impl.all, 3, Impl.Last_Id, Value); end Set_Last_Id; function Get_Last_Id (Object : in Fileset_Ref) return ADO.Identifier is Impl : constant Fileset_Access := Fileset_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Last_Id; end Get_Last_Id; procedure Set_Backup (Object : in out Fileset_Ref; Value : in Babel.Base.Models.Backup_Ref'Class) is Impl : Fileset_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Object (Impl.all, 4, Impl.Backup, Value); end Set_Backup; function Get_Backup (Object : in Fileset_Ref) return Babel.Base.Models.Backup_Ref'Class is Impl : constant Fileset_Access := Fileset_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Backup; end Get_Backup; -- Copy of the object. procedure Copy (Object : in Fileset_Ref; Into : in out Fileset_Ref) is Result : Fileset_Ref; begin if not Object.Is_Null then declare Impl : constant Fileset_Access := Fileset_Impl (Object.Get_Load_Object.all)'Access; Copy : constant Fileset_Access := new Fileset_Impl; begin ADO.Objects.Set_Object (Result, Copy.all'Access); Copy.Copy (Impl.all); Copy.First_Id := Impl.First_Id; Copy.Last_Id := Impl.Last_Id; Copy.Backup := Impl.Backup; end; end if; Into := Result; end Copy; procedure Find (Object : in out Fileset_Ref; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Impl : constant Fileset_Access := new Fileset_Impl; begin Impl.Find (Session, Query, Found); if Found then ADO.Objects.Set_Object (Object, Impl.all'Access); else ADO.Objects.Set_Object (Object, null); Destroy (Impl); end if; end Find; procedure Load (Object : in out Fileset_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier) is Impl : constant Fileset_Access := new Fileset_Impl; Found : Boolean; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); raise ADO.Objects.NOT_FOUND; end if; ADO.Objects.Set_Object (Object, Impl.all'Access); end Load; procedure Load (Object : in out Fileset_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier; Found : out Boolean) is Impl : constant Fileset_Access := new Fileset_Impl; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); else ADO.Objects.Set_Object (Object, Impl.all'Access); end if; end Load; procedure Save (Object : in out Fileset_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl = null then Impl := new Fileset_Impl; ADO.Objects.Set_Object (Object, Impl); end if; if not ADO.Objects.Is_Created (Impl.all) then Impl.Create (Session); else Impl.Save (Session); end if; end Save; procedure Delete (Object : in out Fileset_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl /= null then Impl.Delete (Session); end if; end Delete; -- -------------------- -- Free the object -- -------------------- procedure Destroy (Object : access Fileset_Impl) is type Fileset_Impl_Ptr is access all Fileset_Impl; procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Fileset_Impl, Fileset_Impl_Ptr); pragma Warnings (Off, "*redundant conversion*"); Ptr : Fileset_Impl_Ptr := Fileset_Impl (Object.all)'Access; pragma Warnings (On, "*redundant conversion*"); begin Unchecked_Free (Ptr); end Destroy; procedure Find (Object : in out Fileset_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, FILESET_DEF'Access); begin Stmt.Execute; if Stmt.Has_Elements then Object.Load (Stmt, Session); Stmt.Next; Found := not Stmt.Has_Elements; else Found := False; end if; end Find; overriding procedure Load (Object : in out Fileset_Impl; Session : in out ADO.Sessions.Session'Class) is Found : Boolean; Query : ADO.SQL.Query; Id : constant ADO.Identifier := Object.Get_Key_Value; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Object.Find (Session, Query, Found); if not Found then raise ADO.Objects.NOT_FOUND; end if; end Load; procedure Save (Object : in out Fileset_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Update_Statement := Session.Create_Statement (FILESET_DEF'Access); begin if Object.Is_Modified (1) then Stmt.Save_Field (Name => COL_0_3_NAME, -- id Value => Object.Get_Key); Object.Clear_Modified (1); end if; if Object.Is_Modified (2) then Stmt.Save_Field (Name => COL_1_3_NAME, -- first_id Value => Object.First_Id); Object.Clear_Modified (2); end if; if Object.Is_Modified (3) then Stmt.Save_Field (Name => COL_2_3_NAME, -- last_id Value => Object.Last_Id); Object.Clear_Modified (3); end if; if Object.Is_Modified (4) then Stmt.Save_Field (Name => COL_3_3_NAME, -- backup_id Value => Object.Backup); Object.Clear_Modified (4); end if; if Stmt.Has_Save_Fields then Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); declare Result : Integer; begin Stmt.Execute (Result); if Result /= 1 then if Result /= 0 then raise ADO.Objects.UPDATE_ERROR; end if; end if; end; end if; end Save; procedure Create (Object : in out Fileset_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Query : ADO.Statements.Insert_Statement := Session.Create_Statement (FILESET_DEF'Access); Result : Integer; begin Session.Allocate (Id => Object); Query.Save_Field (Name => COL_0_3_NAME, -- id Value => Object.Get_Key); Query.Save_Field (Name => COL_1_3_NAME, -- first_id Value => Object.First_Id); Query.Save_Field (Name => COL_2_3_NAME, -- last_id Value => Object.Last_Id); Query.Save_Field (Name => COL_3_3_NAME, -- backup_id Value => Object.Backup); Query.Execute (Result); if Result /= 1 then raise ADO.Objects.INSERT_ERROR; end if; ADO.Objects.Set_Created (Object); end Create; procedure Delete (Object : in out Fileset_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Delete_Statement := Session.Create_Statement (FILESET_DEF'Access); begin Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Execute; end Delete; function Get_Value (From : in Fileset_Ref; Name : in String) return Util.Beans.Objects.Object is Obj : constant ADO.Objects.Object_Record_Access := From.Get_Load_Object; Impl : access Fileset_Impl; begin if Obj = null then return Util.Beans.Objects.Null_Object; end if; Impl := Fileset_Impl (Obj.all)'Access; if Name = "id" then return ADO.Objects.To_Object (Impl.Get_Key); elsif Name = "first_id" then return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.First_Id)); elsif Name = "last_id" then return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Last_Id)); end if; return Util.Beans.Objects.Null_Object; end Get_Value; -- ------------------------------ -- Load the object from current iterator position -- ------------------------------ procedure Load (Object : in out Fileset_Impl; Stmt : in out ADO.Statements.Query_Statement'Class; Session : in out ADO.Sessions.Session'Class) is begin Object.Set_Key_Value (Stmt.Get_Identifier (0)); Object.First_Id := Stmt.Get_Identifier (1); Object.Last_Id := Stmt.Get_Identifier (2); if not Stmt.Is_Null (3) then Object.Backup.Set_Key_Value (Stmt.Get_Identifier (3), Session); end if; ADO.Objects.Set_Created (Object); end Load; function Path_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => PATH_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Path_Key; function Path_Key (Id : in String) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => PATH_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Path_Key; function "=" (Left, Right : Path_Ref'Class) return Boolean is begin return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right); end "="; procedure Set_Field (Object : in out Path_Ref'Class; Impl : out Path_Access) is Result : ADO.Objects.Object_Record_Access; begin Object.Prepare_Modify (Result); Impl := Path_Impl (Result.all)'Access; end Set_Field; -- Internal method to allocate the Object_Record instance procedure Allocate (Object : in out Path_Ref) is Impl : Path_Access; begin Impl := new Path_Impl; ADO.Objects.Set_Object (Object, Impl.all'Access); end Allocate; -- ---------------------------------------- -- Data object: Path -- ---------------------------------------- procedure Set_Id (Object : in out Path_Ref; Value : in ADO.Identifier) is Impl : Path_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value); end Set_Id; function Get_Id (Object : in Path_Ref) return ADO.Identifier is Impl : constant Path_Access := Path_Impl (Object.Get_Object.all)'Access; begin return Impl.Get_Key_Value; end Get_Id; procedure Set_Name (Object : in out Path_Ref; Value : in String) is Impl : Path_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_String (Impl.all, 2, Impl.Name, Value); end Set_Name; procedure Set_Name (Object : in out Path_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String) is Impl : Path_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Unbounded_String (Impl.all, 2, Impl.Name, Value); end Set_Name; function Get_Name (Object : in Path_Ref) return String is begin return Ada.Strings.Unbounded.To_String (Object.Get_Name); end Get_Name; function Get_Name (Object : in Path_Ref) return Ada.Strings.Unbounded.Unbounded_String is Impl : constant Path_Access := Path_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Name; end Get_Name; procedure Set_Store (Object : in out Path_Ref; Value : in Babel.Base.Models.Store_Ref'Class) is Impl : Path_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Object (Impl.all, 3, Impl.Store, Value); end Set_Store; function Get_Store (Object : in Path_Ref) return Babel.Base.Models.Store_Ref'Class is Impl : constant Path_Access := Path_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Store; end Get_Store; -- Copy of the object. procedure Copy (Object : in Path_Ref; Into : in out Path_Ref) is Result : Path_Ref; begin if not Object.Is_Null then declare Impl : constant Path_Access := Path_Impl (Object.Get_Load_Object.all)'Access; Copy : constant Path_Access := new Path_Impl; begin ADO.Objects.Set_Object (Result, Copy.all'Access); Copy.Copy (Impl.all); Copy.Name := Impl.Name; Copy.Store := Impl.Store; end; end if; Into := Result; end Copy; procedure Find (Object : in out Path_Ref; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Impl : constant Path_Access := new Path_Impl; begin Impl.Find (Session, Query, Found); if Found then ADO.Objects.Set_Object (Object, Impl.all'Access); else ADO.Objects.Set_Object (Object, null); Destroy (Impl); end if; end Find; procedure Load (Object : in out Path_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier) is Impl : constant Path_Access := new Path_Impl; Found : Boolean; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); raise ADO.Objects.NOT_FOUND; end if; ADO.Objects.Set_Object (Object, Impl.all'Access); end Load; procedure Load (Object : in out Path_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier; Found : out Boolean) is Impl : constant Path_Access := new Path_Impl; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); else ADO.Objects.Set_Object (Object, Impl.all'Access); end if; end Load; procedure Save (Object : in out Path_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl = null then Impl := new Path_Impl; ADO.Objects.Set_Object (Object, Impl); end if; if not ADO.Objects.Is_Created (Impl.all) then Impl.Create (Session); else Impl.Save (Session); end if; end Save; procedure Delete (Object : in out Path_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl /= null then Impl.Delete (Session); end if; end Delete; -- -------------------- -- Free the object -- -------------------- procedure Destroy (Object : access Path_Impl) is type Path_Impl_Ptr is access all Path_Impl; procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Path_Impl, Path_Impl_Ptr); pragma Warnings (Off, "*redundant conversion*"); Ptr : Path_Impl_Ptr := Path_Impl (Object.all)'Access; pragma Warnings (On, "*redundant conversion*"); begin Unchecked_Free (Ptr); end Destroy; procedure Find (Object : in out Path_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, PATH_DEF'Access); begin Stmt.Execute; if Stmt.Has_Elements then Object.Load (Stmt, Session); Stmt.Next; Found := not Stmt.Has_Elements; else Found := False; end if; end Find; overriding procedure Load (Object : in out Path_Impl; Session : in out ADO.Sessions.Session'Class) is Found : Boolean; Query : ADO.SQL.Query; Id : constant ADO.Identifier := Object.Get_Key_Value; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Object.Find (Session, Query, Found); if not Found then raise ADO.Objects.NOT_FOUND; end if; end Load; procedure Save (Object : in out Path_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Update_Statement := Session.Create_Statement (PATH_DEF'Access); begin if Object.Is_Modified (1) then Stmt.Save_Field (Name => COL_0_4_NAME, -- id Value => Object.Get_Key); Object.Clear_Modified (1); end if; if Object.Is_Modified (2) then Stmt.Save_Field (Name => COL_1_4_NAME, -- name Value => Object.Name); Object.Clear_Modified (2); end if; if Object.Is_Modified (3) then Stmt.Save_Field (Name => COL_2_4_NAME, -- store_id Value => Object.Store); Object.Clear_Modified (3); end if; if Stmt.Has_Save_Fields then Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); declare Result : Integer; begin Stmt.Execute (Result); if Result /= 1 then if Result /= 0 then raise ADO.Objects.UPDATE_ERROR; end if; end if; end; end if; end Save; procedure Create (Object : in out Path_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Query : ADO.Statements.Insert_Statement := Session.Create_Statement (PATH_DEF'Access); Result : Integer; begin Session.Allocate (Id => Object); Query.Save_Field (Name => COL_0_4_NAME, -- id Value => Object.Get_Key); Query.Save_Field (Name => COL_1_4_NAME, -- name Value => Object.Name); Query.Save_Field (Name => COL_2_4_NAME, -- store_id Value => Object.Store); Query.Execute (Result); if Result /= 1 then raise ADO.Objects.INSERT_ERROR; end if; ADO.Objects.Set_Created (Object); end Create; procedure Delete (Object : in out Path_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Delete_Statement := Session.Create_Statement (PATH_DEF'Access); begin Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Execute; end Delete; function Get_Value (From : in Path_Ref; Name : in String) return Util.Beans.Objects.Object is Obj : constant ADO.Objects.Object_Record_Access := From.Get_Load_Object; Impl : access Path_Impl; begin if Obj = null then return Util.Beans.Objects.Null_Object; end if; Impl := Path_Impl (Obj.all)'Access; if Name = "id" then return ADO.Objects.To_Object (Impl.Get_Key); elsif Name = "name" then return Util.Beans.Objects.To_Object (Impl.Name); end if; return Util.Beans.Objects.Null_Object; end Get_Value; -- ------------------------------ -- Load the object from current iterator position -- ------------------------------ procedure Load (Object : in out Path_Impl; Stmt : in out ADO.Statements.Query_Statement'Class; Session : in out ADO.Sessions.Session'Class) is begin Object.Set_Key_Value (Stmt.Get_Identifier (0)); Object.Name := Stmt.Get_Unbounded_String (1); if not Stmt.Is_Null (2) then Object.Store.Set_Key_Value (Stmt.Get_Identifier (2), Session); end if; ADO.Objects.Set_Created (Object); end Load; function File_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => FILE_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end File_Key; function File_Key (Id : in String) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => FILE_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end File_Key; function "=" (Left, Right : File_Ref'Class) return Boolean is begin return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right); end "="; procedure Set_Field (Object : in out File_Ref'Class; Impl : out File_Access) is Result : ADO.Objects.Object_Record_Access; begin Object.Prepare_Modify (Result); Impl := File_Impl (Result.all)'Access; end Set_Field; -- Internal method to allocate the Object_Record instance procedure Allocate (Object : in out File_Ref) is Impl : File_Access; begin Impl := new File_Impl; Impl.Size := 0; Impl.Date := ADO.DEFAULT_TIME; ADO.Objects.Set_Object (Object, Impl.all'Access); end Allocate; -- ---------------------------------------- -- Data object: File -- ---------------------------------------- procedure Set_Id (Object : in out File_Ref; Value : in ADO.Identifier) is Impl : File_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value); end Set_Id; function Get_Id (Object : in File_Ref) return ADO.Identifier is Impl : constant File_Access := File_Impl (Object.Get_Object.all)'Access; begin return Impl.Get_Key_Value; end Get_Id; procedure Set_Size (Object : in out File_Ref; Value : in Integer) is Impl : File_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Integer (Impl.all, 2, Impl.Size, Value); end Set_Size; function Get_Size (Object : in File_Ref) return Integer is Impl : constant File_Access := File_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Size; end Get_Size; procedure Set_Date (Object : in out File_Ref; Value : in Ada.Calendar.Time) is Impl : File_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Time (Impl.all, 3, Impl.Date, Value); end Set_Date; function Get_Date (Object : in File_Ref) return Ada.Calendar.Time is Impl : constant File_Access := File_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Date; end Get_Date; procedure Set_Sha1 (Object : in out File_Ref; Value : in ADO.Blob_Ref) is Impl : File_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Blob (Impl.all, 4, Impl.Sha1, Value); end Set_Sha1; function Get_Sha1 (Object : in File_Ref) return ADO.Blob_Ref is Impl : constant File_Access := File_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Sha1; end Get_Sha1; procedure Set_Directory (Object : in out File_Ref; Value : in Babel.Base.Models.Path_Ref'Class) is Impl : File_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Object (Impl.all, 5, Impl.Directory, Value); end Set_Directory; function Get_Directory (Object : in File_Ref) return Babel.Base.Models.Path_Ref'Class is Impl : constant File_Access := File_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Directory; end Get_Directory; procedure Set_Name (Object : in out File_Ref; Value : in Babel.Base.Models.Path_Ref'Class) is Impl : File_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Object (Impl.all, 6, Impl.Name, Value); end Set_Name; function Get_Name (Object : in File_Ref) return Babel.Base.Models.Path_Ref'Class is Impl : constant File_Access := File_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Name; end Get_Name; -- Copy of the object. procedure Copy (Object : in File_Ref; Into : in out File_Ref) is Result : File_Ref; begin if not Object.Is_Null then declare Impl : constant File_Access := File_Impl (Object.Get_Load_Object.all)'Access; Copy : constant File_Access := new File_Impl; begin ADO.Objects.Set_Object (Result, Copy.all'Access); Copy.Copy (Impl.all); Copy.Size := Impl.Size; Copy.Date := Impl.Date; Copy.Sha1 := Impl.Sha1; Copy.Directory := Impl.Directory; Copy.Name := Impl.Name; end; end if; Into := Result; end Copy; procedure Find (Object : in out File_Ref; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Impl : constant File_Access := new File_Impl; begin Impl.Find (Session, Query, Found); if Found then ADO.Objects.Set_Object (Object, Impl.all'Access); else ADO.Objects.Set_Object (Object, null); Destroy (Impl); end if; end Find; procedure Load (Object : in out File_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier) is Impl : constant File_Access := new File_Impl; Found : Boolean; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); raise ADO.Objects.NOT_FOUND; end if; ADO.Objects.Set_Object (Object, Impl.all'Access); end Load; procedure Load (Object : in out File_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier; Found : out Boolean) is Impl : constant File_Access := new File_Impl; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); else ADO.Objects.Set_Object (Object, Impl.all'Access); end if; end Load; procedure Save (Object : in out File_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl = null then Impl := new File_Impl; ADO.Objects.Set_Object (Object, Impl); end if; if not ADO.Objects.Is_Created (Impl.all) then Impl.Create (Session); else Impl.Save (Session); end if; end Save; procedure Delete (Object : in out File_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl /= null then Impl.Delete (Session); end if; end Delete; -- -------------------- -- Free the object -- -------------------- procedure Destroy (Object : access File_Impl) is type File_Impl_Ptr is access all File_Impl; procedure Unchecked_Free is new Ada.Unchecked_Deallocation (File_Impl, File_Impl_Ptr); pragma Warnings (Off, "*redundant conversion*"); Ptr : File_Impl_Ptr := File_Impl (Object.all)'Access; pragma Warnings (On, "*redundant conversion*"); begin Unchecked_Free (Ptr); end Destroy; procedure Find (Object : in out File_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, FILE_DEF'Access); begin Stmt.Execute; if Stmt.Has_Elements then Object.Load (Stmt, Session); Stmt.Next; Found := not Stmt.Has_Elements; else Found := False; end if; end Find; overriding procedure Load (Object : in out File_Impl; Session : in out ADO.Sessions.Session'Class) is Found : Boolean; Query : ADO.SQL.Query; Id : constant ADO.Identifier := Object.Get_Key_Value; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Object.Find (Session, Query, Found); if not Found then raise ADO.Objects.NOT_FOUND; end if; end Load; procedure Save (Object : in out File_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Update_Statement := Session.Create_Statement (FILE_DEF'Access); begin if Object.Is_Modified (1) then Stmt.Save_Field (Name => COL_0_5_NAME, -- id Value => Object.Get_Key); Object.Clear_Modified (1); end if; if Object.Is_Modified (2) then Stmt.Save_Field (Name => COL_1_5_NAME, -- size Value => Object.Size); Object.Clear_Modified (2); end if; if Object.Is_Modified (3) then Stmt.Save_Field (Name => COL_2_5_NAME, -- date Value => Object.Date); Object.Clear_Modified (3); end if; if Object.Is_Modified (4) then Stmt.Save_Field (Name => COL_3_5_NAME, -- sha1 Value => Object.Sha1); Object.Clear_Modified (4); end if; if Object.Is_Modified (5) then Stmt.Save_Field (Name => COL_4_5_NAME, -- directory_id Value => Object.Directory); Object.Clear_Modified (5); end if; if Object.Is_Modified (6) then Stmt.Save_Field (Name => COL_5_5_NAME, -- name_id Value => Object.Name); Object.Clear_Modified (6); end if; if Stmt.Has_Save_Fields then Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); declare Result : Integer; begin Stmt.Execute (Result); if Result /= 1 then if Result /= 0 then raise ADO.Objects.UPDATE_ERROR; end if; end if; end; end if; end Save; procedure Create (Object : in out File_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Query : ADO.Statements.Insert_Statement := Session.Create_Statement (FILE_DEF'Access); Result : Integer; begin Session.Allocate (Id => Object); Query.Save_Field (Name => COL_0_5_NAME, -- id Value => Object.Get_Key); Query.Save_Field (Name => COL_1_5_NAME, -- size Value => Object.Size); Query.Save_Field (Name => COL_2_5_NAME, -- date Value => Object.Date); Query.Save_Field (Name => COL_3_5_NAME, -- sha1 Value => Object.Sha1); Query.Save_Field (Name => COL_4_5_NAME, -- directory_id Value => Object.Directory); Query.Save_Field (Name => COL_5_5_NAME, -- name_id Value => Object.Name); Query.Execute (Result); if Result /= 1 then raise ADO.Objects.INSERT_ERROR; end if; ADO.Objects.Set_Created (Object); end Create; procedure Delete (Object : in out File_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Delete_Statement := Session.Create_Statement (FILE_DEF'Access); begin Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Execute; end Delete; function Get_Value (From : in File_Ref; Name : in String) return Util.Beans.Objects.Object is Obj : constant ADO.Objects.Object_Record_Access := From.Get_Load_Object; Impl : access File_Impl; begin if Obj = null then return Util.Beans.Objects.Null_Object; end if; Impl := File_Impl (Obj.all)'Access; if Name = "id" then return ADO.Objects.To_Object (Impl.Get_Key); elsif Name = "size" then return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Size)); elsif Name = "date" then return Util.Beans.Objects.Time.To_Object (Impl.Date); end if; return Util.Beans.Objects.Null_Object; end Get_Value; -- ------------------------------ -- Load the object from current iterator position -- ------------------------------ procedure Load (Object : in out File_Impl; Stmt : in out ADO.Statements.Query_Statement'Class; Session : in out ADO.Sessions.Session'Class) is begin Object.Set_Key_Value (Stmt.Get_Identifier (0)); Object.Size := Stmt.Get_Integer (1); Object.Date := Stmt.Get_Time (2); Object.Sha1 := Stmt.Get_Blob (3); if not Stmt.Is_Null (4) then Object.Directory.Set_Key_Value (Stmt.Get_Identifier (4), Session); end if; if not Stmt.Is_Null (5) then Object.Name.Set_Key_Value (Stmt.Get_Identifier (5), Session); end if; ADO.Objects.Set_Created (Object); end Load; end Babel.Base.Models;
onox/orka
Ada
1,511
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 Orka.SIMD.SSE2.Doubles; package Orka.SIMD.SSE4_1.Doubles.Math is pragma Pure; use Orka.SIMD.SSE2.Doubles; function Round (Elements : m128d; Rounding : Integer_32) return m128d with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_roundpd"; function Round_Nearest_Integer (Elements : m128d) return m128d is (Round (Elements, 0)); -- Round each element to the nearest integer function Floor (Elements : m128d) return m128d is (Round (Elements, 1)); -- Round each element down to an integer value function Ceil (Elements : m128d) return m128d is (Round (Elements, 2)); -- Round each element up to an integer value function Round_Truncate (Elements : m128d) return m128d is (Round (Elements, 3)); -- Round each element to zero end Orka.SIMD.SSE4_1.Doubles.Math;
pvrego/adaino
Ada
1,222
ads
-- ============================================================================= -- Package AVR.SPI -- -- Handles the SPI. -- ============================================================================= package AVR.SPI is type SPI_Control_Register_Type is record SPR0 : Boolean; SPR1 : Boolean; CPHA : Boolean; CPOL : Boolean; MSTR : Boolean; DORD : Boolean; SPE : Boolean; SPIE : Boolean; end record; pragma Pack (SPI_Control_Register_Type); for SPI_Control_Register_Type'Size use BYTE_SIZE; type SPI_Status_Register_Type is record SPI2X : Boolean; Spare : Spare_Type (0 .. 4); WCOL : Boolean; SPIF : Boolean; end record; pragma Pack (SPI_Status_Register_Type); for SPI_Status_Register_Type'Size use BYTE_SIZE; type SPI_Data_Register_Type is new Byte_Type; Reg_SPCR : SPI_Control_Register_Type; for Reg_SPCR'Address use System'To_Address (16#4C#); Reg_SPSR : SPI_Status_Register_Type; for Reg_SPSR'Address use System'To_Address (16#4D#); Reg_SPDR : SPI_Data_Register_Type; for Reg_SPDR'Address use System'To_Address (16#4E#); end AVR.SPI;
michael-hardeman/contacts_app
Ada
2,437
adb
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../../License.txt with Ada.Characters.Handling; package body AdaBase.Results.Sets is package ACH renames Ada.Characters.Handling; -------------- -- column -- -------------- function column (row : Datarow; index : Positive) return ARF.Std_Field is begin if index > Natural (row.crate.Length) then raise COLUMN_DOES_NOT_EXIST with "Column" & index'Img & " requested, but only" & row.crate.Length'Img & " columns present."; end if; return row.crate.Element (Index => index); end column; -------------- -- column -- -------------- function column (row : Datarow; heading : String) return ARF.Std_Field is use type heading_map.Cursor; cursor : heading_map.Cursor; index : Positive; headup : String := ACH.To_Upper (heading); begin cursor := row.map.Find (Key => headup); if cursor = heading_map.No_Element then raise COLUMN_DOES_NOT_EXIST with "There is no column named '" & headup & "'."; end if; index := heading_map.Element (Position => cursor); return row.crate.Element (Index => index); end column; ------------- -- count -- ------------- function count (row : Datarow) return Natural is begin return Natural (row.crate.Length); end count; ---------------------- -- data_exhausted -- ---------------------- function data_exhausted (row : Datarow) return Boolean is begin return row.done; end data_exhausted; -------------------- -- Same_Strings -- -------------------- function Same_Strings (S, T : String) return Boolean is begin return S = T; end Same_Strings; ------------ -- push -- ------------ procedure push (row : out Datarow; heading : String; field : ARF.Std_Field; last_field : Boolean := False) is begin if row.locked then raise CONSTRUCTOR_DO_NOT_USE with "The push method is not for you."; end if; if last_field then row.locked := True; end if; row.crate.Append (New_Item => field); row.map.Insert (Key => ACH.To_Upper (heading), New_Item => row.crate.Last_Index); end push; end AdaBase.Results.Sets;
reznikmm/matreshka
Ada
4,025
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.Dr3d_Ambient_Color_Attributes; package Matreshka.ODF_Dr3d.Ambient_Color_Attributes is type Dr3d_Ambient_Color_Attribute_Node is new Matreshka.ODF_Dr3d.Abstract_Dr3d_Attribute_Node and ODF.DOM.Dr3d_Ambient_Color_Attributes.ODF_Dr3d_Ambient_Color_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Dr3d_Ambient_Color_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Dr3d_Ambient_Color_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Dr3d.Ambient_Color_Attributes;
zhmu/ananas
Ada
13,065
ads
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- ADA.CONTAINERS.BOUNDED_DOUBLY_LINKED_LISTS -- -- -- -- S p e c -- -- -- -- Copyright (C) 2004-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/>. -- -- -- -- This unit was originally developed by Matthew J Heaney. -- ------------------------------------------------------------------------------ with Ada.Iterator_Interfaces; with Ada.Containers.Helpers; private with Ada.Streams; private with Ada.Finalization; private with Ada.Strings.Text_Buffers; generic type Element_Type is private; with function "=" (Left, Right : Element_Type) return Boolean is <>; package Ada.Containers.Bounded_Doubly_Linked_Lists with SPARK_Mode => Off is pragma Annotate (CodePeer, Skip_Analysis); pragma Pure; pragma Remote_Types; type List (Capacity : Count_Type) is tagged private with Constant_Indexing => Constant_Reference, Variable_Indexing => Reference, Default_Iterator => Iterate, Iterator_Element => Element_Type, Aggregate => (Empty => Empty, Add_Unnamed => Append), Preelaborable_Initialization => Element_Type'Preelaborable_Initialization; type Cursor is private with Preelaborable_Initialization; Empty_List : constant List; No_Element : constant Cursor; function Empty (Capacity : Count_Type := 10) return List; function Has_Element (Position : Cursor) return Boolean; package List_Iterator_Interfaces is new Ada.Iterator_Interfaces (Cursor, Has_Element); function "=" (Left, Right : List) return Boolean; function Length (Container : List) return Count_Type; function Is_Empty (Container : List) return Boolean; procedure Clear (Container : in out List); function Element (Position : Cursor) return Element_Type; procedure Replace_Element (Container : in out List; Position : Cursor; New_Item : Element_Type); procedure Query_Element (Position : Cursor; Process : not null access procedure (Element : Element_Type)); procedure Update_Element (Container : in out List; Position : Cursor; Process : not null access procedure (Element : in out Element_Type)); type Constant_Reference_Type (Element : not null access constant Element_Type) is private with Implicit_Dereference => Element; type Reference_Type (Element : not null access Element_Type) is private with Implicit_Dereference => Element; function Constant_Reference (Container : aliased List; Position : Cursor) return Constant_Reference_Type; function Reference (Container : aliased in out List; Position : Cursor) return Reference_Type; procedure Assign (Target : in out List; Source : List); function Copy (Source : List; Capacity : Count_Type := 0) return List; procedure Move (Target : in out List; Source : in out List); procedure Insert (Container : in out List; Before : Cursor; New_Item : Element_Type; Count : Count_Type := 1); procedure Insert (Container : in out List; Before : Cursor; New_Item : Element_Type; Position : out Cursor; Count : Count_Type := 1); procedure Insert (Container : in out List; Before : Cursor; Position : out Cursor; Count : Count_Type := 1); procedure Prepend (Container : in out List; New_Item : Element_Type; Count : Count_Type := 1); procedure Append (Container : in out List; New_Item : Element_Type; Count : Count_Type); procedure Append (Container : in out List; New_Item : Element_Type); procedure Delete (Container : in out List; Position : in out Cursor; Count : Count_Type := 1); procedure Delete_First (Container : in out List; Count : Count_Type := 1); procedure Delete_Last (Container : in out List; Count : Count_Type := 1); procedure Reverse_Elements (Container : in out List); function Iterate (Container : List) return List_Iterator_Interfaces.Reversible_Iterator'class; function Iterate (Container : List; Start : Cursor) return List_Iterator_Interfaces.Reversible_Iterator'class; procedure Swap (Container : in out List; I, J : Cursor); procedure Swap_Links (Container : in out List; I, J : Cursor); procedure Splice (Target : in out List; Before : Cursor; Source : in out List); procedure Splice (Target : in out List; Before : Cursor; Source : in out List; Position : in out Cursor); procedure Splice (Container : in out List; Before : Cursor; Position : Cursor); function First (Container : List) return Cursor; function First_Element (Container : List) return Element_Type; function Last (Container : List) return Cursor; function Last_Element (Container : List) return Element_Type; function Next (Position : Cursor) return Cursor; procedure Next (Position : in out Cursor); function Previous (Position : Cursor) return Cursor; procedure Previous (Position : in out Cursor); function Find (Container : List; Item : Element_Type; Position : Cursor := No_Element) return Cursor; function Reverse_Find (Container : List; Item : Element_Type; Position : Cursor := No_Element) return Cursor; function Contains (Container : List; Item : Element_Type) return Boolean; procedure Iterate (Container : List; Process : not null access procedure (Position : Cursor)); procedure Reverse_Iterate (Container : List; Process : not null access procedure (Position : Cursor)); generic with function "<" (Left, Right : Element_Type) return Boolean is <>; package Generic_Sorting is function Is_Sorted (Container : List) return Boolean; procedure Sort (Container : in out List); procedure Merge (Target, Source : in out List); end Generic_Sorting; private pragma Inline (Next); pragma Inline (Previous); use Ada.Containers.Helpers; package Implementation is new Generic_Implementation; use Implementation; use Ada.Streams; use Ada.Finalization; type Node_Type is record Prev : Count_Type'Base; Next : Count_Type; Element : aliased Element_Type; end record; type Node_Array is array (Count_Type range <>) of Node_Type; type List (Capacity : Count_Type) is tagged record Nodes : Node_Array (1 .. Capacity); Free : Count_Type'Base := -1; First : Count_Type := 0; Last : Count_Type := 0; Length : Count_Type := 0; TC : aliased Tamper_Counts; end record with Put_Image => Put_Image; procedure Put_Image (S : in out Ada.Strings.Text_Buffers.Root_Buffer_Type'Class; V : List); procedure Read (Stream : not null access Root_Stream_Type'Class; Item : out List); for List'Read use Read; procedure Write (Stream : not null access Root_Stream_Type'Class; Item : List); for List'Write use Write; type List_Access is access all List; for List_Access'Storage_Size use 0; type Cursor is record Container : List_Access; Node : Count_Type := 0; end record; procedure Read (Stream : not null access Root_Stream_Type'Class; Item : out Cursor); for Cursor'Read use Read; procedure Write (Stream : not null access Root_Stream_Type'Class; Item : Cursor); for Cursor'Write use Write; subtype Reference_Control_Type is Implementation.Reference_Control_Type; -- It is necessary to rename this here, so that the compiler can find it type Constant_Reference_Type (Element : not null access constant Element_Type) is record Control : Reference_Control_Type := raise Program_Error with "uninitialized reference"; -- The RM says, "The default initialization of an object of -- type Constant_Reference_Type or Reference_Type propagates -- Program_Error." end record; procedure Read (Stream : not null access Root_Stream_Type'Class; Item : out Constant_Reference_Type); for Constant_Reference_Type'Read use Read; procedure Write (Stream : not null access Root_Stream_Type'Class; Item : Constant_Reference_Type); for Constant_Reference_Type'Write use Write; type Reference_Type (Element : not null access Element_Type) is record Control : Reference_Control_Type := raise Program_Error with "uninitialized reference"; -- The RM says, "The default initialization of an object of -- type Constant_Reference_Type or Reference_Type propagates -- Program_Error." end record; procedure Write (Stream : not null access Root_Stream_Type'Class; Item : Reference_Type); for Reference_Type'Write use Write; procedure Read (Stream : not null access Root_Stream_Type'Class; Item : out Reference_Type); for Reference_Type'Read use Read; -- Three operations are used to optimize in the expansion of "for ... of" -- loops: the Next(Cursor) procedure in the visible part, and the following -- Pseudo_Reference and Get_Element_Access functions. See Exp_Ch5 for -- details. function Pseudo_Reference (Container : aliased List'Class) return Reference_Control_Type; pragma Inline (Pseudo_Reference); -- Creates an object of type Reference_Control_Type pointing to the -- container, and increments the Lock. Finalization of this object will -- decrement the Lock. type Element_Access is access all Element_Type with Storage_Size => 0; function Get_Element_Access (Position : Cursor) return not null Element_Access; -- Returns a pointer to the element designated by Position. Empty_List : constant List := (Capacity => 0, others => <>); No_Element : constant Cursor := Cursor'(null, 0); type Iterator is new Limited_Controlled and List_Iterator_Interfaces.Reversible_Iterator with record Container : List_Access; Node : Count_Type; end record with Disable_Controlled => not T_Check; overriding procedure Finalize (Object : in out Iterator); overriding function First (Object : Iterator) return Cursor; overriding function Last (Object : Iterator) return Cursor; overriding function Next (Object : Iterator; Position : Cursor) return Cursor; overriding function Previous (Object : Iterator; Position : Cursor) return Cursor; end Ada.Containers.Bounded_Doubly_Linked_Lists;
reznikmm/matreshka
Ada
4,672
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_Table.Source_Field_Name_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Table_Source_Field_Name_Attribute_Node is begin return Self : Table_Source_Field_Name_Attribute_Node do Matreshka.ODF_Table.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Table_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Table_Source_Field_Name_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Source_Field_Name_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Table_URI, Matreshka.ODF_String_Constants.Source_Field_Name_Attribute, Table_Source_Field_Name_Attribute_Node'Tag); end Matreshka.ODF_Table.Source_Field_Name_Attributes;
onox/orka
Ada
15,509
adb
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2016 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. package body Orka.Scenes.Generic_Scene_Trees is function To_Cursor (Object : Tree; Name : String) return Cursor is use type SU.Unbounded_String; begin for Level_Index in Object.Levels.First_Index .. Object.Levels.Last_Index loop declare Node_Level : Level renames Object.Levels (Level_Index); begin for Node_Index in Node_Level.Nodes.First_Index .. Node_Level.Nodes.Last_Index loop declare Current_Node : Node renames Node_Level.Nodes (Node_Index); begin if Current_Node.Name = Name then return Cursor'(Level => Level_Index, Offset => Node_Index); end if; end; end loop; end; end loop; raise Unknown_Node_Error; end To_Cursor; procedure Update_Tree (Object : in out Tree) is begin Object.Update_Tree (Transforms.Identity_Matrix); end Update_Tree; procedure Update_Tree (Object : in out Tree; Root_Transform : Transforms.Matrix4) is use Transforms; Root_Local : constant Matrix4 := Object.Levels (Object.Levels.First_Index).Local_Transforms.Element (1); Root_Visible : constant Boolean := Object.Levels (Object.Levels.First_Index).Local_Visibilities.Element (1); begin -- Copy local data of root node to its world data Object.Levels (Object.Levels.First_Index).World_Transforms.Replace_Element (1, Root_Transform * Root_Local); Object.Levels (Object.Levels.First_Index).World_Visibilities.Replace_Element (1, Root_Visible); for Level_Index in Object.Levels.First_Index .. Object.Levels.Last_Index - 1 loop declare Current_Level : Level renames Object.Levels (Level_Index); Parent_Level_W : Matrix_Vectors.Vector renames Current_Level.World_Transforms; Parent_Level_V : Boolean_Vectors.Vector renames Current_Level.World_Visibilities; Parent_Level_N : Node_Vectors.Vector renames Current_Level.Nodes; procedure Update (Child_Level : in out Level) is begin for Parent_Index in Parent_Level_N.First_Index .. Parent_Level_N.Last_Index loop declare Parent_Transform : Matrix4 renames Parent_Level_W.Element (Parent_Index); Parent_Visible : Boolean renames Parent_Level_V.Element (Parent_Index); Parent : Node renames Parent_Level_N.Element (Parent_Index); begin for Node_Index in Parent.Offset .. Parent.Offset + Parent.Count - 1 loop declare Local_Transform : Matrix4 renames Child_Level.Local_Transforms.Element (Node_Index); Local_Visible : Boolean renames Child_Level.Local_Visibilities.Element (Node_Index); begin Child_Level.World_Transforms.Replace_Element (Node_Index, Parent_Transform * Local_Transform); Child_Level.World_Visibilities.Replace_Element (Node_Index, Parent_Visible and then Local_Visible); end; end loop; end; end loop; end Update; begin Object.Levels.Update_Element (Level_Index + 1, Update'Access); end; end loop; end Update_Tree; procedure Set_Visibility (Object : in out Tree; Node : Cursor; Visible : Boolean) is Node_Level : Level renames Object.Levels (Node.Level); begin Node_Level.Local_Visibilities.Replace_Element (Node.Offset, Visible); end Set_Visibility; function Visibility (Object : Tree; Node : Cursor) return Boolean is Node_Level : Level renames Object.Levels (Node.Level); begin return Node_Level.World_Visibilities.Element (Node.Offset); end Visibility; procedure Set_Local_Transform (Object : in out Tree; Node : Cursor; Transform : Transforms.Matrix4) is Node_Level : Level renames Object.Levels (Node.Level); begin Node_Level.Local_Transforms.Replace_Element (Node.Offset, Transform); end Set_Local_Transform; function World_Transform (Object : Tree; Node : Cursor) return Transforms.Matrix4 is Node_Level : Level renames Object.Levels (Node.Level); begin return Node_Level.World_Transforms.Element (Node.Offset); end World_Transform; function Root_Name (Object : Tree) return String is (SU.To_String (Object.Levels (Object.Levels.First_Index).Nodes.Element (1).Name)); function Create_Tree (Name : String) return Tree is begin return Object : Tree do Object.Levels.Append (Level'(others => <>)); declare Root_Level : Level renames Object.Levels (Object.Levels.First_Index); begin Root_Level.Nodes.Append (Node'(Name => SU.To_Unbounded_String (Name), Offset => 1, Count => 0)); Root_Level.Local_Transforms.Append (Transforms.Identity_Matrix); Root_Level.World_Transforms.Append (Transforms.Identity_Matrix); Root_Level.Local_Visibilities.Append (True); Root_Level.World_Visibilities.Append (True); end; end return; end Create_Tree; procedure Add_Node (Object : in out Tree; Name, Parent : String) is begin Object.Add_Node (SU.To_Unbounded_String (Name), Parent); end Add_Node; procedure Add_Node (Object : in out Tree; Name : SU.Unbounded_String; Parent : String) is Parent_Cursor : constant Cursor := To_Cursor (Object, Parent); begin -- Add a new level if parent is a leaf node if Parent_Cursor.Level = Positive (Object.Levels.Length) then Object.Levels.Append (Level'(others => <>)); end if; declare Parent_Level : Level renames Object.Levels (Parent_Cursor.Level); Child_Level : Level renames Object.Levels (Parent_Cursor.Level + 1); Parent_Node : Node renames Parent_Level.Nodes (Parent_Cursor.Offset); New_Node_Index : constant Positive := Parent_Node.Offset + Parent_Node.Count; procedure Increment_Offset (Parent : in out Node) is begin Parent.Offset := Parent.Offset + 1; end Increment_Offset; Parent_Last_Index : constant Positive := Parent_Level.Nodes.Last_Index; begin -- If the node (in level j) has a parent that is the last node in level i, -- then the node can simply be appended to level j, which is faster to do if Parent_Cursor.Offset = Parent_Last_Index then Child_Level.Nodes.Append (Node'(Name => Name, Offset => 1, Count => 0)); Child_Level.Local_Transforms.Append (Transforms.Identity_Matrix); Child_Level.World_Transforms.Append (Transforms.Identity_Matrix); Child_Level.Local_Visibilities.Append (True); Child_Level.World_Visibilities.Append (True); else -- Insert new node and its transforms Child_Level.Nodes.Insert (New_Node_Index, Node'(Name => Name, Offset => 1, Count => 0)); Child_Level.Local_Transforms.Insert (New_Node_Index, Transforms.Identity_Matrix); Child_Level.World_Transforms.Insert (New_Node_Index, Transforms.Identity_Matrix); Child_Level.Local_Visibilities.Insert (New_Node_Index, True); Child_Level.World_Visibilities.Insert (New_Node_Index, True); -- After inserting a new node (in level j), increment the offsets -- of all parents that come after the new node's parent (in level i) for Parent_Index in Parent_Cursor.Offset + 1 .. Parent_Last_Index loop Parent_Level.Nodes.Update_Element (Parent_Index, Increment_Offset'Access); end loop; end if; Parent_Node.Count := Parent_Node.Count + 1; end; end Add_Node; procedure Remove_Node (Object : in out Tree; Name : String) is use Ada.Containers; Node_Cursor : constant Cursor := To_Cursor (Object, Name); Current_First_Index : Positive := Node_Cursor.Offset; Current_Last_Index : Positive := Node_Cursor.Offset; -- Assign a dummy value to silence any warnings about being uninitialized Next_First_Index, Next_Last_Index : Positive := Positive'Last; Empty_Level_Index : Positive := Object.Levels.Last_Index + 1; begin if Node_Cursor.Level = Positive'First and Node_Cursor.Offset = Positive'First then raise Root_Removal_Error with "Cannot remove root node"; end if; -- If the node that is the root of the subtree that is going to -- be removed, has a parent, then reduce the count of this parent. if Node_Cursor.Level > Object.Levels.First_Index then declare Parent_Level : Level renames Object.Levels (Node_Cursor.Level - 1); After_Parent_Index : Positive := Parent_Level.Nodes.Last_Index + 1; begin for Parent_Index in Parent_Level.Nodes.First_Index .. Parent_Level.Nodes.Last_Index loop declare Parent : Node renames Parent_Level.Nodes (Parent_Index); begin if Node_Cursor.Offset in Parent.Offset .. Parent.Offset + Parent.Count - 1 then Parent.Count := Parent.Count - 1; After_Parent_Index := Parent_Index + 1; exit; end if; end; end loop; -- Reduce the offsets of any nodes that come after the parent node for Parent_Index in After_Parent_Index .. Parent_Level.Nodes.Last_Index loop declare Parent : Node renames Parent_Level.Nodes (Parent_Index); begin Parent.Offset := Parent.Offset - 1; end; end loop; end; end if; for Level_Index in Node_Cursor.Level .. Object.Levels.Last_Index loop declare Node_Level : Level renames Object.Levels (Level_Index); Min_Index : Positive'Base := Current_Last_Index + 1; Max_Index : Positive'Base := Current_First_Index - 1; begin -- Because child nodes in the next level (in all levels actually) -- are adjacent, we can just use the offset of the first node -- that is not a leaf node and the offset + count - 1 of the last -- node that is not a leaf node. for Node_Index in Current_First_Index .. Current_Last_Index loop declare Current_Node : Node renames Node_Level.Nodes (Node_Index); begin if Current_Node.Count /= 0 then Min_Index := Positive'Min (Node_Index, Min_Index); Max_Index := Positive'Max (Node_Index, Max_Index); end if; end; end loop; -- Before removing the nodes and transforms, compute the range -- of the child nodes, if any, in the next level if Min_Index in Current_First_Index .. Current_Last_Index then declare Min_Node : Node renames Node_Level.Nodes (Min_Index); Max_Node : Node renames Node_Level.Nodes (Max_Index); begin -- Nodes to iterate over in next level Next_First_Index := Min_Node.Offset; Next_Last_Index := Max_Node.Offset + Max_Node.Count - 1; -- There are child nodes that are going to be removed next -- iteration, so we need to reduce the offset of the nodes -- that come after Current_Last_Index. declare Count : constant Positive := Next_Last_Index - Next_First_Index + 1; begin for Parent_Index in Current_Last_Index + 1 .. Node_Level.Nodes.Last_Index loop declare Parent : Node renames Node_Level.Nodes (Parent_Index); begin Parent.Offset := Parent.Offset - Count; end; end loop; end; end; end if; -- Remove all nodes between Current_First_Index .. Current_Last_Index in current level declare Count : constant Count_Type := Count_Type (Current_Last_Index - Current_First_Index + 1); begin Node_Level.Nodes.Delete (Current_First_Index, Count); Node_Level.Local_Transforms.Delete (Current_First_Index, Count); Node_Level.World_Transforms.Delete (Current_First_Index, Count); Node_Level.Local_Visibilities.Delete (Current_First_Index, Count); Node_Level.World_Visibilities.Delete (Current_First_Index, Count); end; -- Record the level index of the first empty level. Any levels down -- the tree should be(come) empty as well. if Node_Level.Nodes.Is_Empty then Empty_Level_Index := Positive'Min (Empty_Level_Index, Level_Index); end if; -- Exit if there are no nodes that have children exit when Min_Index not in Current_First_Index .. Current_Last_Index; -- If we reach this code here, then there is a node that has -- children. The variables below have been updated in the if -- block above. pragma Assert (Next_First_Index /= Positive'Last); pragma Assert (Next_Last_Index /= Positive'Last); Current_First_Index := Next_First_Index; Current_Last_Index := Next_Last_Index; end; end loop; -- Remove empty levels if Empty_Level_Index < Object.Levels.Last_Index + 1 then declare Count : constant Count_Type := Count_Type (Object.Levels.Last_Index - Empty_Level_Index + 1); begin Object.Levels.Delete (Empty_Level_Index, Count); end; end if; end Remove_Node; end Orka.Scenes.Generic_Scene_Trees;
zhmu/ananas
Ada
10,613
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . T A S K I N G -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNARL 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/>. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ with System.Task_Primitives.Operations; with System.Storage_Elements; package body System.Tasking is package STPO renames System.Task_Primitives.Operations; --------------------- -- Detect_Blocking -- --------------------- function Detect_Blocking return Boolean is GL_Detect_Blocking : Integer; pragma Import (C, GL_Detect_Blocking, "__gl_detect_blocking"); -- Global variable exported by the binder generated file. A value equal -- to 1 indicates that pragma Detect_Blocking is active, while 0 is used -- for the pragma not being present. begin return GL_Detect_Blocking = 1; end Detect_Blocking; ----------------------- -- Number_Of_Entries -- ----------------------- function Number_Of_Entries (Self_Id : Task_Id) return Entry_Index is begin return Entry_Index (Self_Id.Entry_Num); end Number_Of_Entries; ---------- -- Self -- ---------- function Self return Task_Id renames STPO.Self; ------------------ -- Storage_Size -- ------------------ function Storage_Size (T : Task_Id) return System.Parameters.Size_Type is begin return System.Parameters.Size_Type (T.Common.Compiler_Data.Pri_Stack_Info.Size); end Storage_Size; --------------------- -- Initialize_ATCB -- --------------------- procedure Initialize_ATCB (Self_ID : Task_Id; Task_Entry_Point : Task_Procedure_Access; Task_Arg : System.Address; Parent : Task_Id; Elaborated : Access_Boolean; Base_Priority : System.Any_Priority; Base_CPU : System.Multiprocessors.CPU_Range; Domain : Dispatching_Domain_Access; Task_Info : System.Task_Info.Task_Info_Type; Stack_Size : System.Parameters.Size_Type; T : Task_Id; Success : out Boolean) is begin T.Common.State := Unactivated; -- Initialize T.Common.LL STPO.Initialize_TCB (T, Success); if not Success then return; end if; -- Note that use of an aggregate here for this assignment -- would be illegal, because Common_ATCB is limited because -- Task_Primitives.Private_Data is limited. T.Common.Parent := Parent; T.Common.Base_Priority := Base_Priority; T.Common.Base_CPU := Base_CPU; -- The Domain defaults to that of the activator. But that can be null in -- the case of foreign threads (see Register_Foreign_Thread), in which -- case we default to the System_Domain. if Domain /= null then T.Common.Domain := Domain; elsif Self_ID.Common.Domain /= null then T.Common.Domain := Self_ID.Common.Domain; else T.Common.Domain := System_Domain; end if; pragma Assert (T.Common.Domain /= null); T.Common.Current_Priority := Priority'First; T.Common.Protected_Action_Nesting := 0; T.Common.Call := null; T.Common.Task_Arg := Task_Arg; T.Common.Task_Entry_Point := Task_Entry_Point; T.Common.Activator := Self_ID; T.Common.Wait_Count := 0; T.Common.Elaborated := Elaborated; T.Common.Activation_Failed := False; T.Common.Task_Info := Task_Info; T.Common.Global_Task_Lock_Nesting := 0; T.Common.Fall_Back_Handler := null; T.Common.Specific_Handler := null; T.Common.Debug_Events := [others => False]; T.Common.Task_Image_Len := 0; if T.Common.Parent = null then -- For the environment task, the adjusted stack size is meaningless. -- For example, an unspecified Stack_Size means that the stack size -- is determined by the environment, or can grow dynamically. The -- Stack_Checking algorithm therefore needs to use the requested -- size, or 0 in case of an unknown size. T.Common.Compiler_Data.Pri_Stack_Info.Size := Storage_Elements.Storage_Offset (Stack_Size); else T.Common.Compiler_Data.Pri_Stack_Info.Size := Storage_Elements.Storage_Offset (Parameters.Adjust_Storage_Size (Stack_Size)); end if; -- Link the task into the list of all tasks T.Common.All_Tasks_Link := All_Tasks_List; All_Tasks_List := T; end Initialize_ATCB; ---------------- -- Initialize -- ---------------- Main_Task_Image : constant String := "main_task"; -- Image of environment task Main_Priority : constant Integer; pragma Import (C, Main_Priority, "__gl_main_priority"); -- Priority for main task. Note that this is of type Integer, not Priority, -- because we use the value -1 to indicate the default main priority, and -- that is of course not in Priority'range. Main_CPU : constant Integer; pragma Import (C, Main_CPU, "__gl_main_cpu"); -- Affinity for main task. Note that this is of type Integer, not -- CPU_Range, because we use the value -1 to indicate the unassigned -- affinity, and that is of course not in CPU_Range'Range. Initialized : Boolean := False; -- Used to prevent multiple calls to Initialize procedure Initialize is T : Task_Id; Base_Priority : Any_Priority; Base_CPU : System.Multiprocessors.CPU_Range; Success : Boolean; use type System.Multiprocessors.CPU_Range; begin if Initialized then return; end if; Initialized := True; -- Initialize Environment Task Base_Priority := (if Main_Priority = Unspecified_Priority then Default_Priority else Priority (Main_Priority)); Base_CPU := (if Main_CPU = Unspecified_CPU then System.Multiprocessors.Not_A_Specific_CPU else System.Multiprocessors.CPU_Range (Main_CPU)); -- At program start-up the environment task is allocated to the default -- system dispatching domain. -- Make sure that the processors which are not available are not taken -- into account. Use Number_Of_CPUs to know the exact number of -- processors in the system at execution time. System_Domain := new Dispatching_Domain' (Multiprocessors.CPU'First .. Multiprocessors.Number_Of_CPUs => True); T := STPO.New_ATCB (0); Initialize_ATCB (Self_ID => null, Task_Entry_Point => null, Task_Arg => Null_Address, Parent => Null_Task, Elaborated => null, Base_Priority => Base_Priority, Base_CPU => Base_CPU, Domain => System_Domain, Task_Info => Task_Info.Unspecified_Task_Info, Stack_Size => 0, T => T, Success => Success); pragma Assert (Success); STPO.Initialize (T); STPO.Set_Priority (T, T.Common.Base_Priority); T.Common.State := Runnable; T.Common.Task_Image_Len := Main_Task_Image'Length; T.Common.Task_Image (Main_Task_Image'Range) := Main_Task_Image; Dispatching_Domain_Tasks := new Array_Allocated_Tasks' (Multiprocessors.CPU'First .. Multiprocessors.Number_Of_CPUs => 0); -- Signal that this task is being allocated to a processor if Base_CPU /= System.Multiprocessors.Not_A_Specific_CPU then -- Increase the number of tasks attached to the CPU to which this -- task is allocated. Dispatching_Domain_Tasks (Base_CPU) := Dispatching_Domain_Tasks (Base_CPU) + 1; end if; -- The full initialization of the environment task's Entry_Calls array -- is deferred to Init_RTS because only the first element of the array -- is used by the restricted Ravenscar runtime. T.Entry_Calls (T.Entry_Calls'First).Self := T; T.Entry_Calls (T.Entry_Calls'First).Level := T.Entry_Calls'First; end Initialize; end System.Tasking;
ph0sph8/amass
Ada
1,457
ads
-- Copyright 2017 Jeff Foley. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. local json = require("json") name = "C99" type = "api" function start() setratelimit(10) end function vertical(ctx, domain) if (api == nil or api.key == "") then return end local resp local vurl = buildurl(domain) -- Check if the response data is in the graph database if (api.ttl ~= nil and api.ttl > 0) then resp = obtain_response(vurl, api.ttl) end if (resp == nil or resp == "") then local err resp, err = request({ url=vurl, headers={['Content-Type']="application/json"}, }) if (err ~= nil and err ~= "") then return end if (api.ttl ~= nil and api.ttl > 0) then cache_response(vurl, resp) end end local d = json.decode(resp) if (d == nil or d.success ~= true or #(d.subdomains) == 0) then return end for i, s in pairs(d.subdomains) do sendnames(ctx, s.subdomain) end end function buildurl(domain) return "https://api.c99.nl/subdomainfinder?key=" .. api.key .. "&domain=" .. domain .. "&json" end function sendnames(ctx, content) local names = find(content, subdomainre) if names == nil then return end for i, v in pairs(names) do newname(ctx, v) end end
micahwelf/FLTK-Ada
Ada
3,535
ads
with FLTK.Widgets.Groups.Windows; package FLTK.Devices.Surfaces.Paged is type Paged_Surface is new Surface_Device with private; type Paged_Surface_Reference (Data : not null access Paged_Surface'Class) is limited null record with Implicit_Dereference => Data; type Page_Format is (A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, B0, B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, C5E, DLE, Executive, Folio, Ledger, Legal, Letter, Tabloid, Envelope); type Page_Layout is (Potrait, Landscape, Reversed, Orientation); Page_Error : exception; package Forge is function Create return Paged_Surface; end Forge; procedure Start_Job (This : in out Paged_Surface; Count : in Natural); procedure Start_Job (This : in out Paged_Surface; Count : in Natural; From, To : in Positive); procedure End_Job (This : in out Paged_Surface); procedure Start_Page (This : in out Paged_Surface); procedure End_Page (This : in out Paged_Surface); procedure Get_Margins (This : in Paged_Surface; Left, Top, Right, Bottom : out Integer); procedure Get_Printable_Rect (This : in Paged_Surface; W, H : out Integer); procedure Get_Origin (This : in Paged_Surface; X, Y : out Integer); procedure Set_Origin (This : in out Paged_Surface; X, Y : in Integer); procedure Rotate (This : in out Paged_Surface; Degrees : in Float); procedure Scale (This : in out Paged_Surface; Factor : in Float); procedure Scale (This : in out Paged_Surface; Factor_X, Factor_Y : in Float); procedure Translate (This : in out Paged_Surface; Delta_X, Delta_Y : in Integer); procedure Untranslate (This : in out Paged_Surface); procedure Print_Widget (This : in out Paged_Surface; Item : in FLTK.Widgets.Widget'Class; Offset_X, Offset_Y : in Integer := 0); procedure Print_Window (This : in out Paged_Surface; Item : in FLTK.Widgets.Groups.Windows.Window'Class; Offset_X, Offset_Y : in Integer := 0); procedure Print_Window_Part (This : in out Paged_Surface; Item : in FLTK.Widgets.Groups.Windows.Window'Class; X, Y, W, H : in Integer; Offset_X, Offset_Y : in Integer := 0); private type Paged_Surface is new Surface_Device with null record; overriding procedure Finalize (This : in out Paged_Surface); pragma Inline (Start_Job); pragma Inline (End_Job); pragma Inline (Start_Page); pragma Inline (End_Page); pragma Inline (Get_Margins); pragma Inline (Get_Printable_Rect); pragma Inline (Get_Origin); pragma Inline (Set_Origin); pragma Inline (Rotate); pragma Inline (Scale); pragma Inline (Translate); pragma Inline (Untranslate); pragma Inline (Print_Widget); pragma Inline (Print_Window); pragma Inline (Print_Window_Part); end FLTK.Devices.Surfaces.Paged;
landgraf/nanomsg-ada
Ada
1,315
ads
-- The MIT License (MIT) -- Copyright (c) 2015 Pavel Zhukov <[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. package Nanomsg.Pair is Nn_Proto_Pair : constant := 1; Nn_Pair : constant Protocol_T := Nn_Proto_Pair * 16 + 0; end Nanomsg.Pair;
onox/sdlada
Ada
2,293
ads
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2013-2018 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.TTFs.Versions -- -- Library version information. -------------------------------------------------------------------------------------------------------------------- with SDL.Versions; package SDL.TTFs.Versions is -- These allow the user to determine which version of SDLAda_TTF they compiled with. Compiled_Major : constant SDL.Versions.Version_Level with Import => True, Convention => C, External_Name => "SDL_Ada_TTF_Major_Version"; Compiled_Minor : constant SDL.Versions.Version_Level with Import => True, Convention => C, External_Name => "SDL_Ada_TTF_Minor_Version"; Compiled_Patch : constant SDL.Versions.Version_Level with Import => True, Convention => C, External_Name => "SDL_Ada_TTF_Patch_Version"; Compiled : constant SDL.Versions.Version := (Major => Compiled_Major, Minor => Compiled_Minor, Patch => Compiled_Patch); procedure Linked_With (Info : in out SDL.Versions.Version); end SDL.TTFs.Versions;
charlie5/aIDE
Ada
1,988
ads
with AdaM.a_Type, Ada.Containers.Vectors, Ada.Streams; package AdaM.Declaration.of_object is type Item is new Declaration.item with private; -- View -- type View is access all Item'Class; procedure View_write (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : in View); procedure View_read (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : out View); for View'write use View_write; for View'read use View_read; -- Vector -- package Vectors is new ada.Containers.Vectors (Positive, View); subtype Vector is Vectors.Vector; -- Forge -- function new_Declaration (Name : in String) return Declaration.of_object.view; procedure free (Self : in out Declaration.of_object.view); overriding procedure destruct (Self : in out Declaration.of_object.item); -- Attributes -- overriding function Id (Self : access Item) return AdaM.Id; procedure is_Aliased (Self : in out Item; Now : in Boolean := True); function is_Aliased (Self : in Item) return Boolean; procedure is_Constant (Self : in out Item; Now : in Boolean := True); function is_Constant (Self : in Item) return Boolean; procedure Type_is (Self : in out Item; Now : in AdaM.a_Type.view); function my_Type (Self : in Item) return AdaM.a_Type.view; function my_Type (Self : access Item) return access AdaM.a_Type.view; procedure Initialiser_is (Self : in out Item; Now : in String); function Initialiser (Self : in Item) return String; private type Item is new Declaration.item with record is_Aliased : Boolean := False; is_Constant : Boolean := False; my_Type : aliased a_Type.view; Initialiser : Text; end record; end AdaM.Declaration.of_object;
reznikmm/matreshka
Ada
4,866
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.DG.Polylines.Collections is pragma Preelaborate; package DG_Polyline_Collections is new AMF.Generic_Collections (DG_Polyline, DG_Polyline_Access); type Set_Of_DG_Polyline is new DG_Polyline_Collections.Set with null record; Empty_Set_Of_DG_Polyline : constant Set_Of_DG_Polyline; type Ordered_Set_Of_DG_Polyline is new DG_Polyline_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_DG_Polyline : constant Ordered_Set_Of_DG_Polyline; type Bag_Of_DG_Polyline is new DG_Polyline_Collections.Bag with null record; Empty_Bag_Of_DG_Polyline : constant Bag_Of_DG_Polyline; type Sequence_Of_DG_Polyline is new DG_Polyline_Collections.Sequence with null record; Empty_Sequence_Of_DG_Polyline : constant Sequence_Of_DG_Polyline; private Empty_Set_Of_DG_Polyline : constant Set_Of_DG_Polyline := (DG_Polyline_Collections.Set with null record); Empty_Ordered_Set_Of_DG_Polyline : constant Ordered_Set_Of_DG_Polyline := (DG_Polyline_Collections.Ordered_Set with null record); Empty_Bag_Of_DG_Polyline : constant Bag_Of_DG_Polyline := (DG_Polyline_Collections.Bag with null record); Empty_Sequence_Of_DG_Polyline : constant Sequence_Of_DG_Polyline := (DG_Polyline_Collections.Sequence with null record); end AMF.DG.Polylines.Collections;
johnperry-math/hac
Ada
10,506
ads
------------------------------------------------------------------------------------- -- -- HAC - HAC Ada Compiler -- -- A compiler in Ada for an Ada subset -- -- Copyright, license, etc. : see top package. -- ------------------------------------------------------------------------------------- -- -- This package defines the PCode Virtual Machine. with HAC_Sys.Defs; with Ada.Text_IO; -- Only used for file descriptors package HAC_Sys.PCode is -----------------------------------------------------PCode Opcodes---- type Opcode is ( k_Push_Address, k_Push_Value, k_Push_Indirect_Value, k_Push_Discrete_Literal, k_Push_Float_Literal, -- k_Variable_Initialization, k_Update_Display_Vector, k_Store, -- k_Standard_Functions, -- k_Jump, k_Conditional_Jump, -- k_CASE_Switch, k_CASE_Choice_Data, k_CASE_Match_Jump, k_CASE_No_Choice_Found, -- k_FOR_Forward_Begin, k_FOR_Forward_End, k_FOR_Reverse_Begin, k_FOR_Reverse_End, k_FOR_Release_Stack_After_End, -- k_Array_Index_Element_Size_1, k_Array_Index, k_Record_Field_Offset, k_Load_Block, k_Copy_Block, k_String_Literal_Assignment, -- k_Mark_Stack, -- First instruction for a Call k_Call, -- Procedure and task entry Call k_Exit_Call, k_Exit_Function, -- k_Integer_to_Float, -- The reverse conversion is done by a k_Standard_Functions k_Dereference, k_Unary_MINUS_Float, -- 2020-04-04 k_Unary_MINUS_Integer, k_NOT_Boolean, -- k_EQL_Integer, k_NEQ_Integer, k_LSS_Integer, k_LEQ_Integer, k_GTR_Integer, k_GEQ_Integer, -- k_EQL_VString, k_NEQ_VString, k_LSS_VString, k_LEQ_VString, k_GTR_VString, k_GEQ_VString, -- k_EQL_Float, k_NEQ_Float, k_LSS_Float, k_LEQ_Float, k_GTR_Float, k_GEQ_Float, -- k_ADD_Integer, k_SUBTRACT_Integer, k_MULT_Integer, k_DIV_Integer, k_MOD_Integer, k_Power_Integer, -- 2018-03-18 : 3 ** 6 -- k_ADD_Float, k_SUBTRACT_Float, k_MULT_Float, k_DIV_Float, k_Power_Float, -- 2018-03-22 : 3.14 ** 6.28 k_Power_Float_Integer, -- 2018-03-22 : 3.14 ** 6 -- k_OR_Boolean, k_AND_Boolean, k_XOR_Boolean, -- k_File_I_O, -- k_Halt_Interpreter, -- Switch off the processor's running loop k_Accept_Rendezvous, k_End_Rendezvous, k_Wait_Semaphore, k_Signal_Semaphore, k_Delay, k_Set_Quantum_Task, k_Set_Task_Priority, k_Set_Task_Priority_Inheritance, k_Selective_Wait ); subtype Unary_Operator_Opcode is Opcode range k_Integer_to_Float .. k_NOT_Boolean; subtype Binary_Operator_Opcode is Opcode range k_EQL_Integer .. k_XOR_Boolean; -- subtype Atomic_Data_Push_Opcode is Opcode range k_Push_Address .. k_Push_Float_Literal; subtype Calling_Opcode is Opcode range k_Mark_Stack .. k_Exit_Function; subtype CASE_Data_Opcode is Opcode range k_CASE_Choice_Data .. k_CASE_No_Choice_Found; subtype Composite_Data_Opcode is Opcode range k_Array_Index_Element_Size_1 .. k_String_Literal_Assignment; subtype Jump_Opcode is Opcode range k_Jump .. k_Conditional_Jump; subtype Multi_Statement_Opcode is Opcode range k_CASE_Switch .. k_FOR_Release_Stack_After_End; subtype Tasking_Opcode is Opcode range k_Halt_Interpreter .. k_Selective_Wait; function For_END (for_BEGIN : Opcode) return Opcode; type Opcode_Set is array (Opcode) of Boolean; OK_for_Exception : constant Opcode_Set := (k_Exit_Call .. k_Exit_Function | k_Halt_Interpreter => True, others => False); type Operand_1_Type is new Integer; -- Mostly used to pass nesting levels subtype Nesting_level is Operand_1_Type range 0 .. HAC_Sys.Defs.Nesting_Level_Max; -- Type for operand 2 (Y) is large enough for containing -- addresses, plus signed integer values *in* HAC programs. -- subtype Operand_2_Type is HAC_Sys.Defs.HAC_Integer; type Debug_Info is record -- Line number in the source code. Line_Number : Positive; -- Current block's path (if any). Example: hac-pcode-interpreter.adb. Full_Block_Id : Defs.VString; -- Source code file name. Example: HAC.PCode.Interpreter.Do_Write_Formatted. File_Name : Defs.VString; end record; -- PCode instruction record (stores a compiled PCode instruction) type Order is record F : Opcode; -- Opcode (or instruction field) X : Operand_1_Type; -- Operand 1 is mostly used to point to the static level Y : Operand_2_Type; -- Operand 2 is used to pass addresses and sizes to the -- instructions or immediate discrete values (k_Literal). D : Debug_Info; end record; type Object_Code_Table is array (Natural range <>) of Order; -- For jumps forward in the code towards an ELSE, ELSIF, END IF, END LOOP, ... -- When the code is emited, the address is still unknown. -- When the address is known, jump addresses are patched. -- Patching using dummy addresses. -- For loops, this technique can be used only for exiting -- the current loop. dummy_address_if : constant := -1; dummy_address_loop : constant := -2; -- Patch to OC'Last all addresses of Jump_Opcode's which are equal to dummy_address. procedure Patch_Addresses ( OC : in out Object_Code_Table; dummy_address : Operand_2_Type ); -- Mechanism for patching instructions at selected addresses. type Patch_Table is array (Positive range <>) of Operand_2_Type; subtype Fixed_Size_Patch_Table is Patch_Table (1 .. HAC_Sys.Defs.Patch_Max); -- Patch to OC'Last all addresses for Jump instructions whose -- addresses are contained in the Patch_Table, up to index Top. -- Reset Top to 0. procedure Patch_Addresses ( OC : in out Object_Code_Table; PT : Patch_Table; Top : in out Natural ); -- Add new instruction address to a Patch_Table. procedure Feed_Patch_Table ( PT : in out Patch_Table; Top : in out Natural; LC : Integer ); procedure Dump ( OC : Object_Code_Table; Str_Const : String; Flt_Const : Defs.Float_Constants_Table_Type; Text : Ada.Text_IO.File_Type ); -- Store PCode instruction in the object code table OC at position LC and increments LC. procedure Emit_Instruction ( OC : in out Object_Code_Table; LC : in out Integer; D : Debug_Info; FCT : Opcode; a : Operand_1_Type; B : Operand_2_Type ); -- Save and restore an object file procedure SaveOBJ (FileName : String); procedure RestoreOBJ (FileName : String); ------------------------------------ -- Standard function operations -- ------------------------------------ type SF_Code is ( SF_Abs_Int, SF_Abs_Float, SF_T_Val, -- S'Val : RM 3.5.5 (5) SF_T_Pos, -- S'Pos : RM 3.5.5 (2) SF_T_Succ, -- S'Succ : RM 3.5 (22) SF_T_Pred, -- S'Pred : RM 3.5 (25) -- Numerical functions SF_Round_Float_to_Int, SF_Trunc_Float_to_Int, SF_Float_to_Duration, SF_Duration_to_Float, SF_Int_to_Duration, SF_Duration_to_Int, SF_Sin, SF_Cos, SF_Exp, SF_Log, SF_Sqrt, SF_Arctan, SF_EOF, SF_EOLN, SF_Random_Int, -- VString functions SF_String_to_VString, -- +S (S is a fixed-size string) SF_Literal_to_VString, -- +"Hello" SF_Char_to_VString, -- +'x' SF_Two_VStrings_Concat, -- V1 & V2 SF_VString_Char_Concat, -- V & 'x' SF_Char_VString_Concat, -- 'x' & V SF_LStr_VString_Concat, -- "Hello " & V -- SF_VString_Int_Concat, -- V & 123 SF_Int_VString_Concat, -- 123 & V SF_VString_Float_Concat, -- V & 3.14159 SF_Float_VString_Concat, -- 3.14159 & V -- SF_Element, SF_Length, SF_Slice, -- SF_To_Lower_Char, SF_To_Upper_Char, SF_To_Lower_VStr, SF_To_Upper_VStr, SF_Index, SF_Int_Times_Char, SF_Int_Times_VStr, -- SF_Trim_Left, SF_Trim_Right, SF_Trim_Both, -- SF_Head, SF_Tail, SF_Starts_With, SF_Ends_With, -- -- Ada.Calendar-like functions -- SF_Time_Subtract, -- T2 - T1 -> Duration SF_Duration_Add, SF_Duration_Subtract, SF_Year, SF_Month, SF_Day, SF_Seconds, -- SF_Image_Ints, SF_Image_Floats, -- "Nice" image SF_Image_Attribute_Floats, -- Image attribute "as is" from Ada SF_Image_Times, SF_Image_Durations, SF_Integer_Value, SF_Float_Value, -- SF_Argument, SF_Exists, -- Ada.Directories-like SF_Get_Env, -- -- Niladic functions (they have no arguments). -- SF_Clock, SF_Random_Float, SF_Argument_Count, SF_Command_Name, SF_Directory_Separator, SF_Current_Directory, -- Ada.Directories-like -- SF_Get_Needs_Skip_Line -- Informs whether Get from console needs Skip_Line ); subtype SF_Niladic is SF_Code range SF_Clock .. SF_Get_Needs_Skip_Line; subtype SF_File_Information is SF_Code range SF_EOF .. SF_EOLN; ------------------------------------- -- Standard procedure operations -- ------------------------------------- type SP_Code is ( SP_Create, SP_Open, SP_Append, SP_Close, -- SP_Push_Abstract_Console, -- SP_Get, SP_Get_Immediate, SP_Get_Line, SP_Get_F, SP_Get_Line_F, SP_Skip_Line, -- SP_Put, SP_Put_Line, SP_Put_F, SP_Put_Line_F, SP_New_Line, -- SP_Wait, SP_Signal, -- SP_Quantum, SP_Priority, SP_InheritP, -- -- Ada.Environment_Variables-like procedures -- SP_Set_Env, -- -- Ada.Directories-like procedures -- SP_Copy_File, SP_Delete_File, SP_Rename, SP_Set_Directory, SP_Set_Exit_Status, -- -- Other system procedures -- SP_Shell_Execute_without_Result, SP_Shell_Execute_with_Result ); subtype SP_Shell_Execute is SP_Code range SP_Shell_Execute_without_Result .. SP_Shell_Execute_with_Result; end HAC_Sys.PCode;
faelys/ada-syslog
Ada
5,679
adb
------------------------------------------------------------------------------ -- Copyright (c) 2014-2015, 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. -- ------------------------------------------------------------------------------ with Ada.Calendar.Formatting; with Ada.Calendar.Time_Zones; package body Syslog.Timestamps is Months : constant array (Ada.Calendar.Month_Number) of String (1 .. 3) := ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); Digit : constant array (0 .. 9) of Character := ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); function RFC_3164 return String is Result : String (1 .. 15); Now : constant Ada.Calendar.Time := Ada.Calendar.Clock; Year : Ada.Calendar.Year_Number; Month : Ada.Calendar.Month_Number; Day : Ada.Calendar.Day_Number; Hour : Ada.Calendar.Formatting.Hour_Number; Minute : Ada.Calendar.Formatting.Minute_Number; Second : Ada.Calendar.Formatting.Second_Number; Sub_Second : Ada.Calendar.Formatting.Second_Duration; begin Ada.Calendar.Formatting.Split (Now, Year, Month, Day, Hour, Minute, Second, Sub_Second, Ada.Calendar.Time_Zones.UTC_Time_Offset (Now)); Result (1 .. 3) := Months (Month); Result (4) := ' '; if Day < 10 then Result (5) := ' '; Result (6) := Digit (Day); else Result (5) := Digit (Day / 10); Result (6) := Digit (Day mod 10); end if; Result (7 .. 15) := (' ', Digit (Hour / 10), Digit (Hour mod 10), ':', Digit (Minute / 10), Digit (Minute mod 10), ':', Digit (Second / 10), Digit (Second mod 10)); return Result; end RFC_3164; function RFC_5424 (With_Frac : Boolean := True) return String is use type Ada.Calendar.Time_Zones.Time_Offset; Now : constant Ada.Calendar.Time := Ada.Calendar.Clock; Offset : constant Ada.Calendar.Time_Zones.Time_Offset := Ada.Calendar.Time_Zones.UTC_Time_Offset (Now); Year : Ada.Calendar.Year_Number; Month : Ada.Calendar.Month_Number; Day : Ada.Calendar.Day_Number; Hour : Ada.Calendar.Formatting.Hour_Number; Minute : Ada.Calendar.Formatting.Minute_Number; Second : Ada.Calendar.Formatting.Second_Number; Sub_Second : Ada.Calendar.Formatting.Second_Duration; Prefix : String (1 .. 19); Frac : String (1 .. 7); Time_Zone : String (1 .. 6); begin Ada.Calendar.Formatting.Split (Now, Year, Month, Day, Hour, Minute, Second, Sub_Second, Offset); Prefix := (Digit (Year / 1000), Digit ((Year / 100) mod 10), Digit ((Year / 10) mod 10), Digit (Year mod 10), '-', Digit (Month / 10), Digit (Month mod 10), '-', Digit (Day / 10), Digit (Day mod 10), 'T', Digit (Hour / 10), Digit (Hour mod 10), ':', Digit (Minute / 10), Digit (Minute mod 10), ':', Digit (Second / 10), Digit (Second mod 10)); if With_Frac then if Sub_Second = 0.0 then Frac := (1 => '.', others => '0'); else Frac := ('.', Digit (Natural (Sub_Second * 10 - 0.5)), Digit (Natural (Sub_Second * 100 - 0.5) mod 10), Digit (Natural (Sub_Second * 1000 - 0.5) mod 10), Digit (Natural (Sub_Second * 10000 - 0.5) mod 10), Digit (Natural (Sub_Second * 100000 - 0.5) mod 10), Digit (Natural (Sub_Second * 1000000 - 0.5) mod 10)); end if; end if; if Offset = 0 then if With_Frac then return Prefix & Frac & 'Z'; else return Prefix & 'Z'; end if; else declare Off_Minute : constant Natural := Natural (abs Offset mod 60); Off_Hour : constant Natural := Natural (abs Offset / 60); begin if Offset < 0 then Time_Zone (1) := '-'; else Time_Zone (1) := '+'; end if; Time_Zone (2 .. 6) := (Digit (Off_Hour / 10), Digit (Off_Hour mod 10), ':', Digit (Off_Minute / 10), Digit (Off_Minute mod 10)); end; if With_Frac then return Prefix & Frac & Time_Zone; else return Prefix & Time_Zone; end if; end if; end RFC_5424; end Syslog.Timestamps;
jwarwick/aoc_2020
Ada
7,866
adb
-- AoC 2020, Day 21 with Ada.Text_IO; with Ada.Containers.Indefinite_Hashed_Maps; with Ada.Containers.Ordered_Sets; with Ada.Containers.Vectors; use Ada.Containers; with Ada.Strings.Fixed; use Ada.Strings.Fixed; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Strings.Hash; package body Day is package TIO renames Ada.Text_IO; package Ingredient_Maps is new Ada.Containers.Indefinite_Hashed_Maps (Key_Type => String, Element_Type => Natural, Hash => Ada.Strings.Hash, Equivalent_Keys => "="); use Ingredient_Maps; package String_Vectors is new Ada.Containers.Vectors (Index_Type => Natural, Element_Type => Unbounded_String); use String_Vectors; package List_Vectors is new Ada.Containers.Vectors (Index_Type => Natural, Element_Type => String_Vectors.Vector); use List_Vectors; package String_Sets is new Ada.Containers.Ordered_Sets (Element_Type => Unbounded_String); use String_Sets; package Set_Vectors is new Ada.Containers.Vectors (Index_Type => Natural, Element_Type => String_Sets.Set); use Set_Vectors; package Ingredient_To_Allergen_Maps is new Ada.Containers.Indefinite_Hashed_Maps (Key_Type => String, Element_Type => String_Sets.Set, Hash => Ada.Strings.Hash, Equivalent_Keys => "="); use Ingredient_To_Allergen_Maps; package Allergen_To_Ingredient_Maps is new Ada.Containers.Indefinite_Hashed_Maps (Key_Type => String, Element_Type => Set_Vectors.Vector, Hash => Ada.Strings.Hash, Equivalent_Keys => "="); use Allergen_To_Ingredient_Maps; counts : Ingredient_Maps.Map; foods : List_Vectors.Vector; allergen_keys : String_Sets.Set; ingredient_allergens : Ingredient_To_Allergen_Maps.Map; allergen_ingredients : Allergen_To_Ingredient_Maps.Map; allergens : Ingredient_To_Allergen_Maps.Map; -- function Allergen_Less(a1: in Unbounded_String; a2 : in Unbounded_String) return boolean is -- begin -- return allergens(to_string(a1)).first_element < allergens(to_string(a2)).first_element; -- end Allergen_Less; -- package Ingredient_Sort is new String_Vectors.Generic_Sorting(Allergen_Less); -- use Ingredient_Sort; procedure flatten_allergens is s : String_Sets.Set; begin for c in allergen_ingredients.Iterate loop s.clear; for v of allergen_ingredients(c) loop s := s or v; end loop; allergens.insert(key(c), s); end loop; end flatten_allergens; function all_length_one return Boolean is begin for c in allergens.iterate loop if allergens(c).length /= 1 then return false; end if; end loop; return true; end all_length_one; function all_singles return String_Sets.Set is s : String_Sets.Set := String_Sets.Empty_Set; begin for c in allergens.iterate loop if allergens(c).length = 1 then s.include(allergens(c).first_element); end if; end loop; return s; end all_singles; procedure reduce_allergens is begin loop if all_length_one then exit; end if; declare singles : constant String_Sets.Set := all_singles; begin if singles.is_empty then TIO.put_line("No single element sets!"); exit; end if; for k of allergen_keys loop if allergens(to_string(k)).length > 1 then allergens(to_string(k)) := allergens(to_string(k)) - singles; end if; end loop; end; end loop; end reduce_allergens; procedure link_allergen(allergen : in String; ing : in String_Vectors.Vector) is set_vec : Set_Vectors.Vector := Set_Vectors.Empty_Vector; str_set : String_Sets.Set := String_Sets.Empty_Set; begin allergen_keys.include(to_unbounded_string(allergen)); for i of ing loop str_set.include(i); end loop; set_vec.append(str_set); if allergen_ingredients.contains(allergen) then append(allergen_ingredients(allergen), set_vec); else allergen_ingredients.insert(allergen, set_vec); end if; for i of ing loop declare allergen_set : String_Sets.Set := String_Sets.Empty_Set; i_str : constant String := to_string(i); begin allergen_set.include(to_unbounded_string(allergen)); if ingredient_allergens.contains(i_str) then ingredient_allergens(i_str).include(to_unbounded_string(allergen)); else ingredient_allergens.insert(i_str, allergen_set); end if; end; end loop; end link_allergen; procedure read_ingredient(line : in String) is ing : String_Vectors.Vector := String_Vectors.Empty_Vector; idx : Natural := line'first; begin loop declare next_idx : constant Natural := index(line(idx..line'last), " "); s : constant String := line(idx..next_idx-1); begin idx := next_idx + 1; if s(s'first) = '(' then exit; end if; if counts.contains(s) then counts(s) := counts(s) + 1; else counts.insert(s, 1); end if; ing.append(to_unbounded_string(s)); end; end loop; foods.append(ing); loop declare next_idx : constant Natural := index(line(idx..line'last), ","); begin if next_idx = 0 then link_allergen(line(idx..line'last-1), ing); exit; end if; link_allergen(line(idx..next_idx-1), ing); idx := next_idx + 2; end; end loop; end read_ingredient; procedure ingredient_count(filename : in String) is file : TIO.File_Type; sum : Natural := 0; begin foods.clear; counts.clear; ingredient_allergens.clear; allergen_ingredients.clear; TIO.open(File => file, Mode => TIO.In_File, Name => filename); while not TIO.end_of_file(file) loop read_ingredient(TIO.get_line(file)); end loop; TIO.close(file); -- TIO.put_line("Foods: "); -- for f of foods loop -- for i of f loop -- TIO.put(to_string(i) & ", "); -- end loop; -- TIO.new_line; -- end loop; -- for c in allergen_ingredients.Iterate loop -- TIO.put_line("Allergen: " & Key(c)); -- for i of allergen_ingredients(c) loop -- for s of i loop -- TIO.put(to_string(s) & ", "); -- end loop; -- TIO.new_line; -- end loop; -- end loop; -- for c in ingredient_allergens.Iterate loop -- TIO.put_line("Ingredient: " & Key(c)); -- for a of ingredient_allergens(c) loop -- TIO.put(to_string(a) & ", "); -- end loop; -- TIO.new_line; -- end loop; flatten_allergens; for c in ingredient_allergens.Iterate loop declare possible_allergens : constant String_Sets.Set := ingredient_allergens(c); ing : constant String := Key(c); cnt : Natural := Natural(possible_allergens.length); begin for a of possible_allergens loop for v of allergen_ingredients(to_string(a)) loop if not v.contains(to_unbounded_string(ing)) then cnt := cnt - 1; allergens(to_string(a)).exclude(to_unbounded_string(ing)); exit; end if; end loop; end loop; if cnt = 0 then sum := sum + counts(ing); end if; end; end loop; TIO.put_line("Part 1: " & sum'IMAGE); reduce_allergens; for c in allergens.iterate loop TIO.put_line("Allergen: " & key(c)); for elt of allergens(c) loop TIO.put(to_string(elt) & ", "); end loop; TIO.new_line; end loop; -- screw sorting in Ada. -- examine the above output and sort it yourself end ingredient_count; end Day;
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_Default_Cell_Style_Name_Attributes is pragma Preelaborate; type ODF_Table_Default_Cell_Style_Name_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Table_Default_Cell_Style_Name_Attribute_Access is access all ODF_Table_Default_Cell_Style_Name_Attribute'Class with Storage_Size => 0; end ODF.DOM.Table_Default_Cell_Style_Name_Attributes;
zhmu/ananas
Ada
258
adb
-- { dg-do compile } package body Discr53 is function F return Rec is Data : Rec; begin return Data; end; type Ptr is access Rec; procedure Proc is Local : Ptr; begin Local := new Rec'(F); end; end Discr53;
sungyeon/drake
Ada
3,430
adb
with Ada.Exception_Identification.From_Here; with System.Zero_Terminated_Strings; with C.dlfcn; package body System.Program.Dynamic_Linking is use Ada.Exception_Identification.From_Here; use type C.signed_int; use type C.size_t; procedure Open (Handle : out C.void_ptr; Name : String); procedure Open (Handle : out C.void_ptr; Name : String) is C_Name : C.char_array ( 0 .. Name'Length * Zero_Terminated_Strings.Expanding); begin Zero_Terminated_Strings.To_C (Name, C_Name (0)'Access); Handle := C.dlfcn.dlopen (C_Name (0)'Access, 0); if Address (Handle) = Null_Address then Raise_Exception (Name_Error'Identity); end if; end Open; procedure Close (Handle : C.void_ptr; Raise_On_Error : Boolean); procedure Close (Handle : C.void_ptr; Raise_On_Error : Boolean) is R : C.signed_int; begin if Address (Handle) /= Null_Address then R := C.dlfcn.dlclose (Handle); if R < 0 and then Raise_On_Error then Raise_Exception (Use_Error'Identity); end if; end if; end Close; -- implementation function Is_Open (Lib : Library) return Boolean is Handle : C.void_ptr renames Controlled.Reference (Lib).all; begin return Address (Handle) /= Null_Address; end Is_Open; procedure Open (Lib : in out Library; Name : String) is pragma Check (Pre, Check => not Is_Open (Lib) or else raise Status_Error); Handle : C.void_ptr renames Controlled.Reference (Lib).all; begin Open (Handle, Name); end Open; function Open (Name : String) return Library is begin return Result : Library do declare Handle : C.void_ptr renames Controlled.Reference (Result).all; begin Open (Handle, Name); end; end return; end Open; procedure Close (Lib : in out Library) is pragma Check (Pre, Check => Is_Open (Lib) or else raise Status_Error); Handle : C.void_ptr renames Controlled.Reference (Lib).all; Freeing_Handle : constant C.void_ptr := Handle; begin Handle := C.void_ptr (Null_Address); Close (Freeing_Handle, Raise_On_Error => True); end Close; function Import ( Lib : Library; Symbol : String) return Address is pragma Check (Dynamic_Predicate, Check => Is_Open (Lib) or else raise Status_Error); Handle : C.void_ptr renames Controlled.Reference (Lib).all; C_Symbol : C.char_array ( 0 .. Symbol'Length * Zero_Terminated_Strings.Expanding); Result : C.void_ptr; begin Zero_Terminated_Strings.To_C (Symbol, C_Symbol (0)'Access); Result := C.dlfcn.dlsym (Handle, C_Symbol (0)'Access); if Address (Result) = Null_Address then Raise_Exception (Data_Error'Identity); else return Address (Result); end if; end Import; package body Controlled is function Reference (Lib : Dynamic_Linking.Library) return not null access C.void_ptr is begin return Library (Lib).Handle'Unrestricted_Access; end Reference; overriding procedure Finalize (Object : in out Library) is begin Close (Object.Handle, Raise_On_Error => False); end Finalize; end Controlled; end System.Program.Dynamic_Linking;
reznikmm/matreshka
Ada
3,669
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.Draw_Image_Map_Elements is pragma Preelaborate; type ODF_Draw_Image_Map is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Draw_Image_Map_Access is access all ODF_Draw_Image_Map'Class with Storage_Size => 0; end ODF.DOM.Draw_Image_Map_Elements;
reznikmm/matreshka
Ada
3,950
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2015, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Asis.Elements; with Asis.Expressions; package body Properties.Expressions.Parameter_Association is ------------ -- Bounds -- ------------ function Bounds (Engine : access Engines.Contexts.Context; Element : Asis.Association; Name : Engines.Text_Property) return League.Strings.Universal_String is Param : constant Asis.Element := Asis.Expressions.Formal_Parameter (Element); begin return Engine.Text.Get_Property (Asis.Elements.Enclosing_Element (Param), Name); end Bounds; end Properties.Expressions.Parameter_Association;
jhumphry/PRNG_Zoo
Ada
1,738
ads
-- -- PRNG Zoo -- Copyright (c) 2014 - 2015, 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 AUnit; use AUnit; with AUnit.Test_Cases; use AUnit.Test_Cases; with PRNG_Zoo.MT; with PRNGTests_Suite.Sanity_Checks; with PRNGTests_Suite.Sanity_Checks32; package PRNGTests_Suite.MT_Tests is type MT_Test is new Test_Cases.Test_Case with null record; procedure Register_Tests (T: in out MT_Test); function Name (T : MT_Test) return Test_String; procedure Set_Up (T : in out MT_Test); -- Test Routines: procedure Test_MT19937 (T : in out Test_Cases.Test_Case'Class); procedure Test_MT19937_64 (T : in out Test_Cases.Test_Case'Class); procedure Test_TinyMT_64 (T : in out Test_Cases.Test_Case'Class); procedure Sanity_Check_MT19937 is new PRNGTests_Suite.Sanity_Checks32(P => MT.MT19937); procedure Sanity_Check_MT19937_64 is new PRNGTests_Suite.Sanity_Checks(P => MT.MT19937_64); procedure Sanity_Check_TinyMT_64 is new PRNGTests_Suite.Sanity_Checks(P => MT.TinyMT_64); end PRNGTests_Suite.MT_Tests ;
reznikmm/matreshka
Ada
4,855
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_Elements; with AMF.Standard_Profile_L2.Calls; with AMF.UML.Usages; with AMF.Visitors; package AMF.Internals.Standard_Profile_L2_Calls is type Standard_Profile_L2_Call_Proxy is limited new AMF.Internals.UML_Elements.UML_Element_Base and AMF.Standard_Profile_L2.Calls.Standard_Profile_L2_Call with null record; overriding function Get_Base_Usage (Self : not null access constant Standard_Profile_L2_Call_Proxy) return AMF.UML.Usages.UML_Usage_Access; -- Getter of Call::base_Usage. -- overriding procedure Set_Base_Usage (Self : not null access Standard_Profile_L2_Call_Proxy; To : AMF.UML.Usages.UML_Usage_Access); -- Setter of Call::base_Usage. -- overriding procedure Enter_Element (Self : not null access constant Standard_Profile_L2_Call_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); overriding procedure Leave_Element (Self : not null access constant Standard_Profile_L2_Call_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); overriding procedure Visit_Element (Self : not null access constant Standard_Profile_L2_Call_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); end AMF.Internals.Standard_Profile_L2_Calls;
onox/orka
Ada
1,000
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2019 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. package Orka.Features.Atmosphere.KTX is function Load_Textures (Data : Model_Data; Location : Resources.Locations.Location_Ptr) return Precomputed_Textures; procedure Save_Textures (Object : Precomputed_Textures; Location : Resources.Locations.Writable_Location_Ptr); end Orka.Features.Atmosphere.KTX;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
939
ads
with STM32_SVD.GPIO; generic Pin : GPIO_Pin; Port : GPIO_Port; Mode : Pin_IO_Modes := Mode_In; Pull_Resistor : in Internal_Pin_Resistors := Floating; Alternate_Function : in GPIO_Alternate_Function := 0; package STM32GD.GPIO.Pin is pragma Preelaborate; procedure Enable; procedure Disable; procedure Init; procedure Set_Mode (Mode : Pin_IO_Modes); procedure Set_Type (Pin_Type : Pin_Output_Types); function Get_Pull_Resistor return Internal_Pin_Resistors; procedure Set_Pull_Resistor (Pull : Internal_Pin_Resistors); procedure Configure_Alternate_Function (AF : GPIO_Alternate_Function); procedure Configure_Trigger (Rising : Boolean := False; Falling : Boolean := False); procedure Wait_For_Trigger; procedure Clear_Trigger; function Triggered return Boolean; function Is_Set return Boolean; procedure Set; procedure Clear; procedure Toggle; end STM32GD.GPIO.Pin;
charlie5/cBound
Ada
1,679
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_glx_get_tex_gendv_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; context_tag : aliased xcb.xcb_glx_context_tag_t; coord : aliased Interfaces.Unsigned_32; pname : aliased Interfaces.Unsigned_32; end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_glx_get_tex_gendv_request_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_tex_gendv_request_t.Item, Element_Array => xcb.xcb_glx_get_tex_gendv_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_glx_get_tex_gendv_request_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_tex_gendv_request_t.Pointer, Element_Array => xcb.xcb_glx_get_tex_gendv_request_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_glx_get_tex_gendv_request_t;
gitter-badger/spat
Ada
2,681
adb
------------------------------------------------------------------------------ -- Copyright (C) 2020 by Heisenbug Ltd. ([email protected]) -- -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the LICENSE file for more details. ------------------------------------------------------------------------------ pragma License (Unrestricted); package body SPAT.Proof_Attempt is --------------------------------------------------------------------------- -- "<" --------------------------------------------------------------------------- not overriding function "<" (Left : in T; Right : in T) return Boolean is use type Proof_Attempt_Ids.Id; begin -- Sort by time, steps, result, and then prover name. if Left.Time /= Right.Time then return Left.Time > Right.Time; end if; if Left.Steps /= Right.Steps then return Left.Steps > Right.Steps; end if; if Left.Result /= Right.Result then return Left.Result < Right.Result; end if; if Left.Prover /= Right.Prover then return Left.Prover < Right.Prover; end if; -- Last resort, the unique id. return Left.Id < Right.Id; end "<"; --------------------------------------------------------------------------- -- Create --------------------------------------------------------------------------- function Create (Object : JSON_Value; Prover : Subject_Name) return T is Time_Field : constant JSON_Value := Object.Get (Field => Field_Names.Time); begin return T'(Entity.T with Prover => Prover, Result => Object.Get (Field => Field_Names.Result), Time => (case Time_Field.Kind is when JSON_Float_Type => Duration (Time_Field.Get_Long_Float), when JSON_Int_Type => Duration (Long_Long_Integer'(Time_Field.Get)), when others => raise Program_Error with "Fatal: Impossible Kind """ & Time_Field.Kind'Image & """ of JSON object!"), Steps => Prover_Steps (Long_Integer'(Object.Get (Field => Field_Names.Steps))), Id => Proof_Attempt_Ids.Next); end Create; end SPAT.Proof_Attempt;
marcello-s/AeonFlux
Ada
7,477
adb
-- Copyright (c) 2015-2019 Marcel Schneider -- for details see License.txt with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Containers.Hashed_Maps; use Ada.Containers; with Tokens; use Tokens; package body Punctuation is procedure Initialize (O : in out Object) is begin -- Punctuators O.Punctuators.Insert(To_Unbounded_String ("("), Tokens.LeftBracket); O.Punctuators.Insert(To_Unbounded_String (")"), Tokens.RightBracket); O.Punctuators.Insert(To_Unbounded_String ("{"), Tokens.LeftBrace); O.Punctuators.Insert(To_Unbounded_String ("}"), Tokens.RightBrace); O.Punctuators.Insert(To_Unbounded_String ("["), Tokens.LeftSquareBracket); O.Punctuators.Insert(To_Unbounded_String ("]"), Tokens.RightSquareBracket); O.Punctuators.Insert(To_Unbounded_String (";"), Tokens.Semicolon); O.Punctuators.Insert(To_Unbounded_String (","), Tokens.Comma); O.Punctuators.Insert(To_Unbounded_String ("."), Tokens.Point); -- Operators O.Operators.Insert(To_Unbounded_String ("?"), Tokens.Question); O.Operators.Insert(To_Unbounded_String (":"), Tokens.Colon); O.Operators.Insert(To_Unbounded_String ("~"), Tokens.Tilde); O.Operators.Insert(To_Unbounded_String ("*"), Tokens.Asterisk); O.Operators.Insert(To_Unbounded_String ("*="), Tokens.AsteriskEqual); O.Operators.Insert(To_Unbounded_String ("%"), Tokens.Percent); O.Operators.Insert(To_Unbounded_String ("%="), Tokens.PercentEqual); O.Operators.Insert(To_Unbounded_String ("^"), Tokens.Carot); O.Operators.Insert(To_Unbounded_String ("^="), Tokens.CarotEqual); O.Operators.Insert(To_Unbounded_String ("/"), Tokens.Slash); O.Operators.Insert(To_Unbounded_String ("/="), Tokens.SlashEqual); O.Operators.Insert(To_Unbounded_String ("&"), Tokens.Ampersand); O.Operators.Insert(To_Unbounded_String ("&&"), Tokens.Ampersand2); O.Operators.Insert(To_Unbounded_String ("&&="), Tokens.AmpersandEqual); O.Operators.Insert(To_Unbounded_String ("|"), Tokens.Pipe); O.Operators.Insert(To_Unbounded_String ("||"), Tokens.Pipe2); O.Operators.Insert(To_Unbounded_String ("|="), Tokens.PipeEqual); O.Operators.Insert(To_Unbounded_String ("="), Tokens.Equal); O.Operators.Insert(To_Unbounded_String ("=="), Tokens.Equal2); O.Operators.Insert(To_Unbounded_String ("==="), Tokens.Equal3); O.Operators.Insert(To_Unbounded_String ("!"), Tokens.Exclamation); O.Operators.Insert(To_Unbounded_String ("!="), Tokens.ExclamationEqual); O.Operators.Insert(To_Unbounded_String ("!=="), Tokens.ExclamationEqual2); O.Operators.Insert(To_Unbounded_String ("+"), Tokens.Plus); O.Operators.Insert(To_Unbounded_String ("++"), Tokens.Plus2); O.Operators.Insert(To_Unbounded_String ("+="), Tokens.PlusEqual); O.Operators.Insert(To_Unbounded_String ("-"), Tokens.Minus); O.Operators.Insert(To_Unbounded_String ("--"), Tokens.Minus2); O.Operators.Insert(To_Unbounded_String ("-="), Tokens.MinusEqual); O.Operators.Insert(To_Unbounded_String ("<"), Tokens.LessThan); O.Operators.Insert(To_Unbounded_String ("<<"), Tokens.LessThan2); O.Operators.Insert(To_Unbounded_String ("<="), Tokens.LessThanEqual); O.Operators.Insert(To_Unbounded_String ("<<="), Tokens.LessThan2Equal); O.Operators.Insert(To_Unbounded_String (">"), Tokens.GreaterThan); O.Operators.Insert(To_Unbounded_String (">>"), Tokens.GreaterThan2); O.Operators.Insert(To_Unbounded_String (">="), Tokens.GreaterThanEqual); O.Operators.Insert(To_Unbounded_String (">>="), Tokens.GreaterThan2Equal); O.Operators.Insert(To_Unbounded_String (">>>"), Tokens.GreaterThan3); O.Operators.Insert(To_Unbounded_String (">>>="), Tokens.GreaterThan3Equal); -- reserved Keywords O.Keywords.Insert(To_Unbounded_String ("break"), Tokens.Break); O.Keywords.Insert(To_Unbounded_String ("case"), Tokens.Case_Tok); O.Keywords.Insert(To_Unbounded_String ("catch"), Tokens.Catch); O.Keywords.Insert(To_Unbounded_String ("continue"), Tokens.Continue); O.Keywords.Insert(To_Unbounded_String ("debugger"), Tokens.Debugger); O.Keywords.Insert(To_Unbounded_String ("default"), Tokens.Default); O.Keywords.Insert(To_Unbounded_String ("delete"), Tokens.Delete); O.Keywords.Insert(To_Unbounded_String ("do"), Tokens.Do_Tok); O.Keywords.Insert(To_Unbounded_String ("else"), Tokens.Else_Tok); O.Keywords.Insert(To_Unbounded_String ("finally"), Tokens.Finally); O.Keywords.Insert(To_Unbounded_String ("for"), Tokens.For_Tok); O.Keywords.Insert(To_Unbounded_String ("function"), Tokens.Function_Tok); O.Keywords.Insert(To_Unbounded_String ("if"), Tokens.If_Tok); O.Keywords.Insert(To_Unbounded_String ("in"), Tokens.In_Tok); O.Keywords.Insert(To_Unbounded_String ("instanceof"), Tokens.Instanceof); O.Keywords.Insert(To_Unbounded_String ("new"), Tokens.New_Tok); O.Keywords.Insert(To_Unbounded_String ("return"), Tokens.Return_Tok); O.Keywords.Insert(To_Unbounded_String ("switch"), Tokens.Switch); O.Keywords.Insert(To_Unbounded_String ("this"), Tokens.This); O.Keywords.Insert(To_Unbounded_String ("throw"), Tokens.Throw); O.Keywords.Insert(To_Unbounded_String ("try"), Tokens.Try); O.Keywords.Insert(To_Unbounded_String ("typeof"), Tokens.Typeof); O.Keywords.Insert(To_Unbounded_String ("var"), Tokens.Var); O.Keywords.Insert(To_Unbounded_String ("void"), Tokens.Void); O.Keywords.Insert(To_Unbounded_String ("while"), Tokens.While_Tok); O.Keywords.Insert(To_Unbounded_String ("with"), Tokens.With_Tok); O.Keywords.Insert(To_Unbounded_String ("true"), Tokens.True); O.Keywords.Insert(To_Unbounded_String ("false"), Tokens.False); O.Keywords.Insert(To_Unbounded_String ("null"), Tokens.Null_Tok); -- future reserved word O.FutureReservedWords.Insert(To_Unbounded_String("class"), Tokens.Class); O.FutureReservedWords.Insert(To_Unbounded_String("const"), Tokens.Const); O.FutureReservedWords.Insert(To_Unbounded_String("enum"), Tokens.Enum); O.FutureReservedWords.Insert(To_Unbounded_String("export"), Tokens.Export); O.FutureReservedWords.Insert(To_Unbounded_String("extends"), Tokens.Extends); O.FutureReservedWords.Insert(To_Unbounded_String("import"), Tokens.Import); O.FutureReservedWords.Insert(To_Unbounded_String("super"), Tokens.Super); O.FutureReservedWords.Insert(To_Unbounded_String("implements"), Tokens.Implements); O.FutureReservedWords.Insert(To_Unbounded_String("interface"), Tokens.InterfaceType); O.FutureReservedWords.Insert(To_Unbounded_String("let"), Tokens.Let); O.FutureReservedWords.Insert(To_Unbounded_String("package"), Tokens.PackageType); O.FutureReservedWords.Insert(To_Unbounded_String("private"), Tokens.PrivateScope); O.FutureReservedWords.Insert(To_Unbounded_String("protected"), Tokens.ProtectedScope); O.FutureReservedWords.Insert(To_Unbounded_String("public"), Tokens.Public); O.FutureReservedWords.Insert(To_Unbounded_String("static"), Tokens.Static); O.FutureReservedWords.Insert(To_Unbounded_String("yield"), Tokens.Yield); end Initialize; procedure Clear (O : in out Object) is begin O.Punctuators.Clear; O.Operators.Clear; O.Keywords.Clear; end Clear; end Punctuation;
adamnemecek/GA_Ada
Ada
605
ads
with GL.Objects.Programs; with GL.Types; with GL.Types.Colors; with C3GA; package C3GA_Draw is procedure Draw (Render_Program : GL.Objects.Programs.Program; Model_View_Matrix : GL.Types.Singles.Matrix4; aVector : C3GA.Vector_E3GA; Colour : GL.Types.Colors.Color; Scale : float := 1.0); procedure Draw (Render_Program : GL.Objects.Programs.Program; Model_View_Matrix : GL.Types.Singles.Matrix4; Point_Position : C3GA.Normalized_Point; Colour : GL.Types.Colors.Color); end C3GA_Draw;
persan/protobuf-ada
Ada
43
ads
package Benchmarks is end Benchmarks;
reznikmm/matreshka
Ada
6,961
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_Table.Table_Template_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Table_Table_Template_Element_Node is begin return Self : Table_Table_Template_Element_Node do Matreshka.ODF_Table.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Table_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Table_Table_Template_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Enter_Table_Table_Template (ODF.DOM.Table_Table_Template_Elements.ODF_Table_Table_Template_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Enter_Node (Visitor, Control); end if; end Enter_Node; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Table_Table_Template_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Table_Template_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Table_Table_Template_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Leave_Table_Table_Template (ODF.DOM.Table_Table_Template_Elements.ODF_Table_Table_Template_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Leave_Node (Visitor, Control); end if; end Leave_Node; ---------------- -- Visit_Node -- ---------------- overriding procedure Visit_Node (Self : not null access Table_Table_Template_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then ODF.DOM.Iterators.Abstract_ODF_Iterator'Class (Iterator).Visit_Table_Table_Template (Visitor, ODF.DOM.Table_Table_Template_Elements.ODF_Table_Table_Template_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Visit_Node (Iterator, Visitor, Control); end if; end Visit_Node; begin Matreshka.DOM_Documents.Register_Element (Matreshka.ODF_String_Constants.Table_URI, Matreshka.ODF_String_Constants.Table_Template_Element, Table_Table_Template_Element_Node'Tag); end Matreshka.ODF_Table.Table_Template_Elements;
zhmu/ananas
Ada
48,463
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- ADA.NUMERICS.GENERIC_COMPLEX_ARRAYS -- -- -- -- B o d y -- -- -- -- Copyright (C) 2006-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. -- -- -- ------------------------------------------------------------------------------ -- Preconditions, postconditions, ghost code, loop invariants and assertions -- in this unit are meant for analysis only, not for run-time checking, as it -- would be too costly otherwise. This is enforced by setting the assertion -- policy to Ignore. pragma Assertion_Policy (Pre => Ignore, Post => Ignore, Ghost => Ignore, Loop_Invariant => Ignore, Assert => Ignore); with System.Generic_Array_Operations; use System.Generic_Array_Operations; package body Ada.Numerics.Generic_Complex_Arrays is -- Operations that are defined in terms of operations on the type Real, -- such as addition, subtraction and scaling, are computed in the canonical -- way looping over all elements. package Ops renames System.Generic_Array_Operations; subtype Real is Real_Arrays.Real; -- Work around visibility bug ??? function Is_Non_Zero (X : Complex) return Boolean is (X /= (0.0, 0.0)); -- Needed by Back_Substitute procedure Back_Substitute is new Ops.Back_Substitute (Scalar => Complex, Matrix => Complex_Matrix, Is_Non_Zero => Is_Non_Zero); procedure Forward_Eliminate is new Ops.Forward_Eliminate (Scalar => Complex, Real => Real'Base, Matrix => Complex_Matrix, Zero => (0.0, 0.0), One => (1.0, 0.0)); procedure Transpose is new Ops.Transpose (Scalar => Complex, Matrix => Complex_Matrix); -- Helper function that raises a Constraint_Error is the argument is -- not a square matrix, and otherwise returns its length. function Length is new Square_Matrix_Length (Complex, Complex_Matrix); -- Instant a generic square root implementation here, in order to avoid -- instantiating a complete copy of Generic_Elementary_Functions. -- Speed of the square root is not a big concern here. function Sqrt is new Ops.Sqrt (Real'Base); -- Instantiating the following subprograms directly would lead to -- name clashes, so use a local package. package Instantiations is --------- -- "*" -- --------- function "*" is new Vector_Scalar_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Left_Vector => Complex_Vector, Result_Vector => Complex_Vector, Operation => "*"); function "*" is new Vector_Scalar_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Vector => Complex_Vector, Result_Vector => Complex_Vector, Operation => "*"); function "*" is new Scalar_Vector_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Right_Vector => Complex_Vector, Result_Vector => Complex_Vector, Operation => "*"); function "*" is new Scalar_Vector_Elementwise_Operation (Left_Scalar => Real'Base, Right_Scalar => Complex, Result_Scalar => Complex, Right_Vector => Complex_Vector, Result_Vector => Complex_Vector, Operation => "*"); function "*" is new Inner_Product (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Vector => Complex_Vector, Right_Vector => Real_Vector, Zero => (0.0, 0.0)); function "*" is new Inner_Product (Left_Scalar => Real'Base, Right_Scalar => Complex, Result_Scalar => Complex, Left_Vector => Real_Vector, Right_Vector => Complex_Vector, Zero => (0.0, 0.0)); function "*" is new Inner_Product (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Left_Vector => Complex_Vector, Right_Vector => Complex_Vector, Zero => (0.0, 0.0)); function "*" is new Outer_Product (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Left_Vector => Complex_Vector, Right_Vector => Complex_Vector, Matrix => Complex_Matrix); function "*" is new Outer_Product (Left_Scalar => Real'Base, Right_Scalar => Complex, Result_Scalar => Complex, Left_Vector => Real_Vector, Right_Vector => Complex_Vector, Matrix => Complex_Matrix); function "*" is new Outer_Product (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Vector => Complex_Vector, Right_Vector => Real_Vector, Matrix => Complex_Matrix); function "*" is new Matrix_Scalar_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Left_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Operation => "*"); function "*" is new Matrix_Scalar_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Operation => "*"); function "*" is new Scalar_Matrix_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Right_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Operation => "*"); function "*" is new Scalar_Matrix_Elementwise_Operation (Left_Scalar => Real'Base, Right_Scalar => Complex, Result_Scalar => Complex, Right_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Operation => "*"); function "*" is new Matrix_Vector_Product (Left_Scalar => Real'Base, Right_Scalar => Complex, Result_Scalar => Complex, Matrix => Real_Matrix, Right_Vector => Complex_Vector, Result_Vector => Complex_Vector, Zero => (0.0, 0.0)); function "*" is new Matrix_Vector_Product (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Complex, Matrix => Complex_Matrix, Right_Vector => Real_Vector, Result_Vector => Complex_Vector, Zero => (0.0, 0.0)); function "*" is new Matrix_Vector_Product (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Matrix => Complex_Matrix, Right_Vector => Complex_Vector, Result_Vector => Complex_Vector, Zero => (0.0, 0.0)); function "*" is new Vector_Matrix_Product (Left_Scalar => Real'Base, Right_Scalar => Complex, Result_Scalar => Complex, Left_Vector => Real_Vector, Matrix => Complex_Matrix, Result_Vector => Complex_Vector, Zero => (0.0, 0.0)); function "*" is new Vector_Matrix_Product (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Vector => Complex_Vector, Matrix => Real_Matrix, Result_Vector => Complex_Vector, Zero => (0.0, 0.0)); function "*" is new Vector_Matrix_Product (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Left_Vector => Complex_Vector, Matrix => Complex_Matrix, Result_Vector => Complex_Vector, Zero => (0.0, 0.0)); function "*" is new Matrix_Matrix_Product (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Left_Matrix => Complex_Matrix, Right_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Zero => (0.0, 0.0)); function "*" is new Matrix_Matrix_Product (Left_Scalar => Real'Base, Right_Scalar => Complex, Result_Scalar => Complex, Left_Matrix => Real_Matrix, Right_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Zero => (0.0, 0.0)); function "*" is new Matrix_Matrix_Product (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Matrix => Complex_Matrix, Right_Matrix => Real_Matrix, Result_Matrix => Complex_Matrix, Zero => (0.0, 0.0)); --------- -- "+" -- --------- function "+" is new Vector_Elementwise_Operation (X_Scalar => Complex, Result_Scalar => Complex, X_Vector => Complex_Vector, Result_Vector => Complex_Vector, Operation => "+"); function "+" is new Vector_Vector_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Left_Vector => Complex_Vector, Right_Vector => Complex_Vector, Result_Vector => Complex_Vector, Operation => "+"); function "+" is new Vector_Vector_Elementwise_Operation (Left_Scalar => Real'Base, Right_Scalar => Complex, Result_Scalar => Complex, Left_Vector => Real_Vector, Right_Vector => Complex_Vector, Result_Vector => Complex_Vector, Operation => "+"); function "+" is new Vector_Vector_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Vector => Complex_Vector, Right_Vector => Real_Vector, Result_Vector => Complex_Vector, Operation => "+"); function "+" is new Matrix_Elementwise_Operation (X_Scalar => Complex, Result_Scalar => Complex, X_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Operation => "+"); function "+" is new Matrix_Matrix_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Left_Matrix => Complex_Matrix, Right_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Operation => "+"); function "+" is new Matrix_Matrix_Elementwise_Operation (Left_Scalar => Real'Base, Right_Scalar => Complex, Result_Scalar => Complex, Left_Matrix => Real_Matrix, Right_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Operation => "+"); function "+" is new Matrix_Matrix_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Matrix => Complex_Matrix, Right_Matrix => Real_Matrix, Result_Matrix => Complex_Matrix, Operation => "+"); --------- -- "-" -- --------- function "-" is new Vector_Elementwise_Operation (X_Scalar => Complex, Result_Scalar => Complex, X_Vector => Complex_Vector, Result_Vector => Complex_Vector, Operation => "-"); function "-" is new Vector_Vector_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Left_Vector => Complex_Vector, Right_Vector => Complex_Vector, Result_Vector => Complex_Vector, Operation => "-"); function "-" is new Vector_Vector_Elementwise_Operation (Left_Scalar => Real'Base, Right_Scalar => Complex, Result_Scalar => Complex, Left_Vector => Real_Vector, Right_Vector => Complex_Vector, Result_Vector => Complex_Vector, Operation => "-"); function "-" is new Vector_Vector_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Vector => Complex_Vector, Right_Vector => Real_Vector, Result_Vector => Complex_Vector, Operation => "-"); function "-" is new Matrix_Elementwise_Operation (X_Scalar => Complex, Result_Scalar => Complex, X_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Operation => "-"); function "-" is new Matrix_Matrix_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Left_Matrix => Complex_Matrix, Right_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Operation => "-"); function "-" is new Matrix_Matrix_Elementwise_Operation (Left_Scalar => Real'Base, Right_Scalar => Complex, Result_Scalar => Complex, Left_Matrix => Real_Matrix, Right_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Operation => "-"); function "-" is new Matrix_Matrix_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Matrix => Complex_Matrix, Right_Matrix => Real_Matrix, Result_Matrix => Complex_Matrix, Operation => "-"); --------- -- "/" -- --------- function "/" is new Vector_Scalar_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Left_Vector => Complex_Vector, Result_Vector => Complex_Vector, Operation => "/"); function "/" is new Vector_Scalar_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Vector => Complex_Vector, Result_Vector => Complex_Vector, Operation => "/"); function "/" is new Matrix_Scalar_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Complex, Result_Scalar => Complex, Left_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Operation => "/"); function "/" is new Matrix_Scalar_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Operation => "/"); ----------- -- "abs" -- ----------- function "abs" is new L2_Norm (X_Scalar => Complex, Result_Real => Real'Base, X_Vector => Complex_Vector); -------------- -- Argument -- -------------- function Argument is new Vector_Elementwise_Operation (X_Scalar => Complex, Result_Scalar => Real'Base, X_Vector => Complex_Vector, Result_Vector => Real_Vector, Operation => Argument); function Argument is new Vector_Scalar_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Real'Base, Left_Vector => Complex_Vector, Result_Vector => Real_Vector, Operation => Argument); function Argument is new Matrix_Elementwise_Operation (X_Scalar => Complex, Result_Scalar => Real'Base, X_Matrix => Complex_Matrix, Result_Matrix => Real_Matrix, Operation => Argument); function Argument is new Matrix_Scalar_Elementwise_Operation (Left_Scalar => Complex, Right_Scalar => Real'Base, Result_Scalar => Real'Base, Left_Matrix => Complex_Matrix, Result_Matrix => Real_Matrix, Operation => Argument); ---------------------------- -- Compose_From_Cartesian -- ---------------------------- function Compose_From_Cartesian is new Vector_Elementwise_Operation (X_Scalar => Real'Base, Result_Scalar => Complex, X_Vector => Real_Vector, Result_Vector => Complex_Vector, Operation => Compose_From_Cartesian); function Compose_From_Cartesian is new Vector_Vector_Elementwise_Operation (Left_Scalar => Real'Base, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Vector => Real_Vector, Right_Vector => Real_Vector, Result_Vector => Complex_Vector, Operation => Compose_From_Cartesian); function Compose_From_Cartesian is new Matrix_Elementwise_Operation (X_Scalar => Real'Base, Result_Scalar => Complex, X_Matrix => Real_Matrix, Result_Matrix => Complex_Matrix, Operation => Compose_From_Cartesian); function Compose_From_Cartesian is new Matrix_Matrix_Elementwise_Operation (Left_Scalar => Real'Base, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Matrix => Real_Matrix, Right_Matrix => Real_Matrix, Result_Matrix => Complex_Matrix, Operation => Compose_From_Cartesian); ------------------------ -- Compose_From_Polar -- ------------------------ function Compose_From_Polar is new Vector_Vector_Elementwise_Operation (Left_Scalar => Real'Base, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Vector => Real_Vector, Right_Vector => Real_Vector, Result_Vector => Complex_Vector, Operation => Compose_From_Polar); function Compose_From_Polar is new Vector_Vector_Scalar_Elementwise_Operation (X_Scalar => Real'Base, Y_Scalar => Real'Base, Z_Scalar => Real'Base, Result_Scalar => Complex, X_Vector => Real_Vector, Y_Vector => Real_Vector, Result_Vector => Complex_Vector, Operation => Compose_From_Polar); function Compose_From_Polar is new Matrix_Matrix_Elementwise_Operation (Left_Scalar => Real'Base, Right_Scalar => Real'Base, Result_Scalar => Complex, Left_Matrix => Real_Matrix, Right_Matrix => Real_Matrix, Result_Matrix => Complex_Matrix, Operation => Compose_From_Polar); function Compose_From_Polar is new Matrix_Matrix_Scalar_Elementwise_Operation (X_Scalar => Real'Base, Y_Scalar => Real'Base, Z_Scalar => Real'Base, Result_Scalar => Complex, X_Matrix => Real_Matrix, Y_Matrix => Real_Matrix, Result_Matrix => Complex_Matrix, Operation => Compose_From_Polar); --------------- -- Conjugate -- --------------- function Conjugate is new Vector_Elementwise_Operation (X_Scalar => Complex, Result_Scalar => Complex, X_Vector => Complex_Vector, Result_Vector => Complex_Vector, Operation => Conjugate); function Conjugate is new Matrix_Elementwise_Operation (X_Scalar => Complex, Result_Scalar => Complex, X_Matrix => Complex_Matrix, Result_Matrix => Complex_Matrix, Operation => Conjugate); -------- -- Im -- -------- function Im is new Vector_Elementwise_Operation (X_Scalar => Complex, Result_Scalar => Real'Base, X_Vector => Complex_Vector, Result_Vector => Real_Vector, Operation => Im); function Im is new Matrix_Elementwise_Operation (X_Scalar => Complex, Result_Scalar => Real'Base, X_Matrix => Complex_Matrix, Result_Matrix => Real_Matrix, Operation => Im); ------------- -- Modulus -- ------------- function Modulus is new Vector_Elementwise_Operation (X_Scalar => Complex, Result_Scalar => Real'Base, X_Vector => Complex_Vector, Result_Vector => Real_Vector, Operation => Modulus); function Modulus is new Matrix_Elementwise_Operation (X_Scalar => Complex, Result_Scalar => Real'Base, X_Matrix => Complex_Matrix, Result_Matrix => Real_Matrix, Operation => Modulus); -------- -- Re -- -------- function Re is new Vector_Elementwise_Operation (X_Scalar => Complex, Result_Scalar => Real'Base, X_Vector => Complex_Vector, Result_Vector => Real_Vector, Operation => Re); function Re is new Matrix_Elementwise_Operation (X_Scalar => Complex, Result_Scalar => Real'Base, X_Matrix => Complex_Matrix, Result_Matrix => Real_Matrix, Operation => Re); ------------ -- Set_Im -- ------------ procedure Set_Im is new Update_Vector_With_Vector (X_Scalar => Complex, Y_Scalar => Real'Base, X_Vector => Complex_Vector, Y_Vector => Real_Vector, Update => Set_Im); procedure Set_Im is new Update_Matrix_With_Matrix (X_Scalar => Complex, Y_Scalar => Real'Base, X_Matrix => Complex_Matrix, Y_Matrix => Real_Matrix, Update => Set_Im); ------------ -- Set_Re -- ------------ procedure Set_Re is new Update_Vector_With_Vector (X_Scalar => Complex, Y_Scalar => Real'Base, X_Vector => Complex_Vector, Y_Vector => Real_Vector, Update => Set_Re); procedure Set_Re is new Update_Matrix_With_Matrix (X_Scalar => Complex, Y_Scalar => Real'Base, X_Matrix => Complex_Matrix, Y_Matrix => Real_Matrix, Update => Set_Re); ----------- -- Solve -- ----------- function Solve is new Matrix_Vector_Solution (Complex, (0.0, 0.0), Complex_Vector, Complex_Matrix); function Solve is new Matrix_Matrix_Solution (Complex, (0.0, 0.0), Complex_Matrix); ----------------- -- Unit_Matrix -- ----------------- function Unit_Matrix is new System.Generic_Array_Operations.Unit_Matrix (Scalar => Complex, Matrix => Complex_Matrix, Zero => (0.0, 0.0), One => (1.0, 0.0)); function Unit_Vector is new System.Generic_Array_Operations.Unit_Vector (Scalar => Complex, Vector => Complex_Vector, Zero => (0.0, 0.0), One => (1.0, 0.0)); end Instantiations; --------- -- "*" -- --------- function "*" (Left : Complex_Vector; Right : Complex_Vector) return Complex renames Instantiations."*"; function "*" (Left : Real_Vector; Right : Complex_Vector) return Complex renames Instantiations."*"; function "*" (Left : Complex_Vector; Right : Real_Vector) return Complex renames Instantiations."*"; function "*" (Left : Complex; Right : Complex_Vector) return Complex_Vector renames Instantiations."*"; function "*" (Left : Complex_Vector; Right : Complex) return Complex_Vector renames Instantiations."*"; function "*" (Left : Real'Base; Right : Complex_Vector) return Complex_Vector renames Instantiations."*"; function "*" (Left : Complex_Vector; Right : Real'Base) return Complex_Vector renames Instantiations."*"; function "*" (Left : Complex_Matrix; Right : Complex_Matrix) return Complex_Matrix renames Instantiations."*"; function "*" (Left : Complex_Vector; Right : Complex_Vector) return Complex_Matrix renames Instantiations."*"; function "*" (Left : Complex_Vector; Right : Complex_Matrix) return Complex_Vector renames Instantiations."*"; function "*" (Left : Complex_Matrix; Right : Complex_Vector) return Complex_Vector renames Instantiations."*"; function "*" (Left : Real_Matrix; Right : Complex_Matrix) return Complex_Matrix renames Instantiations."*"; function "*" (Left : Complex_Matrix; Right : Real_Matrix) return Complex_Matrix renames Instantiations."*"; function "*" (Left : Real_Vector; Right : Complex_Vector) return Complex_Matrix renames Instantiations."*"; function "*" (Left : Complex_Vector; Right : Real_Vector) return Complex_Matrix renames Instantiations."*"; function "*" (Left : Real_Vector; Right : Complex_Matrix) return Complex_Vector renames Instantiations."*"; function "*" (Left : Complex_Vector; Right : Real_Matrix) return Complex_Vector renames Instantiations."*"; function "*" (Left : Real_Matrix; Right : Complex_Vector) return Complex_Vector renames Instantiations."*"; function "*" (Left : Complex_Matrix; Right : Real_Vector) return Complex_Vector renames Instantiations."*"; function "*" (Left : Complex; Right : Complex_Matrix) return Complex_Matrix renames Instantiations."*"; function "*" (Left : Complex_Matrix; Right : Complex) return Complex_Matrix renames Instantiations."*"; function "*" (Left : Real'Base; Right : Complex_Matrix) return Complex_Matrix renames Instantiations."*"; function "*" (Left : Complex_Matrix; Right : Real'Base) return Complex_Matrix renames Instantiations."*"; --------- -- "+" -- --------- function "+" (Right : Complex_Vector) return Complex_Vector renames Instantiations."+"; function "+" (Left : Complex_Vector; Right : Complex_Vector) return Complex_Vector renames Instantiations."+"; function "+" (Left : Real_Vector; Right : Complex_Vector) return Complex_Vector renames Instantiations."+"; function "+" (Left : Complex_Vector; Right : Real_Vector) return Complex_Vector renames Instantiations."+"; function "+" (Right : Complex_Matrix) return Complex_Matrix renames Instantiations."+"; function "+" (Left : Complex_Matrix; Right : Complex_Matrix) return Complex_Matrix renames Instantiations."+"; function "+" (Left : Real_Matrix; Right : Complex_Matrix) return Complex_Matrix renames Instantiations."+"; function "+" (Left : Complex_Matrix; Right : Real_Matrix) return Complex_Matrix renames Instantiations."+"; --------- -- "-" -- --------- function "-" (Right : Complex_Vector) return Complex_Vector renames Instantiations."-"; function "-" (Left : Complex_Vector; Right : Complex_Vector) return Complex_Vector renames Instantiations."-"; function "-" (Left : Real_Vector; Right : Complex_Vector) return Complex_Vector renames Instantiations."-"; function "-" (Left : Complex_Vector; Right : Real_Vector) return Complex_Vector renames Instantiations."-"; function "-" (Right : Complex_Matrix) return Complex_Matrix renames Instantiations."-"; function "-" (Left : Complex_Matrix; Right : Complex_Matrix) return Complex_Matrix renames Instantiations."-"; function "-" (Left : Real_Matrix; Right : Complex_Matrix) return Complex_Matrix renames Instantiations."-"; function "-" (Left : Complex_Matrix; Right : Real_Matrix) return Complex_Matrix renames Instantiations."-"; --------- -- "/" -- --------- function "/" (Left : Complex_Vector; Right : Complex) return Complex_Vector renames Instantiations."/"; function "/" (Left : Complex_Vector; Right : Real'Base) return Complex_Vector renames Instantiations."/"; function "/" (Left : Complex_Matrix; Right : Complex) return Complex_Matrix renames Instantiations."/"; function "/" (Left : Complex_Matrix; Right : Real'Base) return Complex_Matrix renames Instantiations."/"; ----------- -- "abs" -- ----------- function "abs" (Right : Complex_Vector) return Real'Base renames Instantiations."abs"; -------------- -- Argument -- -------------- function Argument (X : Complex_Vector) return Real_Vector renames Instantiations.Argument; function Argument (X : Complex_Vector; Cycle : Real'Base) return Real_Vector renames Instantiations.Argument; function Argument (X : Complex_Matrix) return Real_Matrix renames Instantiations.Argument; function Argument (X : Complex_Matrix; Cycle : Real'Base) return Real_Matrix renames Instantiations.Argument; ---------------------------- -- Compose_From_Cartesian -- ---------------------------- function Compose_From_Cartesian (Re : Real_Vector) return Complex_Vector renames Instantiations.Compose_From_Cartesian; function Compose_From_Cartesian (Re : Real_Vector; Im : Real_Vector) return Complex_Vector renames Instantiations.Compose_From_Cartesian; function Compose_From_Cartesian (Re : Real_Matrix) return Complex_Matrix renames Instantiations.Compose_From_Cartesian; function Compose_From_Cartesian (Re : Real_Matrix; Im : Real_Matrix) return Complex_Matrix renames Instantiations.Compose_From_Cartesian; ------------------------ -- Compose_From_Polar -- ------------------------ function Compose_From_Polar (Modulus : Real_Vector; Argument : Real_Vector) return Complex_Vector renames Instantiations.Compose_From_Polar; function Compose_From_Polar (Modulus : Real_Vector; Argument : Real_Vector; Cycle : Real'Base) return Complex_Vector renames Instantiations.Compose_From_Polar; function Compose_From_Polar (Modulus : Real_Matrix; Argument : Real_Matrix) return Complex_Matrix renames Instantiations.Compose_From_Polar; function Compose_From_Polar (Modulus : Real_Matrix; Argument : Real_Matrix; Cycle : Real'Base) return Complex_Matrix renames Instantiations.Compose_From_Polar; --------------- -- Conjugate -- --------------- function Conjugate (X : Complex_Vector) return Complex_Vector renames Instantiations.Conjugate; function Conjugate (X : Complex_Matrix) return Complex_Matrix renames Instantiations.Conjugate; ----------------- -- Determinant -- ----------------- function Determinant (A : Complex_Matrix) return Complex is M : Complex_Matrix := A; B : Complex_Matrix (A'Range (1), 1 .. 0); R : Complex; begin Forward_Eliminate (M, B, R); return R; end Determinant; ----------------- -- Eigensystem -- ----------------- procedure Eigensystem (A : Complex_Matrix; Values : out Real_Vector; Vectors : out Complex_Matrix) is N : constant Natural := Length (A); -- For a Hermitian matrix C, we convert the eigenvalue problem to a -- real symmetric one: if C = A + i * B, then the (N, N) complex -- eigenvalue problem: -- (A + i * B) * (u + i * v) = Lambda * (u + i * v) -- -- is equivalent to the (2 * N, 2 * N) real eigenvalue problem: -- [ A, B ] [ u ] = Lambda * [ u ] -- [ -B, A ] [ v ] [ v ] -- -- Note that the (2 * N, 2 * N) matrix above is symmetric, as -- Transpose (A) = A and Transpose (B) = -B if C is Hermitian. -- We solve this eigensystem using the real-valued algorithms. The final -- result will have every eigenvalue twice, so in the sorted output we -- just pick every second value, with associated eigenvector u + i * v. M : Real_Matrix (1 .. 2 * N, 1 .. 2 * N); Vals : Real_Vector (1 .. 2 * N); Vecs : Real_Matrix (1 .. 2 * N, 1 .. 2 * N); begin for J in 1 .. N loop for K in 1 .. N loop declare C : constant Complex := (A (A'First (1) + (J - 1), A'First (2) + (K - 1))); begin M (J, K) := Re (C); M (J + N, K + N) := Re (C); M (J + N, K) := Im (C); M (J, K + N) := -Im (C); end; end loop; end loop; Eigensystem (M, Vals, Vecs); for J in 1 .. N loop declare Col : constant Integer := Values'First + (J - 1); begin Values (Col) := Vals (2 * J); for K in 1 .. N loop declare Row : constant Integer := Vectors'First (2) + (K - 1); begin Vectors (Row, Col) := (Vecs (J * 2, Col), Vecs (J * 2, Col + N)); end; end loop; end; end loop; end Eigensystem; ----------------- -- Eigenvalues -- ----------------- function Eigenvalues (A : Complex_Matrix) return Real_Vector is -- See Eigensystem for a description of the algorithm N : constant Natural := Length (A); R : Real_Vector (A'Range (1)); M : Real_Matrix (1 .. 2 * N, 1 .. 2 * N); Vals : Real_Vector (1 .. 2 * N); begin for J in 1 .. N loop for K in 1 .. N loop declare C : constant Complex := (A (A'First (1) + (J - 1), A'First (2) + (K - 1))); begin M (J, K) := Re (C); M (J + N, K + N) := Re (C); M (J + N, K) := Im (C); M (J, K + N) := -Im (C); end; end loop; end loop; Vals := Eigenvalues (M); for J in 1 .. N loop R (A'First (1) + (J - 1)) := Vals (2 * J); end loop; return R; end Eigenvalues; -------- -- Im -- -------- function Im (X : Complex_Vector) return Real_Vector renames Instantiations.Im; function Im (X : Complex_Matrix) return Real_Matrix renames Instantiations.Im; ------------- -- Inverse -- ------------- function Inverse (A : Complex_Matrix) return Complex_Matrix is (Solve (A, Unit_Matrix (Length (A), First_1 => A'First (2), First_2 => A'First (1)))); ------------- -- Modulus -- ------------- function Modulus (X : Complex_Vector) return Real_Vector renames Instantiations.Modulus; function Modulus (X : Complex_Matrix) return Real_Matrix renames Instantiations.Modulus; -------- -- Re -- -------- function Re (X : Complex_Vector) return Real_Vector renames Instantiations.Re; function Re (X : Complex_Matrix) return Real_Matrix renames Instantiations.Re; ------------ -- Set_Im -- ------------ procedure Set_Im (X : in out Complex_Matrix; Im : Real_Matrix) renames Instantiations.Set_Im; procedure Set_Im (X : in out Complex_Vector; Im : Real_Vector) renames Instantiations.Set_Im; ------------ -- Set_Re -- ------------ procedure Set_Re (X : in out Complex_Matrix; Re : Real_Matrix) renames Instantiations.Set_Re; procedure Set_Re (X : in out Complex_Vector; Re : Real_Vector) renames Instantiations.Set_Re; ----------- -- Solve -- ----------- function Solve (A : Complex_Matrix; X : Complex_Vector) return Complex_Vector renames Instantiations.Solve; function Solve (A : Complex_Matrix; X : Complex_Matrix) return Complex_Matrix renames Instantiations.Solve; --------------- -- Transpose -- --------------- function Transpose (X : Complex_Matrix) return Complex_Matrix is R : Complex_Matrix (X'Range (2), X'Range (1)); begin Transpose (X, R); return R; end Transpose; ----------------- -- Unit_Matrix -- ----------------- function Unit_Matrix (Order : Positive; First_1 : Integer := 1; First_2 : Integer := 1) return Complex_Matrix renames Instantiations.Unit_Matrix; ----------------- -- Unit_Vector -- ----------------- function Unit_Vector (Index : Integer; Order : Positive; First : Integer := 1) return Complex_Vector renames Instantiations.Unit_Vector; end Ada.Numerics.Generic_Complex_Arrays;
mitchelhaan/ncurses
Ada
3,584
ads
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding -- -- -- -- Terminal_Interface.Curses.Text_IO.Fixed_IO -- -- -- -- S P E C -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Juergen Pfeifer <[email protected]> 1996 -- Version Control: -- $Revision: 1.7 $ -- Binding Version 00.93 ------------------------------------------------------------------------------ generic type Num is delta <>; package Terminal_Interface.Curses.Text_IO.Fixed_IO is Default_Fore : Field := Num'Fore; Default_Aft : Field := Num'Aft; Default_Exp : Field := 0; procedure Put (Win : in Window; Item : in Num; Fore : in Field := Default_Fore; Aft : in Field := Default_Aft; Exp : in Field := Default_Exp); procedure Put (Item : in Num; Fore : in Field := Default_Fore; Aft : in Field := Default_Aft; Exp : in Field := Default_Exp); private pragma Inline (Put); end Terminal_Interface.Curses.Text_IO.Fixed_IO;
guillaume-lin/tsc
Ada
6,836
adb
------------------------------------------------------------------------------ -- -- -- 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 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ with ncurses2.util; use ncurses2.util; with Terminal_Interface.Curses; use Terminal_Interface.Curses; -- test effects of overlapping windows procedure ncurses2.overlap_test is procedure fillwin (win : Window; ch : Character); procedure crosswin (win : Window; ch : Character); procedure fillwin (win : Window; ch : Character) is y1 : Line_Position; x1 : Column_Position; begin Get_Size (win, y1, x1); for y in 0 .. y1 - 1 loop Move_Cursor (win, y, 0); for x in 0 .. x1 - 1 loop Add (win, Ch => ch); end loop; end loop; exception when Curses_Exception => null; -- write to lower right corner end fillwin; procedure crosswin (win : Window; ch : Character) is y1 : Line_Position; x1 : Column_Position; begin Get_Size (win, y1, x1); for y in 0 .. y1 - 1 loop for x in 0 .. x1 - 1 loop if (((x > (x1 - 1) / 3) and (x <= (2 * (x1 - 1)) / 3)) or (((y > (y1 - 1) / 3) and (y <= (2 * (y1 - 1)) / 3)))) then Move_Cursor (win, y, x); Add (win, Ch => ch); end if; end loop; end loop; end crosswin; -- In a 24x80 screen like some xterms are, the instructions will -- be overwritten. ch : Character; win1 : Window := New_Window (9, 20, 3, 3); win2 : Window := New_Window (9, 20, 9, 16); begin Set_Raw_Mode (SwitchOn => True); Refresh; Move_Cursor (Line => 0, Column => 0); Add (Str => "This test shows the behavior of wnoutrefresh() with " & "respect to"); Add (Ch => newl); Add (Str => "the shared region of two overlapping windows A and B. "& "The cross"); Add (Ch => newl); Add (Str => "pattern in each window does not overlap the other."); Add (Ch => newl); Move_Cursor (Line => 18, Column => 0); Add (Str => "a = refresh A, then B, then doupdate. b = refresh B, " & "then A, then doupdaute"); Add (Ch => newl); Add (Str => "c = fill window A with letter A. d = fill window B " & "with letter B."); Add (Ch => newl); Add (Str => "e = cross pattern in window A. f = cross pattern " & "in window B."); Add (Ch => newl); Add (Str => "g = clear window A. h = clear window B."); Add (Ch => newl); Add (Str => "i = overwrite A onto B. j = overwrite " & "B onto A."); Add (Ch => newl); Add (Str => "^Q/ESC = terminate test."); loop ch := Code_To_Char (Getchar); exit when ch = CTRL ('Q') or ch = CTRL ('['); -- QUIT or ESCAPE case ch is when 'a' => -- refresh window A first, then B Refresh_Without_Update (win1); Refresh_Without_Update (win2); Update_Screen; when 'b' => -- refresh window B first, then A Refresh_Without_Update (win2); Refresh_Without_Update (win1); Update_Screen; when 'c' => -- fill window A so it's visible fillwin (win1, 'A'); when 'd' => -- fill window B so it's visible fillwin (win2, 'B'); when 'e' => -- cross test pattern in window A crosswin (win1, 'A'); when 'f' => -- cross test pattern in window B crosswin (win2, 'B'); when 'g' => -- clear window A Clear (win1); Move_Cursor (win1, 0, 0); when 'h' => -- clear window B Clear (win2); Move_Cursor (win2, 0, 0); when 'i' => -- overwrite A onto B Overwrite (win1, win2); when 'j' => -- overwrite B onto A Overwrite (win2, win1); when others => null; end case; end loop; Delete (win2); Delete (win1); Erase; End_Windows; end ncurses2.overlap_test;
kjseefried/coreland-cgbc
Ada
838
adb
with Ada.Strings; with CGBC.Bounded_Strings; with Test; procedure T_Bstr_Append_LB01 is package BS renames CGBC.Bounded_Strings; TC : Test.Context_t; S1 : BS.Bounded_String (8); S : constant String := " 012345678 "; begin Test.Initialize (Test_Context => TC, Program => "t_bstr_append_lb01", Test_DB => "TEST_DB", Test_Results => "TEST_RESULTS"); BS.Append (S1, "ABCD"); pragma Assert (S (9 .. 17) = "012345678"); BS.Append (Source => S1, New_Item => S (9 .. 17), Drop => Ada.Strings.Left); Test.Check (TC, 218, BS.Length (S1) = 8, "BS.Length (S1) = 8"); Test.Check (TC, 219, BS.Maximum_Length (S1) = 8, "BS.Maximum_Length (S1) = 8"); Test.Check (TC, 220, BS.To_String (S1) = "12345678", "BS.To_String (S1) = ""12345678"""); end T_Bstr_Append_LB01;
etorri/protobuf-ada
Ada
953
ads
-- Package used by generated code to generate special default values -- (Inf, -Inf and NaN) for PB_Float and PB_Double. This might not be portable, -- consider replacing with something that is??? pragma Ada_2012; with Protocol_Buffers.Wire_Format; package Protocol_Buffers.Generated_Message_Utilities is -- Protocol_Buffers.Wire_Format.PB_Float function Positive_Infinity return Protocol_Buffers.Wire_Format.PB_Float; function Negative_Infinity return Protocol_Buffers.Wire_Format.PB_Float; function NaN return Protocol_Buffers.Wire_Format.PB_Float; -- Protocol_Buffers.Wire_Format.PB_Double function Positive_Infinity return Protocol_Buffers.Wire_Format.PB_Double; function Negative_Infinity return Protocol_Buffers.Wire_Format.PB_Double; function NaN return Protocol_Buffers.Wire_Format.PB_Double; EMPTY_STRING : aliased Protocol_Buffers.Wire_Format.PB_String := ""; end Protocol_Buffers.Generated_Message_Utilities;
mgrojo/smk
Ada
5,347
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.IO body -- -- Implementation Notes: -- -- Portability Issues: -- -- Anticipated Changes: -- -- ----------------------------------------------------------------------------- with Ada.Calendar.Formatting; with Ada.Calendar.Time_Zones; with Ada.Strings; with Ada.Strings.Fixed; with Ada.Text_IO; package body Smk.IO is Warnings : Natural := 0; -- -------------------------------------------------------------------------- -- Function: GNU_Prefix -- -- Purpose: -- This function return a source/line/column prefix to messages compatible -- whith GNU Standard -- (refer to <https://www.gnu.org/prep/standards/html_node/Errors.html>), -- That is : -- > program:sourcefile:lineno: message -- when there is an appropriate source file, or : -- > program: message -- otherwise. -- -- -------------------------------------------------------------------------- function GNU_Prefix (File : in String; Line : in Integer := 0) return String is use Ada.Strings; use Ada.Strings.Fixed; Trimed_File : constant String := Trim (File, Side => Both); Trimed_Line : constant String := Trim (Positive'Image (Line), Side => Both); Common_Part : constant String := "smk:" & Trimed_File; begin if File = "" then return ""; elsif Line = 0 then return Common_Part & " "; else return Common_Part & ":" & Trimed_Line & ": "; end if; end GNU_Prefix; -- -------------------------------------------------------------------------- procedure Put_Warning (Msg : in String; File : in String := ""; Line : in Integer := 0) is begin Warnings := Warnings + 1; Put_Line ("Warning : " & Msg, File, Line); -- use the local version of Put_Line, and not the Ada.Text_IO one, -- so that Warning messages are also ignored when --quiet. end Put_Warning; Errors : Natural := 0; -- -------------------------------------------------------------------------- procedure Put_Error (Msg : in String; File : in String := ""; Line : in Integer := 0) is begin Errors := Errors + 1; Put_Line ("Error : " & Msg, File, Line, Level => Quiet); -- Quiet because Error Msg should not be ignored end Put_Error; -- -------------------------------------------------------------------------- procedure Put_Exception (Msg : in String; File : in String := ""; Line : in Integer := 0) is begin Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error, GNU_Prefix (File, Line) & "Exception : " & Msg); end Put_Exception; -- -------------------------------------------------------------------------- function Error_Count return Natural is (Errors); function Warning_Count return Natural is (Warnings); -- -------------------------------------------------------------------------- procedure Put_Debug_Line (Msg : in String; Debug : in Boolean; Prefix : in String; File : in String := ""; Line : in Integer := 0) is begin if Debug then Ada.Text_IO.Put_Line (GNU_Prefix (File, Line) & Prefix & Msg); end if; end Put_Debug_Line; -- -------------------------------------------------------------------------- procedure Put_Line (Item : String; File : in String := ""; Line : in Integer := 0; Level : Print_Out_Level := Normal) is begin if Level >= Settings.Verbosity then Ada.Text_IO.Put_Line (GNU_Prefix (File, Line) & Item); end if; end Put_Line; -- -------------------------------------------------------------------------- function Image (Time : in Ada.Calendar.Time) return String is begin return Ada.Calendar.Formatting.Image (Date => Time, Include_Time_Fraction => True, Time_Zone => Ada.Calendar.Time_Zones.UTC_Time_Offset); end Image; end Smk.IO;
adamnemecek/GA_Ada
Ada
773
ads
with E3GA; with GA_Maths; with Multivector; with Multivector_Analyze; with Multivector_Type; package E3GA_Utilities is -- special exp() for 3D bivectors function exp (BV : Multivector.Bivector) return Multivector.Rotor; -- special log() for 3D rotors function log (R : Multivector.Rotor) return Multivector.Bivector; procedure Print_Rotor (Name : String; R : Multivector.Rotor); -- procedure Print_Vector (Name : String; aVector : E2GA.Vector); -- procedure Print_Vector (Name : String; aVector : E3GA.Vector); procedure Rotor_To_Matrix (R : Multivector.Rotor; M : out GA_Maths.GA_Matrix3); function Rotor_Vector_To_Vector (From, To : Multivector.Vector) return Multivector.Rotor; end E3GA_Utilities;
AdaCore/Ada_Drivers_Library
Ada
3,038
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of 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 Ada.Interrupts.Names; use Ada.Interrupts.Names; with STM32F4_DMA_Interrupts; with STM32.Device; use STM32.Device; with STM32.DMA; use STM32.DMA; package Peripherals is Controller : DMA_Controller renames DMA_2; -- DMA_2 is required for memory-to-memory transfers, per the ST Micro -- reference manual RM0090, pg 308 Stream : constant DMA_Stream_Selector := Stream_0; IRQ_Id : constant Ada.Interrupts.Interrupt_ID := DMA2_Stream0_Interrupt; -- must match that of the selected controller and stream number!!!! IRQ_Handler : STM32F4_DMA_Interrupts.Handler (Controller'Access, Stream, IRQ_Id); end Peripherals;
PThierry/ewok-kernel
Ada
27
ads
../stm32f439/soc-system.ads
reznikmm/matreshka
Ada
3,744
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Complete Meta Object Facility -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011, 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.AMF_URI_Extents; package body AMF.Extents.Collections is ---------- -- Hash -- ---------- function Hash (Item : not null AMF.Extents.Extent_Access) return Ada.Containers.Hash_Type is begin return Ada.Containers.Hash_Type (AMF.Internals.AMF_URI_Extents.AMF_URI_Extent'Class (Item.all).Id); end Hash; end AMF.Extents.Collections;
sf17k/sdlada
Ada
2,089
ads
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2014-2015 Luke A. Guest -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- -- 1. The origin of this software must not be misrepresented; you must not -- claim that you wrote the original software. If you use this software -- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- -- 3. This notice may not be removed or altered from any source -- distribution. -------------------------------------------------------------------------------------------------------------------- -- SDL.Power -- -- Battery access on the target platform. -------------------------------------------------------------------------------------------------------------------- package SDL.Power is type State is (Unknown, -- Cannot determine power status. Battery, -- Not plugged in, running on the battery. No_Battery, -- Plugged in, no battery available. Charging, -- Plugged in, charging battery. Charged -- Plugged in, battery charged. ) with Convention => C; type Seconds is range 0 .. Integer'Last; type Percentage is range 0 .. 100; type Battery_Info is record Power_State : State; Time_Valid : Boolean; Time : Seconds; Percentage_Valid : Boolean; Percent : Percentage; end record; procedure Info (Data : in out Battery_Info); end SDL.Power;
reznikmm/matreshka
Ada
39,339
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.Internals.Strings.Configuration; with Matreshka.Internals.Unicode.Characters.Latin; with Matreshka.Internals.Utf16; package body Matreshka.Internals.Text_Codecs.IBM437 is use Matreshka.Internals.Strings.Configuration; use Matreshka.Internals.Unicode.Characters.Latin; use type Matreshka.Internals.Unicode.Code_Unit_32; use type Matreshka.Internals.Utf16.Utf16_String_Index; Decode_Table : constant array (Ada.Streams.Stream_Element range 16#80# .. 16#FF#) of Matreshka.Internals.Unicode.Code_Point := (16#80# => 16#00C7#, -- LATIN CAPITAL LETTER C WITH CEDILLA 16#81# => 16#00FC#, -- LATIN SMALL LETTER U WITH DIAERESIS 16#82# => 16#00E9#, -- LATIN SMALL LETTER E WITH ACUTE 16#83# => 16#00E2#, -- LATIN SMALL LETTER A WITH CIRCUMFLEX 16#84# => 16#00E4#, -- LATIN SMALL LETTER A WITH DIAERESIS 16#85# => 16#00E0#, -- LATIN SMALL LETTER A WITH GRAVE 16#86# => 16#00E5#, -- LATIN SMALL LETTER A WITH RING ABOVE 16#87# => 16#00E7#, -- LATIN SMALL LETTER C WITH CEDILLA 16#88# => 16#00EA#, -- LATIN SMALL LETTER E WITH CIRCUMFLEX 16#89# => 16#00EB#, -- LATIN SMALL LETTER E WITH DIAERESIS 16#8A# => 16#00E8#, -- LATIN SMALL LETTER E WITH GRAVE 16#8B# => 16#00EF#, -- LATIN SMALL LETTER I WITH DIAERESIS 16#8C# => 16#00EE#, -- LATIN SMALL LETTER I WITH CIRCUMFLEX 16#8D# => 16#00EC#, -- LATIN SMALL LETTER I WITH GRAVE 16#8E# => 16#00C4#, -- LATIN CAPITAL LETTER A WITH DIAERESIS 16#8F# => 16#00C5#, -- LATIN CAPITAL LETTER A WITH RING -- ABOVE 16#90# => 16#00C9#, -- LATIN CAPITAL LETTER E WITH ACUTE 16#91# => 16#00E6#, -- LATIN SMALL LETTER AE 16#92# => 16#00C6#, -- LATIN CAPITAL LETTER AE 16#93# => 16#00F4#, -- LATIN SMALL LETTER O WITH CIRCUMFLEX 16#94# => 16#00F6#, -- LATIN SMALL LETTER O WITH DIAERESIS 16#95# => 16#00F2#, -- LATIN SMALL LETTER O WITH GRAVE 16#96# => 16#00FB#, -- LATIN SMALL LETTER U WITH CIRCUMFLEX 16#97# => 16#00F9#, -- LATIN SMALL LETTER U WITH GRAVE 16#98# => 16#00FF#, -- LATIN SMALL LETTER Y WITH DIAERESIS 16#99# => 16#00D6#, -- LATIN CAPITAL LETTER O WITH DIAERESIS 16#9A# => 16#00DC#, -- LATIN CAPITAL LETTER U WITH DIAERESIS 16#9B# => 16#00A2#, -- CENT SIGN 16#9C# => 16#00A3#, -- POUND SIGN 16#9D# => 16#00A5#, -- YEN SIGN 16#9E# => 16#20A7#, -- PESETA SIGN 16#9F# => 16#0192#, -- LATIN SMALL LETTER F WITH HOOK 16#A0# => 16#00E1#, -- LATIN SMALL LETTER A WITH ACUTE 16#A1# => 16#00ED#, -- LATIN SMALL LETTER I WITH ACUTE 16#A2# => 16#00F3#, -- LATIN SMALL LETTER O WITH ACUTE 16#A3# => 16#00FA#, -- LATIN SMALL LETTER U WITH ACUTE 16#A4# => 16#00F1#, -- LATIN SMALL LETTER N WITH TILDE 16#A5# => 16#00D1#, -- LATIN CAPITAL LETTER N WITH TILDE 16#A6# => 16#00AA#, -- FEMININE ORDINAL INDICATOR 16#A7# => 16#00BA#, -- MASCULINE ORDINAL INDICATOR 16#A8# => 16#00BF#, -- INVERTED QUESTION MARK 16#A9# => 16#2310#, -- REVERSED NOT SIGN 16#AA# => 16#00AC#, -- NOT SIGN 16#AB# => 16#00BD#, -- VULGAR FRACTION ONE HALF 16#AC# => 16#00BC#, -- VULGAR FRACTION ONE QUARTER 16#AD# => 16#00A1#, -- INVERTED EXCLAMATION MARK 16#AE# => 16#00AB#, -- LEFT-POINTING DOUBLE ANGLE QUOTATION -- MARK 16#AF# => 16#00BB#, -- RIGHT-POINTING DOUBLE ANGLE QUOTATION -- MARK 16#B0# => 16#2591#, -- LIGHT SHADE 16#B1# => 16#2592#, -- MEDIUM SHADE 16#B2# => 16#2593#, -- DARK SHADE 16#B3# => 16#2502#, -- BOX DRAWINGS LIGHT VERTICAL 16#B4# => 16#2524#, -- BOX DRAWINGS LIGHT VERTICAL AND LEFT 16#B5# => 16#2561#, -- BOX DRAWINGS VERTICAL SINGLE AND LEFT -- DOUBLE 16#B6# => 16#2562#, -- BOX DRAWINGS VERTICAL DOUBLE AND LEFT -- SINGLE 16#B7# => 16#2556#, -- BOX DRAWINGS DOWN DOUBLE AND LEFT -- SINGLE 16#B8# => 16#2555#, -- BOX DRAWINGS DOWN SINGLE AND LEFT -- DOUBLE 16#B9# => 16#2563#, -- BOX DRAWINGS DOUBLE VERTICAL AND LEFT 16#BA# => 16#2551#, -- BOX DRAWINGS DOUBLE VERTICAL 16#BB# => 16#2557#, -- BOX DRAWINGS DOUBLE DOWN AND LEFT 16#BC# => 16#255D#, -- BOX DRAWINGS DOUBLE UP AND LEFT 16#BD# => 16#255C#, -- BOX DRAWINGS UP DOUBLE AND LEFT SINGLE 16#BE# => 16#255B#, -- BOX DRAWINGS UP SINGLE AND LEFT DOUBLE 16#BF# => 16#2510#, -- BOX DRAWINGS LIGHT DOWN AND LEFT 16#C0# => 16#2514#, -- BOX DRAWINGS LIGHT UP AND RIGHT 16#C1# => 16#2534#, -- BOX DRAWINGS LIGHT UP AND HORIZONTAL 16#C2# => 16#252C#, -- BOX DRAWINGS LIGHT DOWN AND HORIZONTAL 16#C3# => 16#251C#, -- BOX DRAWINGS LIGHT VERTICAL AND RIGHT 16#C4# => 16#2500#, -- BOX DRAWINGS LIGHT HORIZONTAL 16#C5# => 16#253C#, -- BOX DRAWINGS LIGHT VERTICAL AND -- HORIZONTAL 16#C6# => 16#255E#, -- BOX DRAWINGS VERTICAL SINGLE AND -- RIGHT DOUBLE 16#C7# => 16#255F#, -- BOX DRAWINGS VERTICAL DOUBLE AND -- RIGHT SINGLE 16#C8# => 16#255A#, -- BOX DRAWINGS DOUBLE UP AND RIGHT 16#C9# => 16#2554#, -- BOX DRAWINGS DOUBLE DOWN AND RIGHT 16#CA# => 16#2569#, -- BOX DRAWINGS DOUBLE UP AND HORIZONTAL 16#CB# => 16#2566#, -- BOX DRAWINGS DOUBLE DOWN AND -- HORIZONTAL 16#CC# => 16#2560#, -- BOX DRAWINGS DOUBLE VERTICAL AND -- RIGHT 16#CD# => 16#2550#, -- BOX DRAWINGS DOUBLE HORIZONTAL 16#CE# => 16#256C#, -- BOX DRAWINGS DOUBLE VERTICAL AND -- HORIZONTAL 16#CF# => 16#2567#, -- BOX DRAWINGS UP SINGLE AND HORIZONTAL -- DOUBLE 16#D0# => 16#2568#, -- BOX DRAWINGS UP DOUBLE AND HORIZONTAL -- SINGLE 16#D1# => 16#2564#, -- BOX DRAWINGS DOWN SINGLE AND -- HORIZONTAL DOUBLE 16#D2# => 16#2565#, -- BOX DRAWINGS DOWN DOUBLE AND -- HORIZONTAL SINGLE 16#D3# => 16#2559#, -- BOX DRAWINGS UP DOUBLE AND RIGHT -- SINGLE 16#D4# => 16#2558#, -- BOX DRAWINGS UP SINGLE AND RIGHT -- DOUBLE 16#D5# => 16#2552#, -- BOX DRAWINGS DOWN SINGLE AND RIGHT -- DOUBLE 16#D6# => 16#2553#, -- BOX DRAWINGS DOWN DOUBLE AND RIGHT -- SINGLE 16#D7# => 16#256B#, -- BOX DRAWINGS VERTICAL DOUBLE AND -- HORIZONTAL SINGLE 16#D8# => 16#256A#, -- BOX DRAWINGS VERTICAL SINGLE AND -- HORIZONTAL DOUBLE 16#D9# => 16#2518#, -- BOX DRAWINGS LIGHT UP AND LEFT 16#DA# => 16#250C#, -- BOX DRAWINGS LIGHT DOWN AND RIGHT 16#DB# => 16#2588#, -- FULL BLOCK 16#DC# => 16#2584#, -- LOWER HALF BLOCK 16#DD# => 16#258C#, -- LEFT HALF BLOCK 16#DE# => 16#2590#, -- RIGHT HALF BLOCK 16#DF# => 16#2580#, -- UPPER HALF BLOCK 16#E0# => 16#03B1#, -- GREEK SMALL LETTER ALPHA 16#E1# => 16#00DF#, -- LATIN SMALL LETTER SHARP S 16#E2# => 16#0393#, -- GREEK CAPITAL LETTER GAMMA 16#E3# => 16#03C0#, -- GREEK SMALL LETTER PI 16#E4# => 16#03A3#, -- GREEK CAPITAL LETTER SIGMA 16#E5# => 16#03C3#, -- GREEK SMALL LETTER SIGMA 16#E6# => 16#00B5#, -- MICRO SIGN 16#E7# => 16#03C4#, -- GREEK SMALL LETTER TAU 16#E8# => 16#03A6#, -- GREEK CAPITAL LETTER PHI 16#E9# => 16#0398#, -- GREEK CAPITAL LETTER THETA 16#EA# => 16#03A9#, -- GREEK CAPITAL LETTER OMEGA 16#EB# => 16#03B4#, -- GREEK SMALL LETTER DELTA 16#EC# => 16#221E#, -- INFINITY 16#ED# => 16#03C6#, -- GREEK SMALL LETTER PHI 16#EE# => 16#03B5#, -- GREEK SMALL LETTER EPSILON 16#EF# => 16#2229#, -- INTERSECTION 16#F0# => 16#2261#, -- IDENTICAL TO 16#F1# => 16#00B1#, -- PLUS-MINUS SIGN 16#F2# => 16#2265#, -- GREATER-THAN OR EQUAL TO 16#F3# => 16#2264#, -- LESS-THAN OR EQUAL TO 16#F4# => 16#2320#, -- TOP HALF INTEGRAL 16#F5# => 16#2321#, -- BOTTOM HALF INTEGRAL 16#F6# => 16#00F7#, -- DIVISION SIGN 16#F7# => 16#2248#, -- ALMOST EQUAL TO 16#F8# => 16#00B0#, -- DEGREE SIGN 16#F9# => 16#2219#, -- BULLET OPERATOR 16#FA# => 16#00B7#, -- MIDDLE DOT 16#FB# => 16#221A#, -- SQUARE ROOT 16#FC# => 16#207F#, -- SUPERSCRIPT LATIN SMALL LETTER N 16#FD# => 16#00B2#, -- SUPERSCRIPT TWO 16#FE# => 16#25A0#, -- BLACK SQUARE 16#FF# => 16#00A0#); -- NO-BREAK SPACE Encode_Table_00 : constant array (Matreshka.Internals.Unicode.Code_Point range 16#00A0# .. 16#00FF#) of Ada.Streams.Stream_Element := (16#00A0# => 16#FF#, -- NO-BREAK SPACE 16#00A1# => 16#AD#, -- INVERTED EXCLAMATION MARK 16#00A2# => 16#9B#, -- CENT SIGN 16#00A3# => 16#9C#, -- POUND SIGN 16#00A4# => Question_Mark, 16#00A5# => 16#9D#, -- YEN SIGN 16#00A6# => Question_Mark, 16#00A7# => Question_Mark, 16#00A8# => Question_Mark, 16#00A9# => Question_Mark, 16#00AA# => 16#A6#, -- FEMININE ORDINAL INDICATOR 16#00AB# => 16#AE#, -- LEFT-POINTING DOUBLE ANGLE QUOTATION MARK 16#00AC# => 16#AA#, -- NOT SIGN 16#00AD# => Question_Mark, 16#00AE# => Question_Mark, 16#00AF# => Question_Mark, 16#00B0# => 16#F8#, -- DEGREE SIGN 16#00B1# => 16#F1#, -- PLUS-MINUS SIGN 16#00B2# => 16#FD#, -- SUPERSCRIPT TWO 16#00B3# => Question_Mark, 16#00B4# => Question_Mark, 16#00B5# => 16#E6#, -- MICRO SIGN 16#00B6# => Question_Mark, 16#00B7# => 16#FA#, -- MIDDLE DOT 16#00B8# => Question_Mark, 16#00B9# => Question_Mark, 16#00BA# => 16#A7#, -- MASCULINE ORDINAL INDICATOR 16#00BB# => 16#AF#, -- RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK 16#00BC# => 16#AC#, -- VULGAR FRACTION ONE QUARTER 16#00BD# => 16#AB#, -- VULGAR FRACTION ONE HALF 16#00BE# => Question_Mark, 16#00BF# => 16#A8#, -- INVERTED QUESTION MARK 16#00C0# => Question_Mark, 16#00C1# => Question_Mark, 16#00C2# => Question_Mark, 16#00C3# => Question_Mark, 16#00C4# => 16#8E#, -- LATIN CAPITAL LETTER A WITH DIAERESIS 16#00C5# => 16#8F#, -- LATIN CAPITAL LETTER A WITH RING ABOVE 16#00C6# => 16#92#, -- LATIN CAPITAL LETTER AE 16#00C7# => 16#80#, -- LATIN CAPITAL LETTER C WITH CEDILLA 16#00C8# => Question_Mark, 16#00C9# => 16#90#, -- LATIN CAPITAL LETTER E WITH ACUTE 16#00CA# => Question_Mark, 16#00CB# => Question_Mark, 16#00CC# => Question_Mark, 16#00CD# => Question_Mark, 16#00CE# => Question_Mark, 16#00CF# => Question_Mark, 16#00D0# => Question_Mark, 16#00D1# => 16#A5#, -- LATIN CAPITAL LETTER N WITH TILDE 16#00D2# => Question_Mark, 16#00D3# => Question_Mark, 16#00D4# => Question_Mark, 16#00D5# => Question_Mark, 16#00D6# => 16#99#, -- LATIN CAPITAL LETTER O WITH DIAERESIS 16#00D7# => Question_Mark, 16#00D8# => Question_Mark, 16#00D9# => Question_Mark, 16#00DA# => Question_Mark, 16#00DB# => Question_Mark, 16#00DC# => 16#9A#, -- LATIN CAPITAL LETTER U WITH DIAERESIS 16#00DD# => Question_Mark, 16#00DE# => Question_Mark, 16#00DF# => 16#E1#, -- LATIN SMALL LETTER SHARP S 16#00E0# => 16#85#, -- LATIN SMALL LETTER A WITH GRAVE 16#00E1# => 16#A0#, -- LATIN SMALL LETTER A WITH ACUTE 16#00E2# => 16#83#, -- LATIN SMALL LETTER A WITH CIRCUMFLEX 16#00E3# => Question_Mark, 16#00E4# => 16#84#, -- LATIN SMALL LETTER A WITH DIAERESIS 16#00E5# => 16#86#, -- LATIN SMALL LETTER A WITH RING ABOVE 16#00E6# => 16#91#, -- LATIN SMALL LETTER AE 16#00E7# => 16#87#, -- LATIN SMALL LETTER C WITH CEDILLA 16#00E8# => 16#8A#, -- LATIN SMALL LETTER E WITH GRAVE 16#00E9# => 16#82#, -- LATIN SMALL LETTER E WITH ACUTE 16#00EA# => 16#88#, -- LATIN SMALL LETTER E WITH CIRCUMFLEX 16#00EB# => 16#89#, -- LATIN SMALL LETTER E WITH DIAERESIS 16#00EC# => 16#8D#, -- LATIN SMALL LETTER I WITH GRAVE 16#00ED# => 16#A1#, -- LATIN SMALL LETTER I WITH ACUTE 16#00EE# => 16#8C#, -- LATIN SMALL LETTER I WITH CIRCUMFLEX 16#00EF# => 16#8B#, -- LATIN SMALL LETTER I WITH DIAERESIS 16#00F0# => Question_Mark, 16#00F1# => 16#A4#, -- LATIN SMALL LETTER N WITH TILDE 16#00F2# => 16#95#, -- LATIN SMALL LETTER O WITH GRAVE 16#00F3# => 16#A2#, -- LATIN SMALL LETTER O WITH ACUTE 16#00F4# => 16#93#, -- LATIN SMALL LETTER O WITH CIRCUMFLEX 16#00F5# => Question_Mark, 16#00F6# => 16#94#, -- LATIN SMALL LETTER O WITH DIAERESIS 16#00F7# => 16#F6#, -- DIVISION SIGN 16#00F8# => Question_Mark, 16#00F9# => 16#97#, -- LATIN SMALL LETTER U WITH GRAVE 16#00FA# => 16#A3#, -- LATIN SMALL LETTER U WITH ACUTE 16#00FB# => 16#96#, -- LATIN SMALL LETTER U WITH CIRCUMFLEX 16#00FC# => 16#81#, -- LATIN SMALL LETTER U WITH DIAERESIS 16#00FD# => Question_Mark, 16#00FE# => Question_Mark, 16#00FF# => 16#98#); -- LATIN SMALL LETTER Y WITH DIAERESIS Encode_Table_03 : constant array (Matreshka.Internals.Unicode.Code_Point range 16#0393# .. 16#03C6#) of Ada.Streams.Stream_Element := (16#0393# => 16#E2#, -- GREEK CAPITAL LETTER GAMMA 16#0394# => Question_Mark, 16#0395# => Question_Mark, 16#0396# => Question_Mark, 16#0397# => Question_Mark, 16#0398# => 16#E9#, -- GREEK CAPITAL LETTER THETA 16#0399# => Question_Mark, 16#039A# => Question_Mark, 16#039B# => Question_Mark, 16#039C# => Question_Mark, 16#039D# => Question_Mark, 16#039E# => Question_Mark, 16#039F# => Question_Mark, 16#03A0# => Question_Mark, 16#03A1# => Question_Mark, 16#03A2# => Question_Mark, 16#03A3# => 16#E4#, -- GREEK CAPITAL LETTER SIGMA 16#03A4# => Question_Mark, 16#03A5# => Question_Mark, 16#03A6# => 16#E8#, -- GREEK CAPITAL LETTER PHI 16#03A7# => Question_Mark, 16#03A8# => Question_Mark, 16#03A9# => 16#EA#, -- GREEK CAPITAL LETTER OMEGA 16#03AA# => Question_Mark, 16#03AB# => Question_Mark, 16#03AC# => Question_Mark, 16#03AD# => Question_Mark, 16#03AE# => Question_Mark, 16#03AF# => Question_Mark, 16#03B0# => Question_Mark, 16#03B1# => 16#E0#, -- GREEK SMALL LETTER ALPHA 16#03B2# => Question_Mark, 16#03B3# => Question_Mark, 16#03B4# => 16#EB#, -- GREEK SMALL LETTER DELTA 16#03B5# => 16#EE#, -- GREEK SMALL LETTER EPSILON 16#03B6# => Question_Mark, 16#03B7# => Question_Mark, 16#03B8# => Question_Mark, 16#03B9# => Question_Mark, 16#03BA# => Question_Mark, 16#03BB# => Question_Mark, 16#03BC# => Question_Mark, 16#03BD# => Question_Mark, 16#03BE# => Question_Mark, 16#03BF# => Question_Mark, 16#03C0# => 16#E3#, -- GREEK SMALL LETTER PI 16#03C1# => Question_Mark, 16#03C2# => Question_Mark, 16#03C3# => 16#E5#, -- GREEK SMALL LETTER SIGMA 16#03C4# => 16#E7#, -- GREEK SMALL LETTER TAU 16#03C5# => Question_Mark, 16#03C6# => 16#ED#); -- GREEK SMALL LETTER PHI Encode_Table_22 : constant array (Matreshka.Internals.Unicode.Code_Point range 16#2219# .. 16#2265#) of Ada.Streams.Stream_Element := (16#2219# => 16#F9#, -- BULLET OPERATOR 16#221A# => 16#FB#, -- SQUARE ROOT 16#221B# => Question_Mark, 16#221C# => Question_Mark, 16#221D# => Question_Mark, 16#221E# => 16#EC#, -- INFINITY 16#221F# => Question_Mark, 16#2220# => Question_Mark, 16#2221# => Question_Mark, 16#2222# => Question_Mark, 16#2223# => Question_Mark, 16#2224# => Question_Mark, 16#2225# => Question_Mark, 16#2226# => Question_Mark, 16#2227# => Question_Mark, 16#2228# => Question_Mark, 16#2229# => 16#EF#, -- INTERSECTION 16#222A# => Question_Mark, 16#222B# => Question_Mark, 16#222C# => Question_Mark, 16#222D# => Question_Mark, 16#222E# => Question_Mark, 16#222F# => Question_Mark, 16#2230# => Question_Mark, 16#2231# => Question_Mark, 16#2232# => Question_Mark, 16#2233# => Question_Mark, 16#2234# => Question_Mark, 16#2235# => Question_Mark, 16#2236# => Question_Mark, 16#2237# => Question_Mark, 16#2238# => Question_Mark, 16#2239# => Question_Mark, 16#223A# => Question_Mark, 16#223B# => Question_Mark, 16#223C# => Question_Mark, 16#223D# => Question_Mark, 16#223E# => Question_Mark, 16#223F# => Question_Mark, 16#2240# => Question_Mark, 16#2241# => Question_Mark, 16#2242# => Question_Mark, 16#2243# => Question_Mark, 16#2244# => Question_Mark, 16#2245# => Question_Mark, 16#2246# => Question_Mark, 16#2247# => Question_Mark, 16#2248# => 16#F7#, -- ALMOST EQUAL TO 16#2249# => Question_Mark, 16#224A# => Question_Mark, 16#224B# => Question_Mark, 16#224C# => Question_Mark, 16#224D# => Question_Mark, 16#224E# => Question_Mark, 16#224F# => Question_Mark, 16#2250# => Question_Mark, 16#2251# => Question_Mark, 16#2252# => Question_Mark, 16#2253# => Question_Mark, 16#2254# => Question_Mark, 16#2255# => Question_Mark, 16#2256# => Question_Mark, 16#2257# => Question_Mark, 16#2258# => Question_Mark, 16#2259# => Question_Mark, 16#225A# => Question_Mark, 16#225B# => Question_Mark, 16#225C# => Question_Mark, 16#225D# => Question_Mark, 16#225E# => Question_Mark, 16#225F# => Question_Mark, 16#2260# => Question_Mark, 16#2261# => 16#F0#, -- IDENTICAL TO 16#2262# => Question_Mark, 16#2263# => Question_Mark, 16#2264# => 16#F3#, -- LESS-THAN OR EQUAL TO 16#2265# => 16#F2#); -- GREATER-THAN OR EQUAL TO Encode_Table_23 : constant array (Matreshka.Internals.Unicode.Code_Point range 16#2310# .. 16#2321#) of Ada.Streams.Stream_Element := (16#2310# => 16#A9#, -- REVERSED NOT SIGN 16#2311# => Question_Mark, 16#2312# => Question_Mark, 16#2313# => Question_Mark, 16#2314# => Question_Mark, 16#2315# => Question_Mark, 16#2316# => Question_Mark, 16#2317# => Question_Mark, 16#2318# => Question_Mark, 16#2319# => Question_Mark, 16#231A# => Question_Mark, 16#231B# => Question_Mark, 16#231C# => Question_Mark, 16#231D# => Question_Mark, 16#231E# => Question_Mark, 16#231F# => Question_Mark, 16#2320# => 16#F4#, -- TOP HALF INTEGRAL 16#2321# => 16#F5#); -- BOTTOM HALF INTEGRAL Encode_Table_25 : constant array (Matreshka.Internals.Unicode.Code_Point range 16#2500# .. 16#25A0#) of Ada.Streams.Stream_Element := (16#2500# => 16#C4#, -- BOX DRAWINGS LIGHT HORIZONTAL 16#2501# => Question_Mark, 16#2502# => 16#B3#, -- BOX DRAWINGS LIGHT VERTICAL 16#2503# => Question_Mark, 16#2504# => Question_Mark, 16#2505# => Question_Mark, 16#2506# => Question_Mark, 16#2507# => Question_Mark, 16#2508# => Question_Mark, 16#2509# => Question_Mark, 16#250A# => Question_Mark, 16#250B# => Question_Mark, 16#250C# => 16#DA#, -- BOX DRAWINGS LIGHT DOWN AND RIGHT 16#250D# => Question_Mark, 16#250E# => Question_Mark, 16#250F# => Question_Mark, 16#2510# => 16#BF#, -- BOX DRAWINGS LIGHT DOWN AND LEFT 16#2511# => Question_Mark, 16#2512# => Question_Mark, 16#2513# => Question_Mark, 16#2514# => 16#C0#, -- BOX DRAWINGS LIGHT UP AND RIGHT 16#2515# => Question_Mark, 16#2516# => Question_Mark, 16#2517# => Question_Mark, 16#2518# => 16#D9#, -- BOX DRAWINGS LIGHT UP AND LEFT 16#2519# => Question_Mark, 16#251A# => Question_Mark, 16#251B# => Question_Mark, 16#251C# => 16#C3#, -- BOX DRAWINGS LIGHT VERTICAL AND RIGHT 16#251D# => Question_Mark, 16#251E# => Question_Mark, 16#251F# => Question_Mark, 16#2520# => Question_Mark, 16#2521# => Question_Mark, 16#2522# => Question_Mark, 16#2523# => Question_Mark, 16#2524# => 16#B4#, -- BOX DRAWINGS LIGHT VERTICAL AND LEFT 16#2525# => Question_Mark, 16#2526# => Question_Mark, 16#2527# => Question_Mark, 16#2528# => Question_Mark, 16#2529# => Question_Mark, 16#252A# => Question_Mark, 16#252B# => Question_Mark, 16#252C# => 16#C2#, -- BOX DRAWINGS LIGHT DOWN AND HORIZONTAL 16#252D# => Question_Mark, 16#252E# => Question_Mark, 16#252F# => Question_Mark, 16#2530# => Question_Mark, 16#2531# => Question_Mark, 16#2532# => Question_Mark, 16#2533# => Question_Mark, 16#2534# => 16#C1#, -- BOX DRAWINGS LIGHT UP AND HORIZONTAL 16#2535# => Question_Mark, 16#2536# => Question_Mark, 16#2537# => Question_Mark, 16#2538# => Question_Mark, 16#2539# => Question_Mark, 16#253A# => Question_Mark, 16#253B# => Question_Mark, 16#253C# => 16#C5#, -- BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL 16#253D# => Question_Mark, 16#253E# => Question_Mark, 16#253F# => Question_Mark, 16#2540# => Question_Mark, 16#2541# => Question_Mark, 16#2542# => Question_Mark, 16#2543# => Question_Mark, 16#2544# => Question_Mark, 16#2545# => Question_Mark, 16#2546# => Question_Mark, 16#2547# => Question_Mark, 16#2548# => Question_Mark, 16#2549# => Question_Mark, 16#254A# => Question_Mark, 16#254B# => Question_Mark, 16#254C# => Question_Mark, 16#254D# => Question_Mark, 16#254E# => Question_Mark, 16#254F# => Question_Mark, 16#2550# => 16#CD#, -- BOX DRAWINGS DOUBLE HORIZONTAL 16#2551# => 16#BA#, -- BOX DRAWINGS DOUBLE VERTICAL 16#2552# => 16#D5#, -- BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE 16#2553# => 16#D6#, -- BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE 16#2554# => 16#C9#, -- BOX DRAWINGS DOUBLE DOWN AND RIGHT 16#2555# => 16#B8#, -- BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE 16#2556# => 16#B7#, -- BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE 16#2557# => 16#BB#, -- BOX DRAWINGS DOUBLE DOWN AND LEFT 16#2558# => 16#D4#, -- BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE 16#2559# => 16#D3#, -- BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE 16#255A# => 16#C8#, -- BOX DRAWINGS DOUBLE UP AND RIGHT 16#255B# => 16#BE#, -- BOX DRAWINGS UP SINGLE AND LEFT DOUBLE 16#255C# => 16#BD#, -- BOX DRAWINGS UP DOUBLE AND LEFT SINGLE 16#255D# => 16#BC#, -- BOX DRAWINGS DOUBLE UP AND LEFT 16#255E# => 16#C6#, -- BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE 16#255F# => 16#C7#, -- BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE 16#2560# => 16#CC#, -- BOX DRAWINGS DOUBLE VERTICAL AND RIGHT 16#2561# => 16#B5#, -- BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE 16#2562# => 16#B6#, -- BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE 16#2563# => 16#B9#, -- BOX DRAWINGS DOUBLE VERTICAL AND LEFT 16#2564# => 16#D1#, -- BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE 16#2565# => 16#D2#, -- BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE 16#2566# => 16#CB#, -- BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL 16#2567# => 16#CF#, -- BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE 16#2568# => 16#D0#, -- BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE 16#2569# => 16#CA#, -- BOX DRAWINGS DOUBLE UP AND HORIZONTAL 16#256A# => 16#D8#, -- BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE 16#256B# => 16#D7#, -- BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE 16#256C# => 16#CE#, -- BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL 16#256D# => Question_Mark, 16#256E# => Question_Mark, 16#256F# => Question_Mark, 16#2570# => Question_Mark, 16#2571# => Question_Mark, 16#2572# => Question_Mark, 16#2573# => Question_Mark, 16#2574# => Question_Mark, 16#2575# => Question_Mark, 16#2576# => Question_Mark, 16#2577# => Question_Mark, 16#2578# => Question_Mark, 16#2579# => Question_Mark, 16#257A# => Question_Mark, 16#257B# => Question_Mark, 16#257C# => Question_Mark, 16#257D# => Question_Mark, 16#257E# => Question_Mark, 16#257F# => Question_Mark, 16#2580# => 16#DF#, -- UPPER HALF BLOCK 16#2581# => Question_Mark, 16#2582# => Question_Mark, 16#2583# => Question_Mark, 16#2584# => 16#DC#, -- LOWER HALF BLOCK 16#2585# => Question_Mark, 16#2586# => Question_Mark, 16#2587# => Question_Mark, 16#2588# => 16#DB#, -- FULL BLOCK 16#2589# => Question_Mark, 16#258A# => Question_Mark, 16#258B# => Question_Mark, 16#258C# => 16#DD#, -- LEFT HALF BLOCK 16#258D# => Question_Mark, 16#258E# => Question_Mark, 16#258F# => Question_Mark, 16#2590# => 16#DE#, -- RIGHT HALF BLOCK 16#2591# => 16#B0#, -- LIGHT SHADE 16#2592# => 16#B1#, -- MEDIUM SHADE 16#2593# => 16#B2#, -- DARK SHADE 16#2594# => Question_Mark, 16#2595# => Question_Mark, 16#2596# => Question_Mark, 16#2597# => Question_Mark, 16#2598# => Question_Mark, 16#2599# => Question_Mark, 16#259A# => Question_Mark, 16#259B# => Question_Mark, 16#259C# => Question_Mark, 16#259D# => Question_Mark, 16#259E# => Question_Mark, 16#259F# => Question_Mark, 16#25A0# => 16#FE#); -- BLACK SQUARE ------------------- -- Decode_Append -- ------------------- overriding procedure Decode_Append (Self : in out IBM437_Decoder; Data : Ada.Streams.Stream_Element_Array; String : in out Matreshka.Internals.Strings.Shared_String_Access) is begin Matreshka.Internals.Strings.Mutate (String, String.Unused + Data'Length); for J in Data'Range loop case Data (J) is when 16#00# .. 16#7F# => -- Directly mapped. Self.Unchecked_Append (Self, String, Matreshka.Internals.Unicode.Code_Point (Data (J))); when 16#80# .. 16#FF# => -- Table translated. Self.Unchecked_Append (Self, String, Decode_Table (Data (J))); end case; end loop; String_Handler.Fill_Null_Terminator (String); end Decode_Append; ------------- -- Decoder -- ------------- function Decoder (Mode : Decoder_Mode) return Abstract_Decoder'Class is begin case Mode is when Raw => return IBM437_Decoder' (Skip_LF => False, Unchecked_Append => Unchecked_Append_Raw'Access); when XML_1_0 => return IBM437_Decoder' (Skip_LF => False, Unchecked_Append => Unchecked_Append_XML10'Access); when XML_1_1 => return IBM437_Decoder' (Skip_LF => False, Unchecked_Append => Unchecked_Append_XML11'Access); end case; end Decoder; ------------ -- Encode -- ------------ overriding procedure Encode (Self : in out IBM437_Encoder; String : not null Matreshka.Internals.Strings.Shared_String_Access; Buffer : out MISEV.Shared_Stream_Element_Vector_Access) is pragma Unreferenced (Self); use Matreshka.Internals.Stream_Element_Vectors; use Ada.Streams; Code : Matreshka.Internals.Unicode.Code_Point; Position : Matreshka.Internals.Utf16.Utf16_String_Index := 0; Element : Ada.Streams.Stream_Element; begin if String.Unused = 0 then Buffer := Empty_Shared_Stream_Element_Vector'Access; else Buffer := Allocate (Ada.Streams.Stream_Element_Offset (String.Unused)); while Position < String.Unused loop Matreshka.Internals.Utf16.Unchecked_Next (String.Value, Position, Code); if Code in 16#0000# .. 16#007F# then -- Direct mapping. Element := Stream_Element (Code); elsif Code in Encode_Table_00'Range then -- Table translation, range 00A0 .. 00FF Element := Encode_Table_00 (Code); elsif Code in Encode_Table_03'Range then -- Table translation, range 0393 .. 03C6 Element := Encode_Table_03 (Code); elsif Code in Encode_Table_22'Range then -- Table translation, range 2219 .. 2265 Element := Encode_Table_22 (Code); elsif Code in Encode_Table_23'Range then -- Table translation, range 2310 .. 2321 Element := Encode_Table_23 (Code); elsif Code in Encode_Table_25'Range then -- Table translation, range 2500 .. 25A0 Element := Encode_Table_25 (Code); elsif Code = 16#0192# then -- 16#0192# => 16#9F# -- LATIN SMALL LETTER F WITH HOOK Element := 16#9F#; elsif Code = 16#207F# then -- 16#207F# => 16#FC# -- SUPERSCRIPT LATIN SMALL LETTER N Element := 16#FC#; elsif Code = 16#20A7# then -- 16#20A7# => 16#9E# -- PESETA SIGN Element := 16#9E#; else Element := Question_Mark; end if; Buffer.Value (Buffer.Length) := Element; Buffer.Length := Buffer.Length + 1; end loop; end if; end Encode; ------------- -- Encoder -- ------------- function Encoder return Abstract_Encoder'Class is begin return IBM437_Encoder'(null record); end Encoder; -------------- -- Is_Error -- -------------- overriding function Is_Error (Self : IBM437_Decoder) return Boolean is pragma Unreferenced (Self); begin return False; end Is_Error; ------------------- -- Is_Mailformed -- ------------------- overriding function Is_Mailformed (Self : IBM437_Decoder) return Boolean is pragma Unreferenced (Self); begin return False; end Is_Mailformed; end Matreshka.Internals.Text_Codecs.IBM437;
OneWingedShark/Byron
Ada
4,090
ads
Pragma Ada_2012; Pragma Assertion_Policy( Check ); With Ada.Containers; Generic Container : in out Vector; Package Byron.Generics.Vector.Generic_Cursor with SPARK_Mode => On is -- A type which indicates a particular element in a collection (or non at all). Type Cursor is tagged private; -- Creates a cursor from a given index; returns No_Element when the given -- index is outside the proper range of Container. Function To_Cursor(Index : Index_Type) return Cursor with Inline; -- Returns the next element; a look-ahead(1) function. Not Overriding Function Succ(Item : Cursor) return Cursor; -- Returns the previous element; a look-behind(1) function. Not Overriding Function Pred(Item : Cursor) return Cursor; -- Returns the actual item indicated by the cursor. Function Element( Item : Cursor ) return Element_Type with Pre => Has_Element( Item ); -- Returns true if the cursor has an element. Not Overriding Function Has_Element(Item : Cursor) return Boolean; -- A cursor which does not point to an element. No_Element : Constant Cursor; -- Iterates over the vector, replacing the element as with the result of the operation. Generic -- We must use a function here instead of an in-out procedure because of -- the possibility of the elements having discriminants; the parameter -- is a Cursor so that look-ahead and look-behind may be done. with Function Operation(Item : Cursor) return Element_Type; -- The Vector must have a method with which to replace a given element. with Procedure Replace_Element( Container : in out Vector; Position : Index_Type; New_Item : Element_Type ) is <>; Forward : Boolean := True; Procedure Updater with SPARK_Mode => On, Global => Null ; -- Iterates a cursor over the vector, executing the given operation. Generic -- We must use a function here instead of an in-out procedure because of -- the possibility of the elements having discriminants; the parameter -- is a Cursor so that look-ahead and look-behind may be done. with Procedure Operation(Item : Cursor); Forward : Boolean := True; Procedure Iterator with SPARK_Mode => On, Global => Null ; -- Iterates over the vector, deleting the element as per the result of the operation. Generic -- We must use a function here instead of an in-out procedure because of -- the possibility of the elements having discriminants; the parameter -- is a Cursor so that look-ahead and look-behind may be done. with Function Operation(Item : Cursor'Class) return Boolean; -- The Vector must have a method with which to replace a given element. with Procedure Delete( Container : in out Vector; Position : Index_Type; Count : Count_Type ) is <>; Forward : Boolean := True; Procedure Deleter with SPARK_Mode => On, Global => Null ; Generic -- The Vector must have a method with which to replace a given element. with Procedure Delete( Container : in out Vector; Position : Index_Type; Count : Count_Type ) is <>; Procedure Generic_Delete( Item : in out Cursor; Count : Natural := 1 ) with SPARK_Mode => On, Global => Null ; Generic -- The Vector must have a method with which to replace a given element. with Procedure Replace_Element( Container : in out Vector; Position : Index_Type; New_Item : Element_Type ) is <>; Procedure Replace_Element(Cursor : Generic_Cursor.Cursor; New_Item : Element_Type) with SPARK_Mode => On, Global => Null ; Private Type Cursor is tagged record Valid : Boolean := False; Index : Index_Type; end record; Function Get_Element( Item : Cursor ) return Element_Type is ( Element( Container, Item.Index ) ); Function Has_Element( Item : Cursor ) return Boolean is (Item.Valid); No_Element : Constant Cursor:= Cursor'(Valid => False, others => <>); End Byron.Generics.Vector.Generic_Cursor;
reznikmm/matreshka
Ada
23,156
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_Packages; with AMF.String_Collections; with AMF.UML.Constraints.Collections; with AMF.UML.Dependencies.Collections; with AMF.UML.Element_Imports.Collections; with AMF.UML.Models; with AMF.UML.Named_Elements.Collections; with AMF.UML.Namespaces; with AMF.UML.Package_Imports.Collections; with AMF.UML.Package_Merges.Collections; with AMF.UML.Packageable_Elements.Collections; with AMF.UML.Packages.Collections; with AMF.UML.Parameterable_Elements.Collections; with AMF.UML.Profile_Applications.Collections; with AMF.UML.Profiles; with AMF.UML.Stereotypes.Collections; with AMF.UML.String_Expressions; with AMF.UML.Template_Bindings.Collections; with AMF.UML.Template_Parameters; with AMF.UML.Template_Signatures; with AMF.UML.Types.Collections; with AMF.Visitors; package AMF.Internals.UML_Models is type UML_Model_Proxy is limited new AMF.Internals.UML_Packages.UML_Package_Proxy and AMF.UML.Models.UML_Model with null record; overriding function Get_Viewpoint (Self : not null access constant UML_Model_Proxy) return AMF.Optional_String; -- Getter of Model::viewpoint. -- -- The name of the viewpoint that is expressed by a model (This name may -- refer to a profile definition). overriding procedure Set_Viewpoint (Self : not null access UML_Model_Proxy; To : AMF.Optional_String); -- Setter of Model::viewpoint. -- -- The name of the viewpoint that is expressed by a model (This name may -- refer to a profile definition). overriding function Get_URI (Self : not null access constant UML_Model_Proxy) return AMF.Optional_String; -- Getter of Package::URI. -- -- Provides an identifier for the package that can be used for many -- purposes. A URI is the universally unique identification of the package -- following the IETF URI specification, RFC 2396 -- http://www.ietf.org/rfc/rfc2396.txt and it must comply with those -- syntax rules. overriding procedure Set_URI (Self : not null access UML_Model_Proxy; To : AMF.Optional_String); -- Setter of Package::URI. -- -- Provides an identifier for the package that can be used for many -- purposes. A URI is the universally unique identification of the package -- following the IETF URI specification, RFC 2396 -- http://www.ietf.org/rfc/rfc2396.txt and it must comply with those -- syntax rules. overriding function Get_Nested_Package (Self : not null access constant UML_Model_Proxy) return AMF.UML.Packages.Collections.Set_Of_UML_Package; -- Getter of Package::nestedPackage. -- -- References the packaged elements that are Packages. overriding function Get_Nesting_Package (Self : not null access constant UML_Model_Proxy) return AMF.UML.Packages.UML_Package_Access; -- Getter of Package::nestingPackage. -- -- References the Package that owns this Package. overriding procedure Set_Nesting_Package (Self : not null access UML_Model_Proxy; To : AMF.UML.Packages.UML_Package_Access); -- Setter of Package::nestingPackage. -- -- References the Package that owns this Package. overriding function Get_Owned_Stereotype (Self : not null access constant UML_Model_Proxy) return AMF.UML.Stereotypes.Collections.Set_Of_UML_Stereotype; -- Getter of Package::ownedStereotype. -- -- References the Stereotypes that are owned by the Package overriding function Get_Owned_Type (Self : not null access constant UML_Model_Proxy) return AMF.UML.Types.Collections.Set_Of_UML_Type; -- Getter of Package::ownedType. -- -- References the packaged elements that are Types. overriding function Get_Package_Merge (Self : not null access constant UML_Model_Proxy) return AMF.UML.Package_Merges.Collections.Set_Of_UML_Package_Merge; -- Getter of Package::packageMerge. -- -- References the PackageMerges that are owned by this Package. overriding function Get_Packaged_Element (Self : not null access constant UML_Model_Proxy) return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element; -- Getter of Package::packagedElement. -- -- Specifies the packageable elements that are owned by this Package. overriding function Get_Profile_Application (Self : not null access constant UML_Model_Proxy) return AMF.UML.Profile_Applications.Collections.Set_Of_UML_Profile_Application; -- Getter of Package::profileApplication. -- -- References the ProfileApplications that indicate which profiles have -- been applied to the Package. overriding function Get_Element_Import (Self : not null access constant UML_Model_Proxy) return AMF.UML.Element_Imports.Collections.Set_Of_UML_Element_Import; -- Getter of Namespace::elementImport. -- -- References the ElementImports owned by the Namespace. overriding function Get_Imported_Member (Self : not null access constant UML_Model_Proxy) return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element; -- Getter of Namespace::importedMember. -- -- References the PackageableElements that are members of this Namespace -- as a result of either PackageImports or ElementImports. overriding function Get_Member (Self : not null access constant UML_Model_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element; -- Getter of Namespace::member. -- -- A collection of NamedElements identifiable within the Namespace, either -- by being owned or by being introduced by importing or inheritance. overriding function Get_Owned_Member (Self : not null access constant UML_Model_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element; -- Getter of Namespace::ownedMember. -- -- A collection of NamedElements owned by the Namespace. overriding function Get_Owned_Rule (Self : not null access constant UML_Model_Proxy) return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint; -- Getter of Namespace::ownedRule. -- -- Specifies a set of Constraints owned by this Namespace. overriding function Get_Package_Import (Self : not null access constant UML_Model_Proxy) return AMF.UML.Package_Imports.Collections.Set_Of_UML_Package_Import; -- Getter of Namespace::packageImport. -- -- References the PackageImports owned by the Namespace. overriding function Get_Client_Dependency (Self : not null access constant UML_Model_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_Model_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_Model_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_Model_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_Model_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 Get_Owning_Template_Parameter (Self : not null access constant UML_Model_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access; -- Getter of ParameterableElement::owningTemplateParameter. -- -- The formal template parameter that owns this element. overriding procedure Set_Owning_Template_Parameter (Self : not null access UML_Model_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access); -- Setter of ParameterableElement::owningTemplateParameter. -- -- The formal template parameter that owns this element. overriding function Get_Template_Parameter (Self : not null access constant UML_Model_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access; -- Getter of ParameterableElement::templateParameter. -- -- The template parameter that exposes this element as a formal parameter. overriding procedure Set_Template_Parameter (Self : not null access UML_Model_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access); -- Setter of ParameterableElement::templateParameter. -- -- The template parameter that exposes this element as a formal parameter. overriding function Get_Owned_Template_Signature (Self : not null access constant UML_Model_Proxy) return AMF.UML.Template_Signatures.UML_Template_Signature_Access; -- Getter of TemplateableElement::ownedTemplateSignature. -- -- The optional template signature specifying the formal template -- parameters. overriding procedure Set_Owned_Template_Signature (Self : not null access UML_Model_Proxy; To : AMF.UML.Template_Signatures.UML_Template_Signature_Access); -- Setter of TemplateableElement::ownedTemplateSignature. -- -- The optional template signature specifying the formal template -- parameters. overriding function Get_Template_Binding (Self : not null access constant UML_Model_Proxy) return AMF.UML.Template_Bindings.Collections.Set_Of_UML_Template_Binding; -- Getter of TemplateableElement::templateBinding. -- -- The optional bindings from this element to templates. overriding function All_Applicable_Stereotypes (Self : not null access constant UML_Model_Proxy) return AMF.UML.Stereotypes.Collections.Set_Of_UML_Stereotype; -- Operation Package::allApplicableStereotypes. -- -- The query allApplicableStereotypes() returns all the directly or -- indirectly owned stereotypes, including stereotypes contained in -- sub-profiles. overriding function Containing_Profile (Self : not null access constant UML_Model_Proxy) return AMF.UML.Profiles.UML_Profile_Access; -- Operation Package::containingProfile. -- -- The query containingProfile() returns the closest profile directly or -- indirectly containing this package (or this package itself, if it is a -- profile). overriding function Makes_Visible (Self : not null access constant UML_Model_Proxy; El : AMF.UML.Named_Elements.UML_Named_Element_Access) return Boolean; -- Operation Package::makesVisible. -- -- The query makesVisible() defines whether a Package makes an element -- visible outside itself. Elements with no visibility and elements with -- public visibility are made visible. overriding function Nested_Package (Self : not null access constant UML_Model_Proxy) return AMF.UML.Packages.Collections.Set_Of_UML_Package; -- Operation Package::nestedPackage. -- -- Missing derivation for Package::/nestedPackage : Package overriding function Owned_Stereotype (Self : not null access constant UML_Model_Proxy) return AMF.UML.Stereotypes.Collections.Set_Of_UML_Stereotype; -- Operation Package::ownedStereotype. -- -- Missing derivation for Package::/ownedStereotype : Stereotype overriding function Owned_Type (Self : not null access constant UML_Model_Proxy) return AMF.UML.Types.Collections.Set_Of_UML_Type; -- Operation Package::ownedType. -- -- Missing derivation for Package::/ownedType : Type overriding function Visible_Members (Self : not null access constant UML_Model_Proxy) return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element; -- Operation Package::visibleMembers. -- -- The query visibleMembers() defines which members of a Package can be -- accessed outside it. overriding function Exclude_Collisions (Self : not null access constant UML_Model_Proxy; Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element) return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element; -- Operation Namespace::excludeCollisions. -- -- The query excludeCollisions() excludes from a set of -- PackageableElements any that would not be distinguishable from each -- other in this namespace. overriding function Get_Names_Of_Member (Self : not null access constant UML_Model_Proxy; Element : AMF.UML.Named_Elements.UML_Named_Element_Access) return AMF.String_Collections.Set_Of_String; -- Operation Namespace::getNamesOfMember. -- -- The query getNamesOfMember() takes importing into account. It gives -- back the set of names that an element would have in an importing -- namespace, either because it is owned, or if not owned then imported -- individually, or if not individually then from a package. -- The query getNamesOfMember() gives a set of all of the names that a -- member would have in a Namespace. In general a member can have multiple -- names in a Namespace if it is imported more than once with different -- aliases. The query takes account of importing. It gives back the set of -- names that an element would have in an importing namespace, either -- because it is owned, or if not owned then imported individually, or if -- not individually then from a package. overriding function Import_Members (Self : not null access constant UML_Model_Proxy; Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element) return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element; -- Operation Namespace::importMembers. -- -- The query importMembers() defines which of a set of PackageableElements -- are actually imported into the namespace. This excludes hidden ones, -- i.e., those which have names that conflict with names of owned members, -- and also excludes elements which would have the same name when imported. overriding function Imported_Member (Self : not null access constant UML_Model_Proxy) return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element; -- Operation Namespace::importedMember. -- -- The importedMember property is derived from the ElementImports and the -- PackageImports. References the PackageableElements that are members of -- this Namespace as a result of either PackageImports or ElementImports. overriding function Members_Are_Distinguishable (Self : not null access constant UML_Model_Proxy) return Boolean; -- Operation Namespace::membersAreDistinguishable. -- -- The Boolean query membersAreDistinguishable() determines whether all of -- the namespace's members are distinguishable within it. overriding function Owned_Member (Self : not null access constant UML_Model_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element; -- Operation Namespace::ownedMember. -- -- Missing derivation for Namespace::/ownedMember : NamedElement overriding function All_Owning_Packages (Self : not null access constant UML_Model_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_Model_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_Model_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Operation NamedElement::namespace. -- -- Missing derivation for NamedElement::/namespace : Namespace overriding function Is_Compatible_With (Self : not null access constant UML_Model_Proxy; P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access) return Boolean; -- Operation ParameterableElement::isCompatibleWith. -- -- The query isCompatibleWith() determines if this parameterable element -- is compatible with the specified parameterable element. By default -- parameterable element P is compatible with parameterable element Q if -- the kind of P is the same or a subtype as the kind of Q. Subclasses -- should override this operation to specify different compatibility -- constraints. overriding function Is_Template_Parameter (Self : not null access constant UML_Model_Proxy) return Boolean; -- Operation ParameterableElement::isTemplateParameter. -- -- The query isTemplateParameter() determines if this parameterable -- element is exposed as a formal template parameter. overriding function Is_Template (Self : not null access constant UML_Model_Proxy) return Boolean; -- Operation TemplateableElement::isTemplate. -- -- The query isTemplate() returns whether this templateable element is -- actually a template. overriding function Parameterable_Elements (Self : not null access constant UML_Model_Proxy) return AMF.UML.Parameterable_Elements.Collections.Set_Of_UML_Parameterable_Element; -- Operation TemplateableElement::parameterableElements. -- -- The query parameterableElements() returns the set of elements that may -- be used as the parametered elements for a template parameter of this -- templateable element. By default, this set includes all the owned -- elements. Subclasses may override this operation if they choose to -- restrict the set of parameterable elements. overriding procedure Enter_Element (Self : not null access constant UML_Model_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_Model_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_Model_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_Models;
reznikmm/matreshka
Ada
4,712
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_Style.Use_Optimal_Row_Height_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Use_Optimal_Row_Height_Attribute_Node is begin return Self : Style_Use_Optimal_Row_Height_Attribute_Node do Matreshka.ODF_Style.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Style_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Style_Use_Optimal_Row_Height_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Use_Optimal_Row_Height_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Style_URI, Matreshka.ODF_String_Constants.Use_Optimal_Row_Height_Attribute, Style_Use_Optimal_Row_Height_Attribute_Node'Tag); end Matreshka.ODF_Style.Use_Optimal_Row_Height_Attributes;
HectorMtz22/lang-pro-pia
Ada
416
adb
With Gnat.IO; use Gnat.IO; procedure ej2 is type Peras is new Integer; type Naranjas is new Integer; P : Peras; N : Naranjas; S : Integer; begin Put ("Ingrese primer operando entero: "); Get (Integer(N)); New_Line; Put ("Ingrese segundo operando entero: "); Get (Integer(P)); New_Line; S:= Integer(P)+Integer(N); Put ("La suma es: "); Put (S); end ej2;
afrl-rq/OpenUxAS
Ada
274
ads
package AFRL.CMASI.MissionCommand.SPARK_Boundary with SPARK_Mode is pragma Annotate (GNATprove, Terminating, SPARK_Boundary); function Get_VehicleID (Command : MissionCommand) return Int64 with Global => null; end AFRL.CMASI.MissionCommand.SPARK_Boundary;
0siris/carve
Ada
7,435
adb
-- -- (c) Copyright 1993,1994,1995,1996 Silicon Graphics, Inc. -- ALL RIGHTS RESERVED -- Permission to use, copy, modify, and distribute this software for -- any purpose and without fee is hereby granted, provided that the above -- copyright notice appear in all copies and that both the copyright notice -- and this permission notice appear in supporting documentation, and that -- the name of Silicon Graphics, Inc. not be used in advertising -- or publicity pertaining to distribution of the software without specific, -- written prior permission. -- -- THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" -- AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, -- INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR -- FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON -- GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, -- SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY -- KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, -- LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF -- THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN -- ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON -- ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE -- POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. -- -- US Government Users Restricted Rights -- Use, duplication, or disclosure by the Government is subject to -- restrictions set forth in FAR 52.227.19(c)(2) or subparagraph -- (c)(1)(ii) of the Rights in Technical Data and Computer Software -- clause at DFARS 252.227-7013 and/or in similar or successor -- clauses in the FAR or the DOD or NASA FAR Supplement. -- Unpublished-- rights reserved under the copyright laws of the -- United States. Contractor/manufacturer is Silicon Graphics, -- Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. -- -- OpenGL(TM) is a trademark of Silicon Graphics, Inc. -- with GL; use GL; with Glut; use Glut; package body Teapots_Procs is procedure DoInit is ambient : array (0 .. 3) of aliased GLfloat := (0.0, 0.0, 0.0, 1.0); diffuse : array (0 .. 3) of aliased GLfloat := (1.0, 1.0, 1.0, 1.0); specular : array (0 .. 3) of aliased GLfloat := (1.0, 1.0, 1.0, 1.0); position : array (0 .. 3) of aliased GLfloat := (0.0, 3.0, 3.0, 0.0); lmodel_ambient : array (0 .. 3) of aliased GLfloat := (0.2, 0.2, 0.2, 1.0); local_view : aliased GLfloat := 0.0; begin glLightfv (GL_LIGHT0, GL_AMBIENT, ambient (0)'Access); glLightfv (GL_LIGHT0, GL_DIFFUSE, diffuse (0)'Access); glLightfv (GL_LIGHT0, GL_POSITION, position (0)'Access); glLightModelfv (GL_LIGHT_MODEL_AMBIENT, lmodel_ambient (0)'Access); glLightModelfv (GL_LIGHT_MODEL_LOCAL_VIEWER, local_view'Access); glFrontFace (GL_CW); glEnable (GL_LIGHTING); glEnable (GL_LIGHT0); glEnable (GL_AUTO_NORMAL); glEnable (GL_NORMALIZE); glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LESS); end DoInit; procedure renderTeapot (x : GLfloat; y : GLfloat; ambr : GLfloat; ambg : GLfloat; ambb : GLfloat; difr : GLfloat; difg : GLfloat; difb : GLfloat; specr : GLfloat; specg : GLfloat; specb : GLfloat; shine : GLfloat) is mat : array (0 .. 3) of aliased GLfloat; begin glPushMatrix; glTranslatef (x, y, 0.0); mat (0) := ambr; mat (1) := ambg; mat (2) := ambb; mat (3) := 1.0; glMaterialfv (GL_FRONT, GL_AMBIENT, mat (0)'Access); mat (0) := difr; mat (1) := difg; mat (2) := difb; glMaterialfv (GL_FRONT, GL_DIFFUSE, mat (0)'Access); mat (0) := specr; mat (1) := specg; mat (2) := specb; glMaterialfv (GL_FRONT, GL_SPECULAR, mat (0)'Access); glMaterialf (GL_FRONT, GL_SHININESS, shine * 128.0); glutSolidTeapot (1.0); glPopMatrix; end renderTeapot; procedure DoDisplay is begin -- 16#4100# = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT glClear (GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); renderTeapot (2.0, 17.0, 0.0215, 0.1745, 0.0215, 0.07568, 0.61424, 0.07568, 0.633, 0.727811, 0.633, 0.6); renderTeapot (2.0, 14.0, 0.135, 0.2225, 0.1575, 0.54, 0.89, 0.63, 0.316228, 0.316228, 0.316228, 0.1); renderTeapot (2.0, 11.0, 0.05375, 0.05, 0.06625, 0.18275, 0.17, 0.22525, 0.332741, 0.328634, 0.346435, 0.3); renderTeapot (2.0, 8.0, 0.25, 0.20725, 0.20725, 1.0, 0.829, 0.829, 0.296648, 0.296648, 0.296648, 0.088); renderTeapot (2.0, 5.0, 0.1745, 0.01175, 0.01175, 0.61424, 0.04136, 0.04136, 0.727811, 0.626959, 0.626959, 0.6); renderTeapot (2.0, 2.0, 0.1, 0.18725, 0.1745, 0.396, 0.74151, 0.69102, 0.297254, 0.30829, 0.306678, 0.1); renderTeapot (6.0, 17.0, 0.329412, 0.223529, 0.027451, 0.780392, 0.568627, 0.113725, 0.992157, 0.941176, 0.807843, 0.21794872); renderTeapot (6.0, 14.0, 0.2125, 0.1275, 0.054, 0.714, 0.4284, 0.18144, 0.393548, 0.271906, 0.166721, 0.2); renderTeapot (6.0, 11.0, 0.25, 0.25, 0.25, 0.4, 0.4, 0.4, 0.774597, 0.774597, 0.774597, 0.6); renderTeapot (6.0, 8.0, 0.19125, 0.0735, 0.0225, 0.7038, 0.27048, 0.0828, 0.256777, 0.137622, 0.086014, 0.1); renderTeapot (6.0, 5.0, 0.24725, 0.1995, 0.0745, 0.75164, 0.60648, 0.22648, 0.628281, 0.555802, 0.366065, 0.4); renderTeapot (6.0, 2.0, 0.19225, 0.19225, 0.19225, 0.50754, 0.50754, 0.50754, 0.508273, 0.508273, 0.508273, 0.4); renderTeapot (10.0, 17.0, 0.0, 0.0, 0.0, 0.01, 0.01, 0.01, 0.50, 0.50, 0.50, 0.25); renderTeapot (10.0, 14.0, 0.0, 0.1, 0.06, 0.0, 0.50980392, 0.50980392, 0.50196078, 0.50196078, 0.50196078, 0.25); renderTeapot (10.0, 11.0, 0.0, 0.0, 0.0, 0.1, 0.35, 0.1, 0.45, 0.55, 0.45, 0.25); renderTeapot (10.0, 8.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.7, 0.6, 0.6, 0.25); renderTeapot (10.0, 5.0, 0.0, 0.0, 0.0, 0.55, 0.55, 0.55, 0.70, 0.70, 0.70, 0.25); renderTeapot (10.0, 2.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0, 0.60, 0.60, 0.50, 0.25); renderTeapot (14.0, 17.0, 0.02, 0.02, 0.02, 0.01, 0.01, 0.01, 0.4, 0.4, 0.4, 0.078125); renderTeapot (14.0, 14.0, 0.0, 0.05, 0.05, 0.4, 0.5, 0.5, 0.04, 0.7, 0.7, 0.078125); renderTeapot (14.0, 11.0, 0.0, 0.05, 0.0, 0.4, 0.5, 0.4, 0.04, 0.7, 0.04, 0.078125); renderTeapot (14.0, 8.0, 0.05, 0.0, 0.0, 0.5, 0.4, 0.4, 0.7, 0.04, 0.04, 0.078125); renderTeapot (14.0, 5.0, 0.05, 0.05, 0.05, 0.5, 0.5, 0.5, 0.7, 0.7, 0.7, 0.078125); renderTeapot (14.0, 2.0, 0.05, 0.05, 0.0, 0.5, 0.5, 0.4, 0.7, 0.7, 0.04, 0.078125); glFlush; end DoDisplay; procedure ReshapeCallback (w : Integer; h : Integer) is begin glViewport (0, 0, GLsizei(w), GLsizei(h)); glMatrixMode (GL_PROJECTION); glLoadIdentity; if w <= h then glOrtho (0.0, 16.0, 0.0, GLdouble (16.0*Float (h)/Float (w)), -10.0, 0.0); else glOrtho (0.0, GLdouble (16.0*Float (w)/Float (h)), 0.0, 16.0, -10.0, 10.0); end if; glMatrixMode (GL_MODELVIEW); end ReshapeCallback; end Teapots_Procs;
Componolit/libsparkcrypto
Ada
2,157
ads
------------------------------------------------------------------------------- -- This file is part of libsparkcrypto. -- -- Copyright (C) 2010, Alexander Senier -- Copyright (C) 2010, secunet Security Networks AG -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- * Redistributions of source code must retain the above copyright notice, -- this list of conditions and the following disclaimer. -- -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- -- * Neither the name of the 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. ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- -- Base package of libsparkcrypto internal API ------------------------------------------------------------------------------- package LSC.Internal is pragma Pure; end LSC.Internal;
rveenker/sdlada
Ada
1,404
adb
-------------------------------------------------------------------------------------------------------------------- -- 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. -------------------------------------------------------------------------------------------------------------------- -- iOS implementation. -------------------------------------------------------------------------------------------------------------------- separate (SDL.Platform) function Get return Platforms is begin return iOS; end Get;
stcarrez/ada-el
Ada
36,550
adb
----------------------------------------------------------------------- -- el-expressions-nodes -- Expression Nodes -- Copyright (C) 2009 - 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. ----------------------------------------------------------------------- with Ada.Unchecked_Deallocation; with Ada.Characters.Conversions; with EL.Variables; with Util.Beans.Methods; with Util.Beans.Basic; with Util.Strings; package body EL.Expressions.Nodes is use EL.Variables; use Util.Concurrent; -- ------------------------------ -- Evaluate a node on a given context. If -- ------------------------------ function Get_Safe_Value (Expr : in ELNode; Context : in ELContext'Class) return Object is begin return ELNode'Class (Expr).Get_Value (Context); exception when E : others => Context.Handle_Exception (E); return EL.Objects.Null_Object; end Get_Safe_Value; -- ------------------------------ -- Evaluate a node on a given context. -- ------------------------------ overriding function Get_Value (Expr : ELUnary; Context : ELContext'Class) return Object is begin declare Value : constant Object := Expr.Node.Get_Value (Context); begin case Expr.Kind is when EL_NOT => return To_Object (not To_Boolean (Value)); when EL_MINUS => return -Value; when EL_EMPTY => return To_Object (Is_Empty (Value)); when others => return Value; end case; end; exception when E : EL.Variables.No_Variable | EL.Expressions.Invalid_Variable => -- If we can't find the variable, empty predicate must return true. if Expr.Kind = EL_EMPTY then return To_Object (True); end if; -- For others, this is an error. Context.Handle_Exception (E); return EL.Objects.Null_Object; end Get_Value; -- ------------------------------ -- Reduce the expression by eliminating variables which are known -- and computing constant expressions. Returns either a new expression -- tree or a constant value. -- ------------------------------ overriding function Reduce (Expr : access ELUnary; Context : in ELContext'Class) return Reduction is Value : Reduction := Expr.Node.Reduce (Context); begin if Value.Node /= null then Value.Node := Create_Node (Expr.Kind, Value.Node); else case Expr.Kind is when EL_NOT => Value.Value := To_Object (not To_Boolean (Value.Value)); when EL_MINUS => Value.Value := -Value.Value; when EL_EMPTY => Value.Value := To_Object (Is_Empty (Value.Value)); when others => null; end case; end if; return Value; end Reduce; -- ------------------------------ -- Delete the expression tree (calls Delete (ELNode_Access) recursively). -- ------------------------------ overriding procedure Delete (Node : in out ELUnary) is begin Delete (Node.Node); end Delete; -- ------------------------------ -- Evaluate a node on a given context. -- ------------------------------ overriding function Get_Value (Expr : ELBinary; Context : ELContext'Class) return Object is Left : constant Object := Expr.Left.Get_Safe_Value (Context); Right : constant Object := Expr.Right.Get_Safe_Value (Context); begin case Expr.Kind is when EL_EQ => return To_Object (Left = Right); when EL_NE => return To_Object (Left /= Right); when EL_LE => return To_Object (Left <= Right); when EL_LT => return To_Object (Left < Right); when EL_GE => return To_Object (Left >= Right); when EL_GT => return To_Object (Left > Right); when EL_ADD => return Left + Right; when EL_SUB => return Left - Right; when EL_MUL => return Left * Right; when EL_DIV => return Left / Right; when EL_MOD => return Left mod Right; when EL_LAND => return To_Object (To_Boolean (Left) and then To_Boolean (Right)); when EL_LOR | EL_OR => return To_Object (To_Boolean (Left) or else To_Boolean (Right)); when EL_CONCAT => -- If one of the object is null, ignore it. if Is_Null (Left) then return Right; end if; if Is_Null (Right) then return Left; end if; if Get_Type (Left) = TYPE_WIDE_STRING or else Get_Type (Right) = TYPE_WIDE_STRING then return To_Object (To_Wide_Wide_String (Left) & To_Wide_Wide_String (Right)); else return To_Object (To_String (Left) & To_String (Right)); end if; when EL_AND => return Left & Right; end case; end Get_Value; -- ------------------------------ -- Reduce the expression by eliminating variables which are known -- and computing constant expressions. Returns either a new expression -- tree or a constant value. -- ------------------------------ overriding function Reduce (Expr : access ELBinary; Context : in ELContext'Class) return Reduction is Left : Reduction := Expr.Left.Reduce (Context); Right : Reduction := Expr.Right.Reduce (Context); begin -- If at least one value is not constant, return an expression. if Left.Node /= null or else Right.Node /= null then if Left.Node = null then Left.Node := new ELObject '(Value => Left.Value, Ref_Counter => Counters.ONE); elsif Right.Node = null then Right.Node := new ELObject '(Value => Right.Value, Ref_Counter => Counters.ONE); end if; Left.Node := Create_Node (Expr.Kind, Left.Node, Right.Node); else -- Both values are known, compute the result. case Expr.Kind is when EL_EQ => Left.Value := To_Object (Left.Value = Right.Value); when EL_NE => Left.Value := To_Object (Left.Value /= Right.Value); when EL_LE => Left.Value := To_Object (Left.Value <= Right.Value); when EL_LT => Left.Value := To_Object (Left.Value < Right.Value); when EL_GE => Left.Value := To_Object (Left.Value >= Right.Value); when EL_GT => Left.Value := To_Object (Left.Value > Right.Value); when EL_ADD => Left.Value := Left.Value + Right.Value; when EL_SUB => Left.Value := Left.Value - Right.Value; when EL_MUL => Left.Value := Left.Value * Right.Value; when EL_DIV => Left.Value := Left.Value / Right.Value; when EL_MOD => Left.Value := Left.Value mod Right.Value; when EL_LAND => Left.Value := To_Object (To_Boolean (Left.Value) and then To_Boolean (Right.Value)); when EL_LOR | EL_OR => Left.Value := To_Object (To_Boolean (Left.Value) or else To_Boolean (Right.Value)); when EL_CONCAT => if Get_Type (Left.Value) = TYPE_WIDE_STRING or else Get_Type (Right.Value) = TYPE_WIDE_STRING then Left.Value := To_Object (To_Wide_Wide_String (Left.Value) & To_Wide_Wide_String (Right.Value)); else Left.Value := To_Object (To_String (Left.Value) & To_String (Right.Value)); end if; when EL_AND => Left.Value := Left.Value & Right.Value; end case; end if; return Left; end Reduce; -- ------------------------------ -- Delete the expression tree (calls Delete (ELNode_Access) recursively). -- ------------------------------ overriding procedure Delete (Node : in out ELBinary) is begin Delete (Node.Left); Delete (Node.Right); end Delete; -- ------------------------------ -- Evaluate a node on a given context. -- ------------------------------ overriding function Get_Value (Expr : ELTernary; Context : ELContext'Class) return Object is Cond : constant Object := Expr.Cond.Get_Safe_Value (Context); begin if To_Boolean (Cond) then return Expr.Left.Get_Safe_Value (Context); else return Expr.Right.Get_Safe_Value (Context); end if; end Get_Value; -- ------------------------------ -- Reduce the expression by eliminating variables which are known -- and computing constant expressions. Returns either a new expression -- tree or a constant value. -- ------------------------------ overriding function Reduce (Expr : access ELTernary; Context : in ELContext'Class) return Reduction is Cond : constant Reduction := Expr.Cond.Reduce (Context); begin -- Condition value is known, evaluate one or the other part. if Cond.Node = null then if To_Boolean (Cond.Value) then return Expr.Left.Reduce (Context); else return Expr.Right.Reduce (Context); end if; end if; declare Left : Reduction := Expr.Left.Reduce (Context); Right : Reduction := Expr.Right.Reduce (Context); begin if Left.Node = null then Left.Node := new ELObject '(Value => Left.Value, Ref_Counter => Counters.ONE); end if; if Right.Node = null then Right.Node := new ELObject '(Value => Right.Value, Ref_Counter => Counters.ONE); end if; Left.Node := Create_Node (Cond.Node, Left.Node, Right.Node); return Left; end; end Reduce; -- ------------------------------ -- Delete the expression tree. Free the memory allocated by nodes -- of the expression tree. Clears the node pointer. -- ------------------------------ overriding procedure Delete (Node : in out ELTernary) is begin Delete (Node.Right); Delete (Node.Left); Delete (Node.Cond); end Delete; -- ------------------------------ -- Variable to be looked at in the expression context -- ------------------------------ -- ------------------------------ -- Evaluate a node on a given context. -- ------------------------------ overriding function Get_Value (Expr : ELVariable; Context : ELContext'Class) return Object is Mapper : constant access Variable_Mapper'Class := Context.Get_Variable_Mapper; Resolver : constant ELResolver_Access := Context.Get_Resolver; begin -- Resolve using the variable mapper first. If an exception is raised, -- use the context Handle_Exception to give a chance to report custom errors (See ASF). -- If the value can't be found and the Handle_Exception did not raised any exception, -- return the Null object. if Mapper /= null then begin declare Value : constant Expression := Mapper.Get_Variable (Expr.Name); begin -- If the returned expression is null, assume the variable was not found. -- A variable mapper that returns a null expression is faster than raising -- the No_Variable exception (around 30us on Intel Core @ 2.6GHz!). if not Value.Is_Null then return Value.Get_Value (Context); end if; end; exception when No_Variable => if Resolver = null then raise; end if; end; end if; if Resolver = null then raise Invalid_Variable with "Cannot resolve variable: '" & To_String (Expr.Name) & "'"; end if; return Resolver.all.Get_Value (Context, null, Expr.Name); end Get_Value; -- ------------------------------ -- Reduce the expression by eliminating variables which are known -- and computing constant expressions. Returns either a new expression -- tree or a constant value. -- ------------------------------ overriding function Reduce (Expr : access ELVariable; Context : in ELContext'Class) return Reduction is Mapper : constant access Variable_Mapper'Class := Context.Get_Variable_Mapper; begin if Mapper /= null then declare Value : constant Expression := Mapper.Get_Variable (Expr.Name); begin if Value.Node /= null then return Value.Node.Reduce (Context); elsif not EL.Objects.Is_Null (Value.Value) then return Reduction '(Value => Value.Value, Node => null); end if; exception when others => -- An exception such as Invalid_Variable can be raised if the value expression -- defined in <b>Value</b> refers to a variable which is not yet defined. -- We want to keep the resolution we did (hence Expr.Name) and still refer -- to the new expression so that it can be resolved later on. Typical case in -- ASF: -- <h:list value="#{list}" var="item"> -- <ui:include src="item.xhtml"> -- <ui:param name="c" value="#{item.components.data}"/> -- </ui:include> -- </h:list> -- -- Here, the <b>Value</b> will refer to the EL expression #{item.components.data} -- which is not known at the time of reduction. if Value.Node /= null then Util.Concurrent.Counters.Increment (Value.Node.Ref_Counter); return Reduction '(Value => EL.Objects.Null_Object, Node => Value.Node.all'Access); end if; end; end if; Util.Concurrent.Counters.Increment (Expr.Ref_Counter); return Reduction '(Value => EL.Objects.Null_Object, Node => Expr.all'Access); exception when others => Util.Concurrent.Counters.Increment (Expr.Ref_Counter); return Reduction '(Value => EL.Objects.Null_Object, Node => Expr.all'Access); end Reduce; -- ------------------------------ -- Delete the expression tree (calls Delete (ELNode_Access) recursively). -- ------------------------------ overriding procedure Delete (Node : in out ELVariable) is begin null; end Delete; overriding function Get_Value (Expr : ELValue; Context : ELContext'Class) return Object is Var : constant Object := Expr.Variable.Get_Value (Context); Bean : constant access Util.Beans.Basic.Readonly_Bean'Class := To_Bean (Var); begin if Bean /= null then return Bean.Get_Value (Expr.Name); else return Var; end if; end Get_Value; -- ------------------------------ -- Check if the target bean is a readonly bean. -- ------------------------------ function Is_Readonly (Node : in ELValue; Context : in ELContext'Class) return Boolean is Var : constant Object := Node.Variable.Get_Value (Context); Bean : constant access Util.Beans.Basic.Readonly_Bean'Class := To_Bean (Var); begin return Bean = null or else not (Bean.all in Util.Beans.Basic.Bean'Class); end Is_Readonly; -- ------------------------------ -- Get the variable name. -- ------------------------------ function Get_Variable_Name (Node : in ELValue) return String is begin if Node.Variable.all in ELVariable'Class then return To_String (ELVariable'Class (Node.Variable.all).Name); else return "?"; end if; end Get_Variable_Name; -- ------------------------------ -- Evaluate the node and return a method info with -- the bean object and the method binding. -- ------------------------------ function Get_Method_Info (Node : in ELValue; Context : in ELContext'Class) return Method_Info is use Util.Beans.Methods; use type Util.Strings.Name_Access; Result : Method_Info; Bean : access Util.Beans.Basic.Readonly_Bean'Class; begin Result.Object := Node.Variable.Get_Value (Context); Bean := To_Bean (Result.Object); if Bean = null then if EL.Objects.Is_Null (Result.Object) then raise Invalid_Variable with "Variable '" & Node.Get_Variable_Name & "' not found"; else raise Invalid_Variable with "Variable '" & Node.Get_Variable_Name & "' has no method"; end if; end if; -- If the bean is a method bean, get the methods that it exposes -- and look for the binding that matches our method name. if Bean.all in Method_Bean'Class then declare MBean : constant access Method_Bean'Class := Method_Bean'Class (Bean.all)'Access; Bindings : constant Method_Binding_Array_Access := MBean.Get_Method_Bindings; begin for I in Bindings'Range loop if Bindings (I) /= null and then Bindings (I).Name /= null and then Node.Name = Bindings (I).Name.all then Result.Binding := Bindings (I); return Result; end if; end loop; end; end if; raise Invalid_Method with "Method '" & Node.Name & "' not found"; end Get_Method_Info; -- ------------------------------ -- Evaluate the node and set the value on the associated bean. -- Raises Invalid_Variable if the target object is not a bean. -- Raises Invalid_Expression if the target bean is not writable. -- ------------------------------ procedure Set_Value (Node : in ELValue; Context : in ELContext'Class; Value : in Objects.Object) is use Util.Beans; Var : constant Object := Node.Variable.Get_Value (Context); Bean : constant access Basic.Readonly_Bean'Class := To_Bean (Var); begin if Bean = null then if EL.Objects.Is_Null (Var) then raise Invalid_Variable with "Variable '" & Node.Get_Variable_Name & "' not found"; else raise Invalid_Variable with "Variable '" & Node.Get_Variable_Name & "' cannot be set"; end if; end if; -- If the bean is a method bean, get the methods that it exposes -- and look for the binding that matches our method name. if not (Bean.all in Basic.Bean'Class) then raise Invalid_Method with "Method '" & Node.Name & "' not found"; end if; Basic.Bean'Class (Bean.all).Set_Value (Node.Name, Value); end Set_Value; -- ------------------------------ -- Reduce the expression by eliminating variables which are known -- and computing constant expressions. Returns either a new expression -- tree or a constant value. -- ------------------------------ overriding function Reduce (Expr : access ELValue; Context : in ELContext'Class) return Reduction is Var : Reduction := Expr.Variable.Reduce (Context); begin if Var.Node = null then declare Bean : constant access Util.Beans.Basic.Readonly_Bean'Class := To_Bean (Var.Value); begin if Bean /= null then Var.Value := Bean.Get_Value (Expr.Name); Var.Node := null; return Var; end if; end; end if; -- If the reduction returned the same variable, return the same ELvalue. -- Release the counter for the returned variable and increment the other one. if Var.Node = Expr.Variable then Util.Concurrent.Counters.Decrement (Var.Node.Ref_Counter); Util.Concurrent.Counters.Increment (Expr.Ref_Counter); return Reduction '(Node => Expr.all'Access, Value => EL.Objects.Null_Object); else -- Otherwise, replace the variable. return Reduction '(Node => new ELValue '(Variable => Var.Node, Len => Expr.Len, Name => Expr.Name, Ref_Counter => Counters.ONE), Value => EL.Objects.Null_Object); end if; end Reduce; -- ------------------------------ -- Delete the expression tree (calls Delete (ELNode_Access) recursively). -- ------------------------------ overriding procedure Delete (Node : in out ELValue) is begin Delete (Node.Variable); end Delete; -- ------------------------------ -- Literal object (integer, boolean, float, string) -- ------------------------------ -- ------------------------------ -- Evaluate a node on a given context. -- ------------------------------ overriding function Get_Value (Expr : ELObject; Context : ELContext'Class) return Object is pragma Unreferenced (Context); begin return Expr.Value; end Get_Value; -- ------------------------------ -- Reduce the expression by eliminating variables which are known -- and computing constant expressions. Returns either a new expression -- tree or a constant value. -- ------------------------------ overriding function Reduce (Expr : access ELObject; Context : in ELContext'Class) return Reduction is pragma Unreferenced (Context); begin return Reduction '(Value => Expr.Value, Node => null); end Reduce; overriding procedure Delete (Node : in out ELObject) is begin null; end Delete; -- ------------------------------ -- Evaluate a node on a given context. -- ------------------------------ overriding function Get_Value (Expr : ELFunction; Context : ELContext'Class) return Object is Arg1, Arg2, Arg3, Arg4 : Object; begin if Expr.Arg1 = null then raise Missing_Argument with "Missing argument 1"; end if; Arg1 := Expr.Arg1.Get_Safe_Value (Context); if Expr.Func.Of_Type = F_1_ARG then return Expr.Func.Func1 (Arg1); end if; if Expr.Arg2 = null then raise Missing_Argument with "Missing argument 2"; end if; Arg2 := Expr.Arg2.Get_Safe_Value (Context); if Expr.Func.Of_Type = F_2_ARG then return Expr.Func.Func2 (Arg1, Arg2); end if; if Expr.Arg3 = null then raise Missing_Argument with "Missing argument 3"; end if; Arg3 := Expr.Arg3.Get_Safe_Value (Context); if Expr.Func.Of_Type = F_3_ARG then return Expr.Func.Func3 (Arg1, Arg2, Arg3); end if; if Expr.Arg4 = null then raise Missing_Argument with "Missing argument 4"; end if; Arg4 := Expr.Arg4.Get_Safe_Value (Context); return Expr.Func.Func4 (Arg1, Arg2, Arg3, Arg4); end Get_Value; -- ------------------------------ -- Reduce the expression by eliminating variables which are known -- and computing constant expressions. Returns either a new expression -- tree or a constant value. -- ------------------------------ overriding function Reduce (Expr : access ELFunction; Context : in ELContext'Class) return Reduction is Arg1, Arg2, Arg3, Arg4 : Reduction; begin if Expr.Arg1 /= null then Arg1 := Expr.Arg1.Reduce (Context); end if; if Expr.Func.Of_Type = F_1_ARG then if Arg1.Node = null and then Expr.Func.Optimize and then Expr.Func.Func1 /= null then Arg1.Value := Expr.Func.Func1 (Arg1.Value); return Arg1; end if; if Arg1.Node = null then Arg1.Node := new ELObject '(Value => Arg1.Value, Ref_Counter => Counters.ONE); end if; Arg1.Node := Create_Node (Expr.Func, Arg1.Node); return Arg1; end if; if Expr.Arg2 /= null then Arg2 := Expr.Arg2.Reduce (Context); end if; if Expr.Func.Of_Type = F_2_ARG then if Arg1.Node = null and then Arg2.Node = null and then Expr.Func.Optimize and then Expr.Func.Func2 /= null then Arg1.Value := Expr.Func.Func2 (Arg1.Value, Arg2.Value); return Arg1; end if; if Arg1.Node = null then Arg1.Node := new ELObject '(Value => Arg1.Value, Ref_Counter => Counters.ONE); end if; if Arg2.Node = null then Arg2.Node := new ELObject '(Value => Arg2.Value, Ref_Counter => Counters.ONE); end if; Arg1.Node := Create_Node (Expr.Func, Arg1.Node, Arg2.Node); return Arg1; end if; if Expr.Arg3 /= null then Arg3 := Expr.Arg3.Reduce (Context); end if; if Expr.Func.Of_Type = F_3_ARG then if Arg1.Node = null and then Arg2.Node = null and then Arg3.Node = null and then Expr.Func.Optimize and then Expr.Func.Func3 /= null then Arg1.Value := Expr.Func.Func3 (Arg1.Value, Arg2.Value, Arg3.Value); return Arg1; end if; if Arg1.Node = null then Arg1.Node := new ELObject '(Value => Arg1.Value, Ref_Counter => Counters.ONE); end if; if Arg2.Node = null then Arg2.Node := new ELObject '(Value => Arg2.Value, Ref_Counter => Counters.ONE); end if; if Arg3.Node = null then Arg3.Node := new ELObject '(Value => Arg3.Value, Ref_Counter => Counters.ONE); end if; Arg1.Node := Create_Node (Expr.Func, Arg1.Node, Arg2.Node, Arg3.Node); return Arg1; end if; if Expr.Arg4 /= null then Arg4 := Expr.Arg4.Reduce (Context); end if; if Arg1.Node = null and then Arg2.Node = null and then Arg3.Node = null and then Arg4.Node = null and then Expr.Func.Optimize and then Expr.Func.Func4 /= null then Arg1.Value := Expr.Func.Func4 (Arg1.Value, Arg2.Value, Arg3.Value, Arg4.Value); return Arg1; end if; if Arg1.Node = null then Arg1.Node := new ELObject '(Value => Arg1.Value, Ref_Counter => Counters.ONE); end if; if Arg2.Node = null then Arg2.Node := new ELObject '(Value => Arg2.Value, Ref_Counter => Counters.ONE); end if; if Arg3.Node = null then Arg3.Node := new ELObject '(Value => Arg3.Value, Ref_Counter => Counters.ONE); end if; if Arg4.Node = null then Arg4.Node := new ELObject '(Value => Arg4.Value, Ref_Counter => Counters.ONE); end if; Arg1.Node := Create_Node (Expr.Func, Arg1.Node, Arg2.Node, Arg3.Node, Arg4.Node); return Arg1; end Reduce; overriding procedure Delete (Node : in out ELFunction) is begin if Node.Arg1 /= null then Delete (Node.Arg1); end if; if Node.Arg2 /= null then Delete (Node.Arg2); end if; if Node.Arg3 /= null then Delete (Node.Arg3); end if; if Node.Arg4 /= null then Delete (Node.Arg4); end if; end Delete; -- ------------------------------ -- Create a literal number -- ------------------------------ function Create_Node (Value : Boolean) return ELNode_Access is begin return new ELObject '(Value => To_Object (Value), Ref_Counter => Counters.ONE); end Create_Node; -- ------------------------------ -- Create a literal number -- ------------------------------ function Create_Node (Value : Long_Long_Integer) return ELNode_Access is begin return new ELObject '(Value => To_Object (Value), Ref_Counter => Counters.ONE); end Create_Node; function Create_Node (Value : String) return ELNode_Access is begin return new ELObject '(Value => To_Object (Value), Ref_Counter => Counters.ONE); end Create_Node; function Create_Node (Value : Wide_Wide_String) return ELNode_Access is begin return new ELObject '(Value => To_Object (Value), Ref_Counter => Counters.ONE); end Create_Node; function Create_Node (Value : Unbounded_Wide_Wide_String) return ELNode_Access is begin return new ELObject '(Value => To_Object (Value), Ref_Counter => Counters.ONE); end Create_Node; function Create_Node (Value : Long_Float) return ELNode_Access is begin return new ELObject '(Value => To_Object (Value), Ref_Counter => Counters.ONE); end Create_Node; function Create_Variable (Name : in Wide_Wide_String) return ELNode_Access is Result : constant ELVariable_Access := new ELVariable '(Name => Null_Unbounded_String, Ref_Counter => Counters.ONE); begin Append (Result.Name, Ada.Characters.Conversions.To_String (Name)); return Result.all'Access; end Create_Variable; function Create_Value (Variable : in ELNode_Access; Name : in Wide_Wide_String) return ELNode_Access is Result : constant ELValue_Access := new ELValue '(Len => Name'Length, Variable => Variable, Ref_Counter => Counters.ONE, Name => (others => <>)); Pos : Positive := 1; begin for I in Name'Range loop Result.Name (Pos) := Ada.Characters.Conversions.To_Character (Name (I)); Pos := Pos + 1; end loop; return Result.all'Access; end Create_Value; -- ------------------------------ -- Create unary expressions -- ------------------------------ function Create_Node (Of_Type : Unary_Node; Expr : ELNode_Access) return ELNode_Access is begin return new ELUnary '(Kind => Of_Type, Node => Expr, Ref_Counter => Counters.ONE); end Create_Node; -- ------------------------------ -- Create binary expressions -- ------------------------------ function Create_Node (Of_Type : Binary_Node; Left : ELNode_Access; Right : ELNode_Access) return ELNode_Access is begin return new ELBinary '(Kind => Of_Type, Left => Left, Right => Right, Ref_Counter => Counters.ONE); end Create_Node; -- ------------------------------ -- Create a ternary expression. -- ------------------------------ function Create_Node (Cond : ELNode_Access; Left : ELNode_Access; Right : ELNode_Access) return ELNode_Access is begin return new ELTernary '(Cond => Cond, Left => Left, Right => Right, Ref_Counter => Counters.ONE); end Create_Node; -- ------------------------------ -- Create a function call expression -- ------------------------------ function Create_Node (Func : Function_Access; Arg1 : ELNode_Access) return ELNode_Access is begin return new ELFunction '(Ref_Counter => Counters.ONE, Func => Func, Arg1 => Arg1, others => null); end Create_Node; -- ------------------------------ -- Create a function call expression -- ------------------------------ function Create_Node (Func : Function_Access; Arg1 : ELNode_Access; Arg2 : ELNode_Access) return ELNode_Access is begin return new ELFunction '(Ref_Counter => Counters.ONE, Func => Func, Arg1 => Arg1, Arg2 => Arg2, others => null); end Create_Node; -- ------------------------------ -- Create a function call expression -- ------------------------------ function Create_Node (Func : Function_Access; Arg1 : ELNode_Access; Arg2 : ELNode_Access; Arg3 : ELNode_Access) return ELNode_Access is begin return new ELFunction '(Ref_Counter => Counters.ONE, Func => Func, Arg1 => Arg1, Arg2 => Arg2, Arg3 => Arg3, others => null); end Create_Node; -- ------------------------------ -- Create a function call expression -- ------------------------------ function Create_Node (Func : Function_Access; Arg1 : ELNode_Access; Arg2 : ELNode_Access; Arg3 : ELNode_Access; Arg4 : ELNode_Access) return ELNode_Access is begin return new ELFunction '(Ref_Counter => Counters.ONE, Func => Func, Arg1 => Arg1, Arg2 => Arg2, Arg3 => Arg3, Arg4 => Arg4); end Create_Node; -- ------------------------------ -- Delete the expression tree. Free the memory allocated by nodes -- of the expression tree. Clears the node pointer. -- ------------------------------ procedure Delete (Node : in out ELNode_Access) is procedure Free is new Ada.Unchecked_Deallocation (Object => ELNode'Class, Name => ELNode_Access); Is_Zero : Boolean; begin if Node /= null then Util.Concurrent.Counters.Decrement (Node.Ref_Counter, Is_Zero); if Is_Zero then Delete (Node.all); Free (Node); end if; end if; end Delete; end EL.Expressions.Nodes;
reznikmm/matreshka
Ada
3,719
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_Line_Break_Attributes is pragma Preelaborate; type ODF_Style_Line_Break_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Style_Line_Break_Attribute_Access is access all ODF_Style_Line_Break_Attribute'Class with Storage_Size => 0; end ODF.DOM.Style_Line_Break_Attributes;
AdaCore/libadalang
Ada
161
adb
package body D is procedure Pouet (Self : in out Foo; R : C.Root_Type) is begin C.Visit (R, Self); pragma Test_Statement; end Pouet; end D;
stcarrez/ada-util
Ada
4,407
ads
----------------------------------------------------------------------- -- util-commands-consoles -- Console interface -- Copyright (C) 2014, 2015, 2017, 2018, 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. ----------------------------------------------------------------------- generic type Field_Type is (<>); type Notice_Type is (<>); type Element_Type is (<>); type Input_Type is array (Positive range <>) of Element_Type; with function To_Input (Value : in Integer) return Input_Type; package Util.Commands.Consoles is type Justify_Type is (J_LEFT, -- Justify left |item | J_RIGHT, -- Justify right | item| J_CENTER, -- Justify center | item | J_RIGHT_NO_FILL -- Justify right |item| ); type Console_Type is abstract tagged limited private; type Console_Access is access all Console_Type'Class; -- Report an error message. procedure Error (Console : in out Console_Type; Message : in Input_Type) is abstract; -- Report a notice message. procedure Notice (Console : in out Console_Type; Kind : in Notice_Type; Message : in Input_Type) is abstract; -- Print the field value for the given field. procedure Print_Field (Console : in out Console_Type; Field : in Field_Type; Value : in Input_Type; Justify : in Justify_Type := J_LEFT) is abstract; -- Print the title for the given field. procedure Print_Title (Console : in out Console_Type; Field : in Field_Type; Title : in Input_Type; Justify : in Justify_Type := J_LEFT) is abstract; -- Start a new title in a report. procedure Start_Title (Console : in out Console_Type) is abstract; -- Finish a new title in a report. procedure End_Title (Console : in out Console_Type) is abstract; -- Start a new row in a report. procedure Start_Row (Console : in out Console_Type) is abstract; -- Finish a new row in a report. procedure End_Row (Console : in out Console_Type) is abstract; -- Print the title for the given field and setup the associated field size. procedure Print_Title (Console : in out Console_Type; Field : in Field_Type; Title : in Input_Type; Length : in Positive; Justify : in Justify_Type := J_LEFT); -- Set the length of a field. procedure Set_Field_Length (Console : in out Console_Type; Field : in Field_Type; Length : in Positive); -- Format the integer and print it for the given field. procedure Print_Field (Console : in out Console_Type; Field : in Field_Type; Value : in Integer; Justify : in Justify_Type := J_LEFT); -- Get the field count that was setup through the Print_Title calls. function Get_Field_Count (Console : in Console_Type) return Natural; -- Reset the field count. procedure Clear_Fields (Console : in out Console_Type); private type Field_Size_Array is array (Field_Type) of Natural; type Field_List_Array is array (1 .. Field_Size_Array'Length) of Field_Type; type Console_Type is abstract tagged limited record Sizes : Field_Size_Array := (others => 0); Cols : Field_Size_Array := (others => 1); Fields : Field_List_Array; Field_Count : Natural := 0; end record; end Util.Commands.Consoles;
optikos/oasis
Ada
1,533
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Elements.Type_Definitions; with Program.Lexical_Elements; with Program.Elements.Definitions; package Program.Elements.Record_Types is pragma Pure (Program.Elements.Record_Types); type Record_Type is limited interface and Program.Elements.Type_Definitions.Type_Definition; type Record_Type_Access is access all Record_Type'Class with Storage_Size => 0; not overriding function Record_Definition (Self : Record_Type) return not null Program.Elements.Definitions.Definition_Access is abstract; type Record_Type_Text is limited interface; type Record_Type_Text_Access is access all Record_Type_Text'Class with Storage_Size => 0; not overriding function To_Record_Type_Text (Self : aliased in out Record_Type) return Record_Type_Text_Access is abstract; not overriding function Abstract_Token (Self : Record_Type_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Tagged_Token (Self : Record_Type_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Limited_Token (Self : Record_Type_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; end Program.Elements.Record_Types;
twdroeger/ada-awa
Ada
1,710
ads
----------------------------------------------------------------------- -- files.tests -- Unit tests for files -- Copyright (C) 2009, 2010, 2011, 2012, 2013 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; with AWA.Tests; package AWA.Users.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new AWA.Tests.Test with null record; -- Test creation of user by simulating web requests. procedure Test_Create_User (T : in out Test); procedure Test_Logout_User (T : in out Test); -- Test user authentication by simulating a web request. procedure Test_Login_User (T : in out Test); -- Test the reset password by simulating web requests. procedure Test_Reset_Password_User (T : in out Test); -- Run the recovery password process for the given user and change the password. procedure Recover_Password (T : in out Test; Email : in String; Password : in String); end AWA.Users.Tests;
reznikmm/matreshka
Ada
3,613
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 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$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Elements.Style.Style is type ODF_Style_Style is new XML.DOM.Elements.DOM_Element with private; private type ODF_Style_Style is new XML.DOM.Elements.DOM_Element with null record; end ODF.DOM.Elements.Style.Style;
HackInvent/Ada_Drivers_Library
Ada
39,378
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-2017, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of STMicroelectronics nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- -- -- -- This file is based on: -- -- -- -- @file stm32f429xx.h -- -- @author MCD Application Team -- -- @version V1.1.0 -- -- @date 19-June-2014 -- -- @brief CMSIS STM32F407xx Device Peripheral Access Layer Header File. -- -- -- -- COPYRIGHT(c) 2014 STMicroelectronics -- ------------------------------------------------------------------------------ -- This file provides declarations for devices on the STM32H7xx MCUs -- manufactured by ST Microelectronics. -- BEH to be updated with STM32H7 pragma Warnings (Off, "* is an internal GNAT unit"); private with System.BB.Parameters; pragma Warnings (On, "* is an internal GNAT unit"); -- with STM32_SVD; use STM32_SVD; -- with STM32_SVD.DSI; -- with STM32_SVD.SAI; -- with STM32_SVD.SDMMC; -- with STM32.ADC; use STM32.ADC; -- with STM32.DAC; use STM32.DAC; -- with STM32.DMA; use STM32.DMA; -- with STM32.DMA.Interrupts; use STM32.DMA.Interrupts; -- with STM32.DSI; use STM32.DSI; with STM32.GPIO; use STM32.GPIO; -- with STM32.I2C; use STM32.I2C; -- with STM32.SDMMC; use STM32.SDMMC; with STM32.SPI; use STM32.SPI; -- with STM32.SPI.DMA; use STM32.SPI.DMA; -- with STM32.I2S; use STM32.I2S; -- with STM32.Timers; use STM32.Timers; -- with STM32.RTC; use STM32.RTC; -- with Ada.Interrupts.Names; package STM32.Device is pragma Elaborate_Body; Unknown_Device : exception; -- Raised by the routines below for a device passed as an actual parameter -- when that device is not present on the given hardware instance. -- The clocks of the MCU are: -- HSI = 8, 16, 32, 64MHz -- HSE from 4MHz to 64MHz -- LSE 32kHz -- LSI 32kHz -- CSI 4MHz -- HSI48 48MHz HSI_VALUE : constant := 64_000_000; CSI_VALUE : constant := 4_000_000; -- Internal oscillator in Hz HSE_VALUE : constant UInt32; -- External oscillator in Hz procedure Enable_Clock_Main; -- configure the clock for the mcu STM32H7xx procedure Enable_Clock (This : aliased in out GPIO_Port) with Inline; procedure Enable_Clock (Point : GPIO_Point) with Inline; procedure Enable_Clock (Points : GPIO_Points) with Inline; procedure Reset (This : aliased in out GPIO_Port) with Inline; procedure Reset (Point : GPIO_Point) with Inline; procedure Reset (Points : GPIO_Points) with Inline; GPIO_A : aliased GPIO_Port with Import, Volatile, Address => GPIOA_Base; GPIO_B : aliased GPIO_Port with Import, Volatile, Address => GPIOB_Base; GPIO_C : aliased GPIO_Port with Import, Volatile, Address => GPIOC_Base; GPIO_D : aliased GPIO_Port with Import, Volatile, Address => GPIOD_Base; GPIO_E : aliased GPIO_Port with Import, Volatile, Address => GPIOE_Base; GPIO_F : aliased GPIO_Port with Import, Volatile, Address => GPIOF_Base; GPIO_G : aliased GPIO_Port with Import, Volatile, Address => GPIOG_Base; GPIO_H : aliased GPIO_Port with Import, Volatile, Address => GPIOH_Base; GPIO_I : aliased GPIO_Port with Import, Volatile, Address => GPIOI_Base; GPIO_J : aliased GPIO_Port with Import, Volatile, Address => GPIOJ_Base; GPIO_K : aliased GPIO_Port with Import, Volatile, Address => GPIOK_Base; function GPIO_Port_Representation (Port : GPIO_Port) return UInt4 with Inline; PA0 : aliased GPIO_Point := (GPIO_A'Access, Pin_0); PA1 : aliased GPIO_Point := (GPIO_A'Access, Pin_1); PA2 : aliased GPIO_Point := (GPIO_A'Access, Pin_2); PA3 : aliased GPIO_Point := (GPIO_A'Access, Pin_3); PA4 : aliased GPIO_Point := (GPIO_A'Access, Pin_4); PA5 : aliased GPIO_Point := (GPIO_A'Access, Pin_5); PA6 : aliased GPIO_Point := (GPIO_A'Access, Pin_6); PA7 : aliased GPIO_Point := (GPIO_A'Access, Pin_7); PA8 : aliased GPIO_Point := (GPIO_A'Access, Pin_8); PA9 : aliased GPIO_Point := (GPIO_A'Access, Pin_9); PA10 : aliased GPIO_Point := (GPIO_A'Access, Pin_10); PA11 : aliased GPIO_Point := (GPIO_A'Access, Pin_11); PA12 : aliased GPIO_Point := (GPIO_A'Access, Pin_12); PA13 : aliased GPIO_Point := (GPIO_A'Access, Pin_13); PA14 : aliased GPIO_Point := (GPIO_A'Access, Pin_14); PA15 : aliased GPIO_Point := (GPIO_A'Access, Pin_15); PB0 : aliased GPIO_Point := (GPIO_B'Access, Pin_0); PB1 : aliased GPIO_Point := (GPIO_B'Access, Pin_1); PB2 : aliased GPIO_Point := (GPIO_B'Access, Pin_2); PB3 : aliased GPIO_Point := (GPIO_B'Access, Pin_3); PB4 : aliased GPIO_Point := (GPIO_B'Access, Pin_4); PB5 : aliased GPIO_Point := (GPIO_B'Access, Pin_5); PB6 : aliased GPIO_Point := (GPIO_B'Access, Pin_6); PB7 : aliased GPIO_Point := (GPIO_B'Access, Pin_7); PB8 : aliased GPIO_Point := (GPIO_B'Access, Pin_8); PB9 : aliased GPIO_Point := (GPIO_B'Access, Pin_9); PB10 : aliased GPIO_Point := (GPIO_B'Access, Pin_10); PB11 : aliased GPIO_Point := (GPIO_B'Access, Pin_11); PB12 : aliased GPIO_Point := (GPIO_B'Access, Pin_12); PB13 : aliased GPIO_Point := (GPIO_B'Access, Pin_13); PB14 : aliased GPIO_Point := (GPIO_B'Access, Pin_14); PB15 : aliased GPIO_Point := (GPIO_B'Access, Pin_15); PC0 : aliased GPIO_Point := (GPIO_C'Access, Pin_0); PC1 : aliased GPIO_Point := (GPIO_C'Access, Pin_1); PC2 : aliased GPIO_Point := (GPIO_C'Access, Pin_2); PC3 : aliased GPIO_Point := (GPIO_C'Access, Pin_3); PC4 : aliased GPIO_Point := (GPIO_C'Access, Pin_4); PC5 : aliased GPIO_Point := (GPIO_C'Access, Pin_5); PC6 : aliased GPIO_Point := (GPIO_C'Access, Pin_6); PC7 : aliased GPIO_Point := (GPIO_C'Access, Pin_7); PC8 : aliased GPIO_Point := (GPIO_C'Access, Pin_8); PC9 : aliased GPIO_Point := (GPIO_C'Access, Pin_9); PC10 : aliased GPIO_Point := (GPIO_C'Access, Pin_10); PC11 : aliased GPIO_Point := (GPIO_C'Access, Pin_11); PC12 : aliased GPIO_Point := (GPIO_C'Access, Pin_12); PC13 : aliased GPIO_Point := (GPIO_C'Access, Pin_13); PC14 : aliased GPIO_Point := (GPIO_C'Access, Pin_14); PC15 : aliased GPIO_Point := (GPIO_C'Access, Pin_15); PD0 : aliased GPIO_Point := (GPIO_D'Access, Pin_0); PD1 : aliased GPIO_Point := (GPIO_D'Access, Pin_1); PD2 : aliased GPIO_Point := (GPIO_D'Access, Pin_2); PD3 : aliased GPIO_Point := (GPIO_D'Access, Pin_3); PD4 : aliased GPIO_Point := (GPIO_D'Access, Pin_4); PD5 : aliased GPIO_Point := (GPIO_D'Access, Pin_5); PD6 : aliased GPIO_Point := (GPIO_D'Access, Pin_6); PD7 : aliased GPIO_Point := (GPIO_D'Access, Pin_7); PD8 : aliased GPIO_Point := (GPIO_D'Access, Pin_8); PD9 : aliased GPIO_Point := (GPIO_D'Access, Pin_9); PD10 : aliased GPIO_Point := (GPIO_D'Access, Pin_10); PD11 : aliased GPIO_Point := (GPIO_D'Access, Pin_11); PD12 : aliased GPIO_Point := (GPIO_D'Access, Pin_12); PD13 : aliased GPIO_Point := (GPIO_D'Access, Pin_13); PD14 : aliased GPIO_Point := (GPIO_D'Access, Pin_14); PD15 : aliased GPIO_Point := (GPIO_D'Access, Pin_15); PE0 : aliased GPIO_Point := (GPIO_E'Access, Pin_0); PE1 : aliased GPIO_Point := (GPIO_E'Access, Pin_1); PE2 : aliased GPIO_Point := (GPIO_E'Access, Pin_2); PE3 : aliased GPIO_Point := (GPIO_E'Access, Pin_3); PE4 : aliased GPIO_Point := (GPIO_E'Access, Pin_4); PE5 : aliased GPIO_Point := (GPIO_E'Access, Pin_5); PE6 : aliased GPIO_Point := (GPIO_E'Access, Pin_6); PE7 : aliased GPIO_Point := (GPIO_E'Access, Pin_7); PE8 : aliased GPIO_Point := (GPIO_E'Access, Pin_8); PE9 : aliased GPIO_Point := (GPIO_E'Access, Pin_9); PE10 : aliased GPIO_Point := (GPIO_E'Access, Pin_10); PE11 : aliased GPIO_Point := (GPIO_E'Access, Pin_11); PE12 : aliased GPIO_Point := (GPIO_E'Access, Pin_12); PE13 : aliased GPIO_Point := (GPIO_E'Access, Pin_13); PE14 : aliased GPIO_Point := (GPIO_E'Access, Pin_14); PE15 : aliased GPIO_Point := (GPIO_E'Access, Pin_15); PF0 : aliased GPIO_Point := (GPIO_F'Access, Pin_0); PF1 : aliased GPIO_Point := (GPIO_F'Access, Pin_1); PF2 : aliased GPIO_Point := (GPIO_F'Access, Pin_2); PF3 : aliased GPIO_Point := (GPIO_F'Access, Pin_3); PF4 : aliased GPIO_Point := (GPIO_F'Access, Pin_4); PF5 : aliased GPIO_Point := (GPIO_F'Access, Pin_5); PF6 : aliased GPIO_Point := (GPIO_F'Access, Pin_6); PF7 : aliased GPIO_Point := (GPIO_F'Access, Pin_7); PF8 : aliased GPIO_Point := (GPIO_F'Access, Pin_8); PF9 : aliased GPIO_Point := (GPIO_F'Access, Pin_9); PF10 : aliased GPIO_Point := (GPIO_F'Access, Pin_10); PF11 : aliased GPIO_Point := (GPIO_F'Access, Pin_11); PF12 : aliased GPIO_Point := (GPIO_F'Access, Pin_12); PF13 : aliased GPIO_Point := (GPIO_F'Access, Pin_13); PF14 : aliased GPIO_Point := (GPIO_F'Access, Pin_14); PF15 : aliased GPIO_Point := (GPIO_F'Access, Pin_15); PG0 : aliased GPIO_Point := (GPIO_G'Access, Pin_0); PG1 : aliased GPIO_Point := (GPIO_G'Access, Pin_1); PG2 : aliased GPIO_Point := (GPIO_G'Access, Pin_2); PG3 : aliased GPIO_Point := (GPIO_G'Access, Pin_3); PG4 : aliased GPIO_Point := (GPIO_G'Access, Pin_4); PG5 : aliased GPIO_Point := (GPIO_G'Access, Pin_5); PG6 : aliased GPIO_Point := (GPIO_G'Access, Pin_6); PG7 : aliased GPIO_Point := (GPIO_G'Access, Pin_7); PG8 : aliased GPIO_Point := (GPIO_G'Access, Pin_8); PG9 : aliased GPIO_Point := (GPIO_G'Access, Pin_9); PG10 : aliased GPIO_Point := (GPIO_G'Access, Pin_10); PG11 : aliased GPIO_Point := (GPIO_G'Access, Pin_11); PG12 : aliased GPIO_Point := (GPIO_G'Access, Pin_12); PG13 : aliased GPIO_Point := (GPIO_G'Access, Pin_13); PG14 : aliased GPIO_Point := (GPIO_G'Access, Pin_14); PG15 : aliased GPIO_Point := (GPIO_G'Access, Pin_15); PH0 : aliased GPIO_Point := (GPIO_H'Access, Pin_0); PH1 : aliased GPIO_Point := (GPIO_H'Access, Pin_1); PH2 : aliased GPIO_Point := (GPIO_H'Access, Pin_2); PH3 : aliased GPIO_Point := (GPIO_H'Access, Pin_3); PH4 : aliased GPIO_Point := (GPIO_H'Access, Pin_4); PH5 : aliased GPIO_Point := (GPIO_H'Access, Pin_5); PH6 : aliased GPIO_Point := (GPIO_H'Access, Pin_6); PH7 : aliased GPIO_Point := (GPIO_H'Access, Pin_7); PH8 : aliased GPIO_Point := (GPIO_H'Access, Pin_8); PH9 : aliased GPIO_Point := (GPIO_H'Access, Pin_9); PH10 : aliased GPIO_Point := (GPIO_H'Access, Pin_10); PH11 : aliased GPIO_Point := (GPIO_H'Access, Pin_11); PH12 : aliased GPIO_Point := (GPIO_H'Access, Pin_12); PH13 : aliased GPIO_Point := (GPIO_H'Access, Pin_13); PH14 : aliased GPIO_Point := (GPIO_H'Access, Pin_14); PH15 : aliased GPIO_Point := (GPIO_H'Access, Pin_15); PI0 : aliased GPIO_Point := (GPIO_I'Access, Pin_0); PI1 : aliased GPIO_Point := (GPIO_I'Access, Pin_1); PI2 : aliased GPIO_Point := (GPIO_I'Access, Pin_2); PI3 : aliased GPIO_Point := (GPIO_I'Access, Pin_3); PI4 : aliased GPIO_Point := (GPIO_I'Access, Pin_4); PI5 : aliased GPIO_Point := (GPIO_I'Access, Pin_5); PI6 : aliased GPIO_Point := (GPIO_I'Access, Pin_6); PI7 : aliased GPIO_Point := (GPIO_I'Access, Pin_7); PI8 : aliased GPIO_Point := (GPIO_I'Access, Pin_8); PI9 : aliased GPIO_Point := (GPIO_I'Access, Pin_9); PI10 : aliased GPIO_Point := (GPIO_I'Access, Pin_10); PI11 : aliased GPIO_Point := (GPIO_I'Access, Pin_11); PI12 : aliased GPIO_Point := (GPIO_I'Access, Pin_12); PI13 : aliased GPIO_Point := (GPIO_I'Access, Pin_13); PI14 : aliased GPIO_Point := (GPIO_I'Access, Pin_14); PI15 : aliased GPIO_Point := (GPIO_I'Access, Pin_15); PJ0 : aliased GPIO_Point := (GPIO_J'Access, Pin_0); PJ1 : aliased GPIO_Point := (GPIO_J'Access, Pin_1); PJ2 : aliased GPIO_Point := (GPIO_J'Access, Pin_2); PJ3 : aliased GPIO_Point := (GPIO_J'Access, Pin_3); PJ4 : aliased GPIO_Point := (GPIO_J'Access, Pin_4); PJ5 : aliased GPIO_Point := (GPIO_J'Access, Pin_5); PJ6 : aliased GPIO_Point := (GPIO_J'Access, Pin_6); PJ7 : aliased GPIO_Point := (GPIO_J'Access, Pin_7); PJ8 : aliased GPIO_Point := (GPIO_J'Access, Pin_8); PJ9 : aliased GPIO_Point := (GPIO_J'Access, Pin_9); PJ10 : aliased GPIO_Point := (GPIO_J'Access, Pin_10); PJ11 : aliased GPIO_Point := (GPIO_J'Access, Pin_11); PJ12 : aliased GPIO_Point := (GPIO_J'Access, Pin_12); PJ13 : aliased GPIO_Point := (GPIO_J'Access, Pin_13); PJ14 : aliased GPIO_Point := (GPIO_J'Access, Pin_14); PJ15 : aliased GPIO_Point := (GPIO_J'Access, Pin_15); PK0 : aliased GPIO_Point := (GPIO_K'Access, Pin_0); PK1 : aliased GPIO_Point := (GPIO_K'Access, Pin_1); PK2 : aliased GPIO_Point := (GPIO_K'Access, Pin_2); PK3 : aliased GPIO_Point := (GPIO_K'Access, Pin_3); PK4 : aliased GPIO_Point := (GPIO_K'Access, Pin_4); PK5 : aliased GPIO_Point := (GPIO_K'Access, Pin_5); PK6 : aliased GPIO_Point := (GPIO_K'Access, Pin_6); PK7 : aliased GPIO_Point := (GPIO_K'Access, Pin_7); PK8 : aliased GPIO_Point := (GPIO_K'Access, Pin_8); PK9 : aliased GPIO_Point := (GPIO_K'Access, Pin_9); PK10 : aliased GPIO_Point := (GPIO_K'Access, Pin_10); PK11 : aliased GPIO_Point := (GPIO_K'Access, Pin_11); PK12 : aliased GPIO_Point := (GPIO_K'Access, Pin_12); PK13 : aliased GPIO_Point := (GPIO_K'Access, Pin_13); PK14 : aliased GPIO_Point := (GPIO_K'Access, Pin_14); PK15 : aliased GPIO_Point := (GPIO_K'Access, Pin_15); GPIO_AF_RTC_50Hz_0 : constant GPIO_Alternate_Function; GPIO_AF_MCO_0 : constant GPIO_Alternate_Function; GPIO_AF_TAMPER_0 : constant GPIO_Alternate_Function; GPIO_AF_SWJ_0 : constant GPIO_Alternate_Function; GPIO_AF_TRACE_0 : constant GPIO_Alternate_Function; GPIO_AF_TIM1_1 : constant GPIO_Alternate_Function; GPIO_AF_TIM2_1 : constant GPIO_Alternate_Function; GPIO_AF_I2C4_1 : constant GPIO_Alternate_Function; GPIO_AF_UART5_1 : constant GPIO_Alternate_Function; GPIO_AF_TIM3_2 : constant GPIO_Alternate_Function; GPIO_AF_TIM4_2 : constant GPIO_Alternate_Function; GPIO_AF_TIM5_2 : constant GPIO_Alternate_Function; GPIO_AF_TIM8_3 : constant GPIO_Alternate_Function; GPIO_AF_TIM9_3 : constant GPIO_Alternate_Function; GPIO_AF_TIM10_3 : constant GPIO_Alternate_Function; GPIO_AF_TIM11_3 : constant GPIO_Alternate_Function; GPIO_AF_LPTIM1_3 : constant GPIO_Alternate_Function; GPIO_AF_DFSDM1_3 : constant GPIO_Alternate_Function; GPIO_AF_CEC_3 : constant GPIO_Alternate_Function; GPIO_AF_I2C1_4 : constant GPIO_Alternate_Function; GPIO_AF_I2C2_4 : constant GPIO_Alternate_Function; GPIO_AF_I2C3_4 : constant GPIO_Alternate_Function; GPIO_AF_I2C4_4 : constant GPIO_Alternate_Function; GPIO_AF_USART1_4 : constant GPIO_Alternate_Function; GPIO_AF_CEC_4 : constant GPIO_Alternate_Function; GPIO_AF_SPI1_5 : constant GPIO_Alternate_Function; GPIO_AF_SPI2_5 : constant GPIO_Alternate_Function; GPIO_AF_I2S3_5 : constant GPIO_Alternate_Function; GPIO_AF_SPI4_5 : constant GPIO_Alternate_Function; GPIO_AF_SPI5_5 : constant GPIO_Alternate_Function; GPIO_AF_SPI6_5 : constant GPIO_Alternate_Function; GPIO_AF_SPI2_6 : constant GPIO_Alternate_Function; GPIO_AF_SPI3_6 : constant GPIO_Alternate_Function; GPIO_AF_I2S2_6 : constant GPIO_Alternate_Function; GPIO_AF_I2S3_6 : constant GPIO_Alternate_Function; GPIO_AF_SAI1_6 : constant GPIO_Alternate_Function; GPIO_AF_UART4_6 : constant GPIO_Alternate_Function; GPIO_AF_DFSDM1_6 : constant GPIO_Alternate_Function; GPIO_AF_SPI2_7 : constant GPIO_Alternate_Function; GPIO_AF_I2S2_7 : constant GPIO_Alternate_Function; GPIO_AF_SPI3_7 : constant GPIO_Alternate_Function; GPIO_AF_I2S3_7 : constant GPIO_Alternate_Function; GPIO_AF_SPI6_7 : constant GPIO_Alternate_Function; GPIO_AF_USART1_7 : constant GPIO_Alternate_Function; GPIO_AF_USART2_7 : constant GPIO_Alternate_Function; GPIO_AF_USART3_7 : constant GPIO_Alternate_Function; GPIO_AF_UART5_7 : constant GPIO_Alternate_Function; GPIO_AF_DFSDM1_7 : constant GPIO_Alternate_Function; GPIO_AF_SPDIF_7 : constant GPIO_Alternate_Function; GPIO_AF_SPI6_8 : constant GPIO_Alternate_Function; GPIO_AF_SAI2_8 : constant GPIO_Alternate_Function; GPIO_AF_UART4_8 : constant GPIO_Alternate_Function; GPIO_AF_UART5_8 : constant GPIO_Alternate_Function; GPIO_AF_USART6_8 : constant GPIO_Alternate_Function; GPIO_AF_UART7_8 : constant GPIO_Alternate_Function; GPIO_AF_UART8_8 : constant GPIO_Alternate_Function; GPIO_AF_OTG_FS_8 : constant GPIO_Alternate_Function; GPIO_AF_SPDIF_8 : constant GPIO_Alternate_Function; GPIO_AF_CAN1_9 : constant GPIO_Alternate_Function; GPIO_AF_CAN2_9 : constant GPIO_Alternate_Function; GPIO_AF_TIM12_9 : constant GPIO_Alternate_Function; GPIO_AF_TIM13_9 : constant GPIO_Alternate_Function; GPIO_AF_TIM14_9 : constant GPIO_Alternate_Function; GPIO_AF_QUADSPI_9 : constant GPIO_Alternate_Function; GPIO_AF_FMC_9 : constant GPIO_Alternate_Function; GPIO_AF_LTDC_9 : constant GPIO_Alternate_Function; GPIO_AF_SAI2_10 : constant GPIO_Alternate_Function; GPIO_AF_QUADSPI_10 : constant GPIO_Alternate_Function; GPIO_AF_SDMMC2_10 : constant GPIO_Alternate_Function; GPIO_AF_DFSDM1_10 : constant GPIO_Alternate_Function; GPIO_AF_OTG1_FS_10 : constant GPIO_Alternate_Function; GPIO_AF_OTG_HS_10 : constant GPIO_Alternate_Function; GPIO_AF_LTDC_10 : constant GPIO_Alternate_Function; GPIO_AF_I2C4_11 : constant GPIO_Alternate_Function; GPIO_AF_CAN3_11 : constant GPIO_Alternate_Function; GPIO_AF_SDMMC2_11 : constant GPIO_Alternate_Function; GPIO_AF_ETH_11 : constant GPIO_Alternate_Function; GPIO_AF_UART7_12 : constant GPIO_Alternate_Function; GPIO_AF_FMC_12 : constant GPIO_Alternate_Function; GPIO_AF_SDMMC1_12 : constant GPIO_Alternate_Function; GPIO_AF_MDIOS_12 : constant GPIO_Alternate_Function; GPIO_AF_OTG2_FS_12 : constant GPIO_Alternate_Function; GPIO_AF_DCMI_13 : constant GPIO_Alternate_Function; GPIO_AF_DSI_13 : constant GPIO_Alternate_Function; GPIO_AF_LTDC_13 : constant GPIO_Alternate_Function; GPIO_AF_LTDC_14 : constant GPIO_Alternate_Function; GPIO_AF_EVENTOUT_15 : constant GPIO_Alternate_Function; -- -- ADC_1 : aliased Analog_To_Digital_Converter -- with Import, Volatile, Address => ADC1_Base; -- ADC_2 : aliased Analog_To_Digital_Converter -- with Import, Volatile, Address => ADC2_Base; -- ADC_3 : aliased Analog_To_Digital_Converter -- with Import, Volatile, Address => ADC3_Base; -- -- VBat : constant ADC_Point := (ADC_1'Access, Channel => VBat_Channel); -- Temperature_Sensor : constant ADC_Point := VBat; -- -- see RM pg 410, section 13.10, also pg 389 -- -- VBat_Bridge_Divisor : constant := 4; -- -- The VBAT pin is internally connected to a bridge divider. The actual -- -- voltage is the raw conversion value * the divisor. See section 13.11, -- -- pg 412 of the RM. -- -- procedure Enable_Clock (This : aliased in out Analog_To_Digital_Converter); -- -- procedure Reset_All_ADC_Units; -- -- DAC_1 : aliased Digital_To_Analog_Converter -- with Import, Volatile, Address => DAC_Base; -- -- -- ??? Taken from the STM32F429 definition, TO BE CHECKED FOR THE F7 -- DAC_Channel_1_IO : constant GPIO_Point := PA4; -- DAC_Channel_2_IO : constant GPIO_Point := PA5; -- -- procedure Enable_Clock (This : aliased in out Digital_To_Analog_Converter); -- procedure Reset (This : aliased in out Digital_To_Analog_Converter); -- -- -- USART_1 : aliased USART with Import, Volatile, Address => USART1_Base; -- -- USART_2 : aliased USART with Import, Volatile, Address => USART2_Base; -- -- USART_3 : aliased USART with Import, Volatile, Address => USART3_Base; -- -- UART_4 : aliased USART with Import, Volatile, Address => UART4_Base; -- -- UART_5 : aliased USART with Import, Volatile, Address => UART5_Base; -- -- USART_6 : aliased USART with Import, Volatile, Address => USART6_Base; -- -- USART_7 : aliased USART with Import, Volatile, Address => UART7_Base; -- -- USART_8 : aliased USART with Import, Volatile, Address => UART8_Base; -- -- -- -- procedure Enable_Clock (This : aliased in out USART); -- -- -- -- procedure Reset (This : aliased in out USART); -- -- DMA_1 : aliased DMA_Controller with Import, Volatile, Address => DMA1_Base; -- DMA_2 : aliased DMA_Controller with Import, Volatile, Address => DMA2_Base; -- -- procedure Enable_Clock (This : aliased in out DMA_Controller); -- procedure Reset (This : aliased in out DMA_Controller); -- -- DMA1_Stream0 : aliased DMA_Interrupt_Controller -- (DMA_1'Access, Stream_0, Ada.Interrupts.Names.DMA1_Stream0_Interrupt); -- DMA1_Stream1 : aliased DMA_Interrupt_Controller -- (DMA_1'Access, Stream_1, Ada.Interrupts.Names.DMA1_Stream1_Interrupt); -- DMA1_Stream2 : aliased DMA_Interrupt_Controller -- (DMA_1'Access, Stream_2, Ada.Interrupts.Names.DMA1_Stream2_Interrupt); -- DMA1_Stream3 : aliased DMA_Interrupt_Controller -- (DMA_1'Access, Stream_3, Ada.Interrupts.Names.DMA1_Stream3_Interrupt); -- DMA1_Stream4 : aliased DMA_Interrupt_Controller -- (DMA_1'Access, Stream_4, Ada.Interrupts.Names.DMA1_Stream4_Interrupt); -- DMA1_Stream5 : aliased DMA_Interrupt_Controller -- (DMA_1'Access, Stream_5, Ada.Interrupts.Names.DMA1_Stream5_Interrupt); -- DMA1_Stream6 : aliased DMA_Interrupt_Controller -- (DMA_1'Access, Stream_6, Ada.Interrupts.Names.DMA1_Stream6_Interrupt); -- DMA1_Stream7 : aliased DMA_Interrupt_Controller -- (DMA_1'Access, Stream_7, Ada.Interrupts.Names.DMA1_Stream7_Interrupt); -- -- DMA2_Stream0 : aliased DMA_Interrupt_Controller -- (DMA_2'Access, Stream_0, Ada.Interrupts.Names.DMA2_Stream0_Interrupt); -- DMA2_Stream1 : aliased DMA_Interrupt_Controller -- (DMA_2'Access, Stream_1, Ada.Interrupts.Names.DMA2_Stream1_Interrupt); -- DMA2_Stream2 : aliased DMA_Interrupt_Controller -- (DMA_2'Access, Stream_2, Ada.Interrupts.Names.DMA2_Stream2_Interrupt); -- DMA2_Stream3 : aliased DMA_Interrupt_Controller -- (DMA_2'Access, Stream_3, Ada.Interrupts.Names.DMA2_Stream3_Interrupt); -- DMA2_Stream4 : aliased DMA_Interrupt_Controller -- (DMA_2'Access, Stream_4, Ada.Interrupts.Names.DMA2_Stream4_Interrupt); -- DMA2_Stream5 : aliased DMA_Interrupt_Controller -- (DMA_2'Access, Stream_5, Ada.Interrupts.Names.DMA2_Stream5_Interrupt); -- DMA2_Stream6 : aliased DMA_Interrupt_Controller -- (DMA_2'Access, Stream_6, Ada.Interrupts.Names.DMA2_Stream6_Interrupt); -- DMA2_Stream7 : aliased DMA_Interrupt_Controller -- (DMA_2'Access, Stream_7, Ada.Interrupts.Names.DMA2_Stream7_Interrupt); -- -- Internal_I2C_Port_1 : aliased Internal_I2C_Port -- with Import, Volatile, Address => I2C1_Base; -- Internal_I2C_Port_2 : aliased Internal_I2C_Port -- with Import, Volatile, Address => I2C2_Base; -- Internal_I2C_Port_3 : aliased Internal_I2C_Port -- with Import, Volatile, Address => I2C3_Base; -- Internal_I2C_Port_4 : aliased Internal_I2C_Port -- with Import, Volatile, Address => I2C4_Base; -- -- I2C_1 : aliased I2C_Port (Internal_I2C_Port_1'Access); -- I2C_2 : aliased I2C_Port (Internal_I2C_Port_2'Access); -- I2C_3 : aliased I2C_Port (Internal_I2C_Port_3'Access); -- I2C_4 : aliased I2C_Port (Internal_I2C_Port_4'Access); -- -- type I2C_Port_Id is (I2C_Id_1, I2C_Id_2, I2C_Id_3, I2C_Id_4); -- -- function As_Port_Id (Port : I2C_Port'Class) return I2C_Port_Id with Inline; -- procedure Enable_Clock (This : I2C_Port'Class); -- procedure Enable_Clock (This : I2C_Port_Id); -- procedure Reset (This : I2C_Port'Class); -- procedure Reset (This : I2C_Port_Id); Internal_SPI_1 : aliased Internal_SPI_Port with Import, Volatile, Address => SPI1_Base; Internal_SPI_2 : aliased Internal_SPI_Port with Import, Volatile, Address => SPI2_Base; Internal_SPI_3 : aliased Internal_SPI_Port with Import, Volatile, Address => SPI3_Base; Internal_SPI_4 : aliased Internal_SPI_Port with Import, Volatile, Address => SPI4_Base; Internal_SPI_5 : aliased Internal_SPI_Port with Import, Volatile, Address => SPI5_Base; Internal_SPI_6 : aliased Internal_SPI_Port with Import, Volatile, Address => SPI6_Base; SPI_1 : aliased SPI_Port (Internal_SPI_1'Access); SPI_2 : aliased SPI_Port (Internal_SPI_2'Access); SPI_3 : aliased SPI_Port (Internal_SPI_3'Access); SPI_4 : aliased SPI_Port (Internal_SPI_4'Access); SPI_5 : aliased SPI_Port (Internal_SPI_5'Access); SPI_6 : aliased SPI_Port (Internal_SPI_6'Access); -- SPI_1_DMA : aliased SPI_Port_DMA (Internal_SPI_1'Access); -- SPI_2_DMA : aliased SPI_Port_DMA (Internal_SPI_2'Access); -- SPI_3_DMA : aliased SPI_Port_DMA (Internal_SPI_3'Access); -- SPI_4_DMA : aliased SPI_Port_DMA (Internal_SPI_4'Access); -- SPI_5_DMA : aliased SPI_Port_DMA (Internal_SPI_5'Access); -- SPI_6_DMA : aliased SPI_Port_DMA (Internal_SPI_6'Access); -- procedure Enable_Clock (This : SPI_Port'Class); procedure Reset (This : SPI_Port'Class); -- -- Internal_I2S_1 : aliased Internal_I2S_Port -- with Import, Volatile, Address => SPI1_Base; -- Internal_I2S_2 : aliased Internal_I2S_Port -- with Import, Volatile, Address => SPI2_Base; -- Internal_I2S_3 : aliased Internal_I2S_Port -- with Import, Volatile, Address => SPI3_Base; -- Internal_I2S_4 : aliased Internal_I2S_Port -- with Import, Volatile, Address => SPI4_Base; -- Internal_I2S_5 : aliased Internal_I2S_Port -- with Import, Volatile, Address => SPI5_Base; -- Internal_I2S_6 : aliased Internal_I2S_Port -- with Import, Volatile, Address => SPI6_Base; -- -- I2S_1 : aliased I2S_Port (Internal_I2S_1'Access, Extended => False); -- I2S_2 : aliased I2S_Port (Internal_I2S_2'Access, Extended => False); -- I2S_3 : aliased I2S_Port (Internal_I2S_3'Access, Extended => False); -- I2S_4 : aliased I2S_Port (Internal_I2S_4'Access, Extended => False); -- I2S_5 : aliased I2S_Port (Internal_I2S_5'Access, Extended => False); -- I2S_6 : aliased I2S_Port (Internal_I2S_6'Access, Extended => False); -- -- procedure Enable_Clock (This : I2S_Port); -- procedure Reset (This : in out I2S_Port); -- -- Timer_1 : aliased Timer with Volatile, Address => TIM1_Base; -- pragma Import (Ada, Timer_1); -- Timer_2 : aliased Timer with Volatile, Address => TIM2_Base; -- pragma Import (Ada, Timer_2); -- Timer_3 : aliased Timer with Volatile, Address => TIM3_Base; -- pragma Import (Ada, Timer_3); -- Timer_4 : aliased Timer with Volatile, Address => TIM4_Base; -- pragma Import (Ada, Timer_4); -- Timer_5 : aliased Timer with Volatile, Address => TIM5_Base; -- pragma Import (Ada, Timer_5); -- Timer_6 : aliased Timer with Volatile, Address => TIM6_Base; -- pragma Import (Ada, Timer_6); -- Timer_7 : aliased Timer with Volatile, Address => TIM7_Base; -- pragma Import (Ada, Timer_7); -- Timer_8 : aliased Timer with Volatile, Address => TIM8_Base; -- pragma Import (Ada, Timer_8); -- Timer_9 : aliased Timer with Volatile, Address => TIM9_Base; -- pragma Import (Ada, Timer_9); -- Timer_10 : aliased Timer with Volatile, Address => TIM10_Base; -- pragma Import (Ada, Timer_10); -- Timer_11 : aliased Timer with Volatile, Address => TIM11_Base; -- pragma Import (Ada, Timer_11); -- Timer_12 : aliased Timer with Volatile, Address => TIM12_Base; -- pragma Import (Ada, Timer_12); -- Timer_13 : aliased Timer with Volatile, Address => TIM13_Base; -- pragma Import (Ada, Timer_13); -- Timer_14 : aliased Timer with Volatile, Address => TIM14_Base; -- pragma Import (Ada, Timer_14); -- -- procedure Enable_Clock (This : in out Timer); -- procedure Reset (This : in out Timer); -- -- ----------- -- -- Audio -- -- ----------- -- -- subtype SAI_Port is STM32_SVD.SAI.SAI_Peripheral; -- -- SAI_1 : SAI_Port renames STM32_SVD.SAI.SAI1_Periph; -- SAI_2 : SAI_Port renames STM32_SVD.SAI.SAI2_Periph; -- -- procedure Enable_Clock (This : in out SAI_Port); -- procedure Reset (This : in out SAI_Port); -- function Get_Input_Clock (Periph : SAI_Port) return UInt32; -- -- -------------- -- -- DSI Host -- -- -------------- -- -- DSIHOST : aliased DSI_Host (STM32_SVD.DSI.DSI_Periph'Access); -- -- ------------ -- -- SDMMC -- -- ------------ -- -- type SDMMC_Clock_Source is (Src_Sysclk, Src_48Mhz); -- -- SDMMC_1 : aliased SDMMC_Controller (STM32_SVD.SDMMC.SDMMC1_Periph'Access); -- SDMMC_2 : aliased SDMMC_Controller (STM32_SVD.SDMMC.SDMMC2_Periph'Access); -- -- procedure Enable_Clock (This : in out SDMMC_Controller); -- procedure Reset (This : in out SDMMC_Controller); -- procedure Set_Clock_Source -- (This : in out SDMMC_Controller; -- Src : SDMMC_Clock_Source); ----------------------------- -- Reset and Clock Control -- ----------------------------- type RCC_System_Clocks is record SYSCLK : UInt32; HCLK : UInt32; PCLK1 : UInt32; PCLK2 : UInt32; TIMCLK1 : UInt32; TIMCLK2 : UInt32; I2SCLK : UInt32; end record; function System_Clock_Frequencies return RCC_System_Clocks; -- procedure Set_PLLI2S_Factors (Pll_N : UInt9; -- Pll_R : UInt3); -- function PLLI2S_Enabled return Boolean; -- procedure Enable_PLLI2S -- with Post => PLLI2S_Enabled; -- procedure Disable_PLLI2S -- with Post => not PLLI2S_Enabled; type PLLSAI_DivR is new UInt2; PLLSAI_DIV2 : constant PLLSAI_DivR := 0; PLLSAI_DIV4 : constant PLLSAI_DivR := 1; PLLSAI_DIV8 : constant PLLSAI_DivR := 2; PLLSAI_DIV16 : constant PLLSAI_DivR := 3; -- procedure Set_PLLSAI_Factors -- (LCD : UInt3; -- VCO : UInt9; -- DivR : PLLSAI_DivR); -- procedure Enable_PLLSAI; -- procedure Disable_PLLSAI; -- function PLLSAI_Ready return Boolean; subtype DIVQ is Natural range 1 .. 32; -- -- procedure Configure_SAI_I2S_Clock -- (Periph : SAI_Port; -- PLLI2SN : UInt9; -- PLLI2SQ : UInt4; -- PLLI2SDIVQ : DIVQ); -- -- procedure Enable_DCMI_Clock; -- procedure Reset_DCMI; -- -- RTC : aliased RTC_Device; private HSE_VALUE : constant UInt32 := System.BB.Parameters.HSE_Clock; GPIO_AF_RTC_50Hz_0 : constant GPIO_Alternate_Function := 0; GPIO_AF_MCO_0 : constant GPIO_Alternate_Function := 0; GPIO_AF_TAMPER_0 : constant GPIO_Alternate_Function := 0; GPIO_AF_SWJ_0 : constant GPIO_Alternate_Function := 0; GPIO_AF_TRACE_0 : constant GPIO_Alternate_Function := 0; GPIO_AF_TIM1_1 : constant GPIO_Alternate_Function := 1; GPIO_AF_TIM2_1 : constant GPIO_Alternate_Function := 1; GPIO_AF_I2C4_1 : constant GPIO_Alternate_Function := 1; GPIO_AF_UART5_1 : constant GPIO_Alternate_Function := 1; GPIO_AF_TIM3_2 : constant GPIO_Alternate_Function := 2; GPIO_AF_TIM4_2 : constant GPIO_Alternate_Function := 2; GPIO_AF_TIM5_2 : constant GPIO_Alternate_Function := 2; GPIO_AF_TIM8_3 : constant GPIO_Alternate_Function := 3; GPIO_AF_TIM9_3 : constant GPIO_Alternate_Function := 3; GPIO_AF_TIM10_3 : constant GPIO_Alternate_Function := 3; GPIO_AF_TIM11_3 : constant GPIO_Alternate_Function := 3; GPIO_AF_LPTIM1_3 : constant GPIO_Alternate_Function := 3; GPIO_AF_DFSDM1_3 : constant GPIO_Alternate_Function := 3; GPIO_AF_CEC_3 : constant GPIO_Alternate_Function := 3; GPIO_AF_I2C1_4 : constant GPIO_Alternate_Function := 4; GPIO_AF_I2C2_4 : constant GPIO_Alternate_Function := 4; GPIO_AF_I2C3_4 : constant GPIO_Alternate_Function := 4; GPIO_AF_I2C4_4 : constant GPIO_Alternate_Function := 4; GPIO_AF_USART1_4 : constant GPIO_Alternate_Function := 4; GPIO_AF_CEC_4 : constant GPIO_Alternate_Function := 4; GPIO_AF_SPI1_5 : constant GPIO_Alternate_Function := 5; GPIO_AF_SPI2_5 : constant GPIO_Alternate_Function := 5; GPIO_AF_I2S3_5 : constant GPIO_Alternate_Function := 5; GPIO_AF_SPI4_5 : constant GPIO_Alternate_Function := 5; GPIO_AF_SPI5_5 : constant GPIO_Alternate_Function := 5; GPIO_AF_SPI6_5 : constant GPIO_Alternate_Function := 5; GPIO_AF_SPI2_6 : constant GPIO_Alternate_Function := 6; GPIO_AF_SPI3_6 : constant GPIO_Alternate_Function := 6; GPIO_AF_I2S2_6 : constant GPIO_Alternate_Function := 6; GPIO_AF_I2S3_6 : constant GPIO_Alternate_Function := 6; GPIO_AF_SAI1_6 : constant GPIO_Alternate_Function := 6; GPIO_AF_UART4_6 : constant GPIO_Alternate_Function := 6; GPIO_AF_DFSDM1_6 : constant GPIO_Alternate_Function := 6; GPIO_AF_SPI2_7 : constant GPIO_Alternate_Function := 7; GPIO_AF_I2S2_7 : constant GPIO_Alternate_Function := 7; GPIO_AF_SPI3_7 : constant GPIO_Alternate_Function := 7; GPIO_AF_I2S3_7 : constant GPIO_Alternate_Function := 7; GPIO_AF_SPI6_7 : constant GPIO_Alternate_Function := 7; GPIO_AF_USART1_7 : constant GPIO_Alternate_Function := 7; GPIO_AF_USART2_7 : constant GPIO_Alternate_Function := 7; GPIO_AF_USART3_7 : constant GPIO_Alternate_Function := 7; GPIO_AF_UART5_7 : constant GPIO_Alternate_Function := 7; GPIO_AF_DFSDM1_7 : constant GPIO_Alternate_Function := 7; GPIO_AF_SPDIF_7 : constant GPIO_Alternate_Function := 8; GPIO_AF_SPI6_8 : constant GPIO_Alternate_Function := 8; GPIO_AF_SAI2_8 : constant GPIO_Alternate_Function := 8; GPIO_AF_UART4_8 : constant GPIO_Alternate_Function := 8; GPIO_AF_UART5_8 : constant GPIO_Alternate_Function := 8; GPIO_AF_USART6_8 : constant GPIO_Alternate_Function := 8; GPIO_AF_UART7_8 : constant GPIO_Alternate_Function := 8; GPIO_AF_UART8_8 : constant GPIO_Alternate_Function := 8; GPIO_AF_OTG_FS_8 : constant GPIO_Alternate_Function := 8; GPIO_AF_SPDIF_8 : constant GPIO_Alternate_Function := 8; GPIO_AF_CAN1_9 : constant GPIO_Alternate_Function := 9; GPIO_AF_CAN2_9 : constant GPIO_Alternate_Function := 9; GPIO_AF_TIM12_9 : constant GPIO_Alternate_Function := 9; GPIO_AF_TIM13_9 : constant GPIO_Alternate_Function := 9; GPIO_AF_TIM14_9 : constant GPIO_Alternate_Function := 9; GPIO_AF_QUADSPI_9 : constant GPIO_Alternate_Function := 9; GPIO_AF_FMC_9 : constant GPIO_Alternate_Function := 9; GPIO_AF_LTDC_9 : constant GPIO_Alternate_Function := 9; GPIO_AF_SAI2_10 : constant GPIO_Alternate_Function := 10; GPIO_AF_QUADSPI_10 : constant GPIO_Alternate_Function := 10; GPIO_AF_SDMMC2_10 : constant GPIO_Alternate_Function := 10; GPIO_AF_DFSDM1_10 : constant GPIO_Alternate_Function := 10; GPIO_AF_OTG1_FS_10 : constant GPIO_Alternate_Function := 10; GPIO_AF_OTG_HS_10 : constant GPIO_Alternate_Function := 10; GPIO_AF_LTDC_10 : constant GPIO_Alternate_Function := 10; GPIO_AF_I2C4_11 : constant GPIO_Alternate_Function := 11; GPIO_AF_CAN3_11 : constant GPIO_Alternate_Function := 11; GPIO_AF_SDMMC2_11 : constant GPIO_Alternate_Function := 11; GPIO_AF_ETH_11 : constant GPIO_Alternate_Function := 11; GPIO_AF_UART7_12 : constant GPIO_Alternate_Function := 12; GPIO_AF_FMC_12 : constant GPIO_Alternate_Function := 12; GPIO_AF_SDMMC1_12 : constant GPIO_Alternate_Function := 12; GPIO_AF_MDIOS_12 : constant GPIO_Alternate_Function := 12; GPIO_AF_OTG2_FS_12 : constant GPIO_Alternate_Function := 12; GPIO_AF_DCMI_13 : constant GPIO_Alternate_Function := 13; GPIO_AF_DSI_13 : constant GPIO_Alternate_Function := 13; GPIO_AF_LTDC_13 : constant GPIO_Alternate_Function := 13; GPIO_AF_LTDC_14 : constant GPIO_Alternate_Function := 14; GPIO_AF_EVENTOUT_15 : constant GPIO_Alternate_Function := 15; end STM32.Device;
AdaCore/training_material
Ada
12,366
ads
pragma Ada_2005; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; with SDL_SDL_stdinc_h; with SDL_SDL_keyboard_h; with System; package SDL_SDL_events_h is SDL_RELEASED : constant := 0; -- ../include/SDL/SDL_events.h:47 SDL_PRESSED : constant := 1; -- ../include/SDL/SDL_events.h:48 -- arg-macro: function SDL_EVENTMASK (X) -- return 2**(X); SDL_ALLEVENTS : constant := 16#FFFFFFFF#; -- ../include/SDL/SDL_events.h:115 SDL_QUERY : constant := -1; -- ../include/SDL/SDL_events.h:334 SDL_IGNORE : constant := 0; -- ../include/SDL/SDL_events.h:335 SDL_DISABLE : constant := 0; -- ../include/SDL/SDL_events.h:336 SDL_ENABLE : constant := 1; -- ../include/SDL/SDL_events.h:337 subtype SDL_EventType is unsigned; SDL_NOEVENT : constant SDL_EventType := 0; SDL_ACTIVEEVENT : constant SDL_EventType := 1; SDL_KEYDOWN : constant SDL_EventType := 2; SDL_KEYUP : constant SDL_EventType := 3; SDL_MOUSEMOTION : constant SDL_EventType := 4; SDL_MOUSEBUTTONDOWN : constant SDL_EventType := 5; SDL_MOUSEBUTTONUP : constant SDL_EventType := 6; SDL_JOYAXISMOTION : constant SDL_EventType := 7; SDL_JOYBALLMOTION : constant SDL_EventType := 8; SDL_JOYHATMOTION : constant SDL_EventType := 9; SDL_JOYBUTTONDOWN : constant SDL_EventType := 10; SDL_JOYBUTTONUP : constant SDL_EventType := 11; SDL_QUIT : constant SDL_EventType := 12; SDL_SYSWMEVENT : constant SDL_EventType := 13; SDL_EVENT_RESERVEDA : constant SDL_EventType := 14; SDL_EVENT_RESERVEDB : constant SDL_EventType := 15; SDL_VIDEORESIZE : constant SDL_EventType := 16; SDL_VIDEOEXPOSE : constant SDL_EventType := 17; SDL_EVENT_RESERVED2 : constant SDL_EventType := 18; SDL_EVENT_RESERVED3 : constant SDL_EventType := 19; SDL_EVENT_RESERVED4 : constant SDL_EventType := 20; SDL_EVENT_RESERVED5 : constant SDL_EventType := 21; SDL_EVENT_RESERVED6 : constant SDL_EventType := 22; SDL_EVENT_RESERVED7 : constant SDL_EventType := 23; SDL_USEREVENT : constant SDL_EventType := 24; SDL_NUMEVENTS : constant SDL_EventType := 32; -- ../include/SDL/SDL_events.h:83 subtype SDL_EventMask is unsigned; SDL_ACTIVEEVENTMASK : constant SDL_EventMask := 2; SDL_KEYDOWNMASK : constant SDL_EventMask := 4; SDL_KEYUPMASK : constant SDL_EventMask := 8; SDL_KEYEVENTMASK : constant SDL_EventMask := 12; SDL_MOUSEMOTIONMASK : constant SDL_EventMask := 16; SDL_MOUSEBUTTONDOWNMASK : constant SDL_EventMask := 32; SDL_MOUSEBUTTONUPMASK : constant SDL_EventMask := 64; SDL_MOUSEEVENTMASK : constant SDL_EventMask := 112; SDL_JOYAXISMOTIONMASK : constant SDL_EventMask := 128; SDL_JOYBALLMOTIONMASK : constant SDL_EventMask := 256; SDL_JOYHATMOTIONMASK : constant SDL_EventMask := 512; SDL_JOYBUTTONDOWNMASK : constant SDL_EventMask := 1024; SDL_JOYBUTTONUPMASK : constant SDL_EventMask := 2048; SDL_JOYEVENTMASK : constant SDL_EventMask := 3968; SDL_VIDEORESIZEMASK : constant SDL_EventMask := 65536; SDL_VIDEOEXPOSEMASK : constant SDL_EventMask := 131072; SDL_QUITMASK : constant SDL_EventMask := 4096; SDL_SYSWMEVENTMASK : constant SDL_EventMask := 8192; -- ../include/SDL/SDL_events.h:114 type SDL_ActiveEvent_Rec is record c_type : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:120 gain : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:121 state : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:122 end record; pragma Convention (C_Pass_By_Copy, SDL_ActiveEvent_Rec); -- ../include/SDL/SDL_events.h:119 type SDL_KeyboardEvent is record c_type : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:127 which : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:128 state : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:129 keysym : aliased SDL_SDL_keyboard_h.SDL_keysym; -- ../include/SDL/SDL_events.h:130 end record; pragma Convention (C_Pass_By_Copy, SDL_KeyboardEvent); -- ../include/SDL/SDL_events.h:126 type SDL_MouseMotionEvent is record c_type : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:135 which : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:136 state : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:137 x : aliased SDL_SDL_stdinc_h.Uint16; -- ../include/SDL/SDL_events.h:138 y : aliased SDL_SDL_stdinc_h.Uint16; -- ../include/SDL/SDL_events.h:138 xrel : aliased SDL_SDL_stdinc_h.Sint16; -- ../include/SDL/SDL_events.h:139 yrel : aliased SDL_SDL_stdinc_h.Sint16; -- ../include/SDL/SDL_events.h:140 end record; pragma Convention (C_Pass_By_Copy, SDL_MouseMotionEvent); -- ../include/SDL/SDL_events.h:134 type SDL_MouseButtonEvent is record c_type : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:145 which : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:146 button : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:147 state : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:148 x : aliased SDL_SDL_stdinc_h.Uint16; -- ../include/SDL/SDL_events.h:149 y : aliased SDL_SDL_stdinc_h.Uint16; -- ../include/SDL/SDL_events.h:149 end record; pragma Convention (C_Pass_By_Copy, SDL_MouseButtonEvent); -- ../include/SDL/SDL_events.h:144 type SDL_JoyAxisEvent is record c_type : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:154 which : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:155 axis : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:156 value : aliased SDL_SDL_stdinc_h.Sint16; -- ../include/SDL/SDL_events.h:157 end record; pragma Convention (C_Pass_By_Copy, SDL_JoyAxisEvent); -- ../include/SDL/SDL_events.h:153 type SDL_JoyBallEvent is record c_type : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:162 which : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:163 ball : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:164 xrel : aliased SDL_SDL_stdinc_h.Sint16; -- ../include/SDL/SDL_events.h:165 yrel : aliased SDL_SDL_stdinc_h.Sint16; -- ../include/SDL/SDL_events.h:166 end record; pragma Convention (C_Pass_By_Copy, SDL_JoyBallEvent); -- ../include/SDL/SDL_events.h:161 type SDL_JoyHatEvent is record c_type : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:171 which : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:172 hat : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:173 value : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:174 end record; pragma Convention (C_Pass_By_Copy, SDL_JoyHatEvent); -- ../include/SDL/SDL_events.h:170 type SDL_JoyButtonEvent is record c_type : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:184 which : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:185 button : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:186 state : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:187 end record; pragma Convention (C_Pass_By_Copy, SDL_JoyButtonEvent); -- ../include/SDL/SDL_events.h:183 type SDL_ResizeEvent is record c_type : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:195 w : aliased int; -- ../include/SDL/SDL_events.h:196 h : aliased int; -- ../include/SDL/SDL_events.h:197 end record; pragma Convention (C_Pass_By_Copy, SDL_ResizeEvent); -- ../include/SDL/SDL_events.h:194 type SDL_ExposeEvent is record c_type : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:202 end record; pragma Convention (C_Pass_By_Copy, SDL_ExposeEvent); -- ../include/SDL/SDL_events.h:201 type SDL_QuitEvent is record c_type : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:207 end record; pragma Convention (C_Pass_By_Copy, SDL_QuitEvent); -- ../include/SDL/SDL_events.h:206 type SDL_UserEvent_Rec is record c_type : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:212 code : aliased int; -- ../include/SDL/SDL_events.h:213 data1 : System.Address; -- ../include/SDL/SDL_events.h:214 data2 : System.Address; -- ../include/SDL/SDL_events.h:215 end record; pragma Convention (C_Pass_By_Copy, SDL_UserEvent_Rec); -- ../include/SDL/SDL_events.h:211 -- skipped empty struct SDL_SysWMmsg type SDL_SysWMEvent_Rec is record c_type : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:222 msg : System.Address; -- ../include/SDL/SDL_events.h:223 end record; pragma Convention (C_Pass_By_Copy, SDL_SysWMEvent_Rec); -- ../include/SDL/SDL_events.h:221 type SDL_Event (discr : unsigned := 0) is record case discr is when 0 => c_type : aliased SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:228 when 1 => active : aliased SDL_ActiveEvent_Rec; -- ../include/SDL/SDL_events.h:229 when 2 => key : aliased SDL_KeyboardEvent; -- ../include/SDL/SDL_events.h:230 when 3 => motion : aliased SDL_MouseMotionEvent; -- ../include/SDL/SDL_events.h:231 when 4 => button : aliased SDL_MouseButtonEvent; -- ../include/SDL/SDL_events.h:232 when 5 => jaxis : aliased SDL_JoyAxisEvent; -- ../include/SDL/SDL_events.h:233 when 6 => jball : aliased SDL_JoyBallEvent; -- ../include/SDL/SDL_events.h:234 when 7 => jhat : aliased SDL_JoyHatEvent; -- ../include/SDL/SDL_events.h:235 when 8 => jbutton : aliased SDL_JoyButtonEvent; -- ../include/SDL/SDL_events.h:236 when 9 => resize : aliased SDL_ResizeEvent; -- ../include/SDL/SDL_events.h:237 when 10 => expose : aliased SDL_ExposeEvent; -- ../include/SDL/SDL_events.h:238 when 11 => quit : aliased SDL_QuitEvent; -- ../include/SDL/SDL_events.h:239 when 12 => user : aliased SDL_UserEvent_Rec; -- ../include/SDL/SDL_events.h:240 when others => syswm : aliased SDL_SysWMEvent_Rec; -- ../include/SDL/SDL_events.h:241 end case; end record; pragma Convention (C_Pass_By_Copy, SDL_Event); pragma Unchecked_Union (SDL_Event); -- ../include/SDL/SDL_events.h:227 procedure SDL_PumpEvents; -- ../include/SDL/SDL_events.h:251 pragma Import (C, SDL_PumpEvents, "SDL_PumpEvents"); type SDL_eventaction is (SDL_ADDEVENT, SDL_PEEKEVENT, SDL_GETEVENT); pragma Convention (C, SDL_eventaction); -- ../include/SDL/SDL_events.h:257 function SDL_PeepEvents (events : access SDL_Event; numevents : int; action : SDL_eventaction; mask : SDL_SDL_stdinc_h.Uint32) return int; -- ../include/SDL/SDL_events.h:277 pragma Import (C, SDL_PeepEvents, "SDL_PeepEvents"); function SDL_PollEvent (event : access SDL_Event) return int; -- ../include/SDL/SDL_events.h:284 pragma Import (C, SDL_PollEvent, "SDL_PollEvent"); function SDL_WaitEvent (event : access SDL_Event) return int; -- ../include/SDL/SDL_events.h:290 pragma Import (C, SDL_WaitEvent, "SDL_WaitEvent"); function SDL_PushEvent (event : access SDL_Event) return int; -- ../include/SDL/SDL_events.h:296 pragma Import (C, SDL_PushEvent, "SDL_PushEvent"); type SDL_EventFilter is access function (arg1 : System.Address) return int; pragma Convention (C, SDL_EventFilter); -- ../include/SDL/SDL_events.h:300 procedure SDL_SetEventFilter (filter : SDL_EventFilter); -- ../include/SDL/SDL_events.h:323 pragma Import (C, SDL_SetEventFilter, "SDL_SetEventFilter"); function SDL_GetEventFilter return SDL_EventFilter; -- ../include/SDL/SDL_events.h:329 pragma Import (C, SDL_GetEventFilter, "SDL_GetEventFilter"); function SDL_EventState (c_type : SDL_SDL_stdinc_h.Uint8; state : int) return SDL_SDL_stdinc_h.Uint8; -- ../include/SDL/SDL_events.h:348 pragma Import (C, SDL_EventState, "SDL_EventState"); end SDL_SDL_events_h;
damaki/SPARKNaCl
Ada
19,155
ads
------------------------------------------------------------------------------ -- Copyright (c) 2020,2021 Protean Code Limited -- All rights reserved. -- -- "Simplified" (2-Clause) BSD Licence -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are -- met: -- -- 1. Redistributions of source code must retain the above copyright notice, -- This list of conditions and the following disclaimer. -- 2. Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR -- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------ with Interfaces; use Interfaces; package SPARKNaCl with Pure, SPARK_Mode => On is --============================================== -- Exported types and constants -- -- These are needed by clients, or by the -- specifications of child packages --============================================== subtype Byte is Unsigned_8; subtype U16 is Unsigned_16; subtype U32 is Unsigned_32; subtype U64 is Unsigned_64; subtype I32 is Integer_32; subtype N32 is I32 range 0 .. I32'Last; subtype I32_Bit is I32 range 0 .. 1; subtype I64 is Integer_64; subtype I64_Byte is I64 range 0 .. 255; subtype I64_Bit is I64 range 0 .. 1; -- Byte_Seq and constrained subtypes thereof type Byte_Seq is array (N32 range <>) of Byte; subtype Index_4 is I32 range 0 .. 3; subtype Index_8 is I32 range 0 .. 7; subtype Index_12 is I32 range 0 .. 11; subtype Index_16 is I32 range 0 .. 15; subtype Index_24 is I32 range 0 .. 23; subtype Index_32 is I32 range 0 .. 31; subtype Index_64 is I32 range 0 .. 63; subtype Bytes_4 is Byte_Seq (Index_4); subtype Bytes_8 is Byte_Seq (Index_8); subtype Bytes_12 is Byte_Seq (Index_12); subtype Bytes_16 is Byte_Seq (Index_16); subtype Bytes_24 is Byte_Seq (Index_24); subtype Bytes_32 is Byte_Seq (Index_32); subtype Bytes_64 is Byte_Seq (Index_64); Zero_Bytes_16 : constant Bytes_16 := (others => 0); Zero_Bytes_32 : constant Bytes_32 := (others => 0); -- A sequence of I64 values, but where each is limited to -- values 0 .. 255; type I64_Byte_Seq is array (N32 range <>) of I64_Byte; -- Sequences of I64 values and subtypes thereof type I64_Seq is array (N32 range <>) of I64; subtype I64_Seq_64 is I64_Seq (Index_64); type U32_Seq is array (N32 range <>) of U32; -------------------------------------------------------- -- Intrinsic functions -- -- GNAT supports Intrinsic Shift and Rotate operations -- on signed as well as unsigned integer types, and -- SPARK Community Edition 2021 knows the semantics -- of them. -------------------------------------------------------- function Shift_Right_Arithmetic (Value : I64; Amount : Natural) return I64 with Import, Convention => Intrinsic; function Shift_Right_Arithmetic (Value : I32; Amount : Natural) return I32 with Import, Convention => Intrinsic; -------------------------------------------------------- -- Constant time equality test -------------------------------------------------------- -- Primitive operation of Byte_Seq, so inheritable function Equal (X, Y : in Byte_Seq) return Boolean with Pure_Function, Global => null, Pre => X'First = Y'First and X'Last = Y'Last, Post => Equal'Result = (for all I in X'Range => X (I) = Y (I)); -------------------------------------------------------- -- Utility functions -------------------------------------------------------- -- Convert String to Byte_Seq using Character'Pos to -- map each character to a Byte value function To_Byte_Seq (S : String) return Byte_Seq with Global => null, Pre => S'Length >= 1, Post => To_Byte_Seq'Result'Length = S'Length and then To_Byte_Seq'Result'First = 0, Pure_Function; -------------------------------------------------------- -- Data sanitization -------------------------------------------------------- -- Primitive operation of Byte_Seq, so inheritable. -- In their "Volatiles are mis-compiled..." paper, -- Regehr et al. recommend that calls to such subprograms -- should never be in-lined as a way to prevent -- the incorrect optimization (to nothing) of such a call, -- so we apply No_Inline here. pragma Warnings (GNATProve, Off, "No_Inline"); procedure Sanitize (R : out Byte_Seq) with Global => null, No_Inline; private --============================================== -- Local types - visible below, in this package -- body and in the bodies of child packages --============================================== subtype Index_15 is I32 range 0 .. 14; subtype Index_20 is I32 range 0 .. 19; subtype Index_31 is I32 range 0 .. 30; subtype Index_128 is I32 range 0 .. 127; subtype Index_256 is I32 range 0 .. 255; subtype Bytes_128 is Byte_Seq (Index_128); subtype Bytes_256 is Byte_Seq (Index_256); type U64_Seq is array (N32 range <>) of U64; subtype U32_Seq_4 is U32_Seq (Index_4); subtype U32_Seq_8 is U32_Seq (Index_8); subtype U32_Seq_16 is U32_Seq (Index_16); subtype I64_Byte_Seq_32 is I64_Byte_Seq (Index_32); subtype U64_Seq_8 is U64_Seq (Index_8); subtype U64_Seq_16 is U64_Seq (Index_16); -- Constant Sigma used for initialization of Core Salsa20 -- function in both Stream and Cryptobox packages Sigma : constant Bytes_16 := (0 => Character'Pos ('e'), 1 => Character'Pos ('x'), 2 => Character'Pos ('p'), 3 => Character'Pos ('a'), 4 => Character'Pos ('n'), 5 => Character'Pos ('d'), 6 => Character'Pos (' '), 7 => Character'Pos ('3'), 8 => Character'Pos ('2'), 9 => Character'Pos ('-'), 10 => Character'Pos ('b'), 11 => Character'Pos ('y'), 12 => Character'Pos ('t'), 13 => Character'Pos ('e'), 14 => Character'Pos (' '), 15 => Character'Pos ('k')); ------------------------------------------------------------------------- -- Constants common to the whole library -- -- Some "Huffman-lite coding" is applied to names here - the most -- frequently used constants having abbreviated names. ------------------------------------------------------------------------- -- GF "Limbs" are stored modulo 65536 -- -- "LM" = "Limb Modulus" -- "LMM1" = "Limb Modulus Minus 1" LM : constant := 65536; LMM1 : constant := 65535; -- The modulus of curve 25519 is (2**255 - 19). -- In the reduction of GF values, we sometime need to multiply a limb -- value by 2**256 mod (2**255 - 19), which is actually equal to 38, -- since 2**256 = (2 * (2**255 - 19)) + 38 -- -- "R2256" = "Remainder of 2**256 (modulo 2**255-19)" R2256 : constant := 38; ------------------------------------------------------------------------- -- Bounds on All GF Limbs -- -- In the most general case, we define GF_Any_Limb so it can take -- on the value of any GF limb at any point including intermediate -- values inside the "*", "-" and "+" operations. -- -- Lower bound on GF_Any_Limb -- -- During a subtraction of a GF, a limb can also reach -65535, -- but this can be rounded down to -65536 by addition of a -1 carry, -- so the lower bound is -65536 -- -- Upper bound on GF_Any_Limb -- -- During the "reduction modulo 2**255-19" phase of the "*" -- operation, each limb GF (I) is added to R2256 * GF (I + 16) -- The worst-case upper bound of this result is when I = 0, -- where GF (0) has upper bound MGFLP and GF (16) has upper bound -- 15 * MGFLP. -- -- Therefore the upper bound of Any_GF_Limb is -- (R2256 * 15 + 1) * MGFLP = 571 * MGFLP ------------------------------------------------------------------------- -- "Maximum GF Limb Coefficient" MGFLC : constant := (R2256 * 15) + 1; -- In multiplying two normalized GFs, a simple product of -- two limbs is bounded to 65535**2. This comes up in -- predicates and subtypes below, so a named number here -- is called for. The name "MGFLP" is short for -- "Maximum GF Limb Product" MGFLP : constant := LMM1 * LMM1; -- The max value of a GF32_Any_Limb is the upper bound on digit 0 -- following ONE application of Product_To_Seminormal_GF to the -- intermidiate result of a "*" operation. This value is actually -- a bit less than 2**27 which justifies that subsequence normalization -- steps can all be done in 32-bit arithmetic. -- -- See the declaration of Seminormal_GF_LSL below for detail of -- how this value is derived. GF32_Any_Limb_Max : constant := (LMM1 + R2256 * ((53 * MGFLP) / LM)); subtype GF32_Any_Limb is I32 range -LM .. GF32_Any_Limb_Max; type GF32 is array (Index_16) of GF32_Any_Limb; -- In the "*" operator for GF, intermediate results require -- 64 bit integers before being normalized, so... subtype GF64_Any_Limb is I64 range -LM .. (MGFLC * MGFLP); type GF64 is array (Index_16) of GF64_Any_Limb; -- GF64 Product Accumulator - used in "*" to accumulate the -- intermediate results of Left * Right type GF64_PA is array (Index_31) of GF64_Any_Limb; ------------------------------------------------------------------------- subtype GF64_Normal_Limb is GF64_Any_Limb range 0 .. LMM1; subtype GF32_Normal_Limb is GF32_Any_Limb range 0 .. LMM1; subtype GF16_Normal_Limb is U16; subtype Normal_GF64 is GF64 with Dynamic_Predicate => (for all I in Index_16 => Normal_GF64 (I) in GF64_Normal_Limb); subtype Normal_GF32 is GF32 with Dynamic_Predicate => (for all I in Index_16 => Normal_GF32 (I) in GF32_Normal_Limb); type Normal_GF is array (Index_16) of GF16_Normal_Limb with Alignment => 4; ------------------------------------------------------------------------- ------------------------------------------------------------------------- -- Subtypes supporting "+" operation on GF -- -- In a "+" operation, intermediate result limbs peak at +131070, so subtype GF_Sum_Limb is I32 range 0 .. (LMM1 * 2); subtype Sum_GF is GF32 with Dynamic_Predicate => (for all I in Index_16 => Sum_GF (I) in GF_Sum_Limb); ------------------------------------------------------------------------- ------------------------------------------------------------------------- -- Subtypes supporting "-" operation on GF -- -- In a "-" operation, each limb of the intermediate result is -- increased by 65536 to make sure it's not negative, and one -- is taken off the next limb up to balance the value. -- -- This means that -- Limb 0 is in range (0 - 65535) + 65536 .. (65535 - 0) + 65536 -- which is 1 .. 131071 -- Limbs 1 .. 15 are in range (0 - 65535) + 65535 .. (65535 - 0) + 65535 -- which is 0 .. 131070 -- -- Finally, to balance the -1 value carried into limb 16, limb 0 -- is reduced by R2256, so... subtype Difference_GF is GF32 with Dynamic_Predicate => ((Difference_GF (0) in (1 - R2256) .. (2 * LMM1) + 1) and (for all K in Index_16 range 1 .. 15 => Difference_GF (K) in 0 .. 2 * LMM1)); ------------------------------------------------------------------------- -- Subtypes supporting "*" operation on GF -- -- A GF which is the result of multiplying two other Normalized GFs, -- but BEFORE normalization is applied has the following bounds on -- its limbs. The upperbound on Limb 0 is MGFLC * MGFLP as in -- GF_Any_Limb, but the upper bound reduces by 37 * MGFLP -- for each limb onwards... -- -- Lower-bound here is 0 since "*" always takes Normal_GF -- parameters, so an intermediate limb can never be negative. subtype Product_GF is GF64 with Dynamic_Predicate => (for all I in Index_16 => Product_GF (I) >= 0 and Product_GF (I) <= (MGFLC - 37 * GF64_Any_Limb (I)) * MGFLP); ---------------------------------------------------------------------- -- A "Seminormal GF" is the result of applying a single -- normalization step to a Product_GF -- -- Least Significant Limb ("LSL") of a Seminormal GF. -- LSL is initially normalized to 0 .. 65535, but gets -- R2256 * Carry added to it, where Carry is (Limb 15 / 65536) -- The upper-bound on Limb 15 is given by substituting I = 14 -- into the Dynamic_Predicate above, so -- (MGFLC - 37 * 14) * MGFLP = 53 * MGFLP -- See the body of Product_To_Seminormal for the full -- proof of this upper-bound subtype Seminormal_GF_LSL is GF32_Any_Limb range 0 .. GF32_Any_Limb_Max; -- Limbs 1 though 15 are in 0 .. 65535, but the -- Least Significant Limb 0 is in GF_Seminormal_Product_LSL subtype Seminormal_GF is GF32 with Dynamic_Predicate => (Seminormal_GF (0) in Seminormal_GF_LSL and (for all I in Index_16 range 1 .. 15 => Seminormal_GF (I) in GF32_Normal_Limb)); ------------------------------------------------------------------------ -- A "Nearly-normal GF" is the result of applying either: -- 1. TWO normalization steps to a Product_GF -- OR -- 2. ONE normalization step to the SUM of 2 normalized GFs -- OR -- 3. ONE normalization step to the DIFFERENCE of 2 normalized GFs -- -- The least-significant-limb is normalized to 0 .. 65535, but then -- has +R2256 or -R2256 added to it, so its range is... subtype Nearlynormal_GF is GF32 with Dynamic_Predicate => ((Nearlynormal_GF (0) in -R2256 .. LMM1 + R2256) and (for all K in Index_16 range 1 .. 15 => (Nearlynormal_GF (K) in GF32_Normal_Limb))); ------------------------------------------------------------------------ --================================================= -- Constants, used in more than one child package --================================================= GF_0 : constant Normal_GF := (others => 0); GF32_0 : constant Normal_GF32 := (others => 0); GF_1 : constant Normal_GF := (1, others => 0); --================== -- Local functions --================== -- returns equivalent of X >> 16 in C, doing an arithmetic -- shift right when X is negative, assuming 2's complement -- representation function ASR64_16 (X : in I64) return I64 is (Shift_Right_Arithmetic (X, 16)) with Post => (if X >= 0 then ASR64_16'Result = X / LM else ASR64_16'Result = ((X + 1) / LM) - 1); -- returns equivalent of X >> 16 in C, doing an arithmetic -- shift right when X is negative, assuming 2's complement -- representation function ASR32_16 (X : in I32) return I32 is (Shift_Right_Arithmetic (X, 16)) with Post => (if X >= 0 then ASR32_16'Result = X / LM else ASR32_16'Result = ((X + 1) / LM) - 1); -- returns equivalent of X >> 8 in C, doing an arithmetic -- shift right when X is negative, assuming 2's complement -- representation function ASR_8 (X : in I64) return I64 is (Shift_Right_Arithmetic (X, 8)) with Post => (if X >= 0 then ASR_8'Result = X / 256 else ASR_8'Result = ((X + 1) / 256) - 1); -- returns equivalent of X >> 4 in C, doing an arithmetic -- shift right when X is negative, assuming 2's complement -- representation function ASR_4 (X : in I64) return I64 is (Shift_Right_Arithmetic (X, 4)) with Post => (if X >= 0 then ASR_4'Result = X / 16 else ASR_4'Result = ((X + 1) / 16) - 1); --=============================== -- Local subprogram declarations --=============================== function "+" (Left, Right : in Normal_GF) return Normal_GF with Pure_Function, Global => null; function "-" (Left, Right : in Normal_GF) return Normal_GF with Pure_Function, Global => null; function "*" (Left, Right : in Normal_GF) return Normal_GF with Pure_Function, Global => null; function Square (A : in Normal_GF) return Normal_GF is (A * A) with Pure_Function, Global => null; -- Additional sanitization procedures for local types procedure Sanitize_U32 (R : out U32) with Global => null, No_Inline; procedure Sanitize_U16 (R : out U16) with Global => null, No_Inline; procedure Sanitize_U64 (R : out U64) with Global => null, No_Inline; procedure Sanitize_GF32 (R : out GF32) with Global => null, No_Inline, Post => R in Normal_GF32; procedure Sanitize_GF16 (R : out Normal_GF) with Global => null, No_Inline, Post => R in Normal_GF; procedure Sanitize_GF64_PA (R : out GF64_PA) with Global => null, No_Inline; procedure Sanitize_I64_Seq (R : out I64_Seq) with Global => null, No_Inline; procedure Sanitize_U32_Seq (R : out U32_Seq) with Global => null, No_Inline; procedure Sanitize_Boolean (R : out Boolean) with Global => null, No_Inline; end SPARKNaCl;
stcarrez/swagger-ada
Ada
1,673
adb
-- ------------ EDIT NOTE ------------ -- REST API Validation -- API to validate -- This file was generated with openapi-generator. You can modify it to implement -- the client. After you modify this file, you should add the following line -- to the .openapi-generator-ignore file: -- -- src/testbinary.ads -- -- Then, you can drop this edit note comment. -- ------------ EDIT NOTE ------------ with TestBinary.Clients; with TestBinary.Models; with Swagger; with Swagger.Credentials.OAuth; with Util.Http.Clients.Curl; with Ada.Text_IO; with Ada.Command_Line; with Ada.Calendar.Formatting; with Ada.Exceptions; procedure TestBinary.Client is use Ada.Text_IO; procedure Usage; Server : constant Swagger.UString := Swagger.To_UString ("http://localhost:8080/v2"); Arg_Count : constant Natural := Ada.Command_Line.Argument_Count; Arg : Positive := 1; procedure Usage is begin Put_Line ("Usage: TestBinary {params}..."); end Usage; begin if Arg_Count <= 1 then Usage; return; end if; Util.Http.Clients.Curl.Register; declare Command : constant String := Ada.Command_Line.Argument (Arg); Item : constant String := Ada.Command_Line.Argument (Arg + 1); Cred : aliased Swagger.Credentials.OAuth.OAuth2_Credential_Type; C : TestBinary.Clients.Client_Type; begin C.Set_Server (Server); C.Set_Credentials (Cred'Unchecked_Access); Arg := Arg + 2; exception when E : Constraint_Error => Put_Line ("Constraint error raised: " & Ada.Exceptions.Exception_Message (E)); end; end TestBinary.Client;
reznikmm/matreshka
Ada
24,698
adb
------------------------------------------------------------------------------ -- -- -- 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.Elements; with AMF.Internals.Element_Collections; with AMF.Internals.Helpers; with AMF.Internals.Tables.UML_Attributes; with AMF.Visitors.UML_Iterators; with AMF.Visitors.UML_Visitors; with League.Strings.Internals; with Matreshka.Internals.Strings; package body AMF.Internals.UML_Expansion_Nodes is ------------------- -- Enter_Element -- ------------------- overriding procedure Enter_Element (Self : not null access constant UML_Expansion_Node_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then AMF.Visitors.UML_Visitors.UML_Visitor'Class (Visitor).Enter_Expansion_Node (AMF.UML.Expansion_Nodes.UML_Expansion_Node_Access (Self), Control); end if; end Enter_Element; ------------------- -- Leave_Element -- ------------------- overriding procedure Leave_Element (Self : not null access constant UML_Expansion_Node_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then AMF.Visitors.UML_Visitors.UML_Visitor'Class (Visitor).Leave_Expansion_Node (AMF.UML.Expansion_Nodes.UML_Expansion_Node_Access (Self), Control); end if; end Leave_Element; ------------------- -- Visit_Element -- ------------------- overriding procedure Visit_Element (Self : not null access constant UML_Expansion_Node_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Iterator in AMF.Visitors.UML_Iterators.UML_Iterator'Class then AMF.Visitors.UML_Iterators.UML_Iterator'Class (Iterator).Visit_Expansion_Node (Visitor, AMF.UML.Expansion_Nodes.UML_Expansion_Node_Access (Self), Control); end if; end Visit_Element; ------------------------- -- Get_Region_As_Input -- ------------------------- overriding function Get_Region_As_Input (Self : not null access constant UML_Expansion_Node_Proxy) return AMF.UML.Expansion_Regions.UML_Expansion_Region_Access is begin return AMF.UML.Expansion_Regions.UML_Expansion_Region_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Region_As_Input (Self.Element))); end Get_Region_As_Input; ------------------------- -- Set_Region_As_Input -- ------------------------- overriding procedure Set_Region_As_Input (Self : not null access UML_Expansion_Node_Proxy; To : AMF.UML.Expansion_Regions.UML_Expansion_Region_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Region_As_Input (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Region_As_Input; -------------------------- -- Get_Region_As_Output -- -------------------------- overriding function Get_Region_As_Output (Self : not null access constant UML_Expansion_Node_Proxy) return AMF.UML.Expansion_Regions.UML_Expansion_Region_Access is begin return AMF.UML.Expansion_Regions.UML_Expansion_Region_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Region_As_Output (Self.Element))); end Get_Region_As_Output; -------------------------- -- Set_Region_As_Output -- -------------------------- overriding procedure Set_Region_As_Output (Self : not null access UML_Expansion_Node_Proxy; To : AMF.UML.Expansion_Regions.UML_Expansion_Region_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Region_As_Output (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Region_As_Output; ------------------ -- Get_In_State -- ------------------ overriding function Get_In_State (Self : not null access constant UML_Expansion_Node_Proxy) return AMF.UML.States.Collections.Set_Of_UML_State is begin return AMF.UML.States.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_In_State (Self.Element))); end Get_In_State; ------------------------- -- Get_Is_Control_Type -- ------------------------- overriding function Get_Is_Control_Type (Self : not null access constant UML_Expansion_Node_Proxy) return Boolean is begin return AMF.Internals.Tables.UML_Attributes.Internal_Get_Is_Control_Type (Self.Element); end Get_Is_Control_Type; ------------------------- -- Set_Is_Control_Type -- ------------------------- overriding procedure Set_Is_Control_Type (Self : not null access UML_Expansion_Node_Proxy; To : Boolean) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Control_Type (Self.Element, To); end Set_Is_Control_Type; ------------------ -- Get_Ordering -- ------------------ overriding function Get_Ordering (Self : not null access constant UML_Expansion_Node_Proxy) return AMF.UML.UML_Object_Node_Ordering_Kind is begin return AMF.Internals.Tables.UML_Attributes.Internal_Get_Ordering (Self.Element); end Get_Ordering; ------------------ -- Set_Ordering -- ------------------ overriding procedure Set_Ordering (Self : not null access UML_Expansion_Node_Proxy; To : AMF.UML.UML_Object_Node_Ordering_Kind) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Ordering (Self.Element, To); end Set_Ordering; ------------------- -- Get_Selection -- ------------------- overriding function Get_Selection (Self : not null access constant UML_Expansion_Node_Proxy) return AMF.UML.Behaviors.UML_Behavior_Access is begin return AMF.UML.Behaviors.UML_Behavior_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Selection (Self.Element))); end Get_Selection; ------------------- -- Set_Selection -- ------------------- overriding procedure Set_Selection (Self : not null access UML_Expansion_Node_Proxy; To : AMF.UML.Behaviors.UML_Behavior_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Selection (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Selection; --------------------- -- Get_Upper_Bound -- --------------------- overriding function Get_Upper_Bound (Self : not null access constant UML_Expansion_Node_Proxy) return AMF.UML.Value_Specifications.UML_Value_Specification_Access is begin return AMF.UML.Value_Specifications.UML_Value_Specification_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Upper_Bound (Self.Element))); end Get_Upper_Bound; --------------------- -- Set_Upper_Bound -- --------------------- overriding procedure Set_Upper_Bound (Self : not null access UML_Expansion_Node_Proxy; To : AMF.UML.Value_Specifications.UML_Value_Specification_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Upper_Bound (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Upper_Bound; ------------------ -- Get_Activity -- ------------------ overriding function Get_Activity (Self : not null access constant UML_Expansion_Node_Proxy) return AMF.UML.Activities.UML_Activity_Access is begin return AMF.UML.Activities.UML_Activity_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Activity (Self.Element))); end Get_Activity; ------------------ -- Set_Activity -- ------------------ overriding procedure Set_Activity (Self : not null access UML_Expansion_Node_Proxy; To : AMF.UML.Activities.UML_Activity_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Activity (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Activity; ------------------ -- Get_In_Group -- ------------------ overriding function Get_In_Group (Self : not null access constant UML_Expansion_Node_Proxy) return AMF.UML.Activity_Groups.Collections.Set_Of_UML_Activity_Group is begin return AMF.UML.Activity_Groups.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_In_Group (Self.Element))); end Get_In_Group; --------------------------------- -- Get_In_Interruptible_Region -- --------------------------------- overriding function Get_In_Interruptible_Region (Self : not null access constant UML_Expansion_Node_Proxy) return AMF.UML.Interruptible_Activity_Regions.Collections.Set_Of_UML_Interruptible_Activity_Region is begin return AMF.UML.Interruptible_Activity_Regions.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_In_Interruptible_Region (Self.Element))); end Get_In_Interruptible_Region; ---------------------- -- Get_In_Partition -- ---------------------- overriding function Get_In_Partition (Self : not null access constant UML_Expansion_Node_Proxy) return AMF.UML.Activity_Partitions.Collections.Set_Of_UML_Activity_Partition is begin return AMF.UML.Activity_Partitions.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_In_Partition (Self.Element))); end Get_In_Partition; ---------------------------- -- Get_In_Structured_Node -- ---------------------------- overriding function Get_In_Structured_Node (Self : not null access constant UML_Expansion_Node_Proxy) return AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access is begin return AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_In_Structured_Node (Self.Element))); end Get_In_Structured_Node; ---------------------------- -- Set_In_Structured_Node -- ---------------------------- overriding procedure Set_In_Structured_Node (Self : not null access UML_Expansion_Node_Proxy; To : AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_In_Structured_Node (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_In_Structured_Node; ------------------ -- Get_Incoming -- ------------------ overriding function Get_Incoming (Self : not null access constant UML_Expansion_Node_Proxy) return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge is begin return AMF.UML.Activity_Edges.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Incoming (Self.Element))); end Get_Incoming; ------------------ -- Get_Outgoing -- ------------------ overriding function Get_Outgoing (Self : not null access constant UML_Expansion_Node_Proxy) return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge is begin return AMF.UML.Activity_Edges.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Outgoing (Self.Element))); end Get_Outgoing; ------------------------ -- Get_Redefined_Node -- ------------------------ overriding function Get_Redefined_Node (Self : not null access constant UML_Expansion_Node_Proxy) return AMF.UML.Activity_Nodes.Collections.Set_Of_UML_Activity_Node is begin return AMF.UML.Activity_Nodes.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Redefined_Node (Self.Element))); end Get_Redefined_Node; ----------------- -- Get_Is_Leaf -- ----------------- overriding function Get_Is_Leaf (Self : not null access constant UML_Expansion_Node_Proxy) return Boolean is begin return AMF.Internals.Tables.UML_Attributes.Internal_Get_Is_Leaf (Self.Element); end Get_Is_Leaf; ----------------- -- Set_Is_Leaf -- ----------------- overriding procedure Set_Is_Leaf (Self : not null access UML_Expansion_Node_Proxy; To : Boolean) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Leaf (Self.Element, To); end Set_Is_Leaf; --------------------------- -- Get_Redefined_Element -- --------------------------- overriding function Get_Redefined_Element (Self : not null access constant UML_Expansion_Node_Proxy) return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element is begin return AMF.UML.Redefinable_Elements.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Redefined_Element (Self.Element))); end Get_Redefined_Element; ------------------------------ -- Get_Redefinition_Context -- ------------------------------ overriding function Get_Redefinition_Context (Self : not null access constant UML_Expansion_Node_Proxy) return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is begin return AMF.UML.Classifiers.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Redefinition_Context (Self.Element))); end Get_Redefinition_Context; --------------------------- -- Get_Client_Dependency -- --------------------------- overriding function Get_Client_Dependency (Self : not null access constant UML_Expansion_Node_Proxy) return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency is begin return AMF.UML.Dependencies.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Client_Dependency (Self.Element))); end Get_Client_Dependency; ------------------------- -- Get_Name_Expression -- ------------------------- overriding function Get_Name_Expression (Self : not null access constant UML_Expansion_Node_Proxy) return AMF.UML.String_Expressions.UML_String_Expression_Access is begin return AMF.UML.String_Expressions.UML_String_Expression_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Name_Expression (Self.Element))); end Get_Name_Expression; ------------------------- -- Set_Name_Expression -- ------------------------- overriding procedure Set_Name_Expression (Self : not null access UML_Expansion_Node_Proxy; To : AMF.UML.String_Expressions.UML_String_Expression_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Name_Expression (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Name_Expression; ------------------- -- Get_Namespace -- ------------------- overriding function Get_Namespace (Self : not null access constant UML_Expansion_Node_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access is begin return AMF.UML.Namespaces.UML_Namespace_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Namespace (Self.Element))); end Get_Namespace; ------------------------ -- Get_Qualified_Name -- ------------------------ overriding function Get_Qualified_Name (Self : not null access constant UML_Expansion_Node_Proxy) return AMF.Optional_String is begin declare use type Matreshka.Internals.Strings.Shared_String_Access; Aux : constant Matreshka.Internals.Strings.Shared_String_Access := AMF.Internals.Tables.UML_Attributes.Internal_Get_Qualified_Name (Self.Element); begin if Aux = null then return (Is_Empty => True); else return (False, League.Strings.Internals.Create (Aux)); end if; end; end Get_Qualified_Name; -------------- -- Get_Type -- -------------- overriding function Get_Type (Self : not null access constant UML_Expansion_Node_Proxy) return AMF.UML.Types.UML_Type_Access is begin return AMF.UML.Types.UML_Type_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Type (Self.Element))); end Get_Type; -------------- -- Set_Type -- -------------- overriding procedure Set_Type (Self : not null access UML_Expansion_Node_Proxy; To : AMF.UML.Types.UML_Type_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Type (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Type; ------------------------ -- Is_Consistent_With -- ------------------------ overriding function Is_Consistent_With (Self : not null access constant UML_Expansion_Node_Proxy; Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Is_Consistent_With unimplemented"); raise Program_Error with "Unimplemented procedure UML_Expansion_Node_Proxy.Is_Consistent_With"; return Is_Consistent_With (Self, Redefinee); end Is_Consistent_With; ----------------------------------- -- Is_Redefinition_Context_Valid -- ----------------------------------- overriding function Is_Redefinition_Context_Valid (Self : not null access constant UML_Expansion_Node_Proxy; Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Is_Redefinition_Context_Valid unimplemented"); raise Program_Error with "Unimplemented procedure UML_Expansion_Node_Proxy.Is_Redefinition_Context_Valid"; return Is_Redefinition_Context_Valid (Self, Redefined); end Is_Redefinition_Context_Valid; ------------------------- -- All_Owning_Packages -- ------------------------- overriding function All_Owning_Packages (Self : not null access constant UML_Expansion_Node_Proxy) return AMF.UML.Packages.Collections.Set_Of_UML_Package is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "All_Owning_Packages unimplemented"); raise Program_Error with "Unimplemented procedure UML_Expansion_Node_Proxy.All_Owning_Packages"; return All_Owning_Packages (Self); end All_Owning_Packages; ----------------------------- -- Is_Distinguishable_From -- ----------------------------- overriding function Is_Distinguishable_From (Self : not null access constant UML_Expansion_Node_Proxy; N : AMF.UML.Named_Elements.UML_Named_Element_Access; Ns : AMF.UML.Namespaces.UML_Namespace_Access) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented"); raise Program_Error with "Unimplemented procedure UML_Expansion_Node_Proxy.Is_Distinguishable_From"; return Is_Distinguishable_From (Self, N, Ns); end Is_Distinguishable_From; --------------- -- Namespace -- --------------- overriding function Namespace (Self : not null access constant UML_Expansion_Node_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Namespace unimplemented"); raise Program_Error with "Unimplemented procedure UML_Expansion_Node_Proxy.Namespace"; return Namespace (Self); end Namespace; end AMF.Internals.UML_Expansion_Nodes;
annexi-strayline/AURA
Ada
6,515
adb
------------------------------------------------------------------------------ -- -- -- Ada User Repository Annex (AURA) -- -- ANNEXI-STRAYLINE Reference Implementation -- -- -- -- Command Line Interface -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Copyright (C) 2020-2021, ANNEXI-STRAYLINE Trans-Human Ltd. -- -- All rights reserved. -- -- -- -- Original Contributors: -- -- * Richard Wai (ANNEXI-STRAYLINE) -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- -- -- * Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -- -- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with Ada.Assertions; with Ada.Streams.Stream_IO; with Registrar.Registration; with Stream_Hashing.Collective; separate (Build) package body Hash_Compilation_Orders is use Registrar.Library_Units; ----------- -- Image -- ----------- function Image (Order: Hash_Compilation_Order) return String is ("[Hash_Compilation_Order] (Build)" & New_Line & " Target unit: " & Order.Target.Name.To_UTF8_String); ------------- -- Execute -- ------------- procedure Execute (Order: in out Hash_Compilation_Order) is use Stream_Hashing.Collective; Collection: Hash_Collections.Set; procedure Include_Hash (Path: in String) is use Ada.Streams.Stream_IO; File: File_Type; begin Open (File => File, Mode => In_File, Name => Path); Collection.Include (Stream_Hashing.Digest_Stream (Stream (File))); Close (File); end Include_Hash; Object_Path: constant String := Object_File_Name (Order.Target); ALI_Path : constant String := ALI_File_Name (Order.Target); Have_Object: constant Boolean := Ada.Directories.Exists (Object_Path); Have_ALI : constant Boolean := Ada.Directories.Exists (ALI_Path); begin pragma Assert (Order.Target.Kind not in Unknown | Subunit and then Order.Target.State in Available | Compiled); -- Don't waste time if we have no object or ALI! if (not Have_Object) and (not Have_ALI) then return; end if; -- For units that are not External_Units, we expect to have an ".ali". -- file as well as .o file. It is all or nothing. If we don't find both, -- then we want to delete the ones we do have. -- -- For subsystems checked-out from "System" repository, Object_Path will -- return a path to the library shared object. -- -- Otherwise, we expect that an External Unit will not have an ALI file if Order.Target.Kind = External_Unit then Ada.Assertions.Assert (Check => not Have_ALI, Message => "External_Units should not have .ali files."); elsif Have_Object xor Have_ALI then if Have_Object then Ada.Directories.Delete_File (Object_Path); else Ada.Directories.Delete_File (ALI_Path); end if; return; end if; if Have_Object then Include_Hash (Object_Path); end if; if Have_ALI then Include_Hash (ALI_Path); end if; Compute_Collective_Hash (Collection => Collection, Collective_Hash => Order.Target.Compilation_Hash); Order.Target.State := Compiled; -- If we got this far, it definately means the unit was compiled, so -- we can promote that unit to being such Registrar.Registration.Update_Library_Unit (Order.Target); end Execute; end Hash_Compilation_Orders;
reznikmm/matreshka
Ada
3,883
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 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$ ------------------------------------------------------------------------------ with Matreshka.ODF_Attributes.Style.Flow_With_Text; package ODF.DOM.Attributes.Style.Flow_With_Text.Internals is function Create (Node : Matreshka.ODF_Attributes.Style.Flow_With_Text.Style_Flow_With_Text_Access) return ODF.DOM.Attributes.Style.Flow_With_Text.ODF_Style_Flow_With_Text; function Wrap (Node : Matreshka.ODF_Attributes.Style.Flow_With_Text.Style_Flow_With_Text_Access) return ODF.DOM.Attributes.Style.Flow_With_Text.ODF_Style_Flow_With_Text; end ODF.DOM.Attributes.Style.Flow_With_Text.Internals;
zhmu/ananas
Ada
148
ads
package prefix1 is type Arr is array (1..10) of Natural; type T is tagged null record; function Func (Object : T) return Arr; end prefix1;
reznikmm/matreshka
Ada
4,322
adb
------------------------------------------------------------------------------ -- -- -- 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$ ------------------------------------------------------------------------------ with Ada.Wide_Wide_Text_IO; package body AMF.Internals.XMI_Error_Handlers is ----------- -- Error -- ----------- overriding procedure Error (Self : in out Default_Error_Handler; Occurrence : XML.SAX.Parse_Exceptions.SAX_Parse_Exception; Success : in out Boolean) is begin -- Don't output duplicate messages. if not Self.Messages.Contains (Occurrence.Message) then Self.Messages.Insert (Occurrence.Message); Ada.Wide_Wide_Text_IO.Put_Line (Ada.Wide_Wide_Text_IO.Standard_Error, Occurrence.Message.To_Wide_Wide_String); end if; end Error; ------------------ -- Error_String -- ------------------ overriding function Error_String (Self : Default_Error_Handler) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return League.Strings.Empty_Universal_String; end Error_String; end AMF.Internals.XMI_Error_Handlers;
sungyeon/drake
Ada
9,938
ads
pragma License (Unrestricted); -- Ada 2005 with Ada.Iterator_Interfaces; private with Ada.Containers.Copy_On_Write; private with Ada.Containers.Hash_Tables; private with Ada.Finalization; private with Ada.Streams; generic type Element_Type (<>) is private; with function Hash (Element : Element_Type) return Hash_Type; with function Equivalent_Elements (Left, Right : Element_Type) return Boolean; with function "=" (Left, Right : Element_Type) return Boolean is <>; package Ada.Containers.Indefinite_Hashed_Sets is pragma Preelaborate; pragma Remote_Types; type Set is tagged private with Constant_Indexing => Constant_Reference, Default_Iterator => Iterate, Iterator_Element => Element_Type; pragma Preelaborable_Initialization (Set); type Cursor is private; pragma Preelaborable_Initialization (Cursor); -- modified -- Empty_Set : constant Set; function Empty_Set return Set; No_Element : constant Cursor; function Has_Element (Position : Cursor) return Boolean; package Set_Iterator_Interfaces is new Iterator_Interfaces (Cursor, Has_Element); overriding function "=" (Left, Right : Set) return Boolean; function Equivalent_Sets (Left, Right : Set) return Boolean; function To_Set (New_Item : Element_Type) return Set; -- diff (Generic_Array_To_Set) -- -- -- -- function Capacity (Container : Set) return Count_Type; procedure Reserve_Capacity ( Container : in out Set; Capacity : Count_Type); function Length (Container : Set) return Count_Type; function Is_Empty (Container : Set) return Boolean; procedure Clear (Container : in out Set); function Element (Position : Cursor) return Element_Type; procedure Replace_Element ( Container : in out Set; Position : Cursor; New_Item : Element_Type); procedure Query_Element ( Position : Cursor; Process : not null access procedure (Element : Element_Type)); type Constant_Reference_Type ( Element : not null access constant Element_Type) is private with Implicit_Dereference => Element; function Constant_Reference (Container : aliased Set; Position : Cursor) return Constant_Reference_Type; procedure Assign (Target : in out Set; Source : Set); function Copy (Source : Set; Capacity : Count_Type := 0) return Set; procedure Move (Target : in out Set; Source : in out Set); procedure Insert ( Container : in out Set; New_Item : Element_Type; Position : out Cursor; Inserted : out Boolean); procedure Insert ( Container : in out Set; New_Item : Element_Type); procedure Include (Container : in out Set; New_Item : Element_Type); procedure Replace (Container : in out Set; New_Item : Element_Type); procedure Exclude (Container : in out Set; Item : Element_Type); procedure Delete (Container : in out Set; Item : Element_Type); procedure Delete (Container : in out Set; Position : in out Cursor); procedure Union (Target : in out Set; Source : Set); function Union (Left, Right : Set) return Set; function "or" (Left, Right : Set) return Set renames Union; procedure Intersection (Target : in out Set; Source : Set); function Intersection (Left, Right : Set) return Set; function "and" (Left, Right : Set) return Set renames Intersection; procedure Difference (Target : in out Set; Source : Set); function Difference (Left, Right : Set) return Set; function "-" (Left, Right : Set) return Set renames Difference; procedure Symmetric_Difference (Target : in out Set; Source : Set); function Symmetric_Difference (Left, Right : Set) return Set; function "xor" (Left, Right : Set) return Set renames Symmetric_Difference; function Overlap (Left, Right : Set) return Boolean; function Is_Subset (Subset : Set; Of_Set : Set) return Boolean; function First (Container : Set) return Cursor; function Next (Position : Cursor) return Cursor; procedure Next (Position : in out Cursor); function Find (Container : Set; Item : Element_Type) return Cursor; function Contains (Container : Set; Item : Element_Type) return Boolean; function Equivalent_Elements (Left, Right : Cursor) return Boolean; function Equivalent_Elements (Left : Cursor; Right : Element_Type) return Boolean; -- function Equivalent_Elements (Left : Element_Type; Right : Cursor) -- return Boolean; -- modified procedure Iterate ( Container : Set'Class; -- not primitive Process : not null access procedure (Position : Cursor)); -- modified function Iterate (Container : Set'Class) -- not primitive return Set_Iterator_Interfaces.Forward_Iterator'Class; generic type Key_Type (<>) is private; with function Key (Element : Element_Type) return Key_Type; with function Hash (Key : Key_Type) return Hash_Type; with function Equivalent_Keys (Left, Right : Key_Type) return Boolean; package Generic_Keys is function Key (Position : Cursor) return Key_Type; function Element (Container : Set; Key : Key_Type) return Element_Type; procedure Replace ( Container : in out Set; Key : Key_Type; New_Item : Element_Type); procedure Exclude (Container : in out Set; Key : Key_Type); procedure Delete (Container : in out Set; Key : Key_Type); function Find (Container : Set; Key : Key_Type) return Cursor; function Contains (Container : Set; Key : Key_Type) return Boolean; procedure Update_Element_Preserving_Key ( Container : in out Set; Position : Cursor; Process : not null access procedure ( Element : in out Element_Type)); type Reference_Type ( Element : not null access Element_Type) is private with Implicit_Dereference => Element; function Reference_Preserving_Key ( Container : aliased in out Set; Position : Cursor) return Reference_Type; function Constant_Reference (Container : aliased Set; Key : Key_Type) return Constant_Reference_Type; function Reference_Preserving_Key ( Container : aliased in out Set; Key : Key_Type) return Reference_Type; private type Reference_Type ( Element : not null access Element_Type) is null record; -- dummy 'Read and 'Write procedure Missing_Read ( Stream : access Streams.Root_Stream_Type'Class; Item : out Reference_Type) with Import, Convention => Ada, External_Name => "__drake_program_error"; procedure Missing_Write ( Stream : access Streams.Root_Stream_Type'Class; Item : Reference_Type) with Import, Convention => Ada, External_Name => "__drake_program_error"; for Reference_Type'Read use Missing_Read; for Reference_Type'Write use Missing_Write; end Generic_Keys; -- diff (Equivalents) -- -- -- -- -- private type Element_Access is access Element_Type; type Node is limited record Super : aliased Hash_Tables.Node; Element : Element_Access; end record; -- place Super at first whether Element_Type is controlled-type for Node use record Super at 0 range 0 .. Hash_Tables.Node_Size - 1; end record; type Data is limited record Super : aliased Copy_On_Write.Data; Table : Hash_Tables.Table_Access := null; Length : Count_Type := 0; end record; type Data_Access is access Data; type Set is new Finalization.Controlled with record Super : aliased Copy_On_Write.Container; -- diff end record; overriding procedure Adjust (Object : in out Set); overriding procedure Finalize (Object : in out Set) renames Clear; type Cursor is access Node; type Constant_Reference_Type ( Element : not null access constant Element_Type) is null record; type Set_Access is access constant Set; for Set_Access'Storage_Size use 0; type Set_Iterator is new Set_Iterator_Interfaces.Forward_Iterator with record First : Cursor; end record; overriding function First (Object : Set_Iterator) return Cursor; overriding function Next (Object : Set_Iterator; Position : Cursor) return Cursor; package Streaming is procedure Read ( Stream : not null access Streams.Root_Stream_Type'Class; Item : out Set); procedure Write ( Stream : not null access Streams.Root_Stream_Type'Class; Item : Set); procedure Missing_Read ( Stream : access Streams.Root_Stream_Type'Class; Item : out Cursor) with Import, Convention => Ada, External_Name => "__drake_program_error"; procedure Missing_Write ( Stream : access Streams.Root_Stream_Type'Class; Item : Cursor) with Import, Convention => Ada, External_Name => "__drake_program_error"; procedure Missing_Read ( Stream : access Streams.Root_Stream_Type'Class; Item : out Constant_Reference_Type) with Import, Convention => Ada, External_Name => "__drake_program_error"; procedure Missing_Write ( Stream : access Streams.Root_Stream_Type'Class; Item : Constant_Reference_Type) with Import, Convention => Ada, External_Name => "__drake_program_error"; end Streaming; for Set'Read use Streaming.Read; for Set'Write use Streaming.Write; for Cursor'Read use Streaming.Missing_Read; for Cursor'Write use Streaming.Missing_Write; for Constant_Reference_Type'Read use Streaming.Missing_Read; for Constant_Reference_Type'Write use Streaming.Missing_Write; No_Element : constant Cursor := null; end Ada.Containers.Indefinite_Hashed_Sets;
zhmu/ananas
Ada
86
ads
package Varsize3_Pkg2 is function Last_Index return Positive; end Varsize3_Pkg2;
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.Text_Journal_Attributes is pragma Preelaborate; type ODF_Text_Journal_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Text_Journal_Attribute_Access is access all ODF_Text_Journal_Attribute'Class with Storage_Size => 0; end ODF.DOM.Text_Journal_Attributes;
strenkml/EE368
Ada
1,262
adb
with Memory.RAM; use Memory.RAM; with Memory.SPM; use Memory.SPM; package body Test.SPM is procedure Run_Tests is ram : constant RAM_Pointer := Create_RAM(latency => 100, word_size => 8); spm : SPM_Pointer := Create_SPM(ram, 1024, 1); begin Check(Get_Time(spm.all) = 0); Check(Get_Writes(spm.all) = 0); Check(Get_Cost(spm.all) = 1); Read(spm.all, 0, 1); Check(Get_Time(spm.all) = 1); Check(Get_Writes(spm.all) = 0); Read(spm.all, 1024 - 8, 8); Check(Get_Time(spm.all) = 2); Check(Get_Writes(spm.all) = 0); Read(spm.all, 1024, 4); Check(Get_Time(spm.all) = 102); Check(Get_Writes(spm.all) = 0); Read(spm.all, 1023, 2); Check(Get_Time(spm.all) = 202); Check(Get_Writes(spm.all) = 0); Write(spm.all, 1024, 1); Check(Get_Time(spm.all) = 302); Check(Get_Writes(spm.all) = 1); Write(spm.all, 8, 1); Check(Get_Time(spm.all) = 303); Check(Get_Writes(spm.all) = 1); Write(spm.all, 8192, 16); Check(Get_Time(spm.all) = 503); Check(Get_Writes(spm.all) = 2); Destroy(Memory_Pointer(spm)); end Run_Tests; end Test.SPM;
zhmu/ananas
Ada
17,447
ads
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- G N A T . S P I T B O L -- -- -- -- S p e c -- -- -- -- Copyright (C) 1997-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. -- -- -- ------------------------------------------------------------------------------ -- SPITBOL-like interface facilities -- This package provides a set of interfaces to semantic operations copied -- from SPITBOL, including a complete implementation of SPITBOL pattern -- matching. The code is derived from the original SPITBOL MINIMAL sources, -- created by Robert Dewar. The translation is not exact, but the -- algorithmic approaches are similar. with Ada.Finalization; use Ada.Finalization; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Interfaces; use Interfaces; package GNAT.Spitbol is pragma Preelaborate; -- The Spitbol package relies heavily on the Unbounded_String package, -- using the synonym VString for variable length string. The following -- declarations define this type and other useful abbreviations. subtype VString is Ada.Strings.Unbounded.Unbounded_String; function V (Source : String) return VString renames Ada.Strings.Unbounded.To_Unbounded_String; function S (Source : VString) return String renames Ada.Strings.Unbounded.To_String; Nul : VString renames Ada.Strings.Unbounded.Null_Unbounded_String; ------------------------- -- Facilities Provided -- ------------------------- -- The SPITBOL support in GNAT consists of this package together with -- several child packages. In this package, we have first a set of -- useful string functions, copied exactly from the corresponding -- SPITBOL functions, except that we had to rename REVERSE because -- reverse is a reserved word (it is now Reverse_String). -- The second element of the parent package is a generic implementation -- of a table facility. In SPITBOL, the TABLE function allows general -- mappings from any datatype to any other datatype, and of course, as -- always, we can freely mix multiple types in the same table. -- The Ada version of tables is strongly typed, so the indexing type and -- the range type are always of a consistent type. In this implementation -- we only provide VString as an indexing type, since this is by far the -- most common case. The generic instantiation specifies the range type -- to be used. -- Three child packages provide standard instantiations of this table -- package for three common datatypes: -- GNAT.Spitbol.Table_Boolean (file g-sptabo.ads) -- The range type is Boolean. The default value is False. This -- means that this table is essentially a representation of a set. -- GNAT.Spitbol.Table_Integer (file g-sptain.ads) -- The range type is Integer. The default value is Integer'First. -- This provides a general mapping from strings to integers. -- GNAT.Spitbol.Table_VString (file g-sptavs.ads) -- The range type is VString. The default value is the null string. -- This provides a general mapping from strings to strings. -- Finally there is another child package: -- GNAT.Spitbol.Patterns (file g-spipat.ads) -- This child package provides a complete implementation of SPITBOL -- pattern matching. The spec contains a complete tutorial on the -- use of pattern matching. --------------------------------- -- Standard String Subprograms -- --------------------------------- -- This section contains some operations on unbounded strings that are -- closely related to those in the package Unbounded.Strings, but they -- correspond to the SPITBOL semantics for these operations. function Char (Num : Natural) return Character; pragma Inline (Char); -- Equivalent to Character'Val (Num) function Lpad (Str : VString; Len : Natural; Pad : Character := ' ') return VString; function Lpad (Str : String; Len : Natural; Pad : Character := ' ') return VString; -- If the length of Str is greater than or equal to Len, then Str is -- returned unchanged. Otherwise, the value returned is obtained by -- concatenating Length (Str) - Len instances of the Pad character to -- the left hand side. procedure Lpad (Str : in out VString; Len : Natural; Pad : Character := ' '); -- The procedure form is identical to the function form, except that -- the result overwrites the input argument Str. function Reverse_String (Str : VString) return VString; function Reverse_String (Str : String) return VString; -- Returns result of reversing the string Str, i.e. the result returned -- is a mirror image (end-for-end reversal) of the input string. procedure Reverse_String (Str : in out VString); -- The procedure form is identical to the function form, except that the -- result overwrites the input argument Str. function Rpad (Str : VString; Len : Natural; Pad : Character := ' ') return VString; function Rpad (Str : String; Len : Natural; Pad : Character := ' ') return VString; -- If the length of Str is greater than or equal to Len, then Str is -- returned unchanged. Otherwise, the value returned is obtained by -- concatenating Length (Str) - Len instances of the Pad character to -- the right hand side. procedure Rpad (Str : in out VString; Len : Natural; Pad : Character := ' '); -- The procedure form is identical to the function form, except that the -- result overwrites the input argument Str. function Size (Source : VString) return Natural renames Ada.Strings.Unbounded.Length; function Substr (Str : VString; Start : Positive; Len : Natural) return VString; function Substr (Str : String; Start : Positive; Len : Natural) return VString; -- Returns the substring starting at the given character position (which -- is always counted from the start of the string, regardless of bounds, -- e.g. 2 means starting with the second character of the string), and -- with the length (Len) given. Index_Error is raised if the starting -- position is out of range, and Length_Error is raised if Len is too long. function Trim (Str : VString) return VString; function Trim (Str : String) return VString; -- Returns the string obtained by removing all spaces from the right -- hand side of the string Str. procedure Trim (Str : in out VString); -- The procedure form is identical to the function form, except that the -- result overwrites the input argument Str. ----------------------- -- Utility Functions -- ----------------------- -- In SPITBOL, integer values can be freely treated as strings. The -- following definitions help provide some of this capability in -- some common cases. function "&" (Num : Integer; Str : String) return String; function "&" (Str : String; Num : Integer) return String; function "&" (Num : Integer; Str : VString) return VString; function "&" (Str : VString; Num : Integer) return VString; -- In all these concatenation operations, the integer is converted to -- its corresponding decimal string form, with no leading blank. function S (Num : Integer) return String; function V (Num : Integer) return VString; -- These operators return the given integer converted to its decimal -- string form with no leading blank. function N (Str : VString) return Integer; -- Converts string to number (same as Integer'Value (S (Str))) ------------------- -- Table Support -- ------------------- -- So far, we only provide support for tables whose indexing data values -- are strings (or unbounded strings). The values stored may be of any -- type, as supplied by the generic formal parameter. generic type Value_Type is private; -- Any non-limited type can be used as the value type in the table Null_Value : Value_Type; -- Value used to represent a value that is not present in the table with function Img (A : Value_Type) return String; -- Used to provide image of value in Dump procedure with function "=" (A, B : Value_Type) return Boolean is <>; -- This allows a user-defined equality function to override the -- predefined equality function. package Table is ------------------------ -- Table Declarations -- ------------------------ type Table (N : Unsigned_32) is private; -- This is the table type itself. A table is a mapping from string -- values to values of Value_Type. The discriminant is an estimate of -- the number of values in the table. If the estimate is much too -- high, some space is wasted, if the estimate is too low, access to -- table elements is slowed down. The type Table has copy semantics, -- not reference semantics. This means that if a table is copied -- using simple assignment, then the two copies refer to entirely -- separate tables. ----------------------------- -- Table Access Operations -- ----------------------------- function Get (T : Table; Name : VString) return Value_Type; function Get (T : Table; Name : Character) return Value_Type; pragma Inline (Get); function Get (T : Table; Name : String) return Value_Type; -- If an entry with the given name exists in the table, then the -- corresponding Value_Type value is returned. Otherwise Null_Value -- is returned. function Present (T : Table; Name : VString) return Boolean; function Present (T : Table; Name : Character) return Boolean; pragma Inline (Present); function Present (T : Table; Name : String) return Boolean; -- Determines if an entry with the given name is present in the table. -- A returned value of True means that it is in the table, otherwise -- False indicates that it is not in the table. procedure Delete (T : in out Table; Name : VString); procedure Delete (T : in out Table; Name : Character); pragma Inline (Delete); procedure Delete (T : in out Table; Name : String); -- Deletes the table element with the given name from the table. If -- no element in the table has this name, then the call has no effect. procedure Set (T : in out Table; Name : VString; Value : Value_Type); procedure Set (T : in out Table; Name : Character; Value : Value_Type); pragma Inline (Set); procedure Set (T : in out Table; Name : String; Value : Value_Type); -- Sets the value of the element with the given name to the given -- value. If Value is equal to Null_Value, the effect is to remove -- the entry from the table. If no element with the given name is -- currently in the table, then a new element with the given value -- is created. ---------------------------- -- Allocation and Copying -- ---------------------------- -- Table is a controlled type, so that all storage associated with -- tables is properly reclaimed when a Table value is abandoned. -- Tables have value semantics rather than reference semantics as -- in Spitbol, i.e. when you assign a copy you end up with two -- distinct copies of the table, as though COPY had been used in -- Spitbol. It seems clearly more appropriate in Ada to require -- the use of explicit pointers for reference semantics. procedure Clear (T : in out Table); -- Clears all the elements of the given table, freeing associated -- storage. On return T is an empty table with no elements. procedure Copy (From : Table; To : in out Table); -- First all the elements of table To are cleared (as described for -- the Clear procedure above), then all the elements of table From -- are copied into To. In the case where the tables From and To have -- the same declared size (i.e. the same discriminant), the call to -- Copy has the same effect as the assignment of From to To. The -- difference is that, unlike the assignment statement, which will -- cause a Constraint_Error if the source and target are of different -- sizes, Copy works fine with different sized tables. ---------------- -- Conversion -- ---------------- type Table_Entry is record Name : VString; Value : Value_Type; end record; type Table_Array is array (Positive range <>) of Table_Entry; function Convert_To_Array (T : Table) return Table_Array; -- Returns a Table_Array value with a low bound of 1, and a length -- corresponding to the number of elements in the table. The elements -- of the array give the elements of the table in unsorted order. --------------- -- Debugging -- --------------- procedure Dump (T : Table; Str : String := "Table"); -- Dump contents of given table to the standard output file. The -- string value Str is used as the name of the table in the dump. procedure Dump (T : Table_Array; Str : String := "Table_Array"); -- Dump contents of given table array to the current output file. The -- string value Str is used as the name of the table array in the dump. private ------------------ -- Private Part -- ------------------ -- A Table is a pointer to a hash table which contains the indicated -- number of hash elements (the number is forced to the next odd value -- if it is even to improve hashing performance). If more than one -- of the entries in a table hashes to the same slot, the Next field -- is used to chain entries from the header. The chains are not kept -- ordered. A chain is terminated by a null pointer in Next. An unused -- chain is marked by an element whose Name is null and whose value -- is Null_Value. type Hash_Element; type Hash_Element_Ptr is access all Hash_Element; type Hash_Element is record Name : String_Access := null; Value : Value_Type := Null_Value; Next : Hash_Element_Ptr := null; end record; type Hash_Table is array (Unsigned_32 range <>) of aliased Hash_Element; type Table (N : Unsigned_32) is new Controlled with record Elmts : Hash_Table (1 .. N); end record; pragma Finalize_Storage_Only (Table); overriding procedure Adjust (Object : in out Table); -- The Adjust procedure does a deep copy of the table structure -- so that the effect of assignment is, like other assignments -- in Ada, value-oriented. overriding procedure Finalize (Object : in out Table); -- This is the finalization routine that ensures that all storage -- associated with a table is properly released when a table object -- is abandoned and finalized. end Table; end GNAT.Spitbol;
jrcarter/Gnoga_Bar_Codes
Ada
2,727
adb
-- Test program for Gnoga_Bar_Codes -- -- Copyright (C) 2018 by PragmAda Software Engineering -- -- Released under the terms of the 3-Clause BSD License. See https://opensource.org/licenses/BSD-3-Clause with Bar_Codes; with Gnoga.Application.Singleton; with Gnoga.Gui.Base; with Gnoga.Gui.Element.Common; with Gnoga.Gui.Element.Form; with Gnoga.Gui.Window; with Gnoga_Bar_Codes; with Gnoga_Extra; procedure Gnoga_Bar_Codes_Test is Window : Gnoga.Gui.Window.Window_Type; View : Gnoga.Gui.Element.Form.Form_Type; Code_1D : Gnoga_Bar_Codes.Bar_Code; Code_2D : Gnoga_Bar_Codes.Bar_Code; Input : Gnoga_Extra.Text_Info; Gen : Gnoga.Gui.Element.Common.Button_Type; Quit : Gnoga.Gui.Element.Common.Button_Type; procedure Generate (Object : in out Gnoga.Gui.Base.Base_Type'Class) is -- Empty begin -- Generate Code_2D.Generate (Kind => Bar_Codes.Code_QR_Low, Text => Input.Box.Value); Code_1D.Generate (Kind => Bar_Codes.Code_128, Text => Input.Box.Value); exception -- Generate when Bar_Codes.Cannot_Encode => Code_1D.Generate (Kind => Bar_Codes.Code_128, Text => ""); end Generate; procedure Quit_Now (Object : in out Gnoga.Gui.Base.Base_Type'Class) is -- Empty; begin -- Quit_Now Gnoga.Application.Singleton.End_Application; end Quit_Now; Box_1D : constant Bar_Codes.Module_Box := Bar_Codes.Fitting (Kind => Bar_Codes.Code_128, Text => (1 .. 50 => 'a') ); Box_2D : constant Bar_Codes.Module_Box := Bar_Codes.Fitting (Kind => Bar_Codes.Code_QR_Low, Text => (1 .. 50 => 'a') ); Code_Width : constant Positive := 2 * Box_1D.Width; Code_Height : constant Positive := Code_Width / 4; begin -- Gnoga_Bar_Codes_Test Gnoga.Application.Title ("Gnoga Bar-Codes Test"); Gnoga.Application.HTML_On_Close ("Gnoga Bar-Codes Test ended."); Gnoga.Application.Open_URL; Gnoga.Application.Singleton.Initialize (Main_Window => Window); View.Create (Parent => Window); View.Text_Alignment (Value => Gnoga.Gui.Element.Center); View.New_Line; Code_1D.Create (Parent => View, Width => Code_Width, Height => Code_Height); View.New_Line; Code_2D.Create (Parent => View, Width => 8 * Box_2D.Width, Height => 8 * Box_2D.Width); View.New_Line; Input.Create (Form => View, Label => "Text :", Width => 20); Gen.Create (Parent => View, Content => "Generate"); Gen.On_Click_Handler (Handler => Generate'Unrestricted_Access); View.On_Submit_Handler (Handler => Generate'Unrestricted_Access); View.New_Line; Quit.Create (Parent => View, Content => "Quit"); Quit.On_Click_Handler (Handler => Quit_Now'Unrestricted_Access); Gnoga.Application.Singleton.Message_Loop; end Gnoga_Bar_Codes_Test;