repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
Lucretia/pc_tut
Ada
3,571
adb
package body Parsing is function Parse (Parser : in Parse_Character; Input : in String) return Result'Class is begin if Input = "" then return Failure'(Message => To_Unbounded_String ("No more input")); elsif Input (Input'First) = Parser.Match then declare Chars : Char_List.List; L : List_Of_Char_Lists.List; begin Chars.Append (Parser.Match); L.Append (Chars); return Success'(Matched => L, Remaining => To_Unbounded_String (Input (Input'First + 1 .. Input'Last))); end; else return Failure'(Message => To_Unbounded_String ("Expecting '" & Parser.Match & "', got '" & Input (Input'First) & "'")); end if; end Parse; function Parse (Parser : in Parse_Character_Range; Input : in String) return Result'Class is First : constant Character := Input (Input'First); begin if Input = "" then return Failure'(Message => To_Unbounded_String ("No more input")); elsif First in Parser.Match_From .. Parser.Match_To then declare Chars : Char_List.List; L : List_Of_Char_Lists.List; begin Chars.Append (First); L.Append (Chars); return Success'(Matched => L, Remaining => To_Unbounded_String (Input (Input'First + 1 .. Input'Last))); end; else return Failure'(Message => To_Unbounded_String ("Expecting '" & Parser.Match_To & "', got '" & First & "'")); end if; end Parse; function Parse (Parser : in Parse_And_Then; Input : in String) return Result'Class is Result_1 : Result'Class := Parser.Parser_A.Constant_Reference.Parse (Input); begin if Result_1 in Failure'Class then return Result_1; end if; declare Result_2 : Result'Class := Parser.Parser_B.Constant_Reference.Parse (To_String (Success (Result_1).Remaining)); Chars : Char_List.List; L : List_Of_Char_Lists.List; begin if Result_2 in Failure'Class then return Result_2; end if; for I of Success (Result_1).Matched loop for C of I loop Chars.Append (C); end loop; end loop; for I of Success (Result_2).Matched loop for C of I loop Chars.Append (C); end loop; end loop; L.Append (Chars); return Success'(Matched => L, Remaining => Success (Result_2).Remaining); end; end Parse; function Parse (Parser : in Parse_Or_Else; Input : in String) return Result'Class is function Build_Result (R : in Success) return Result'Class is Chars : Char_List.List; L : List_Of_Char_Lists.List; begin for I of R.Matched loop for C of I loop Chars.Append (C); end loop; end loop; L.Append (Chars); return Success'(Matched => L, Remaining => R.Remaining); end Build_Result; Result_1 : Result'Class := Parser.Parser_A.Constant_Reference.Parse (Input); begin -- Do this... if Result_1 in Success'Class then return Build_Result (Success (Result_1)); end if; -- Or this... return Parser.Parser_B.Constant_Reference.Parse (Input); end Parse; end Parsing;
reznikmm/matreshka
Ada
13,517
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. ------------------------------------------------------------------------------ -- Style contains formatting properties that affect the appearance or style -- of graphical elements. ------------------------------------------------------------------------------ limited with AMF.DC; limited with AMF.DG.Fills; with AMF.Real_Collections; package AMF.DG.Styles is pragma Preelaborate; type DG_Style is limited interface; type DG_Style_Access is access all DG_Style'Class; for DG_Style_Access'Storage_Size use 0; not overriding function Get_Fill (Self : not null access constant DG_Style) return AMF.DG.Fills.DG_Fill_Access is abstract; -- Getter of Style::fill. -- -- a reference to a fill that is used to paint the enclosed regions of a -- graphical element. A fill value is exclusive with a fillColor value. If -- both are specified, the fill value is used. If none is specified, no -- fill is applied (i.e. the element becomes see-through). not overriding procedure Set_Fill (Self : not null access DG_Style; To : AMF.DG.Fills.DG_Fill_Access) is abstract; -- Setter of Style::fill. -- -- a reference to a fill that is used to paint the enclosed regions of a -- graphical element. A fill value is exclusive with a fillColor value. If -- both are specified, the fill value is used. If none is specified, no -- fill is applied (i.e. the element becomes see-through). not overriding function Get_Fill_Color (Self : not null access constant DG_Style) return AMF.DC.Optional_DC_Color is abstract; -- Getter of Style::fillColor. -- -- a color that is used to paint the enclosed regions of graphical -- element. A fillColor value is exclusive with a fill value. If both are -- specified, the fill value is used. If none is specified, no fill is -- applied (i.e. the element becomes see-through). not overriding procedure Set_Fill_Color (Self : not null access DG_Style; To : AMF.DC.Optional_DC_Color) is abstract; -- Setter of Style::fillColor. -- -- a color that is used to paint the enclosed regions of graphical -- element. A fillColor value is exclusive with a fill value. If both are -- specified, the fill value is used. If none is specified, no fill is -- applied (i.e. the element becomes see-through). not overriding function Get_Fill_Opacity (Self : not null access constant DG_Style) return AMF.Optional_Real is abstract; -- Getter of Style::fillOpacity. -- -- a real number (>=0 and <=1) representing the opacity of the fill or -- fillColor used to paint a graphical element. A value of 0 means totally -- transparent, while a value of 1 means totally opaque. The default is 1. not overriding procedure Set_Fill_Opacity (Self : not null access DG_Style; To : AMF.Optional_Real) is abstract; -- Setter of Style::fillOpacity. -- -- a real number (>=0 and <=1) representing the opacity of the fill or -- fillColor used to paint a graphical element. A value of 0 means totally -- transparent, while a value of 1 means totally opaque. The default is 1. not overriding function Get_Stroke_Width (Self : not null access constant DG_Style) return AMF.Optional_Real is abstract; -- Getter of Style::strokeWidth. -- -- a real number (>=0) representing the width of the stroke used to paint -- the outline of a graphical element. A value of 0 specifies no stroke is -- painted. The default is 1. not overriding procedure Set_Stroke_Width (Self : not null access DG_Style; To : AMF.Optional_Real) is abstract; -- Setter of Style::strokeWidth. -- -- a real number (>=0) representing the width of the stroke used to paint -- the outline of a graphical element. A value of 0 specifies no stroke is -- painted. The default is 1. not overriding function Get_Stroke_Opacity (Self : not null access constant DG_Style) return AMF.Optional_Real is abstract; -- Getter of Style::strokeOpacity. -- -- a real number (>=0 and <=1) representing the opacity of the stroke used -- for a graphical element. A value of 0 means totally transparent, while -- a value of 1 means totally opaque. The default is 1. not overriding procedure Set_Stroke_Opacity (Self : not null access DG_Style; To : AMF.Optional_Real) is abstract; -- Setter of Style::strokeOpacity. -- -- a real number (>=0 and <=1) representing the opacity of the stroke used -- for a graphical element. A value of 0 means totally transparent, while -- a value of 1 means totally opaque. The default is 1. not overriding function Get_Stroke_Color (Self : not null access constant DG_Style) return AMF.DC.Optional_DC_Color is abstract; -- Getter of Style::strokeColor. -- -- the color of the stroke used to paint the outline of a graphical -- element. The default is black (red=0, green=0, blue=0). not overriding procedure Set_Stroke_Color (Self : not null access DG_Style; To : AMF.DC.Optional_DC_Color) is abstract; -- Setter of Style::strokeColor. -- -- the color of the stroke used to paint the outline of a graphical -- element. The default is black (red=0, green=0, blue=0). not overriding function Get_Stroke_Dash_Length (Self : not null access constant DG_Style) return AMF.Real_Collections.Sequence_Of_Real is abstract; -- Getter of Style::strokeDashLength. -- -- a list of real numbers specifying a pattern of alternating dash and gap -- lengths used in stroking the outline of a graphical element with the -- first one specifying a dash length. The size of the list is expected to -- be even. If the list is empty, the stroke is drawn solid. The default -- is empty list. not overriding function Get_Font_Size (Self : not null access constant DG_Style) return AMF.Optional_Real is abstract; -- Getter of Style::fontSize. -- -- a real number (>=0) representing the size (in unit of length) of the -- font used to render a text element. The default is 10. not overriding procedure Set_Font_Size (Self : not null access DG_Style; To : AMF.Optional_Real) is abstract; -- Setter of Style::fontSize. -- -- a real number (>=0) representing the size (in unit of length) of the -- font used to render a text element. The default is 10. not overriding function Get_Font_Name (Self : not null access constant DG_Style) return AMF.Optional_String is abstract; -- Getter of Style::fontName. -- -- the name of the font used to render a text element (e.g. "Times New -- Roman", "Arial" or "Helvetica"). The default is "Arial". not overriding procedure Set_Font_Name (Self : not null access DG_Style; To : AMF.Optional_String) is abstract; -- Setter of Style::fontName. -- -- the name of the font used to render a text element (e.g. "Times New -- Roman", "Arial" or "Helvetica"). The default is "Arial". not overriding function Get_Font_Color (Self : not null access constant DG_Style) return AMF.DC.Optional_DC_Color is abstract; -- Getter of Style::fontColor. -- -- the color of the font used to render a text element. The default is -- black (red=0, green=0, blue=0). not overriding procedure Set_Font_Color (Self : not null access DG_Style; To : AMF.DC.Optional_DC_Color) is abstract; -- Setter of Style::fontColor. -- -- the color of the font used to render a text element. The default is -- black (red=0, green=0, blue=0). not overriding function Get_Font_Italic (Self : not null access constant DG_Style) return AMF.Optional_Boolean is abstract; -- Getter of Style::fontItalic. -- -- whether the font used to render a text element has an <i>italic</i> -- style. The default is false. not overriding procedure Set_Font_Italic (Self : not null access DG_Style; To : AMF.Optional_Boolean) is abstract; -- Setter of Style::fontItalic. -- -- whether the font used to render a text element has an <i>italic</i> -- style. The default is false. not overriding function Get_Font_Bold (Self : not null access constant DG_Style) return AMF.Optional_Boolean is abstract; -- Getter of Style::fontBold. -- -- whether the font used to render a text element has a <b>bold</b> style. -- The default is false. not overriding procedure Set_Font_Bold (Self : not null access DG_Style; To : AMF.Optional_Boolean) is abstract; -- Setter of Style::fontBold. -- -- whether the font used to render a text element has a <b>bold</b> style. -- The default is false. not overriding function Get_Font_Underline (Self : not null access constant DG_Style) return AMF.Optional_Boolean is abstract; -- Getter of Style::fontUnderline. -- -- whether the font used to render a text element has an <b>underline</b> -- style. The default is false. not overriding procedure Set_Font_Underline (Self : not null access DG_Style; To : AMF.Optional_Boolean) is abstract; -- Setter of Style::fontUnderline. -- -- whether the font used to render a text element has an <b>underline</b> -- style. The default is false. not overriding function Get_Font_Strike_Through (Self : not null access constant DG_Style) return AMF.Optional_Boolean is abstract; -- Getter of Style::fontStrikeThrough. -- -- whether the font used to render a text element has a -- <b>strike-through</b> style. The default is false. not overriding procedure Set_Font_Strike_Through (Self : not null access DG_Style; To : AMF.Optional_Boolean) is abstract; -- Setter of Style::fontStrikeThrough. -- -- whether the font used to render a text element has a -- <b>strike-through</b> style. The default is false. end AMF.DG.Styles;
optikos/oasis
Ada
2,336
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Elements.Declarations; with Program.Lexical_Elements; with Program.Elements.Defining_Identifiers; with Program.Elements.Aspect_Specifications; package Program.Elements.Package_Body_Stubs is pragma Pure (Program.Elements.Package_Body_Stubs); type Package_Body_Stub is limited interface and Program.Elements.Declarations.Declaration; type Package_Body_Stub_Access is access all Package_Body_Stub'Class with Storage_Size => 0; not overriding function Name (Self : Package_Body_Stub) return not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access is abstract; not overriding function Aspects (Self : Package_Body_Stub) return Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access is abstract; type Package_Body_Stub_Text is limited interface; type Package_Body_Stub_Text_Access is access all Package_Body_Stub_Text'Class with Storage_Size => 0; not overriding function To_Package_Body_Stub_Text (Self : aliased in out Package_Body_Stub) return Package_Body_Stub_Text_Access is abstract; not overriding function Package_Token (Self : Package_Body_Stub_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Body_Token (Self : Package_Body_Stub_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Is_Token (Self : Package_Body_Stub_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Separate_Token (Self : Package_Body_Stub_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function With_Token (Self : Package_Body_Stub_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Semicolon_Token (Self : Package_Body_Stub_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; end Program.Elements.Package_Body_Stubs;
AdaCore/training_material
Ada
564
ads
--:::::::::: --phil.ads --:::::::::: with Society; package Phil is -- Dining Philosophers - Ada 95 edition -- Philosopher is an Ada 95 task type with discriminant -- Michael B. Feldman, The George Washington University, -- July, 1995. task type Philosopher (My_ID : Society.Unique_DNA_Codes) is entry Start_Eating (Chopstick1 : in Positive; Chopstick2 : in Positive); end Philosopher; type States is (Breathing, Thinking, Eating, Done_Eating, Got_One_Stick, Got_Other_Stick, Dying); end Phil;
AdaCore/libadalang
Ada
290
adb
procedure Test is package P is type T is private; subtype TT is T; private type T is record A, B : Integer; end record; end P; package body P is A : TT := (A => 12, B => 15); pragma Test_Statement; end; begin null; end Test;
AdaCore/gpr
Ada
4,626
adb
-- -- Copyright (C) 2021-2023, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 -- with Ada.Text_IO; with GPR2.Context; with GPR2.Log; with GPR2.Path_Name; with GPR2.Project.Attribute; with GPR2.Project.Attribute.Set; with GPR2.Project.Registry; with GPR2.Project.Registry.Attribute; with GPR2.Project.Tree; with GPR2.Project.Variable; with GPR2.Project.View; with GPR2.Source_Reference; with GPR2.Source_Reference.Value; procedure Main is Tree : GPR2.Project.Tree.Object; Context : GPR2.Context.Object; use GPR2; use GPR2.Project.Registry.Attribute; procedure Print_Messages is begin if Tree.Has_Messages then for C in Tree.Log_Messages.Iterate (Information => False) loop Ada.Text_IO.Put_Line (GPR2.Log.Element (C).Format); end loop; end if; end Print_Messages; procedure Print_Attributes (Name : Q_Attribute_Id) is Attributes : GPR2.Project.Attribute.Set.Object; use GPR2; Header : String := (if Name.Pack = Project_Level_Scope then Image (Name.Attr) else Image (Name.Pack) & "." & Image (Name.Attr)); begin Attributes := Tree.Root_Project.Attributes (Name => Name, With_Defaults => False, With_Config => False); for A of Attributes loop declare Attribute : GPR2.Project.Attribute.Object := A; use GPR2.Project.Registry.Attribute; begin Ada.Text_IO.Put (Header); if Attribute.Has_Index then Ada.Text_IO.Put ( "(" & Attribute.Index.Text & ")"); end if; Ada.Text_IO.Put ("="); if Attribute.Kind = GPR2.Project.Registry.Attribute.Single then Ada.Text_IO.Put (""""); Ada.Text_IO.Put (String (Attribute.Value.Text)); Ada.Text_IO.Put (""""); else declare Separator : Boolean := False; Value : GPR2.Source_Reference.Value.Object; begin Ada.Text_IO.Put ("("); for V of Attribute.Values loop Value := V; if Separator then Ada.Text_IO.Put (","); end if; Separator := True; Ada.Text_IO.Put (""""); Ada.Text_IO.Put (String (Value.Text)); Ada.Text_IO.Put (""""); end loop; Ada.Text_IO.Put (")"); end; end if; Ada.Text_IO.Put_Line (""); end; end loop; end Print_Attributes; procedure Print_Variable (Name : Name_Type) is Var : constant GPR2.Project.Variable.Object := Tree.Root_Project.Variable (Name); use type GPR2.Project.Registry.Attribute.Value_Kind; begin Ada.Text_IO.Put (String (Name) & "="); if Var.Kind = GPR2.Project.Registry.Attribute.Single then Ada.Text_IO.Put (""""); Ada.Text_IO.Put (String (Var.Value.Text)); Ada.Text_IO.Put (""""); else declare Separator : Boolean := False; Value : GPR2.Source_Reference.Value.Object; begin Ada.Text_IO.Put ("("); for V of Var.Values loop Value := V; if Separator then Ada.Text_IO.Put (","); end if; Separator := True; Ada.Text_IO.Put (""""); Ada.Text_IO.Put (String (Value.Text)); Ada.Text_IO.Put (""""); end loop; Ada.Text_IO.Put (")"); end; end if; Ada.Text_IO.Put_Line (""); end Print_Variable; procedure Test is begin Print_Attributes (Source_Dirs); Print_Variable ("A"); Print_Variable ("B"); Print_Variable ("C"); Print_Variable ("D"); Print_Variable ("E"); exception when Project_Error => Print_Messages; end Test; procedure Load (Project_Name : GPR2.Filename_Type) is begin Tree.Unload; Tree.Load_Autoconf (Filename => GPR2.Path_Name.Create_File (GPR2.Project.Ensure_Extension (Project_Name), GPR2.Path_Name.No_Resolution), Context => Context); Print_Messages; exception when Project_Error => Print_Messages; end Load; begin Load ("files/prj1.gpr"); Test; Load ("files/prj2.gpr"); end Main;
xeenta/learning-ada
Ada
2,353
adb
-- tests with generics with Ada.Text_IO; use Ada.Text_IO; procedure Generics is generic type T is (<>); N : in T; with function "*" (A, B : T) return T is <>; function Multiplier (X : T) return T; function Multiplier (X : T) return T is begin return N * X; end; function Double_It is new Multiplier (Integer, 2); -- this can't work. --function Double_It is new Multiplier (Float, 2.0); type Num is (Zero, One, Two, Three, Four, Five, Six); function "*" (A, B : Num) return Num is begin if Num'Pos (A) * Num'Pos (B) <= Num'Pos (Six) then return Num'Val (Num'Pos (A) * Num'Pos (B)); else return Six; end if; end; -- no problem with overloading in Ada! function Double_It is new Multiplier (Num, Two); function Star_Op (A, B : Integer) return Integer is begin return (if A > B then A * (B + 1) else (A + 1) * B); end Star_Op; --function Strangeness is new Multiplier (Integer, 6, Star_Op); function Strangeness is new Multiplier (T => Integer, N => 6, "*" => Star_Op); -- Ada.Text_IO.Integer_IO is a generic pkg! Here we instantiate it, -- the use it to overload Put with this type too. package Int_IO is new Integer_IO (Integer); use Int_IO; -- a modular type type Byte is mod 256; Byte_Test : Byte := 255; -- Ada.Text_IO.Modular_IO is another generic pkg. package Mod_IO is new Modular_IO (Byte); use Mod_IO; -- and another generic package is... package Enum_IO is new Enumeration_IO (Num); use Enum_IO; Num_Test : Num := Zero; begin -- Modular test Put (Byte_Test); New_Line; -- 255 Byte_Test := Byte_Test + 1; -- this is ok Put (Byte_Test); New_Line; -- 0 -- enumeration test Put (Num_Test); New_Line; -- ZERO Put (Num'Succ (Num_Test)); New_Line; -- ONE -- generics tests Put (Double_It (10)); New_Line; -- instead of Enum_IO, we can do this: Put_Line (Num'Image (Double_It (Three))); -- SIX Put_Line (Num'Image (Double_It (Two))); -- FOUR Put (Strangeness (10)); New_Line; Put (Strangeness (5)); New_Line; Put (Strangeness (7)); New_Line; end Generics;
optikos/oasis
Ada
1,709
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Elements.Definitions; with Program.Lexical_Elements; with Program.Elements.Expressions; with Program.Elements.Constraints; package Program.Elements.Subtype_Indications is pragma Pure (Program.Elements.Subtype_Indications); type Subtype_Indication is limited interface and Program.Elements.Definitions.Definition; type Subtype_Indication_Access is access all Subtype_Indication'Class with Storage_Size => 0; not overriding function Subtype_Mark (Self : Subtype_Indication) return not null Program.Elements.Expressions.Expression_Access is abstract; not overriding function Constraint (Self : Subtype_Indication) return Program.Elements.Constraints.Constraint_Access is abstract; not overriding function Has_Not_Null (Self : Subtype_Indication) return Boolean is abstract; type Subtype_Indication_Text is limited interface; type Subtype_Indication_Text_Access is access all Subtype_Indication_Text'Class with Storage_Size => 0; not overriding function To_Subtype_Indication_Text (Self : aliased in out Subtype_Indication) return Subtype_Indication_Text_Access is abstract; not overriding function Not_Token (Self : Subtype_Indication_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Null_Token (Self : Subtype_Indication_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; end Program.Elements.Subtype_Indications;
sbksba/Concurrence-LI330
Ada
1,351
adb
with Ada.Text_Io; use Ada.Text_Io; procedure Erato_Statique is type Nb_Premiers; type A_Nb_Premiers is access Nb_Premiers; type Nb_Premiers is record N : Natural; Suiv : A_Nb_Premiers; end record; procedure Affichage (L : in A_Nb_Premiers) is P : A_Nb_Premiers := L; begin while P /= null loop Put(Natural'Image(P.N) &" "); P := P.all.Suiv; end loop; end Affichage; function Ajouter_Nb_Premiers (L : in A_Nb_Premiers; N : Natural) return A_Nb_Premiers is P : A_Nb_Premiers := L; begin if P = null then return new Nb_Premiers'(N,null); end if; while (P.all.Suiv /= null) loop P := P.all.Suiv; end loop; P.all.Suiv := new Nb_Premiers'(N,null); return L; end Ajouter_Nb_Premiers; procedure Filtrer (N : in Natural; L : in out A_Nb_Premiers) is P : A_Nb_Premiers := L; begin while P /= null loop if N mod P.all.N /= 0 then P := P.all.Suiv; else return; end if; end loop; L := Ajouter_Nb_Premiers(L,N); end Filtrer; Liste_Nb_Premiers : A_Nb_Premiers; begin Liste_Nb_Premiers := new Nb_Premiers'(2,null); for I in 3..100 loop Filtrer (I,Liste_Nb_Premiers); end loop; Affichage (Liste_Nb_Premiers); end Erato_Statique;
jamiepg1/sdlada
Ada
1,555
ads
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2014 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.Error -- -- Error message handling. -------------------------------------------------------------------------------------------------------------------- package SDL.Error is procedure Clear with Import => True, Convention => C, External_Name => "SDL_ClearError"; procedure Set (S : in String); function Get return String; end SDL.Error;
reznikmm/matreshka
Ada
3,639
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.Attributes; package ODF.DOM.Attributes.FO.Font_Weight is type ODF_FO_Font_Weight is new XML.DOM.Attributes.DOM_Attribute with private; private type ODF_FO_Font_Weight is new XML.DOM.Attributes.DOM_Attribute with null record; end ODF.DOM.Attributes.FO.Font_Weight;
michael-hardeman/contacts_app
Ada
4,629
ads
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../../License.txt with AdaBase.Interfaces.Driver; with AdaBase.Statement.Base.PostgreSQL; with AdaBase.Connection.Base.PostgreSQL; with Ada.Containers.Vectors; package AdaBase.Driver.Base.PostgreSQL is package AID renames AdaBase.Interfaces.Driver; package SMT renames AdaBase.Statement.Base.PostgreSQL; package CON renames AdaBase.Connection.Base.PostgreSQL; type PostgreSQL_Driver is new Base_Driver and AID.iDriver with private; overriding function execute (driver : PostgreSQL_Driver; sql : String) return Affected_Rows; function query (driver : PostgreSQL_Driver; sql : String) return SMT.PostgreSQL_statement; function prepare (driver : PostgreSQL_Driver; sql : String) return SMT.PostgreSQL_statement; function query_select (driver : PostgreSQL_Driver; distinct : Boolean := False; tables : String; columns : String; conditions : String := blankstring; groupby : String := blankstring; having : String := blankstring; order : String := blankstring; null_sort : Null_Priority := native; limit : Trax_ID := 0; offset : Trax_ID := 0) return SMT.PostgreSQL_statement; function prepare_select (driver : PostgreSQL_Driver; distinct : Boolean := False; tables : String; columns : String; conditions : String := blankstring; groupby : String := blankstring; having : String := blankstring; order : String := blankstring; null_sort : Null_Priority := native; limit : Trax_ID := 0; offset : Trax_ID := 0) return SMT.PostgreSQL_statement; function call_stored_procedure (driver : PostgreSQL_Driver; stored_procedure : String; proc_arguments : String) return SMT.PostgreSQL_statement; function trait_query_buffers_used (driver : PostgreSQL_Driver) return Boolean; procedure set_trait_query_buffers_used (driver : PostgreSQL_Driver; trait : Boolean); private global_statement_counter : Trax_ID := 0; type PostgreSQL_Driver is new Base_Driver and AID.iDriver with record local_connection : aliased CON.PostgreSQL_Connection; async_cmd_mode : Boolean := False; end record; overriding procedure private_connect (driver : out PostgreSQL_Driver; database : String; username : String; password : String; hostname : String := blankstring; socket : String := blankstring; port : Posix_Port := portless); function sql_assemble (distinct : Boolean := False; tables : String; columns : String; conditions : String := blankstring; groupby : String := blankstring; having : String := blankstring; order : String := blankstring; null_sort : Null_Priority := native; limit : Trax_ID := 0; offset : Trax_ID := 0) return String; function private_statement (driver : PostgreSQL_Driver; sql : String; nextsets : String := ""; prepared : Boolean) return SMT.PostgreSQL_statement; overriding procedure initialize (Object : in out PostgreSQL_Driver); end AdaBase.Driver.Base.PostgreSQL;
Arles96/PCompiladores
Ada
66
adb
procedure Hello is x: Integer := 1; begin get(x); end Hello;
dan76/Amass
Ada
3,556
ads
-- Copyright © by Jeff Foley 2017-2023. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. -- SPDX-License-Identifier: Apache-2.0 local json = require("json") name = "DNSlytics" type = "api" function start() set_rate_limit(1) end function check() local c local cfg = datasrc_config() if (cfg ~= nil) then c = cfg.credentials end if (c ~= nil and c.key ~= nil and c.key ~= "") then return true end return false end function horizontal(ctx, domain) local c local cfg = datasrc_config() if (cfg ~= nil) then c = cfg.credentials end if (c == nil or c.key == nil or c.key == "") then return end -- DNSlytics ReverseIP API local resp, err = request(ctx, {['url']=first_url(domain, c.key)}) if (err ~= nil and err ~= "") then log(ctx, "first horizontal request to service failed: " .. err) return elseif (resp.status_code < 200 or resp.status_code >= 400) then log(ctx, "first horizontal request to service returned with status: " .. resp.status) return end local d = json.decode(resp.body) if (d == nil) then log(ctx, "failed to decode the JSON first response") return elseif (d.data == nil or d['data'].domains == nil or #(d['data'].domains) == 0) then return end for _, name in pairs(d['data'].domains) do if (name ~= nil and name ~= "") then associated(ctx, domain, name) end end -- DNSlytics ReverseGAnalytics API resp, err = request(ctx, {['url']=second_url(domain, c.key)}) if (err ~= nil and err ~= "") then log(ctx, "second horizontal request to service failed: " .. err) return elseif (resp.status_code < 200 or resp.status_code >= 400) then log(ctx, "second horizontal request to service returned with status: " .. resp.status) return end d = json.decode(resp.body) if (d == nil) then log(ctx, "failed to decode the JSON second response") return elseif (d.data == nil or d['data'].domains == nil or #(d['data'].domains) == 0) then return end for _, res in pairs(d['data'].domains) do if (res ~= nil and res.domain ~= nil and res.domain ~= "") then associated(ctx, domain, res.domain) end end end function first_url(domain, key) return "https://api.dnslytics.net/v1/reverseip/" .. domain .. "?apikey=" .. key end function second_url(domain, key) return "https://api.dnslytics.net/v1/reverseganalytics/" .. domain .. "?apikey=" .. key end function asn(ctx, addr, asn) if (addr == "") then return end local resp, err = request(ctx, {['url']=asn_url(addr)}) if (err ~= nil and err ~= "") then log(ctx, "asn request to service failed: " .. err) return elseif (resp.status_code < 200 or resp.status_code >= 400) then log(ctx, "asn request to service returned with status: " .. resp.status) return end local d = json.decode(resp.body) if (d == nil) then log(ctx, "failed to decode the JSON response") return elseif (d.announced == nil or not d.announced) then return end new_asn(ctx, { ['addr']=d.ip, ['asn']=d.asn, ['desc']=d.shortname .. ", " .. d.country, ['prefix']=d.cidr, }) end function asn_url(addr) return "https://freeapi.dnslytics.net/v1/ip2asn/" .. addr end
ytomino/gnat4drake
Ada
299
adb
package body GNAT.Case_Util is procedure To_Lower (A : in out String) is begin for I in A'Range loop A (I) := To_Lower (A (I)); end loop; -- Constraint_Error will be propagated if "A" has any multi-byte -- character. end To_Lower; end GNAT.Case_Util;
onox/sdlada
Ada
12,675
adb
-------------------------------------------------------------------------------------------------------------------- -- 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 -------------------------------------------------------------------------------------------------------------------- with Interfaces.C.Strings; with SDL.Error; package body SDL.TTFs is use type C.char_array; use type C.int; function Initialise return Boolean is function TTF_Init return C.int with Import => True, Convention => C, External_Name => "TTF_Init"; Result : C.int := TTF_Init; begin return (Result = Success); end Initialise; overriding procedure Finalize (Self : in out Fonts) is procedure TTF_Close_Font (Font : in Fonts_Ref) with Import => True, Convention => C, External_Name => "TTF_CloseFont"; procedure TTF_Quit with Import => True, Convention => C, External_Name => "TTF_Quit"; begin if Self.Internal /= null then if Self.Source_Freed = False then TTF_Close_Font (Self.Internal); end if; Self.Internal := null; TTF_Quit; end if; end Finalize; function Style (Self : in Fonts) return Font_Styles is function TTF_Get_Font_Style (Font : in Fonts_Ref) return Font_Styles with Import => True, Convention => C, External_Name => "TTF_GetFontStyle"; begin return TTF_Get_Font_Style (Self.Internal); end Style; procedure Set_Style (Self : in out Fonts; Now : in Font_Styles) is procedure TTF_Set_Font_Style (Font : in Fonts_Ref; Now : in Font_Styles) with Import => True, Convention => C, External_Name => "TTF_SetFontStyle"; begin TTF_Set_Font_Style (Self.Internal, Now); end Set_Style; function Outline (Self : in Fonts) return Font_Outlines is function TTF_Get_Font_Outline (Font : in Fonts_Ref) return Font_Outlines with Import => True, Convention => C, External_Name => "TTF_GetFontOutline"; begin return TTF_Get_Font_Outline (Self.Internal); end Outline; procedure Set_Outline (Self : in out Fonts; Now : in Font_Outlines := Outlines_Off) is procedure TTF_Set_Font_Outline (Font : in Fonts_Ref; Now : in Font_Outlines) with Import => True, Convention => C, External_Name => "TTF_SetFontOutline"; begin TTF_Set_Font_Outline (Self.Internal, Now); end Set_Outline; function Hinting (Self : in Fonts) return Font_Hints is function TTF_Get_Font_Hinting (Font : in Fonts_Ref) return Font_Hints with Import => True, Convention => C, External_Name => "TTF_GetFontHinting"; begin return TTF_Get_Font_Hinting (Self.Internal); end Hinting; procedure Set_Hinting (Self : in out Fonts; Now : in Font_Hints := Normal) is procedure TTF_Set_Font_Hinting (Font : in Fonts_Ref; Now : in Font_Hints) with Import => True, Convention => C, External_Name => "TTF_SetFontHinting"; begin TTF_Set_Font_Hinting (Self.Internal, Now); end Set_Hinting; function Kerning (Self : in Fonts) return Boolean is function TTF_Get_Font_Kerning (Font : in Fonts_Ref) return C.int with Import => True, Convention => C, External_Name => "TTF_GetFontKerning"; Enabled : C.int := TTF_Get_Font_Kerning (Self.Internal); begin return (if Enabled = 0 then False else True); end Kerning; procedure Set_Kerning (Self : in out Fonts; Now : in Boolean) is procedure TTF_Set_Font_Kerning (Font : in Fonts_Ref; Now : in C.int) with Import => True, Convention => C, External_Name => "TTF_SetFontKerning"; begin TTF_Set_Font_Kerning (Font => Self.Internal, Now => (if Now = True then 1 else 0)); end Set_Kerning; function Height (Self : in Fonts) return Font_Measurements is function TTF_Font_Height (Font : in Fonts_Ref) return Font_Measurements with Import => True, Convention => C, External_Name => "TTF_FontHeight"; begin return TTF_Font_Height (Self.Internal); end Height; function Ascent (Self : in Fonts) return Font_Measurements is function TTF_Font_Ascent (Font : in Fonts_Ref) return Font_Measurements with Import => True, Convention => C, External_Name => "TTF_FontAscent"; begin return TTF_Font_Ascent (Self.Internal); end Ascent; function Descent (Self : in Fonts) return Font_Measurements is function TTF_Font_Descent (Font : in Fonts_Ref) return Font_Measurements with Import => True, Convention => C, External_Name => "TTF_FontDescent"; begin return TTF_Font_Descent (Self.Internal); end Descent; function Line_Skip (Self : in Fonts) return Font_Measurements is function TTF_Font_Line_Skip (Font : in Fonts_Ref) return Font_Measurements with Import => True, Convention => C, External_Name => "TTF_FontLineSkip"; begin return TTF_Font_Line_Skip (Self.Internal); end Line_Skip; function Faces (Self : in Fonts) return Font_Faces is function TTF_Font_Faces (Font : in Fonts_Ref) return Font_Faces with Import => True, Convention => C, External_Name => "TTF_FontFaces"; begin return TTF_Font_Faces (Self.Internal); end Faces; function Is_Face_Fixed_Width (Self : in Fonts) return Boolean is function TTF_Font_Face_Is_Fixed_Width (Font : in Fonts_Ref) return C.int with Import => True, Convention => C, External_Name => "TTF_FontFaceIsFixedWidth"; Result : C.int := TTF_Font_Face_Is_Fixed_Width (Self.Internal); begin return (if Result > 0 then True else False); end Is_Face_Fixed_Width; function Face_Family_Name (Self : in Fonts) return String is function TTF_Font_Face_Family_Name (Font : in Fonts_Ref) return C.Strings.chars_ptr with Import => True, Convention => C, External_Name => "TTF_FontFaceFamilyName"; begin return C.Strings.Value (TTF_Font_Face_Family_Name (Self.Internal)); end Face_Family_Name; function Face_Style_Name (Self : in Fonts) return String is function TTF_Font_Face_Style_Name (Font : in Fonts_Ref) return C.Strings.chars_ptr with Import => True, Convention => C, External_Name => "TTF_FontFaceStyleName"; begin return C.Strings.Value (TTF_Font_Face_Style_Name (Self.Internal)); end Face_Style_Name; function Size_Latin_1 (Self : in Fonts; Text : in String) return SDL.Sizes is function TTF_Size_Text (Font : in Fonts_Ref; Text : in C.Strings.chars_ptr; W : out Dimension; H : out Dimension) return C.int with Import => True, Convention => C, External_Name => "TTF_SizeText"; Size : SDL.Sizes := SDL.Zero_Size; C_Text : C.Strings.chars_ptr := C.Strings.New_String (Text); Result : C.int := TTF_Size_Text (Self.Internal, C_Text, Size.Width, Size.Height); begin C.Strings.Free (C_Text); return Size; end Size_Latin_1; function Size_UTF_8 (Self : in Fonts; Text : in UTF_Strings.UTF_8_String) return SDL.Sizes is function TTF_Size_UTF_8 (Font : in Fonts_Ref; Text : in C.Strings.chars_ptr; W : out Dimension; H : out Dimension) return C.int with Import => True, Convention => C, External_Name => "TTF_SizeUTF8"; Size : SDL.Sizes := SDL.Zero_Size; C_Text : C.Strings.chars_ptr := C.Strings.New_String (Text); Result : C.int := TTF_Size_UTF_8 (Self.Internal, C_Text, Size.Width, Size.Height); begin return Size; end Size_UTF_8; function Make_Surface_From_Pointer (S : in Video.Surfaces.Internal_Surface_Pointer; Owns : in Boolean := False) return Video.Surfaces.Surface with Import => True, Convention => Ada; function Render_Solid (Self : in Fonts; Text : in String; Colour : in SDL.Video.Palettes.Colour) return SDL.Video.Surfaces.Surface is function TTF_Render_Text_Solid (Font : in Fonts_Ref; Text : in C.Strings.chars_ptr; Colour : in SDL.Video.Palettes.Colour) return Video.Surfaces.Internal_Surface_Pointer with Import => True, Convention => C, External_Name => "TTF_RenderText_Solid"; C_Text : C.Strings.chars_ptr := C.Strings.New_String (Text); begin return S : SDL.Video.Surfaces.Surface := Make_Surface_From_Pointer (S => TTF_Render_Text_Solid (Self.Internal, C_Text, Colour), Owns => True) do C.Strings.Free (C_Text); end return; end Render_Solid; function Render_Shaded (Self : in Fonts; Text : in String; Colour : in SDL.Video.Palettes.Colour; Background_Colour : in SDL.Video.Palettes.Colour) return SDL.Video.Surfaces.Surface is function TTF_Render_Text_Shaded (Font : in Fonts_Ref; Text : in C.Strings.chars_ptr; Colour : in SDL.Video.Palettes.Colour; Background_Colour : in SDL.Video.Palettes.Colour) return Video.Surfaces.Internal_Surface_Pointer with Import => True, Convention => C, External_Name => "TTF_RenderText_Shaded"; C_Text : C.Strings.chars_ptr := C.Strings.New_String (Text); begin return S : SDL.Video.Surfaces.Surface := Make_Surface_From_Pointer (S => TTF_Render_Text_Shaded (Self.Internal, C_Text, Colour, Background_Colour), Owns => True) do C.Strings.Free (C_Text); end return; end Render_Shaded; function Render_Blended (Self : in Fonts; Text : in String; Colour : in SDL.Video.Palettes.Colour) return SDL.Video.Surfaces.Surface is function TTF_Render_Text_Blended (Font : in Fonts_Ref; Text : in C.Strings.chars_ptr; Colour : in SDL.Video.Palettes.Colour) return Video.Surfaces.Internal_Surface_Pointer with Import => True, Convention => C, External_Name => "TTF_RenderText_Blended"; C_Text : C.Strings.chars_ptr := C.Strings.New_String (Text); begin return S : SDL.Video.Surfaces.Surface := Make_Surface_From_Pointer (S => TTF_Render_Text_Blended (Self.Internal, C_Text, Colour), Owns => True) do C.Strings.Free (C_Text); end return; end Render_Blended; end SDL.TTFs;
reznikmm/matreshka
Ada
4,105
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.Draw_Frame_Display_Scrollbar_Attributes; package Matreshka.ODF_Draw.Frame_Display_Scrollbar_Attributes is type Draw_Frame_Display_Scrollbar_Attribute_Node is new Matreshka.ODF_Draw.Abstract_Draw_Attribute_Node and ODF.DOM.Draw_Frame_Display_Scrollbar_Attributes.ODF_Draw_Frame_Display_Scrollbar_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Draw_Frame_Display_Scrollbar_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Draw_Frame_Display_Scrollbar_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Draw.Frame_Display_Scrollbar_Attributes;
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.Db_Precision_Attributes is pragma Preelaborate; type ODF_Db_Precision_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Db_Precision_Attribute_Access is access all ODF_Db_Precision_Attribute'Class with Storage_Size => 0; end ODF.DOM.Db_Precision_Attributes;
reznikmm/matreshka
Ada
5,596
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2016-2020, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with WebAPI.DOM.Elements; with WebAPI.DOM.Rects; package body WUI.Events.Mouse is ------------------ -- Constructors -- ------------------ package body Constructors is ---------------- -- Initialize -- ---------------- procedure Initialize (Self : in out Abstract_Mouse_Event'Class; Event : not null access WebAPI.UI_Events.Mouse.Mouse_Event'Class) is begin WUI.Events.Constructors.Initialize (Self, Event); end Initialize; end Constructors; -- ------------- -- -- Buttons -- -- ------------- -- -- function Buttons -- (Self : Abstract_Mouse_Event'Class) return Mouse_Buttons -- is -- use type WebAPI.DOM_Unsigned_Short; -- -- Buttons : constant WebAPI.DOM_Unsigned_Short -- := WebAPI.UI_Events.Mouse.Mouse_Event'Class -- (Self.Event.all).Get_Buttons; -- Result : Mouse_Buttons := (others => False); -- -- begin -- if (Buttons and 2#0001#) /= 0 then -- Result (Button_1) := True; -- end if; -- -- if (Buttons and 2#0010#) /= 0 then -- Result (Button_2) := True; -- end if; -- -- if (Buttons and 2#0100#) /= 0 then -- Result (Button_3) := True; -- end if; -- -- return Result; -- end Buttons; ------- -- X -- ------- function X (Self : Abstract_Mouse_Event'Class) return Long_Float is E : WebAPI.UI_Events.Mouse.Mouse_Event'Class renames WebAPI.UI_Events.Mouse.Mouse_Event'Class (Self.Event.all); R : constant WebAPI.DOM.Rects.DOM_Rect_Access := WebAPI.DOM.Elements.Element'Class (E.Get_Target.all).Get_Bounding_Client_Rect; begin return Long_Float (E.Get_Client_X) - Long_Float (R.Get_Left); end X; ------- -- Y -- ------- function Y (Self : Abstract_Mouse_Event'Class) return Long_Float is E : WebAPI.UI_Events.Mouse.Mouse_Event'Class renames WebAPI.UI_Events.Mouse.Mouse_Event'Class (Self.Event.all); R : constant WebAPI.DOM.Rects.DOM_Rect_Access := WebAPI.DOM.Elements.Element'Class (E.Get_Target.all).Get_Bounding_Client_Rect; begin return Long_Float (E.Get_Client_Y) - Long_Float (R.Get_Top); end Y; end WUI.Events.Mouse;
reznikmm/matreshka
Ada
3,978
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. ------------------------------------------------------------------------------ -- See Annex A. ------------------------------------------------------------------------------ with AMF.UMLDI.UML_Structure_Diagrams; package AMF.UMLDI.UML_Object_Diagrams is pragma Preelaborate; type UMLDI_UML_Object_Diagram is limited interface and AMF.UMLDI.UML_Structure_Diagrams.UMLDI_UML_Structure_Diagram; type UMLDI_UML_Object_Diagram_Access is access all UMLDI_UML_Object_Diagram'Class; for UMLDI_UML_Object_Diagram_Access'Storage_Size use 0; end AMF.UMLDI.UML_Object_Diagrams;
skordal/ada-regex
Ada
5,589
adb
-- Ada regular expression library -- (c) Kristian Klomsten Skordal 2020 <[email protected]> -- Report bugs and issues on <https://github.com/skordal/ada-regex> with Ada.Containers.Generic_Array_Sort; package body Regex.Utilities.Sorted_Sets is function To_Set (Item : in Element_Type) return Sorted_Set is Retval : Sorted_Set := Empty_Set; begin Retval.Add (Item); return Retval; end To_Set; function Create_Set (Capacity : in Natural) return Sorted_Set is begin return Retval : Sorted_Set do Retval.Capacity := Capacity; Retval.Item_Count := 0; Retval.Items := new Item_Array (1 .. Capacity); end return; end Create_Set; function Length (This : in Sorted_Set) return Natural is begin return This.Item_Count; end Length; procedure Add (This : in out Sorted_Set; Item : in Element_Type) is procedure Sort_Array is new Ada.Containers.Generic_Array_Sort ( Index_Type => Positive, Element_Type => Element_Type, Array_Type => Item_Array); begin -- Check if the element exists in the set: if This.Element_Exists (Item) then return; end if; if This.Item_Count = 0 or else This.Item_Count >= This.Capacity then This.Enlarge_Item_Array; end if; This.Item_Count := This.Item_Count + 1; This.Items (This.Item_Count) := Item; Sort_Array (This.Items (1 .. This.Item_Count)); end Add; procedure Add (This : in out Sorted_Set; Items : in Sorted_Set) is begin for Item of Items loop This.Add (Item); end loop; end Add; function Element_Exists (This : in Sorted_Set; Item : in Element_Type) return Boolean is begin for I of This loop if I = Item then return True; end if; end loop; return False; end Element_Exists; function "&" (Left : in Sorted_Set; Right : in Element_Type) return Sorted_Set is Retval : Sorted_Set := Left; begin Retval.Add (Right); return Retval; end "&"; function "&" (Left, Right : in Sorted_Set) return Sorted_Set is Result_Set : Sorted_Set := Create_Set (Natural'Max (Left.Capacity, Right.Capacity)); begin for I of Left loop Result_Set.Add (I); end loop; for I of Right loop Result_Set.Add (I); end loop; return Result_Set; end "&"; function "=" (Left, Right : in Sorted_Set) return Boolean is begin if Left.Length /= Right.Length then return False; end if; for I in 1 .. Left.Item_Count loop if Left.Items (I) /= Right.Items (I) then return False; end if; end loop; return True; end "="; function Has_Element (Position : in Cursor) return Boolean is begin return Position.Index > 0 and Position.Index <= Position.End_Index; end Has_Element; function Iterate (This : in Sorted_Set) return Set_Iterators.Forward_Iterator'Class is begin return Retval : Set_Iterator do Retval.Items := This.Items; Retval.Item_Count := This.Item_Count; end return; end Iterate; function Element_Value (This : in Sorted_Set; Position : in Cursor) return Element_Type is begin return This.Items (Position.Index); end Element_Value; function Constant_Reference (This : in Sorted_Set; Position : in Cursor) return Constant_Reference_Type is Retval : Constant_Reference_Type (Item => This.Items (Position.Index)'Access); begin return Retval; end Constant_Reference; procedure Adjust (This : in out Sorted_Set) is New_Array : Item_Array_Access; begin if This.Items /= null then New_Array := new Item_Array (This.Items'Range); for I in This.Items'Range loop New_Array (I) := This.Items (I); end loop; This.Items := New_Array; end if; end Adjust; procedure Finalize (This : in out Sorted_Set) is begin if This.Items /= null then Free_Item_Array (This.Items); end if; end Finalize; procedure Enlarge_Item_Array (This : in out Sorted_Set) is New_Capacity : Natural; New_Array : Item_Array_Access; begin if This.Capacity = 0 then This.Items := new Item_Array (1 .. Default_Capacity); This.Capacity := Default_Capacity; else -- Enlarge the item array by ~10 %, minimum Default_Capacity elements: New_Capacity := Natural (Float (This.Capacity) * 1.1); if New_Capacity < This.Capacity + Default_Capacity then New_Capacity := This.Capacity + Default_Capacity; end if; New_Array := new Item_Array (1 .. New_Capacity); for I in This.Items'Range loop New_Array (I) := This.Items (I); end loop; Free_Item_Array (This.Items); This.Capacity := New_Capacity; This.Items := New_Array; end if; end Enlarge_Item_Array; function First (This : in Set_Iterator) return Cursor is begin return Retval : Cursor do Retval.Items := This.Items; Retval.Index := 1; Retval.End_Index := This.Item_Count; end return; end First; function Next (This : in Set_Iterator; Position : in Cursor) return Cursor is Retval : Cursor := Position; begin Retval.Items := This.Items; Retval.Index := Retval.Index + 1; Retval.End_Index := This.Item_Count; return Retval; end Next; end Regex.Utilities.Sorted_Sets;
AdaCore/Ada_Drivers_Library
Ada
5,563
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2017-2018, 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 FE310_SVD.GPIO; use FE310_SVD.GPIO; with HAL.GPIO; use HAL.GPIO; package body FE310.GPIO is --------------------- -- Set_IO_Function -- --------------------- procedure Set_IO_Function (This : in out GPIO_Point; Func : IO_Function) is begin case Func is when Disabled => GPIO0_Periph.IO_FUNC_EN.Arr (This.Pin) := False; when IOF0 | IOF1 => GPIO0_Periph.IO_FUNC_SEL.Arr (This.Pin) := Func = IOF1; GPIO0_Periph.IO_FUNC_EN.Arr (This.Pin) := True; end case; end Set_IO_Function; ------------ -- Invert -- ------------ procedure Invert (This : in out GPIO_Point; Enabled : Boolean := True) is begin GPIO0_Periph.OUT_XOR.Arr (This.Pin) := Enabled; end Invert; -- Invert the output level function Inverted (This : GPIO_Point) return Boolean is (GPIO0_Periph.OUT_XOR.Arr (This.Pin)); ---------- -- Mode -- ---------- overriding function Mode (This : GPIO_Point) return HAL.GPIO.GPIO_Mode is begin if GPIO0_Periph.IO_FUNC_EN.Arr (This.Pin) then return Unknown_Mode; elsif GPIO0_Periph.OUTPUT_EN.Arr (This.Pin) then return Output; else return Input; end if; end Mode; -------------- -- Set_Mode -- -------------- overriding procedure Set_Mode (This : in out GPIO_Point; Mode : HAL.GPIO.GPIO_Config_Mode) is begin -- Input mode is always on to make sure we can read IO state even in -- output mode. GPIO0_Periph.INPUT_EN.Arr (This.Pin) := True; GPIO0_Periph.OUTPUT_EN.Arr (This.Pin) := Mode = Output; end Set_Mode; ------------------- -- Pull_Resistor -- ------------------- overriding function Pull_Resistor (This : GPIO_Point) return HAL.GPIO.GPIO_Pull_Resistor is begin if GPIO0_Periph.PULLUP.Arr (This.Pin) then return Pull_Up; else return Floating; end if; end Pull_Resistor; ----------------------- -- Set_Pull_Resistor -- ----------------------- overriding procedure Set_Pull_Resistor (This : in out GPIO_Point; Pull : HAL.GPIO.GPIO_Pull_Resistor) is begin GPIO0_Periph.PULLUP.Arr (This.Pin) := Pull = Pull_Up; end Set_Pull_Resistor; --------- -- Set -- --------- overriding function Set (This : GPIO_Point) return Boolean is begin return GPIO0_Periph.VALUE.Arr (This.Pin); end Set; --------- -- Set -- --------- overriding procedure Set (This : in out GPIO_Point) is begin GPIO0_Periph.PORT.Arr (This.Pin) := True; end Set; ----------- -- Clear -- ----------- overriding procedure Clear (This : in out GPIO_Point) is begin GPIO0_Periph.PORT.Arr (This.Pin) := False; end Clear; ------------ -- Toggle -- ------------ overriding procedure Toggle (This : in out GPIO_Point) is begin GPIO0_Periph.PORT.Arr (This.Pin) := not GPIO0_Periph.VALUE.Arr (This.Pin); end Toggle; end FE310.GPIO;
tum-ei-rcs/StratoX
Ada
4,833
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . B B . I N T E R R U P T S -- -- -- -- S p e c -- -- -- -- Copyright (C) 1999-2002 Universidad Politecnica de Madrid -- -- Copyright (C) 2003-2004 The European Space Agency -- -- Copyright (C) 2003-2013, AdaCore -- -- -- -- 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. GNARL 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. -- -- -- -- -- -- -- -- -- -- -- -- 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. -- -- -- -- The port of GNARL to bare board targets was initially developed by the -- -- Real-Time Systems Group at the Technical University of Madrid. -- -- -- ------------------------------------------------------------------------------ -- Package in charge of implementing the basic routines for interrupt -- management. pragma Restrictions (No_Elaboration_Code); with System; with System.BB.Parameters; with System.Multiprocessors; package System.BB.Interrupts is pragma Preelaborate; Max_Interrupt : constant := System.BB.Parameters.Number_Of_Interrupt_ID; -- Number of interrupts subtype Interrupt_ID is Natural range 0 .. Max_Interrupt; -- Interrupt identifier No_Interrupt : constant Interrupt_ID := 0; -- Special value indicating no interrupt type Interrupt_Handler is access procedure (Id : Interrupt_ID); -- Prototype of procedures used as low level handlers procedure Initialize_Interrupts; -- Initialize table containing the pointers to the different interrupt -- stacks. Should be called before any other subprograms in this package. procedure Attach_Handler (Handler : not null Interrupt_Handler; Id : Interrupt_ID; Prio : Interrupt_Priority) with Pre => Id /= No_Interrupt; pragma Inline (Attach_Handler); -- Attach the procedure Handler as handler of the interrupt Id. Prio is -- the priority of the associated protected object. This priority could be -- used to program the hardware priority of the interrupt. function Current_Interrupt return Interrupt_ID; -- Function that returns the hardware interrupt currently being handled on -- the current CPU (if any). If no hardware interrupt is being handled the -- returned value is No_Interrupt. function Within_Interrupt_Stack (Stack_Address : System.Address) return Boolean; pragma Inline (Within_Interrupt_Stack); -- Function that tells whether the Address passed as argument belongs to -- the interrupt stack that is currently being used on current CPU (if -- any). It returns True if Stack_Address is within the range of the -- interrupt stack being used. False in case Stack_Address is not within -- the interrupt stack (or no interrupt is being handled). end System.BB.Interrupts;
AdaCore/libadalang
Ada
62
ads
with A; with B; package C is X : A.T; Y : B.U; end C;
databuzzword/ai-api-marketplace
Ada
2,701
ads
-- FastAPI -- No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) -- -- The version of the OpenAPI document: 0.1.0 -- -- -- NOTE: This package is auto generated by OpenAPI-Generator 4.0.0. -- https://openapi-generator.tech -- Do not edit the class manually. with Swagger.Streams; with Ada.Containers.Vectors; package .Models is -- ------------------------------ -- ValidationError -- ------------------------------ type ValidationErrorType is record Loc : Swagger.UString_Vectors.Vector; Msg : Swagger.UString; P_Type : Swagger.UString; end record; package ValidationErrorType_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => ValidationErrorType); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in ValidationErrorType); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in ValidationErrorType_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out ValidationErrorType); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out ValidationErrorType_Vectors.Vector); -- ------------------------------ -- HTTPValidationError -- ------------------------------ type HTTPValidationErrorType is record Detail : .Models.ValidationErrorType_Vectors.Vector; end record; package HTTPValidationErrorType_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => HTTPValidationErrorType); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in HTTPValidationErrorType); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in HTTPValidationErrorType_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out HTTPValidationErrorType); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out HTTPValidationErrorType_Vectors.Vector); end .Models;
annexi-strayline/AURA
Ada
49,096
adb
------------------------------------------------------------------------------ -- -- -- Ada User Repository Annex (AURA) -- -- ANNEXI-STRAYLINE Reference Implementation -- -- -- -- Command Line Interface -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Copyright (C) 2020-2023, 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.Exceptions; with Ada.Strings.Fixed; with Ada.Strings.Wide_Wide_Maps; with Ada.Strings.Unbounded; with Ada.Strings.Wide_Wide_Unbounded; with Ada.Strings.UTF_Encoding.Wide_Wide_Strings; with Ada.Characters.Handling; with Ada.Containers.Hashed_Maps; with Ada.Directories; with Ada.Command_Line; with CLI; use CLI; with UI_Primitives; with Build, Build.Compilation, Build.Linking; with Checkout; with Progress; with Workers.Reporting; with Unit_Names, Unit_Names.Sets; with Configuration; with Repositories; with Repositories.Cache; with Registrar.Queries; with Registrar.Subsystems; with Registrar.Library_Units; with Registrar.Registration; with Registrar.Implementation_Hashing; with Registrar.Dependency_Processing; with Registrar.Last_Run_Store; with Depreciation_Handlers; package body Scheduling is package UI renames UI_Primitives; package UBS renames Ada.Strings.Unbounded; use type Ada.Containers.Count_Type; subtype Count_Type is Ada.Containers.Count_Type; -- Utilities function Trim (Source: in String; Side : in Ada.Strings.Trim_End := Ada.Strings.Both) return String renames Ada.Strings.Fixed.Trim; -- -- Parameters -- type Output_Style_Type is (Normal, Verbose, Quiet); type Systemize_Mode_Type is (Show, Add); type Parameter_Set is record Last_Argument: Natural := 0; -- The last argument read Output_Style : Output_Style_Type := Normal; Systemize_Mode: Systemize_Mode_Type := Show; -- Set by -v and -q options Main_Unit : Unit_Names.Unit_Name; -- Valid only for build/run commands. This is set via the -- the command line (if provided) and is assumed to be a UTF-8 string. Target_Units: Registrar.Library_Units.Library_Unit_Sets.Set; -- In the Bind phase, Target_Units will be initialized to either -- all Ada units, or to a singular Ada unit selecred via the value -- of Main_Unit if not empty. The selected unit(s) are then passed to -- the binder. The resulting binder unit ("ada_main" for GNAT), is -- added to Target_Units. -- -- In the Link_or_Archive phase, if Target_Units is a single unit, -- it is expanded to recursively include all dependencies. Otherwise, -- all external units are included. The expanted set is then used to -- link the final image, or to determine which objects are archived. Executable : UBS.Unbounded_String; -- Valid only for run commands, This string is either -- set from the command line, or is computed based on the -- contents of Main_Unit. -- -- This value is set by the Link_Or_Archive phase -- -- This string will be the full path to the executable. Build_Config : Build.Build_Configuration; -- The build configuration passed into the Build package operations, -- also loaded and saved from the backing store end record; Parameters: Parameter_Set; --------------------------- -- Initialize_Parameters -- --------------------------- procedure Initialize_Parameters is separate; -- -- Processes -- ----------- -- Clean -- ----------- procedure Clean is use Ada.Directories; Config_Dir: constant String := Current_Directory & "/.aura"; begin if Exists (Config_Dir) then Delete_Tree (Config_Dir); end if; if Exists (Build.Build_Root) then Delete_Tree (Build.Build_Root); end if; end Clean; ------------------- -- Enter_Project -- ------------------- procedure Check_AURA_Dir; procedure Enter_Root; procedure Enter_All_AURA; procedure Enter_Project is OK_To_Proceed: Boolean := False; begin Enter_Root; Depreciation_Handlers.AURA_Subdirectory (OK_To_Proceed); if OK_To_Proceed then Check_AURA_Dir; Enter_All_AURA; else raise Constraint_Error with "AURA subsystem units in the project root is depreciated."; end if; end Enter_Project; ---------------------------------------------------------------------- function Create_AURA_Dir_User_Approval return Boolean is use UI_Primitives; Approved: Boolean; begin Put_Warn_Tag; Put_Line (" The current directory does not appear to be an active " & "AURA project."); Put_Empty_Tag; Put_Line (" AURA CLI needs to create the 'aura' subdirectory to " & "initialize the project."); Immediate_YN_Query (Prompt => "Create 'aura' subdirectory?", Default => True, Response => Approved); return Approved; end Create_AURA_Dir_User_Approval; ---------------------------------------------------------------------- procedure Check_AURA_Dir is use Ada.Directories; AURA_Subsystem_Directory: constant String := Compose (Containing_Directory => Current_Directory, Name => "aura"); begin -- Ensure that the 'aura' subdirectory exists and is a directory, or else -- create it if Exists (AURA_Subsystem_Directory) then if Kind (AURA_Subsystem_Directory) /= Directory then UI.Put_Fail_Tag; Put_Line ("A file named 'aura' in the project " & "root must be a directory."); UI.Put_Empty_Tag; Put_Line ("(Re)move this file and try again."); raise Process_Failed; end if; elsif Create_AURA_Dir_User_Approval then Create_Directory (AURA_Subsystem_Directory); else UI.Put_Fail_Tag; Put_Line (" Project initialization aborted by user"); raise Process_Failed; end if; end Check_AURA_Dir; ---------------------------------------------------------------------- procedure Enter_Root is Process_Title: constant String := "Entering root items"; Reg_Tracker: Progress.Progress_Tracker renames Registrar.Registration.Entry_Progress; Entered_Sys : Count_Type; Entered_Units: Count_Type; begin UI.Prep_Tracker (Process_Title); Registrar.Registration.Enter_Root; UI.Wait_Tracker_Or_Abort (Process_Title => Process_Title, Tracker => Reg_Tracker); Entered_Sys := Registrar.Queries.Available_Subsystems.Length; Entered_Units := Registrar.Queries.Entered_Library_Units.Length; Clear_Line; UI.Put_OK_Tag; Put_Line (Message => " Entered" & Count_Type'Image (Entered_Sys) & (if Entered_Sys = 1 then " root subsystem " else " root subsystems ") & '(' & Trim (Count_Type'Image (Entered_Units)) & (if Entered_Units = 1 then " unit)." else " units).")); end Enter_Root; ---------------------------------------------------------------------- procedure Enter_All_AURA is Process_Title: constant String := "Entering AURA subsystem units"; Reg_Tracker: Progress.Progress_Tracker renames Registrar.Registration.Entry_Progress; Entered_Units: Count_Type; begin UI.Prep_Tracker (Process_Title); Registrar.Registration.Enter_All_AURA; UI.Wait_Tracker_Or_Abort (Process_Title => Process_Title, Tracker => Reg_Tracker); Entered_Units := Registrar.Queries.Entered_Library_Units.Length; Clear_Line; UI.Put_OK_Tag; Put_Line (Message => " Entered" & Count_Type'Image (Entered_Units) & " AURA subsystem unit" & (if Entered_Units = 1 then "." else "s.")); end Enter_All_AURA; ----------------------------- -- Initialize_Repositories -- ----------------------------- procedure Initialize_Repositories is use Repositories; Process_Title: constant String := "Initializing repositories"; Reg_Title : constant String := "Waiting registration"; Process_Tracker: Progress.Progress_Tracker renames Repositories.Initialize_Repositories_Tracker; Reg_Tracker: Progress.Progress_Tracker renames Registrar.Registration.Entry_Progress; Total_Repos: Repository_Count; begin Reg_Tracker.Reset; UI.Prep_Tracker (Process_Title => Process_Title, Spinner_Only => False); Repositories.Initialize_Repositories; UI.Wait_Tracker_Or_Abort (Process_Title => Process_Title, Tracker => Process_Tracker); UI.Wait_Tracker_Or_Abort (Process_Title => Reg_Title, Tracker => Reg_Tracker, Spinner_Only => True); Total_Repos := Total_Repositories; Clear_Line; UI.Put_OK_Tag; Put_Line (" Loaded" & Repository_Count'Image (Total_Repos) & (if Total_Repos = 1 then " repository." else " repositories.")); end Initialize_Repositories; ---------------------------- -- Add_Explicit_Checkouts -- ---------------------------- procedure Add_Explicit_Checkouts is use Ada.Command_Line; package WWU renames Ada.Strings.Wide_Wide_Unbounded; package UTF renames Ada.Strings.UTF_Encoding.Wide_Wide_Strings; package WWM renames Ada.Strings.Wide_Wide_Maps; function UTF_8 return Ada.Strings.UTF_Encoding.Encoding_Scheme renames Ada.Strings.UTF_Encoding.UTF_8; function To_UTF8 (Wide: WWU.Unbounded_Wide_Wide_String) return String is begin return UTF.Encode (Item => WWU.To_Wide_Wide_String (Wide), Output_Scheme => UTF_8, Output_BOM => False); end To_UTF8; Delimiters: constant WWM.Wide_Wide_Character_Set := WWM.To_Set (".%"); Arg: WWU.Unbounded_Wide_Wide_String; begin if Parameters.Last_Argument = Argument_Count then return; end if; Clear_Line; for I in Parameters.Last_Argument .. Argument_Count loop WWU.Set_Unbounded_Wide_Wide_String (Target => Arg, Source => UTF.Decode (Item => Argument (I), Input_Scheme => UTF_8)); -- Each argument should be a valid unit name, but should also be -- a subsystem name (contain no delimiters) if not Unit_Names.Valid_Unit_Name (WWU.To_Wide_Wide_String (Arg)) then UI.Put_Fail_Tag; Put_Line (" """ & To_UTF8 (Arg) & """ is not a valid subsystem name"); raise Process_Failed; elsif WWU.Count (Source => Arg, Set => Delimiters) > 0 then UI.Put_Fail_Tag; Put_Line (" Only subsystems can be checked out."); UI.Put_Empty_Tag; Put_Line (" """ & To_UTF8 (Arg) & """ is not a library-level unit."); raise Process_Failed; end if; -- Ask the Registrar to register it. If this fails, it means it is -- a root subsystem, and can't be requested declare OK: Boolean; begin Registrar.Registration.Request_AURA_Subsystem (Name => Unit_Names.Set_Name (WWU.To_Wide_Wide_String (Arg)), OK => OK); if not OK then UI.Put_Fail_Tag; Put_Line (" Subsystem """ & To_UTF8 (Arg) & """ is part of the root project,"); UI.Put_Empty_Tag; Put_Line (" and can't be checked-out"); raise Process_Failed; end if; end; end loop; end Add_Explicit_Checkouts; -------------------- -- Checkout_Cycle -- -------------------- procedure Checkout_Cycle is Checkout_Tracker: Progress.Progress_Tracker renames Checkout.Checkout_Pass_Progress; Reg_Tracker: Progress.Progress_Tracker renames Registrar.Registration.Entry_Progress; Hash_Crunch_Tracker: Progress.Progress_Tracker renames Registrar.Implementation_Hashing.Crunch_Phase_Progress; Config_Tracker: Progress.Progress_Tracker renames Configuration.Configuration_Progress; Caching_Tracker: Progress.Progress_Tracker renames Repositories.Cache.Caching_Progress; Checkout_Title : constant String := "Checking out subsystems"; Reg_Title : constant String := "Registering new units "; Hash_Crunch_Title : constant String := "Hashing configurations "; Config_Title : constant String := "Configuring subsystems "; Config_Root_Title : constant String := "Processing root config "; Cache_Title : constant String := "Caching repositories "; Pass: Positive := 1; Failures, Timedout: Boolean; Num_Requested: Count_Type; begin -- Check and dump any work reports that might exist. We don't expect -- any at this stage, but there's no harm in dumping them here, if they -- are part of debugging Clear_Line; if Workers.Reporting.Available_Reports > 0 then UI.Put_Info_Tag; Put_Line (" Unexpected worker reports. " & Count_Type'Image (Workers.Reporting.Available_Reports) & " reports to follow:"); UI.Dump_Reports; end if; loop Checkout_Tracker .Reset; Reg_Tracker .Reset; Hash_Crunch_Tracker.Reset; Config_Tracker .Reset; Caching_Tracker .Reset; -- Checkout requested repositories UI.Prep_Tracker (Checkout_Title); Checkout.Checkout_Pass; UI.Wait_Tracker (Process_Title => Checkout_Title, Tracker => Checkout_Tracker, Failures => Failures, Timedout => Timedout); if (Failures and then Workers.Reporting.Available_Reports > 0) or else Timedout then -- This means something "uncommon" went wrong - something that was -- not the innocent failure to find a requested subsystem, and -- so we need to go through the more aggressive abort with worker -- reports route. -- Otherwise the failed items will result in a subsystem being -- set to the Unavailable state, which can be queried later raise Process_Failed; end if; UI.Wait_Tracker_Or_Abort (Process_Title => Reg_Title, Tracker => Reg_Tracker); -- Hash any configuration or manifest units UI.Prep_Tracker (Hash_Crunch_Title); Registrar.Implementation_Hashing.Hash_Configurations; UI.Wait_Tracker_Or_Abort (Process_Title => Hash_Crunch_Title, Tracker => Hash_Crunch_Tracker); -- Configuration run UI.Prep_Tracker (Config_Title); Configuration.Configuration_Pass; UI.Wait_Tracker_Or_Abort (Process_Title => Config_Title, Tracker => Config_Tracker); -- Wait on entry of any condepaths UI.Wait_Tracker_Or_Abort (Process_Title => Reg_Title, Tracker => Reg_Tracker); Num_Requested := Registrar.Queries.Requested_Subsystems.Length; Clear_Line; UI.Put_OK_Tag; UI.Put_Info (" Checkout - pass" & Positive'Image (Pass) & " completed. " & (if Num_Requested = 1 then " 1 subsystem" else Count_Type'Image (Num_Requested) & " subsystems") & " remaining."); exit when Num_Requested = 0; Pass := Pass + 1; -- Cache repos ahead of next run UI.Prep_Tracker (Cache_Title); Repositories.Cache.Cache_Repositories; UI.Wait_Tracker_Or_Abort (Process_Title => Cache_Title, Tracker => Caching_Tracker, Spinner_Only => False, Process_Timeout => 120.0); end loop; -- Root config Config_Tracker.Reset; UI.Prep_Tracker (Config_Root_Title); Configuration.Process_Root_Configuration; UI.Wait_Tracker_Or_Abort (Process_Title => Config_Root_Title, Tracker => Config_Tracker); Clear_Line; -- Final tally declare use Registrar.Subsystems; All_Subsystems: constant Subsystem_Sets.Set := Registrar.Queries.All_Subsystems; Avail_Tally, Unavail_Tally: Count_Type := 0; begin for Subsys of All_Subsystems loop if Subsys.AURA then case Subsys.State is when Available => Avail_Tally := Avail_Tally + 1; when Unavailable => Unavail_Tally := Unavail_Tally + 1; when others => null; end case; end if; end loop; if Unavail_Tally > 0 then UI.Put_Fail_Tag; Put_Line (" Failed to checkout" & Count_Type'Image (Unavail_Tally) & " AURA " & (if Unavail_Tally = 1 then "subsystem." else "subsystems.") & " Details to follow.."); else Registrar.Registration.Exclude_Manifests; UI.Put_OK_Tag; Put_Line (" Checked-out and configured" & Count_Type'Image (Avail_Tally) & " AURA " & (if Avail_Tally = 1 then "subsystem " else "subsystems ") & "in" & Positive'Image (Pass) & (if Pass = 1 then " pass." else " passes.")); end if; end; end Checkout_Cycle; ------------------------------ -- Consolidate_Dependencies -- ------------------------------ procedure Consolidate_Dependencies is Consolidation_Merge_Title : constant String := "Consolidating dependencies (Merge) "; Consolidation_Fan_Out_Title: constant String := "Consolidating dependencies (Fan-out)"; Consolidation_Build_Title : constant String := "Consolidating dependencies (Build) "; Consolidation_Merge_Tracker: Progress.Progress_Tracker renames Registrar.Dependency_Processing.Merge_Subunits_Progress; Consolidation_Fan_Out_Tracker: Progress.Progress_Tracker renames Registrar.Dependency_Processing.Fan_Out_Progress; Consolidation_Build_Tracker: Progress.Progress_Tracker renames Registrar.Dependency_Processing.Build_Reverse_Progress; begin Consolidation_Merge_Tracker .Reset; Consolidation_Fan_Out_Tracker.Reset; Consolidation_Build_Tracker .Reset; UI.Prep_Tracker (Consolidation_Merge_Title); Registrar.Dependency_Processing.Consolidate_Dependencies; UI.Wait_Tracker_Or_Abort (Process_Title => Consolidation_Merge_Title, Tracker => Consolidation_Merge_Tracker); UI.Wait_Tracker_Or_Abort (Process_Title => Consolidation_Fan_Out_Title, Tracker => Consolidation_Fan_Out_Tracker); UI.Wait_Tracker_Or_Abort (Process_Title => Consolidation_Build_Title, Tracker => Consolidation_Build_Tracker); Clear_Line; UI.Put_OK_Tag; UI.Put_Info (" All dependency maps consolidated."); end Consolidate_Dependencies; ---------------------- -- Check_Completion -- ---------------------- procedure Report_Unavailable_Subsystems (Unavailable_Subsystems: in Registrar.Subsystems.Subsystem_Sets.Set) is separate; -- Dumps the information for the case when one or more AURA Subsystems -- could not be aquired procedure Report_Incomplete_Subsystems (Requested_Units: in Registrar.Library_Units.Library_Unit_Sets.Set) is separate; -- Dumps the information for the case when one or more units have not been -- entered -------------------------------------------------- procedure Check_Completion is use Registrar.Subsystems; use Registrar.Library_Units; package Subsystem_Unfulfilled_Maps is new Ada.Containers.Hashed_Maps (Key_Type => Subsystem, Element_Type => Library_Unit_Sets.Set, Hash => Subsystem_Name_Hash, Equivalent_Keys => Equivalent_Subsystems, "=" => Library_Unit_Sets."="); Entered_Units: constant Library_Unit_Sets.Set := Registrar.Queries.Entered_Library_Units; Requested_Units: constant Library_Unit_Sets.Set := Registrar.Queries.Requested_Library_Units; Available_Subsystems: constant Subsystem_Sets.Set := Registrar.Queries.Available_Subsystems; Unavailable_Subsystems: constant Subsystem_Sets.Set := Registrar.Queries.Unavailable_Subsystems; pragma Assert (Registrar.Queries.Requested_Subsystems.Length = 0); pragma Assert (Registrar.Queries.Aquired_Subsystems.Length = 0); -- These conditions should be enforced by the Checkout_Cycle phase, which -- should either configure all aquired subsystems, or mark them as -- Unavailable begin Clear_Line; if Unavailable_Subsystems.Length > 0 then Report_Unavailable_Subsystems (Unavailable_Subsystems); raise Process_Failed; elsif Requested_Units.Length > 0 then -- If we have unavailable subsystems, we ignore missing units. Let's -- deal with one thing at a time UI.Put_Fail_Tag; Put_Line (" Some expected library units are missing."); UI.Put_Empty_Tag; Put_Line (" This may indicate subsystem version incompatabilities, or"); UI.Put_Empty_Tag; Put_Line (" incompatabilities with the subsystem configuration (" & "deactivated codepaths)."); Report_Incomplete_Subsystems (Requested_Units); raise Process_Failed; else -- Everything looks good. Lets print some statistics UI.Put_OK_Tag; Put_Line (" All dependencies satisfied (" & Trim(Count_Type'Image (Available_Subsystems.Length)) & (if Available_Subsystems.Length = 1 then " subsystem," else " subsystems,") & Count_Type'Image (Entered_Units.Length) & (if Entered_Units.Length = 1 then " unit)." else " units).")); end if; end Check_Completion; ------------------- -- Hash_Registry -- ------------------- procedure Hash_Registry is Hash_Collection_Title: constant String := "Hashing all units (Collection) "; Hash_Crunch_Title: constant String := "Hashing all units (Crunch) "; Hash_Object_Title: constant String := "Hashing all units (Objects) "; Hash_Collection_Tracker: Progress.Progress_Tracker renames Registrar.Implementation_Hashing.Collection_Phase_Progress; Hash_Crunch_Tracker: Progress.Progress_Tracker renames Registrar.Implementation_Hashing.Crunch_Phase_Progress; Hash_Object_Tracker: Progress.Progress_Tracker renames Build.Compilation_Hash_Progress; begin Clear_Line; Hash_Collection_Tracker.Reset; Hash_Crunch_Tracker .Reset; Hash_Object_Tracker .Reset; UI.Prep_Tracker (Hash_Collection_Title); Registrar.Implementation_Hashing.Hash_All; UI.Wait_Tracker_Or_Abort (Process_Title => Hash_Collection_Title, Tracker => Hash_Collection_Tracker); UI.Wait_Tracker_Or_Abort (Process_Title => Hash_Crunch_Title, Tracker => Hash_Crunch_Tracker); UI.Prep_Tracker (Hash_Object_Title); Build.Hash_Compilation_Products; UI.Wait_Tracker_Or_Abort (Process_Title => Hash_Object_Title, Tracker => Hash_Object_Tracker); Clear_Line; UI.Put_OK_Tag; UI.Put_Info (" All units hashed."); Clear_Line; end Hash_Registry; ------------- -- Compile -- ------------- procedure Compile is use Registrar.Library_Units; Output_Quiet: constant Boolean := Parameters.Output_Style = Quiet; Compute_Recompilation_Title: constant String := "Computing Compilation Strategy "; Compile_Title: constant String := "Compiling "; Compute_Recompilation_Tracker: Progress.Progress_Tracker renames Build.Compute_Recompilations_Progress; Compile_Tracker: Progress.Progress_Tracker renames Build.Compilation.Compilation_Progress; Compile_Timeout : Boolean; Compile_Failures: Boolean; Pending_Compile: Count_Type; begin Clear_Line; if Workers.Reporting.Available_Reports > 0 then UI.Put_Info_Tag; Put_Line (" Unexpected worker reports. " & Count_Type'Image (Workers.Reporting.Available_Reports) & " reports to follow:"); UI.Dump_Reports; end if; Compute_Recompilation_Tracker.Reset; Compile_Tracker.Reset; UI.Prep_Tracker (Compute_Recompilation_Title); Build.Compute_Recompilations (Parameters.Build_Config); UI.Wait_Tracker_Or_Abort (Process_Title => Compute_Recompilation_Title, Tracker => Compute_Recompilation_Tracker); Clear_Line; UI.Put_Exec_Tag; Put (' ' & Compute_Recompilation_Title & "(Updating registry...)"); Build.Compute_Recompilations_Completion.Wait_Leave; Pending_Compile := Registrar.Queries.Available_Library_Units.Length; Clear_Line; UI.Put_OK_Tag; if Pending_Compile = 0 then -- This should mean that no recompilations are necessary. pragma Assert (for all Unit of Registrar.Queries.All_Library_Units => Unit.State = Compiled or else (Unit.Kind = Subunit and Unit.State = Available)); Put_Line (" No units required compilation."); return; else Put_Line (Count_Type'Image (Pending_Compile) & (if Pending_Compile = 1 then " unit" else " units") & " pending compilation.."); end if; UI.Prep_Tracker (Compile_Title); Build.Init_Paths; Build.Compilation.Compile (Parameters.Build_Config); UI.Wait_Tracker (Process_Title => Compile_Title, Tracker => Compile_Tracker, Failures => Compile_Failures, Timedout => Compile_Timeout); if Compile_Timeout then UI.Put_Fail_Tag; Put_Line (" Compilation timed-out."); end if; Clear_Line; if Build.Compilation.Compiler_Messages.Current_Use > 0 then if Compile_Failures then UI.Put_Fail_Tag; Put_Line (Natural'Image (Compile_Tracker.Failed_Items) & " of" & Natural'Image (Compile_Tracker.Total_Items) & " units failed to compile:"); else UI.Put_Warn_Tag; Put_Line (Natural'Image (Compile_Tracker.Completed_Items) & " units compiled successfully." & Count_Type'Image (Build.Compilation.Compiler_Messages.Current_Use) & " units had warnings" & (if Output_Quiet then '.' else ':')); end if; -- Now display the messages for each unit if Output_Quiet then UI.Put_Info_Tag; Put_Line (" Compiler output suppressed. "); Ui.Put_Empty_Tag; Put_Line (" Refer to contents of aura-build/build_output/"); end if; declare use Build.Compilation; Message: Compiler_Message; begin loop select Compiler_Messages.Dequeue (Message); else exit; end select; case Message.Context is when Warning => UI.Put_Warn_Tag; Put_Line (' ' & Message.Unit.Name.To_UTF8_String & ": Compilation completed with warnings" & (if Output_Quiet then '.' else ':')); when Error => UI.Put_Fail_Tag; Put_Line (' ' & Message.Unit.Name.To_UTF8_String & ": Compilation failed" & (if Output_Quiet then '.' else ':')); end case; if not Output_Quiet then Put_Line (UBS.To_String (Message.STDERR)); end if; end loop; end; if Compile_Failures or Compile_Timeout then raise Build_Failed; end if; elsif Compile_Timeout then raise Build_Failed; else UI.Put_OK_Tag; Put_Line (Natural'Image (Compile_Tracker.Completed_Items) & " units compiled successfully."); -- All units should now be compiled. Note that if we have an actual -- Library_Unit of Kind "Subunit", it means it is an Ada subunit that -- has its own subunits, and therefore, like all subunits, cannot -- actually be compiled pragma Assert (for all Unit of Registrar.Queries.All_Library_Units => Unit.State = Compiled or else (Unit.Kind = Subunit and Unit.State = Available)); end if; end Compile; ---------- -- Bind -- ---------- procedure Bind is use Registrar.Library_Units; Binding_Title: constant String := " Binding..."; begin Clear_Line; UI.Put_Exec_Tag; Put (Binding_Title); -- Set-up the Parameters.Target_Units depending on if we have a -- "main unit" or not if not Parameters.Main_Unit.Empty then if not Registrar.Queries.Unit_Registered (Parameters.Main_Unit) then Clear_Line; UI.Put_Fail_Tag; Put_Line (" Binding failed. Main unit """ & Parameters.Main_Unit.To_UTF8_String & """ does not exist."); raise Build_Failed; end if; declare Main_Unit: constant Library_Unit := Registrar.Queries.Lookup_Unit (Parameters.Main_Unit); begin case Main_Unit.Kind is when Package_Unit | Subprogram_Unit => Parameters.Target_Units := Library_Unit_Sets.To_Set (Main_Unit); when External_Unit => -- AURA does not support using External_Units as the main -- unit. The proper way to do this is to create a library. Clear_Line; UI.Put_Fail_Tag; Put_Line (" The main unit must be an Ada unit." & " Please consider the 'library' command."); raise Build_Failed; when Subunit => Clear_Line; UI.Put_Fail_Tag; Put_Line (" The main unit cannot be a Subunit."); raise Build_Failed; when Unknown => Clear_Line; UI.Put_Fail_Tag; Put_Line (" Internal error: main unit is of Kind 'Unknown'."); raise Build_Failed; end case; end; else -- All (Ada) units are bound Parameters.Target_Units := Registrar.Queries.Ada_Library_Units; end if; pragma Assert (for all Unit of Parameters.Target_Units => Unit.State = Compiled and Unit.Kind in Package_Unit | Subprogram_Unit); declare use UBS; Bind_Errors: Unbounded_String; begin Build.Linking.Bind (Unit_Set => Parameters.Target_Units, Configuration => Parameters.Build_Config, Errors => Bind_Errors); Clear_Line; if Length (Bind_Errors) > 0 then UI.Put_Fail_Tag; Put_Line (" Binding failed:"); New_Line; Put_Line (To_String (Bind_Errors)); raise Build_Failed; end if; exception when Build_Failed => raise; when e: others => Clear_Line; UI.Put_Fail_Tag; Put_Line (" Bind failed with an unexpected exception"); Put_Line (" -- Binder errors --"); Put_Line (To_String (Bind_Errors)); Put_Line (" -- Exception Information --"); Put_Line (Ada.Exceptions.Exception_Information (e)); raise Build_Failed; -- Since Binding is always done "fresh", it's safe to always -- raise a Build_Failed in this case end; UI.Wait_Tracker_Or_Abort (Process_Title => " Entering binder unit", Tracker => Registrar.Registration.Entry_Progress, Spinner_Only => True); -- Interesting fact here - since we entered this binder unit after -- we did the recompilation check orders, it will never be subject -- to that check, and thus will always be compiled. This is -- intentional since this entire binder process is GNAT-specific, -- and AURA is designed to be as compiler-agnostic as possible. -- -- This is a very small price to pay. Clear_Line; Build.Compilation.Compilation_Progress.Reset; Build.Compilation.Compile (Parameters.Build_Config); UI.Wait_Tracker_Or_Abort (Process_Title => " Compiling binder unit", Tracker => Build.Compilation.Compilation_Progress, Spinner_Only => True); -- Incorporate the binder unit into Target_Units declare use Unit_Names; Binder_Unit: constant Library_Unit := Registrar.Queries.Lookup_Unit (Set_Name ("ada_main")); begin Parameters.Target_Units.Include (Binder_Unit); exception when e: others => Clear_Line; UI.Put_Fail_Tag; Put_Line (" Binder unit could not be included"); Put_Line (" -- Exception Information --"); Put_Line (Ada.Exceptions.Exception_Information (e)); raise Process_Failed; end; Clear_Line; UI.Put_OK_Tag; Put_Line (" Binding complete."); end Bind; ------------------------- -- Expand_Dependencies -- ------------------------- procedure Expand_Dependencies is procedure Recursive_Add_Dependencies (Unit: Registrar.Library_Units.Library_Unit); procedure Recursive_Add_Dependencies (Unit: Registrar.Library_Units.Library_Unit) is use Registrar.Library_Units; New_Adds: Library_Unit_Sets.Set := Registrar.Queries.Unit_Dependencies (Unit); begin New_Adds.Difference (Parameters.Target_Units); Parameters.Target_Units.Union (New_Adds); -- This approach ensures that cycles are not possible if the codebase -- has circular dependencies (legal with limited withs), since we only -- ever do a recursive call on units that do not already exist in the -- Target_Units, and we always add those units to the target set -- before recursing. for New_Unit of New_Adds loop Recursive_Add_Dependencies (New_Unit); end loop; end Recursive_Add_Dependencies; Op_Name: constant String := " Expanding Main Unit Dependencies..."; begin if Parameters.Main_Unit.Empty then -- In this case we're building "everything", so just add in any -- external units Parameters.Target_Units.Union (Registrar.Queries.External_Units); return; end if; Clear_Line; UI.Put_Exec_Tag; Put (Op_Name); -- We are going to be tampering with Parameters.Target_Unit, so we -- need to make a copy. The existing set should only contain two -- units. declare use Registrar.Library_Units; Expansion_Base: constant Library_Unit_Sets.Set := Parameters.Target_Units; begin for Base_Unit of Expansion_Base loop Recursive_Add_Dependencies (Base_Unit); end loop; end; Clear_Line; UI.Put_OK_Tag; Put_Line (Op_Name & " Done."); end Expand_Dependencies; ------------------------- -- Scan_Linker_Options -- ------------------------- procedure Scan_Linker_Options is Process_Title: constant String := "Scaning linker options"; Tracker: Progress.Progress_Tracker renames Build.Linking.Scan_Progress; begin UI.Prep_Tracker (Process_Title); Tracker.Reset; Build.Linking.Scan_Linker_Options (Registrar.Queries.Ada_Library_Units); UI.Wait_Tracker_Or_Abort (Process_Title => Process_Title, Tracker => Tracker); Clear_Line; UI.Put_OK_Tag; Put_Line (" Scanned" & Natural'Image (Tracker.Completed_Items) & (if Tracker.Completed_Items = 1 then " unit " else " units ") & "finding" & Count_Type'Image (Build.Linking.Linker_Options.Current_Use) & (if Build.Linking.Linker_Options.Current_Use = 1 then " linker option." else " linker options.")); end Scan_Linker_Options; --------------------- -- Link_Or_Archive -- --------------------- procedure Link_Or_Archive is use UBS; Link_Errors: Unbounded_String; begin Clear_Line; UI.Put_Exec_Tag; case Command is when Build_Command | Run_Command => Put (" Linking Image..."); declare Image_Name: constant String := (if Parameters.Main_Unit.Empty then "aura.out" else Parameters.Main_Unit.To_UTF8_String); Image_Path: constant String := Ada.Directories.Current_Directory & '/' & Image_Name; begin if Command = Run_Command then UBS.Set_Unbounded_String (Target => Parameters.Executable, Source => Image_Path); end if; Build.Linking.Link_Image (Image_Path => Image_Path, Unit_Set => Parameters.Target_Units, Configuration => Parameters.Build_Config, Errors => Link_Errors); end; when Library_Command => Put (" Linking Library.."); declare -- The argument parser (Initialize_Parameters) ensures that -- there is a valid library name following the "last argument" -- in this case Library_Name: constant String := Ada.Command_Line.Argument (Parameters.Last_Argument + 1); Library_Extension: constant String := Ada.Directories.Extension (Library_Name); Library_Path: constant String := Ada.Directories.Current_Directory & '/' & Library_Name; begin if Library_Extension in "a" | "A" then Build.Linking.Archive (Archive_Path => Library_Path, Unit_Set => Parameters.Target_Units, Configuration => Parameters.Build_Config, Errors => Link_Errors); else -- Assume a shared library Build.Linking.Link_Library (Library_Path => Library_Path, Unit_Set => Parameters.Target_Units, Configuration => Parameters.Build_Config, Errors => Link_Errors); end if; end; when others => -- Failed precondition raise Program_Error with "Must be invoked when Command is Build, Run, or Library."; end case; Clear_Line; UI.Put_OK_Tag; Put_Line (" Link complete."); if Length (Link_Errors) > 0 then UI.Put_Fail_Tag; Put_Line (" Linking failed:"); New_Line; Put_Line (To_String (Link_Errors)); raise Process_Failed; end if; exception when Process_Failed => raise; when e: others => Clear_Line; UI.Put_Fail_Tag; Put_Line (" Linker failed with an unexpected exception"); Put_Line (" -- Linker errors --"); Put_Line (To_String (Link_Errors)); Put_Line (" -- Exception Information --"); Put_Line (Ada.Exceptions.Exception_Information (e)); raise Process_Failed; end Link_Or_Archive; ------------------- -- Execute_Image -- ------------------- procedure Execute_Image is separate; ------------------- -- Save_Registry -- ------------------- procedure Save_Registry is begin Registrar.Last_Run_Store.Store_Current_Run; exception when e: others => -- This makes the project inconsistent New_Line; UI.Put_Warn_Tag; Put_Line (" Unable to save registry."); UI.Put_Warn_Tag; Put_Line (' ' & Ada.Exceptions.Exception_Information (e)); UI.Put_Warn_Tag; Put_Line (" Invoke aura clean before next run."); end Save_Registry; ----------------- -- Save_Config -- ----------------- procedure Save_Config is begin Build.Store_Build_Config (Parameters.Build_Config); exception when e: others => New_Line; UI.Put_Warn_Tag; Put_Line (" Unable to save configuration"); UI.Put_Warn_Tag; Put_Line (' ' & Ada.Exceptions.Exception_Information (e)); UI.Put_Warn_Tag; Put_Line (" Invoke aura clean before next run."); end Save_Config; end Scheduling;
SietsevanderMolen/fly-thing
Ada
5,367
ads
with I2C; use I2C; with Interfaces; use Interfaces; package PCA9685 is type Chip is new I2C.Chip with null record; Clock : constant Float := 25000000.0; -- Default oscillator freq Resolution : constant Float := 4096.0; -- PCA9685 is 12bits -- Reset the chip to the power-on reset state. procedure Reset (C : in out Chip); -- Set the PWM Frequency to use for all outputs procedure SetPWMFreq (C : in out Chip; Frequency : Float); pragma Precondition (Frequency >= 40.0 and Frequency <= 1000.0); -- Set PWM for given pin procedure SetPWM (C : in out Chip; Pin : Unsigned_8; On : Unsigned_16; Off : Unsigned_16); pragma Precondition ((Pin <= 15 or Pin = 61) and -- 61 is ALL_LED_ON_L On <= 4096 and Off <= 4096); -- Sets pin without having to deal with on/off tick placement and properly -- handles a zero value as completely off. Optional invert parameter -- supports inverting the pulse for sinking to ground. Val should be a -- value from 0 to 4095 inclusive. procedure SetPin (C : in out Chip; Pin : Unsigned_8; Value : Unsigned_16; Invert : Boolean := False); pragma Precondition ((Pin <= 15 or Pin = 61) and -- 61 is ALL_LED_ON_L Value <= 4095); private -- Name the chip's registers MODE1 : constant Register := 0; MODE2 : constant Register := 1; SUBADR1 : constant Register := 2; SUBADR2 : constant Register := 3; SUBADR3 : constant Register := 4; ALLCALLADR : constant Register := 5; LED0_ON_L : constant Register := 6; LED0_ON_H : constant Register := 7; LED0_OFF_L : constant Register := 8; LED0_OFF_H : constant Register := 9; LED1_ON_L : constant Register := 10; LED1_ON_H : constant Register := 11; LED1_OFF_L : constant Register := 12; LED1_OFF_H : constant Register := 13; LED2_ON_L : constant Register := 14; LED2_ON_H : constant Register := 15; LED2_OFF_L : constant Register := 16; LED2_OFF_H : constant Register := 17; LED3_ON_L : constant Register := 18; LED3_ON_H : constant Register := 19; LED3_OFF_L : constant Register := 20; LED3_OFF_H : constant Register := 21; LED4_ON_L : constant Register := 22; LED4_ON_H : constant Register := 23; LED4_OFF_L : constant Register := 24; LED4_OFF_H : constant Register := 25; LED5_ON_L : constant Register := 26; LED5_ON_H : constant Register := 27; LED5_OFF_L : constant Register := 28; LED5_OFF_H : constant Register := 29; LED6_ON_L : constant Register := 30; LED6_ON_H : constant Register := 31; LED6_OFF_L : constant Register := 32; LED6_OFF_H : constant Register := 33; LED7_ON_L : constant Register := 34; LED7_ON_H : constant Register := 35; LED7_OFF_L : constant Register := 36; LED7_OFF_H : constant Register := 37; LED8_ON_L : constant Register := 38; LED8_ON_H : constant Register := 39; LED8_OFF_L : constant Register := 40; LED8_OFF_H : constant Register := 41; LED9_ON_L : constant Register := 42; LED9_ON_H : constant Register := 43; LED9_OFF_L : constant Register := 44; LED9_OFF_H : constant Register := 45; LED10_ON_L : constant Register := 46; LED10_ON_H : constant Register := 47; LED10_OFF_L : constant Register := 48; LED10_OFF_H : constant Register := 49; LED11_ON_L : constant Register := 50; LED11_ON_H : constant Register := 51; LED11_OFF_L : constant Register := 52; LED11_OFF_H : constant Register := 53; LED12_ON_L : constant Register := 54; LED12_ON_H : constant Register := 55; LED12_OFF_L : constant Register := 56; LED12_OFF_H : constant Register := 57; LED13_ON_L : constant Register := 58; LED13_ON_H : constant Register := 59; LED13_OFF_L : constant Register := 60; LED13_OFF_H : constant Register := 61; LED14_ON_L : constant Register := 62; LED14_ON_H : constant Register := 63; LED14_OFF_L : constant Register := 64; LED14_OFF_H : constant Register := 65; LED15_ON_L : constant Register := 66; LED15_ON_H : constant Register := 67; LED15_OFF_L : constant Register := 68; LED15_OFF_H : constant Register := 69; -- 69-249 reserved for future use ALL_LED_ON_L : constant Register := 250; ALL_LED_ON_H : constant Register := 251; ALL_LED_OFF_L : constant Register := 252; ALL_LED_OFF_H : constant Register := 253; PRESCALE : constant Register := 254; TESTMODE : constant Register := 255; -- Name the MODE1 bits. RESTART : constant Unsigned_8 := 2 ** 7; EXTCLK : constant Unsigned_8 := 2 ** 6; AI : constant Unsigned_8 := 2 ** 5; SLEEP : constant Unsigned_8 := 2 ** 4; SUB1 : constant Unsigned_8 := 2 ** 3; SUB2 : constant Unsigned_8 := 2 ** 2; SUB3 : constant Unsigned_8 := 2 ** 1; ALLCALL : constant Unsigned_8 := 2 ** 0; -- Name the MODE2 bits. -- 5-7 read only, reserved INVRT : constant Unsigned_8 := 2 ** 4; OCH : constant Unsigned_8 := 2 ** 3; OUTDRV : constant Unsigned_8 := 2 ** 2; OUTNE1 : constant Unsigned_8 := 2 ** 1; OUTNE0 : constant Unsigned_8 := 2 ** 0; end PCA9685;
ZinebZaad/ENSEEIHT
Ada
8,189
adb
with Ada.Text_IO; use Ada.Text_IO; with Vecteurs_Creux; use Vecteurs_Creux; procedure Test_Vecteurs_Creux is procedure Initialiser (VC0, VC1, VC2 : out T_Vecteur_Creux) is begin -- VC0 est un vecteur nul Initialiser (VC0); -- VC1 est un vecteur à deux composante Initialiser (VC1); Modifier (VC1, 10, 4.0); Modifier (VC1, 3, -3.0); Initialiser (VC2); Modifier (VC2, 100, 2.0); Modifier (VC2, 3, 3.0); Modifier (VC2, 1, 2.0); -- Afficher les vecteurs -- Put ("VC0 = "); Afficher (VC0); New_Line; -- Put ("VC1 = "); Afficher (VC1); New_Line; -- Put ("VC2 = "); Afficher (VC2); New_Line; end; procedure Detruire (VC0, VC1, VC2 : in out T_Vecteur_Creux) is begin Detruire (VC0); Detruire (VC1); Detruire (VC2); end; procedure Tester_Nul is VC0, VC1, VC2: T_Vecteur_Creux; begin Initialiser (VC0, VC1, VC2); pragma Assert (Est_Nul (VC0)); pragma Assert (not Est_Nul (VC1)); pragma Assert (not Est_Nul (VC2)); Detruire (VC0, VC1, VC2); end Tester_Nul; procedure Tester_Norme2 is VC0, VC1, VC2: T_Vecteur_Creux; begin Initialiser (VC0, VC1, VC2); pragma Assert (0.0 = Norme2 (VC0)); pragma Assert (25.0 = Norme2 (VC1)); Detruire (VC0, VC1, VC2); end Tester_Norme2; type T_Fonction_Composante is access Function (VC : in T_Vecteur_Creux ; Indice : in Integer) return Float; --! Un pointeur sur un sous-programme permet de manipuler un --! sous-programme comme une donnée. Composante : constant T_Fonction_Composante := Composante_Recursif'Access; --! Composante est donc une constante qui pointe sur le sous-programme --! Composante_Recursif. procedure Tester_Composante(La_Composante : T_Fonction_Composante) is --! Remarque : On aurait pu arriver au même résultat en définissant un --! sous-programme générique. --! Voir Tester_Sont_Egaux pour une version générique. VC0, VC1, VC2: T_Vecteur_Creux; begin Initialiser (VC0, VC1, VC2); pragma Assert ( 0.0 = La_Composante (VC0, 1)); pragma Assert ( 0.0 = La_Composante (VC1, 1)); pragma Assert (-3.0 = La_Composante (VC1, 3)); pragma Assert ( 0.0 = La_Composante (VC1, 4)); pragma Assert ( 0.0 = La_Composante (VC1, 9)); pragma Assert ( 4.0 = La_Composante (VC1, 10)); pragma Assert ( 0.0 = La_Composante (VC1, 11)); Detruire (VC0, VC1, VC2); end Tester_Composante; procedure Tester_Modifier is VC0, VC1, VC2: T_Vecteur_Creux; begin Initialiser (VC0, VC1, VC2); pragma Assert (2 = Nombre_Composantes_Non_Nulles (VC1)); -- Changer des composantes non nulles -- * en première position Modifier (VC1, 3, 3.0); pragma Assert (3.0 = Composante (VC1, 3)); pragma Assert (2 = Nombre_Composantes_Non_Nulles (VC1)); -- * après la première Modifier (VC1, 10, 15.0); pragma Assert (15.0 = Composante (VC1, 10)); pragma Assert (2 = Nombre_Composantes_Non_Nulles (VC1)); -- Ajouter au début Modifier (VC1, 1, 1.5); pragma Assert (1.5 = Composante (VC1, 1)); pragma Assert (3 = Nombre_Composantes_Non_Nulles (VC1)); -- Ajouter au milieu Modifier (VC1, 7, 7.5); pragma Assert (7.5 = Composante (VC1, 7)); pragma Assert (4 = Nombre_Composantes_Non_Nulles (VC1)); -- Ajouter à la fin. Modifier (VC1, 111, 0.5); pragma Assert (0.5 = Composante (VC1, 111)); pragma Assert (5 = Nombre_Composantes_Non_Nulles (VC1)); -- Mettre à 0.0 une composante existante -- * Au milieu Modifier (VC1, 10, 0.0); pragma Assert (0.0 = composante (VC1, 10)); pragma Assert (4 = Nombre_Composantes_Non_Nulles (VC1)); -- * À la fin Modifier (VC1, 111, 0.0); pragma Assert (0.0 = composante (VC1, 111)); pragma Assert (3 = Nombre_Composantes_Non_Nulles (VC1)); -- * Au début Modifier (VC1, 1, 0.0); pragma Assert (0.0 = composante (VC1, 1)); pragma Assert (2 = Nombre_Composantes_Non_Nulles (VC1)); -- Mettre à 0.0 une composante déjà nulle Modifier (VC1, 6, 0.0); pragma Assert (2 = Nombre_Composantes_Non_Nulles (VC1)); Modifier (VC1, 2, 0.0); pragma Assert (2 = Nombre_Composantes_Non_Nulles (VC1)); Modifier (VC1, 56, 0.0); pragma Assert (2 = Nombre_Composantes_Non_Nulles (VC1)); -- Supprimer toutes les composantes Modifier (VC1, 7, 0.0); pragma Assert (1 = Nombre_Composantes_Non_Nulles (VC1)); Modifier (VC1, 3, 0.0); pragma Assert (0 = Nombre_Composantes_Non_Nulles (VC1)); pragma Assert (Est_Nul (VC1)); Detruire (VC0, VC1, VC2); end Tester_Modifier; generic with function Egaux (Vecteur1, Vecteur2 : in T_Vecteur_Creux) return Boolean; procedure Tester_Sont_Egaux; procedure Tester_Sont_Egaux is VC0, VC1, VC2, VC3: T_Vecteur_Creux; begin Initialiser (VC0, VC1, VC2); pragma Assert (Egaux (VC0, VC0)); pragma Assert (Egaux (VC1, VC1)); pragma Assert (Egaux (VC2, VC2)); pragma Assert (not Egaux (VC0, VC1)); pragma Assert (not Egaux (VC0, VC2)); pragma Assert (not Egaux (VC1, VC2)); pragma Assert (not Egaux (VC1, VC0)); pragma Assert (not Egaux (VC2, VC0)); pragma Assert (not Egaux (VC2, VC1)); -- VC3 avec les mêmes composantes que VC1 Initialiser (VC3); Modifier (VC3, 10, 4.0); Modifier (VC3, 3, -3.0); pragma Assert (Egaux (VC1, VC3)); pragma Assert (Egaux (VC3, VC1)); Detruire (VC0, VC1, VC2); Detruire (VC3); end Tester_Sont_Egaux; --! Remarque : si on instancie les deux sous-programmes suivant juste --! avant l'implantation de Tester_Sont_Egaux ci-dessus, on n'a pas --! d'erreur de compilation mais une erreur à l'exécution. procedure Tester_Sont_Egaux_Iteratif is new Tester_Sont_Egaux (Sont_Egaux_Iteratif); procedure Tester_Sont_Egaux_Recursif is new Tester_Sont_Egaux (Sont_Egaux_Recursif); procedure Tester_Produit_Scalaire is VC0, VC1, VC2, VC3: T_Vecteur_Creux; begin Initialiser (VC0, VC1, VC2); pragma Assert (0.0 = Produit_Scalaire (VC0, VC1)); pragma Assert (0.0 = Produit_Scalaire (VC0, VC2)); pragma Assert (0.0 = Produit_Scalaire (VC1, VC0)); pragma Assert (-9.0 = Produit_Scalaire (VC1, VC2)); pragma Assert (25.0 = Produit_Scalaire (VC1, VC1)); Initialiser (VC3); Modifier (VC3, 150, 5.0); Modifier (VC3, 10, 4.0); Modifier (VC3, 3, 3.0); Modifier (VC3, 2, 2.0); Modifier (VC3, 1, 1.0); pragma Assert (11.0 = Produit_Scalaire (VC2, VC3)); pragma Assert (11.0 = Produit_Scalaire (VC3, VC2)); pragma Assert (7.0 = Produit_Scalaire (VC1, VC3)); pragma Assert (7.0 = Produit_Scalaire (VC3, VC1)); Detruire (VC0, VC1, VC2); Detruire (VC3); end Tester_Produit_Scalaire; procedure Tester_Additionner_Partage is VC0, VC1: T_Vecteur_Creux; begin -- Construire VC0 Initialiser (VC0); for I in 1..5 loop Modifier (VC0, I, Float(I)); end loop; -- Construire VC1 Initialiser (VC1); for I in 4..15 loop Modifier (VC1, I, Float(I)); end loop; -- Additionner Additionner (VC0, VC1); -- Vérifier qu'il n'y a pas de partage entre cellules de VC0 et VC1 Modifier (VC1, 10, 111.0); pragma Assert (111.0 = Composante (VC1, 10)); pragma Assert (10.0 = Composante (VC0, 10)); Detruire (VC0); Detruire (VC1); end Tester_Additionner_Partage; procedure Tester_Additionner is VC0, VC1, VC2: T_Vecteur_Creux; begin Initialiser (VC0, VC1, VC2); Additionner (VC0, VC1); pragma Assert (Sont_Egaux_Recursif (VC0, VC1)); pragma Assert (2 = Nombre_Composantes_Non_Nulles (VC0)); pragma Assert (-3.0 = Composante (VC0, 3)); pragma Assert ( 4.0 = Composante (VC0, 10)); Additionner (VC0, VC2); pragma Assert (3 = Nombre_Composantes_Non_Nulles (VC0)); pragma Assert (2.0 = Composante (VC0, 1)); pragma Assert (0.0 = Composante (VC0, 3)); pragma Assert (4.0 = Composante (VC0, 10)); pragma Assert (2.0 = Composante (VC0, 100)); Additionner (VC2, VC1); pragma Assert (Sont_Egaux_Recursif (VC0, VC2)); Detruire (VC0, VC1, VC2); end Tester_Additionner; begin Tester_Nul; Tester_Norme2; Tester_Composante (Composante_Recursif'Access); Tester_Composante (Composante_Iteratif'Access); Tester_Modifier; Tester_Sont_Egaux_Recursif; Tester_Sont_Egaux_Iteratif; Tester_Produit_Scalaire; Tester_Additionner_Partage; Tester_Additionner; end Test_Vecteurs_Creux;
reznikmm/matreshka
Ada
6,820
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$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Elements; with AMF.Internals.Helpers; with AMF.Internals.Tables.Utp_Attributes; with AMF.UML.Call_Operation_Actions; with AMF.Visitors.Utp_Iterators; with AMF.Visitors.Utp_Visitors; package body AMF.Internals.Utp_Read_Timer_Actions is ------------------------------------ -- Get_Base_Call_Operation_Action -- ------------------------------------ overriding function Get_Base_Call_Operation_Action (Self : not null access constant Utp_Read_Timer_Action_Proxy) return AMF.UML.Call_Operation_Actions.UML_Call_Operation_Action_Access is begin return AMF.UML.Call_Operation_Actions.UML_Call_Operation_Action_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.Utp_Attributes.Internal_Get_Base_Call_Operation_Action (Self.Element))); end Get_Base_Call_Operation_Action; ------------------------------------ -- Set_Base_Call_Operation_Action -- ------------------------------------ overriding procedure Set_Base_Call_Operation_Action (Self : not null access Utp_Read_Timer_Action_Proxy; To : AMF.UML.Call_Operation_Actions.UML_Call_Operation_Action_Access) is begin AMF.Internals.Tables.Utp_Attributes.Internal_Set_Base_Call_Operation_Action (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Base_Call_Operation_Action; ------------------- -- Enter_Element -- ------------------- overriding procedure Enter_Element (Self : not null access constant Utp_Read_Timer_Action_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.Utp_Visitors.Utp_Visitor'Class then AMF.Visitors.Utp_Visitors.Utp_Visitor'Class (Visitor).Enter_Read_Timer_Action (AMF.Utp.Read_Timer_Actions.Utp_Read_Timer_Action_Access (Self), Control); end if; end Enter_Element; ------------------- -- Leave_Element -- ------------------- overriding procedure Leave_Element (Self : not null access constant Utp_Read_Timer_Action_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.Utp_Visitors.Utp_Visitor'Class then AMF.Visitors.Utp_Visitors.Utp_Visitor'Class (Visitor).Leave_Read_Timer_Action (AMF.Utp.Read_Timer_Actions.Utp_Read_Timer_Action_Access (Self), Control); end if; end Leave_Element; ------------------- -- Visit_Element -- ------------------- overriding procedure Visit_Element (Self : not null access constant Utp_Read_Timer_Action_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.Utp_Iterators.Utp_Iterator'Class then AMF.Visitors.Utp_Iterators.Utp_Iterator'Class (Iterator).Visit_Read_Timer_Action (Visitor, AMF.Utp.Read_Timer_Actions.Utp_Read_Timer_Action_Access (Self), Control); end if; end Visit_Element; end AMF.Internals.Utp_Read_Timer_Actions;
zhmu/ananas
Ada
3,298
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- G N A T . W I D E _ S P E L L I N G _ C H E C K E R -- -- -- -- S p e c -- -- -- -- Copyright (C) 1998-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. -- -- -- ------------------------------------------------------------------------------ -- Spelling checker -- This package provides a utility routine for checking for bad spellings -- for the case of Wide_String arguments. package GNAT.Wide_Spelling_Checker is pragma Pure; function Is_Bad_Spelling_Of (Found : Wide_String; Expect : Wide_String) return Boolean; -- Determines if the string Found is a plausible misspelling of the string -- Expect. Returns True for an exact match or a probably misspelling, False -- if no near match is detected. This routine is case sensitive, so the -- caller should fold both strings to get a case insensitive match. -- -- Note: the spec of this routine is deliberately rather vague. It is used -- by GNAT itself to detect misspelled keywords and identifiers, and is -- heuristically adjusted to be appropriate to this usage. It will work -- well in any similar case of named entities. end GNAT.Wide_Spelling_Checker;
jamiepg1/sdlada
Ada
2,263
adb
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2014 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 System; package body SDL.Versions is package C renames Interfaces.C; function Revision return String is function SDL_Get_Revision return C.Strings.chars_ptr with Import => True, Convention => C, External_Name => "SDL_GetRevision"; C_Str : C.Strings.chars_ptr := SDL_Get_Revision; begin return C.Strings.Value (C_Str); end Revision; function Revision return Revision_Level is function SDL_Get_Revision_Number return C.int with Import => True, Convention => C, External_Name => "SDL_GetRevisionNumber"; begin return Revision_Level (SDL_Get_Revision_Number); end Revision; procedure Linked_With (Info : in out Version) is procedure SDL_Get_Version (V : access Version) with Import => True, Convention => C, External_Name => "SDL_GetVersion"; Data : aliased Version; begin SDL_Get_Version (Data'Access); Info := Data; end Linked_With; end SDL.Versions;
reznikmm/matreshka
Ada
3,872
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.Country_Asian; package ODF.DOM.Attributes.Style.Country_Asian.Internals is function Create (Node : Matreshka.ODF_Attributes.Style.Country_Asian.Style_Country_Asian_Access) return ODF.DOM.Attributes.Style.Country_Asian.ODF_Style_Country_Asian; function Wrap (Node : Matreshka.ODF_Attributes.Style.Country_Asian.Style_Country_Asian_Access) return ODF.DOM.Attributes.Style.Country_Asian.ODF_Style_Country_Asian; end ODF.DOM.Attributes.Style.Country_Asian.Internals;
AdaCore/gpr
Ada
3,309
adb
-- -- Copyright (C) 2019-2023, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 -- with Ada.Strings.Fixed; with Ada.Text_IO; with GPR2.Unit; with GPR2.Context; with GPR2.Log; with GPR2.Message; with GPR2.Path_Name; with GPR2.Project.Source.Set; with GPR2.Project.Tree; with GPR2.Project.View; with GPR2.Source_Info.Parser.Ada_Language; procedure Main is use Ada; use GPR2; use GPR2.Project; procedure Check (Project_Name : Filename_Type); -- Do check the given project's sources procedure Output_Filename (Filename : Path_Name.Full_Name); -- Remove the leading tmp directory ----------- -- Check -- ----------- procedure Check (Project_Name : Filename_Type) is Prj : Project.Tree.Object; Ctx : Context.Object; View : Project.View.Object; begin Project.Tree.Load (Prj, Create (Project_Name), Ctx); View := Prj.Root_Project; Text_IO.Put_Line ("Project: " & String (View.Name)); for Source of View.Sources loop declare U : constant Optional_Name_Type := Source.Unit_Name; begin Output_Filename (Source.Path_Name.Value); Text_IO.Set_Col (16); Text_IO.Put (" language: " & Image (Source.Language)); Text_IO.Set_Col (33); Text_IO.Put (" Kind: " & GPR2.Unit.Library_Unit_Type'Image (Source.Kind)); if U /= "" then Text_IO.Put (" unit: " & String (U)); end if; Text_IO.New_Line; end; end loop; exception when E : GPR2.Project_Error => Text_IO.Put_Line ("BEFORE: Has unread Message: " & Prj.Log_Messages.Has_Element (Read => False)'Img); for C in Prj.Log_Messages.Iterate (False, True, True, True, True) loop declare M : constant Message.Object := Log.Element (C); F : constant String := M.Sloc.Filename; I : constant Natural := Strings.Fixed.Index (F, "source-errors"); begin Text_IO.Put_Line ("> " & F (I - 1 .. F'Last)); Text_IO.Put_Line (M.Level'Img); if M.Sloc.Has_Source_Reference then Text_IO.Put_Line (M.Sloc.Line'Img); Text_IO.Put_Line (M.Sloc.Column'Img); end if; Text_IO.Put_Line (M.Message); end; end loop; -- Read also information message for C in Prj.Log_Messages.Iterate (True, True, True, True, True) loop null; end loop; Text_IO.Put_Line ("AFTER: Has unread Message: " & Prj.Log_Messages.Has_Element (Read => False)'Img); Text_IO.New_Line; end Check; --------------------- -- Output_Filename -- --------------------- procedure Output_Filename (Filename : Path_Name.Full_Name) is I : constant Positive := Strings.Fixed.Index (Filename, "source-errors"); begin Text_IO.Put (" > " & Filename (I + 14 .. Filename'Last)); end Output_Filename; begin Check ("demo1.gpr"); Check ("demo2.gpr"); Check ("demo3.gpr"); Check ("demo4.gpr"); Check ("demo5.gpr"); end Main;
google-code/ada-util
Ada
8,859
ads
----------------------------------------------------------------------- -- util-http-clients -- HTTP Clients -- Copyright (C) 2011, 2012 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Finalization; with Util.Http.Cookies; -- == Client == -- The <tt>Util.Http.Clients</tt> package defines a set of API for an HTTP client to send -- requests to an HTTP server. -- -- === GET request === -- To retrieve a content using the HTTP GET operation, a client instance must be created. -- The response is returned in a specific object that must therefore be declared: -- -- Http : Util.Http.Clients.Client; -- Response : Util.Http.Clients.Response; -- -- Before invoking the GET operation, the client can setup a number of HTTP headers. -- -- Http.Add_Header ("X-Requested-By", "wget"); -- -- The GET operation is performed when the <tt>Get</tt> procedure is called: -- -- Http.Get ("http://www.google.com", Response); -- -- Once the response is received, the <tt>Response</tt> object contains the status of the -- HTTP response, the HTTP reply headers and the body. A response header can be obtained -- by using the <tt>Get_Header</tt> function and the body using <tt>Get_Body</tt>: -- -- Body : constant String := Response.Get_Body; -- package Util.Http.Clients is Connection_Error : exception; -- ------------------------------ -- Http response -- ------------------------------ -- The <b>Response</b> type represents a response returned by an HTTP request. type Response is limited new Abstract_Response with private; -- Returns a boolean indicating whether the named response header has already -- been set. overriding function Contains_Header (Reply : in Response; Name : in String) return Boolean; -- Returns the value of the specified response header as a String. If the response -- did not include a header of the specified name, this method returns null. -- If there are multiple headers with the same name, this method returns the -- first head in the request. The header name is case insensitive. You can use -- this method with any response header. overriding function Get_Header (Reply : in Response; Name : in String) return String; -- Sets a message header with the given name and value. If the header had already -- been set, the new value overwrites the previous one. The containsHeader -- method can be used to test for the presence of a header before setting its value. overriding procedure Set_Header (Reply : in out Response; Name : in String; Value : in String); -- Adds a request header with the given name and value. -- This method allows request headers to have multiple values. overriding procedure Add_Header (Reply : in out Response; Name : in String; Value : in String); -- Iterate over the response headers and executes the <b>Process</b> procedure. overriding procedure Iterate_Headers (Reply : in Response; Process : not null access procedure (Name : in String; Value : in String)); -- Get the response body as a string. overriding function Get_Body (Reply : in Response) return String; -- Get the response status code. overriding function Get_Status (Reply : in Response) return Natural; -- ------------------------------ -- Http client -- ------------------------------ -- The <b>Client</b> type allows to execute HTTP GET/POST requests. type Client is limited new Abstract_Request with private; type Client_Access is access all Client; -- Returns a boolean indicating whether the named response header has already -- been set. overriding function Contains_Header (Request : in Client; Name : in String) return Boolean; -- Returns the value of the specified request header as a String. If the request -- did not include a header of the specified name, this method returns null. -- If there are multiple headers with the same name, this method returns the -- first head in the request. The header name is case insensitive. You can use -- this method with any response header. overriding function Get_Header (Request : in Client; Name : in String) return String; -- Sets a header with the given name and value. If the header had already -- been set, the new value overwrites the previous one. The containsHeader -- method can be used to test for the presence of a header before setting its value. overriding procedure Set_Header (Request : in out Client; Name : in String; Value : in String); -- Adds a header with the given name and value. -- This method allows headers to have multiple values. overriding procedure Add_Header (Request : in out Client; Name : in String; Value : in String); -- Iterate over the request headers and executes the <b>Process</b> procedure. overriding procedure Iterate_Headers (Request : in Client; Process : not null access procedure (Name : in String; Value : in String)); -- Removes all headers with the given name. procedure Remove_Header (Request : in out Client; Name : in String); -- Adds the specified cookie to the request. This method can be called multiple -- times to set more than one cookie. procedure Add_Cookie (Http : in out Client; Cookie : in Util.Http.Cookies.Cookie); -- Execute an http GET request on the given URL. Additional request parameters, -- cookies and headers should have been set on the client object. procedure Get (Request : in out Client; URL : in String; Reply : out Response'Class); -- Execute an http POST request on the given URL. The post data is passed in <b>Data</b>. -- Additional request cookies and headers should have been set on the client object. procedure Post (Request : in out Client; URL : in String; Data : in String; Reply : out Response'Class); private subtype Http_Request is Abstract_Request; subtype Http_Request_Access is Abstract_Request_Access; subtype Http_Response is Abstract_Response; subtype Http_Response_Access is Abstract_Response_Access; type Http_Manager is interface; type Http_Manager_Access is access all Http_Manager'Class; procedure Create (Manager : in Http_Manager; Http : in out Client'Class) is abstract; procedure Do_Get (Manager : in Http_Manager; Http : in Client'Class; URI : in String; Reply : out Response'Class) is abstract; procedure Do_Post (Manager : in Http_Manager; Http : in Client'Class; URI : in String; Data : in String; Reply : out Response'Class) is abstract; Default_Http_Manager : Http_Manager_Access; type Response is new Ada.Finalization.Limited_Controlled and Abstract_Response with record Delegate : Abstract_Response_Access; end record; -- Free the resource used by the response. overriding procedure Finalize (Reply : in out Response); type Client is new Ada.Finalization.Limited_Controlled and Abstract_Request with record Manager : Http_Manager_Access; Delegate : Http_Request_Access; end record; -- Initialize the client overriding procedure Initialize (Http : in out Client); overriding procedure Finalize (Http : in out Client); end Util.Http.Clients;
damaki/libkeccak
Ada
2,001
ads
------------------------------------------------------------------------------- -- Copyright (c) 2019, Daniel King -- 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. -- * The name of the copyright holder may not 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 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 Keccak.Generic_XOF; generic with package XOF is new Keccak.Generic_XOF (<>); package XOF_Runner is procedure Run_Tests (File_Name : in String; Num_Passed : out Natural; Num_Failed : out Natural); end XOF_Runner;
flyx/OpenGLAda
Ada
2,616
ads
-- part of OpenGLAda, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "COPYING" with System; with Interfaces.C; with GL.Low_Level; -- This package is incomplete. As I do not develop or test under Linux, this -- has very low priority. Perhaps someone wants to help out... package GL.GLX is pragma Preelaborate; -- needed types from Xlib type XID is new Interfaces.C.unsigned_long; type GLX_Context is new System.Address; type GLX_Drawable is new XID; type Screen_Depth is new Natural; type Screen_Number is new Natural; type Visual_ID is new XID; type Display_Pointer is new System.Address; type X_Visual_Info is record Visual : System.Address; Visual_Ident : Visual_ID; Screen : Screen_Number; Depth : Screen_Depth; Class : Integer; Red_Mask : Long_Integer; Green_Mask : Long_Integer; Blue_Mask : Long_Integer; Colormap_Size : Natural; Bits_Per_RGB : Natural; end record; pragma Convention (C_Pass_By_Copy, X_Visual_Info); type X_Visual_Info_Pointer is access all X_Visual_Info; pragma Convention (C, X_Visual_Info_Pointer); function Create_Context (Display : Display_Pointer; Visual : X_Visual_Info_Pointer; Share_List : GLX_Context; Direct : Low_Level.Bool) return GLX_Context; function Make_Current (Display : Display_Pointer; Drawable : GLX_Drawable; Context : GLX_Context) return Low_Level.Bool; function Make_Context_Current (Display : Display_Pointer; Draw : GLX_Drawable; Read : GLX_Drawable; Context : GLX_Context) return Low_Level.Bool; function Get_Current_Context return System.Address; function Get_Current_Display return System.Address; function Get_Proc_Address (Name : Interfaces.C.char_array) return System.Address; private pragma Import (C, Create_Context, "glXCreateContext"); pragma Import (C, Make_Current, "glXMakeCurrent"); pragma Import (C, Make_Context_Current, "glXMakeContextCurrent"); pragma Import (C, Get_Current_Context, "glXGetCurrentContext"); pragma Import (C, Get_Current_Display, "glXGetCurrentDisplay"); pragma Import (C, Get_Proc_Address, "glXGetProcAddress"); end GL.GLX;
reznikmm/matreshka
Ada
4,588
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- 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.CMOF.Classifiers.Collections; with AMF.CMOF.Redefinable_Elements.Collections; with AMF.Internals.CMOF_Named_Elements; package AMF.Internals.CMOF_Redefinable_Elements is type CMOF_Redefinable_Element_Proxy is abstract limited new AMF.Internals.CMOF_Named_Elements.CMOF_Named_Element_Proxy and AMF.CMOF.Redefinable_Elements.CMOF_Redefinable_Element with null record; overriding function Get_Is_Leaf (Self : not null access constant CMOF_Redefinable_Element_Proxy) return Boolean; overriding function Get_Redefined_Element (Self : not null access constant CMOF_Redefinable_Element_Proxy) return AMF.CMOF.Redefinable_Elements.Collections.Set_Of_CMOF_Redefinable_Element; -- Getter of RedefinableElement::redefinedElement. -- -- The redefinable element that is being redefined by this element. overriding function Get_Redefinition_Context (Self : not null access constant CMOF_Redefinable_Element_Proxy) return AMF.CMOF.Classifiers.Collections.Set_Of_CMOF_Classifier; -- Getter of RedefinableElement::redefinitionContext. -- -- References the contexts that this element may be redefined from. end AMF.Internals.CMOF_Redefinable_Elements;
AdaCore/libadalang
Ada
200
adb
procedure Gen_Use is generic type T is private; use type T; package Gen is end Gen; package My_Pkg is new Gen (Integer); --% node.p_inst_params begin null; end Gen_Use;
stcarrez/jason
Ada
953
ads
----------------------------------------------------------------------- -- jason -- Jason Project Management ----------------------------------------------------------------------- -- Copyright (C) 2016, 2017 Stephane.Carrez -- Written by Stephane.Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package Jason is end Jason;
zhmu/ananas
Ada
248
ads
package Subp_Inst_Pkg is pragma Pure; generic type T; type T_Access is access T; function Image (Val : T_Access) return String; generic type T; function T_Image (Val : access T) return String; end Subp_Inst_Pkg;
AdaCore/libadalang
Ada
103
ads
package A is X : Integer; pragma Find_All_References (Any, Imprecise_Fallback => True); end A;
AdaCore/ada-traits-containers
Ada
1,489
ads
-- -- Copyright (C) 2015-2016, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- -- Unbounded controlled vectors of unconstrained elements pragma Ada_2012; with Ada.Finalization; with Conts.Elements.Indefinite; with Conts.Vectors.Generics; with Conts.Vectors.Storage.Unbounded; generic type Index_Type is (<>); type Element_Type (<>) is private; with procedure Free (E : in out Element_Type) is null; package Conts.Vectors.Indefinite_Unbounded is pragma Assertion_Policy (Pre => Suppressible, Ghost => Suppressible, Post => Ignore); package Elements is new Conts.Elements.Indefinite (Element_Type, Free => Free, Pool => Conts.Global_Pool); package Storage is new Conts.Vectors.Storage.Unbounded (Elements => Elements.Traits, Container_Base_Type => Ada.Finalization.Controlled, Resize_Policy => Conts.Vectors.Resize_1_5); package Vectors is new Conts.Vectors.Generics (Index_Type, Storage.Traits); subtype Vector is Vectors.Vector; subtype Cursor is Vectors.Cursor; subtype Constant_Returned is Elements.Traits.Constant_Returned; No_Element : Cursor renames Vectors.No_Element; No_Index : Index_Type renames Vectors.No_Index; package Cursors renames Vectors.Cursors; package Maps renames Vectors.Maps; procedure Swap (Self : in out Cursors.Forward.Container; Left, Right : Index_Type) renames Vectors.Swap; end Conts.Vectors.Indefinite_Unbounded;
AdaCore/Ada-IntelliJ
Ada
13,802
ads
-- Copyright (c) 2013, Nordic Semiconductor ASA -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- * Redistributions of source code must retain the above copyright notice, this -- list of conditions and the following disclaimer. -- -- * Redistributions in binary form must reproduce the above copyright notice, -- this list of conditions and the following disclaimer in the documentation -- and/or other materials provided with the distribution. -- -- * Neither the name of Nordic Semiconductor ASA nor the names of its -- contributors may be used to endorse or promote products derived from -- this software without specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- This spec has been automatically generated from nrf51.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package NRF51_SVD.GPIO is pragma Preelaborate; --------------- -- Registers -- --------------- -- Pin 0. type OUT_PIN0_Field is ( -- Pin driver is low. Low, -- Pin driver is high. High) with Size => 1; for OUT_PIN0_Field use (Low => 0, High => 1); -- OUT_PIN array type OUT_PIN_Field_Array is array (0 .. 31) of OUT_PIN0_Field with Component_Size => 1, Size => 32; -- Write GPIO port. type OUT_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : HAL.UInt32; when True => -- PIN as an array Arr : OUT_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for OUT_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- Pin 0. type OUTSET_PIN0_Field is ( -- Pin driver is low. Low, -- Pin driver is high. High) with Size => 1; for OUTSET_PIN0_Field use (Low => 0, High => 1); -- Pin 0. type OUTSET_PIN0_Field_1 is ( -- Reset value for the field Outset_Pin0_Field_Reset, -- Set pin driver high. Set) with Size => 1; for OUTSET_PIN0_Field_1 use (Outset_Pin0_Field_Reset => 0, Set => 1); -- OUTSET_PIN array type OUTSET_PIN_Field_Array is array (0 .. 31) of OUTSET_PIN0_Field_1 with Component_Size => 1, Size => 32; -- Set individual bits in GPIO port. type OUTSET_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : HAL.UInt32; when True => -- PIN as an array Arr : OUTSET_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for OUTSET_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- Pin 0. type OUTCLR_PIN0_Field is ( -- Pin driver is low. Low, -- Pin driver is high. High) with Size => 1; for OUTCLR_PIN0_Field use (Low => 0, High => 1); -- Pin 0. type OUTCLR_PIN0_Field_1 is ( -- Reset value for the field Outclr_Pin0_Field_Reset, -- Set pin driver low. Clear) with Size => 1; for OUTCLR_PIN0_Field_1 use (Outclr_Pin0_Field_Reset => 0, Clear => 1); -- OUTCLR_PIN array type OUTCLR_PIN_Field_Array is array (0 .. 31) of OUTCLR_PIN0_Field_1 with Component_Size => 1, Size => 32; -- Clear individual bits in GPIO port. type OUTCLR_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : HAL.UInt32; when True => -- PIN as an array Arr : OUTCLR_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for OUTCLR_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- Pin 0. type IN_PIN0_Field is ( -- Pin input is low. Low, -- Pin input is high. High) with Size => 1; for IN_PIN0_Field use (Low => 0, High => 1); -- IN_PIN array type IN_PIN_Field_Array is array (0 .. 31) of IN_PIN0_Field with Component_Size => 1, Size => 32; -- Read GPIO port. type IN_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : HAL.UInt32; when True => -- PIN as an array Arr : IN_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for IN_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- Pin 0. type DIR_PIN0_Field is ( -- Pin set as input. Input, -- Pin set as output. Output) with Size => 1; for DIR_PIN0_Field use (Input => 0, Output => 1); -- DIR_PIN array type DIR_PIN_Field_Array is array (0 .. 31) of DIR_PIN0_Field with Component_Size => 1, Size => 32; -- Direction of GPIO pins. type DIR_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : HAL.UInt32; when True => -- PIN as an array Arr : DIR_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for DIR_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- Set as output pin 0. type DIRSET_PIN0_Field is ( -- Pin set as input. Input, -- Pin set as output. Output) with Size => 1; for DIRSET_PIN0_Field use (Input => 0, Output => 1); -- Set as output pin 0. type DIRSET_PIN0_Field_1 is ( -- Reset value for the field Dirset_Pin0_Field_Reset, -- Set pin as output. Set) with Size => 1; for DIRSET_PIN0_Field_1 use (Dirset_Pin0_Field_Reset => 0, Set => 1); -- DIRSET_PIN array type DIRSET_PIN_Field_Array is array (0 .. 31) of DIRSET_PIN0_Field_1 with Component_Size => 1, Size => 32; -- DIR set register. type DIRSET_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : HAL.UInt32; when True => -- PIN as an array Arr : DIRSET_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for DIRSET_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- Set as input pin 0. type DIRCLR_PIN0_Field is ( -- Pin set as input. Input, -- Pin set as output. Output) with Size => 1; for DIRCLR_PIN0_Field use (Input => 0, Output => 1); -- Set as input pin 0. type DIRCLR_PIN0_Field_1 is ( -- Reset value for the field Dirclr_Pin0_Field_Reset, -- Set pin as input. Clear) with Size => 1; for DIRCLR_PIN0_Field_1 use (Dirclr_Pin0_Field_Reset => 0, Clear => 1); -- DIRCLR_PIN array type DIRCLR_PIN_Field_Array is array (0 .. 31) of DIRCLR_PIN0_Field_1 with Component_Size => 1, Size => 32; -- DIR clear register. type DIRCLR_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PIN as a value Val : HAL.UInt32; when True => -- PIN as an array Arr : DIRCLR_PIN_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for DIRCLR_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- Pin direction. type PIN_CNF_DIR_Field is ( -- Configure pin as an input pin. Input, -- Configure pin as an output pin. Output) with Size => 1; for PIN_CNF_DIR_Field use (Input => 0, Output => 1); -- Connect or disconnect input path. type PIN_CNF_INPUT_Field is ( -- Connect input pin. Connect, -- Disconnect input pin. Disconnect) with Size => 1; for PIN_CNF_INPUT_Field use (Connect => 0, Disconnect => 1); -- Pull-up or -down configuration. type PIN_CNF_PULL_Field is ( -- No pull. Disabled, -- Pulldown on pin. Pulldown, -- Pullup on pin. Pullup) with Size => 2; for PIN_CNF_PULL_Field use (Disabled => 0, Pulldown => 1, Pullup => 3); -- Drive configuration. type PIN_CNF_DRIVE_Field is ( -- Standard '0', Standard '1'. S0S1, -- High '0', Standard '1'. H0S1, -- Standard '0', High '1'. S0H1, -- High '0', High '1'. H0H1, -- Disconnected '0', Standard '1'. D0S1, -- Disconnected '0', High '1'. D0H1, -- Standard '0', Disconnected '1'. S0D1, -- High '0', Disconnected '1'. H0D1) with Size => 3; for PIN_CNF_DRIVE_Field use (S0S1 => 0, H0S1 => 1, S0H1 => 2, H0H1 => 3, D0S1 => 4, D0H1 => 5, S0D1 => 6, H0D1 => 7); -- Pin sensing mechanism. type PIN_CNF_SENSE_Field is ( -- Disabled. Disabled, -- Wakeup on high level. High, -- Wakeup on low level. Low) with Size => 2; for PIN_CNF_SENSE_Field use (Disabled => 0, High => 2, Low => 3); -- Configuration of GPIO pins. type PIN_CNF_Register is record -- Pin direction. DIR : PIN_CNF_DIR_Field := NRF51_SVD.GPIO.Input; -- Connect or disconnect input path. INPUT : PIN_CNF_INPUT_Field := NRF51_SVD.GPIO.Disconnect; -- Pull-up or -down configuration. PULL : PIN_CNF_PULL_Field := NRF51_SVD.GPIO.Disabled; -- unspecified Reserved_4_7 : HAL.UInt4 := 16#0#; -- Drive configuration. DRIVE : PIN_CNF_DRIVE_Field := NRF51_SVD.GPIO.S0S1; -- unspecified Reserved_11_15 : HAL.UInt5 := 16#0#; -- Pin sensing mechanism. SENSE : PIN_CNF_SENSE_Field := NRF51_SVD.GPIO.Disabled; -- unspecified Reserved_18_31 : HAL.UInt14 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for PIN_CNF_Register use record DIR at 0 range 0 .. 0; INPUT at 0 range 1 .. 1; PULL at 0 range 2 .. 3; Reserved_4_7 at 0 range 4 .. 7; DRIVE at 0 range 8 .. 10; Reserved_11_15 at 0 range 11 .. 15; SENSE at 0 range 16 .. 17; Reserved_18_31 at 0 range 18 .. 31; end record; -- Configuration of GPIO pins. type PIN_CNF_Registers is array (0 .. 31) of PIN_CNF_Register with Volatile; ----------------- -- Peripherals -- ----------------- -- General purpose input and output. type GPIO_Peripheral is record -- Write GPIO port. OUT_k : aliased OUT_Register; -- Set individual bits in GPIO port. OUTSET : aliased OUTSET_Register; -- Clear individual bits in GPIO port. OUTCLR : aliased OUTCLR_Register; -- Read GPIO port. IN_k : aliased IN_Register; -- Direction of GPIO pins. DIR : aliased DIR_Register; -- DIR set register. DIRSET : aliased DIRSET_Register; -- DIR clear register. DIRCLR : aliased DIRCLR_Register; -- Configuration of GPIO pins. PIN_CNF : aliased PIN_CNF_Registers; end record with Volatile; for GPIO_Peripheral use record OUT_k at 16#504# range 0 .. 31; OUTSET at 16#508# range 0 .. 31; OUTCLR at 16#50C# range 0 .. 31; IN_k at 16#510# range 0 .. 31; DIR at 16#514# range 0 .. 31; DIRSET at 16#518# range 0 .. 31; DIRCLR at 16#51C# range 0 .. 31; PIN_CNF at 16#700# range 0 .. 1023; end record; -- General purpose input and output. GPIO_Periph : aliased GPIO_Peripheral with Import, Address => System'To_Address (16#50000000#); end NRF51_SVD.GPIO;
reznikmm/matreshka
Ada
3,734
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_Selected_Page_Attributes is pragma Preelaborate; type ODF_Table_Selected_Page_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Table_Selected_Page_Attribute_Access is access all ODF_Table_Selected_Page_Attribute'Class with Storage_Size => 0; end ODF.DOM.Table_Selected_Page_Attributes;
stcarrez/ada-awa
Ada
4,488
ads
----------------------------------------------------------------------- -- awa_test_app - -- Copyright (C) 2020, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with ASF.Servlets.Faces; with Servlet.Core.Files; with ASF.Servlets.Ajax; with ASF.Filters.Dump; with ASF.Filters.Cache_Control; with Servlet.Core.Measures; with ASF.Security.Servlets; with ASF.Converters.Sizes; with AWA.Users.Servlets; with AWA.Users.Modules; with AWA.Mail.Modules; with AWA.Comments.Modules; with AWA.Blogs.Modules; with AWA.Tags.Modules; with AWA.Storages.Modules; with AWA.Applications; with AWA.Workspaces.Modules; with AWA.Wikis.Modules; with AWA.Wikis.Previews; with AWA.Jobs.Modules; with AWA.Images.Modules; with AWA.Counters.Modules; with AWA.Services.Filters; with AWA.Converters.Dates; package AWA_Test_App is CONFIG_PATH : constant String := "/test"; CONTEXT_PATH : constant String := "/test"; type Application is new AWA.Applications.Application with private; type Application_Access is access all Application'Class; -- Initialize the servlets provided by the application. -- This procedure is called by <b>Initialize</b>. -- It should register the application servlets. overriding procedure Initialize_Servlets (App : in out Application); -- Initialize the filters provided by the application. -- This procedure is called by <b>Initialize</b>. -- It should register the application filters. overriding procedure Initialize_Filters (App : in out Application); -- Initialize the AWA modules provided by the application. -- This procedure is called by <b>Initialize</b>. -- It should register the modules used by the application. overriding procedure Initialize_Modules (App : in out Application); private type Application is new AWA.Applications.Application with record Self : Application_Access; -- Application servlets and filters (add new servlet and filter instances here). Faces : aliased ASF.Servlets.Faces.Faces_Servlet; Ajax : aliased ASF.Servlets.Ajax.Ajax_Servlet; Files : aliased Servlet.Core.Files.File_Servlet; Dump : aliased ASF.Filters.Dump.Dump_Filter; Service_Filter : aliased AWA.Services.Filters.Service_Filter; Measures : aliased Servlet.Core.Measures.Measure_Servlet; No_Cache : aliased ASF.Filters.Cache_Control.Cache_Control_Filter; -- Authentication servlet and filter. Auth : aliased ASF.Security.Servlets.Request_Auth_Servlet; Verify_Auth : aliased AWA.Users.Servlets.Verify_Auth_Servlet; Verify_Key : aliased AWA.Users.Servlets.Verify_Key_Servlet; -- Converters shared by web requests. Rel_Date_Converter : aliased AWA.Converters.Dates.Relative_Date_Converter; Size_Converter : aliased ASF.Converters.Sizes.Size_Converter; -- The application modules. User_Module : aliased AWA.Users.Modules.User_Module; Workspace_Module : aliased AWA.Workspaces.Modules.Workspace_Module; Blog_Module : aliased AWA.Blogs.Modules.Blog_Module; Mail_Module : aliased AWA.Mail.Modules.Mail_Module; Comment_Module : aliased AWA.Comments.Modules.Comment_Module; Storage_Module : aliased AWA.Storages.Modules.Storage_Module; Tag_Module : aliased AWA.Tags.Modules.Tag_Module; Job_Module : aliased AWA.Jobs.Modules.Job_Module; Image_Module : aliased AWA.Images.Modules.Image_Module; Wiki_Module : aliased AWA.Wikis.Modules.Wiki_Module; Preview_Module : aliased AWA.Wikis.Previews.Preview_Module; Counter_Module : aliased AWA.Counters.Modules.Counter_Module; end record; end AWA_Test_App;
reznikmm/matreshka
Ada
4,616
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.Font_Pitch_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Font_Pitch_Attribute_Node is begin return Self : Style_Font_Pitch_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_Font_Pitch_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Font_Pitch_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Style_URI, Matreshka.ODF_String_Constants.Font_Pitch_Attribute, Style_Font_Pitch_Attribute_Node'Tag); end Matreshka.ODF_Style.Font_Pitch_Attributes;
reznikmm/matreshka
Ada
4,145
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.Presentation_Use_Date_Time_Name_Attributes; package Matreshka.ODF_Presentation.Use_Date_Time_Name_Attributes is type Presentation_Use_Date_Time_Name_Attribute_Node is new Matreshka.ODF_Presentation.Abstract_Presentation_Attribute_Node and ODF.DOM.Presentation_Use_Date_Time_Name_Attributes.ODF_Presentation_Use_Date_Time_Name_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Presentation_Use_Date_Time_Name_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Presentation_Use_Date_Time_Name_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Presentation.Use_Date_Time_Name_Attributes;
AdaCore/training_material
Ada
4,141
adb
----------------------------------------------------------------------- -- Ada Labs -- -- -- -- Copyright (C) 2008-2009, AdaCore -- -- -- -- Labs is free software; you can redistribute it and/or modify it -- -- under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or -- -- (at your option) any later version. -- -- -- -- This program is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. You should have received -- -- a copy of the GNU General Public License along with this program; -- -- if not, write to the Free Software Foundation, Inc., 59 Temple -- -- Place - Suite 330, Boston, MA 02111-1307, USA. -- ----------------------------------------------------------------------- with Ada.Real_Time; use Ada.Real_Time; with Solar_System; use Solar_System; with Display; use Display; with Display.Basic; use Display.Basic; with Solar_System.Graphics; use Solar_System.Graphics; --with Last_Chance_Handler; procedure Main is -- declare a variable Now of type Time to record current time Now : Time; -- declare a constant Period of 40 milliseconds of type Time_Span defining the loop period Period : constant Time_Span := Milliseconds (30); -- reference to the application window Window : Window_ID; Canvas : Canvas_ID; begin -- Create the main window Window := Create_Window (Width => 240, Height => 320, Name => "Solar System"); Canvas := Get_Canvas (Window); -- Graphic_Context.Set_Window (Window); -- initialize Bodies using Init_Body procedure Init_Body (B => Sun, Radius => 20.0, Color => Yellow, Distance => 0.0, Speed => 0.0, Turns_Around => Sun); Init_Body (B => Earth, Radius => 5.0, Color => Blue, Distance => 50.0, Speed => 0.02, Turns_Around => Sun); Init_Body (B => Moon, Radius => 2.0, Color => Gray, Distance => 15.0, Speed => 0.04, Turns_Around => Earth); Init_Body (B => Satellite, Radius => 1.0, Color => Red, Distance => 8.0, Speed => 0.1, Turns_Around => Earth); Init_Body (B => Comet, Radius => 1.0, Color => Yellow, Distance => 80.0, Speed => 0.05, Tail => True, Turns_Around => Sun); Init_Body (B => Black_Hole, Radius => 0.0, Color => Blue, Distance => 75.0, Speed => -0.02, Turns_Around => Sun, Visible => False); Init_Body (B => Asteroid_1, Radius => 2.0, Color => Green, Distance => 5.0, Speed => 0.1, Turns_Around => Black_Hole); Init_Body (B => Asteroid_2, Radius => 2.0, Color => Blue, Distance => 5.0, Speed => 0.1, Angle => 1.57, Turns_Around => Black_Hole); -- create an infinite loop -- update the Now time with current clock -- wait until Now + Period time elapsed before the next Now := Clock; while not Is_Killed loop for B in Bodies_Enum_T loop Draw_Body (Object => Get_Body (B), Canvas => Canvas); end loop; Swap_Buffers (Window); delay until Now + Period; Now := Now + Period; end loop; end Main;
psyomn/afile
Ada
813
ads
-- Copyright 2017-2019 Simon Symeonidis (psyomn) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License.with Interfaces; use Interfaces; with Interfaces; use Interfaces; package Identify is function Try (H : Unsigned_64) return Boolean; procedure Identify_File (Filename : String); end Identify;
io7m/coreland-sdl-ada-annex
Ada
123
ads
package SDL.Video.Annex is function Data_Size (Surface : in Surface_Access_t) return Natural; end SDL.Video.Annex;
AdaCore/libadalang
Ada
67
ads
generic package Pkg_G is Test_Generic_Pkg : Integer; end Pkg_G;
zrmyers/VulkanAda
Ada
2,898
adb
-------------------------------------------------------------------------------- -- MIT License -- -- Copyright (c) 2020 Zane Myers -- -- Permission is hereby granted, free of charge, to any person obtaining a copy -- of this software and associated documentation files (the "Software"), to deal -- in the Software without restriction, including without limitation the rights -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -- copies of the Software, and to permit persons to whom the Software is -- furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in all -- copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -- SOFTWARE. -------------------------------------------------------------------------------- package body Vulkan.Math.GenIType is function Apply_Func_IVI_IVI_IVB_RVI( IVI1, IVI2 : in Vkm_GenIType; IVB1 : in Vkm_GenBType) return Vkm_GenIType is result : Vkm_GenIType := (last_index => IVI1.last_index, others => <>); begin for index in result.data'Range loop result.data(index) := Func(IVI1.data(index), IVI2.data(index), IVB1.data(index)); end loop; return result; end Apply_Func_IVI_IVI_IVB_RVI; ---------------------------------------------------------------------------- function Apply_Func_IVI_IVI_RVB( IVI1, IVI2 : in Vkm_GenIType) return Vkm_GenBType is result : Vkm_GenBType := (last_index => IVI1.last_index, others => <>); begin for index in result.data'Range loop result.data(index) := Func(IVI1.data(index),IVI2.data(index)); end loop; return result; end Apply_Func_IVI_IVI_RVB; ---------------------------------------------------------------------------- function Apply_Func_IVU_RVI( IVU1 : in Vkm_GenUType) return Vkm_GenIType is result : Vkm_GenIType := (last_index => IVU1.last_index, others => <>); begin for index in result.data'Range loop result.data(index) := Func(IVU1.data(index)); end loop; return result; end Apply_Func_IVU_RVI; end Vulkan.Math.GenIType;
reznikmm/matreshka
Ada
5,658
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. ------------------------------------------------------------------------------ with AMF.Generic_Collections; package AMF.UML.Template_Parameter_Substitutions.Collections is pragma Preelaborate; package UML_Template_Parameter_Substitution_Collections is new AMF.Generic_Collections (UML_Template_Parameter_Substitution, UML_Template_Parameter_Substitution_Access); type Set_Of_UML_Template_Parameter_Substitution is new UML_Template_Parameter_Substitution_Collections.Set with null record; Empty_Set_Of_UML_Template_Parameter_Substitution : constant Set_Of_UML_Template_Parameter_Substitution; type Ordered_Set_Of_UML_Template_Parameter_Substitution is new UML_Template_Parameter_Substitution_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_UML_Template_Parameter_Substitution : constant Ordered_Set_Of_UML_Template_Parameter_Substitution; type Bag_Of_UML_Template_Parameter_Substitution is new UML_Template_Parameter_Substitution_Collections.Bag with null record; Empty_Bag_Of_UML_Template_Parameter_Substitution : constant Bag_Of_UML_Template_Parameter_Substitution; type Sequence_Of_UML_Template_Parameter_Substitution is new UML_Template_Parameter_Substitution_Collections.Sequence with null record; Empty_Sequence_Of_UML_Template_Parameter_Substitution : constant Sequence_Of_UML_Template_Parameter_Substitution; private Empty_Set_Of_UML_Template_Parameter_Substitution : constant Set_Of_UML_Template_Parameter_Substitution := (UML_Template_Parameter_Substitution_Collections.Set with null record); Empty_Ordered_Set_Of_UML_Template_Parameter_Substitution : constant Ordered_Set_Of_UML_Template_Parameter_Substitution := (UML_Template_Parameter_Substitution_Collections.Ordered_Set with null record); Empty_Bag_Of_UML_Template_Parameter_Substitution : constant Bag_Of_UML_Template_Parameter_Substitution := (UML_Template_Parameter_Substitution_Collections.Bag with null record); Empty_Sequence_Of_UML_Template_Parameter_Substitution : constant Sequence_Of_UML_Template_Parameter_Substitution := (UML_Template_Parameter_Substitution_Collections.Sequence with null record); end AMF.UML.Template_Parameter_Substitutions.Collections;
charlie5/aIDE
Ada
1,568
ads
with Ada.Streams; package AdaM.a_Type.record_type is type Item is new a_Type.composite_Type with private; type View is access all Item'Class; -- Forge -- function new_Type (Name : in String := "") return record_type.view; overriding procedure destruct (Self : in out Item); procedure free (Self : in out record_type.view); -- Attributes -- overriding function Id (Self : access Item) return AdaM.Id; overriding function to_Source (Self : in Item) return text_Vectors.Vector; function is_Abstract (Self : in Item) return Boolean; procedure is_Abstract (Self : out Item; Now : in Boolean := True); function is_Tagged (Self : in Item) return Boolean; procedure is_Tagged (Self : out Item; Now : in Boolean := True); function is_Limited (Self : in Item) return Boolean; procedure is_Limited (Self : out Item; Now : in Boolean := True); private type Item is new a_Type.composite_Type with record is_Abstract : Boolean; is_Tagged : Boolean; is_Limited : Boolean; end record; -- Streams -- procedure View_write (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : in View); procedure View_read (Stream : not null access Ada.Streams.Root_Stream_Type'Class; Self : out View); for View'write use View_write; for View'read use View_read; end AdaM.a_Type.record_type;
zhmu/ananas
Ada
162
ads
package Opt48_Pkg2 is pragma Pure; type Rec (L : Natural) is record S : String (1 .. L); end record; function F return Rec; end Opt48_Pkg2;
reznikmm/matreshka
Ada
19,473
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- SQL Database Access -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-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 Ada.Numerics.Discrete_Random; with Matreshka.Internals.SQL_Drivers.Firebird.Fields; with Matreshka.Internals.SQL_Parameter_Rewriters.Firebird; package body Matreshka.Internals.SQL_Drivers.Firebird.Queries is SQL_Dialect : constant Isc_Db_Dialect := 3; Rewriter : SQL_Parameter_Rewriters.Firebird.Firebird_Parameter_Rewriter; function Random_String (Length : Interfaces.C.size_t) return Isc_String; ---------------- -- Bind_Value -- ---------------- overriding procedure Bind_Value (Self : not null access Firebird_Query; Name : League.Strings.Universal_String; Value : League.Holders.Holder; Direction : SQL.Parameter_Directions) is pragma Unreferenced (Direction); begin Self.Parameters.Set_Value (Name, Value); end Bind_Value; ----------------- -- Bound_Value -- ----------------- overriding function Bound_Value (Self : not null access Firebird_Query; Name : League.Strings.Universal_String) return League.Holders.Holder is pragma Unreferenced (Self); pragma Unreferenced (Name); begin return League.Holders.Empty_Holder; end Bound_Value; ------------------- -- Error_Message -- ------------------- overriding function Error_Message (Self : not null access Firebird_Query) return League.Strings.Universal_String is begin return Self.Error; end Error_Message; ------------- -- Execute -- ------------- overriding function Execute (Self : not null access Firebird_Query) return Boolean is Value : League.Holders.Holder; Result : Isc_Result_Code; begin -- Prepare parameter values. for Idx in 1 .. Self.Parameters.Number_Of_Positional loop Value := Self.Parameters.Value (Idx); Self.Sql_Params.Fields.Element (Isc_Valid_Field_Index (Idx)).Value (Value); end loop; Self.Sql_Record.Clear_Values; if Self.Sql_Type = DDL then return Self.Execute_Immediate; end if; case Self.Sql_Type is when Simple_Select | Select_For_Update => Result := Isc_Dsql_Execute (Self.Status'Access, Databases.Firebird_Database'Class (Self.Database.all).Transaction_Handle, Self.Stmt_Handle'Access, Sql_Dialect, Self.Sql_Params.Sqlda); if Result > 0 then Self.Error := Get_Error (Self.Status'Access); return False; end if; Self.State := Active; Self.Sql_Record.Clear_Values; when Exec_Procedure => Result := Isc_Dsql_Execute2 (Self.Status'Access, Databases.Firebird_Database'Class (Self.Database.all).Transaction_Handle, Self.Stmt_Handle'Access, Sql_Dialect, Self.Sql_Params.Sqlda, Self.Sql_Record.Sqlda); if Self.Status (1) = 1 and then Self.Status (2) > 0 then Self.Error := Get_Error (Self.Status'Access); return False; end if; when Commit | Rollback => return False; when Unknown | Insert | Update | Delete | DDL | Get_Segment | Put_Segment | Start_Transaction | Set_Generator | Save_Point_Operation => Result := Isc_Dsql_Execute (Self.Status'Access, Databases.Firebird_Database'Class (Self.Database.all).Transaction_Handle, Self.Stmt_Handle'Access, Sql_Dialect, Self.Sql_Params.Sqlda); if Result > 0 then Self.Error := Get_Error (Self.Status'Access); return False; end if; end case; Self.Is_Valid := False; return True; exception when others => Self.Free_Handle; return False; end Execute; ----------------------- -- Execute_Immediate -- ----------------------- function Execute_Immediate (Self : not null access Firebird_Query) return Boolean is Result : Isc_Result_Code; begin Self.Free_Handle; declare Statement : constant Isc_String := To_Isc_String (Self.Sql_Text); begin Result := Isc_Dsql_Execute_Immediate (Self.Status'Access, Databases.Firebird_Database'Class (Self.Database.all).Database_Handle, Databases.Firebird_Database'Class (Self.Database.all).Transaction_Handle, Statement'Length, Statement, Sql_Dialect, Self.Sql_Params.Sqlda); end; if Result > 0 then Self.Error := Get_Error (Self.Status'Access); return False; end if; return True; end Execute_Immediate; ------------ -- Finish -- ------------ overriding procedure Finish (Self : not null access Firebird_Query) is use type Isc_Long; EC : constant Isc_Result_Codes (1 .. 2) := (Isc_Bad_Stmt_Handle, Isc_Dsql_Cursor_Close_Err); Result : Isc_Result_Code; pragma Warnings (Off, Result); begin if Self.Stmt_Handle /= Null_Isc_Stmt_Handle then case Self.Sql_Type is when Simple_Select | Select_For_Update => Result := Isc_Dsql_Free_Statement (Self.Status'Access, Self.Stmt_Handle'Access, Isc_Sql_Close); if Self.Status (1) = 1 and then Self.Status (2) > 0 and then not Check_For_Error (Self.Status'Access, EC) then Self.Error := Get_Error (Self.Status'Access); end if; when others => Self.Free_Handle; end case; end if; Self.State := Inactive; end Finish; ----------------- -- Free_Handle -- ----------------- procedure Free_Handle (Self : not null access Firebird_Query) is use type Isc_Long; Result : Isc_Result_Code; begin Self.Sql_Record.Count (0); if Self.Stmt_Handle /= Null_Isc_Stmt_Handle then Result := Isc_Dsql_Free_Statement (Self.Status'Access, Self.Stmt_Handle'Access, Isc_Sql_Drop); Self.Stmt_Handle := Null_Isc_Stmt_Handle; Self.State := Inactive; if Self.Status (1) = 1 and then Result > 0 and then Result /= Isc_Bad_Stmt_Handle then Self.Error := Get_Error (Self.Status'Access); end if; end if; end Free_Handle; ---------------- -- Initialize -- ---------------- procedure Initialize (Self : not null access Firebird_Query'Class; Database : not null access Databases.Firebird_Database'Class; Codec : access League.Text_Codecs.Text_Codec; Utf : Boolean) is begin Self.Sql_Record.Codec := Codec; Self.Sql_Params.Codec := Codec; Self.Sql_Record.Utf := Utf; Self.Sql_Params.Utf := Utf; Self.Is_Valid := False; SQL_Drivers.Initialize (Self, Database_Access (Database)); end Initialize; ---------------- -- Invalidate -- ---------------- overriding procedure Invalidate (Self : not null access Firebird_Query) is begin Self.Finish; if Self.Stmt_Handle /= Null_Isc_Stmt_Handle then Self.Free_Handle; end if; Self.Sql_Params.Finalize; Self.Sql_Record.Finalize; -- Call Invalidate of parent tagged type. Abstract_Query (Self.all).Invalidate; end Invalidate; --------------- -- Is_Active -- --------------- overriding function Is_Active (Self : not null access Firebird_Query) return Boolean is begin return Self.State = Active; end Is_Active; -------------- -- Is_Valid -- -------------- overriding function Is_Valid (Self : not null access Firebird_Query) return Boolean is begin return Self.Is_Valid; end Is_Valid; ---------- -- Next -- ---------- overriding function Next (Self : not null access Firebird_Query) return Boolean is use type Isc_Long; Result : Isc_Result_Code; begin Result := Isc_Dsql_Fetch (Self.Status'Access, Self.Stmt_Handle'Access, Sql_Dialect, Self.Sql_Record.Sqlda); if Result > 0 then if Result = 100 then Self.Is_Valid := False; return False; else declare EC : constant Isc_Result_Codes (1 .. 1) := (others => Isc_Dsql_Cursor_Err); begin if Check_For_Error (Self.Status'Access, EC) then Self.Is_Valid := False; return False; else Self.Error := Get_Error (Self.Status'Access); Self.Finish; Self.Is_Valid := False; return False; end if; end; end if; else Self.Is_Valid := True; return True; end if; end Next; ------------- -- Prepare -- ------------- overriding function Prepare (Self : not null access Firebird_Query; Query : League.Strings.Universal_String) return Boolean is use type Records.Isc_Sqlda_Access; Result : Isc_Result_Code; Field : Fields.Field_Access; begin Self.Finish; Rewriter.Rewrite (Query, Self.Sql_Text, Self.Parameters); Self.Sql_Params.Count (Isc_Field_Index (Self.Parameters.Number_Of_Positional)); -- add params for Idx in 1 .. Isc_Field_Index (Self.Parameters.Number_Of_Positional) loop Field := Self.Sql_Params.Fields.Element (Idx); Field.Set_Null (True); Field.Sqlvar.Sqltype := Isc_Type_Empty; end loop; Result := Isc_Dsql_Alloc_Statement2 (Self.Status'Access, Databases.Firebird_Database'Class (Self.Database.all).Database_Handle, Self.Stmt_Handle'Access); if Result > 0 then Self.Error := Get_Error (Self.Status'Access); return False; end if; Self.Sql_Record.Count (1); declare Statement : constant Isc_String := To_Isc_String (Self.Sql_Text); begin Result := Isc_Dsql_Prepare (Self.Status'Access, Databases.Firebird_Database'Class (Self.Database.all).Transaction_Handle, Self.Stmt_Handle'Access, 0, Statement, Sql_Dialect, Self.Sql_Record.Sqlda); if Result > 0 then Self.Error := Get_Error (Self.Status'Access); return False; end if; end; -- Get the type of the statement declare use type Interfaces.C.char; Len : Isc_Long; Buffer : aliased Isc_String := (1 .. 9 => Interfaces.C.nul); Item : Isc_String (1 .. 1); begin Item (1) := Isc_Info_Sql_Stmt_Type; Result := Isc_Dsql_Sql_Info (Self.Status'Access, Self.Stmt_Handle'Access, 1, Item, 8, Buffer'Access); if Result > 0 then Self.Error := Get_Error (Self.Status'Access); return False; end if; if Buffer (1) /= Isc_Info_Sql_Stmt_Type then return False; end if; Len := Isc_Vax_Integer (Buffer (2 .. 4), 2); Self.Sql_Type := Query_Sql_Type'Val (Isc_Vax_Integer (Buffer (4 .. 9), Isc_Short (Len))); end; if Self.Sql_Type = Select_For_Update then Self.Cursor_Name := Random_String (10); Result := Isc_Dsql_Set_Cursor_Name (Self.Status'Access, Self.Stmt_Handle'Access, Self.Cursor_Name, 0); if Result > 0 then Self.Error := Get_Error (Self.Status'Access); return False; end if; end if; -- Done getting the type case Self.Sql_Type is when Get_Segment | Put_Segment | Start_Transaction => Self.Free_Handle; return False; when Insert | Update | Delete | Simple_Select | Select_For_Update | Exec_Procedure => if Self.Sql_Params.Sqlda /= null then Result := Isc_Dsql_Describe_Bind (Self.Status'Access, Self.Stmt_Handle'Access, Sql_Dialect, Self.Sql_Params.Sqlda); if Result > 0 then Self.Error := Get_Error (Self.Status'Access); return False; end if; end if; Self.Sql_Params.Init; case Self.Sql_Type is when Simple_Select | Select_For_Update | Exec_Procedure => if Self.Sql_Record.Sqlda.Sqld > Self.Sql_Record.Sqlda.Sqln then Self.Sql_Record.Count (Self.Sql_Record.Sqlda.Sqld); Result := Isc_Dsql_Describe (Self.Status'Access, Self.Stmt_Handle'Access, Sql_Dialect, Self.Sql_Record.Sqlda); if Result > 0 then Self.Error := Get_Error (Self.Status'Access); return False; end if; else if Self.Sql_Record.Sqlda.Sqld = 0 then Self.Sql_Record.Count (0); end if; end if; Self.Sql_Record.Init; when Unknown | Insert | Update | Delete | DDL | Get_Segment | Put_Segment | Start_Transaction | Commit | Rollback | Set_Generator | Save_Point_Operation => Self.Sql_Record.Count (0); end case; when Unknown | DDL | Commit | Rollback | Set_Generator | Save_Point_Operation => null; end case; return True; exception when others => if Self.Stmt_Handle /= Null_Isc_Stmt_Handle then Self.Free_Handle; end if; return False; end Prepare; ------------------- -- Random_String -- ------------------- function Random_String (Length : Interfaces.C.size_t) return Isc_String is use type Interfaces.C.size_t; use type Interfaces.C.char; subtype A_Z is Interfaces.C.char range '0' .. 'z'; package Rand is new Ada.Numerics.Discrete_Random (A_Z); Gen : Rand.Generator; Str : Isc_String (1 .. Length); Char : Interfaces.C.char; begin Rand.Reset (Gen); for Idx in 1 .. Length - 1 loop loop Char := Rand.Random (Gen); exit when (Char >= '0' and then Char <= '9') or else (Char >= 'A' and then Char <= 'Z') or else (Char >= 'a' and then Char <= 'z'); end loop; Str (Idx) := Char; end loop; Str (Str'Last) := Interfaces.C.nul; return Str; end Random_String; ----------- -- Value -- ----------- overriding function Value (Self : not null access Firebird_Query; Index : Positive) return League.Holders.Holder is begin return Self.Sql_Record.Fields.Element (Isc_Valid_Field_Index (Index)).Value; end Value; end Matreshka.Internals.SQL_Drivers.Firebird.Queries;
Samsung/TizenRT
Ada
12,642
ads
--------------------------------------------------------------- - -- ZLib for Ada thick binding. -- -- -- -- Copyright(C) 2002 - 2003 Dmitriy Anisimkov -- -- -- -- Open source license information is in the zlib.ads file. -- ---------------------------------------------------------------- -- $Id: zlib - thin.ads, v 1.11 2004 / 07 / 23 06:33:11 vagul Exp $ with Interfaces.C.Strings; with System; private package ZLib.Thin is - - From zconf.h MAX_MEM_LEVEL : constant : = 9; -- zconf.h: 105 - - zconf.h:105 MAX_WBITS : constant : = 15; -- zconf.h: 115 - - 32K LZ77 window -- zconf.h:115 SEEK_SET : constant : = 8#0000#; -- zconf.h: 244 - - Seek from beginning of file. -- zconf.h:244 SEEK_CUR : constant : = 1; -- zconf.h: 245 - - Seek from current position. -- zconf.h:245 SEEK_END : constant : = 2; -- zconf.h: 246 - - Set file pointer to EOF plus "offset" -- zconf.h:246 type Byte is new Interfaces.C.unsigned_char; -- 8 bits - - zconf.h:214 type UInt is new Interfaces.C.unsigned; -- 16 bits or more - - zconf.h:216 type Int is new Interfaces.C.int; type ULong is new Interfaces.C.unsigned_long; -- 32 bits or more - - zconf.h:217 subtype Chars_Ptr is Interfaces.C.Strings.chars_ptr; type ULong_Access is access ULong; type Int_Access is access Int; subtype Voidp is System.Address; -- zconf.h: 232 subtype Byte_Access is Voidp; Nul : constant Voidp : = System.Null_Address; - - end from zconf Z_NO_FLUSH : constant : = 8#0000#; -- zlib.h: 125 - - zlib.h:125 Z_PARTIAL_FLUSH : constant : = 1; -- zlib.h: 126 - - will be removed, use -- Z_SYNC_FLUSH instead -- zlib.h:126 Z_SYNC_FLUSH : constant : = 2; -- zlib.h: 127 - - zlib.h:127 Z_FULL_FLUSH : constant : = 3; -- zlib.h: 128 - - zlib.h:128 Z_FINISH : constant : = 4; -- zlib.h: 129 - - zlib.h:129 Z_OK : constant : = 8#0000#; -- zlib.h: 132 - - zlib.h:132 Z_STREAM_END : constant : = 1; -- zlib.h: 133 - - zlib.h:133 Z_NEED_DICT : constant : = 2; -- zlib.h: 134 - - zlib.h:134 Z_ERRNO : constant : = -1; -- zlib.h: 135 - - zlib.h:135 Z_STREAM_ERROR : constant : = -2; -- zlib.h: 136 - - zlib.h:136 Z_DATA_ERROR : constant : = -3; -- zlib.h: 137 - - zlib.h:137 Z_MEM_ERROR : constant : = -4; -- zlib.h: 138 - - zlib.h:138 Z_BUF_ERROR : constant : = -5; -- zlib.h: 139 - - zlib.h:139 Z_VERSION_ERROR : constant : = -6; -- zlib.h: 140 - - zlib.h:140 Z_NO_COMPRESSION : constant : = 8#0000#; -- zlib.h: 145 - - zlib.h:145 Z_BEST_SPEED : constant : = 1; -- zlib.h: 146 - - zlib.h:146 Z_BEST_COMPRESSION : constant : = 9; -- zlib.h: 147 - - zlib.h:147 Z_DEFAULT_COMPRESSION : constant : = -1; -- zlib.h: 148 - - zlib.h:148 Z_FILTERED : constant : = 1; -- zlib.h: 151 - - zlib.h:151 Z_HUFFMAN_ONLY : constant : = 2; -- zlib.h: 152 - - zlib.h:152 Z_DEFAULT_STRATEGY : constant : = 8#0000#; -- zlib.h: 153 - - zlib.h:153 Z_BINARY : constant : = 8#0000#; -- zlib.h: 156 - - zlib.h:156 Z_ASCII : constant : = 1; -- zlib.h: 157 - - zlib.h:157 Z_UNKNOWN : constant : = 2; -- zlib.h: 158 - - zlib.h:158 Z_DEFLATED : constant : = 8; -- zlib.h: 161 - - zlib.h:161 Z_NULL : constant : = 8#0000#; -- zlib.h: 164 - - for initializing zalloc, zfree, opaque -- zlib.h:164 type gzFile is new Voidp; -- zlib.h: 646 type Z_Stream is private; type Z_Streamp is access all Z_Stream; -- zlib.h: 89 type alloc_func is access function (Opaque : Voidp; Items : UInt; Size : UInt) return Voidp; -- zlib.h: 63 type free_func is access procedure(opaque : Voidp; address : Voidp); function zlibVersion return Chars_Ptr; function Deflate(strm : Z_Streamp; flush : Int) return Int; function DeflateEnd(strm : Z_Streamp) return Int; function Inflate(strm : Z_Streamp; flush : Int) return Int; function InflateEnd(strm : Z_Streamp) return Int; function deflateSetDictionary (strm : Z_Streamp; dictionary : Byte_Access; dictLength : UInt) return Int; function deflateCopy(dest : Z_Streamp; source : Z_Streamp) return Int; - - zlib.h:478 function deflateReset(strm : Z_Streamp) return Int; -- zlib.h: 495 function deflateParams (strm : Z_Streamp; level : Int; strategy : Int) return Int; -- zlib.h: 506 function inflateSetDictionary (strm : Z_Streamp; dictionary : Byte_Access; dictLength : UInt) return Int; -- zlib.h: 548 function inflateSync(strm : Z_Streamp) return Int; -- zlib.h: 565 function inflateReset(strm : Z_Streamp) return Int; -- zlib.h: 580 function compress (dest : Byte_Access; destLen : ULong_Access; source : Byte_Access; sourceLen : ULong) return Int; -- zlib.h: 601 function compress2 (dest : Byte_Access; destLen : ULong_Access; source : Byte_Access; sourceLen : ULong; level : Int) return Int; -- zlib.h: 615 function uncompress (dest : Byte_Access; destLen : ULong_Access; source : Byte_Access; sourceLen : ULong) return Int; function gzopen(path : Chars_Ptr; mode : Chars_Ptr) return gzFile; function gzdopen(fd : Int; mode : Chars_Ptr) return gzFile; function gzsetparams (file : gzFile; level : Int; strategy : Int) return Int; function gzread (file : gzFile; buf : Voidp; len : UInt) return Int; function gzwrite (file : in gzFile; buf : in Voidp; len : in UInt) return Int; function gzprintf(file : in gzFile; format : in Chars_Ptr) return Int; function gzputs(file : in gzFile; s : in Chars_Ptr) return Int; function gzgets (file : gzFile; buf : Chars_Ptr; len : Int) return Chars_Ptr; function gzputc(file : gzFile; char : Int) return Int; function gzgetc(file : gzFile) return Int; function gzflush(file : gzFile; flush : Int) return Int; function gzseek (file : gzFile; offset : Int; whence : Int) return Int; function gzrewind(file : gzFile) return Int; function gztell(file : gzFile) return Int; function gzeof(file : gzFile) return Int; function gzclose(file : gzFile) return Int; function gzerror(file : gzFile; errnum : Int_Access) return Chars_Ptr; function adler32 (adler : ULong; buf : Byte_Access; len : UInt) return ULong; function crc32 (crc : ULong; buf : Byte_Access; len : UInt) return ULong; function deflateInit (strm : Z_Streamp; level : Int; version : Chars_Ptr; stream_size : Int) return Int; function deflateInit2 (strm : Z_Streamp; level : Int; method : Int; windowBits : Int; memLevel : Int; strategy : Int; version : Chars_Ptr; stream_size : Int) return Int; function Deflate_Init (strm : Z_Streamp; level : Int; method : Int; windowBits : Int; memLevel : Int; strategy : Int) return Int; pragma Inline(Deflate_Init); function inflateInit (strm : Z_Streamp; version : Chars_Ptr; stream_size : Int) return Int; function inflateInit2 (strm : in Z_Streamp; windowBits : in Int; version : in Chars_Ptr; stream_size : in Int) return Int; function inflateBackInit (strm : in Z_Streamp; windowBits : in Int; window : in Byte_Access; version : in Chars_Ptr; stream_size : in Int) return Int; - - Size of window have to be 2 * *windowBits. function Inflate_Init(strm : Z_Streamp; windowBits : Int) return Int; pragma Inline(Inflate_Init); function zError(err : Int) return Chars_Ptr; function inflateSyncPoint(z : Z_Streamp) return Int; function get_crc_table return ULong_Access; - - Interface to the available fields of the z_stream structure. -- The application must update next_in and avail_in when avail_in has -- dropped to zero. It must update next_out and avail_out when avail_out -- has dropped to zero. The application must initialize zalloc, zfree and -- opaque before calling the init function. procedure Set_In (Strm : in out Z_Stream; Buffer : in Voidp; Size : in UInt); pragma Inline(Set_In); procedure Set_Out (Strm : in out Z_Stream; Buffer : in Voidp; Size : in UInt); pragma Inline(Set_Out); procedure Set_Mem_Func (Strm : in out Z_Stream; Opaque : in Voidp; Alloc : in alloc_func; Free : in free_func); pragma Inline(Set_Mem_Func); function Last_Error_Message(Strm : in Z_Stream) return String; pragma Inline(Last_Error_Message); function Avail_Out(Strm : in Z_Stream) return UInt; pragma Inline(Avail_Out); function Avail_In(Strm : in Z_Stream) return UInt; pragma Inline(Avail_In); function Total_In(Strm : in Z_Stream) return ULong; pragma Inline(Total_In); function Total_Out(Strm : in Z_Stream) return ULong; pragma Inline(Total_Out); function inflateCopy (dest : in Z_Streamp; Source : in Z_Streamp) return Int; function compressBound(Source_Len : in ULong) return ULong; function deflateBound (Strm : in Z_Streamp; Source_Len : in ULong) return ULong; function gzungetc(C : in Int; File : in gzFile) return Int; function zlibCompileFlags return ULong; private type Z_Stream is record -- zlib.h: 68 Next_In : Voidp : = Nul; -- next input byte Avail_In : UInt : = 0; -- number of bytes available at next_in Total_In : ULong : = 0; -- total nb of input bytes read so far Next_Out : Voidp : = Nul; -- next output byte should be put there Avail_Out : UInt : = 0; -- remaining free space at next_out Total_Out : ULong : = 0; -- total nb of bytes output so far msg : Chars_Ptr; -- last error message, NULL if no error state : Voidp; -- not visible by applications zalloc : alloc_func : = null; -- used to allocate the internal state zfree : free_func : = null; -- used to free the internal state opaque : Voidp; -- private data object passed to - - zalloc and zfree data_type : Int; -- best guess about the data type: - - ascii or binary adler : ULong; -- adler32 value of the uncompressed - - data reserved : ULong; -- reserved for future use end record; pragma Convention(C, Z_Stream); pragma Import(C, zlibVersion, "zlibVersion"); pragma Import(C, Deflate, "deflate"); pragma Import(C, DeflateEnd, "deflateEnd"); pragma Import(C, Inflate, "inflate"); pragma Import(C, InflateEnd, "inflateEnd"); pragma Import(C, deflateSetDictionary, "deflateSetDictionary"); pragma Import(C, deflateCopy, "deflateCopy"); pragma Import(C, deflateReset, "deflateReset"); pragma Import(C, deflateParams, "deflateParams"); pragma Import(C, inflateSetDictionary, "inflateSetDictionary"); pragma Import(C, inflateSync, "inflateSync"); pragma Import(C, inflateReset, "inflateReset"); pragma Import(C, compress, "compress"); pragma Import(C, compress2, "compress2"); pragma Import(C, uncompress, "uncompress"); pragma Import(C, gzopen, "gzopen"); pragma Import(C, gzdopen, "gzdopen"); pragma Import(C, gzsetparams, "gzsetparams"); pragma Import(C, gzread, "gzread"); pragma Import(C, gzwrite, "gzwrite"); pragma Import(C, gzprintf, "gzprintf"); pragma Import(C, gzputs, "gzputs"); pragma Import(C, gzgets, "gzgets"); pragma Import(C, gzputc, "gzputc"); pragma Import(C, gzgetc, "gzgetc"); pragma Import(C, gzflush, "gzflush"); pragma Import(C, gzseek, "gzseek"); pragma Import(C, gzrewind, "gzrewind"); pragma Import(C, gztell, "gztell"); pragma Import(C, gzeof, "gzeof"); pragma Import(C, gzclose, "gzclose"); pragma Import(C, gzerror, "gzerror"); pragma Import(C, adler32, "adler32"); pragma Import(C, crc32, "crc32"); pragma Import(C, deflateInit, "deflateInit_"); pragma Import(C, inflateInit, "inflateInit_"); pragma Import(C, deflateInit2, "deflateInit2_"); pragma Import(C, inflateInit2, "inflateInit2_"); pragma Import(C, zError, "zError"); pragma Import(C, inflateSyncPoint, "inflateSyncPoint"); pragma Import(C, get_crc_table, "get_crc_table"); - - since zlib 1.2.0: pragma Import(C, inflateCopy, "inflateCopy"); pragma Import(C, compressBound, "compressBound"); pragma Import(C, deflateBound, "deflateBound"); pragma Import(C, gzungetc, "gzungetc"); pragma Import(C, zlibCompileFlags, "zlibCompileFlags"); pragma Import(C, inflateBackInit, "inflateBackInit_"); - - I stopped binding the inflateBack routines, because realize that -- it does not support zlib and gzip headers for now, and have no -- symmetric deflateBack routines. -- ZLib - Ada is symmetric regarding deflate / inflate data transformation -- and has a similar generic callback interface for the -- deflate / inflate transformation based on the regular Deflate / Inflate -- routines. -- pragma Import(C, inflateBack, "inflateBack"); - - pragma Import(C, inflateBackEnd, "inflateBackEnd"); end ZLib.Thin;
reznikmm/matreshka
Ada
4,772
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.Text_Sender_Initials_Elements; package Matreshka.ODF_Text.Sender_Initials_Elements is type Text_Sender_Initials_Element_Node is new Matreshka.ODF_Text.Abstract_Text_Element_Node and ODF.DOM.Text_Sender_Initials_Elements.ODF_Text_Sender_Initials with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_Sender_Initials_Element_Node; overriding function Get_Local_Name (Self : not null access constant Text_Sender_Initials_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Text_Sender_Initials_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 Text_Sender_Initials_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 Text_Sender_Initials_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_Text.Sender_Initials_Elements;
Heziode/lsystem-editor
Ada
13,573
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.Strings; with Ada.Strings.Fixed; with GNAT.Regpat; with LSE.Model.L_System.Error.Invalid_Rule; with LSE.Model.L_System.Error.Missing_Angle; with LSE.Model.L_System.Error.Missing_Axiom; with LSE.Model.L_System.Error.Missing_Restore; with LSE.Model.L_System.Error.Missing_Rule; with LSE.Model.L_System.Error.Missing_Save; with LSE.Model.L_System.Error.Not_A_Angle; with LSE.Model.L_System.Error.Unexpected_Character; with LSE.Model.L_System.Factory; package body LSE.Model.L_System.Concrete_Builder is package L renames Ada.Characters.Latin_1; package Pat renames GNAT.Regpat; procedure Initialize (This : out Instance) is Axiom : LSE.Model.Grammar.Symbol_Utils.P_List.List; Rules : LSE.Model.L_System.Growth_Rule_Utils.P_List.List; Error : Error_Vector.Vector; begin This := Instance '(Axiom, 0.0, Rules, Error); end Initialize; function Make (This : out Instance; Item : String) return Boolean is use Ada.Strings; use Ada.Strings.Fixed; -------------------------------- -- Constants, types, packages -- -------------------------------- Make_Error : exception; --------------- -- Variables -- --------------- V : String_Vector.Vector; Current_First : Positive; First, Last : Positive := 1; Found : Boolean; Error : Boolean := False; Line : Positive := 1; Input : Unbounded_String := To_Unbounded_String (Trim (Item, Both)); begin This.Initialize; -- If Item is empty, no L-System found if Item = "" then This.Error.Append (Missing_Angle.Initialize); raise Missing_Angle.Error; end if; -- Check syntax Parse (To_String (Input), L.LF & "", V); for Str of V loop Current_First := Str'First; First := 1; Last := 1; loop Search_For_Pattern (Regexp_Global, Str (Current_First .. Str'Last), First, Last, Found); exit when not Found; Error := True; This.Error. Append (Unexpected_Character.Initialize ( Line => Line, Column => First, Value => To_Unbounded_String (Str (First .. Last)))); Current_First := Last + 1; end loop; Line := Line + 1; end loop; if Error then raise Unexpected_Character.Error; end if; -- Check Save/Restore declare Counter : Integer := 0; Line_S, Column_S : Positive := 1; begin Line := 1; Check_Save_Restore : for Str of V loop Current_First := Str'First; First := 1; Last := 1; for C of Str loop if C = '[' then if Counter = 0 then Line_S := Line; Column_S := Current_First; end if; Counter := Counter + 1; elsif C = ']' then Counter := Counter - 1; if Counter < 0 then exit Check_Save_Restore; end if; end if; Current_First := Current_First + 1; end loop; Line := Line + 1; end loop Check_Save_Restore; if Counter < 0 then This.Error.Append (Missing_Restore.Initialize (Line, Current_First)); raise Missing_Restore.Error; elsif Counter > 0 then This.Error.Append (Missing_Save.Initialize (Line_S, Column_S)); raise Missing_Save.Error; end if; end; -- Clean String (removing CR,LF and useless space) V.Clear; Parse (To_String (Input), L.LF & "", V); Concat (Input, " ", V); V.Clear; Parse (To_String (Input), L.CR & "", V); Concat (Input, " ", V); Trim (Input, Both); Current_First := 1; loop if Element (Input, Current_First) = ' ' then if Current_First + 1 <= Length (Input) and then Element (Input, Current_First + 1) = ' ' then Delete (Input, Current_First, Current_First + 1); end if; end if; exit when Current_First = Length (Input); Current_First := Current_First + 1; end loop; V.Clear; -- Make angle if not Make_Angle (This, Input, First, Last) then raise Make_Error; end if; -- Make axiom if not Make_Axiom (This, Input, First, Last) then raise Make_Error; end if; -- Make rules if not Make_Rule (This, Input, First, Last) then raise Make_Error; end if; return True; exception when Missing_Angle.Error | Unexpected_Character.Error | Missing_Save.Error | Missing_Restore.Error | Make_Error => return False; end Make; function Get_Product (This : Instance; Turtle : LSE.Model.IO.Turtle_Utils.Holder) return L_System.Instance is LS : L_System.Instance; begin Initialize (LS, This.Axiom, This.Angle, This.Rules, Turtle); return LS; end Get_Product; procedure Get_Product (This : Instance; LS : out L_System.Instance; Turtle : LSE.Model.IO.Turtle_Utils.Holder) is begin Initialize (LS, This.Axiom, This.Angle, This.Rules, Turtle); end Get_Product; function Get_Error (This : Instance) return String is Str : Unbounded_String; begin for Error of This.Error loop Str := Str & Error.Get_Error & L.LF; end loop; return To_String (Str); end Get_Error; procedure Parse (Item : String; Separator : String; Vec : in out String_Vector.Vector) is use Ada.Strings.Fixed; i : constant Integer := Index (Item, Separator); begin if Item'Length > 0 then if i < Item'First then Vec.Append (Item); else Vec.Append (Item (Item'First .. i - 1)); Parse (To_String ( To_Unbounded_String (Item (i + 1 .. Item'Last))), L.LF & "", Vec); end if; end if; end Parse; procedure Concat (Item : out Unbounded_String; Separator : String; Vec : in out String_Vector.Vector) is Result : Unbounded_String := To_Unbounded_String (""); begin for Str of Vec loop Result := Result & Separator & To_Unbounded_String (Str); end loop; Item := Result; end Concat; procedure Search_For_Pattern (Expression, Search_In : String; First, Last : out Positive; Found : out Boolean) is Compiled_Expression : constant Pat.Pattern_Matcher := Pat.Compile (Expression); Result : Pat.Match_Array (0 .. 1); begin Pat.Match (Compiled_Expression, Search_In, Result); Found := not Pat."="(Result (1), Pat.No_Match); if Found then First := Result (1).First; Last := Result (1).Last; end if; end Search_For_Pattern; function Get_Next_Token (Item : out Unbounded_String; Last_Index : out Positive; First, Last : Positive) return Boolean is use Ada.Strings; begin Delete (Item, First, Last); Trim (Item, Left); if Item = "" then return False; end if; Last_Index := Length (Item); return True; end Get_Next_Token; function Make_Angle (This : out Instance; Input : Unbounded_String; First, Last : in out Positive) return Boolean is Last_Index : Positive; Found : Boolean; begin Last_Index := To_String (Input)'Last; Search_For_Pattern (Regexp_Angle, To_String (Input) (1 .. Last_Index), First, Last, Found); if not Found then This.Error.Append (Missing_Angle.Initialize); raise Missing_Angle.Error; return False; end if; if not Is_Angle (To_String (Input) (First .. Last)) then This.Error.Append (Not_A_Angle.Initialize); raise Not_A_Angle.Error; end if; This.Angle := Factory.Make_Angle (To_String (Input) (First .. Last)); return True; exception when Missing_Angle.Error | Not_A_Angle.Error => return False; end Make_Angle; function Make_Axiom (This : out Instance; Input : out Unbounded_String; First, Last : in out Positive) return Boolean is Last_Index : Positive; Found : Boolean; begin if not Get_Next_Token (Input, Last_Index, First, Last) then This.Error.Append (Missing_Axiom.Initialize); raise Missing_Axiom.Error; end if; Search_For_Pattern (Regexp_Axiom, To_String (Input) (1 .. Last_Index), First, Last, Found); if not Found then This.Error.Append (Missing_Axiom.Initialize); raise Missing_Axiom.Error; end if; This.Axiom := Factory.Make_Axiom (To_String (Input) (1 + First - 1 .. 1 + Last - 1)); return True; exception when Missing_Axiom.Error => return False; end Make_Axiom; function Make_Rule (This : out Instance; Input : out Unbounded_String; First, Last : in out Positive) return Boolean is use Ada.Strings; use Ada.Strings.Fixed; Last_Index : Positive; Found : Boolean := False; begin loop -- If it is the end of Input if not Get_Next_Token (Input, Last_Index, First, Last) then exit; end if; Search_For_Pattern (Regexp_Rule, To_String ( Input) (1 .. Last_Index), First, Last, Found); exit when not Found; declare Result : String (1 + First - 1 .. 1 + Last - 1); begin Result := To_String (Input) (1 + First - 1 .. 1 + Last - 1); This.Rules.Append (Factory.Make_Rule (Result (Result'First), Trim (Result (Result'First + 1 .. Result'Last), Both))); end; end loop; if not Found then if LSE.Model.L_System.Growth_Rule_Utils.P_List.Length (This.Rules) = 0 then This.Error.Append (Missing_Rule.Initialize); raise Missing_Rule.Error; else declare Result_Error : constant String := To_String (Input); First_I : constant Positive := Result_Error'First; Last_I : constant Positive := (if First_I + Invalid_Rule.Max_String_Length <= Result_Error'Last then First_I + Invalid_Rule.Max_String_Length else Result_Error'Last); begin This.Error.Append (Invalid_Rule.Initialize ( Result_Error (First_I .. Last_I))); end; raise Invalid_Rule.Error; end if; end if; return True; exception when Missing_Rule.Error | Invalid_Rule.Error => return False; end Make_Rule; end LSE.Model.L_System.Concrete_Builder;
reznikmm/matreshka
Ada
3,987
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.Table_Execute_Attributes; package Matreshka.ODF_Table.Execute_Attributes is type Table_Execute_Attribute_Node is new Matreshka.ODF_Table.Abstract_Table_Attribute_Node and ODF.DOM.Table_Execute_Attributes.ODF_Table_Execute_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Table_Execute_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Table_Execute_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Table.Execute_Attributes;
OneWingedShark/Byron
Ada
488
adb
Pragma Ada_2012; Pragma Assertion_Policy( Check ); Procedure Byron.Generics.Iterator(Input : Vector_Package.Vector) is Subtype Iteration_Range is Vector_Package.Index_Type range Vector_Package.First_Index(Input)..Vector_Package.Last_Index(Input); Begin For Index in Iteration_Range loop declare Item : constant Vector_Package.Element_Type := Vector_Package.Element(Input, Index); begin Operation( Item ); end; End loop; End Byron.Generics.Iterator;
stcarrez/ada-awa
Ada
2,364
ads
----------------------------------------------------------------------- -- awa-index_arrays -- Static index arrays -- Copyright (C) 2015 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 Index_Type is range <>; type Element_Type (<>) is private; with function "=" (Left, Right : in Element_Type) return Boolean is <>; with function "<" (Left, Right : in Element_Type) return Boolean is <>; with function "&" (Left : in String; Right : in Element_Type) return String is <>; package AWA.Index_Arrays is -- This package must be instantiated for each definition. -- It allocates a unique <tt>Index_Type</tt> value for each definition. generic Name : Element_Type; package Definition is function Kind return Index_Type; pragma Inline_Always (Kind); end Definition; type Element_Type_Access is access constant Element_Type; -- Exception raised if a name is not found. Not_Found : exception; -- Identifies an invalid index. Invalid_Index : constant Index_Type; -- Find the runtime index given the name. -- Raises Not_Found exception if the name is not recognized. function Find (Name : in Element_Type) return Index_Type; -- Get the element associated with the index. function Get_Element (Index : in Index_Type) return Element_Type_Access; -- Check if the index is a valid index. function Is_Valid (Index : in Index_Type) return Boolean; -- Get the last valid index. function Get_Last return Index_Type; private Invalid_Index : constant Index_Type := Index_Type'First; pragma Inline (Is_Valid); pragma Inline (Get_Last); end AWA.Index_Arrays;
tum-ei-rcs/StratoX
Ada
24,912
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of STMicroelectronics nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with System; use System; pragma Warnings (Off, "* is an internal GNAT unit"); with System.BB.Parameters; pragma Warnings (On, "* is an internal GNAT unit"); with STM32_SVD.RCC; use STM32_SVD.RCC; package body STM32.Device with SPARK_Mode => Off is HSE_VALUE : constant Word := Word (System.BB.Parameters.HSE_Clock); -- External oscillator in Hz HSI_VALUE : constant := 16_000_000; -- Internal oscillator in Hz HPRE_Presc_Table : constant array (UInt4) of Word := (1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 8, 16, 64, 128, 256, 512); PPRE_Presc_Table : constant array (UInt3) of Word := (1, 1, 1, 1, 2, 4, 8, 16); ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : aliased in out Internal_GPIO_Port) is begin if This'Address = GPIOA_Base then RCC_Periph.AHB1ENR.GPIOAEN := True; elsif This'Address = GPIOB_Base then RCC_Periph.AHB1ENR.GPIOBEN := True; elsif This'Address = GPIOC_Base then RCC_Periph.AHB1ENR.GPIOCEN := True; elsif This'Address = GPIOD_Base then RCC_Periph.AHB1ENR.GPIODEN := True; elsif This'Address = GPIOE_Base then RCC_Periph.AHB1ENR.GPIOEEN := True; elsif This'Address = GPIOF_Base then RCC_Periph.AHB1ENR.GPIOFEN := True; elsif This'Address = GPIOG_Base then RCC_Periph.AHB1ENR.GPIOGEN := True; elsif This'Address = GPIOH_Base then RCC_Periph.AHB1ENR.GPIOHEN := True; elsif This'Address = GPIOI_Base then RCC_Periph.AHB1ENR.GPIOIEN := True; elsif This'Address = GPIOJ_Base then RCC_Periph.AHB1ENR.GPIOJEN := True; elsif This'Address = GPIOK_Base then RCC_Periph.AHB1ENR.GPIOKEN := True; else raise Unknown_Device; end if; end Enable_Clock; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (Point : GPIO_Point) is begin Enable_Clock (Point.Periph.all); end Enable_Clock; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (Points : GPIO_Points) is begin for Point of Points loop Enable_Clock (Point.Periph.all); end loop; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : aliased in out Internal_GPIO_Port) is begin if This'Address = GPIOA_Base then RCC_Periph.AHB1RSTR.GPIOARST := True; RCC_Periph.AHB1RSTR.GPIOARST := False; elsif This'Address = GPIOB_Base then RCC_Periph.AHB1RSTR.GPIOBRST := True; RCC_Periph.AHB1RSTR.GPIOBRST := False; elsif This'Address = GPIOC_Base then RCC_Periph.AHB1RSTR.GPIOCRST := True; RCC_Periph.AHB1RSTR.GPIOCRST := False; elsif This'Address = GPIOD_Base then RCC_Periph.AHB1RSTR.GPIODRST := True; RCC_Periph.AHB1RSTR.GPIODRST := False; elsif This'Address = GPIOE_Base then RCC_Periph.AHB1RSTR.GPIOERST := True; RCC_Periph.AHB1RSTR.GPIOERST := False; elsif This'Address = GPIOF_Base then RCC_Periph.AHB1RSTR.GPIOFRST := True; RCC_Periph.AHB1RSTR.GPIOFRST := False; elsif This'Address = GPIOG_Base then RCC_Periph.AHB1RSTR.GPIOGRST := True; RCC_Periph.AHB1RSTR.GPIOGRST := False; elsif This'Address = GPIOH_Base then RCC_Periph.AHB1RSTR.GPIOHRST := True; RCC_Periph.AHB1RSTR.GPIOHRST := False; elsif This'Address = GPIOI_Base then RCC_Periph.AHB1RSTR.GPIOIRST := True; RCC_Periph.AHB1RSTR.GPIOIRST := False; elsif This'Address = GPIOJ_Base then RCC_Periph.AHB1RSTR.GPIOJRST := True; RCC_Periph.AHB1RSTR.GPIOJRST := False; elsif This'Address = GPIOK_Base then RCC_Periph.AHB1RSTR.GPIOKRST := True; RCC_Periph.AHB1RSTR.GPIOKRST := False; else raise Unknown_Device; end if; end Reset; ----------- -- Reset -- ----------- procedure Reset (Point : GPIO_Point) is begin Reset (Point.Periph.all); end Reset; ----------- -- Reset -- ----------- procedure Reset (Points : GPIO_Points) is Do_Reset : Boolean; begin for J in Points'Range loop Do_Reset := True; for K in Points'First .. J - 1 loop if Points (K).Periph = Points (J).Periph then Do_Reset := False; exit; end if; end loop; if Do_Reset then Reset (Points (J).Periph.all); end if; end loop; end Reset; --------------------- -- As_GPIO_Port_Id -- --------------------- function As_GPIO_Port_Id (Port : Internal_GPIO_Port) return GPIO_Port_Id is begin -- TODO: rather ugly to have this board-specific range here if Port'Address = GPIOA_Base then return GPIO_Port_A; elsif Port'Address = GPIOB_Base then return GPIO_Port_B; elsif Port'Address = GPIOC_Base then return GPIO_Port_C; elsif Port'Address = GPIOD_Base then return GPIO_Port_D; elsif Port'Address = GPIOE_Base then return GPIO_Port_E; elsif Port'Address = GPIOF_Base then return GPIO_Port_F; elsif Port'Address = GPIOG_Base then return GPIO_Port_G; elsif Port'Address = GPIOH_Base then return GPIO_Port_H; elsif Port'Address = GPIOI_Base then return GPIO_Port_I; elsif Port'Address = GPIOJ_Base then return GPIO_Port_J; elsif Port'Address = GPIOK_Base then return GPIO_Port_K; else raise Program_Error; end if; end As_GPIO_Port_Id; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : aliased in out Analog_To_Digital_Converter) is begin if This'Address = ADC1_Base then RCC_Periph.APB2ENR.ADC1EN := True; elsif This'Address = ADC2_Base then RCC_Periph.APB2ENR.ADC2EN := True; elsif This'Address = ADC3_Base then RCC_Periph.APB2ENR.ADC3EN := True; else raise Unknown_Device; end if; end Enable_Clock; ------------------------- -- Reset_All_ADC_Units -- ------------------------- procedure Reset_All_ADC_Units is begin RCC_Periph.APB2RSTR.ADCRST := True; RCC_Periph.APB2RSTR.ADCRST := False; end Reset_All_ADC_Units; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : aliased in out Digital_To_Analog_Converter) is pragma Unreferenced (This); begin RCC_Periph.APB1ENR.DACEN := True; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : aliased in out Digital_To_Analog_Converter) is pragma Unreferenced (This); begin RCC_Periph.APB1RSTR.DACRST := True; RCC_Periph.APB1RSTR.DACRST := False; end Reset; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : aliased in out USART) is begin if This'Address = USART1_Base then RCC_Periph.APB2ENR.USART1EN := True; elsif This'Address = USART2_Base then RCC_Periph.APB1ENR.USART2EN := True; elsif This'Address = USART3_Base then RCC_Periph.APB1ENR.USART3EN := True; elsif This'Address = UART4_Base then RCC_Periph.APB1ENR.UART4EN := True; elsif This'Address = UART5_Base then RCC_Periph.APB1ENR.UART5EN := True; elsif This'Address = USART6_Base then RCC_Periph.APB2ENR.USART6EN := True; elsif This'Address = UART7_Base then RCC_Periph.APB1ENR.UART7ENR := True; elsif This'Address = UART8_Base then RCC_Periph.APB1ENR.UART8ENR := True; else raise Unknown_Device; end if; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : aliased in out USART) is begin if This'Address = USART1_Base then RCC_Periph.APB2RSTR.USART1RST := True; RCC_Periph.APB2RSTR.USART1RST := False; elsif This'Address = USART2_Base then RCC_Periph.APB1RSTR.UART2RST := True; RCC_Periph.APB1RSTR.UART2RST := False; elsif This'Address = USART3_Base then RCC_Periph.APB1RSTR.UART3RST := True; RCC_Periph.APB1RSTR.UART3RST := False; elsif This'Address = UART4_Base then RCC_Periph.APB1RSTR.UART4RST := True; RCC_Periph.APB1RSTR.UART4RST := False; elsif This'Address = UART5_Base then RCC_Periph.APB1RSTR.UART5RST := True; RCC_Periph.APB1RSTR.UART5RST := False; elsif This'Address = USART6_Base then RCC_Periph.APB2RSTR.USART6RST := True; RCC_Periph.APB2RSTR.USART6RST := False; elsif This'Address = UART7_Base then RCC_Periph.APB1RSTR.UART7RST := True; RCC_Periph.APB1RSTR.UART7RST := False; elsif This'Address = UART8_Base then RCC_Periph.APB1RSTR.UART8RST := True; RCC_Periph.APB1RSTR.UART8RST := False; else raise Unknown_Device; end if; end Reset; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : aliased in out DMA_Controller) is begin if This'Address = STM32_SVD.DMA1_Base then RCC_Periph.AHB1ENR.DMA1EN := True; elsif This'Address = STM32_SVD.DMA2_Base then RCC_Periph.AHB1ENR.DMA2EN := True; else raise Unknown_Device; end if; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : aliased in out DMA_Controller) is begin if This'Address = STM32_SVD.DMA1_Base then RCC_Periph.AHB1RSTR.DMA1RST := True; RCC_Periph.AHB1RSTR.DMA1RST := False; elsif This'Address = STM32_SVD.DMA2_Base then RCC_Periph.AHB1RSTR.DMA2RST := True; RCC_Periph.AHB1RSTR.DMA2RST := False; else raise Unknown_Device; end if; end Reset; ---------------- -- As_Port_Id -- ---------------- function As_Port_Id (Port : I2C_Port) return I2C_Port_Id is begin if Port.Periph.all'Address = I2C1_Base then return I2C_Id_1; elsif Port.Periph.all'Address = I2C2_Base then return I2C_Id_2; elsif Port.Periph.all'Address = I2C3_Base then return I2C_Id_3; else raise Unknown_Device; end if; end As_Port_Id; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : I2C_Port) is begin Enable_Clock (As_Port_Id (This)); end Enable_Clock; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : I2C_Port_Id) is begin case This is when I2C_Id_1 => RCC_Periph.APB1ENR.I2C1EN := True; when I2C_Id_2 => RCC_Periph.APB1ENR.I2C2EN := True; when I2C_Id_3 => RCC_Periph.APB1ENR.I2C3EN := True; end case; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : I2C_Port) is begin Reset (As_Port_Id (This)); end Reset; ----------- -- Reset -- ----------- procedure Reset (This : I2C_Port_Id) is begin case This is when I2C_Id_1 => RCC_Periph.APB1RSTR.I2C1RST := True; RCC_Periph.APB1RSTR.I2C1RST := False; when I2C_Id_2 => RCC_Periph.APB1RSTR.I2C2RST := True; RCC_Periph.APB1RSTR.I2C2RST := False; when I2C_Id_3 => RCC_Periph.APB1RSTR.I2C3RST := True; RCC_Periph.APB1RSTR.I2C3RST := False; end case; end Reset; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : SPI_Port) is begin if This.Periph.all'Address = SPI1_Base then RCC_Periph.APB2ENR.SPI1EN := True; elsif This.Periph.all'Address = SPI2_Base then RCC_Periph.APB1ENR.SPI2EN := True; elsif This.Periph.all'Address = SPI3_Base then RCC_Periph.APB1ENR.SPI3EN := True; elsif This.Periph.all'Address = SPI4_Base then RCC_Periph.APB2ENR.SPI4ENR := True; elsif This.Periph.all'Address = SPI5_Base then RCC_Periph.APB2ENR.SPI5ENR := True; elsif This.Periph.all'Address = SPI6_Base then RCC_Periph.APB2ENR.SPI6ENR := True; else raise Unknown_Device; end if; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : SPI_Port) is begin if This.Periph.all'Address = SPI1_Base then RCC_Periph.APB2RSTR.SPI1RST := True; RCC_Periph.APB2RSTR.SPI1RST := False; elsif This.Periph.all'Address = SPI2_Base then RCC_Periph.APB1RSTR.SPI2RST := True; RCC_Periph.APB1RSTR.SPI2RST := False; elsif This.Periph.all'Address = SPI3_Base then RCC_Periph.APB1RSTR.SPI3RST := True; RCC_Periph.APB1RSTR.SPI3RST := False; elsif This.Periph.all'Address = SPI4_Base then RCC_Periph.APB2RSTR.SPI4RST := True; RCC_Periph.APB2RSTR.SPI4RST := False; elsif This.Periph.all'Address = SPI5_Base then RCC_Periph.APB2RSTR.SPI5RST := True; RCC_Periph.APB2RSTR.SPI5RST := False; elsif This.Periph.all'Address = SPI6_Base then RCC_Periph.APB2RSTR.SPI6RST := True; RCC_Periph.APB2RSTR.SPI6RST := False; else raise Unknown_Device; end if; end Reset; ------------------ -- Enable_Clock -- ------------------ procedure Enable_Clock (This : in out Timer) is begin if This'Address = TIM1_Base then RCC_Periph.APB2ENR.TIM1EN := True; elsif This'Address = TIM2_Base then RCC_Periph.APB1ENR.TIM2EN := True; elsif This'Address = TIM3_Base then RCC_Periph.APB1ENR.TIM3EN := True; elsif This'Address = TIM4_Base then RCC_Periph.APB1ENR.TIM4EN := True; elsif This'Address = TIM5_Base then RCC_Periph.APB1ENR.TIM5EN := True; elsif This'Address = TIM6_Base then RCC_Periph.APB1ENR.TIM6EN := True; elsif This'Address = TIM7_Base then RCC_Periph.APB1ENR.TIM7EN := True; elsif This'Address = TIM8_Base then RCC_Periph.APB2ENR.TIM8EN := True; elsif This'Address = TIM9_Base then RCC_Periph.APB2ENR.TIM9EN := True; elsif This'Address = TIM10_Base then RCC_Periph.APB2ENR.TIM10EN := True; elsif This'Address = TIM11_Base then RCC_Periph.APB2ENR.TIM11EN := True; elsif This'Address = TIM12_Base then RCC_Periph.APB1ENR.TIM12EN := True; elsif This'Address = TIM13_Base then RCC_Periph.APB1ENR.TIM13EN := True; elsif This'Address = TIM14_Base then RCC_Periph.APB1ENR.TIM14EN := True; else raise Unknown_Device; end if; end Enable_Clock; ----------- -- Reset -- ----------- procedure Reset (This : in out Timer) is begin if This'Address = TIM1_Base then RCC_Periph.APB2RSTR.TIM1RST := True; RCC_Periph.APB2RSTR.TIM1RST := False; elsif This'Address = TIM2_Base then RCC_Periph.APB1RSTR.TIM2RST := True; RCC_Periph.APB1RSTR.TIM2RST := False; elsif This'Address = TIM3_Base then RCC_Periph.APB1RSTR.TIM3RST := True; RCC_Periph.APB1RSTR.TIM3RST := False; elsif This'Address = TIM4_Base then RCC_Periph.APB1RSTR.TIM4RST := True; RCC_Periph.APB1RSTR.TIM4RST := False; elsif This'Address = TIM5_Base then RCC_Periph.APB1RSTR.TIM5RST := True; RCC_Periph.APB1RSTR.TIM5RST := False; elsif This'Address = TIM6_Base then RCC_Periph.APB1RSTR.TIM6RST := True; RCC_Periph.APB1RSTR.TIM6RST := False; elsif This'Address = TIM7_Base then RCC_Periph.APB1RSTR.TIM7RST := True; RCC_Periph.APB1RSTR.TIM7RST := False; elsif This'Address = TIM8_Base then RCC_Periph.APB2RSTR.TIM8RST := True; RCC_Periph.APB2RSTR.TIM8RST := False; elsif This'Address = TIM9_Base then RCC_Periph.APB2RSTR.TIM9RST := True; RCC_Periph.APB2RSTR.TIM9RST := False; elsif This'Address = TIM10_Base then RCC_Periph.APB2RSTR.TIM10RST := True; RCC_Periph.APB2RSTR.TIM10RST := False; elsif This'Address = TIM11_Base then RCC_Periph.APB2RSTR.TIM11RST := True; RCC_Periph.APB2RSTR.TIM11RST := False; elsif This'Address = TIM12_Base then RCC_Periph.APB1RSTR.TIM12RST := True; RCC_Periph.APB1RSTR.TIM12RST := False; elsif This'Address = TIM13_Base then RCC_Periph.APB1RSTR.TIM13RST := True; RCC_Periph.APB1RSTR.TIM13RST := False; elsif This'Address = TIM14_Base then RCC_Periph.APB1RSTR.TIM14RST := True; RCC_Periph.APB1RSTR.TIM14RST := False; else raise Unknown_Device; end if; end Reset; ------------------------------ -- System_Clock_Frequencies -- ------------------------------ function System_Clock_Frequencies return RCC_System_Clocks is Source : constant CFGR_SWS_Field := RCC_Periph.CFGR.SWS; Result : RCC_System_Clocks; begin case Source.Val is when 0 => -- HSI as source Result.SYSCLK := HSI_VALUE; when 1 => -- HSE as source Result.SYSCLK := HSE_VALUE; when 2 => -- PLL as source declare HSE_Source : constant Boolean := RCC_Periph.PLLCFGR.PLLSRC; Pllm : constant Word := Word (RCC_Periph.PLLCFGR.PLLM.Val); Plln : constant Word := Word (RCC_Periph.PLLCFGR.PLLN.Val); Pllp : constant Word := (Word (RCC_Periph.PLLCFGR.PLLP.Val) + 1) * 2; Pllvco : Word; begin if not HSE_Source then Pllvco := (HSI_VALUE / Pllm) * Plln; else Pllvco := (HSE_VALUE / Pllm) * Plln; end if; Result.SYSCLK := Pllvco / Pllp; end; when others => Result.SYSCLK := HSI_VALUE; end case; declare HPRE : constant UInt4 := RCC_Periph.CFGR.HPRE; PPRE1 : constant UInt3 := RCC_Periph.CFGR.PPRE.Arr (1); PPRE2 : constant UInt3 := RCC_Periph.CFGR.PPRE.Arr (2); begin Result.HCLK := Result.SYSCLK / HPRE_Presc_Table (HPRE); Result.PCLK1 := Result.HCLK / PPRE_Presc_Table (PPRE1); Result.PCLK2 := Result.HCLK / PPRE_Presc_Table (PPRE2); -- Timer clocks -- See Dedicated clock cfg register documentation. if not RCC_Periph.DCKCFGR.TIMPRE then -- Mode 0: -- If the APB prescaler (PPRE1, PPRE2 in the RCC_CFGR register) -- is configured to a division factor of 1, TIMxCLK = PCLKx. -- Otherwise, the timer clock frequencies are set to twice to the -- frequency of the APB domain to which the timers are connected : -- TIMxCLK = 2xPCLKx. if PPRE_Presc_Table (PPRE1) = 1 then Result.TIMCLK1 := Result.PCLK1; else Result.TIMCLK1 := Result.PCLK1 * 2; end if; if PPRE_Presc_Table (PPRE2) = 1 then Result.TIMCLK2 := Result.PCLK2; else Result.TIMCLK2 := Result.PCLK2 * 2; end if; else -- Mpde 1: -- If the APB prescaler (PPRE1, PPRE2 in the RCC_CFGR register) is -- configured to a division factor of 1, 2 or 4, TIMxCLK = HCLK. -- Otherwise, the timer clock frequencies are set to four times -- to the frequency of the APB domain to which the timers are -- connected : TIMxCLK = 4xPCLKx. if PPRE_Presc_Table (PPRE1) in 1 .. 4 then Result.TIMCLK1 := Result.HCLK; else Result.TIMCLK1 := Result.PCLK1 * 4; end if; if PPRE_Presc_Table (PPRE2) in 1 .. 4 then Result.TIMCLK2 := Result.HCLK; else Result.TIMCLK2 := Result.PCLK1 * 4; end if; end if; end; return Result; end System_Clock_Frequencies; ------------------ -- PLLSAI_Ready -- ------------------ function PLLSAI_Ready return Boolean is begin -- SHould be PLLSAIRDY, but not binded by the SVD file -- PLLSAIRDY: bit 29 return (RCC_Periph.CR.Reserved_28_31 and 2) /= 0; end PLLSAI_Ready; ------------------- -- Enable_PLLSAI -- -------------------; procedure Enable_PLLSAI is begin -- Should be PLLSAION, but not binded by the SVD file -- PLLSAION: bit 28 RCC_Periph.CR.Reserved_28_31 := RCC_Periph.CR.Reserved_28_31 or 1; -- Wait for PLLSAI activation loop exit when PLLSAI_Ready; end loop; end Enable_PLLSAI; ------------------- -- Enable_PLLSAI -- -------------------; procedure Disable_PLLSAI is begin -- Should be PLLSAION, but not binded by the SVD file -- PLLSAION: bit 28 RCC_Periph.CR.Reserved_28_31 := RCC_Periph.CR.Reserved_28_31 and not 1; end Disable_PLLSAI; ------------------------ -- Set_PLLSAI_Factors -- ------------------------ procedure Set_PLLSAI_Factors (LCD : UInt3; VCO : UInt9; DivR : PLLSAI_DivR) is PLLSAICFGR : PLLSAICFGR_Register; begin PLLSAICFGR.PLLSAIR := LCD; PLLSAICFGR.PLLSAIN := VCO; RCC_Periph.PLLSAICFGR := PLLSAICFGR; -- The exact bit name is device-specific RCC_Periph.DCKCFGR.PLLSAIDIVR := UInt2 (DivR); end Set_PLLSAI_Factors; ----------------------- -- Enable_DCMI_Clock -- ----------------------- procedure Enable_DCMI_Clock is begin RCC_Periph.AHB2ENR.DCMIEN := True; end Enable_DCMI_Clock; ---------------- -- Reset_DCMI -- ---------------- procedure Reset_DCMI is begin RCC_Periph.AHB2RSTR.DCMIRST := True; RCC_Periph.AHB2RSTR.DCMIRST := False; end Reset_DCMI; end STM32.Device;
zhmu/ananas
Ada
61,028
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- G E N _ I L . G E N . G E N _ E N T I T I E S -- -- -- -- B o d y -- -- -- -- Copyright (C) 2020-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ procedure Gen_IL.Gen.Gen_Entities is procedure Ab -- Short for "Abstract" (T : Abstract_Entity; Parent : Abstract_Type; Fields : Field_Sequence := No_Fields) renames Create_Abstract_Entity_Type; procedure Cc -- Short for "ConCrete" (T : Concrete_Entity; Parent : Abstract_Type; Fields : Field_Sequence := No_Fields) renames Create_Concrete_Entity_Type; -- No Sy (Syntactic) fields in entities function Sm -- Short for "Semantic" (Field : Field_Enum; Field_Type : Type_Enum; Type_Only : Type_Only_Enum := No_Type_Only; Pre, Pre_Get, Pre_Set : String := "") return Field_Desc renames Create_Semantic_Field; procedure Union (T : Abstract_Entity; Children : Type_Array) renames Create_Entity_Union_Type; begin -- Gen_IL.Gen.Gen_Entities pragma Style_Checks ("M200"); Create_Root_Entity_Type (Entity_Kind, (Sm (Ekind, Entity_Kind_Type), Sm (Basic_Convention, Convention_Id), Sm (Address_Taken, Flag), Sm (Associated_Entity, Node_Id), Sm (Can_Never_Be_Null, Flag), Sm (Checks_May_Be_Suppressed, Flag), Sm (Debug_Info_Off, Flag), Sm (Default_Expressions_Processed, Flag), Sm (Delay_Cleanups, Flag), Sm (Delay_Subprogram_Descriptors, Flag), Sm (Depends_On_Private, Flag), Sm (Disable_Controlled, Flag, Base_Type_Only), Sm (Discard_Names, Flag), Sm (First_Rep_Item, Node_Id), Sm (Freeze_Node, Node_Id), Sm (From_Limited_With, Flag), Sm (Has_Aliased_Components, Flag, Impl_Base_Type_Only), Sm (Has_Alignment_Clause, Flag), Sm (Has_All_Calls_Remote, Flag), Sm (Has_Atomic_Components, Flag, Impl_Base_Type_Only), Sm (Has_Biased_Representation, Flag), Sm (Has_Completion, Flag), Sm (Has_Contiguous_Rep, Flag), Sm (Has_Controlled_Component, Flag, Base_Type_Only), Sm (Has_Controlling_Result, Flag), Sm (Has_Convention_Pragma, Flag), Sm (Has_Default_Aspect, Flag, Base_Type_Only), Sm (Has_Delayed_Aspects, Flag), Sm (Has_Delayed_Freeze, Flag), Sm (Has_Delayed_Rep_Aspects, Flag), Sm (Has_Exit, Flag), Sm (Has_Forward_Instantiation, Flag), Sm (Has_Fully_Qualified_Name, Flag), Sm (Has_Gigi_Rep_Item, Flag), Sm (Has_Homonym, Flag), Sm (Has_Implicit_Dereference, Flag), Sm (Has_Independent_Components, Flag, Impl_Base_Type_Only), Sm (Has_Master_Entity, Flag), Sm (Has_Nested_Block_With_Handler, Flag), Sm (Has_Non_Standard_Rep, Flag, Impl_Base_Type_Only), Sm (Has_Per_Object_Constraint, Flag), Sm (Has_Pragma_Elaborate_Body, Flag), Sm (Has_Pragma_Inline, Flag), Sm (Has_Pragma_Inline_Always, Flag), Sm (Has_Pragma_No_Inline, Flag), Sm (Has_Pragma_Preelab_Init, Flag), Sm (Has_Pragma_Pure, Flag), Sm (Has_Pragma_Pure_Function, Flag), Sm (Has_Pragma_Thread_Local_Storage, Flag), Sm (Has_Pragma_Unmodified, Flag), Sm (Has_Pragma_Unreferenced, Flag), Sm (Has_Pragma_Unused, Flag), Sm (Has_Private_Ancestor, Flag), Sm (Has_Private_Declaration, Flag), Sm (Has_Protected, Flag, Base_Type_Only), Sm (Has_Qualified_Name, Flag), Sm (Has_Size_Clause, Flag), Sm (Has_Stream_Size_Clause, Flag), Sm (Has_Task, Flag, Base_Type_Only), Sm (Has_Timing_Event, Flag, Base_Type_Only), Sm (Has_Thunks, Flag), Sm (Has_Unchecked_Union, Flag, Base_Type_Only), Sm (Has_Volatile_Components, Flag, Impl_Base_Type_Only), Sm (Has_Xref_Entry, Flag), Sm (Has_Yield_Aspect, Flag), Sm (Homonym, Node_Id), Sm (In_Package_Body, Flag), Sm (In_Private_Part, Flag), Sm (In_Use, Flag), Sm (Is_Ada_2005_Only, Flag), Sm (Is_Ada_2012_Only, Flag), Sm (Is_Ada_2022_Only, Flag), Sm (Is_Aliased, Flag), Sm (Is_Atomic, Flag), Sm (Is_Bit_Packed_Array, Flag, Impl_Base_Type_Only), Sm (Is_Character_Type, Flag), Sm (Is_Checked_Ghost_Entity, Flag), Sm (Is_Child_Unit, Flag), Sm (Is_Class_Wide_Wrapper, Flag), Sm (Is_Class_Wide_Equivalent_Type, Flag), Sm (Is_Compilation_Unit, Flag), Sm (Is_Concurrent_Record_Type, Flag), Sm (Is_Constr_Subt_For_U_Nominal, Flag), Sm (Is_Constr_Subt_For_UN_Aliased, Flag), Sm (Is_Constrained, Flag), Sm (Is_Constructor, Flag), Sm (Is_Controlled_Active, Flag, Base_Type_Only), Sm (Is_CPP_Class, Flag), Sm (Is_Descendant_Of_Address, Flag), Sm (Is_Discrim_SO_Function, Flag), Sm (Is_Discriminant_Check_Function, Flag), Sm (Is_Dispatch_Table_Entity, Flag), Sm (Is_Dispatch_Table_Wrapper, Flag), Sm (Is_Dispatching_Operation, Flag), Sm (Is_Eliminated, Flag), Sm (Is_Entry_Formal, Flag), Sm (Is_Entry_Wrapper, Flag), Sm (Is_Exported, Flag), Sm (Is_First_Subtype, Flag), Sm (Is_Formal_Subprogram, Flag), Sm (Is_Frozen, Flag), Sm (Is_Generic_Instance, Flag), Sm (Is_Generic_Type, Flag), Sm (Is_Hidden, Flag), Sm (Is_Hidden_Non_Overridden_Subpgm, Flag), Sm (Is_Hidden_Open_Scope, Flag), Sm (Is_Ignored_Ghost_Entity, Flag), Sm (Is_Immediately_Visible, Flag), Sm (Is_Implementation_Defined, Flag), Sm (Is_Imported, Flag), Sm (Is_Independent, Flag), Sm (Is_Inlined, Flag), Sm (Is_Instantiated, Flag), Sm (Is_Interface, Flag), Sm (Is_Internal, Flag), Sm (Is_Interrupt_Handler, Flag), Sm (Is_Intrinsic_Subprogram, Flag), Sm (Is_Itype, Flag), Sm (Is_Known_Non_Null, Flag), Sm (Is_Known_Null, Flag), Sm (Is_Known_Valid, Flag), Sm (Is_Limited_Composite, Flag), Sm (Is_Limited_Interface, Flag), Sm (Is_Limited_Record, Flag), Sm (Is_Loop_Parameter, Flag), Sm (Is_Obsolescent, Flag), Sm (Is_Package_Body_Entity, Flag), Sm (Is_Packed, Flag, Impl_Base_Type_Only), Sm (Is_Packed_Array_Impl_Type, Flag), Sm (Is_Potentially_Use_Visible, Flag), Sm (Is_Preelaborated, Flag), Sm (Is_Private_Descendant, Flag), Sm (Is_Public, Flag), Sm (Is_Pure, Flag), Sm (Is_Remote_Call_Interface, Flag), Sm (Is_Remote_Types, Flag), Sm (Is_Renaming_Of_Object, Flag), Sm (Is_Return_Object, Flag), Sm (Is_Safe_To_Reevaluate, Flag), Sm (Is_Shared_Passive, Flag), Sm (Is_Static_Type, Flag), Sm (Is_Statically_Allocated, Flag), Sm (Is_Tag, Flag), Sm (Is_Tagged_Type, Flag), Sm (Is_Thunk, Flag), Sm (Is_Trivial_Subprogram, Flag), Sm (Is_True_Constant, Flag), Sm (Is_Unchecked_Union, Flag, Impl_Base_Type_Only), Sm (Is_Underlying_Full_View, Flag), Sm (Is_Underlying_Record_View, Flag, Base_Type_Only), Sm (Is_Unimplemented, Flag), Sm (Is_Uplevel_Referenced_Entity, Flag), Sm (Is_Visible_Formal, Flag), Sm (Is_Visible_Lib_Unit, Flag), Sm (Is_Volatile_Type, Flag), Sm (Is_Volatile_Object, Flag), Sm (Is_Volatile_Full_Access, Flag), Sm (Is_Wrapper, Flag), Sm (Kill_Elaboration_Checks, Flag), Sm (Kill_Range_Checks, Flag), Sm (Low_Bound_Tested, Flag), Sm (Materialize_Entity, Flag), Sm (May_Inherit_Delayed_Rep_Aspects, Flag), Sm (Needs_Activation_Record, Flag), Sm (Needs_Debug_Info, Flag), Sm (Never_Set_In_Source, Flag), Sm (No_Return, Flag), Sm (Overlays_Constant, Flag), Sm (Prev_Entity, Node_Id), Sm (Reachable, Flag), Sm (Referenced, Flag), Sm (Referenced_As_LHS, Flag), Sm (Referenced_As_Out_Parameter, Flag), Sm (Return_Present, Flag), Sm (Returns_By_Ref, Flag), Sm (Sec_Stack_Needed_For_Return, Flag), Sm (Size_Depends_On_Discriminant, Flag), Sm (Size_Known_At_Compile_Time, Flag), Sm (Stores_Attribute_Old_Prefix, Flag), Sm (Strict_Alignment, Flag, Impl_Base_Type_Only), Sm (Suppress_Elaboration_Warnings, Flag), Sm (Suppress_Style_Checks, Flag), Sm (Suppress_Value_Tracking_On_Call, Flag), Sm (Treat_As_Volatile, Flag), Sm (Used_As_Generic_Actual, Flag), Sm (Uses_Sec_Stack, Flag), Sm (Warnings_Off, Flag), Sm (Warnings_Off_Used, Flag), Sm (Warnings_Off_Used_Unmodified, Flag), Sm (Warnings_Off_Used_Unreferenced, Flag), Sm (Was_Hidden, Flag))); Ab (Void_Or_Type_Kind, Entity_Kind); Cc (E_Void, Void_Or_Type_Kind, -- The initial Ekind value for a newly created entity. Also used as the -- Ekind for Standard_Void_Type, a type entity in Standard used as a -- dummy type for the return type of a procedure (the reason we create -- this type is to share the circuits for performing overload -- resolution on calls). (Sm (Alignment, Unat), Sm (Contract, Node_Id), Sm (Is_Elaboration_Warnings_OK_Id, Flag), Sm (Original_Record_Component, Node_Id), Sm (Scope_Depth_Value, Unat), Sm (SPARK_Pragma, Node_Id), Sm (SPARK_Pragma_Inherited, Flag), Sm (Current_Value, Node_Id), -- setter only Sm (Has_Predicates, Flag), -- setter only Sm (Initialization_Statements, Node_Id), -- setter only Sm (Is_Param_Block_Component_Type, Flag, Base_Type_Only), -- setter only Sm (Package_Instantiation, Node_Id), -- setter only Sm (Related_Expression, Node_Id), -- setter only -- If we set the Ekind field properly before setting the following -- fields, then these would not be needed in E_Void. Sm (Accept_Address, Elist_Id), Sm (Associated_Formal_Package, Node_Id), Sm (Associated_Node_For_Itype, Node_Id), Sm (Corresponding_Remote_Type, Node_Id), Sm (CR_Discriminant, Node_Id), Sm (Debug_Renaming_Link, Node_Id), Sm (Discriminal_Link, Node_Id), Sm (Discriminant_Default_Value, Node_Id), Sm (Discriminant_Number, Upos), Sm (Enclosing_Scope, Node_Id), Sm (Entry_Bodies_Array, Node_Id, Pre => "Has_Entries (N)"), Sm (Entry_Cancel_Parameter, Node_Id), Sm (Entry_Component, Node_Id), Sm (Entry_Formal, Node_Id), Sm (Entry_Parameters_Type, Node_Id), Sm (Esize, Uint), Sm (RM_Size, Uint), Sm (Extra_Formal, Node_Id), Sm (First_Entity, Node_Id), Sm (Generic_Homonym, Node_Id), Sm (Generic_Renamings, Elist_Id), Sm (Handler_Records, List_Id), Sm (Has_Static_Discriminants, Flag), Sm (Inner_Instances, Elist_Id), Sm (Interface_Name, Node_Id), Sm (Last_Entity, Node_Id), Sm (Next_Inlined_Subprogram, Node_Id), Sm (Renamed_Or_Alias, Node_Id), -- See Einfo.Utils Sm (Return_Applies_To, Node_Id), Sm (Scalar_Range, Node_Id), Sm (Scale_Value, Uint), Sm (Unset_Reference, Node_Id))); -- For the above "setter only" fields, the setters are called for E_Void, -- but not getters; the Ekind is modified before any such getters are -- called. Ab (Exception_Or_Object_Kind, Entity_Kind); Ab (Object_Kind, Exception_Or_Object_Kind, (Sm (Current_Value, Node_Id), Sm (Renamed_Or_Alias, Node_Id))); Ab (Record_Field_Kind, Object_Kind, (Sm (Component_Bit_Offset, Uint), Sm (Component_Clause, Node_Id), Sm (Corresponding_Record_Component, Node_Id), Sm (Entry_Formal, Node_Id), Sm (Esize, Uint), Sm (Interface_Name, Node_Id), Sm (Normalized_First_Bit, Uint), Sm (Normalized_Position, Uint), Sm (Original_Record_Component, Node_Id))); Cc (E_Component, Record_Field_Kind, -- Components (other than discriminants) of a record declaration, -- private declarations of protected objects. (Sm (Discriminant_Checking_Func, Node_Id), Sm (DT_Entry_Count, Uint, Pre => "Is_Tag (N)"), Sm (DT_Offset_To_Top_Func, Node_Id, Pre => "Is_Tag (N)"), Sm (Prival, Node_Id, Pre => "Is_Protected_Component (N)"), Sm (Related_Type, Node_Id))); Ab (Allocatable_Kind, Object_Kind, (Sm (Activation_Record_Component, Node_Id), Sm (Alignment, Unat), Sm (Esize, Uint), Sm (Interface_Name, Node_Id), Sm (Is_Finalized_Transient, Flag), Sm (Is_Ignored_Transient, Flag), Sm (Linker_Section_Pragma, Node_Id), Sm (Related_Expression, Node_Id), Sm (Status_Flag_Or_Transient_Decl, Node_Id))); Ab (Constant_Or_Variable_Kind, Allocatable_Kind, (Sm (Actual_Subtype, Node_Id), Sm (BIP_Initialization_Call, Node_Id), Sm (Contract, Node_Id), Sm (Discriminal_Link, Node_Id), Sm (Encapsulating_State, Node_Id), Sm (Extra_Accessibility, Node_Id), Sm (Initialization_Statements, Node_Id), Sm (Is_Elaboration_Checks_OK_Id, Flag), Sm (Is_Elaboration_Warnings_OK_Id, Flag), Sm (Last_Aggregate_Assignment, Node_Id), Sm (Optimize_Alignment_Space, Flag), Sm (Optimize_Alignment_Time, Flag), Sm (Prival_Link, Node_Id), Sm (Related_Type, Node_Id), Sm (Return_Statement, Node_Id), Sm (Size_Check_Code, Node_Id), Sm (SPARK_Pragma, Node_Id), Sm (SPARK_Pragma_Inherited, Flag))); Cc (E_Constant, Constant_Or_Variable_Kind, -- Constants created by an object declaration with a constant keyword (Sm (Full_View, Node_Id))); Cc (E_Discriminant, Record_Field_Kind, -- A discriminant, created by the use of a discriminant in a type -- declaration. (Sm (Corresponding_Discriminant, Node_Id), Sm (CR_Discriminant, Node_Id), Sm (Discriminal, Node_Id), Sm (Discriminant_Default_Value, Node_Id), Sm (Discriminant_Number, Upos), Sm (Is_Completely_Hidden, Flag))); Cc (E_Loop_Parameter, Allocatable_Kind); -- A loop parameter created by a for loop Cc (E_Variable, Constant_Or_Variable_Kind, -- Variables created by an object declaration with no constant keyword (Sm (Anonymous_Designated_Type, Node_Id), Sm (Debug_Renaming_Link, Node_Id), Sm (Extra_Constrained, Node_Id), Sm (Has_Initial_Value, Flag), Sm (Hiding_Loop_Variable, Node_Id), Sm (Last_Assignment, Node_Id), Sm (OK_To_Rename, Flag), Sm (Part_Of_Constituents, Elist_Id), Sm (Part_Of_References, Elist_Id), Sm (Shared_Var_Procs_Instance, Node_Id), Sm (Suppress_Initialization, Flag), Sm (Unset_Reference, Node_Id), Sm (Validated_Object, Node_Id))); Ab (Formal_Kind, Object_Kind, -- Formal parameters are also objects (Sm (Activation_Record_Component, Node_Id), Sm (Actual_Subtype, Node_Id), Sm (Alignment, Unat), Sm (Default_Expr_Function, Node_Id), Sm (Default_Value, Node_Id), Sm (Entry_Component, Node_Id), Sm (Esize, Uint), Sm (Extra_Accessibility, Node_Id), Sm (Extra_Constrained, Node_Id), Sm (Extra_Formal, Node_Id), Sm (Has_Initial_Value, Flag), Sm (Is_Controlling_Formal, Flag), Sm (Is_Only_Out_Parameter, Flag), Sm (Linker_Section_Pragma, Node_Id), Sm (Mechanism, Mechanism_Type), Sm (Minimum_Accessibility, Node_Id), Sm (Protected_Formal, Node_Id), Sm (Spec_Entity, Node_Id), Sm (Unset_Reference, Node_Id))); Cc (E_Out_Parameter, Formal_Kind, -- An out parameter of a subprogram or entry (Sm (Last_Assignment, Node_Id))); Cc (E_In_Out_Parameter, Formal_Kind, -- An in-out parameter of a subprogram or entry (Sm (Last_Assignment, Node_Id))); Cc (E_In_Parameter, Formal_Kind, -- An in parameter of a subprogram or entry (Sm (Discriminal_Link, Node_Id), Sm (Discriminant_Default_Value, Node_Id), Sm (Is_Activation_Record, Flag))); Ab (Formal_Object_Kind, Object_Kind, -- Generic formal objects are also objects (Sm (Entry_Component, Node_Id), Sm (Esize, Uint))); Cc (E_Generic_In_Out_Parameter, Formal_Object_Kind, -- A generic in out parameter, created by the use of a generic in out -- parameter in a generic declaration. (Sm (Actual_Subtype, Node_Id))); Cc (E_Generic_In_Parameter, Formal_Object_Kind); -- A generic in parameter, created by the use of a generic in -- parameter in a generic declaration. Ab (Named_Kind, Entity_Kind, (Sm (Renamed_Or_Alias, Node_Id))); Cc (E_Named_Integer, Named_Kind); -- Named numbers created by a number declaration with an integer value Cc (E_Named_Real, Named_Kind); -- Named numbers created by a number declaration with a real value Ab (Type_Kind, Void_Or_Type_Kind, (Sm (Alignment, Unat), Sm (Associated_Node_For_Itype, Node_Id), Sm (Can_Use_Internal_Rep, Flag, Base_Type_Only, Pre => "Ekind (Base_Type (N)) in Access_Subprogram_Kind"), Sm (Class_Wide_Type, Node_Id), Sm (Contract, Node_Id), Sm (Current_Use_Clause, Node_Id), Sm (Derived_Type_Link, Node_Id), Sm (Direct_Primitive_Operations, Elist_Id), Sm (Predicates_Ignored, Flag), Sm (Esize, Uint), Sm (Finalize_Storage_Only, Flag, Base_Type_Only), Sm (Full_View, Node_Id), Sm (Has_Completion_In_Body, Flag), Sm (Has_Constrained_Partial_View, Flag, Base_Type_Only), Sm (Has_Discriminants, Flag), Sm (Has_Dispatch_Table, Flag, Pre => "Is_Tagged_Type (N)"), Sm (Has_Dynamic_Predicate_Aspect, Flag), Sm (Has_Inheritable_Invariants, Flag, Base_Type_Only), Sm (Has_Inherited_DIC, Flag, Base_Type_Only), Sm (Has_Inherited_Invariants, Flag, Base_Type_Only), Sm (Has_Object_Size_Clause, Flag), Sm (Has_Own_DIC, Flag, Base_Type_Only), Sm (Has_Own_Invariants, Flag, Base_Type_Only), Sm (Has_Pragma_Unreferenced_Objects, Flag), Sm (Has_Predicates, Flag), Sm (Has_Primitive_Operations, Flag, Base_Type_Only), Sm (Has_Private_Extension, Flag, Pre => "Is_Tagged_Type (N)"), Sm (Has_Specified_Layout, Flag, Impl_Base_Type_Only), Sm (Has_Specified_Stream_Input, Flag), Sm (Has_Specified_Stream_Output, Flag), Sm (Has_Specified_Stream_Read, Flag), Sm (Has_Specified_Stream_Write, Flag), Sm (Has_Static_Discriminants, Flag), Sm (Has_Static_Predicate, Flag), Sm (Has_Static_Predicate_Aspect, Flag), Sm (Has_Unknown_Discriminants, Flag), Sm (Interface_Name, Node_Id), Sm (Is_Abstract_Type, Flag), Sm (Is_Actual_Subtype, Flag), Sm (Is_Asynchronous, Flag), Sm (Is_Fixed_Lower_Bound_Array_Subtype, Flag), Sm (Is_Fixed_Lower_Bound_Index_Subtype, Flag), Sm (Is_Generic_Actual_Type, Flag), Sm (Is_Non_Static_Subtype, Flag), Sm (Is_Private_Composite, Flag), Sm (Is_RACW_Stub_Type, Flag), Sm (Is_Unsigned_Type, Flag), Sm (Itype_Printed, Flag, Pre => "Is_Itype (N)"), Sm (Known_To_Have_Preelab_Init, Flag), Sm (Linker_Section_Pragma, Node_Id), Sm (Must_Be_On_Byte_Boundary, Flag), Sm (Must_Have_Preelab_Init, Flag), Sm (No_Tagged_Streams_Pragma, Node_Id, Pre => "Is_Tagged_Type (N)"), Sm (Non_Binary_Modulus, Flag, Base_Type_Only), Sm (Optimize_Alignment_Space, Flag), Sm (Optimize_Alignment_Time, Flag), Sm (Partial_View_Has_Unknown_Discr, Flag), Sm (Pending_Access_Types, Elist_Id), Sm (Related_Expression, Node_Id), Sm (RM_Size, Uint), Sm (SPARK_Pragma, Node_Id), Sm (SPARK_Pragma_Inherited, Flag), Sm (Subprograms_For_Type, Elist_Id), Sm (Suppress_Initialization, Flag), Sm (Universal_Aliasing, Flag, Impl_Base_Type_Only), Sm (Renamed_Or_Alias, Node_Id))); Ab (Elementary_Kind, Type_Kind); Ab (Scalar_Kind, Elementary_Kind, (Sm (Default_Aspect_Value, Node_Id, Base_Type_Only), Sm (Scalar_Range, Node_Id))); Ab (Discrete_Kind, Scalar_Kind, (Sm (No_Dynamic_Predicate_On_Actual, Flag), Sm (No_Predicate_On_Actual, Flag), Sm (Static_Discrete_Predicate, List_Id))); Ab (Enumeration_Kind, Discrete_Kind, (Sm (First_Literal, Node_Id), Sm (Has_Enumeration_Rep_Clause, Flag), Sm (Has_Pragma_Ordered, Flag, Impl_Base_Type_Only), Sm (Lit_Indexes, Node_Id), Sm (Lit_Strings, Node_Id), Sm (Nonzero_Is_True, Flag, Base_Type_Only, Pre => "Root_Type (N) = Standard_Boolean"), Sm (Lit_Hash, Node_Id, Root_Type_Only))); Cc (E_Enumeration_Type, Enumeration_Kind, -- Enumeration types, created by an enumeration type declaration (Sm (Enum_Pos_To_Rep, Node_Id), Sm (First_Entity, Node_Id))); Cc (E_Enumeration_Subtype, Enumeration_Kind); -- Enumeration subtypes, created by an explicit or implicit subtype -- declaration applied to an enumeration type or subtype. Ab (Integer_Kind, Discrete_Kind, (Sm (Has_Shift_Operator, Flag, Base_Type_Only))); Ab (Signed_Integer_Kind, Integer_Kind, (Sm (First_Entity, Node_Id))); Cc (E_Signed_Integer_Type, Signed_Integer_Kind); -- Signed integer type, used for the anonymous base type of the -- integer subtype created by an integer type declaration. Cc (E_Signed_Integer_Subtype, Signed_Integer_Kind); -- Signed integer subtype, created by either an integer subtype or -- integer type declaration (in the latter case an integer type is -- created for the base type, and this is the first named subtype). Ab (Modular_Integer_Kind, Integer_Kind, (Sm (Modulus, Uint, Base_Type_Only), Sm (Original_Array_Type, Node_Id))); Cc (E_Modular_Integer_Type, Modular_Integer_Kind); -- Modular integer type, used for the anonymous base type of the -- integer subtype created by a modular integer type declaration. Cc (E_Modular_Integer_Subtype, Modular_Integer_Kind); -- Modular integer subtype, created by either an modular subtype -- or modular type declaration (in the latter case a modular type -- is created for the base type, and this is the first named subtype). Ab (Real_Kind, Scalar_Kind, (Sm (Static_Real_Or_String_Predicate, Node_Id))); Ab (Fixed_Point_Kind, Real_Kind, (Sm (Delta_Value, Ureal), Sm (Small_Value, Ureal))); Ab (Ordinary_Fixed_Point_Kind, Fixed_Point_Kind, (Sm (Has_Small_Clause, Flag))); Cc (E_Ordinary_Fixed_Point_Type, Ordinary_Fixed_Point_Kind); -- Ordinary fixed type, used for the anonymous base type of the fixed -- subtype created by an ordinary fixed point type declaration. Cc (E_Ordinary_Fixed_Point_Subtype, Ordinary_Fixed_Point_Kind); -- Ordinary fixed point subtype, created by either an ordinary fixed -- point subtype or ordinary fixed point type declaration (in the -- latter case a fixed point type is created for the base type, and -- this is the first named subtype). Ab (Decimal_Fixed_Point_Kind, Fixed_Point_Kind, (Sm (Digits_Value, Upos), Sm (Has_Machine_Radix_Clause, Flag), Sm (Machine_Radix_10, Flag), Sm (Scale_Value, Uint))); Cc (E_Decimal_Fixed_Point_Type, Decimal_Fixed_Point_Kind); -- Decimal fixed type, used for the anonymous base type of the decimal -- fixed subtype created by an ordinary fixed point type declaration. Cc (E_Decimal_Fixed_Point_Subtype, Decimal_Fixed_Point_Kind); -- Decimal fixed point subtype, created by either a decimal fixed point -- subtype or decimal fixed point type declaration (in the latter case -- a fixed point type is created for the base type, and this is the -- first named subtype). Ab (Float_Kind, Real_Kind, (Sm (Digits_Value, Upos))); Cc (E_Floating_Point_Type, Float_Kind); -- Floating point type, used for the anonymous base type of the -- floating point subtype created by a floating point type declaration. Cc (E_Floating_Point_Subtype, Float_Kind); -- Floating point subtype, created by either a floating point subtype -- or floating point type declaration (in the latter case a floating -- point type is created for the base type, and this is the first -- named subtype). Ab (Access_Kind, Elementary_Kind, (Sm (Associated_Storage_Pool, Node_Id, Root_Type_Only), Sm (Directly_Designated_Type, Node_Id), Sm (Finalization_Master, Node_Id, Root_Type_Only), Sm (Has_Pragma_Controlled, Flag, Impl_Base_Type_Only), Sm (Has_Storage_Size_Clause, Flag, Impl_Base_Type_Only), Sm (Is_Access_Constant, Flag), Sm (Is_Local_Anonymous_Access, Flag), Sm (Is_Param_Block_Component_Type, Flag, Base_Type_Only), Sm (Is_Pure_Unit_Access_Type, Flag), Sm (Master_Id, Node_Id), Sm (No_Pool_Assigned, Flag, Root_Type_Only), Sm (No_Strict_Aliasing, Flag, Base_Type_Only), Sm (Storage_Size_Variable, Node_Id, Impl_Base_Type_Only))); Cc (E_Access_Type, Access_Kind); -- An access type created by an access type declaration with no all -- keyword present. Cc (E_Access_Subtype, Access_Kind); -- An access subtype created by a subtype declaration for any access -- type (whether or not it is a general access type). Cc (E_Access_Attribute_Type, Access_Kind); -- An access type created for an access attribute (one of 'Access, -- 'Unrestricted_Access, or Unchecked_Access). Cc (E_Allocator_Type, Access_Kind); -- A special internal type used to label allocators and references to -- objects using 'Reference. This is needed because special resolution -- rules apply to these constructs. On the resolution pass, this type -- is almost always replaced by the actual access type, but if the -- context does not provide one, the backend will see Allocator_Type -- itself (which will already have been frozen). Cc (E_General_Access_Type, Access_Kind, -- An access type created by an access type declaration with the all -- keyword present. (Sm (First_Entity, Node_Id))); Ab (Access_Subprogram_Kind, Access_Kind); Cc (E_Access_Subprogram_Type, Access_Subprogram_Kind, -- An access-to-subprogram type, created by an access-to-subprogram -- declaration. (Sm (Equivalent_Type, Node_Id), Sm (Original_Access_Type, Node_Id))); Ab (Access_Protected_Kind, Access_Subprogram_Kind, (Sm (Equivalent_Type, Node_Id))); Cc (E_Access_Protected_Subprogram_Type, Access_Protected_Kind); -- An access to a protected subprogram, created by the corresponding -- declaration. Values of such a type denote both a protected object -- and a protected operation within, and have different compile-time -- and run-time properties than other access-to-subprogram values. Cc (E_Anonymous_Access_Protected_Subprogram_Type, Access_Protected_Kind); -- An anonymous access-to-protected-subprogram type, created by an -- access-to-subprogram declaration. Cc (E_Anonymous_Access_Subprogram_Type, Access_Subprogram_Kind); -- An anonymous access-to-subprogram type, created by an access-to- -- subprogram declaration, or generated for a current instance of -- a type name appearing within a component definition that has an -- anonymous access-to-subprogram type. Cc (E_Anonymous_Access_Type, Access_Kind); -- An anonymous access-to-object type Ab (Composite_Kind, Type_Kind, (Sm (Discriminant_Constraint, Elist_Id, Pre_Get => "Has_Discriminants (N) or else Is_Constrained (N)"))); Ab (Aggregate_Kind, Composite_Kind, (Sm (Component_Alignment, Component_Alignment_Kind, Base_Type_Only), Sm (Has_Pragma_Pack, Flag, Impl_Base_Type_Only), Sm (Reverse_Storage_Order, Flag, Base_Type_Only), Sm (SSO_Set_High_By_Default, Flag, Base_Type_Only), Sm (SSO_Set_Low_By_Default, Flag, Base_Type_Only))); Ab (Array_Kind, Aggregate_Kind, (Sm (Component_Size, Uint, Impl_Base_Type_Only), Sm (Component_Type, Node_Id, Impl_Base_Type_Only), Sm (Default_Aspect_Component_Value, Node_Id, Base_Type_Only), Sm (First_Index, Node_Id), Sm (Has_Component_Size_Clause, Flag, Impl_Base_Type_Only), Sm (Original_Array_Type, Node_Id), Sm (Packed_Array_Impl_Type, Node_Id), Sm (Related_Array_Object, Node_Id))); Cc (E_Array_Type, Array_Kind, -- An array type created by an array type declaration. Includes all -- cases of arrays, except for string types. (Sm (First_Entity, Node_Id), Sm (Static_Real_Or_String_Predicate, Node_Id))); Cc (E_Array_Subtype, Array_Kind, -- An array subtype, created by an explicit array subtype declaration, -- or the use of an anonymous array subtype. (Sm (Predicated_Parent, Node_Id), Sm (First_Entity, Node_Id), Sm (Static_Real_Or_String_Predicate, Node_Id))); Cc (E_String_Literal_Subtype, Array_Kind, -- A special string subtype, used only to describe the type of a string -- literal (will always be one dimensional, with literal bounds). (Sm (String_Literal_Length, Unat), Sm (String_Literal_Low_Bound, Node_Id))); Ab (Class_Wide_Kind, Aggregate_Kind, (Sm (C_Pass_By_Copy, Flag, Impl_Base_Type_Only), Sm (Equivalent_Type, Node_Id), Sm (First_Entity, Node_Id), Sm (Has_Complex_Representation, Flag, Impl_Base_Type_Only), Sm (Has_Record_Rep_Clause, Flag, Impl_Base_Type_Only), Sm (Interfaces, Elist_Id), Sm (Last_Entity, Node_Id), Sm (No_Reordering, Flag, Impl_Base_Type_Only), Sm (Non_Limited_View, Node_Id), Sm (Parent_Subtype, Node_Id, Base_Type_Only), Sm (Reverse_Bit_Order, Flag, Base_Type_Only), Sm (Stored_Constraint, Elist_Id))); Cc (E_Class_Wide_Type, Class_Wide_Kind, -- A class wide type, created by any tagged type declaration (i.e. if -- a tagged type is declared, the corresponding class type is always -- created, using this Ekind value). (Sm (Corresponding_Remote_Type, Node_Id), Sm (Scalar_Range, Node_Id))); Cc (E_Class_Wide_Subtype, Class_Wide_Kind, -- A subtype of a class wide type, created by a subtype declaration -- used to declare a subtype of a class type. (Sm (Cloned_Subtype, Node_Id))); Cc (E_Record_Type, Aggregate_Kind, -- A record type, created by a record type declaration (Sm (Access_Disp_Table, Elist_Id, Impl_Base_Type_Only), Sm (Access_Disp_Table_Elab_Flag, Node_Id, Impl_Base_Type_Only), Sm (C_Pass_By_Copy, Flag, Impl_Base_Type_Only), Sm (Corresponding_Concurrent_Type, Node_Id), Sm (Corresponding_Remote_Type, Node_Id), Sm (Dispatch_Table_Wrappers, Elist_Id, Impl_Base_Type_Only), Sm (First_Entity, Node_Id), Sm (Has_Complex_Representation, Flag, Impl_Base_Type_Only), Sm (Has_Record_Rep_Clause, Flag, Impl_Base_Type_Only), Sm (Interfaces, Elist_Id), Sm (Last_Entity, Node_Id), Sm (No_Reordering, Flag, Impl_Base_Type_Only), Sm (Parent_Subtype, Node_Id, Base_Type_Only), Sm (Reverse_Bit_Order, Flag, Base_Type_Only), Sm (Stored_Constraint, Elist_Id), Sm (Underlying_Record_View, Node_Id))); Cc (E_Record_Subtype, Aggregate_Kind, -- A record subtype, created by a record subtype declaration (Sm (Access_Disp_Table, Elist_Id, Impl_Base_Type_Only), Sm (Access_Disp_Table_Elab_Flag, Node_Id, Impl_Base_Type_Only), Sm (C_Pass_By_Copy, Flag, Impl_Base_Type_Only), Sm (Cloned_Subtype, Node_Id), Sm (Corresponding_Remote_Type, Node_Id), Sm (Predicated_Parent, Node_Id), Sm (Dispatch_Table_Wrappers, Elist_Id, Impl_Base_Type_Only), Sm (First_Entity, Node_Id), Sm (Has_Complex_Representation, Flag, Impl_Base_Type_Only), Sm (Has_Record_Rep_Clause, Flag, Impl_Base_Type_Only), Sm (Interfaces, Elist_Id), Sm (Last_Entity, Node_Id), Sm (No_Reordering, Flag, Impl_Base_Type_Only), Sm (Parent_Subtype, Node_Id, Base_Type_Only), Sm (Reverse_Bit_Order, Flag, Base_Type_Only), Sm (Stored_Constraint, Elist_Id), Sm (Underlying_Record_View, Node_Id))); Ab (Incomplete_Or_Private_Kind, Composite_Kind, (Sm (First_Entity, Node_Id), Sm (Last_Entity, Node_Id), Sm (Private_Dependents, Elist_Id), Sm (Stored_Constraint, Elist_Id))); Ab (Private_Kind, Incomplete_Or_Private_Kind, (Sm (Underlying_Full_View, Node_Id))); Cc (E_Record_Type_With_Private, Private_Kind, -- Used for types defined by a private extension declaration, -- and for tagged private types. Includes the fields for both -- private types and for record types (with the sole exception of -- Corresponding_Concurrent_Type which is obviously not needed). This -- entity is considered to be both a record type and a private type. (Sm (Access_Disp_Table, Elist_Id, Impl_Base_Type_Only), Sm (Access_Disp_Table_Elab_Flag, Node_Id, Impl_Base_Type_Only), Sm (C_Pass_By_Copy, Flag, Impl_Base_Type_Only), Sm (Component_Alignment, Component_Alignment_Kind, Base_Type_Only), Sm (Corresponding_Remote_Type, Node_Id), Sm (Has_Complex_Representation, Flag, Impl_Base_Type_Only), Sm (Has_Pragma_Pack, Flag, Impl_Base_Type_Only), Sm (Has_Record_Rep_Clause, Flag, Impl_Base_Type_Only), Sm (Interfaces, Elist_Id), Sm (No_Reordering, Flag, Impl_Base_Type_Only), Sm (Parent_Subtype, Node_Id, Base_Type_Only), Sm (Reverse_Bit_Order, Flag, Base_Type_Only), Sm (Reverse_Storage_Order, Flag, Base_Type_Only), Sm (SSO_Set_High_By_Default, Flag, Base_Type_Only), Sm (SSO_Set_Low_By_Default, Flag, Base_Type_Only), Sm (Underlying_Record_View, Node_Id))); Cc (E_Record_Subtype_With_Private, Private_Kind, -- A subtype of a type defined by a private extension declaration (Sm (C_Pass_By_Copy, Flag, Impl_Base_Type_Only), Sm (Component_Alignment, Component_Alignment_Kind, Base_Type_Only), Sm (Corresponding_Remote_Type, Node_Id), Sm (Predicated_Parent, Node_Id), Sm (Has_Complex_Representation, Flag, Impl_Base_Type_Only), Sm (Has_Pragma_Pack, Flag, Impl_Base_Type_Only), Sm (Has_Record_Rep_Clause, Flag, Impl_Base_Type_Only), Sm (Interfaces, Elist_Id), Sm (No_Reordering, Flag, Impl_Base_Type_Only), Sm (Parent_Subtype, Node_Id, Base_Type_Only), Sm (Reverse_Bit_Order, Flag, Base_Type_Only), Sm (Reverse_Storage_Order, Flag, Base_Type_Only), Sm (SSO_Set_High_By_Default, Flag, Base_Type_Only), Sm (SSO_Set_Low_By_Default, Flag, Base_Type_Only))); Cc (E_Private_Type, Private_Kind, -- A private type, created by a private type declaration that has -- neither the keyword limited nor the keyword tagged. (Sm (Scalar_Range, Node_Id), Sm (Scope_Depth_Value, Unat))); Cc (E_Private_Subtype, Private_Kind, -- A subtype of a private type, created by a subtype declaration used -- to declare a subtype of a private type. (Sm (Scope_Depth_Value, Unat))); Cc (E_Limited_Private_Type, Private_Kind, -- A limited private type, created by a private type declaration that -- has the keyword limited, but not the keyword tagged. (Sm (Scalar_Range, Node_Id), Sm (Scope_Depth_Value, Unat))); Cc (E_Limited_Private_Subtype, Private_Kind, -- A subtype of a limited private type, created by a subtype declaration -- used to declare a subtype of a limited private type. (Sm (Scope_Depth_Value, Unat))); Ab (Incomplete_Kind, Incomplete_Or_Private_Kind, (Sm (Non_Limited_View, Node_Id))); Cc (E_Incomplete_Type, Incomplete_Kind, -- An incomplete type, created by an incomplete type declaration (Sm (Scalar_Range, Node_Id))); Cc (E_Incomplete_Subtype, Incomplete_Kind); -- An incomplete subtype, created by a subtype declaration where the -- subtype mark denotes an incomplete type. Ab (Concurrent_Kind, Composite_Kind, (Sm (Corresponding_Record_Type, Node_Id), Sm (First_Entity, Node_Id), Sm (First_Private_Entity, Node_Id), Sm (Last_Entity, Node_Id), Sm (Scope_Depth_Value, Unat), Sm (Stored_Constraint, Elist_Id))); Ab (Task_Kind, Concurrent_Kind, (Sm (Has_Storage_Size_Clause, Flag, Impl_Base_Type_Only), Sm (Is_Elaboration_Checks_OK_Id, Flag), Sm (Is_Elaboration_Warnings_OK_Id, Flag), Sm (Relative_Deadline_Variable, Node_Id, Impl_Base_Type_Only), Sm (Storage_Size_Variable, Node_Id, Impl_Base_Type_Only), Sm (Task_Body_Procedure, Node_Id))); Cc (E_Task_Type, Task_Kind, -- A task type, created by a task type declaration. An entity with this -- Ekind is also created to describe the anonymous type of a task that -- is created by a single task declaration. (Sm (Anonymous_Object, Node_Id), Sm (Ignore_SPARK_Mode_Pragmas, Flag), Sm (SPARK_Aux_Pragma, Node_Id), Sm (SPARK_Aux_Pragma_Inherited, Flag))); Cc (E_Task_Subtype, Task_Kind); -- A subtype of a task type, created by a subtype declaration used to -- declare a subtype of a task type. Ab (Protected_Kind, Concurrent_Kind, (Sm (Entry_Bodies_Array, Node_Id, Pre => "Has_Entries (N)"), Sm (Uses_Lock_Free, Flag))); Cc (E_Protected_Type, Protected_Kind, -- A protected type, created by a protected type declaration. An entity -- with this Ekind is also created to describe the anonymous type of -- a protected object created by a single protected declaration. (Sm (Anonymous_Object, Node_Id), Sm (Entry_Max_Queue_Lengths_Array, Node_Id), Sm (Ignore_SPARK_Mode_Pragmas, Flag), Sm (SPARK_Aux_Pragma, Node_Id), Sm (SPARK_Aux_Pragma_Inherited, Flag))); Cc (E_Protected_Subtype, Protected_Kind); -- A subtype of a protected type, created by a subtype declaration used -- to declare a subtype of a protected type. Cc (E_Exception_Type, Type_Kind, -- The type of an exception created by an exception declaration (Sm (Equivalent_Type, Node_Id))); Cc (E_Subprogram_Type, Type_Kind, -- This is the designated type of an Access_To_Subprogram. Has type and -- signature like a subprogram entity, so can appear in calls, which -- are resolved like regular calls, except that such an entity is not -- overloadable. (Sm (Access_Subprogram_Wrapper, Node_Id), Sm (Extra_Accessibility_Of_Result, Node_Id), Sm (Extra_Formals, Node_Id), Sm (First_Entity, Node_Id), Sm (Last_Entity, Node_Id), Sm (Needs_No_Actuals, Flag))); Ab (Overloadable_Kind, Entity_Kind, (Sm (Renamed_Or_Alias, Node_Id), Sm (Extra_Formals, Node_Id), Sm (Is_Abstract_Subprogram, Flag), Sm (Is_Primitive, Flag), Sm (Needs_No_Actuals, Flag), Sm (Requires_Overriding, Flag))); Cc (E_Enumeration_Literal, Overloadable_Kind, -- An enumeration literal, created by the use of the literal in an -- enumeration type definition. (Sm (Enumeration_Pos, Unat), Sm (Enumeration_Rep, Valid_Uint), Sm (Enumeration_Rep_Expr, Node_Id), Sm (Esize, Uint), Sm (Alignment, Unat), Sm (Interface_Name, Node_Id))); Ab (Subprogram_Kind, Overloadable_Kind, (Sm (Body_Needed_For_SAL, Flag), Sm (Class_Postconditions, Node_Id), Sm (Class_Preconditions, Node_Id), Sm (Class_Preconditions_Subprogram, Node_Id), Sm (Contract, Node_Id), Sm (Dynamic_Call_Helper, Node_Id), Sm (Elaboration_Entity, Node_Id), Sm (Elaboration_Entity_Required, Flag), Sm (First_Entity, Node_Id), Sm (Has_Expanded_Contract, Flag), Sm (Has_Nested_Subprogram, Flag), Sm (Has_Out_Or_In_Out_Parameter, Flag), Sm (Has_Recursive_Call, Flag), Sm (Ignored_Class_Postconditions, Node_Id), Sm (Ignored_Class_Preconditions, Node_Id), Sm (Ignore_SPARK_Mode_Pragmas, Flag), Sm (Import_Pragma, Node_Id), Sm (Indirect_Call_Wrapper, Node_Id), Sm (Interface_Alias, Node_Id), Sm (Interface_Name, Node_Id), Sm (Is_Elaboration_Checks_OK_Id, Flag), Sm (Is_Elaboration_Warnings_OK_Id, Flag), Sm (Is_Machine_Code_Subprogram, Flag), Sm (Last_Entity, Node_Id), Sm (Linker_Section_Pragma, Node_Id), Sm (Overridden_Operation, Node_Id), Sm (Protected_Body_Subprogram, Node_Id), Sm (Scope_Depth_Value, Unat), Sm (Static_Call_Helper, Node_Id), Sm (SPARK_Pragma, Node_Id), Sm (SPARK_Pragma_Inherited, Flag), Sm (Subps_Index, Unat))); Cc (E_Function, Subprogram_Kind, -- A function, created by a function declaration or a function body -- that acts as its own declaration. (Sm (Anonymous_Masters, Elist_Id), Sm (Corresponding_Equality, Node_Id, Pre => "not Comes_From_Source (N) and then Chars (N) = Name_Op_Ne"), Sm (Corresponding_Procedure, Node_Id), Sm (DT_Position, Uint, Pre_Get => "Present (DTC_Entity (N))"), Sm (DTC_Entity, Node_Id), Sm (Extra_Accessibility_Of_Result, Node_Id), Sm (Generic_Renamings, Elist_Id), Sm (Handler_Records, List_Id), Sm (Has_Missing_Return, Flag), Sm (Inner_Instances, Elist_Id), Sm (Is_Called, Flag), Sm (Is_CUDA_Kernel, Flag), Sm (Is_DIC_Procedure, Flag), Sm (Is_Generic_Actual_Subprogram, Flag), Sm (Is_Initial_Condition_Procedure, Flag), Sm (Is_Inlined_Always, Flag), Sm (Is_Invariant_Procedure, Flag), Sm (Is_Partial_Invariant_Procedure, Flag), Sm (Is_Predicate_Function, Flag), Sm (Is_Predicate_Function_M, Flag), Sm (Is_Primitive_Wrapper, Flag), Sm (Is_Private_Primitive, Flag), Sm (LSP_Subprogram, Node_Id), Sm (Mechanism, Mechanism_Type), Sm (Next_Inlined_Subprogram, Node_Id), Sm (Original_Protected_Subprogram, Node_Id), Sm (Postconditions_Proc, Node_Id), Sm (Protected_Subprogram, Node_Id), Sm (Protection_Object, Node_Id), Sm (Related_Expression, Node_Id), Sm (Rewritten_For_C, Flag), Sm (Thunk_Entity, Node_Id, Pre => "Is_Thunk (N)"), Sm (Wrapped_Entity, Node_Id, Pre => "Is_Primitive_Wrapper (N)"))); Cc (E_Operator, Subprogram_Kind, -- A predefined operator, appearing in Standard, or an implicitly -- defined concatenation operator created whenever an array is declared. -- We do not make normal derived operators explicit in the tree, but the -- concatenation operators are made explicit. (Sm (Extra_Accessibility_Of_Result, Node_Id), Sm (LSP_Subprogram, Node_Id))); Cc (E_Procedure, Subprogram_Kind, -- A procedure, created by a procedure declaration or a procedure -- body that acts as its own declaration. (Sm (Anonymous_Masters, Elist_Id), Sm (Associated_Node_For_Itype, Node_Id), Sm (Corresponding_Function, Node_Id), Sm (DT_Position, Uint, Pre_Get => "Present (DTC_Entity (N))"), Sm (DTC_Entity, Node_Id), Sm (Entry_Parameters_Type, Node_Id), Sm (Generic_Renamings, Elist_Id), Sm (Handler_Records, List_Id), Sm (Inner_Instances, Elist_Id), Sm (Is_Asynchronous, Flag), Sm (Is_Called, Flag), Sm (Is_CUDA_Kernel, Flag), Sm (Is_DIC_Procedure, Flag), Sm (Is_Generic_Actual_Subprogram, Flag), Sm (Is_Initial_Condition_Procedure, Flag), Sm (Is_Inlined_Always, Flag), Sm (Is_Invariant_Procedure, Flag), Sm (Is_Null_Init_Proc, Flag), Sm (Is_Partial_Invariant_Procedure, Flag), Sm (Is_Predicate_Function, Flag), Sm (Is_Predicate_Function_M, Flag), Sm (Is_Primitive_Wrapper, Flag), Sm (Is_Private_Primitive, Flag), Sm (Is_Valued_Procedure, Flag), Sm (LSP_Subprogram, Node_Id), Sm (Next_Inlined_Subprogram, Node_Id), Sm (Original_Protected_Subprogram, Node_Id), Sm (Postconditions_Proc, Node_Id), Sm (Protected_Subprogram, Node_Id), Sm (Protection_Object, Node_Id), Sm (Receiving_Entry, Node_Id), Sm (Static_Initialization, Node_Id, Pre => "not Is_Dispatching_Operation (N)"), Sm (Thunk_Entity, Node_Id, Pre => "Is_Thunk (N)"), Sm (Wrapped_Entity, Node_Id, Pre => "Is_Primitive_Wrapper (N)"))); Cc (E_Abstract_State, Overloadable_Kind, -- A state abstraction. Used to designate entities introduced by aspect -- or pragma Abstract_State. The entity carries the various properties -- of the state. (Sm (Body_References, Elist_Id), Sm (Encapsulating_State, Node_Id), Sm (First_Entity, Node_Id), Sm (Has_Partial_Visible_Refinement, Flag), Sm (Has_Visible_Refinement, Flag), Sm (Non_Limited_View, Node_Id), Sm (Part_Of_Constituents, Elist_Id), Sm (Refinement_Constituents, Elist_Id), Sm (SPARK_Pragma, Node_Id), Sm (SPARK_Pragma_Inherited, Flag))); Cc (E_Entry, Overloadable_Kind, -- An entry, created by an entry declaration in a task or protected -- object. (Sm (Accept_Address, Elist_Id), Sm (Barrier_Function, Node_Id), Sm (Contract, Node_Id), Sm (Contract_Wrapper, Node_Id), Sm (Elaboration_Entity, Node_Id), Sm (Elaboration_Entity_Required, Flag), Sm (Entry_Accepted, Flag), Sm (Entry_Parameters_Type, Node_Id), Sm (First_Entity, Node_Id), Sm (Has_Out_Or_In_Out_Parameter, Flag), Sm (Ignore_SPARK_Mode_Pragmas, Flag), Sm (Is_Elaboration_Checks_OK_Id, Flag), Sm (Is_Elaboration_Warnings_OK_Id, Flag), Sm (Last_Entity, Node_Id), Sm (Postconditions_Proc, Node_Id), Sm (Protected_Body_Subprogram, Node_Id), Sm (Protection_Object, Node_Id), Sm (Scope_Depth_Value, Unat), Sm (SPARK_Pragma, Node_Id), Sm (SPARK_Pragma_Inherited, Flag))); Cc (E_Entry_Family, Entity_Kind, -- An entry family, created by an entry family declaration in a -- task or protected type definition. (Sm (Accept_Address, Elist_Id), Sm (Barrier_Function, Node_Id), Sm (Contract, Node_Id), Sm (Contract_Wrapper, Node_Id), Sm (Elaboration_Entity, Node_Id), Sm (Elaboration_Entity_Required, Flag), Sm (Entry_Accepted, Flag), Sm (Entry_Parameters_Type, Node_Id), Sm (Extra_Formals, Node_Id), Sm (First_Entity, Node_Id), Sm (Has_Out_Or_In_Out_Parameter, Flag), Sm (Ignore_SPARK_Mode_Pragmas, Flag), Sm (Is_Elaboration_Checks_OK_Id, Flag), Sm (Is_Elaboration_Warnings_OK_Id, Flag), Sm (Last_Entity, Node_Id), Sm (Needs_No_Actuals, Flag), Sm (Postconditions_Proc, Node_Id), Sm (Protected_Body_Subprogram, Node_Id), Sm (Protection_Object, Node_Id), Sm (Renamed_Or_Alias, Node_Id), Sm (Scope_Depth_Value, Unat), Sm (SPARK_Pragma, Node_Id), Sm (SPARK_Pragma_Inherited, Flag))); Cc (E_Block, Entity_Kind, -- A block identifier, created by an explicit or implicit label on -- a block or declare statement. (Sm (Block_Node, Node_Id), Sm (Entry_Cancel_Parameter, Node_Id), Sm (First_Entity, Node_Id), Sm (Is_Exception_Handler, Flag), Sm (Last_Entity, Node_Id), Sm (Renamed_Or_Alias, Node_Id), Sm (Return_Applies_To, Node_Id), Sm (Scope_Depth_Value, Unat))); Cc (E_Entry_Index_Parameter, Entity_Kind, -- An entry index parameter created by an entry index specification -- for the body of a protected entry family. (Sm (Entry_Index_Constant, Node_Id))); Cc (E_Exception, Exception_Or_Object_Kind, -- An exception created by an exception declaration. The exception -- itself uses E_Exception for the Ekind, the implicit type that is -- created to represent its type uses the Ekind E_Exception_Type. (Sm (Alignment, Unat), Sm (Esize, Uint), Sm (Interface_Name, Node_Id), Sm (Is_Raised, Flag), Sm (Register_Exception_Call, Node_Id), Sm (Renamed_Or_Alias, Node_Id))); Ab (Generic_Unit_Kind, Entity_Kind, (Sm (Body_Needed_For_SAL, Flag), Sm (Contract, Node_Id), Sm (Elaboration_Entity, Node_Id), Sm (Elaboration_Entity_Required, Flag), Sm (First_Entity, Node_Id), Sm (Ignore_SPARK_Mode_Pragmas, Flag), Sm (Inner_Instances, Elist_Id), Sm (Interface_Name, Node_Id), Sm (Is_Elaboration_Checks_OK_Id, Flag), Sm (Is_Elaboration_Warnings_OK_Id, Flag), Sm (Last_Entity, Node_Id), Sm (Renamed_Or_Alias, Node_Id), Sm (Scope_Depth_Value, Unat), Sm (SPARK_Pragma, Node_Id), Sm (SPARK_Pragma_Inherited, Flag))); Ab (Generic_Subprogram_Kind, Generic_Unit_Kind, (Sm (Has_Out_Or_In_Out_Parameter, Flag), Sm (Is_Primitive, Flag), Sm (Next_Inlined_Subprogram, Node_Id), Sm (Overridden_Operation, Node_Id))); Cc (E_Generic_Function, Generic_Subprogram_Kind, -- A generic function. This is the entity for a generic function -- created by a generic subprogram declaration. (Sm (Has_Missing_Return, Flag))); Cc (E_Generic_Procedure, Generic_Subprogram_Kind); -- A generic function. This is the entity for a generic procedure -- created by a generic subprogram declaration. Cc (E_Generic_Package, Generic_Unit_Kind, -- A generic package, this is the entity for a generic package created -- by a generic package declaration. (Sm (Abstract_States, Elist_Id), Sm (Body_Entity, Node_Id), Sm (First_Private_Entity, Node_Id), Sm (Generic_Homonym, Node_Id), Sm (Package_Instantiation, Node_Id), Sm (SPARK_Aux_Pragma, Node_Id), Sm (SPARK_Aux_Pragma_Inherited, Flag))); Cc (E_Label, Entity_Kind, -- The defining entity for a label. Note that this is created by the -- implicit label declaration, not the occurrence of the label itself, -- which is simply a direct name referring to the label. (Sm (Enclosing_Scope, Node_Id), Sm (Renamed_Or_Alias, Node_Id))); Cc (E_Loop, Entity_Kind, -- A loop identifier, created by an explicit or implicit label on a -- loop statement. (Sm (First_Entity, Node_Id), Sm (First_Exit_Statement, Node_Id), Sm (Has_Loop_Entry_Attributes, Flag), Sm (Last_Entity, Node_Id), Sm (Renamed_Or_Alias, Node_Id), Sm (Scope_Depth_Value, Unat))); Cc (E_Return_Statement, Entity_Kind, -- A dummy entity created for each return statement. Used to hold -- information about the return statement (what it applies to) and in -- rules checking. For example, a simple_return_statement that applies -- to an extended_return_statement cannot have an expression; this -- requires putting the E_Return_Statement entity for the -- extended_return_statement on the scope stack. (Sm (First_Entity, Node_Id), Sm (Last_Entity, Node_Id), Sm (Return_Applies_To, Node_Id), Sm (Scope_Depth_Value, Unat))); Cc (E_Package, Entity_Kind, -- A package, created by a package declaration (Sm (Abstract_States, Elist_Id), Sm (Anonymous_Masters, Elist_Id), Sm (Associated_Formal_Package, Node_Id), Sm (Body_Entity, Node_Id), Sm (Body_Needed_For_Inlining, Flag), Sm (Body_Needed_For_SAL, Flag), Sm (Contract, Node_Id), Sm (Current_Use_Clause, Node_Id), Sm (Dependent_Instances, Elist_Id, Pre => "Is_Generic_Instance (N)"), Sm (Elaborate_Body_Desirable, Flag), Sm (Elaboration_Entity, Node_Id), Sm (Elaboration_Entity_Required, Flag), Sm (Finalizer, Node_Id), Sm (First_Entity, Node_Id), Sm (First_Private_Entity, Node_Id), Sm (Generic_Renamings, Elist_Id), Sm (Handler_Records, List_Id), Sm (Has_RACW, Flag), Sm (Hidden_In_Formal_Instance, Elist_Id), Sm (Ignore_SPARK_Mode_Pragmas, Flag), Sm (Incomplete_Actuals, Elist_Id), Sm (Inner_Instances, Elist_Id), Sm (Interface_Name, Node_Id), Sm (Is_Called, Flag), Sm (Is_Elaboration_Checks_OK_Id, Flag), Sm (Is_Elaboration_Warnings_OK_Id, Flag), Sm (Last_Entity, Node_Id), Sm (Limited_View, Node_Id), Sm (Package_Instantiation, Node_Id), Sm (Related_Instance, Node_Id), Sm (Renamed_In_Spec, Flag), Sm (Renamed_Or_Alias, Node_Id), Sm (Scope_Depth_Value, Unat), Sm (SPARK_Aux_Pragma, Node_Id), Sm (SPARK_Aux_Pragma_Inherited, Flag), Sm (SPARK_Pragma, Node_Id), Sm (SPARK_Pragma_Inherited, Flag), Sm (Static_Elaboration_Desired, Flag))); Cc (E_Package_Body, Entity_Kind, -- A package body. This entity serves only limited functions, since -- most semantic analysis uses the package entity (E_Package). However -- there are some attributes that are significant for the body entity. -- For example, collection of exception handlers. (Sm (Contract, Node_Id), Sm (Finalizer, Node_Id), Sm (First_Entity, Node_Id), Sm (Handler_Records, List_Id), Sm (Ignore_SPARK_Mode_Pragmas, Flag), Sm (Last_Entity, Node_Id), Sm (Related_Instance, Node_Id), Sm (Renamed_Or_Alias, Node_Id), Sm (Scope_Depth_Value, Unat), Sm (SPARK_Aux_Pragma, Node_Id), Sm (SPARK_Aux_Pragma_Inherited, Flag), Sm (SPARK_Pragma, Node_Id), Sm (SPARK_Pragma_Inherited, Flag), Sm (Spec_Entity, Node_Id))); Ab (Concurrent_Body_Kind, Entity_Kind, (Sm (Ignore_SPARK_Mode_Pragmas, Flag), Sm (SPARK_Pragma, Node_Id), Sm (SPARK_Pragma_Inherited, Flag))); Cc (E_Protected_Body, Concurrent_Body_Kind); -- A protected body. This entity serves almost no function, since all -- semantic analysis uses the protected entity (E_Protected_Type). Cc (E_Task_Body, Concurrent_Body_Kind, -- A task body. This entity serves almost no function, since all -- semantic analysis uses the protected entity (E_Task_Type). (Sm (Contract, Node_Id), Sm (First_Entity, Node_Id))); Cc (E_Subprogram_Body, Entity_Kind, -- A subprogram body. Used when a subprogram has a separate declaration -- to represent the entity for the body. This entity serves almost no -- function, since all semantic analysis uses the subprogram entity -- for the declaration (E_Function or E_Procedure). (Sm (Anonymous_Masters, Elist_Id), Sm (Contract, Node_Id), Sm (Extra_Formals, Node_Id), Sm (First_Entity, Node_Id), Sm (Ignore_SPARK_Mode_Pragmas, Flag), Sm (Interface_Name, Node_Id), Sm (Last_Entity, Node_Id), Sm (Renamed_Or_Alias, Node_Id), Sm (Scope_Depth_Value, Unat), Sm (SPARK_Pragma, Node_Id), Sm (SPARK_Pragma_Inherited, Flag))); -- Union types. These don't fit into the normal parent/child hierarchy -- above. Union (Anonymous_Access_Kind, Children => (E_Anonymous_Access_Protected_Subprogram_Type, E_Anonymous_Access_Subprogram_Type, E_Anonymous_Access_Type)); Union (Assignable_Kind, Children => (E_Variable, E_Out_Parameter, E_In_Out_Parameter)); Union (Digits_Kind, Children => (Decimal_Fixed_Point_Kind, Float_Kind)); Union (Discrete_Or_Fixed_Point_Kind, Children => (Discrete_Kind, Fixed_Point_Kind)); Union (Entry_Kind, Children => (E_Entry, E_Entry_Family)); Union (Evaluable_Kind, Children => (Exception_Or_Object_Kind, E_Enumeration_Literal, E_Label, Subprogram_Kind)); -- Kinds that represent values that can be evaluated Union (Global_Name_Kind, Children => (Constant_Or_Variable_Kind, E_Exception, E_Package, Subprogram_Kind)); -- Kinds that can have an Interface_Name that corresponds to a global -- (linker) name. Union (Named_Access_Kind, Children => (E_Access_Type, E_Access_Subtype, E_Access_Attribute_Type, E_Allocator_Type, E_General_Access_Type, E_Access_Subprogram_Type, E_Access_Protected_Subprogram_Type)); Union (Numeric_Kind, Children => (Integer_Kind, Fixed_Point_Kind, Float_Kind)); Union (Record_Kind, Children => (E_Class_Wide_Type, E_Class_Wide_Subtype, E_Record_Type, E_Record_Subtype, E_Record_Type_With_Private, E_Record_Subtype_With_Private)); Union (Subprogram_Type_Or_Kind, Children => (Subprogram_Kind, E_Subprogram_Body, E_Subprogram_Type)); end Gen_IL.Gen.Gen_Entities;
stcarrez/sql-benchmark
Ada
25,383
adb
----------------------------------------------------------------------- -- tool-data -- Perf data representation -- Copyright (C) 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.Text_IO; with Ada.Strings.Fixed; with Util.Strings; with Util.Log.Loggers; with Util.Serialize.IO.XML; with Util.Strings.Tokenizers; with Excel_Out; package body Tool.Data is use type Ada.Containers.Count_Type; use type Ada.Text_IO.Positive_Count; Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Tool.Data"); function Parse_Time (Value : in String) return Duration; function Get_Title (Value : in String) return String; function Get_Value (Value : in String) return Row_Count_Type; procedure Collect_Result (Into : in out Perf_Result; Driver : in Driver_Type; Result : in Result_Type); procedure Add_Driver (Benchmark : in out Benchmark_Info); function Format (Value : in Duration) return String; function Format_Us (Value : in Duration) return String; Empty_Perf : Perf_Map; Empty_Perf_Result : Perf_Result; function Parse_Time (Value : in String) return Duration is Pos : constant Natural := Util.Strings.Index (Value, ' '); Result : Duration; begin Result := Duration'Value (Value (Value'First .. Pos - 1)); if Value (Pos + 1 .. Value'Last) = "ns" then Result := Result / 1_000_000_000; elsif Value (Pos + 1 .. Value'Last) = "us" then Result := Result / 1_000_000; elsif Value (Pos + 1 .. Value'Last) = "ms" then Result := Result / 1_000; end if; return Result; end Parse_Time; function Get_Title (Value : in String) return String is Pos : constant Natural := Util.Strings.Rindex (Value, ' '); begin if Pos = 0 or Value'Length < String '("SELECT * FROM")'Length then return Value; end if; for C of Value (Pos + 1 .. Value'Last) loop if not (C in '0' .. '9') then return Value; end if; end loop; return Value (Value'First .. Pos - 1); end Get_Title; function Get_Value (Value : in String) return Row_Count_Type is Pos : constant Natural := Util.Strings.Rindex (Value, ' '); begin if Value'Length < String '("SELECT * FROM")'Length then return 0; else return Row_Count_Type'Value (Value (Pos + 1 .. Value'Last)); end if; exception when Constraint_Error => return 0; end Get_Value; function Format (Value : in Duration) return String is begin if Value < 0.000_001 then return Duration'Image (Value * 1_000_000_000) (1 .. 6) & " ns"; elsif Value < 0.001 then return Duration'Image (Value * 1_000_000) (1 .. 6) & " us"; elsif Value < 1.0 then return Duration'Image (Value * 1_000) (1 .. 6) & " ms"; else return Duration'Image (Value) (1 .. 6) & " s"; end if; end Format; function Format_Us (Value : in Duration) return String is Result : constant String := Duration'Image (Value * 1_000_000); Pos : Positive := Result'Last; begin -- Drop leading zeros. while Pos > Result'First and then Result (Pos) = '0' and then Result (Pos - 1) /= '.' loop Pos := Pos - 1; end loop; return Result (Result'First .. Pos); end Format_Us; procedure Collect_Result (Into : in out Perf_Result; Driver : in Driver_Type; Result : in Result_Type) is procedure Update (Item : in out Result_Type); procedure Update (Item : in out Result_Type) is begin Item.Count := Item.Count + Result.Count; Item.Time := Item.Time + Result.Time; end Update; begin while Into.Results.Length < Ada.Containers.Count_Type (Driver) loop Into.Results.Append (Result_Type '(Count => 0, Time => 0.0)); end loop; Into.Results.Update_Element (Driver, Update'Access); end Collect_Result; procedure Add_Driver (Benchmark : in out Benchmark_Info) is procedure Update_Driver (Key : in String; Driver : in out Driver_Result); Database : constant String := UBO.To_String (Benchmark.Driver); Language : constant String := UBO.To_String (Benchmark.Language); Pos : Driver_Cursor := Benchmark.Drivers.Find (Language & " " & Database); New_Driver : Driver_Result; procedure Update_Driver (Key : in String; Driver : in out Driver_Result) is pragma Unreferenced (Key); begin Driver.Count := Driver.Count + 1; Driver.Rss_Size := Driver.Rss_Size + Benchmark.Rss_Size; Driver.Peek_Rss := Driver.Peek_Rss + Benchmark.Peek_Rss_Size; Driver.Thread_Count := Driver.Thread_Count + Benchmark.Thread_Count; Driver.User_Time := Driver.User_Time + Benchmark.User_Time; Driver.Sys_Time := Driver.Sys_Time + Benchmark.Sys_Time; Driver.Language := Benchmark.Language_Index; Driver.Database := Benchmark.Database_Index; Driver.Index := Benchmark.Driver_Index; end Update_Driver; begin Log.Debug ("Adding driver {0} {1}", Language, Database); if UBO.Is_Null (Benchmark.Driver) or else UBO.Is_Null (Benchmark.Language) then return; end if; if not Driver_Maps.Has_Element (Pos) then New_Driver.Index := Driver_Type (Benchmark.Drivers.Length + 1); Benchmark.Drivers.Insert (Language & " " & Database, New_Driver); Pos := Benchmark.Drivers.Find (Language & " " & Database); end if; Benchmark.Database_Index := Benchmark.Databases.Find_Index (Database); Benchmark.Language_Index := Benchmark.Languages.Find_Index (Language); Benchmark.Driver_Index := Driver_Maps.Element (Pos).Index; Benchmark.Drivers.Update_Element (Pos, Update_Driver'Access); end Add_Driver; procedure Set_Member (Benchmark : in out Benchmark_Info; Field : in Benchmark_Fields; Value : in UBO.Object) is begin case Field is when FIELD_DRIVER => if not Benchmark.Databases.Contains (UBO.To_String (Value)) then Benchmark.Databases.Append (UBO.To_String (Value)); end if; Benchmark.Driver := Value; when FIELD_LANGUAGE => if not Benchmark.Languages.Contains (UBO.To_String (Value)) then Benchmark.Languages.Append (UBO.To_String (Value)); end if; Benchmark.Language := Value; when FIELD_THREADS => Benchmark.Thread_Count := UBO.To_Integer (Value); when FIELD_RSS_SIZE => Benchmark.Rss_Size := UBO.To_Integer (Value); when FIELD_PEEK_RSS_SIZE => Benchmark.Peek_Rss_Size := UBO.To_Integer (Value); when FIELD_USER_TIME => Benchmark.User_Time := UBO.To_Integer (Value); when FIELD_SYS_TIME => Benchmark.Sys_Time := UBO.To_Integer (Value); when FIELD_MEASURES => Add_Driver (Benchmark); when FIELD_COUNT => Benchmark.Count := Count_Type (UBO.To_Integer (Value)); when FIELD_TITLE => Benchmark.Title := Value; when FIELD_TOTAL => Benchmark.Time := Parse_Time (UBO.To_String (Value)); when FIELD_TIME => declare procedure Update (Key : in String; Item : in out Perf_Map); procedure Update_Perf_Result (Key : in Row_Count_Type; Item : in out Perf_Result); Main_Title : constant String := UBO.To_String (Benchmark.Title); Title : constant String := Get_Title (Main_Title); Value : constant Row_Count_Type := Get_Value (Main_Title); Pos : Benchmark_Cursor := Benchmark.Benchmarks.Find (Title); Result : Result_Type; procedure Update_Perf_Result (Key : in Row_Count_Type; Item : in out Perf_Result) is pragma Unreferenced (Key); begin Collect_Result (Item, Benchmark.Driver_Index, Result); end Update_Perf_Result; procedure Update (Key : in String; Item : in out Perf_Map) is pragma Unreferenced (Key); Pos : Perf_Cursor := Item.Find (Value); begin if not Perf_Result_Maps.Has_Element (Pos) then Item.Insert (Value, Empty_Perf_Result); Pos := Item.Find (Value); end if; Item.Update_Element (Pos, Update_Perf_Result'Access); end Update; begin Result.Count := Benchmark.Count; Result.Time := Benchmark.Time; if not Benchmark_Maps.Has_Element (Pos) then Benchmark.Benchmarks.Insert (Title, Empty_Perf); Pos := Benchmark.Benchmarks.Find (Title); end if; Benchmark.Benchmarks.Update_Element (Pos, Update'Access); end; end case; end Set_Member; Mapping : aliased Benchmark_Mapper.Mapper; Benchmark : aliased Benchmark_Info; procedure Read (Path : in String) is Mapper : Util.Serialize.Mappers.Processing; Reader : Util.Serialize.IO.XML.Parser; begin Benchmark.User_Time := 0; Benchmark.Sys_Time := 0; Benchmark.Thread_Count := 0; Benchmark.Rss_Size := 0; Benchmark.Peek_Rss_Size := 0; Benchmark.Language := UBO.Null_Object; Benchmark.Driver := UBO.Null_Object; Mapper.Add_Mapping ("benchmark", Mapping'Access); Benchmark_Mapper.Set_Context (Mapper, Benchmark'Access); Reader.Parse (Path, Mapper); end Read; procedure Save_Memory (Path : in String; Languages : in String) is procedure Process_Language (Token : in String; Done : out Boolean); File : Ada.Text_IO.File_Type; procedure Process_Language (Token : in String; Done : out Boolean) is L : constant Language_Type := Benchmark.Languages.Find_Index (Token); begin Done := False; for D in Benchmark.Drivers.Iterate loop declare Driver : constant Driver_Result := Driver_Maps.Element (D); begin if Driver.Language = L then Ada.Text_IO.Put (File, Benchmark.Databases.Element (Driver.Database)); Ada.Text_IO.Set_Col (File, 20); Ada.Text_IO.Put (File, Benchmark.Languages.Element (L)); Ada.Text_IO.Set_Col (File, 30); Ada.Text_IO.Put (File, Natural'Image (Driver.User_Time)); Ada.Text_IO.Set_Col (File, 40); Ada.Text_IO.Put (File, Natural'Image (Driver.Sys_Time)); Ada.Text_IO.Set_Col (File, 60); Ada.Text_IO.Put (File, Natural'Image (Driver.Peek_Rss)); Ada.Text_IO.Set_Col (File, 70); Ada.Text_IO.Put (File, Natural'Image (Driver.Thread_Count)); Ada.Text_IO.New_Line (File); end if; end; end loop; Ada.Text_IO.New_Line (File); Ada.Text_IO.New_Line (File); end Process_Language; begin Ada.Text_IO.Create (File => File, Mode => Ada.Text_IO.Out_File, Name => Path); Util.Strings.Tokenizers.Iterate_Tokens (Content => Languages, Pattern => ",", Process => Process_Language'Access); Ada.Text_IO.Close (File); end Save_Memory; procedure Save (Path : in String; Databases : in String; Languages : in String) is procedure Process_Database (Token : in String; Done : out Boolean); procedure Process_Language (Token : in String; Done : out Boolean); DB_Count : constant Natural := Ada.Strings.Fixed.Count (Databases, ",") + 1; DB_List : Database_Array_Index (1 .. DB_Count); Lang_Count : constant Natural := Ada.Strings.Fixed.Count (Languages, ",") + 1; Lang_List : Language_Array_Index (1 .. Lang_Count); Pos : Positive := 1; Col : Ada.Text_IO.Positive_Count; File : Ada.Text_IO.File_Type; procedure Process_Database (Token : in String; Done : out Boolean) is begin DB_List (Pos) := Benchmark.Databases.Find_Index (Token); Pos := Pos + 1; Done := False; end Process_Database; procedure Process_Language (Token : in String; Done : out Boolean) is begin Lang_List (Pos) := Benchmark.Languages.Find_Index (Token); Pos := Pos + 1; Done := False; end Process_Language; begin Util.Strings.Tokenizers.Iterate_Tokens (Content => Databases, Pattern => ",", Process => Process_Database'Access); Pos := 1; Util.Strings.Tokenizers.Iterate_Tokens (Content => Languages, Pattern => ",", Process => Process_Language'Access); Ada.Text_IO.Create (File => File, Mode => Ada.Text_IO.Out_File, Name => Path); -- Print performance results. Ada.Text_IO.Put (File, "# order is "); Ada.Text_IO.Put (File, Databases); Ada.Text_IO.Put (File, " and "); Ada.Text_IO.Put (File, Languages); Ada.Text_IO.New_Line (File); for C in Benchmark.Benchmarks.Iterate loop for P in Benchmark_Maps.Element (C).Iterate loop if Perf_Result_Maps.Key (P) > 0 then Ada.Text_IO.Put (File, Row_Count_Type'Image (Perf_Result_Maps.Key (P))); for DB_Index of DB_List loop for Lang_Index of Lang_List loop declare Database : constant String := Benchmark.Databases.Element (DB_Index); Language : constant String := Benchmark.Languages.Element (Lang_Index); Key : constant String := Language & " " & Database; Driver : constant Driver_Cursor := Benchmark.Drivers.Find (Key); R : Result_Type; Index : Driver_Type; begin if Driver_Maps.Has_Element (Driver) then Index := Driver_Maps.Element (Driver).Index; if Perf_Result_Maps.Element (P).Results.Last_Index >= Index then R := Perf_Result_Maps.Element (P).Results.Element (Index); if R.Count > 0 then Ada.Text_IO.Put (File, Format_Us (R.Time / Positive (R.Count))); else Ada.Text_IO.Put (File, " 0"); end if; else Ada.Text_IO.Put (File, " 0"); end if; else Ada.Text_IO.Put (File, " 0"); end if; end; end loop; end loop; Ada.Text_IO.New_Line (File); end if; end loop; end loop; -- Print results grouped by benchmark. for C in Benchmark.Benchmarks.Iterate loop for P in Benchmark_Maps.Element (C).Iterate loop declare Row_Count : constant Row_Count_Type := Perf_Result_Maps.Key (P); begin Ada.Text_IO.New_Line; Ada.Text_IO.Put ("## "); if Row_Count > 0 then Ada.Text_IO.Put (Benchmark_Maps.Key (C) & Row_Count_Type'Image (Row_Count)); else Ada.Text_IO.Put (Benchmark_Maps.Key (C)); end if; Ada.Text_IO.New_Line; Ada.Text_IO.New_Line; Ada.Text_IO.Put ("| "); Col := 25; for DB_Index of DB_List loop Ada.Text_IO.Set_Col (Col); Ada.Text_IO.Put ("| "); Ada.Text_IO.Put (Benchmark.Databases.Element (DB_Index)); Col := Col + 16; end loop; Ada.Text_IO.Set_Col (Col); Ada.Text_IO.Put_Line ("|"); Ada.Text_IO.Put ("|-----------------------|"); for DB_Index of DB_List loop Ada.Text_IO.Put ("---------------|"); end loop; Ada.Text_IO.New_Line; for L in 1 .. Benchmark.Languages.Last_Index loop declare Language : constant String := Benchmark.Languages.Element (L); begin Ada.Text_IO.Put ("| "); Ada.Text_IO.Put (Language); Col := 25; for DB_Index of DB_List loop declare Database : constant String := Benchmark.Databases.Element (DB_Index); Key : constant String := Language & " " & Database; Driver : constant Driver_Cursor := Benchmark.Drivers.Find (Key); R : Result_Type; Index : Driver_Type; begin Ada.Text_IO.Set_Col (Col); Ada.Text_IO.Put ("| "); if Driver_Maps.Has_Element (Driver) then Index := Driver_Maps.Element (Driver).Index; if Perf_Result_Maps.Element (P).Results.Last_Index >= Index then R := Perf_Result_Maps.Element (P).Results.Element (Index); if R.Count > 0 then Ada.Text_IO.Put (Format (R.Time / Positive (R.Count))); end if; end if; end if; end; Col := Col + 16; end loop; Ada.Text_IO.Set_Col (Col); Ada.Text_IO.Put_Line ("|"); end; end loop; end; end loop; end loop; end Save; procedure Save_Excel (Path : in String) is File : Excel_Out.Excel_Out_File; Row : Positive := 1; Col : Positive := 1; Font_Title : Excel_Out.Font_type; Font_Sub : Excel_Out.Font_type; Font_Cell : Excel_Out.Font_type; Fmt_Title : Excel_Out.Format_type; Fmt_Value : Excel_Out.Format_type; Fmt_Lang : Excel_Out.Format_type; Fmt_Database : Excel_Out.Format_type; begin File.Create (Path); File.Header ("Driver SQL Benchmark"); File.Footer ("sql-benchmark"); File.Margins (1.2, 1.1, 0.9, 0.8); File.Page_Setup (scaling_percents => 100, fit_width_with_n_pages => 0, orientation => Excel_Out.portrait, scale_or_fit => Excel_Out.fit); File.Write_column_width (1, 15); File.Write_column_width (2, 20); File.Write_column_width (3, 20); File.Write_column_width (4, 20); File.Define_font ("Calibri", 14, Font_Title, Excel_Out.bold); File.Define_font ("Calibri", 12, Font_Sub, Excel_Out.bold); File.Define_font ("Calibri", 12, Font_Cell, Excel_Out.regular); File.Define_format (font => Font_Title, number_format => Excel_Out.general, cell_format => Fmt_Title); File.Define_format (font => Font_Cell, number_format => Excel_Out.general, border => Excel_Out.box, cell_format => Fmt_Value); File.Define_format (font => Font_Sub, number_format => Excel_Out.general, cell_format => Fmt_Lang, border => Excel_Out.box); File.Define_format (font => Font_Sub, number_format => Excel_Out.general, cell_format => Fmt_Database, border => Excel_Out.box); for C in Benchmark.Benchmarks.Iterate loop for P in Benchmark_Maps.Element (C).Iterate loop declare Row_Count : constant Row_Count_Type := Perf_Result_Maps.Key (P); begin Row := Row + 2; File.Use_format (Fmt_Title); if Row_Count > 0 then File.Write (Row, 2, Benchmark_Maps.Key (C) & Row_Count_Type'Image (Row_Count)); else File.Write (Row, 2, Benchmark_Maps.Key (C)); end if; File.Use_format (Fmt_Database); Row := Row + 1; Col := 2; for Database of Benchmark.Databases loop File.Write (Row, Col, Database); Col := Col + 1; end loop; for L in 1 .. Benchmark.Languages.Last_Index loop declare Language : constant String := Benchmark.Languages.Element (L); begin Row := Row + 1; File.Use_format (Fmt_Lang); File.Write (Row, 1, Language); File.Use_format (Fmt_Value); Col := 2; for D in 1 .. Benchmark.Databases.Last_Index loop declare Database : constant String := Benchmark.Databases.Element (D); Key : constant String := Language & " " & Database; Driver : constant Driver_Cursor := Benchmark.Drivers.Find (Key); R : Result_Type; Index : Driver_Type; begin if Driver_Maps.Has_Element (Driver) then Index := Driver_Maps.Element (Driver).Index; if Perf_Result_Maps.Element (P).Results.Last_Index >= Index then R := Perf_Result_Maps.Element (P).Results.Element (Index); if R.Count > 0 then File.Write (Row, Col, Format (R.Time / Positive (R.Count))); end if; end if; end if; end; Col := Col + 1; end loop; end; end loop; end; end loop; end loop; File.Close; end Save_Excel; begin Mapping.Add_Mapping ("@driver", FIELD_DRIVER); Mapping.Add_Mapping ("@language", FIELD_LANGUAGE); Mapping.Add_Mapping ("@threads", FIELD_THREADS); Mapping.Add_Mapping ("@rss_size", FIELD_RSS_SIZE); Mapping.Add_Mapping ("@peek_rss_size", FIELD_PEEK_RSS_SIZE); Mapping.Add_Mapping ("@user_time", FIELD_USER_TIME); Mapping.Add_Mapping ("@sys_time", FIELD_SYS_TIME); Mapping.Add_Mapping ("measures/@title", FIELD_MEASURES); Mapping.Add_Mapping ("measures/time/@count", FIELD_COUNT); Mapping.Add_Mapping ("measures/time/@total", FIELD_TOTAL); Mapping.Add_Mapping ("measures/time/@title", FIELD_TITLE); Mapping.Add_Mapping ("measures/time", FIELD_TIME); end Tool.Data;
zhmu/ananas
Ada
6,064
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . W I D E _ W I D E _ T E X T _ I O . C O M P L E X _ A U X -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Ada.Wide_Wide_Text_IO.Generic_Aux; use Ada.Wide_Wide_Text_IO.Generic_Aux; package body Ada.Wide_Wide_Text_IO.Complex_Aux is --------- -- Get -- --------- procedure Get (File : File_Type; ItemR : out Num; ItemI : out Num; Width : Field) is Buf : String (1 .. Field'Last); Stop : Integer := 0; Ptr : aliased Integer; Paren : Boolean := False; begin -- General note for following code, exceptions from the calls -- to Get for components of the complex value are propagated. if Width /= 0 then Load_Width (File, Width, Buf, Stop); Gets (Buf (1 .. Stop), ItemR, ItemI, Ptr); for J in Ptr + 1 .. Stop loop if not Is_Blank (Buf (J)) then raise Data_Error; end if; end loop; -- Case of width = 0 else Load_Skip (File); Ptr := 0; Load (File, Buf, Ptr, '(', Paren); Aux.Get (File, ItemR, 0); Load_Skip (File); Load (File, Buf, Ptr, ','); Aux.Get (File, ItemI, 0); if Paren then Load_Skip (File); Load (File, Buf, Ptr, ')', Paren); if not Paren then raise Data_Error; end if; end if; end if; end Get; ---------- -- Gets -- ---------- procedure Gets (From : String; ItemR : out Num; ItemI : out Num; Last : out Positive) is Paren : Boolean; Pos : Integer; begin String_Skip (From, Pos); if From (Pos) = '(' then Pos := Pos + 1; Paren := True; else Paren := False; end if; Aux.Gets (From (Pos .. From'Last), ItemR, Pos); String_Skip (From (Pos + 1 .. From'Last), Pos); if From (Pos) = ',' then Pos := Pos + 1; end if; Aux.Gets (From (Pos .. From'Last), ItemI, Pos); if Paren then String_Skip (From (Pos + 1 .. From'Last), Pos); if From (Pos) /= ')' then raise Data_Error; end if; end if; Last := Pos; end Gets; --------- -- Put -- --------- procedure Put (File : File_Type; ItemR : Num; ItemI : Num; Fore : Field; Aft : Field; Exp : Field) is begin Put (File, '('); Aux.Put (File, ItemR, Fore, Aft, Exp); Put (File, ','); Aux.Put (File, ItemI, Fore, Aft, Exp); Put (File, ')'); end Put; ---------- -- Puts -- ---------- procedure Puts (To : out String; ItemR : Num; ItemI : Num; Aft : Field; Exp : Field) is I_String : String (1 .. 3 * Field'Last); R_String : String (1 .. 3 * Field'Last); Iptr : Natural; Rptr : Natural; begin -- Both parts are initially converted with a Fore of 0 Rptr := 0; Aux.Set_Image (ItemR, R_String, Rptr, 0, Aft, Exp); Iptr := 0; Aux.Set_Image (ItemI, I_String, Iptr, 0, Aft, Exp); -- Check room for both parts plus parens plus comma (RM G.1.3(34)) if Rptr + Iptr + 3 > To'Length then raise Layout_Error; end if; -- If there is room, layout result according to (RM G.1.3(31-33)) To (To'First) := '('; To (To'First + 1 .. To'First + Rptr) := R_String (1 .. Rptr); To (To'First + Rptr + 1) := ','; To (To'Last) := ')'; To (To'Last - Iptr .. To'Last - 1) := I_String (1 .. Iptr); for J in To'First + Rptr + 2 .. To'Last - Iptr - 1 loop To (J) := ' '; end loop; end Puts; end Ada.Wide_Wide_Text_IO.Complex_Aux;
reznikmm/matreshka
Ada
5,130
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. ------------------------------------------------------------------------------ with AMF.Generic_Collections; package AMF.UML.Variable_Actions.Collections is pragma Preelaborate; package UML_Variable_Action_Collections is new AMF.Generic_Collections (UML_Variable_Action, UML_Variable_Action_Access); type Set_Of_UML_Variable_Action is new UML_Variable_Action_Collections.Set with null record; Empty_Set_Of_UML_Variable_Action : constant Set_Of_UML_Variable_Action; type Ordered_Set_Of_UML_Variable_Action is new UML_Variable_Action_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_UML_Variable_Action : constant Ordered_Set_Of_UML_Variable_Action; type Bag_Of_UML_Variable_Action is new UML_Variable_Action_Collections.Bag with null record; Empty_Bag_Of_UML_Variable_Action : constant Bag_Of_UML_Variable_Action; type Sequence_Of_UML_Variable_Action is new UML_Variable_Action_Collections.Sequence with null record; Empty_Sequence_Of_UML_Variable_Action : constant Sequence_Of_UML_Variable_Action; private Empty_Set_Of_UML_Variable_Action : constant Set_Of_UML_Variable_Action := (UML_Variable_Action_Collections.Set with null record); Empty_Ordered_Set_Of_UML_Variable_Action : constant Ordered_Set_Of_UML_Variable_Action := (UML_Variable_Action_Collections.Ordered_Set with null record); Empty_Bag_Of_UML_Variable_Action : constant Bag_Of_UML_Variable_Action := (UML_Variable_Action_Collections.Bag with null record); Empty_Sequence_Of_UML_Variable_Action : constant Sequence_Of_UML_Variable_Action := (UML_Variable_Action_Collections.Sequence with null record); end AMF.UML.Variable_Actions.Collections;
jscparker/math_packages
Ada
3,047
ads
-- At the moment the overflow stacks raise the constraint_error -- if the array is full.. -- -- Quickly written mess, but all that matters is that the output is -- correctly sorted, so we just test this each time the routine is run. -- -- For a given X <= Max_Size_of_Item, we get its putative -- table index from X_Index := Size_of_X / S where S is some constant. -- require Max_Size_of_Item / S <= Table_Index'Last. -- or 1 + Max_Size_of_Item / S <= 1 + Table_Index'Last. -- using Max_Size_of_Item <= S * (1 + Max_Size_of_Item / S): -- Max_Size_of_Item <= S * (1 + Table_Index'Last). -- Finally, S >= 1 + Max_Size_of_Item / (1 + Table_Index'Last). -- -- -- put 10 items (the numbers 0..9) into 4 bins (with bin_id 0..3): -- -- Item is an x below: 0..Max_Size_of_Item-1 = 0..9, 9=Max_Size_of_Item -- -- |xxx|xxx|xxx|x00 -- -- Number of x's = 10 = 1 + Max_Size_of_Item = Max_No_of_Items -- Number of bins = 4 = 1 + Table_Index'Last = Size_of_Table -- Items_per_bin = 3 = 1 + (Max_No_of_Items-1) / No_of_Bins = S -- Items_per_bin = 3 = 1 + (Max_No_of_Items-1) / Size_of_Table = S -- -- bin_id = X / S = X / Items_per_bin -- Table_Index'Last is supposed to be >> Max_Allowed_No_of_Items -- Amazingly, equality of the 2 seems to work efficiently. I don't -- know why its efficient so I don't recommend it. -- -- Typical case: -- -- type Item is mod 2**63; -- -- Max_Size_of_Item := 2**48-1; -- Max_Allowed_No_of_Items := 2**26; -- -- type Table_Index is mod (2**26 + 2**24); generic type Item is mod <>; -- can be 64 bit int, but max value that the array can store -- is Max_Size_of_Item. (Here its 2**48-1). -- The Items are the Random ints produced by the generator. Max_Size_of_Item : Item; -- Here Max_Size_of_Item < 2**48 Max_Allowed_No_of_Items : Item; type Table_Index is mod <>; -- make big enough to hold: 0..Max_Allowed_No_of_Items-1, -- but make it much bigger than that. package Sorted_Array is pragma Assert (Table_Index'Last >= Table_Index (Max_Allowed_No_of_Items) + Table_Index (Max_Allowed_No_of_Items/8)); -- Table_Index'Last should be >> Max_Allowed_No_of_Items for best efficiency. -- Max_Allowed_No_of_Items/4 instead of /8 up there is better. -- 2 routines for updating the table: procedure Insert_and_Sort (X : in Item); procedure Initialize_Table_for_Restart; -- 2 routines for reading sequentially from the start: procedure Start_Reading_Array_at_Beginning; procedure Get_Next_Item (X : out Item; Item_is_Invalid : out Boolean); -- for reading the result: function No_of_Collisions_Detected return Table_Index; function Array_Sort_Successful return Boolean; -- for testing function No_of_Items_in_Low_Stack return Table_Index; Size_of_Overflow_Stacks : constant := 2**12; Items_per_Table_Entry : constant Item := 1 + Max_Size_of_Item / (Item (Table_Index'Last) + 1); end Sorted_Array;
pvrego/adaino
Ada
8,231
ads
with System; -- ============================================================================= -- Package AVR.TWI -- -- Implements TWI communication for the MCU micro-controller. -- ============================================================================= package AVR.TWI is type TWI_Status_Register_Type is record TWPS : Bit_Array_Type (0 .. 1); -- TWI Prescaler Bits Spare : Spare_Type (0 .. 0); TWS3 : Boolean; -- TWI Status Bit 3 TWS4 : Boolean; -- TWI Status Bit 4 TWS5 : Boolean; -- TWI Status Bit 5 TWS6 : Boolean; -- TWI Status Bit 6 TWS7 : Boolean; -- TWI Status Bit 7 end record; pragma Pack (TWI_Status_Register_Type); for TWI_Status_Register_Type'Size use BYTE_SIZE; type TWI_Slave_Address_Register_Type is record TWGCE : Boolean; -- TWI General Call Recognition Enable Bit TWA : Bit_Array_Type (0 .. 6); -- TWI Slave Address Register end record; pragma Pack (TWI_Slave_Address_Register_Type); for TWI_Slave_Address_Register_Type'Size use BYTE_SIZE; type TWI_Control_Register_Type is record TWIE : Boolean; -- TWI Interrupt Enable Spare : Spare_Type (0 .. 0); TWEN : Boolean; -- TWI Enable Bit TWWC : Boolean; -- TWI Write Collision Flag TWSTO : Boolean; -- TWI Stop Condition Bit TWSTA : Boolean; -- TWI Start Condition Bit TWEA : Boolean; -- TWI Enable Acknowledge Bit TWINT : Boolean; -- TWI Interrupt Flag end record; pragma Pack (TWI_Control_Register_Type); for TWI_Control_Register_Type'Size use BYTE_SIZE; type TWI_Slave_Address_Mask_Register_Type is record Spare : Spare_Type (0 .. 0); TWAM : Bit_Array_Type (0 .. 6); end record; pragma Pack (TWI_Slave_Address_Mask_Register_Type); for TWI_Slave_Address_Mask_Register_Type'Size use BYTE_SIZE; type TWI_Type is record TWBR : Byte_Type; -- TWI Bit Rate Register TWSR : TWI_Status_Register_Type; TWAR : TWI_Slave_Address_Register_Type; TWDR : Byte_Type; -- TWI Data Register TWCR : TWI_Control_Register_Type; TWAMR : TWI_Slave_Address_Mask_Register_Type; end record; pragma Pack (TWI_Type); for TWI_Type'Size use 6 * BYTE_SIZE; Reg_TWI : TWI_Type; for Reg_TWI'Address use System'To_Address (16#B8#); -- ============ -- Status Codes -- ============ -- Start condition START : constant := 16#08#; REPEATED_START : constant := 16#10#; -- Master Transmitter Mode MT_SLAW_ACK : constant := 16#18#; -- SLA_W transmitted, ACK received MT_SLAW_NACK : constant := 16#20#; -- SLA_W transmitted, NACK receive MT_DATA_ACK : constant := 16#28#; -- Data transmitted, ACK received MT_DATA_NACK : constant := 16#30#; -- Data transmitted, NACK received -- Master Receiver Mode MR_SLAR_ACK : constant := 16#40#; -- SLA_R transmitted, ACK received MR_SLAR_NACK : constant := 16#48#; -- SLA_R transmitted, NACK received MR_DATA_ACK : constant := 16#50#; -- Data byte received, ACK returned MR_DATA_NACK : constant := 16#58#; -- Data byte received, NACK returned -- Slave Receiver Mode SR_SLAW_ACK : constant := 16#60#; -- SLA_W received, ACK returned SR_SLAWR_ACK : constant := 16#68#; -- SLA_W received, ACK returned. Adressed as slave while in master mode (Better reset the communication) SR_GCAW_ACK : constant := 16#70#; -- General Call Address returned, ACK returned SR_GCAWR_ACK : constant := 16#78#; -- General Call Address rreturned, ACK returned. Adressed as slave while in master mode (Better reset the communication) SR_DATA_ACK : constant := 16#80#; -- Data received, ACK returned SR_DATA_NACK : constant := 16#88#; -- Data received, NACK returned. Lost Arbitration as Master SR_DATA_GCA_ACK : constant := 16#90#; -- Data on General Call returned, ACK returned SR_DATA_GCA_NACK : constant := 16#98#; -- Data on General Call returned, NACK returned. Adressed as slave while in master mode (Better reset the communication) -- Slave Transmitter Mode ST_SLAW_ACK : constant := 16#A8#; -- SLA_R received, ACK returned ST_SLAWR_ACK : constant := 16#B0#; -- SLA_R received, ACK returned. Adressed as slave while in master mode (Better reset the communication) ST_DATA_ACK : constant := 16#B8#; -- Data transmitted, ACK received ST_DATA_NACK : constant := 16#C0#; -- Data transmitted, NACK received ST_LAST_DATA_ACK : constant := 16#C8#; -- last byte data transmitted, ACK received. (TWEA = 0); -- Stop condition STOP_REP_START : constant := 16#A0#; -- Stop or repeated start. Should reset state machine -- Generic Errors ERR_BUS_ILLEGAL : constant := 16#00#; -- Illegal START or STOP condition ERR_NO_INFO : constant := 16#F8#; -- Arbitration lost in SLA_W/R, data bytes ERR_ARBIT_LOST : constant := 16#38#; -- No relevant state information available -- ============ -- Constants -- ============ MAX_BUFFER_RANGE : constant := 32; -- ============ -- Types -- ============ type TWI_Operation_Type is (TWI_MASTER, TWI_SLAVE); for TWI_Operation_Type use (TWI_MASTER => 0, TWI_SLAVE => 1); for TWI_Operation_Type'Size use 1; type Request_Type is (TW_WRITE, TW_READ); for Request_Type use (TW_WRITE => 0, TW_READ => 1); for Request_Type'Size use 1; subtype Buffer_Range_Type is Interfaces.Unsigned_8 range 1 .. MAX_BUFFER_RANGE; type Buffer_Type is array (Interfaces.Unsigned_8 range 1 .. 15) of Interfaces.Unsigned_8; type Data_Buffer_Type is record Is_New_Data : Boolean := False; Buffer_Index : Buffer_Range_Type := 1; -- Points to the next free index Buffer_Size : Buffer_Range_Type := 1; -- Buffer useful size Data_Buffer : Buffer_Type := (others => 0); end record; type Error_State_Type is (TWI_NO_ERROR, TWI_BUS_ERROR, TWI_LOST_ARBITRATION, TWI_NACK); for Error_State_Type'Size use 2; procedure Initialize (Address : Interfaces.Unsigned_8; Is_Slave : Boolean ); --+------------------------------------------- -- Usage: The function returns False while the whole Data -- wasn't sent. --+------------------------------------------- function Write_Data (Address : Interfaces.Unsigned_8; Data : Data_Buffer_Type) return Boolean; --+------------------------------------------- -- Usage: The function returns False while the whole Data -- wasn't sent. --+------------------------------------------- function Request_Data (Address : Interfaces.Unsigned_8; Size : Buffer_Range_Type) return Boolean; function Is_Data_Available return Boolean; function Get_Last_Data return Interfaces.Unsigned_8; function Get_Data (Prm_Index : Buffer_Range_Type) return Interfaces.Unsigned_8; function Get_Error return Error_State_Type; -- Manual communication control. If True, a trial is on demmand Twi_TX_Trial_Flag : Boolean := False; -- Manual communication control. If True, a trial is on demmand Twi_RX_Trial_Flag : Boolean := False; procedure Handle_Interrupts; --+-------------------------------------------------------------------------- --| Conversion Services --+-------------------------------------------------------------------------- function To_Byte is new Unchecked_Conversion (Source => TWI_Status_Register_Type, Target => Byte_Type); private type State_Type is (TWI_READY, TWI_BUSY_MT, TWI_BUSY_MR); Twi_Operation : TWI_Operation_Type := TWI_SLAVE; Twi_State : State_Type := TWI_READY; Twi_Error_State : Error_State_Type := TWI_NO_ERROR; Twi_Data_Sent_Flag : Boolean := False; Twi_Buffer : Data_Buffer_Type; -- Twi_Data_Max : Buffer_Range_Type := 2; -- Twi_Data_Size_Received : Interfaces.Unsigned_8 := 0; Twi_SLA_RW : Interfaces.Unsigned_8; pragma Volatile (Twi_SLA_RW); end AVR.TWI;
cborao/Ada-P4-chat
Ada
1,484
adb
--PRÁCTICA 4: CÉSAR BORAO MORATINOS (Handlers.adb) with Ada.Text_IO; with Chat_Messages; with Chat_Procedures; with Ada.Strings.Unbounded; package body Handlers is package ATI renames Ada.Text_IO; package CM renames Chat_Messages; package CP renames Chat_Procedures; package ASU renames Ada.Strings.Unbounded; procedure Client_Handler(From: in LLU.End_Point_Type; To: in LLU.End_Point_Type; P_Buffer: access LLU.Buffer_Type) is Mess: CM.Message_Type; Nick: ASU.Unbounded_String; Comment: ASU.Unbounded_String; begin Mess := CM.Message_Type'Input(P_Buffer); Nick := ASU.Unbounded_String'Input(P_Buffer); Comment := ASU.Unbounded_String'Input(P_Buffer); ATI.New_Line; ATI.Put_Line(ASU.To_String(Nick) & ": " & ASU.To_String(Comment)); LLU.Reset(P_Buffer.all); ATI.Put(">> "); end Client_Handler; procedure Server_Handler (From: in LLU.End_Point_Type; To: in LLU.End_Point_Type; P_Buffer: access LLU.Buffer_Type) is Mess: CM.Message_Type; Buffer_Out: aliased LLU.Buffer_Type(1024); begin Mess := CM.Message_Type'Input (P_Buffer); case Mess is when CM.Init => CP.Case_Init(P_Buffer,Buffer_Out'Access); when CM.Writer => CP.Case_Writer(P_Buffer,Buffer_Out'Access); when CM.Logout => CP.Case_Logout(P_Buffer,Buffer_Out'Access); when others => ATI.Put_Line("Unknown message type"); end case; LLU.Reset (P_Buffer.all); end Server_Handler; end Handlers;
RREE/ada-util
Ada
1,922
ads
----------------------------------------------------------------------- -- util-stacks -- Simple stack -- Copyright (C) 2010, 2011, 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 Ada.Finalization; generic type Element_Type is private; type Element_Type_Access is access all Element_Type; package Util.Stacks is pragma Preelaborate; type Stack is limited private; -- Get access to the current stack element. function Current (Container : in Stack) return Element_Type_Access; -- Push an element on top of the stack making the new element the current one. procedure Push (Container : in out Stack); -- Pop the top element. procedure Pop (Container : in out Stack); -- Clear the stack. procedure Clear (Container : in out Stack); private type Element_Type_Array is array (Natural range <>) of aliased Element_Type; type Element_Type_Array_Access is access all Element_Type_Array; type Stack is new Ada.Finalization.Limited_Controlled with record Current : Element_Type_Access := null; Stack : Element_Type_Array_Access := null; Pos : Natural := 0; end record; -- Release the stack overriding procedure Finalize (Obj : in out Stack); end Util.Stacks;
reznikmm/matreshka
Ada
6,941
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.Default_Style_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Style_Default_Style_Element_Node is begin return Self : Style_Default_Style_Element_Node do Matreshka.ODF_Style.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Style_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Style_Default_Style_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_Style_Default_Style (ODF.DOM.Style_Default_Style_Elements.ODF_Style_Default_Style_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 Style_Default_Style_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Default_Style_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Style_Default_Style_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_Style_Default_Style (ODF.DOM.Style_Default_Style_Elements.ODF_Style_Default_Style_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 Style_Default_Style_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_Style_Default_Style (Visitor, ODF.DOM.Style_Default_Style_Elements.ODF_Style_Default_Style_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.Style_URI, Matreshka.ODF_String_Constants.Default_Style_Element, Style_Default_Style_Element_Node'Tag); end Matreshka.ODF_Style.Default_Style_Elements;
reznikmm/matreshka
Ada
3,636
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. ------------------------------------------------------------------------------ with AMF.Elements.Generic_Hash; function AMF.UML.Test_Identity_Actions.Hash is new AMF.Elements.Generic_Hash (UML_Test_Identity_Action, UML_Test_Identity_Action_Access);
zhmu/ananas
Ada
90
adb
-- { dg-do compile } package body Freezing1 is procedure Foo is null; end Freezing1;
AdaCore/training_material
Ada
622
adb
with Ada.Containers.Generic_Sort; package body Integer_Vectors is --$ begin cut procedure Sort (V : in out Pkg_Vectors.Vector; First : Index_Type; Last : Index_Type) is procedure Swap_Object (A, B : Index_Type) is Temp : Integer := V (A); begin V (A) := V (B); V (B) := Temp; end Swap_Object; procedure Sort_Object is new Ada.Containers .Generic_Sort (Index_Type => Index_Type, Before => "<", Swap => Swap_Object); begin Sort_Object (First, Last); end Sort; --$ end cut end Integer_Vectors;
reznikmm/matreshka
Ada
3,714
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Fo_Font_Variant_Attributes is pragma Preelaborate; type ODF_Fo_Font_Variant_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Fo_Font_Variant_Attribute_Access is access all ODF_Fo_Font_Variant_Attribute'Class with Storage_Size => 0; end ODF.DOM.Fo_Font_Variant_Attributes;
riccardo-bernardini/eugen
Ada
2,187
ads
package EU_Projects.Nodes.Risks is type Risk_Descriptor is new Nodes.Node_Type with private; type Risk_Access is access Risk_Descriptor; type Risk_Label is new Dotted_Identifier; type Risk_Index is new Nodes.Node_Index; type Risk_Severity is (Very_Small, Small, Medium, Large, Very_Large); type Risk_Likeness is (Very_Small, Small, Medium, Large, Very_Large); function New_Risk (Label : Risk_Label; Description : String; Countermeasures : String; Severity : Risk_Severity; Likeness : Risk_Likeness) return Risk_Access; function Label (Item : Risk_Descriptor) return Risk_Label; function Description (Item : Risk_Descriptor) return String; function Countermeasures (Item : Risk_Descriptor) return String; function Severity (Item : Risk_Descriptor) return Risk_Severity; function Likeness (Item : Risk_Descriptor) return Risk_Likeness; function Full_Index (Item : Risk_Descriptor; Prefixed : Boolean) return String; pragma Warnings (Off); function Get_Symbolic_Instant (Item : Risk_Descriptor; Var : Simple_Identifier) return Times.Time_Expressions.Symbolic_Instant is (raise Unknown_Instant_Var); function Get_Symbolic_Duration (Item : Risk_Descriptor; Var : Simple_Identifier) return Times.Time_Expressions.Symbolic_Duration is (raise Unknown_Duration_Var); function Dependency_List (Item : Risk_Descriptor) return Node_Label_Lists.Vector is (Node_Label_Lists.Empty_Vector); pragma Warnings (On); private type Risk_Descriptor is new Nodes.Node_Type with record Countemeasures : Unbounded_String; Severity : Risk_Severity; Likeness : Risk_Likeness; end record; function Full_Index (Item : Risk_Descriptor; Prefixed : Boolean) return String is ("R" & Item.Index_Image); end EU_Projects.Nodes.Risks;
reznikmm/matreshka
Ada
3,856
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$ ------------------------------------------------------------------------------ package Matreshka.ODF_Attributes.FO.Hyphenation_Push_Char_Count is type FO_Hyphenation_Push_Char_Count_Node is new Matreshka.ODF_Attributes.FO.FO_Node_Base with null record; type FO_Hyphenation_Push_Char_Count_Access is access all FO_Hyphenation_Push_Char_Count_Node'Class; overriding function Get_Local_Name (Self : not null access constant FO_Hyphenation_Push_Char_Count_Node) return League.Strings.Universal_String; end Matreshka.ODF_Attributes.FO.Hyphenation_Push_Char_Count;
zhmu/ananas
Ada
744
ads
package test_image_p is type type1 is tagged private; type type3 is limited private; type type5 is tagged limited private; type a_type5_class is access all type5'Class; task type task_t (arg : access type3) is entry entry1; end task_t; function to_type1 (arg1 : in Integer) return type1; private type array_t is array (Positive range <>) of type1; type array_t2 is array (1 .. 3) of Boolean; type type1 is tagged record f2 : array_t2; end record; type type3 is limited record the_task : aliased task_t (type3'Access); the_array : array_t (1 .. 10) := (others => to_type1 (-1)); end record; type type5 is tagged limited record f3 : type3; end record; end;
AdaCore/Ada_Drivers_Library
Ada
6,376
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2017-2018, 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 HAL.GPIO; use HAL.GPIO; with Wire_Simulation; use Wire_Simulation; with Ada.Text_IO; use Ada.Text_IO; procedure TC_Virtual_Wire is pragma Assertion_Policy (Assert => Check); No_Pull_Wire : Virtual_Wire (Default_Pull => Floating, Max_Points => 2); Pull_Up_Wire : Virtual_Wire (Default_Pull => Pull_Up, Max_Points => 2); Pull_Down_Wire : Virtual_Wire (Default_Pull => Pull_Down, Max_Points => 2); Unref : Boolean with Unreferenced; begin -- Default mode -- pragma Assert (No_Pull_Wire.Point (1).Mode = Input, "Default point mode should be input"); -- State with only inputs and a wire pull resistor -- pragma Assert (Pull_Up_Wire.Point (1).Set, "Default state of pull up wire should be high"); pragma Assert (not Pull_Down_Wire.Point (1).Set, "Default state of pull down wire should be low"); -- State with only inputs and a point pull resistor -- pragma Assert (No_Pull_Wire.Point (1).Support (Pull_Up), "It should be possible to change the pull resitor"); No_Pull_Wire.Point (1).Set_Pull_Resistor (Pull_Up); pragma Assert (No_Pull_Wire.Point (1).Set, "State of wire with one pull up point should be high"); No_Pull_Wire.Point (1).Set_Pull_Resistor (Pull_Down); pragma Assert (not No_Pull_Wire.Point (1).Set, "State of wire with one pull down point should be low"); -- State with one input one output and no pull resistor -- pragma Assert (No_Pull_Wire.Point (1).Support (Input), "It should be possible to change the mode"); No_Pull_Wire.Point (1).Set_Mode (Input); No_Pull_Wire.Point (1).Set_Pull_Resistor (Pull_Down); No_Pull_Wire.Point (2).Set_Mode (Output); No_Pull_Wire.Point (2).Set_Pull_Resistor (Floating); No_Pull_Wire.Point (2).Set; pragma Assert (No_Pull_Wire.Point (1).Set, "Should be high"); No_Pull_Wire.Point (2).Clear; pragma Assert (not No_Pull_Wire.Point (1).Set, "Should be low"); -- State with one input one output and point pull resistor -- No_Pull_Wire.Point (1).Set_Mode (Input); No_Pull_Wire.Point (1).Set_Pull_Resistor (Pull_Up); No_Pull_Wire.Point (2).Set_Mode (Output); No_Pull_Wire.Point (2).Set_Pull_Resistor (Floating); No_Pull_Wire.Point (2).Set; pragma Assert (No_Pull_Wire.Point (1).Set, "Should be high"); No_Pull_Wire.Point (2).Clear; pragma Assert (not No_Pull_Wire.Point (1).Set, "Should be low"); No_Pull_Wire.Point (1).Set_Pull_Resistor (Pull_Down); No_Pull_Wire.Point (2).Set; pragma Assert (No_Pull_Wire.Point (1).Set, "Should be high"); No_Pull_Wire.Point (2).Clear; pragma Assert (not No_Pull_Wire.Point (1).Set, "Should be low"); -- Opposite pull on the same wire -- declare begin Pull_Down_Wire.Point (1).Set_Pull_Resistor (Pull_Up); exception when Invalid_Configuration => Put_Line ("Expected exception on oppposite pull (1)"); end; declare begin Pull_Up_Wire.Point (1).Set_Pull_Resistor (Pull_Down); exception when Invalid_Configuration => Put_Line ("Expected exception on oppposite pull (2)"); end; -- Two output point on a wire -- declare begin Pull_Up_Wire.Point (1).Set_Mode (Output); Pull_Up_Wire.Point (2).Set_Mode (Output); exception when Invalid_Configuration => Put_Line ("Expected exception on multiple output points"); end; -- Unknon state -- declare begin No_Pull_Wire.Point (1).Set_Mode (Input); No_Pull_Wire.Point (1).Set_Pull_Resistor (Floating); No_Pull_Wire.Point (2).Set_Mode (Input); No_Pull_Wire.Point (2).Set_Pull_Resistor (Floating); Unref := No_Pull_Wire.Point (2).Set; exception when Unknown_State => Put_Line ("Expected exception on unknown state"); end; end TC_Virtual_Wire;
reznikmm/matreshka
Ada
4,448
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- 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.CLDR.Collation_Loader; with Matreshka.Internals.Locales.Defaults; package body League.Locales.Constructors is ------------------- -- Create_Locale -- ------------------- function Create_Locale (Language : League.Strings.Universal_String) return Locale is begin return Result : Locale := (Ada.Finalization.Controlled with Data => new Matreshka.Internals.Locales.Locale_Data' (Counter => <>, Core => Matreshka.Internals.Locales.Defaults.Default_Locale .Core, Casing => Matreshka.Internals.Locales.Defaults.Default_Locale .Casing, Collation => Matreshka.Internals.Locales.Defaults.Default_Locale .Collation)) do Matreshka.CLDR.Collation_Loader.Load_Collation_Data (Language, Result.Data); end return; end Create_Locale; end League.Locales.Constructors;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
7,169
ads
pragma Style_Checks (Off); -- This spec has been automatically generated from STM32L0x3.svd pragma Restrictions (No_Elaboration_Code); with System; package STM32_SVD.CRS is pragma Preelaborate; --------------- -- Registers -- --------------- subtype CR_SYNCOKIE_Field is STM32_SVD.Bit; subtype CR_SYNCWARNIE_Field is STM32_SVD.Bit; subtype CR_ERRIE_Field is STM32_SVD.Bit; subtype CR_ESYNCIE_Field is STM32_SVD.Bit; subtype CR_CEN_Field is STM32_SVD.Bit; subtype CR_AUTOTRIMEN_Field is STM32_SVD.Bit; subtype CR_SWSYNC_Field is STM32_SVD.Bit; subtype CR_TRIM_Field is STM32_SVD.UInt6; -- control register type CR_Register is record -- SYNC event OK interrupt enable SYNCOKIE : CR_SYNCOKIE_Field := 16#0#; -- SYNC warning interrupt enable SYNCWARNIE : CR_SYNCWARNIE_Field := 16#0#; -- Synchronization or trimming error interrupt enable ERRIE : CR_ERRIE_Field := 16#0#; -- Expected SYNC interrupt enable ESYNCIE : CR_ESYNCIE_Field := 16#0#; -- unspecified Reserved_4_4 : STM32_SVD.Bit := 16#0#; -- Frequency error counter enable CEN : CR_CEN_Field := 16#0#; -- Automatic trimming enable AUTOTRIMEN : CR_AUTOTRIMEN_Field := 16#0#; -- Generate software SYNC event SWSYNC : CR_SWSYNC_Field := 16#0#; -- HSI48 oscillator smooth trimming TRIM : CR_TRIM_Field := 16#20#; -- unspecified Reserved_14_31 : STM32_SVD.UInt18 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CR_Register use record SYNCOKIE at 0 range 0 .. 0; SYNCWARNIE at 0 range 1 .. 1; ERRIE at 0 range 2 .. 2; ESYNCIE at 0 range 3 .. 3; Reserved_4_4 at 0 range 4 .. 4; CEN at 0 range 5 .. 5; AUTOTRIMEN at 0 range 6 .. 6; SWSYNC at 0 range 7 .. 7; TRIM at 0 range 8 .. 13; Reserved_14_31 at 0 range 14 .. 31; end record; subtype CFGR_RELOAD_Field is STM32_SVD.UInt16; subtype CFGR_FELIM_Field is STM32_SVD.Byte; subtype CFGR_SYNCDIV_Field is STM32_SVD.UInt3; subtype CFGR_SYNCSRC_Field is STM32_SVD.UInt2; subtype CFGR_SYNCPOL_Field is STM32_SVD.Bit; -- configuration register type CFGR_Register is record -- Counter reload value RELOAD : CFGR_RELOAD_Field := 16#BB7F#; -- Frequency error limit FELIM : CFGR_FELIM_Field := 16#22#; -- SYNC divider SYNCDIV : CFGR_SYNCDIV_Field := 16#0#; -- unspecified Reserved_27_27 : STM32_SVD.Bit := 16#0#; -- SYNC signal source selection SYNCSRC : CFGR_SYNCSRC_Field := 16#2#; -- unspecified Reserved_30_30 : STM32_SVD.Bit := 16#0#; -- SYNC polarity selection SYNCPOL : CFGR_SYNCPOL_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CFGR_Register use record RELOAD at 0 range 0 .. 15; FELIM at 0 range 16 .. 23; SYNCDIV at 0 range 24 .. 26; Reserved_27_27 at 0 range 27 .. 27; SYNCSRC at 0 range 28 .. 29; Reserved_30_30 at 0 range 30 .. 30; SYNCPOL at 0 range 31 .. 31; end record; subtype ISR_SYNCOKF_Field is STM32_SVD.Bit; subtype ISR_SYNCWARNF_Field is STM32_SVD.Bit; subtype ISR_ERRF_Field is STM32_SVD.Bit; subtype ISR_ESYNCF_Field is STM32_SVD.Bit; subtype ISR_SYNCERR_Field is STM32_SVD.Bit; subtype ISR_SYNCMISS_Field is STM32_SVD.Bit; subtype ISR_TRIMOVF_Field is STM32_SVD.Bit; subtype ISR_FEDIR_Field is STM32_SVD.Bit; subtype ISR_FECAP_Field is STM32_SVD.UInt16; -- interrupt and status register type ISR_Register is record -- Read-only. SYNC event OK flag SYNCOKF : ISR_SYNCOKF_Field; -- Read-only. SYNC warning flag SYNCWARNF : ISR_SYNCWARNF_Field; -- Read-only. Error flag ERRF : ISR_ERRF_Field; -- Read-only. Expected SYNC flag ESYNCF : ISR_ESYNCF_Field; -- unspecified Reserved_4_7 : STM32_SVD.UInt4; -- Read-only. SYNC error SYNCERR : ISR_SYNCERR_Field; -- Read-only. SYNC missed SYNCMISS : ISR_SYNCMISS_Field; -- Read-only. Trimming overflow or underflow TRIMOVF : ISR_TRIMOVF_Field; -- unspecified Reserved_11_14 : STM32_SVD.UInt4; -- Read-only. Frequency error direction FEDIR : ISR_FEDIR_Field; -- Read-only. Frequency error capture FECAP : ISR_FECAP_Field; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ISR_Register use record SYNCOKF at 0 range 0 .. 0; SYNCWARNF at 0 range 1 .. 1; ERRF at 0 range 2 .. 2; ESYNCF at 0 range 3 .. 3; Reserved_4_7 at 0 range 4 .. 7; SYNCERR at 0 range 8 .. 8; SYNCMISS at 0 range 9 .. 9; TRIMOVF at 0 range 10 .. 10; Reserved_11_14 at 0 range 11 .. 14; FEDIR at 0 range 15 .. 15; FECAP at 0 range 16 .. 31; end record; subtype ICR_SYNCOKC_Field is STM32_SVD.Bit; subtype ICR_SYNCWARNC_Field is STM32_SVD.Bit; subtype ICR_ERRC_Field is STM32_SVD.Bit; subtype ICR_ESYNCC_Field is STM32_SVD.Bit; -- interrupt flag clear register type ICR_Register is record -- SYNC event OK clear flag SYNCOKC : ICR_SYNCOKC_Field := 16#0#; -- SYNC warning clear flag SYNCWARNC : ICR_SYNCWARNC_Field := 16#0#; -- Error clear flag ERRC : ICR_ERRC_Field := 16#0#; -- Expected SYNC clear flag ESYNCC : ICR_ESYNCC_Field := 16#0#; -- unspecified Reserved_4_31 : STM32_SVD.UInt28 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ICR_Register use record SYNCOKC at 0 range 0 .. 0; SYNCWARNC at 0 range 1 .. 1; ERRC at 0 range 2 .. 2; ESYNCC at 0 range 3 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Clock recovery system type CRS_Peripheral is record -- control register CR : aliased CR_Register; -- configuration register CFGR : aliased CFGR_Register; -- interrupt and status register ISR : aliased ISR_Register; -- interrupt flag clear register ICR : aliased ICR_Register; end record with Volatile; for CRS_Peripheral use record CR at 16#0# range 0 .. 31; CFGR at 16#4# range 0 .. 31; ISR at 16#8# range 0 .. 31; ICR at 16#C# range 0 .. 31; end record; -- Clock recovery system CRS_Periph : aliased CRS_Peripheral with Import, Address => CRS_Base; end STM32_SVD.CRS;
reznikmm/matreshka
Ada
4,093
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.Db_Row_Retrieving_Statement_Attributes; package Matreshka.ODF_Db.Row_Retrieving_Statement_Attributes is type Db_Row_Retrieving_Statement_Attribute_Node is new Matreshka.ODF_Db.Abstract_Db_Attribute_Node and ODF.DOM.Db_Row_Retrieving_Statement_Attributes.ODF_Db_Row_Retrieving_Statement_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Db_Row_Retrieving_Statement_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Db_Row_Retrieving_Statement_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Db.Row_Retrieving_Statement_Attributes;
optikos/oasis
Ada
20,310
adb
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Ada.Strings.Wide_Wide_Hash; with Ada.Wide_Wide_Characters.Handling; package body Program.Symbols.Tables is ----------- -- Equal -- ----------- function Equal (Left, Right : Symbol_Reference) return S.Boolean is Left_Text : constant Program.Text := Left.Buffer.Text (Left.Span); Right_Text : constant Program.Text := Right.Buffer.Text (Right.Span); begin if Left_Text (Left_Text'First) = ''' then return Left_Text = Right_Text; else return Ada.Wide_Wide_Characters.Handling.To_Lower (Left_Text) = Ada.Wide_Wide_Characters.Handling.To_Lower (Right_Text); end if; end Equal; package Dummy_Source_Buffers is type Dummy_Source_Buffer (Value : access constant Program.Text) is new Program.Source_Buffers.Source_Buffer with null record; overriding function Text (Self : Dummy_Source_Buffer; Unused : Program.Source_Buffers.Span) return Program.Text is (Self.Value.all); overriding procedure Read (Self : in out Dummy_Source_Buffer; Data : out Program.Source_Buffers.Character_Info_Array; Last : out Natural) is null; overriding procedure Rewind (Self : in out Dummy_Source_Buffer) is null; end Dummy_Source_Buffers; ---------- -- Find -- ---------- function Find (Self : Symbol_Table'Class; Value : Program.Text) return Symbol is Text : aliased Program.Text := Value; Dummy : aliased Dummy_Source_Buffers.Dummy_Source_Buffer (Text'Access); Ref : constant Symbol_Reference := (Dummy'Unchecked_Access, (1, 0)); Cursor : constant Symbol_Maps.Cursor := Self.Map.Find (Ref); begin if Symbol_Maps.Has_Element (Cursor) then return Symbol_Maps.Element (Cursor); elsif Value (Value'First) = ''' and Value (Value'Last) = ''' and Value'Length = 3 then -- Character literal return S.Wide_Wide_Character'Pos (Value (Value'First + 1)); else return Program.Symbols.No_Symbol; end if; end Find; -------------------- -- Find_Or_Create -- -------------------- procedure Find_Or_Create (Self : in out Symbol_Table'Class; Buffer : not null Program.Source_Buffers.Source_Buffer_Access; Span : Program.Source_Buffers.Span; Result : out Symbol) is Ref : constant Symbol_Reference := (Buffer, Span); Cursor : constant Symbol_Maps.Cursor := Self.Map.Find (Ref); begin if Symbol_Maps.Has_Element (Cursor) then Result := Symbol_Maps.Element (Cursor); return; end if; declare Value : constant Program.Text := Buffer.Text (Span); begin if Value (Value'First) = ''' and Value (Value'Last) = ''' and Value'Length = 3 then -- Character literal Result := S.Wide_Wide_Character'Pos (Value (Value'First + 1)); return; elsif Value (Value'First) in '"' then Result := No_Symbol; return; end if; end; Self.Last_Symbol := Self.Last_Symbol + 1; Result := Self.Last_Symbol; Self.Map.Insert (Ref, Result); end Find_Or_Create; ---------- -- Hash -- ---------- function Hash (Value : Symbol_Reference) return Ada.Containers.Hash_Type is Value_Text : constant Program.Text := Value.Buffer.Text (Value.Span); begin if Value_Text (Value_Text'First) = ''' then return Ada.Strings.Wide_Wide_Hash (Value_Text); else return Ada.Strings.Wide_Wide_Hash (Ada.Wide_Wide_Characters.Handling.To_Lower (Value_Text)); end if; end Hash; ---------------- -- Initialize -- ---------------- procedure Initialize (Self : in out Symbol_Table) is B : constant Program.Source_Buffers.Source_Buffer_Access := Self.Buffer'Unchecked_Access; begin Self.Map.Insert ((B, (1, 0)), Less_Symbol); Self.Map.Insert ((B, (2, 0)), Equal_Symbol); Self.Map.Insert ((B, (3, 0)), Greater_Symbol); Self.Map.Insert ((B, (4, 0)), Hyphen_Symbol); Self.Map.Insert ((B, (5, 0)), Slash_Symbol); Self.Map.Insert ((B, (6, 0)), Star_Symbol); Self.Map.Insert ((B, (7, 0)), Ampersand_Symbol); Self.Map.Insert ((B, (8, 0)), Plus_Symbol); Self.Map.Insert ((B, (9, 0)), Less_Or_Equal_Symbol); Self.Map.Insert ((B, (10, 0)), Greater_Or_Equal_Symbol); Self.Map.Insert ((B, (11, 0)), Inequality_Symbol); Self.Map.Insert ((B, (12, 0)), Double_Star_Symbol); Self.Map.Insert ((B, (13, 0)), Or_Symbol); Self.Map.Insert ((B, (14, 0)), And_Symbol); Self.Map.Insert ((B, (15, 0)), Xor_Symbol); Self.Map.Insert ((B, (16, 0)), Mod_Symbol); Self.Map.Insert ((B, (17, 0)), Rem_Symbol); Self.Map.Insert ((B, (18, 0)), Abs_Symbol); Self.Map.Insert ((B, (19, 0)), Not_Symbol); Self.Map.Insert ((B, (20, 0)), All_Calls_Remote); Self.Map.Insert ((B, (21, 0)), Assert); Self.Map.Insert ((B, (22, 0)), Assertion_Policy); Self.Map.Insert ((B, (23, 0)), Asynchronous); Self.Map.Insert ((B, (24, 0)), Atomic); Self.Map.Insert ((B, (25, 0)), Atomic_Components); Self.Map.Insert ((B, (26, 0)), Attach_Handler); Self.Map.Insert ((B, (27, 0)), Controlled); Self.Map.Insert ((B, (28, 0)), Convention); Self.Map.Insert ((B, (29, 0)), Detect_Blocking); Self.Map.Insert ((B, (30, 0)), Discard_Names); Self.Map.Insert ((B, (31, 0)), Elaborate); Self.Map.Insert ((B, (32, 0)), Elaborate_All); Self.Map.Insert ((B, (33, 0)), Elaborate_Body); Self.Map.Insert ((B, (34, 0)), Export); Self.Map.Insert ((B, (35, 0)), Import); Self.Map.Insert ((B, (36, 0)), Inline); Self.Map.Insert ((B, (37, 0)), Inspection_Point); Self.Map.Insert ((B, (38, 0)), Interrupt_Handler); Self.Map.Insert ((B, (39, 0)), Interrupt_Priority); Self.Map.Insert ((B, (40, 0)), Linker_Options); Self.Map.Insert ((B, (41, 0)), List); Self.Map.Insert ((B, (42, 0)), Locking_Policy); Self.Map.Insert ((B, (43, 0)), No_Return); Self.Map.Insert ((B, (44, 0)), Normalize_Scalars); Self.Map.Insert ((B, (45, 0)), Optimize); Self.Map.Insert ((B, (46, 0)), Pack); Self.Map.Insert ((B, (47, 0)), Page); Self.Map.Insert ((B, (48, 0)), Partition_Elaboration_Policy); Self.Map.Insert ((B, (49, 0)), Preelaborable_Initialization); Self.Map.Insert ((B, (50, 0)), Preelaborate); Self.Map.Insert ((B, (51, 0)), Priority_Specific_Dispatching); Self.Map.Insert ((B, (52, 0)), Profile); Self.Map.Insert ((B, (53, 0)), Pure); Self.Map.Insert ((B, (54, 0)), Queuing_Policy); Self.Map.Insert ((B, (55, 0)), Relative_Deadline); Self.Map.Insert ((B, (56, 0)), Remote_Call_Interface); Self.Map.Insert ((B, (57, 0)), Remote_Types); Self.Map.Insert ((B, (58, 0)), Restrictions); Self.Map.Insert ((B, (59, 0)), Reviewable); Self.Map.Insert ((B, (60, 0)), Shared_Passive); Self.Map.Insert ((B, (61, 0)), Suppress); Self.Map.Insert ((B, (62, 0)), Task_Dispatching_Policy); Self.Map.Insert ((B, (63, 0)), Unchecked_Union); Self.Map.Insert ((B, (64, 0)), Unsuppress); Self.Map.Insert ((B, (65, 0)), Volatile); Self.Map.Insert ((B, (66, 0)), Volatile_Components); -- Attributes: Self.Map.Insert ((B, (67, 0)), Access_Symbol); Self.Map.Insert ((B, (68, 0)), Address); Self.Map.Insert ((B, (69, 0)), Adjacent); Self.Map.Insert ((B, (70, 0)), Aft); Self.Map.Insert ((B, (71, 0)), Alignment); Self.Map.Insert ((B, (72, 0)), Base); Self.Map.Insert ((B, (73, 0)), Bit_Order); Self.Map.Insert ((B, (74, 0)), Body_Version); Self.Map.Insert ((B, (75, 0)), Callable); Self.Map.Insert ((B, (76, 0)), Caller); Self.Map.Insert ((B, (77, 0)), Ceiling); Self.Map.Insert ((B, (78, 0)), Class); Self.Map.Insert ((B, (79, 0)), Component_Size); Self.Map.Insert ((B, (80, 0)), Compose); Self.Map.Insert ((B, (81, 0)), Constrained); Self.Map.Insert ((B, (82, 0)), Copy_Sign); Self.Map.Insert ((B, (83, 0)), Count); Self.Map.Insert ((B, (84, 0)), Definite); Self.Map.Insert ((B, (85, 0)), Delta_Symbol); Self.Map.Insert ((B, (86, 0)), Denorm); Self.Map.Insert ((B, (87, 0)), Digits_Symbol); Self.Map.Insert ((B, (88, 0)), Exponent); Self.Map.Insert ((B, (89, 0)), External_Tag); Self.Map.Insert ((B, (90, 0)), First); Self.Map.Insert ((B, (91, 0)), First_Bit); Self.Map.Insert ((B, (92, 0)), Floor); Self.Map.Insert ((B, (93, 0)), Fore); Self.Map.Insert ((B, (94, 0)), Fraction); Self.Map.Insert ((B, (95, 0)), Identity); Self.Map.Insert ((B, (96, 0)), Image); Self.Map.Insert ((B, (97, 0)), Input); Self.Map.Insert ((B, (98, 0)), Last); Self.Map.Insert ((B, (99, 0)), Last_Bit); Self.Map.Insert ((B, (100, 0)), Leading_Part); Self.Map.Insert ((B, (101, 0)), Length); Self.Map.Insert ((B, (102, 0)), Machine); Self.Map.Insert ((B, (103, 0)), Machine_Emax); Self.Map.Insert ((B, (104, 0)), Machine_Emin); Self.Map.Insert ((B, (105, 0)), Machine_Mantissa); Self.Map.Insert ((B, (106, 0)), Machine_Overflows); Self.Map.Insert ((B, (107, 0)), Machine_Radix); Self.Map.Insert ((B, (108, 0)), Machine_Rounding); Self.Map.Insert ((B, (109, 0)), Machine_Rounds); Self.Map.Insert ((B, (110, 0)), Max); Self.Map.Insert ((B, (111, 0)), Max_Size_In_Storage_Elements); Self.Map.Insert ((B, (112, 0)), Min); Self.Map.Insert ((B, (113, 0)), Mod_Keyword); Self.Map.Insert ((B, (114, 0)), Model); Self.Map.Insert ((B, (115, 0)), Model_Emin); Self.Map.Insert ((B, (116, 0)), Model_Epsilon); Self.Map.Insert ((B, (117, 0)), Model_Mantissa); Self.Map.Insert ((B, (118, 0)), Model_Small); Self.Map.Insert ((B, (119, 0)), Modulus); Self.Map.Insert ((B, (120, 0)), Output); Self.Map.Insert ((B, (121, 0)), Partition_ID); Self.Map.Insert ((B, (122, 0)), Pos); Self.Map.Insert ((B, (123, 0)), Position); Self.Map.Insert ((B, (124, 0)), Pred); Self.Map.Insert ((B, (125, 0)), Priority); Self.Map.Insert ((B, (126, 0)), Range_Keyword); Self.Map.Insert ((B, (127, 0)), Read); Self.Map.Insert ((B, (128, 0)), Remainder); Self.Map.Insert ((B, (129, 0)), Round); Self.Map.Insert ((B, (130, 0)), Rounding); Self.Map.Insert ((B, (131, 0)), Safe_First); Self.Map.Insert ((B, (132, 0)), Safe_Last); Self.Map.Insert ((B, (133, 0)), Scale); Self.Map.Insert ((B, (134, 0)), Scaling); Self.Map.Insert ((B, (135, 0)), Signed_Zeros); Self.Map.Insert ((B, (136, 0)), Size); Self.Map.Insert ((B, (137, 0)), Small); Self.Map.Insert ((B, (138, 0)), Storage_Pool); Self.Map.Insert ((B, (139, 0)), Storage_Size); Self.Map.Insert ((B, (140, 0)), Stream_Size); Self.Map.Insert ((B, (141, 0)), Succ); Self.Map.Insert ((B, (142, 0)), Tag); Self.Map.Insert ((B, (143, 0)), Terminated); Self.Map.Insert ((B, (144, 0)), Truncation); Self.Map.Insert ((B, (145, 0)), Unbiased_Rounding); Self.Map.Insert ((B, (146, 0)), Unchecked_Access); Self.Map.Insert ((B, (147, 0)), Val); Self.Map.Insert ((B, (148, 0)), Valid); Self.Map.Insert ((B, (149, 0)), Value); Self.Map.Insert ((B, (150, 0)), Version); Self.Map.Insert ((B, (151, 0)), Wide_Image); Self.Map.Insert ((B, (152, 0)), Wide_Value); Self.Map.Insert ((B, (153, 0)), Wide_Wide_Image); Self.Map.Insert ((B, (154, 0)), Wide_Wide_Value); Self.Map.Insert ((B, (155, 0)), Wide_Wide_Width); Self.Map.Insert ((B, (156, 0)), Wide_Width); Self.Map.Insert ((B, (157, 0)), Width); Self.Map.Insert ((B, (158, 0)), Write); -- Other names: Self.Map.Insert ((B, (159, 0)), Standard); Self.Map.Insert ((B, (160, 0)), Boolean); Self.Map.Insert ((B, (161, 0)), Integer); Self.Map.Insert ((B, (162, 0)), Float); Self.Map.Insert ((B, (163, 0)), Character); Self.Map.Insert ((B, (164, 0)), Wide_Character); Self.Map.Insert ((B, (165, 0)), Wide_Wide_Character); Self.Map.Insert ((B, (166, 0)), String); Self.Map.Insert ((B, (167, 0)), Wide_String); Self.Map.Insert ((B, (168, 0)), Wide_Wide_String); Self.Map.Insert ((B, (169, 0)), Duration); Self.Map.Insert ((B, (170, 0)), Root_Integer); Self.Map.Insert ((B, (171, 0)), Root_Real); end Initialize; ---------- -- Text -- ---------- overriding function Text (Self : Predefined_Source_Buffer; Span : Program.Source_Buffers.Span) return Program.Text is pragma Unreferenced (Self); begin case Symbol (Span.From) is when 1 => return """<"""; when 2 => return """="""; when 3 => return """>"""; when 4 => return """-"""; when 5 => return """/"""; when 6 => return """*"""; when 7 => return """&"""; when 8 => return """+"""; when 9 => return """<="""; when 10 => return """>="""; when 11 => return """/="""; when 12 => return """**"""; when 13 => return """or"""; when 14 => return """and"""; when 15 => return """xor"""; when 16 => return """mod"""; when 17 => return """rem"""; when 18 => return """abd"""; when 19 => return """not"""; when 20 => return "All_Calls_Remote"; when 21 => return "Assert"; when 22 => return "Assertion_Policy"; when 23 => return "Asynchronous"; when 24 => return "Atomic"; when 25 => return "Atomic_Components"; when 26 => return "Attach_Handler"; when 27 => return "Controlled"; when 28 => return "Convention"; when 29 => return "Detect_Blocking"; when 30 => return "Discard_Names"; when 31 => return "Elaborate"; when 32 => return "Elaborate_All"; when 33 => return "Elaborate_Body"; when 34 => return "Export"; when 35 => return "Import"; when 36 => return "Inline"; when 37 => return "Inspection_Point"; when 38 => return "Interrupt_Handler"; when 39 => return "Interrupt_Priority"; when 40 => return "Linker_Options"; when 41 => return "List"; when 42 => return "Locking_Policy"; when 43 => return "No_Return"; when 44 => return "Normalize_Scalars"; when 45 => return "Optimize"; when 46 => return "Pack"; when 47 => return "Page"; when 48 => return "Partition_Elaboration_Policy"; when 49 => return "Preelaborable_Initialization"; when 50 => return "Preelaborate"; when 51 => return "Priority_Specific_Dispatching"; when 52 => return "Profile"; when 53 => return "Pure"; when 54 => return "Queuing_Policy"; when 55 => return "Relative_Deadline"; when 56 => return "Remote_Call_Interface"; when 57 => return "Remote_Types"; when 58 => return "Restrictions"; when 59 => return "Reviewable"; when 60 => return "Shared_Passive"; when 61 => return "Suppress"; when 62 => return "Task_Dispatching_Policy"; when 63 => return "Unchecked_Union"; when 64 => return "Unsuppress"; when 65 => return "Volatile"; when 66 => return "Volatile_Components"; when 67 => return "Access_Symbol"; when 68 => return "Address"; when 69 => return "Adjacent"; when 70 => return "Aft"; when 71 => return "Alignment"; when 72 => return "Base"; when 73 => return "Bit_Order"; when 74 => return "Body_Version"; when 75 => return "Callable"; when 76 => return "Caller"; when 77 => return "Ceiling"; when 78 => return "Class"; when 79 => return "Component_Size"; when 80 => return "Compose"; when 81 => return "Constrained"; when 82 => return "Copy_Sign"; when 83 => return "Count"; when 84 => return "Definite"; when 85 => return "Delta_Symbol"; when 86 => return "Denorm"; when 87 => return "Digits_Symbol"; when 88 => return "Exponent"; when 89 => return "External_Tag"; when 90 => return "First"; when 91 => return "First_Bit"; when 92 => return "Floor"; when 93 => return "Fore"; when 94 => return "Fraction"; when 95 => return "Identity"; when 96 => return "Image"; when 97 => return "Input"; when 98 => return "Last"; when 99 => return "Last_Bit"; when 100 => return "Leading_Part"; when 101 => return "Length"; when 102 => return "Machine"; when 103 => return "Machine_Emax"; when 104 => return "Machine_Emin"; when 105 => return "Machine_Mantissa"; when 106 => return "Machine_Overflows"; when 107 => return "Machine_Radix"; when 108 => return "Machine_Rounding"; when 109 => return "Machine_Rounds"; when 110 => return "Max"; when 111 => return "Max_Size_In_Storage_Elements"; when 112 => return "Min"; when 113 => return "Mod"; when 114 => return "Model"; when 115 => return "Model_Emin"; when 116 => return "Model_Epsilon"; when 117 => return "Model_Mantissa"; when 118 => return "Model_Small"; when 119 => return "Modulus"; when 120 => return "Output"; when 121 => return "Partition_ID"; when 122 => return "Pos"; when 123 => return "Position"; when 124 => return "Pred"; when 125 => return "Priority"; when 126 => return "Range"; when 127 => return "Read"; when 128 => return "Remainder"; when 129 => return "Round"; when 130 => return "Rounding"; when 131 => return "Safe_First"; when 132 => return "Safe_Last"; when 133 => return "Scale"; when 134 => return "Scaling"; when 135 => return "Signed_Zeros"; when 136 => return "Size"; when 137 => return "Small"; when 138 => return "Storage_Pool"; when 139 => return "Storage_Size"; when 140 => return "Stream_Size"; when 141 => return "Succ"; when 142 => return "Tag"; when 143 => return "Terminated"; when 144 => return "Truncation"; when 145 => return "Unbiased_Rounding"; when 146 => return "Unchecked_Access"; when 147 => return "Val"; when 148 => return "Valid"; when 149 => return "Value"; when 150 => return "Version"; when 151 => return "Wide_Image"; when 152 => return "Wide_Value"; when 153 => return "Wide_Wide_Image"; when 154 => return "Wide_Wide_Value"; when 155 => return "Wide_Wide_Width"; when 156 => return "Wide_Width"; when 157 => return "Width"; when 158 => return "Write"; when 159 => return "Standard"; when 160 => return "Boolean"; when 161 => return "Integer"; when 162 => return "Float"; when 163 => return "Character"; when 164 => return "Wide_Character"; when 165 => return "Wide_Wide_Character"; when 166 => return "String"; when 167 => return "Wide_String"; when 168 => return "Wide_Wide_String"; when 169 => return "Duration"; when 170 => return "Root_Integer"; when 171 => return "Root_Real"; when others => raise Constraint_Error; end case; end Text; end Program.Symbols.Tables;
joakim-strandberg/wayland_ada_binding
Ada
5,547
adb
--with C_Binding.Linux.Udev.Contexts; --with C_Binding.Linux.Udev.List_Entries; package body C_Binding.Linux.Udev.Queues is use type int; function Udev_Queue_Ref (Queue : Udev_Queue_Ptr) return Udev_Queue_Ptr; pragma Import (C, Udev_Queue_Ref, "udev_queue_ref"); function Udev_Queue_Unref (Queue : Udev_Queue_Ptr) return Udev_Queue_Ptr; pragma Import (C, Udev_Queue_Unref, "udev_queue_unref"); function Udev_Queue_Get_Udev (Queue : Udev_Queue_Ptr) return Udev_Ptr; pragma Import (C, Udev_Queue_Get_Udev, "udev_queue_get_udev"); function Udev_Queue_Get_Kernel_Seqnum (Queue : Udev_Queue_Ptr) return Interfaces.Integer_64; pragma Import (C, Udev_Queue_Get_Kernel_Seqnum, "udev_queue_get_kernel_seqnum"); function Udev_Queue_Get_Udev_Seqnum (Queue : Udev_Queue_Ptr) return Interfaces.Integer_64; pragma Import (C, Udev_Queue_Get_Udev_Seqnum, "udev_queue_get_udev_seqnum"); function Udev_Queue_Get_Udev_Is_Active (Queue : Udev_Queue_Ptr) return Int; pragma Import (C, Udev_Queue_Get_Udev_Is_Active, "udev_queue_get_udev_is_active"); function Udev_Queue_Get_Queue_Is_Empty (Queue : Udev_Queue_Ptr) return Int; pragma Import (C, Udev_Queue_Get_Queue_Is_Empty, "udev_queue_get_queue_is_empty"); -- Returns a flag indicating if udev is currently handling events. function Udev_Queue_Get_Seqnum_Is_Finished (Queue : Udev_Queue_Ptr; Seqnum : Interfaces.Integer_64) return Int; pragma Import (C, Udev_Queue_Get_Seqnum_Is_Finished, "udev_queue_get_seqnum_is_finished"); -- Returns a flag indicating if the given sequence number -- is currently active. function Udev_Queue_Get_Seqnum_Sequence_Is_Finished (Queue : Udev_Queue_Ptr; Start_Number : Interfaces.Integer_64; End_Number : Interfaces.Integer_64) return Int; pragma Import (C, Udev_Queue_Get_Seqnum_Sequence_Is_Finished, "udev_queue_get_seqnum_sequence_is_finished"); -- Returns a flag indicating if any of the sequence numbers -- in the given range is currently active. function Udev_Queue_Get_Fd (Queue : Udev_Queue_Ptr) return Int; pragma Import (C, Udev_Queue_Get_Fd, "udev_queue_get_fd"); function Udev_Queue_Flush (Queue : Udev_Queue_Ptr) return Int; pragma Import (C, Udev_Queue_Flush, "udev_queue_flush"); -- Returns the result of clearing the watch for queue changes. -- On success, returns 0. function Udev_Queue_Get_Queued_List_Entry (Queue : Udev_Queue_Ptr) return Udev_List_Entry_Ptr; pragma Import (C, Udev_Queue_Get_Queued_List_Entry, "udev_queue_get_queued_list_entry"); procedure Acquire (Original : Queue; Reference : out Queue) is begin Reference.My_Ptr := Udev_Queue_Ref (Original.My_Ptr); end Acquire; function Exists (Queue : Queues.Queue) return Boolean is (Queue.My_Ptr /= null); procedure Delete (Queue : in out Queues.Queue) is begin Queue.My_Ptr := Udev_Queue_Unref (Queue.My_Ptr); Queue.My_Ptr := null; -- Is unnecessary, but static code analyzers cannot know -- Udev_Queue_Unref (..) always returns null. end Delete; procedure Context (Queue : Queues.Queue; Context : out Contexts.Context) is begin Context_Base (Context).My_Ptr := Udev_Queue_Get_Udev (Queue.My_Ptr); end Context; function Kernel_Sequence_Number (Queue : Queues.Queue) return Long_Integer is (Long_Integer (Udev_Queue_Get_Kernel_Seqnum (Queue.My_Ptr))); function Sequence_Number (Queue : Queues.Queue) return Long_Integer is (Long_Integer (Udev_Queue_Get_Udev_Seqnum (Queue.My_Ptr))); function Is_Active (Queue : Queues.Queue) return Boolean is (if (Udev_Queue_Get_Udev_Is_Active (Queue.My_Ptr) /= 0) then (True) else (False)); function Is_Empty (Queue : Queues.Queue) return Boolean is (if (Udev_Queue_Get_Queue_Is_Empty (Queue.My_Ptr) /= 0) then (True) else (False)); function Is_Sequence_Number_Finished (Queue : Queues.Queue; Sequence_Number : Long_Integer) return Boolean is (if (Udev_Queue_Get_Seqnum_Is_Finished (Queue.My_Ptr, Interfaces.Integer_64 (Sequence_Number)) /= 0) then (True) else (False)); function Are_Sequence_Numbers_Finished (Queue : Queues.Queue; First_Sequence_Number : Long_Integer; Last_Sequence_Number : Long_Integer) return Boolean is (if (Udev_Queue_Get_Seqnum_Sequence_Is_Finished (Queue.My_Ptr, Interfaces.Integer_64 (First_Sequence_Number), Interfaces.Integer_64 (First_Sequence_Number)) /= 0) then True else False); function File_Descriptor (Queue : Queues.Queue) return Integer is (Integer (Udev_Queue_Get_Fd (Queue.My_Ptr))); function Flush (Queue : Queues.Queue) return Success_Flag is (if (Udev_Queue_Flush (Queue.My_Ptr) = 0) then Success else Failure); procedure Queued_List_Entry (Queue : Queues.Queue; List_Entry : out List_Entries.List_Entry) is begin List_Entry_Base (List_Entry).My_Ptr := Udev_Queue_Get_Queued_List_Entry (Queue.My_Ptr); end Queued_List_Entry; procedure Finalize (Queue : in out Queues.Queue) is begin if Queue.Exists then Queue.Delete; end if; end Finalize; end C_Binding.Linux.Udev.Queues;
albinjal/ada_basic
Ada
4,012
adb
with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Numerics.Discrete_Random; with Ada.Command_Line; use Ada.Command_Line; procedure Lab3b is type Integers is array (1..2) of Integer; type Integers_Array is array (1..20) of Integers; Array_20: Integers_Array; function "<"(Arr1, Arr2: in Integers) return Boolean is begin --for I in Arr1'Range loop if Arr1(2) < Arr2(2) then return True; elsif Arr1(2) = Arr2(2) then if Arr1(1) < Arr2(1) then return True; else return False; end if; else return False; end if; end "<"; ------------------------------------------------------- procedure Generate(Array_20: in out Integers_Array) is subtype First_Ten_Numbers is Integer range 1..10; package Random_Number_One_To_Ten is new Ada.Numerics.Discrete_Random(Result_Subtype => First_Ten_Numbers); G : Random_Number_One_To_Ten.Generator; begin Random_Number_One_To_Ten.Reset(G); for I in Array_20'Range loop for X in Array_20(I)'Range loop Array_20(I)(X) := Random_Number_One_To_Ten.Random(G); end loop; end loop; end Generate; ------------------------------------------------------- ------------------------------------------------------- procedure Swap(Tal_1,Tal_2: in out Integers) is Tal_B : Integers; -- Temporary buffer begin Tal_B := Tal_1; Tal_1 := Tal_2; Tal_2 := Tal_B; -- DEBUG New_Line; Put("SWAP IS RUNNING! INDEXES INPUT: "); Put(Tal_1); Put("+"); Put(Tal_2); New_Line; end Swap; ------------------------------------------------------- ------------------------------------------------------ procedure Sort(Arrayen_Med_Talen: in out Integers_Array) is Minsta_Talet: Integers; Minsta_Talet_Index: Integer; begin Minsta_Talet := (0,0); -- -- Loopa antalet gånger som arrayens längd for IOuter in Arrayen_Med_Talen'Range loop -- -- DEBUG Put("> "); Put(IOuter); Put(" <"); New_Line; -- -- Loopa arrayen med start från yttra loopens värde varje gång. 1..20, 2..20, ... , 20..20 for I in IOuter..Arrayen_Med_Talen'Last loop -- --DEBUG Put(">>>"); Put(I); New_Line; if I = IOuter or Arrayen_Med_Talen(I) < Minsta_Talet then Minsta_Talet := Arrayen_Med_Talen(I); Minsta_Talet_Index := I; end if; end loop; -- Swap(Arrayen_Med_Talen(IOuter), Arrayen_Med_Talen(Minsta_Talet_Index)); -- --DEBUG New_Line; Put("Vi swappar "); Put(Iouter); Put(" och "); Put(Minsta_Talet_Index); New_Line; end loop; end Sort; ----------------------------- -- procedure Put(Arr: in Integers_Array) is -- -- begin -- -- Printar ut en array -- for I in Arr'Range loop -- Put(Arr(I)); -- New_Line; -- end loop; -- end Put; procedure Put(Ints: in Integers) is begin for X in Ints'Range loop Put(Ints(X),2); Put(" "); end loop; end Put; procedure Put(Arr: in Integers_Array) is begin for I in Arr'Range loop Put(Arr(I)); New_Line; end loop; end Put; begin -- Fyller en array med random data Generate(Array_20); Put(Array_20); --Put(Array_20); New_Line; -- Sorterar arrayen, stigande ordning Sort(Array_20); -- Printar ut en array Put(Array_20); --------------------------- -- KOD FÖR TERMINALARGUMENT --------------------------- -- New_Line; -- New_Line; -- if Argument_Count = 0 then -- run A -- Put("No arguments input"); -- else -- if Argument_Count = 1 then -- Put("Arg Input: "); Put(Argument(1)); -- elsif Argument_Count = 2 then -- Put("Arg 1 Input: "); Put(Argument(1)); Put(" Arg 2 Input: "); Put(Argument(2)); -- end if; -- end if; end Lab3b;
Gabriel-Degret/adalib
Ada
639
ads
-- Standard Ada library specification -- Copyright (c) 2003-2018 Maxim Reznik <[email protected]> -- Copyright (c) 2004-2016 AXE Consultants -- Copyright (c) 2004, 2005, 2006 Ada-Europe -- Copyright (c) 2000 The MITRE Corporation, Inc. -- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc. -- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual --------------------------------------------------------------------------- package System.Machine_Code is -- The contents of the library package System.Machine_Code (if provided) -- are implementation defined. end System.Machine_Code;
reznikmm/matreshka
Ada
4,035
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2018, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ package body Properties.Definitions.Signed is --------------------------- -- Typed_Array_Item_Type -- --------------------------- function Typed_Array_Item_Type (Engine : access Engines.Contexts.Context; Element : Asis.Definition; Name : Engines.Text_Property) return League.Strings.Universal_String is pragma Unreferenced (Name); Down : League.Strings.Universal_String; Result : League.Strings.Universal_String; begin Down := Engine.Text.Get_Property (Element, Engines.Size); Result.Append ("_s"); Result.Append (Down); return Result; end Typed_Array_Item_Type; end Properties.Definitions.Signed;
jrcarter/Ada_GUI
Ada
45,830
adb
-- Ada_GUI implementation based on Gnoga. Adapted 2021 -- -- -- GNOGA - The GNU Omnificent GUI for Ada -- -- -- -- G N O G A . G U I . E L E M E N T -- -- -- -- B o d y -- -- -- -- -- -- Copyright (C) 2014 David Botton -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 3, or (at your option) any -- -- later version. This library is distributed in the hope that it will be -- -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- 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/>. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- For more information please go to http://www.gnoga.com -- ------------------------------------------------------------------------------ with Ada.Strings.Fixed; with Ada.Exceptions; with Ada_GUI.Gnoga.Server.Connection; package body Ada_GUI.Gnoga.Gui.Element is ------------------------------------------------------------------------- -- Element_Type - Creation Methods ------------------------------------------------------------------------- ---------------------- -- Create_From_HTML -- ---------------------- procedure Create_From_HTML (Element : in out Element_Type; Parent : in out Gnoga.Gui.Base_Type'Class; HTML : in String; ID : in String := "") is use Gnoga.Server.Connection; function Adjusted_ID return String; function Adjusted_ID return String is begin if ID = "" then return Gnoga.Server.Connection.New_GID; else return ID; end if; end Adjusted_ID; GID : constant String := Adjusted_ID; begin if Gnoga.Server.Connection.Connection_Type (Parent.Connection_ID) = Long_Polling then declare use Ada.Strings.Fixed; P : Natural := Index (Source => HTML, Pattern => ">"); begin if P = 0 then Gnoga.Log ("Malformed HTML = " & HTML); else if HTML (P - 1) = '/' then P := P - 1; end if; end if; declare S : constant String := HTML (HTML'First .. P - 1) & " id='" & GID & "'" & HTML (P .. HTML'Last); begin Gnoga.Server.Connection.Buffer_Append (Parent.Connection_ID, Unescape_Quotes (S)); Element.Attach_Using_Parent (Parent => Parent, ID => GID, ID_Type => Gnoga.DOM_ID); end; end; else Element.Create_With_Script (Connection_ID => Parent.Connection_ID, ID => GID, Script => "gnoga['" & GID & "']=$('" & HTML & "'); gnoga['" & GID & "'].first().prop('id','" & GID & "');", ID_Type => Gnoga.Gnoga_ID); end if; Element.Parent (Parent); end Create_From_HTML; ------------------------ -- Create_XML_Element -- ------------------------ procedure Create_XML_Element (Element : in out Element_Type; Parent : in out Gnoga.Gui.Base_Type'Class; Namespace : in String; Element_Type : in String; ID : in String := "") is function Adjusted_ID return String; function Adjusted_ID return String is begin if ID = "" then return Gnoga.Server.Connection.New_GID; else return ID; end if; end Adjusted_ID; GID : constant String := Adjusted_ID; begin Element.Create_With_Script (Connection_ID => Parent.Connection_ID, ID => GID, Script => "gnoga['" & GID & "']=$(" & "document.createElementNS('" & Namespace & "', '" & Element_Type & "'));", ID_Type => Gnoga.Gnoga_ID); Element.Attribute ("id", GID); Element.Parent (Parent); end Create_XML_Element; ------------------------------------------------------------------------- -- Element_Type - Properties ------------------------------------------------------------------------- ---------------- -- Auto_Place -- ---------------- procedure Auto_Place (Element : in out Element_Type; Value : Boolean) is begin Element.Auto_Place := Value; end Auto_Place; function Auto_Place (Element : Element_Type) return Boolean is begin return Element.Auto_Place; end Auto_Place; ----------- -- Style -- ----------- procedure Style (Element : in out Element_Type; Name : in String; Value : in String) is begin Element.jQuery_Execute ("css ('" & Escape_Quotes (Name) & "', '" & Escape_Quotes (Value) & "');"); end Style; procedure Style (Element : in out Element_Type; Name : in String; Value : in Integer) is begin Element.jQuery_Execute ("css ('" & Escape_Quotes (Name) & "'," & Value'Img & ");"); end Style; function Style (Element : Element_Type; Name : String) return String is begin return Element.jQuery_Execute ("css ('" & Name & "');"); end Style; function Style (Element : Element_Type; Name : String) return Integer is begin return Integer'Value (Element.Style (Name)); exception when E : others => Log ("Error Style converting to Integer (forced to 0)."); Log (Ada.Exceptions.Exception_Information (E)); return 0; end Style; --------------- -- Attribute -- --------------- procedure Attribute (Element : in out Element_Type; Name : in String; Value : in String) is begin Element.jQuery_Execute ("attr ('" & Name & "','" & Escape_Quotes (Value) & "');"); end Attribute; function Attribute (Element : Element_Type; Name : String) return String is begin return Element.jQuery_Execute ("attr ('" & Name & "');"); end Attribute; ---------------- -- Access_Key -- ---------------- procedure Access_Key (Element : in out Element_Type; Value : in String) is begin Element.Property ("accessKey", Value); end Access_Key; function Access_Key (Element : Element_Type) return String is begin return Element.Property ("accessKey"); end Access_Key; -------------------- -- Advisory_Title -- -------------------- procedure Advisory_Title (Element : in out Element_Type; Value : in String) is begin Element.Property ("title", Value); end Advisory_Title; function Advisory_Title (Element : Element_Type) return String is begin return Element.Property ("title"); end Advisory_Title; ---------------- -- Class_Name -- ---------------- procedure Class_Name (Element : in out Element_Type; Value : in String) is begin Element.Property ("className", Value); end Class_Name; function Class_Name (Element : Element_Type) return String is begin return Element.Property ("className"); end Class_Name; -------------- -- Editable -- -------------- procedure Editable (Element : in out Element_Type; Value : in Boolean := True) is begin Element.Property ("contentEditable", Value); end Editable; function Editable (Element : Element_Type) return Boolean is begin return Element.Property ("isContentEditable"); end Editable; ---------------- -- Box_Sizing -- ---------------- procedure Box_Sizing (Element : in out Element_Type; Value : in Box_Sizing_Type) is begin case Value is when Content_Box => Element.Style ("box-sizing", "content-box"); when Border_Box => Element.Style ("box-sizing", "border-box"); end case; end Box_Sizing; function Box_Sizing (Element : Element_Type) return Box_Sizing_Type is begin if Element.Style ("box-sizing") = "border-box" then return Border_Box; else return Content_Box; end if; end Box_Sizing; ---------------- -- Clear_Side -- ---------------- procedure Clear_Side (Element : in out Element_Type; Value : in Clear_Side_Type) is begin Element.Style ("clear", Value'Img); end Clear_Side; ------------------ -- Layout_Float -- ------------------ procedure Layout_Float (Element : in out Element_Type; Value : in Float_Type) is begin Element.Style ("float", Value'Img); end Layout_Float; ------------- -- Display -- ------------- procedure Display (Element : in out Element_Type; Value : in String) is begin Element.Style ("display", Value); end Display; function Display (Element : Element_Type) return String is begin return Element.Style ("display"); end Display; -------------- -- Overflow -- -------------- procedure Overflow (Element : in out Element_Type; Value : in Overflow_Type) is begin Element.Style ("overflow", Value'Img); end Overflow; function Overflow (Element : Element_Type) return Overflow_Type is begin return Overflow_Type'Value (Element.Style ("overflow")); exception when E : others => Log ("Error Overflow converting to Overflow_Type" & " (forced to Visible)."); Log (Ada.Exceptions.Exception_Information (E)); return Visible; end Overflow; ---------------- -- Overflow_X -- ---------------- procedure Overflow_X (Element : in out Element_Type; Value : in Overflow_Type) is begin Element.Style ("overflow-x", Value'Img); end Overflow_X; ---------------- -- Overflow_Y -- ---------------- procedure Overflow_Y (Element : in out Element_Type; Value : in Overflow_Type) is begin Element.Style ("overflow-y", Value'Img); end Overflow_Y; ------------- -- Z_Index -- ------------- procedure Z_Index (Element : in out Element_Type; Value : in Integer) is begin Element.Style ("z-index", Value'Img); end Z_Index; --------------- -- Resizable -- --------------- procedure Resizable (Element : in out Element_Type; Value : in Resizable_Type) is begin Element.Style ("resize", Value'Img); end Resizable; function Resizable (Element : Element_Type) return Resizable_Type is begin return Resizable_Type'Value (Element.Style ("resize")); exception when E : others => Log ("Error Resizable converting to Resizable_Type" & " (forced to None)."); Log (Ada.Exceptions.Exception_Information (E)); return None; end Resizable; -------------- -- Position -- -------------- procedure Position (Element : in out Element_Type; Value : in Position_Type) is begin Element.Style ("position", Value'Img); end Position; function Position (Element : Element_Type) return Position_Type is begin return Position_Type'Value (Element.Style ("position")); exception when E : others => Log ("Error Position converting to Position_Type" & " (forced to Static)."); Log (Ada.Exceptions.Exception_Information (E)); return Static; end Position; ------------------ -- Position_Top -- ------------------ function Position_Top (Element : Element_Type) return Integer is begin return Element.jQuery_Execute ("position().top"); end Position_Top; ------------------- -- Position_Left -- ------------------- function Position_Left (Element : Element_Type) return Integer is begin return Element.jQuery_Execute ("position().left"); end Position_Left; --------------------- -- Offset_From_Top -- --------------------- function Offset_From_Top (Element : Element_Type) return Integer is begin return Element.jQuery_Execute ("offset().top"); end Offset_From_Top; ---------------------- -- Offset_From_Left -- ---------------------- function Offset_From_Left (Element : Element_Type) return Integer is begin return Element.jQuery_Execute ("offset().left"); end Offset_From_Left; ---------- -- Left -- ---------- procedure Left (Element : in out Element_Type; Value : in Integer; Unit : in String := "px") is begin Element.Style ("left", Left_Trim (Value'Img) & Unit); end Left; procedure Left (Element : in out Element_Type; Value : in String) is begin Element.Style ("left", Value); end Left; function Left (Element : Element_Type) return String is begin return Element.Style ("left"); end Left; ----------- -- Right -- ----------- procedure Right (Element : in out Element_Type; Value : in Integer; Unit : in String := "px") is begin Element.Style ("right", Left_Trim (Value'Img) & Unit); end Right; procedure Right (Element : in out Element_Type; Value : in String) is begin Element.Style ("right", Value); end Right; function Right (Element : Element_Type) return String is begin return Element.Style ("right"); end Right; --------- -- Top -- --------- procedure Top (Element : in out Element_Type; Value : in Integer; Unit : in String := "px") is begin Element.Style ("top", Left_Trim (Value'Img) & Unit); end Top; procedure Top (Element : in out Element_Type; Value : in String) is begin Element.Style ("top", Value); end Top; function Top (Element : Element_Type) return String is begin return Element.Style ("top"); end Top; ------------ -- Bottom -- ------------ procedure Bottom (Element : in out Element_Type; Value : in Integer; Unit : in String := "px") is begin Element.Style ("bottom", Left_Trim (Value'Img) & Unit); end Bottom; procedure Bottom (Element : in out Element_Type; Value : in String) is begin Element.Style ("bottom", Value); end Bottom; function Bottom (Element : Element_Type) return String is begin return Element.Style ("bottom"); end Bottom; ---------------- -- Box_Height -- ---------------- procedure Box_Height (Element : in out Element_Type; Value : in Integer; Unit : in String := "px") is begin Element.Style ("height", Left_Trim (Value'Img) & Unit); end Box_Height; procedure Box_Height (Element : in out Element_Type; Value : in String) is begin Element.Style ("height", Value); end Box_Height; function Box_Height (Element : Element_Type) return String is begin return Element.Style ("height"); end Box_Height; -------------------- -- Minimum_Height -- -------------------- procedure Minimum_Height (Element : in out Element_Type; Value : in Integer; Unit : in String := "px") is begin Element.Style ("min-height", Left_Trim (Value'Img) & Unit); end Minimum_Height; procedure Minimum_Height (Element : in out Element_Type; Value : in String) is begin Element.Style ("min-height", Value); end Minimum_Height; function Minimum_Height (Element : Element_Type) return String is begin return Element.Style ("min-height"); end Minimum_Height; -------------------- -- Maximum_Height -- -------------------- procedure Maximum_Height (Element : in out Element_Type; Value : in Integer; Unit : in String := "px") is begin Element.Style ("max-height", Left_Trim (Value'Img) & Unit); end Maximum_Height; procedure Maximum_Height (Element : in out Element_Type; Value : in String) is begin Element.Style ("max-height", Value); end Maximum_Height; function Maximum_Height (Element : Element_Type) return String is begin return Element.Style ("max-height"); end Maximum_Height; --------------- -- Box_Width -- --------------- procedure Box_Width (Element : in out Element_Type; Value : in Integer; Unit : in String := "px") is begin Element.Style ("width", Left_Trim (Value'Img) & Unit); end Box_Width; procedure Box_Width (Element : in out Element_Type; Value : in String) is begin Element.Style ("width", Value); end Box_Width; function Box_Width (Element : Element_Type) return String is begin return Element.Style ("width"); end Box_Width; ------------------- -- Minimum_Width -- ------------------- procedure Minimum_Width (Element : in out Element_Type; Value : in Integer; Unit : in String := "px") is begin Element.Style ("min-width", Left_Trim (Value'Img) & Unit); end Minimum_Width; procedure Minimum_Width (Element : in out Element_Type; Value : in String) is begin Element.Style ("min-width", Value); end Minimum_Width; function Minimum_Width (Element : Element_Type) return String is begin return Element.Style ("min-width"); end Minimum_Width; ------------------- -- Maximum_Width -- ------------------- procedure Maximum_Width (Element : in out Element_Type; Value : in Integer; Unit : in String := "px") is begin Element.Style ("max-width", Left_Trim (Value'Img) & Unit); end Maximum_Width; procedure Maximum_Width (Element : in out Element_Type; Value : in String) is begin Element.Style ("max-width", Value); end Maximum_Width; function Maximum_Width (Element : Element_Type) return String is begin return Element.Style ("max-width"); end Maximum_Width; --------------- -- Draggable -- --------------- procedure Draggable (Element : in out Element_Type; Value : in Boolean := True) is begin Element.Property ("draggable", Value); end Draggable; function Draggable (Element : Element_Type) return Boolean is begin return Element.Property ("draggable"); end Draggable; ------------ -- Hidden -- ------------ procedure Hidden (Element : in out Element_Type; Value : in Boolean := True) is begin Element.Property ("hidden", Value); end Hidden; function Hidden (Element : Element_Type) return Boolean is begin return Element.Property ("hidden"); end Hidden; ---------------- -- Inner_HTML -- ---------------- procedure Inner_HTML (Element : in out Element_Type; Value : in String) is begin Element.jQuery_Execute ("html ('" & Escape_Quotes (Value) & "');"); end Inner_HTML; function Inner_HTML (Element : Element_Type) return String is begin return Element.jQuery_Execute ("html();"); end Inner_HTML; ---------------- -- Outer_HTML -- ---------------- function Outer_HTML (Element : Element_Type) return String is begin return Element.Execute ("outerHTML"); end Outer_HTML; ----------------- -- Spell_Check -- ----------------- procedure Spell_Check (Element : in out Element_Type; Value : in Boolean := True) is begin Element.Property ("spellcheck", Value); end Spell_Check; function Spell_Check (Element : Element_Type) return Boolean is begin return Element.Property ("spellcheck"); end Spell_Check; --------------- -- Tab_Index -- --------------- procedure Tab_Index (Element : in out Element_Type; Value : in Natural) is begin Element.Property ("tabIndex", Value); end Tab_Index; function Tab_Index (Element : Element_Type) return Natural is begin return Element.Property ("tabIndex"); end Tab_Index; ---------- -- Text -- ---------- procedure Text (Element : in out Element_Type; Value : in String) is begin Element.jQuery_Execute ("text ('" & Escape_Quotes (Value) & "');"); end Text; function Text (Element : Element_Type) return String is begin return Element.jQuery_Execute ("text();"); end Text; -------------------- -- Text_Direction -- -------------------- procedure Text_Direction (Element : in out Element_Type; Value : in Text_Direction_Type) is function To_String return String; function To_String return String is begin if Value = Right_To_Left then return "rtl"; else return "ltr"; end if; end To_String; begin Element.Property ("dir", To_String); end Text_Direction; function Text_Direction (Element : Element_Type) return Text_Direction_Type is function To_TDT return Text_Direction_Type; function To_TDT return Text_Direction_Type is begin if Element.Property ("dir") = "rtl" then return Right_To_Left; else return Left_To_Right; end if; end To_TDT; begin return To_TDT; end Text_Direction; ------------------- -- Language_Code -- ------------------- procedure Language_Code (Element : in out Element_Type; Value : in String) is begin Element.Property ("lang", Value); end Language_Code; function Language_Code (Element : Element_Type) return String is begin return Element.Property ("lang"); end Language_Code; ------------- -- Visible -- ------------- procedure Visible (Element : in out Element_Type; Value : in Boolean := True) is begin if Value then Element.Style ("visibility", "visible"); else Element.Style ("visibility", "hidden"); end if; end Visible; function Visible (Element : Element_Type) return Boolean is begin return Element.Style ("visibility") = "visible"; end Visible; ------------------ -- Inner_Height -- ------------------ procedure Inner_Height (Element : in out Element_Type; Value : in Integer) is begin Element.jQuery_Execute ("innerHeight(" & Left_Trim (Value'Img) & ");"); end Inner_Height; function Inner_Height (Element : Element_Type) return Integer is begin return Element.jQuery_Execute ("innerHeight();"); end Inner_Height; ----------------- -- Inner_Width -- ----------------- procedure Inner_Width (Element : in out Element_Type; Value : in Integer) is begin Element.jQuery_Execute ("innerWidth(" & Left_Trim (Value'Img) & ");"); end Inner_Width; function Inner_Width (Element : Element_Type) return Integer is begin return Element.jQuery_Execute ("innerWidth();"); end Inner_Width; ------------------ -- Outer_Height -- ------------------ function Outer_Height (Element : Element_Type) return Integer is begin return Element.jQuery_Execute ("outerHeight();"); end Outer_Height; ----------------- -- Outer_Width -- ----------------- function Outer_Width (Element : Element_Type) return Integer is begin return Element.jQuery_Execute ("outerWidth();"); end Outer_Width; ---------------------------- -- Outer_Height_To_Margin -- ---------------------------- function Outer_Height_To_Margin (Element : Element_Type) return Integer is begin return Element.jQuery_Execute ("outerHeight(true);"); end Outer_Height_To_Margin; --------------------------- -- Outer_Width_To_Margin -- --------------------------- function Outer_Width_To_Margin (Element : Element_Type) return Integer is begin return Element.jQuery_Execute ("outerWidth(true);"); end Outer_Width_To_Margin; ------------------- -- Client_Height -- ------------------- function Client_Height (Element : Element_Type) return Natural is begin return Element.Property ("clientHeight"); end Client_Height; ------------------ -- Client_Width -- ------------------ function Client_Width (Element : Element_Type) return Natural is begin return Element.Property ("clientWidth"); end Client_Width; ------------------ -- Client_Left -- ------------------ function Client_Left (Element : Element_Type) return Natural is begin return Element.Property ("clientLeft"); end Client_Left; ------------------ -- Client_Top -- ------------------ function Client_Top (Element : Element_Type) return Natural is begin return Element.Property ("clientTop"); end Client_Top; ------------------- -- Offset_Height -- ------------------- function Offset_Height (Element : Element_Type) return Integer is begin return Element.Property ("offsetHeight"); end Offset_Height; ------------------ -- Offset_Width -- ------------------ function Offset_Width (Element : Element_Type) return Integer is begin return Element.Property ("offsetWidth"); end Offset_Width; ------------------ -- Offset_Left -- ------------------ function Offset_Left (Element : Element_Type) return Integer is begin return Element.Property ("offsetLeft"); end Offset_Left; ------------------ -- Offset_Top -- ------------------ function Offset_Top (Element : Element_Type) return Integer is begin return Element.Property ("offsetTop"); end Offset_Top; ------------------- -- Scroll_Height -- ------------------- function Scroll_Height (Element : Element_Type) return Natural is begin return Element.Property ("scrollHeight"); end Scroll_Height; ------------------ -- Scroll_Width -- ------------------ function Scroll_Width (Element : Element_Type) return Natural is begin return Element.Property ("scrollWidth"); end Scroll_Width; ------------------ -- Scroll_Left -- ------------------ procedure Scroll_Left (Element : in out Element_Type; Value : Integer) is begin Element.Property ("scrollLeft", Value); end Scroll_Left; function Scroll_Left (Element : Element_Type) return Integer is begin return Element.Property ("scrollLeft"); end Scroll_Left; ------------------ -- Scroll_Top -- ------------------ procedure Scroll_Top (Element : in out Element_Type; Value : Integer) is begin Element.Property ("scrollTop", Value); end Scroll_Top; function Scroll_Top (Element : Element_Type) return Integer is begin return Element.Property ("scrollTop"); end Scroll_Top; ----------- -- Color -- ----------- procedure Color (Element : in out Element_Type; Value : String) is begin Element.Style ("color", Value); end Color; procedure Color (Element : in out Element_Type; RGBA : Gnoga.RGBA_Type) is begin Element.Style ("color", Gnoga.To_String (RGBA)); end Color; procedure Color (Element : in out Element_Type; Enum : Gnoga.Colors.Color_Enumeration) is begin Element.Style ("color", Gnoga.Colors.To_String (Enum)); end Color; function Color (Element : Element_Type) return Gnoga.RGBA_Type is begin return Gnoga.To_RGBA (Element.Style ("color")); end Color; ------------- -- Opacity -- ------------- procedure Opacity (Element : in out Element_Type; Alpha : in Gnoga.Alpha_Type) is begin Element.Style ("opacity", Alpha'Img); end Opacity; function Opacity (Element : Element_Type) return Gnoga.Alpha_Type is begin return Gnoga.Alpha_Type'Value (Element.Style ("opacity")); exception when E : others => Log ("Error Opacity converting to Alpha_Type (forced to 1.0)."); Log (Ada.Exceptions.Exception_Information (E)); return 1.0; end Opacity; --------------------------- -- Background_Attachment -- --------------------------- procedure Background_Attachment (Element : in out Element_Type; Value : in Background_Attachment_Type) is begin Element.Style ("background-attachment", Value'Img); end Background_Attachment; function Background_Attachment (Element : Element_Type) return Background_Attachment_Type is Value : constant String := Element.Style ("background-color"); begin if Value = "" then return Scroll; else return Background_Attachment_Type'Value (Value); end if; end Background_Attachment; ---------------------- -- Background_Color -- ---------------------- procedure Background_Color (Element : in out Element_Type; Value : String) is begin Element.Style ("background-color", Value); end Background_Color; procedure Background_Color (Element : in out Element_Type; RGBA : Gnoga.RGBA_Type) is begin Element.Style ("background-color", Gnoga.To_String (RGBA)); end Background_Color; procedure Background_Color (Element : in out Element_Type; Enum : Gnoga.Colors.Color_Enumeration) is begin Element.Style ("background-color", Gnoga.Colors.To_String (Enum)); end Background_Color; function Background_Color (Element : Element_Type) return Gnoga.RGBA_Type is begin return Gnoga.To_RGBA (Element.Style ("background-color")); end Background_Color; ---------------------- -- Background_Image -- ---------------------- procedure Background_Image (Element : in out Element_Type; Value : in String) is begin if Value = "" then Element.Style ("background-image", "none"); else Element.Style ("background-image", "url('" & Value & "')"); end if; end Background_Image; function Background_Image (Element : Element_Type) return String is begin return Element.Style ("background-image"); end Background_Image; ------------------------- -- Background_Position -- ------------------------- procedure Background_Position (Element : in out Element_Type; Value : in String) is begin Element.Style ("background-position", Value); end Background_Position; function Background_Position (Element : Element_Type) return String is begin return Element.Style ("background-position"); end Background_Position; ----------------------- -- Background_Origin -- ----------------------- procedure Background_Origin (Element : in out Element_Type; Value : in String) is begin Element.Style ("background-origin", Value); end Background_Origin; function Background_Origin (Element : Element_Type) return String is begin return Element.Style ("background-origin"); end Background_Origin; ----------------------- -- Background_Repeat -- ----------------------- procedure Background_Repeat (Element : in out Element_Type; Value : in String) is begin Element.Style ("background-repeat", Value); end Background_Repeat; function Background_Repeat (Element : Element_Type) return String is begin return Element.Style ("background-repeat"); end Background_Repeat; --------------------- -- Background_Clip -- --------------------- procedure Background_Clip (Element : in out Element_Type; Value : in String) is begin Element.Style ("background-clip", Value); end Background_Clip; function Background_Clip (Element : Element_Type) return String is begin return Element.Style ("background-clip"); end Background_Clip; --------------------- -- Background_Size -- --------------------- procedure Background_Size (Element : in out Element_Type; Value : in String) is begin Element.Style ("background-size", Value); end Background_Size; function Background_Size (Element : Element_Type) return String is begin return Element.Style ("background-size"); end Background_Size; ------------ -- Border -- ------------ procedure Border (Element : in out Element_Type; Width : in String := "medium"; Style : in Border_Style := Solid; Color : in Gnoga.Colors.Color_Enumeration := Gnoga.Colors.Black) is begin Element.Style ("border", Width & " " & Style'Img & " " & Gnoga.Colors.To_String (Color)); end Border; ------------------- -- Border_Radius -- ------------------- procedure Border_Radius (Element : in out Element_Type; Radius : in String := "0") is begin Element.Style ("border-radius", Radius); end Border_Radius; ------------ -- Shadow -- ------------ procedure Shadow (Element : in out Element_Type; Horizontal_Position : in String; Vertical_Position : in String; Blur : in String := ""; Spread : in String := ""; Color : in Gnoga.Colors.Color_Enumeration := Gnoga.Colors.Black; Inset_Shadow : in Boolean := False) is function Inset return String; function Inset return String is begin if Inset_Shadow then return "inset"; else return ""; end if; end Inset; begin Element.Style ("box-shadow", Horizontal_Position & " " & Vertical_Position & " " & Blur & " " & Spread & " " & Gnoga.Colors.To_String (Color) & " " & Inset); end Shadow; ----------------- -- Shadow_None -- ----------------- procedure Shadow_None (Element : in out Element_Type) is begin Element.Style ("box-shadow", "none"); end Shadow_None; ------------- -- Outline -- ------------- procedure Outline (Element : in out Element_Type; Color : in String := "invert"; Style : in Outline_Style_Type := None; Width : in String := "medium") is begin Element.Style ("outline", Color & " " & Style'Img & " " & Width); end Outline; ------------ -- Margin -- ------------ procedure Margin (Element : in out Element_Type; Top : in String := "0"; Right : in String := "0"; Bottom : in String := "0"; Left : in String := "0") is begin Element.Style ("margin", Top & " " & Right & " " & Bottom & " " & Left); end Margin; ------------- -- Padding -- ------------- procedure Padding (Element : in out Element_Type; Top : in String := "0"; Right : in String := "0"; Bottom : in String := "0"; Left : in String := "0") is begin Element.Style ("padding", Top & " " & Right & " " & Bottom & " " & Left); end Padding; ------------ -- Cursor -- ------------ procedure Cursor (Element : in out Element_Type; Value : in String) is begin Element.Style ("cursor", Value); end Cursor; function Cursor (Element : Element_Type) return String is begin return Element.Style ("cursor"); end Cursor; ----------- -- Image -- ----------- function Image (Value : in Gnoga.Gui.Element.Font_Weight_Type) return String is W : constant String := Value'Img; begin return W (W'First + 7 .. W'Last); end Image; ----------- -- Value -- ----------- function Value (Value : in String) return Gnoga.Gui.Element.Font_Weight_Type is begin return Gnoga.Gui.Element.Font_Weight_Type'Value ("Weight_" & Value); end Value; ---------- -- Font -- ---------- procedure Font (Element : in out Element_Type; Family : in String := "sans-serif"; Height : in String := "medium"; Style : in Font_Style_Type := Normal; Weight : in Font_Weight_Type := Weight_Normal; Variant : in Font_Variant_Type := Normal) is W : constant String := Weight'Img; begin Element.Style ("font", Style'Img & " " & Variant'Img & " " & W (W'First + 7 .. W'Last) & " " & Height & " " & Family); end Font; procedure Font (Element : in out Element_Type; System_Font : in System_Font_Type) is begin case System_Font is when Caption | Icon | Menu => Element.Style ("font", System_Font'Img); when Message_Box => Element.Style ("font", "message-box"); when Small_Caption => Element.Style ("font", "small-caption"); when Status_Bar => Element.Style ("font", "status-bar"); end case; end Font; -------------------- -- Text_Alignment -- -------------------- procedure Text_Alignment (Element : in out Element_Type; Value : in Alignment_Type) is V : constant String := Value'Img; begin case Value is when Left | Right | Center => Element.Style ("text-align", V); when At_Start | To_End => Element.Style ("text-align", V ((V'First + 3) .. V'Last)); end case; end Text_Alignment; -------------------- -- Vertical_Align -- -------------------- procedure Vertical_Align (Element : in out Element_Type; Value : in Vertical_Align_Type) is begin if Value = Text_Top then Element.Style ("vertical-align", "text-top"); elsif Value = Text_Bottom then Element.Style ("vertical-align", "text-bottom"); else Element.Style ("vertical-align", Value'Img); end if; end Vertical_Align; ----------------- -- First_Child -- ----------------- procedure First_Child (Element : in out Element_Type; Child : in out Element_Type'Class) is begin Child.Attach (Connection_ID => Element.Connection_ID, ID => Element.jQuery_Execute ("children().first().attr('id');"), ID_Type => Gnoga.DOM_ID); end First_Child; ------------------ -- Next_Sibling -- ------------------ procedure Next_Sibling (Element : in out Element_Type; Sibling : in out Element_Type'Class) is begin Sibling.Attach (Connection_ID => Element.Connection_ID, ID => Element.jQuery_Execute ("next().attr('id');"), ID_Type => Gnoga.DOM_ID); end Next_Sibling; -------------- -- HTML_Tag -- -------------- function HTML_Tag (Element : Element_Type) return String is begin return Element.Property ("tagName"); end HTML_Tag; ------------------------------------------------------------------------- -- Element_Type - Methods ------------------------------------------------------------------------- procedure Add_Class (Element : in out Element_Type; Class_Name : in String) is begin Element.jQuery_Execute ("addClass('" & Class_Name & "')"); end Add_Class; procedure Remove_Class (Element : in out Element_Type; Class_Name : in String) is begin Element.jQuery_Execute ("removeClass('" & Class_Name & "')"); end Remove_Class; procedure Toggle_Class (Element : in out Element_Type; Class_Name : in String) is begin Element.jQuery_Execute ("toggleClass('" & Class_Name & "')"); end Toggle_Class; ------------------------- -- Place_Inside_Top_Of -- ------------------------- procedure Place_Inside_Top_Of (Element : in out Element_Type; Target : in out Element_Type'Class) is begin Target.jQuery_Execute ("prepend(" & Element.jQuery & ")"); end Place_Inside_Top_Of; procedure Place_Inside_Bottom_Of (Element : in out Element_Type; Target : in out Element_Type'Class) is begin Target.jQuery_Execute ("append(" & Element.jQuery & ")"); end Place_Inside_Bottom_Of; procedure Place_Before (Element : in out Element_Type; Target : in out Element_Type'Class) is begin Element.jQuery_Execute ("insertBefore(" & Target.jQuery & ")"); end Place_Before; procedure Place_After (Element : in out Element_Type; Target : in out Element_Type'Class) is begin Element.jQuery_Execute ("insertAfter(" & Target.jQuery & ")"); end Place_After; ------------ -- Remove -- ------------ procedure Remove (Element : in out Element_Type) is begin if Element.ID_Type = Gnoga.DOM_ID then declare GID : constant String := Gnoga.Server.Connection.New_GID; begin Element.jQuery_Execute ("gnoga['" & GID & "']=" & Element.jQuery); Element.ID (GID, Gnoga.Gnoga_ID); end; end if; Element.jQuery_Execute ("remove()"); end Remove; ----------- -- Click -- ----------- procedure Click (Element : in out Element_Type) is begin Element.Execute ("click();"); end Click; end Ada_GUI.Gnoga.Gui.Element;
reznikmm/matreshka
Ada
4,121
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.Draw_Textarea_Horizontal_Align_Attributes; package Matreshka.ODF_Draw.Textarea_Horizontal_Align_Attributes is type Draw_Textarea_Horizontal_Align_Attribute_Node is new Matreshka.ODF_Draw.Abstract_Draw_Attribute_Node and ODF.DOM.Draw_Textarea_Horizontal_Align_Attributes.ODF_Draw_Textarea_Horizontal_Align_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Draw_Textarea_Horizontal_Align_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Draw_Textarea_Horizontal_Align_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Draw.Textarea_Horizontal_Align_Attributes;
AdaCore/Ada_Drivers_Library
Ada
2,941
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; use Ada.Interrupts; with STM32.DMA; use STM32.DMA; package STM32F4_DMA_Interrupts is protected type Handler (Controller : access DMA_Controller; Stream : DMA_Stream_Selector; IRQ : Interrupt_ID) is pragma Interrupt_Priority; entry Await_Event (Occurrence : out DMA_Interrupt); private Event_Occurred : Boolean := False; Event_Kind : DMA_Interrupt; procedure IRQ_Handler; pragma Attach_Handler (IRQ_Handler, IRQ); end Handler; end STM32F4_DMA_Interrupts;
ashleygay/adaboy
Ada
4,602
ads
pragma Ada_2005; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; with Interfaces.C.Extensions; with array_hpp; with bitset_hpp; limited with memory_hpp; limited with video_hpp; with word_operations_hpp; package lcd_hpp is type LCDState is (Mode0, Mode1, Mode2, Mode3); pragma Convention (C, LCDState); -- lcd.hpp:18 package Class_State is type State is limited record state : aliased LCDState; -- lcd.hpp:23 duration : aliased int; -- lcd.hpp:27 end record; pragma Import (CPP, State); function can_access_VRAM (this : access constant State) return Extensions.bool; -- lcd.hpp:29 pragma Import (CPP, can_access_VRAM, "_ZNK5State15can_access_VRAMEv"); function can_access_OAM (this : access constant State) return Extensions.bool; -- lcd.hpp:31 pragma Import (CPP, can_access_OAM, "_ZNK5State14can_access_OAMEv"); end; use Class_State; type LCD_states_array is array (0 .. 3) of aliased State; package Class_LCD is type LCD is limited record pixels : aliased array_hpp.template_array_c_array_160.instance; -- lcd.hpp:119 CONTROL : aliased bitset_hpp.template_bitset_8.instance; -- lcd.hpp:134 STATUS : aliased bitset_hpp.template_bitset_8.instance; -- lcd.hpp:150 u_mem : aliased access memory_hpp.Class_Memory.Memory; -- lcd.hpp:152 video : aliased access video_hpp.Class_Video.Video; -- lcd.hpp:153 line : aliased int; -- lcd.hpp:167 current_mode : aliased State; -- lcd.hpp:171 clock : aliased int; -- lcd.hpp:175 sprites : aliased array_hpp.template_array_Class_Sprite_40.instance; -- lcd.hpp:177 on_line : aliased array_hpp.template_array_Class_Sprite_40.instance; -- lcd.hpp:178 states : aliased LCD_states_array; -- lcd.hpp:185 end record; pragma Import (CPP, LCD); function New_LCD (mem : access memory_hpp.Class_Memory.Memory) return LCD; -- lcd.hpp:86 pragma CPP_Constructor (New_LCD, "_ZN3LCDC1ER6Memory"); procedure update_variables (this : access LCD; elapsed_time : int); -- lcd.hpp:93 pragma Import (CPP, update_variables, "_ZN3LCD16update_variablesEi"); procedure step (this : access LCD; elapsed_time : int; s : access unsigned_char); -- lcd.hpp:95 pragma Import (CPP, step, "_ZN3LCD4stepEiPh"); procedure render_tiles (this : access LCD; current_line : int); -- lcd.hpp:98 pragma Import (CPP, render_tiles, "_ZN3LCD12render_tilesEi"); procedure render_sprites (this : access LCD; current_line : int); -- lcd.hpp:100 pragma Import (CPP, render_sprites, "_ZN3LCD14render_spritesEi"); procedure check_lyc (this : access LCD); -- lcd.hpp:110 pragma Import (CPP, check_lyc, "_ZN3LCD9check_lycEv"); procedure check_interrupt_stat (this : access LCD; num_bit : int); -- lcd.hpp:112 pragma Import (CPP, check_interrupt_stat, "_ZN3LCD20check_interrupt_statEi"); procedure draw (this : access LCD; s : access unsigned_char); -- lcd.hpp:114 pragma Import (CPP, draw, "_ZN3LCD4drawEPh"); procedure draw_scanline (this : access LCD); -- lcd.hpp:116 pragma Import (CPP, draw_scanline, "_ZN3LCD13draw_scanlineEv"); function get_tile_num (this : access LCD; tilemap_addr : word_operations_hpp.uint16_t; x : word_operations_hpp.uint8_t; y : word_operations_hpp.uint8_t; is_signed : Extensions.bool) return word_operations_hpp.int16_t; -- lcd.hpp:155 pragma Import (CPP, get_tile_num, "_ZN3LCD12get_tile_numEthhb"); function get_tile_address (this : access LCD; tile_addr : word_operations_hpp.uint16_t; tilenum : word_operations_hpp.int16_t; is_signed : Extensions.bool) return word_operations_hpp.uint16_t; -- lcd.hpp:158 pragma Import (CPP, get_tile_address, "_ZN3LCD16get_tile_addressEtsb"); function get_color_id (this : access LCD; tile_addr : word_operations_hpp.uint16_t; x : word_operations_hpp.uint8_t; y : word_operations_hpp.uint8_t) return word_operations_hpp.uint8_t; -- lcd.hpp:161 pragma Import (CPP, get_color_id, "_ZN3LCD12get_color_idEthh"); function get_color (this : access LCD; id : word_operations_hpp.uint8_t; palette : word_operations_hpp.uint8_t) return int; -- lcd.hpp:163 pragma Import (CPP, get_color, "_ZN3LCD9get_colorEhh"); end; use Class_LCD; end lcd_hpp;
libos-nuse/frankenlibc
Ada
5,994
adb
---------------------------------------------------------------- -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- -- -- -- Open source license information is in the zlib.ads file. -- ---------------------------------------------------------------- -- Id: zlib-streams.adb,v 1.10 2004/05/31 10:53:40 vagul Exp with Ada.Unchecked_Deallocation; package body ZLib.Streams is ----------- -- Close -- ----------- procedure Close (Stream : in out Stream_Type) is procedure Free is new Ada.Unchecked_Deallocation (Stream_Element_Array, Buffer_Access); begin if Stream.Mode = Out_Stream or Stream.Mode = Duplex then -- We should flush the data written by the writer. Flush (Stream, Finish); Close (Stream.Writer); end if; if Stream.Mode = In_Stream or Stream.Mode = Duplex then Close (Stream.Reader); Free (Stream.Buffer); end if; end Close; ------------ -- Create -- ------------ procedure Create (Stream : out Stream_Type; Mode : in Stream_Mode; Back : in Stream_Access; Back_Compressed : in Boolean; Level : in Compression_Level := Default_Compression; Strategy : in Strategy_Type := Default_Strategy; Header : in Header_Type := Default; Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset := Default_Buffer_Size; Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset := Default_Buffer_Size) is subtype Buffer_Subtype is Stream_Element_Array (1 .. Read_Buffer_Size); procedure Init_Filter (Filter : in out Filter_Type; Compress : in Boolean); ----------------- -- Init_Filter -- ----------------- procedure Init_Filter (Filter : in out Filter_Type; Compress : in Boolean) is begin if Compress then Deflate_Init (Filter, Level, Strategy, Header => Header); else Inflate_Init (Filter, Header => Header); end if; end Init_Filter; begin Stream.Back := Back; Stream.Mode := Mode; if Mode = Out_Stream or Mode = Duplex then Init_Filter (Stream.Writer, Back_Compressed); Stream.Buffer_Size := Write_Buffer_Size; else Stream.Buffer_Size := 0; end if; if Mode = In_Stream or Mode = Duplex then Init_Filter (Stream.Reader, not Back_Compressed); Stream.Buffer := new Buffer_Subtype; Stream.Rest_First := Stream.Buffer'Last + 1; Stream.Rest_Last := Stream.Buffer'Last; end if; end Create; ----------- -- Flush -- ----------- procedure Flush (Stream : in out Stream_Type; Mode : in Flush_Mode := Sync_Flush) is Buffer : Stream_Element_Array (1 .. Stream.Buffer_Size); Last : Stream_Element_Offset; begin loop Flush (Stream.Writer, Buffer, Last, Mode); Ada.Streams.Write (Stream.Back.all, Buffer (1 .. Last)); exit when Last < Buffer'Last; end loop; end Flush; ------------- -- Is_Open -- ------------- function Is_Open (Stream : Stream_Type) return Boolean is begin return Is_Open (Stream.Reader) or else Is_Open (Stream.Writer); end Is_Open; ---------- -- Read -- ---------- procedure Read (Stream : in out Stream_Type; Item : out Stream_Element_Array; Last : out Stream_Element_Offset) is procedure Read (Item : out Stream_Element_Array; Last : out Stream_Element_Offset); ---------- -- Read -- ---------- procedure Read (Item : out Stream_Element_Array; Last : out Stream_Element_Offset) is begin Ada.Streams.Read (Stream.Back.all, Item, Last); end Read; procedure Read is new ZLib.Read (Read => Read, Buffer => Stream.Buffer.all, Rest_First => Stream.Rest_First, Rest_Last => Stream.Rest_Last); begin Read (Stream.Reader, Item, Last); end Read; ------------------- -- Read_Total_In -- ------------------- function Read_Total_In (Stream : in Stream_Type) return Count is begin return Total_In (Stream.Reader); end Read_Total_In; -------------------- -- Read_Total_Out -- -------------------- function Read_Total_Out (Stream : in Stream_Type) return Count is begin return Total_Out (Stream.Reader); end Read_Total_Out; ----------- -- Write -- ----------- procedure Write (Stream : in out Stream_Type; Item : in Stream_Element_Array) is procedure Write (Item : in Stream_Element_Array); ----------- -- Write -- ----------- procedure Write (Item : in Stream_Element_Array) is begin Ada.Streams.Write (Stream.Back.all, Item); end Write; procedure Write is new ZLib.Write (Write => Write, Buffer_Size => Stream.Buffer_Size); begin Write (Stream.Writer, Item, No_Flush); end Write; -------------------- -- Write_Total_In -- -------------------- function Write_Total_In (Stream : in Stream_Type) return Count is begin return Total_In (Stream.Writer); end Write_Total_In; --------------------- -- Write_Total_Out -- --------------------- function Write_Total_Out (Stream : in Stream_Type) return Count is begin return Total_Out (Stream.Writer); end Write_Total_Out; end ZLib.Streams;
sungyeon/drake
Ada
17,835
adb
with Ada.Exception_Identification.From_Here; with Ada.Exceptions.Finally; with Ada.Streams.Naked_Stream_IO.Standard_Files; with System.Address_To_Named_Access_Conversions; with System.Native_IO; with System.Standard_Allocators; with System.Storage_Elements; with System.Wide_Startup; -- that is also linked by Ada.Command_Line with System.Zero_Terminated_WStrings; with System.Debug; -- assertions with C.string; with C.windef; with C.winerror; package body System.Native_Processes is use Ada.Exception_Identification.From_Here; use type Ada.Command_Line.Exit_Status; use type Storage_Elements.Storage_Offset; use type C.size_t; use type C.windef.DWORD; use type C.windef.WINBOOL; use type C.windef.UINT; use type C.winnt.HANDLE; -- C.void_ptr use type C.winnt.LPWSTR; -- Command_Type function memchr ( s : Address; c : Integer; n : Storage_Elements.Storage_Count) return Address with Import, Convention => Intrinsic, External_Name => "__builtin_memchr"; package LPWSTR_Conv is new Address_To_Named_Access_Conversions (C.winnt.WCHAR, C.winnt.LPWSTR); package LPWSTR_ptr_Conv is new Address_To_Named_Access_Conversions ( C.winnt.LPWSTR, C.winnt.LPWSTR_ptr); function "+" (Left : C.winnt.LPWSTR_ptr; Right : C.ptrdiff_t) return C.winnt.LPWSTR_ptr with Convention => Intrinsic; pragma Inline_Always ("+"); function "+" (Left : C.winnt.LPWSTR_ptr; Right : C.ptrdiff_t) return C.winnt.LPWSTR_ptr is begin return LPWSTR_ptr_Conv.To_Pointer ( LPWSTR_ptr_Conv.To_Address (Left) + Storage_Elements.Storage_Offset (Right) * (C.winnt.LPWSTR'Size / Standard'Storage_Unit)); end "+"; procedure Reallocate (X : in out Command_Type; Length : C.size_t); procedure Reallocate (X : in out Command_Type; Length : C.size_t) is Size : constant Storage_Elements.Storage_Count := (Storage_Elements.Storage_Offset (Length) + 1) -- NUL * (C.winnt.WCHAR'Size / Standard'Storage_Unit); begin X := LPWSTR_Conv.To_Pointer ( Standard_Allocators.Reallocate (LPWSTR_Conv.To_Address (X), Size)); end Reallocate; procedure C_Append ( Command : Command_Type; Index : in out C.size_t; New_Item : not null C.winnt.LPWSTR); procedure C_Append ( Command : Command_Type; Index : in out C.size_t; New_Item : not null C.winnt.LPWSTR) is New_Item_Length : constant C.size_t := C.string.wcslen (New_Item); Command_All : C.winnt.WCHAR_array ( 0 .. Index + New_Item_Length + 3); -- ' ' & '"' & '"' & NUL for Command_All'Address use LPWSTR_Conv.To_Address (Command); begin if Index > 0 then Command_All (Index) := C.winnt.WCHAR'Val (Character'Pos (' ')); Index := Index + 1; end if; declare Has_Space : constant Boolean := C.string.wcschr ( New_Item, C.wchar_t'Val (Character'Pos (' '))) /= null; begin if Has_Space then Command_All (Index) := C.winnt.WCHAR'Val (Character'Pos ('"')); Index := Index + 1; end if; if New_Item_Length > 0 then declare New_Item_All : C.winnt.WCHAR_array (0 .. New_Item_Length - 1); for New_Item_All'Address use LPWSTR_Conv.To_Address (New_Item); begin Command_All (Index .. Index + New_Item_Length - 1) := New_Item_All; Index := Index + New_Item_Length; end; end if; if Has_Space then Command_All (Index) := C.winnt.WCHAR'Val (Character'Pos ('"')); Index := Index + 1; end if; end; Command_All (Index) := C.winnt.WCHAR'Val (0); end C_Append; -- implementation procedure Free (X : in out Command_Type) is begin Standard_Allocators.Free (LPWSTR_Conv.To_Address (X)); X := null; end Free; function Image (Command : Command_Type) return String is begin return Zero_Terminated_WStrings.Value (Command); end Image; procedure Value ( Command_Line : String; Command : aliased out Command_Type) is Size : constant Storage_Elements.Storage_Count := (Command_Line'Length * Zero_Terminated_WStrings.Expanding + 1) * (C.winnt.WCHAR'Size / Standard'Storage_Unit); begin Command := LPWSTR_Conv.To_Pointer (Standard_Allocators.Allocate (Size)); Zero_Terminated_WStrings.To_C (Command_Line, Command); end Value; procedure Append ( Command : aliased in out Command_Type; New_Item : String) is W_New_Item : aliased C.winnt.WCHAR_array ( 0 .. New_Item'Length * Zero_Terminated_WStrings.Expanding); W_New_Item_Length : C.size_t; Old_Length : C.size_t; begin Zero_Terminated_WStrings.To_C ( New_Item, W_New_Item (0)'Access, W_New_Item_Length); if Command = null then Old_Length := 0; else Old_Length := C.string.wcslen (Command); end if; Reallocate ( Command, Old_Length + W_New_Item_Length + 3); -- space and a pair of '"' C_Append (Command, Old_Length, W_New_Item (0)'Unchecked_Access); end Append; procedure Append ( Command : aliased in out Command_Type; First : Positive; Last : Natural) is pragma Assert (Last >= First); Old_Length : C.size_t; Additional_Length : C.size_t := 0; begin -- get length for I in First .. Last loop declare P : constant C.winnt.LPWSTR_ptr := LPWSTR_ptr_Conv.To_Pointer (Wide_Startup.wargv) + C.ptrdiff_t (I); begin Additional_Length := Additional_Length + C.string.wcslen (P.all) + 3; -- space and a pair of '"' end; end loop; if Command = null then Old_Length := 0; else Old_Length := C.string.wcslen (Command); end if; Reallocate (Command, Old_Length + Additional_Length); -- copy declare Index : C.size_t := Old_Length; begin for I in First .. Last loop declare P : constant C.winnt.LPWSTR_ptr := LPWSTR_ptr_Conv.To_Pointer (Wide_Startup.wargv) + C.ptrdiff_t (I); begin C_Append (Command, Index, P.all); end; end loop; end; end Append; procedure Append_Argument ( Command_Line : in out String; Last : in out Natural; Argument : String) is Argument_Length : constant Natural := Argument'Length; Has_Space : Boolean; begin -- add separator if Last >= Command_Line'First then if Last >= Command_Line'Last then raise Constraint_Error; end if; Last := Last + 1; Command_Line (Last) := ' '; end if; -- find space in argument Has_Space := memchr ( Argument'Address, Character'Pos (' '), Storage_Elements.Storage_Offset (Argument_Length)) /= Null_Address; -- open if Has_Space then if Last >= Command_Line'Last then raise Constraint_Error; end if; Last := Last + 1; Command_Line (Last) := '"'; end if; -- argument if Last + Argument_Length > Command_Line'Last then raise Constraint_Error; end if; Command_Line (Last + 1 .. Last + Argument_Length) := Argument; Last := Last + Argument_Length; -- close if Has_Space then if Last >= Command_Line'Last then raise Constraint_Error; end if; Last := Last + 1; Command_Line (Last) := '"'; end if; end Append_Argument; -- child process management procedure Wait ( Child : in out Process; Milliseconds : C.windef.DWORD; Terminated : out Boolean; Status : out Ada.Command_Line.Exit_Status); procedure Wait ( Child : in out Process; Milliseconds : C.windef.DWORD; Terminated : out Boolean; Status : out Ada.Command_Line.Exit_Status) is begin case C.winbase.WaitForSingleObject (Child.Handle, Milliseconds) is when C.winbase.WAIT_OBJECT_0 => declare Max : constant := C.windef.DWORD'Modulus / 2; -- 2 ** 31 Exit_Code : aliased C.windef.DWORD; Success : C.windef.WINBOOL; begin Success := C.winbase.GetExitCodeProcess ( Child.Handle, Exit_Code'Access); if C.winbase.CloseHandle (Child.Handle) = C.windef.FALSE or else Success = C.windef.FALSE then Raise_Exception (Use_Error'Identity); end if; Child := Null_Process; -- status code if Exit_Code < Max then Status := Ada.Command_Line.Exit_Status (Exit_Code); else -- terminated by an unhandled exception Status := -1; end if; Terminated := True; end; when C.winerror.WAIT_TIMEOUT => Terminated := False; when others => Raise_Exception (Use_Error'Identity); end case; end Wait; -- implementation of child process management function Is_Open (Child : Process) return Boolean is begin return Child.Handle /= C.winbase.INVALID_HANDLE_VALUE; end Is_Open; procedure Create ( Child : in out Process; Command : Command_Type; Directory : String := ""; Search_Path : Boolean := False; Input : Ada.Streams.Naked_Stream_IO.Non_Controlled_File_Type; Output : Ada.Streams.Naked_Stream_IO.Non_Controlled_File_Type; Error : Ada.Streams.Naked_Stream_IO.Non_Controlled_File_Type) is pragma Unreferenced (Search_Path); W_Directory : aliased C.winnt.WCHAR_array (0 .. Directory'Length); Directory_Ref : access constant C.winnt.WCHAR; Startup_Info : aliased C.winbase.STARTUPINFO; Process_Info : aliased C.winbase.PROCESS_INFORMATION; Current_Process : constant C.winnt.HANDLE := C.winbase.GetCurrentProcess; subtype Handle_Index is Integer range 0 .. 2; Source_Files : array (Handle_Index) of Ada.Streams.Naked_Stream_IO.Non_Controlled_File_Type; Target_Handles : array (Handle_Index) of C.winnt.HANDLE; Duplicated_Handles : array (Handle_Index) of aliased C.winnt.HANDLE; Success : C.windef.WINBOOL; begin C.winbase.GetStartupInfo (Startup_Info'Access); Startup_Info.dwFlags := C.winbase.STARTF_USESTDHANDLES or C.winbase.STARTF_FORCEOFFFEEDBACK; Source_Files (0) := Input; Source_Files (1) := Output; Source_Files (2) := Error; for I in Handle_Index loop declare Source_Handle : constant C.winnt.HANDLE := Ada.Streams.Naked_Stream_IO.Handle (Source_Files (I)); begin if Ada.Streams.Naked_Stream_IO.Is_Standard (Source_Files (I)) then Duplicated_Handles (I) := C.winbase.INVALID_HANDLE_VALUE; Target_Handles (I) := Source_Handle; else if C.winbase.DuplicateHandle ( hSourceProcessHandle => Current_Process, hSourceHandle => Source_Handle, hTargetProcessHandle => Current_Process, lpTargetHandle => Duplicated_Handles (I)'Access, dwDesiredAccess => 0, bInheritHandle => 1, dwOptions => C.winnt.DUPLICATE_SAME_ACCESS) = C.windef.FALSE then Raise_Exception (Use_Error'Identity); end if; Target_Handles (I) := Duplicated_Handles (I); end if; end; end loop; Startup_Info.hStdInput := Target_Handles (0); Startup_Info.hStdOutput := Target_Handles (1); Startup_Info.hStdError := Target_Handles (2); if Directory'Length > 0 then Zero_Terminated_WStrings.To_C (Directory, W_Directory (0)'Access); Directory_Ref := W_Directory (0)'Access; else Directory_Ref := null; end if; Success := C.winbase.CreateProcess ( lpApplicationName => null, lpCommandLine => Command, lpProcessAttributes => null, lpThreadAttributes => null, bInheritHandles => 1, dwCreationFlags => 0, lpEnvironment => C.windef.LPVOID (Null_Address), lpCurrentDirectory => Directory_Ref, lpStartupInfo => Startup_Info'Access, lpProcessInformation => Process_Info'Access); for I in Handle_Index loop if Duplicated_Handles (I) /= C.winbase.INVALID_HANDLE_VALUE then if C.winbase.CloseHandle (Duplicated_Handles (I)) = C.windef.FALSE then Raise_Exception (Use_Error'Identity); end if; end if; end loop; if Success = C.windef.FALSE then declare Error : constant C.windef.DWORD := C.winbase.GetLastError; begin case Error is when C.winerror.ERROR_FILE_NOT_FOUND | C.winerror.ERROR_PATH_NOT_FOUND | C.winerror.ERROR_INVALID_NAME => Raise_Exception (Name_Error'Identity); when others => Raise_Exception (Native_IO.IO_Exception_Id (Error)); end case; end; else if C.winbase.CloseHandle (Process_Info.hThread) = C.windef.FALSE then Raise_Exception (Use_Error'Identity); end if; Child.Handle := Process_Info.hProcess; end if; end Create; procedure Create ( Child : in out Process; Command_Line : String; Directory : String := ""; Search_Path : Boolean := False; Input : Ada.Streams.Naked_Stream_IO.Non_Controlled_File_Type; Output : Ada.Streams.Naked_Stream_IO.Non_Controlled_File_Type; Error : Ada.Streams.Naked_Stream_IO.Non_Controlled_File_Type) is W_Command_Line : aliased C.winnt.WCHAR_array ( 0 .. Command_Line'Length * Zero_Terminated_WStrings.Expanding); begin Zero_Terminated_WStrings.To_C (Command_Line, W_Command_Line (0)'Access); Create ( Child, W_Command_Line (0)'Unchecked_Access, Directory, Search_Path, Input, Output, Error); end Create; procedure Close (Child : in out Process) is begin if Is_Open (Child) then declare Success : C.windef.WINBOOL; begin Success := C.winbase.CloseHandle (Child.Handle); pragma Check (Debug, Check => Success /= C.windef.FALSE or else Debug.Runtime_Error ("CloseHandle failed")); end; end if; end Close; procedure Wait ( Child : in out Process; Status : out Ada.Command_Line.Exit_Status) is begin loop declare Terminated : Boolean; begin Wait (Child, C.winbase.INFINITE, Terminated => Terminated, Status => Status); exit when Terminated; end; end loop; end Wait; procedure Wait_Immediate ( Child : in out Process; Terminated : out Boolean; Status : out Ada.Command_Line.Exit_Status) is begin Wait (Child, 0, Terminated => Terminated, Status => Status); end Wait_Immediate; procedure Forced_Abort_Process (Child : Process) is Code : constant C.windef.UINT := -1; -- the MSB should be 1 ??? begin if C.winbase.TerminateProcess (Child.Handle, Code) = C.windef.FALSE then declare Exit_Code : aliased C.windef.DWORD; begin -- It is not an error if the process is already terminated. if C.winbase.GetLastError /= C.winerror.ERROR_ACCESS_DENIED or else C.winbase.GetExitCodeProcess ( Child.Handle, Exit_Code'Access) = C.windef.FALSE or else Exit_Code = C.winbase.STILL_ACTIVE then Raise_Exception (Use_Error'Identity); end if; end; end if; end Forced_Abort_Process; -- implementation of pass a command to the shell procedure Shell ( Command : Command_Type; Status : out Ada.Command_Line.Exit_Status) is -- unimplemented, should use ShellExecute package Holder is new Ada.Exceptions.Finally.Scoped_Holder (Process, Close); P : aliased Process := Null_Process; begin Holder.Assign (P); Create (P, Command, Search_Path => True, Input => Ada.Streams.Naked_Stream_IO.Standard_Files.Standard_Input, Output => Ada.Streams.Naked_Stream_IO.Standard_Files.Standard_Output, Error => Ada.Streams.Naked_Stream_IO.Standard_Files.Standard_Error); Wait (P, Status); end Shell; procedure Shell ( Command_Line : String; Status : out Ada.Command_Line.Exit_Status) is package Holder is new Ada.Exceptions.Finally.Scoped_Holder (Command_Type, Free); Command : aliased Command_Type; begin Holder.Assign (Command); Value (Command_Line, Command); Shell (Command, Status); end Shell; end System.Native_Processes;
tum-ei-rcs/StratoX
Ada
34,927
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of STMicroelectronics nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- -- -- -- This file is based on: -- -- -- -- @file stm32f4xx_hal_dma.c -- -- @author MCD Application Team -- -- @version V1.1.0 -- -- @date 19-June-2014 -- -- @brief DMA HAL module driver. -- Extended by Technical Unversity of Munich, Martin Becker -- -- -- -- COPYRIGHT(c) 2014 STMicroelectronics -- ------------------------------------------------------------------------------ with Ada.Unchecked_Conversion; with System.Storage_Elements; with STM32_SVD.DMA; use STM32_SVD.DMA; package body STM32.DMA is type DMA_Stream_Record is record -- configuration register CR : S0CR_Register; -- number of data register NDTR : S0NDTR_Register; -- peripheral address register PAR : Word; -- memory 0 address register M0AR : Word; -- memory 1 address register M1AR : Word; -- FIFO control register FCR : S0FCR_Register; end record with Volatile; for DMA_Stream_Record use record CR at 0 range 0 .. 31; NDTR at 4 range 0 .. 31; PAR at 8 range 0 .. 31; M0AR at 12 range 0 .. 31; M1AR at 16 range 0 .. 31; FCR at 20 range 0 .. 31; end record; type DMA_Stream is access all DMA_Stream_Record; function Get_Stream (Port : DMA_Controller; Num : DMA_Stream_Selector) return DMA_Stream with Inline; procedure Set_Interrupt_Enabler (This_Stream : DMA_Stream; Source : DMA_Interrupt; Value : Boolean); -- An internal routine, used to enable and disable the specified interrupt function "-" is new Ada.Unchecked_Conversion (Memory_Buffer_Target, Boolean); function "-" is new Ada.Unchecked_Conversion (Boolean, Memory_Buffer_Target); ---------------- -- Get_Stream -- ---------------- function Get_Stream (Port : DMA_Controller; Num : DMA_Stream_Selector) return DMA_Stream is Addr : System.Address; function To_Stream is new Ada.Unchecked_Conversion (System.Address, DMA_Stream); begin case Num is when Stream_0 => Addr := Port.S0CR'Address; when Stream_1 => Addr := Port.S1CR'Address; when Stream_2 => Addr := Port.S2CR'Address; when Stream_3 => Addr := Port.S3CR'Address; when Stream_4 => Addr := Port.S4CR'Address; when Stream_5 => Addr := Port.S5CR'Address; when Stream_6 => Addr := Port.S6CR'Address; when Stream_7 => Addr := Port.S7CR'Address; end case; return To_Stream (Addr); end Get_Stream; ------------ -- Enable -- ------------ procedure Enable (Unit : DMA_Controller; Stream : DMA_Stream_Selector) is begin Get_Stream (Unit, Stream).CR.EN := True; end Enable; ------------- -- Enabled -- ------------- function Enabled (Unit : DMA_Controller; Stream : DMA_Stream_Selector) return Boolean is begin return Get_Stream (Unit, Stream).CR.EN; end Enabled; ------------- -- Disable -- ------------- procedure Disable (Unit : DMA_Controller; Stream : DMA_Stream_Selector) is begin Get_Stream (Unit, Stream).CR.EN := False; -- the STMicro Reference Manual RM0090, Doc Id 018909 Rev 6, pg 319, -- step 1 says we must await the bit actually clearing, to confirm no -- ongoing operation remains active. loop exit when not Enabled (Unit, Stream); end loop; end Disable; --------------------------- -- Set_Interrupt_Enabler -- --------------------------- procedure Set_Interrupt_Enabler (This_Stream : DMA_Stream; Source : DMA_Interrupt; Value : Boolean) is begin case Source is when Direct_Mode_Error_Interrupt => This_Stream.CR.DMEIE := Value; when Transfer_Error_Interrupt => This_Stream.CR.TEIE := Value; when Half_Transfer_Complete_Interrupt => This_Stream.CR.HTIE := Value; when Transfer_Complete_Interrupt => This_Stream.CR.TCIE := Value; when FIFO_Error_Interrupt => This_Stream.FCR.FEIE := Value; end case; end Set_Interrupt_Enabler; ---------------------- -- Enable_Interrupt -- ---------------------- procedure Enable_Interrupt (Unit : DMA_Controller; Stream : DMA_Stream_Selector; Source : DMA_Interrupt) is begin Set_Interrupt_Enabler (Get_Stream (Unit, Stream), Source, True); end Enable_Interrupt; ----------------------- -- Disable_Interrupt -- ----------------------- procedure Disable_Interrupt (Unit : DMA_Controller; Stream : DMA_Stream_Selector; Source : DMA_Interrupt) is begin Set_Interrupt_Enabler (Get_Stream (Unit, Stream), Source, False); end Disable_Interrupt; ----------------------- -- Interrupt_Enabled -- ----------------------- function Interrupt_Enabled (Unit : DMA_Controller; Stream : DMA_Stream_Selector; Source : DMA_Interrupt) return Boolean is Result : Boolean; This_Stream : DMA_Stream renames Get_Stream (Unit, Stream); -- this is a bit heavy, considering it will be called from interrupt -- handlers. -- TODO: consider a much lower level implementation, based on bit-masks. begin case Source is when Direct_Mode_Error_Interrupt => Result := This_Stream.CR.DMEIE; when Transfer_Error_Interrupt => Result := This_Stream.CR.TEIE; when Half_Transfer_Complete_Interrupt => Result := This_Stream.CR.HTIE; when Transfer_Complete_Interrupt => Result := This_Stream.CR.TCIE; when FIFO_Error_Interrupt => Result := This_Stream.FCR.FEIE; end case; return Result; end Interrupt_Enabled; -------------------- -- Start_Transfer -- -------------------- procedure Start_Transfer (Unit : DMA_Controller; Stream : DMA_Stream_Selector; Source : Address; Destination : Address; Data_Count : Short) is begin Disable (Unit, Stream); -- per the RM, eg section 10.5.6 for the NDTR Configure_Data_Flow (Unit, Stream, Source => Source, Destination => Destination, Data_Count => Data_Count); Enable (Unit, Stream); end Start_Transfer; ------------------------------------ -- Start_Transfer_with_Interrupts -- ------------------------------------ procedure Start_Transfer_with_Interrupts (Unit : DMA_Controller; Stream : DMA_Stream_Selector; Source : Address; Destination : Address; Data_Count : Short; Enabled_Interrupts : Interrupt_Selections := (others => True)) is begin Disable (Unit, Stream); -- per the RM, eg section 10.5.6 for the NDTR Configure_Data_Flow (Unit, Stream, Source => Source, Destination => Destination, Data_Count => Data_Count); for Selected_Interrupt in Enabled_Interrupts'Range loop if Enabled_Interrupts (Selected_Interrupt) then Enable_Interrupt (Unit, Stream, Selected_Interrupt); else Disable_Interrupt (Unit, Stream, Selected_Interrupt); end if; end loop; Enable (Unit, Stream); end Start_Transfer_with_Interrupts; ------------------------- -- Configure_Data_Flow -- ------------------------- procedure Configure_Data_Flow (Unit : DMA_Controller; Stream : DMA_Stream_Selector; Source : Address; Destination : Address; Data_Count : Short) is This_Stream : DMA_Stream renames Get_Stream (Unit, Stream); function W is new Ada.Unchecked_Conversion (Address, Word); begin -- the following assignment has NO EFFECT if flow is controlled by -- peripheral. The hardware resets it to 16#FFFF#, see RM0090 10.3.15. This_Stream.NDTR.NDT := Data_Count; if This_Stream.CR.DIR = Memory_To_Peripheral'Enum_Rep then This_Stream.PAR := W (Destination); This_Stream.M0AR := W (Source); else This_Stream.PAR := W (Source); This_Stream.M0AR := W (Destination); end if; end Configure_Data_Flow; -------------------- -- Abort_Transfer -- -------------------- procedure Abort_Transfer (Unit : DMA_Controller; Stream : DMA_Stream_Selector; Result : out DMA_Error_Code) is Max_Abort_Time : constant Time_Span := Seconds (1); Timeout : Time; This_Stream : DMA_Stream renames Get_Stream (Unit, Stream); begin Disable (Unit, Stream); Timeout := Clock + Max_Abort_Time; loop exit when not This_Stream.CR.EN; if Clock > Timeout then Result := DMA_Timeout_Error; return; end if; end loop; Result := DMA_No_Error; end Abort_Transfer; ------------------------- -- Poll_For_Completion -- ------------------------- procedure Poll_For_Completion (Unit : in out DMA_Controller; Stream : DMA_Stream_Selector; Expected_Level : DMA_Transfer_Level; Timeout : Time_Span; Result : out DMA_Error_Code) is Deadline : constant Time := Clock + Timeout; begin Result := DMA_No_Error; -- initially anyway Polling : loop if Expected_Level = Full_Transfer then exit Polling when Status (Unit, Stream, Transfer_Complete_Indicated); else exit Polling when Status (Unit, Stream, Half_Transfer_Complete_Indicated); end if; if Status (Unit, Stream, Transfer_Error_Indicated) or Status (Unit, Stream, FIFO_Error_Indicated) or Status (Unit, Stream, Direct_Mode_Error_Indicated) then Clear_Status (Unit, Stream, Transfer_Error_Indicated); Clear_Status (Unit, Stream, FIFO_Error_Indicated); Clear_Status (Unit, Stream, Direct_Mode_Error_Indicated); Result := DMA_Device_Error; return; end if; if Clock > Deadline then Result := DMA_Timeout_Error; return; end if; end loop Polling; Clear_Status (Unit, Stream, Half_Transfer_Complete_Indicated); if Expected_Level = Full_Transfer then Clear_Status (Unit, Stream, Transfer_Complete_Indicated); else Clear_Status (Unit, Stream, Half_Transfer_Complete_Indicated); end if; end Poll_For_Completion; ------------------ -- Clear_Status -- ------------------ procedure Clear_Status (Unit : in out DMA_Controller; Stream : DMA_Stream_Selector; Flag : DMA_Status_Flag) is begin case Stream is when Stream_0 => case Flag is when FIFO_Error_Indicated => Unit.LIFCR.CFEIF0 := True; when Direct_Mode_Error_Indicated => Unit.LIFCR.CDMEIF0 := True; when Transfer_Error_Indicated => Unit.LIFCR.CTEIF0 := True; when Half_Transfer_Complete_Indicated => Unit.LIFCR.CHTIF0 := True; when Transfer_Complete_Indicated => Unit.LIFCR.CTCIF0 := True; end case; when Stream_1 => case Flag is when FIFO_Error_Indicated => Unit.LIFCR.CFEIF1 := True; when Direct_Mode_Error_Indicated => Unit.LIFCR.CDMEIF1 := True; when Transfer_Error_Indicated => Unit.LIFCR.CTEIF1 := True; when Half_Transfer_Complete_Indicated => Unit.LIFCR.CHTIF1 := True; when Transfer_Complete_Indicated => Unit.LIFCR.CTCIF1 := True; end case; when Stream_2 => case Flag is when FIFO_Error_Indicated => Unit.LIFCR.CFEIF2 := True; when Direct_Mode_Error_Indicated => Unit.LIFCR.CDMEIF2 := True; when Transfer_Error_Indicated => Unit.LIFCR.CTEIF2 := True; when Half_Transfer_Complete_Indicated => Unit.LIFCR.CHTIF2 := True; when Transfer_Complete_Indicated => Unit.LIFCR.CTCIF2 := True; end case; when Stream_3 => case Flag is when FIFO_Error_Indicated => Unit.LIFCR.CFEIF3 := True; when Direct_Mode_Error_Indicated => Unit.LIFCR.CDMEIF3 := True; when Transfer_Error_Indicated => Unit.LIFCR.CTEIF3 := True; when Half_Transfer_Complete_Indicated => Unit.LIFCR.CHTIF3 := True; when Transfer_Complete_Indicated => Unit.LIFCR.CTCIF3 := True; end case; when Stream_4 => case Flag is when FIFO_Error_Indicated => Unit.HIFCR.CFEIF4 := True; when Direct_Mode_Error_Indicated => Unit.HIFCR.CDMEIF4 := True; when Transfer_Error_Indicated => Unit.HIFCR.CTEIF4 := True; when Half_Transfer_Complete_Indicated => Unit.HIFCR.CHTIF4 := True; when Transfer_Complete_Indicated => Unit.HIFCR.CTCIF4 := True; end case; when Stream_5 => case Flag is when FIFO_Error_Indicated => Unit.HIFCR.CFEIF5 := True; when Direct_Mode_Error_Indicated => Unit.HIFCR.CDMEIF5 := True; when Transfer_Error_Indicated => Unit.HIFCR.CTEIF5 := True; when Half_Transfer_Complete_Indicated => Unit.HIFCR.CHTIF5 := True; when Transfer_Complete_Indicated => Unit.HIFCR.CTCIF5 := True; end case; when Stream_6 => case Flag is when FIFO_Error_Indicated => Unit.HIFCR.CFEIF6 := True; when Direct_Mode_Error_Indicated => Unit.HIFCR.CDMEIF6 := True; when Transfer_Error_Indicated => Unit.HIFCR.CTEIF6 := True; when Half_Transfer_Complete_Indicated => Unit.HIFCR.CHTIF6 := True; when Transfer_Complete_Indicated => Unit.HIFCR.CTCIF6 := True; end case; when Stream_7 => case Flag is when FIFO_Error_Indicated => Unit.HIFCR.CFEIF7 := True; when Direct_Mode_Error_Indicated => Unit.HIFCR.CDMEIF7 := True; when Transfer_Error_Indicated => Unit.HIFCR.CTEIF7 := True; when Half_Transfer_Complete_Indicated => Unit.HIFCR.CHTIF7 := True; when Transfer_Complete_Indicated => Unit.HIFCR.CTCIF7 := True; end case; end case; end Clear_Status; ---------------------- -- Clear_All_Status -- ---------------------- procedure Clear_All_Status (Unit : in out DMA_Controller; Stream : DMA_Stream_Selector) is begin case Stream is when Stream_0 => Unit.LIFCR.CFEIF0 := True; Unit.LIFCR.CDMEIF0 := True; Unit.LIFCR.CTEIF0 := True; Unit.LIFCR.CHTIF0 := True; Unit.LIFCR.CTCIF0 := True; when Stream_1 => Unit.LIFCR.CFEIF1 := True; Unit.LIFCR.CDMEIF1 := True; Unit.LIFCR.CTEIF1 := True; Unit.LIFCR.CHTIF1 := True; Unit.LIFCR.CTCIF1 := True; when Stream_2 => Unit.LIFCR.CFEIF2 := True; Unit.LIFCR.CDMEIF2 := True; Unit.LIFCR.CTEIF2 := True; Unit.LIFCR.CHTIF2 := True; Unit.LIFCR.CTCIF2 := True; when Stream_3 => Unit.LIFCR.CFEIF3 := True; Unit.LIFCR.CDMEIF3 := True; Unit.LIFCR.CTEIF3 := True; Unit.LIFCR.CHTIF3 := True; Unit.LIFCR.CTCIF3 := True; when Stream_4 => Unit.HIFCR.CFEIF4 := True; Unit.HIFCR.CDMEIF4 := True; Unit.HIFCR.CTEIF4 := True; Unit.HIFCR.CHTIF4 := True; Unit.HIFCR.CTCIF4 := True; when Stream_5 => Unit.HIFCR.CFEIF5 := True; Unit.HIFCR.CDMEIF5 := True; Unit.HIFCR.CTEIF5 := True; Unit.HIFCR.CHTIF5 := True; Unit.HIFCR.CTCIF5 := True; when Stream_6 => Unit.HIFCR.CFEIF6 := True; Unit.HIFCR.CDMEIF6 := True; Unit.HIFCR.CTEIF6 := True; Unit.HIFCR.CHTIF6 := True; Unit.HIFCR.CTCIF6 := True; when Stream_7 => Unit.HIFCR.CFEIF7 := True; Unit.HIFCR.CDMEIF7 := True; Unit.HIFCR.CTEIF7 := True; Unit.HIFCR.CHTIF7 := True; Unit.HIFCR.CTCIF7 := True; end case; end Clear_All_Status; ------------ -- Status -- ------------ function Status (Unit : DMA_Controller; Stream : DMA_Stream_Selector; Flag : DMA_Status_Flag) return Boolean is begin case Stream is when Stream_0 => case Flag is when FIFO_Error_Indicated => return Unit.LISR.FEIF0; when Direct_Mode_Error_Indicated => return Unit.LISR.DMEIF0; when Transfer_Error_Indicated => return Unit.LISR.TEIF0; when Half_Transfer_Complete_Indicated => return Unit.LISR.HTIF0; when Transfer_Complete_Indicated => return Unit.LISR.TCIF0; end case; when Stream_1 => case Flag is when FIFO_Error_Indicated => return Unit.LISR.FEIF1; when Direct_Mode_Error_Indicated => return Unit.LISR.DMEIF1; when Transfer_Error_Indicated => return Unit.LISR.TEIF1; when Half_Transfer_Complete_Indicated => return Unit.LISR.HTIF1; when Transfer_Complete_Indicated => return Unit.LISR.TCIF1; end case; when Stream_2 => case Flag is when FIFO_Error_Indicated => return Unit.LISR.FEIF2; when Direct_Mode_Error_Indicated => return Unit.LISR.DMEIF2; when Transfer_Error_Indicated => return Unit.LISR.TEIF2; when Half_Transfer_Complete_Indicated => return Unit.LISR.HTIF2; when Transfer_Complete_Indicated => return Unit.LISR.TCIF2; end case; when Stream_3 => case Flag is when FIFO_Error_Indicated => return Unit.LISR.FEIF3; when Direct_Mode_Error_Indicated => return Unit.LISR.DMEIF3; when Transfer_Error_Indicated => return Unit.LISR.TEIF3; when Half_Transfer_Complete_Indicated => return Unit.LISR.HTIF3; when Transfer_Complete_Indicated => return Unit.LISR.TCIF3; end case; when Stream_4 => case Flag is when FIFO_Error_Indicated => return Unit.HISR.FEIF4; when Direct_Mode_Error_Indicated => return Unit.HISR.DMEIF4; when Transfer_Error_Indicated => return Unit.HISR.TEIF4; when Half_Transfer_Complete_Indicated => return Unit.HISR.HTIF4; when Transfer_Complete_Indicated => return Unit.HISR.TCIF4; end case; when Stream_5 => case Flag is when FIFO_Error_Indicated => return Unit.HISR.FEIF5; when Direct_Mode_Error_Indicated => return Unit.HISR.DMEIF5; when Transfer_Error_Indicated => return Unit.HISR.TEIF5; when Half_Transfer_Complete_Indicated => return Unit.HISR.HTIF5; when Transfer_Complete_Indicated => return Unit.HISR.TCIF5; end case; when Stream_6 => case Flag is when FIFO_Error_Indicated => return Unit.HISR.FEIF6; -- underrun or overrunprint when Direct_Mode_Error_Indicated => return Unit.HISR.DMEIF6; when Transfer_Error_Indicated => return Unit.HISR.TEIF6; when Half_Transfer_Complete_Indicated => return Unit.HISR.HTIF6; when Transfer_Complete_Indicated => return Unit.HISR.TCIF6; end case; when Stream_7 => case Flag is when FIFO_Error_Indicated => return Unit.HISR.FEIF7; when Direct_Mode_Error_Indicated => return Unit.HISR.DMEIF7; when Transfer_Error_Indicated => return Unit.HISR.TEIF7; when Half_Transfer_Complete_Indicated => return Unit.HISR.HTIF7; when Transfer_Complete_Indicated => return Unit.HISR.TCIF7; end case; end case; end Status; ----------------- -- Set_Counter -- ----------------- procedure Set_NDT (Unit : DMA_Controller; Stream : DMA_Stream_Selector; Data_Count : Short) is This_Stream : DMA_Stream renames Get_Stream (Unit, Stream); begin This_Stream.NDTR.NDT := Data_Count; end Set_NDT; function Items_Transferred (Unit : DMA_Controller; Stream : DMA_Stream_Selector) return Short is ndt : constant Unsigned_16 := Current_NDT (Unit, Stream); items : Unsigned_16; begin if Operating_Mode (Unit, Stream) = Peripheral_Flow_Control_Mode then items := 16#ffff# - ndt; else items := ndt; end if; return items; end Items_Transferred; function Current_NDT (Unit : DMA_Controller; Stream : DMA_Stream_Selector) return Short is This_Stream : DMA_Stream renames Get_Stream (Unit, Stream); begin return This_Stream.NDTR.NDT; end Current_NDT; --------------------- -- Double_Buffered -- --------------------- function Double_Buffered (Unit : DMA_Controller; Stream : DMA_Stream_Selector) return Boolean is begin return Get_Stream (Unit, Stream).CR.DBM; end Double_Buffered; ------------------- -- Circular_Mode -- ------------------- function Circular_Mode (Unit : DMA_Controller; Stream : DMA_Stream_Selector) return Boolean is begin return Get_Stream (Unit, Stream).CR.CIRC; end Circular_Mode; --------------- -- Configure -- --------------- procedure Configure (Unit : DMA_Controller; Stream : DMA_Stream_Selector; Config : DMA_Stream_Configuration) is -- see HAL_DMA_Init in STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_dma.h This_Stream : DMA_Stream renames Get_Stream (Unit, Stream); begin -- the STMicro Reference Manual RM0090, Doc Id 018909 Rev 6, pg 319 says -- we must disable the stream before configuring it Disable (Unit, Stream); This_Stream.CR.CT := -Memory_Buffer_0; This_Stream.CR.DBM := False; This_Stream.CR.CHSEL := DMA_Channel_Selector'Enum_Rep (Config.Channel); This_Stream.CR.DIR := DMA_Data_Transfer_Direction'Enum_Rep (Config.Direction); This_Stream.CR.PINC := Config.Increment_Peripheral_Address; This_Stream.CR.MINC := Config.Increment_Memory_Address; This_Stream.CR.PSIZE := DMA_Data_Transfer_Widths'Enum_Rep (Config.Peripheral_Data_Format); This_Stream.CR.MSIZE := DMA_Data_Transfer_Widths'Enum_Rep (Config.Memory_Data_Format); This_Stream.CR.PL := DMA_Priority_Level'Enum_Rep (Config.Priority); case Config.Operation_Mode is when Normal_Mode => This_Stream.CR.PFCTRL := False; -- DMA is the flow controller This_Stream.CR.CIRC := False; -- Disable circular mode when Peripheral_Flow_Control_Mode => This_Stream.CR.PFCTRL := True; -- Peripheral is the flow ctrl. This_Stream.CR.CIRC := False; -- Disable circular mode when Circular_Mode => This_Stream.CR.PFCTRL := False; -- DMA is the flow controller This_Stream.CR.CIRC := True; -- Enable circular mode end case; -- the memory burst and peripheral burst values are only used when -- the FIFO is enabled if Config.FIFO_Enabled then This_Stream.CR.MBURST := DMA_Memory_Burst'Enum_Rep (Config.Memory_Burst_Size); This_Stream.CR.PBURST := DMA_Peripheral_Burst'Enum_Rep (Config.Peripheral_Burst_Size); else This_Stream.CR.MBURST := Memory_Burst_Single'Enum_Rep; This_Stream.CR.PBURST := Peripheral_Burst_Single'Enum_Rep; end if; -- was : This_Stream.FCR.DMDIS := not Config.FIFO_Enabled; This_Stream.FCR.DMDIS := Config.FIFO_Enabled; -- but this is correct if Config.FIFO_Enabled then This_Stream.FCR.FTH := DMA_FIFO_Threshold_Level'Enum_Rep (Config.FIFO_Threshold); else This_Stream.FCR.FTH := FIFO_Threshold_1_Quart_Full_Configuration'Enum_Rep; -- 0, default end if; end Configure; ----------- -- Reset -- ----------- procedure Reset (Unit : in out DMA_Controller; Stream : DMA_Stream_Selector) is This_Stream : DMA_Stream renames Get_Stream (Unit, Stream); begin Disable (Unit, Stream); This_Stream.CR := (others => <>); This_Stream.NDTR.NDT := 0; This_Stream.PAR := 0; This_Stream.M0AR := 0; This_Stream.M1AR := 0; This_Stream.FCR := (others => <>); Clear_All_Status (Unit, Stream); end Reset; --------------------------- -- Peripheral_Data_Width -- --------------------------- function Peripheral_Data_Width (Unit : DMA_Controller; Stream : DMA_Stream_Selector) return DMA_Data_Transfer_Widths is begin return DMA_Data_Transfer_Widths'Val (Get_Stream (Unit, Stream).CR.PSIZE); end Peripheral_Data_Width; ----------------------- -- Memory_Data_Width -- ----------------------- function Memory_Data_Width (Unit : DMA_Controller; Stream : DMA_Stream_Selector) return DMA_Data_Transfer_Widths is begin return DMA_Data_Transfer_Widths'Val (Get_Stream (Unit, Stream).CR.MSIZE); end Memory_Data_Width; ------------------------ -- Transfer_Direction -- ------------------------ function Transfer_Direction (Unit : DMA_Controller; Stream : DMA_Stream_Selector) return DMA_Data_Transfer_Direction is begin return DMA_Data_Transfer_Direction'Val (Get_Stream (Unit, Stream).CR.DIR); end Transfer_Direction; -------------------- -- Operating_Mode -- -------------------- function Operating_Mode (Unit : DMA_Controller; Stream : DMA_Stream_Selector) return DMA_Mode is begin if Get_Stream (Unit, Stream).CR.PFCTRL then return Peripheral_Flow_Control_Mode; elsif Get_Stream (Unit, Stream).CR.CIRC then return Circular_Mode; end if; return Normal_Mode; end Operating_Mode; -------------- -- Priority -- -------------- function Priority (Unit : DMA_Controller; Stream : DMA_Stream_Selector) return DMA_Priority_Level is begin return DMA_Priority_Level'Val (Get_Stream (Unit, Stream).CR.PL); end Priority; --------------------------- -- Current_Memory_Buffer -- --------------------------- function Current_Memory_Buffer (Unit : DMA_Controller; Stream : DMA_Stream_Selector) return Memory_Buffer_Target is begin return -Get_Stream (Unit, Stream).CR.CT; end Current_Memory_Buffer; ----------------------- -- Set_Memory_Buffer -- ----------------------- procedure Set_Memory_Buffer (Unit : DMA_Controller; Stream : DMA_Stream_Selector; Buffer : Memory_Buffer_Target; To : System.Address) is function W is new Ada.Unchecked_Conversion (System.Address, Word); This_Stream : DMA_Stream renames Get_Stream (Unit, Stream); begin case Buffer is when Memory_Buffer_0 => This_Stream.M0AR := W (To); when Memory_Buffer_1 => This_Stream.M1AR := W (To); end case; end Set_Memory_Buffer; ---------------------------------- -- Select_Current_Memory_Buffer -- ---------------------------------- procedure Select_Current_Memory_Buffer (Unit : DMA_Controller; Stream : DMA_Stream_Selector; Buffer : Memory_Buffer_Target) is begin Get_Stream (Unit, Stream).CR.CT := -Buffer; end Select_Current_Memory_Buffer; ------------------------------------ -- Configure_Double_Buffered_Mode -- ------------------------------------ procedure Configure_Double_Buffered_Mode (Unit : DMA_Controller; Stream : DMA_Stream_Selector; Buffer_0_Value : Address; Buffer_1_Value : Address; First_Buffer_Used : Memory_Buffer_Target) is begin Set_Memory_Buffer (Unit, Stream, Memory_Buffer_0, Buffer_0_Value); Set_Memory_Buffer (Unit, Stream, Memory_Buffer_1, Buffer_1_Value); Select_Current_Memory_Buffer (Unit, Stream, First_Buffer_Used); end Configure_Double_Buffered_Mode; --------------------------------- -- Enable_Double_Buffered_Mode -- --------------------------------- procedure Enable_Double_Buffered_Mode (Unit : DMA_Controller; Stream : DMA_Stream_Selector) is begin Get_Stream (Unit, Stream).CR.DBM := True; end Enable_Double_Buffered_Mode; ---------------------------------- -- Disable_Double_Buffered_Mode -- ---------------------------------- procedure Disable_Double_Buffered_Mode (Unit : DMA_Controller; Stream : DMA_Stream_Selector) is begin Get_Stream (Unit, Stream).CR.DBM := False; end Disable_Double_Buffered_Mode; ---------------------- -- Selected_Channel -- ---------------------- function Selected_Channel (Unit : DMA_Controller; Stream : DMA_Stream_Selector) return DMA_Channel_Selector is begin return DMA_Channel_Selector'Val (Get_Stream (Unit, Stream).CR.CHSEL); end Selected_Channel; ------------- -- Aligned -- ------------- function Aligned (This : Address; Width : DMA_Data_Transfer_Widths) return Boolean is use System.Storage_Elements; begin case Width is when Words => return To_Integer (This) mod 4 = 0; when HalfWords => return To_Integer (This) mod 2 = 0; when Bytes => return True; end case; end Aligned; end STM32.DMA;
pdaxrom/Kino2
Ada
3,615
ads
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- Status -- -- -- -- 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: Laurent Pautet <[email protected]> -- Modified by: Juergen Pfeifer, 1997 -- Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en -- Version Control -- $Revision: 1.8 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ -- This package has been contributed by Laurent Pautet <[email protected]> -- -- -- with Ada.Interrupts.Names; package Status is pragma Warnings (Off); -- the next pragma exists since 3.11p pragma Unreserve_All_Interrupts; pragma Warnings (On); protected Process is procedure Stop; function Continue return Boolean; pragma Attach_Handler (Stop, Ada.Interrupts.Names.SIGINT); private Done : Boolean := False; end Process; end Status;
reznikmm/matreshka
Ada
4,805
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.Text_Sender_Postal_Code_Elements; package Matreshka.ODF_Text.Sender_Postal_Code_Elements is type Text_Sender_Postal_Code_Element_Node is new Matreshka.ODF_Text.Abstract_Text_Element_Node and ODF.DOM.Text_Sender_Postal_Code_Elements.ODF_Text_Sender_Postal_Code with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_Sender_Postal_Code_Element_Node; overriding function Get_Local_Name (Self : not null access constant Text_Sender_Postal_Code_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Text_Sender_Postal_Code_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 Text_Sender_Postal_Code_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 Text_Sender_Postal_Code_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_Text.Sender_Postal_Code_Elements;
godunko/adawebui
Ada
4,500
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2016-2020, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision: 5703 $ $Date: 2017-01-20 22:17:20 +0300 (Пт, 20 янв 2017) $ ------------------------------------------------------------------------------ package body Web.Core.Connectables.Slots_0.Emitters is ------------- -- Connect -- ------------- overriding procedure Connect (Self : in out Emitter; Slot : Slots_0.Slot'Class) is Slot_End : Slot_End_Access := Slot.Create_Slot_End; Signal_End : Signal_End_Access := new Emitters.Signal_End (Self'Unchecked_Access); begin Slot_End.Attach; Signal_End.Attach; Signal_End.Slot_End := Slot_End; end Connect; ---------- -- Emit -- ---------- procedure Emit (Self : in out Emitter'Class) is Current : Signal_End_Access := Self.Head; begin while Current /= null loop begin Signal_End'Class (Current.all).Invoke; exception when others => null; end; Current := Current.Next; end loop; end Emit; ------------ -- Invoke -- ------------ procedure Invoke (Self : in out Signal_End'Class) is begin Slot_End_0'Class (Self.Slot_End.all).Invoke; end Invoke; end Web.Core.Connectables.Slots_0.Emitters;
dan76/Amass
Ada
1,711
ads
-- Copyright © by Jeff Foley 2017-2023. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. -- SPDX-License-Identifier: Apache-2.0 local json = require("json") name = "Hunter" type = "api" function start() set_rate_limit(1) end function check() local c local cfg = datasrc_config() if (cfg ~= nil) then c = cfg.credentials end if (c ~= nil and c.key ~= nil and c.key ~= "") then return true end return false end function vertical(ctx, domain) local c local cfg = datasrc_config() if (cfg ~= nil) then c = cfg.credentials end if (c == nil or c.key == nil or c.key == "") then return end local resp, err = request(ctx, {['url']=build_url(domain, c.key)}) if (err ~= nil and err ~= "") then log(ctx, "vertical request to service failed: " .. err) return elseif (resp.status_code < 200 or resp.status_code >= 400) then log(ctx, "vertical request to service returned with status: " .. resp.status) return end local d = json.decode(resp.body) if (d == nil) then log(ctx, "failed to decode the JSON response") return elseif (d.data == nil or #(d['data'].emails) == 0) then return end for _, email in pairs(d['data'].emails) do for _, src in pairs(email.sources) do if (src ~= nil and src.domain ~= nil and src.domain ~= "") then new_name(ctx, src.domain) end end end end function build_url(domain, key) return "https://api.hunter.io/v2/domain-search?domain=" .. domain .. "&api_key=" .. key end
Letractively/ada-ado
Ada
1,098
ads
----------------------------------------------------------------------- -- ado.schemas.mysql -- Mysql Database Schemas -- Copyright (C) 2009, 2010 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with ADO.Databases; package ADO.Schemas.Mysql is -- Load the database schema procedure Load_Schema (C : in ADO.Databases.Connection'Class; Schema : out Schema_Definition); end ADO.Schemas.Mysql;