repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
stcarrez/ada-util
Ada
845
adb
with Ada.Text_IO; with Util.Serialize.IO.JSON; with Util.Streams.Texts; procedure Serialize is procedure Write (Stream : in out Util.Serialize.IO.Output_Stream'Class); procedure Write (Stream : in out Util.Serialize.IO.Output_Stream'Class) is begin Stream.Start_Document; Stream.Start_Entity ("person"); Stream.Write_Entity ("name", "Harry Potter"); Stream.Write_Entity ("gender", "male"); Stream.Write_Entity ("age", 17); Stream.End_Entity ("person"); Stream.End_Document; end Write; Output : aliased Util.Streams.Texts.Print_Stream; Stream : Util.Serialize.IO.JSON.Output_Stream; begin Output.Initialize (Size => 10000); Stream.Initialize (Output => Output'Unchecked_Access); Write (Stream); Ada.Text_IO.Put_Line (Util.Streams.Texts.To_String (Output)); end Serialize;
zhmu/ananas
Ada
2,495
adb
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- ADA.STRINGS.BOUNDED.HASH_CASE_INSENSITIVE -- -- -- -- B o d y -- -- -- -- Copyright (C) 2011-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/>. -- -- -- -- This unit was originally developed by Matthew J Heaney. -- ------------------------------------------------------------------------------ with Ada.Strings.Hash_Case_Insensitive; function Ada.Strings.Bounded.Hash_Case_Insensitive (Key : Bounded.Bounded_String) return Containers.Hash_Type is begin return Ada.Strings.Hash_Case_Insensitive (Bounded.To_String (Key)); end Ada.Strings.Bounded.Hash_Case_Insensitive;
optikos/oasis
Ada
2,503
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Elements.Declarations; with Program.Elements.Defining_Identifiers; with Program.Lexical_Elements; with Program.Elements.Expressions; package Program.Elements.Return_Object_Specifications is pragma Pure (Program.Elements.Return_Object_Specifications); type Return_Object_Specification is limited interface and Program.Elements.Declarations.Declaration; type Return_Object_Specification_Access is access all Return_Object_Specification'Class with Storage_Size => 0; not overriding function Name (Self : Return_Object_Specification) return not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access is abstract; not overriding function Object_Subtype (Self : Return_Object_Specification) return not null Program.Elements.Element_Access is abstract; not overriding function Expression (Self : Return_Object_Specification) return Program.Elements.Expressions.Expression_Access is abstract; not overriding function Has_Aliased (Self : Return_Object_Specification) return Boolean is abstract; not overriding function Has_Constant (Self : Return_Object_Specification) return Boolean is abstract; type Return_Object_Specification_Text is limited interface; type Return_Object_Specification_Text_Access is access all Return_Object_Specification_Text'Class with Storage_Size => 0; not overriding function To_Return_Object_Specification_Text (Self : aliased in out Return_Object_Specification) return Return_Object_Specification_Text_Access is abstract; not overriding function Colon_Token (Self : Return_Object_Specification_Text) return not null Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Aliased_Token (Self : Return_Object_Specification_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Constant_Token (Self : Return_Object_Specification_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; not overriding function Assignment_Token (Self : Return_Object_Specification_Text) return Program.Lexical_Elements.Lexical_Element_Access is abstract; end Program.Elements.Return_Object_Specifications;
sungyeon/drake
Ada
10,196
adb
package body System.Formatting.Literals is pragma Suppress (All_Checks); use type Long_Long_Integer_Types.Word_Integer; use type Long_Long_Integer_Types.Word_Unsigned; use type Long_Long_Integer_Types.Long_Long_Unsigned; subtype Word_Integer is Long_Long_Integer_Types.Word_Integer; subtype Word_Unsigned is Long_Long_Integer_Types.Word_Unsigned; subtype Long_Long_Unsigned is Long_Long_Integer_Types.Long_Long_Unsigned; procedure Get ( Item : String; Last : in out Natural; Result : out Word_Unsigned; Base : Number_Base; Error : out Boolean); procedure Get ( Item : String; Last : in out Natural; Result : out Word_Unsigned; Base : Number_Base; Error : out Boolean) is begin Value (Item (Last + 1 .. Item'Last), Last, Result, Base => Base, Skip_Underscore => True, Error => Error); end Get; procedure Get ( Item : String; Last : in out Natural; Result : out Long_Long_Unsigned; Base : Number_Base; Error : out Boolean); procedure Get ( Item : String; Last : in out Natural; Result : out Long_Long_Unsigned; Base : Number_Base; Error : out Boolean) is begin Value (Item (Last + 1 .. Item'Last), Last, Result, Base => Base, Skip_Underscore => True, Error => Error); end Get; procedure Get_Literal_Without_Sign ( Item : String; Last : in out Natural; Result : out Word_Unsigned; Error : out Boolean); procedure Get_Literal_Without_Sign ( Item : String; Last : in out Natural; Result : out Word_Unsigned; Error : out Boolean) is Base : Number_Base := 10; Mark : Character; Exponent : Integer; begin Get (Item, Last, Result, Base => Base, Error => Error); if not Error then if Last < Item'Last and then (Item (Last + 1) = '#' or else Item (Last + 1) = ':') then Mark := Item (Last + 1); Last := Last + 1; if Result not in Word_Unsigned (Number_Base'First) .. Word_Unsigned (Number_Base'Last) then Error := True; else Base := Number_Base (Result); Get (Item, Last, Result, Base => Base, Error => Error); if not Error then if Last >= Item'Last or else Item (Last + 1) /= Mark then Error := True; else Last := Last + 1; end if; end if; end if; end if; if not Error then Get_Exponent (Item, Last, Exponent, Positive_Only => True, Error => Error); if not Error and then Exponent /= 0 then Result := Result * Word_Unsigned (Base) ** Exponent; end if; end if; end if; end Get_Literal_Without_Sign; procedure Get_Literal_Without_Sign ( Item : String; Last : in out Natural; Result : out Long_Long_Unsigned; Error : out Boolean); procedure Get_Literal_Without_Sign ( Item : String; Last : in out Natural; Result : out Long_Long_Unsigned; Error : out Boolean) is Base : Number_Base := 10; Mark : Character; Exponent : Integer; begin Get (Item, Last, Result, Base => Base, Error => Error); if not Error then if Last < Item'Last and then (Item (Last + 1) = '#' or else Item (Last + 1) = ':') then Mark := Item (Last + 1); Last := Last + 1; if Result not in Long_Long_Unsigned (Number_Base'First) .. Long_Long_Unsigned (Number_Base'Last) then Error := True; else Base := Number_Base (Result); Get (Item, Last, Result, Base => Base, Error => Error); if not Error then if Last >= Item'Last or else Item (Last + 1) /= Mark then Error := True; else Last := Last + 1; end if; end if; end if; end if; if not Error then Get_Exponent (Item, Last, Exponent, Positive_Only => True, Error => Error); if not Error and then Exponent /= 0 then Result := Result * Long_Long_Unsigned (Base) ** Exponent; end if; end if; end if; end Get_Literal_Without_Sign; -- implementation procedure Skip_Spaces (Item : String; Last : in out Natural) is begin while Last < Item'Last and then Item (Last + 1) = ' ' loop Last := Last + 1; end loop; end Skip_Spaces; procedure Check_Last (Item : String; Last : Natural; Error : out Boolean) is I : Natural := Last; begin Skip_Spaces (Item, I); Error := I /= Item'Last; end Check_Last; procedure Get_Exponent ( Item : String; Last : in out Natural; Result : out Integer; Positive_Only : Boolean; Error : out Boolean) is begin if Last < Item'Last and then (Item (Last + 1) = 'E' or else Item (Last + 1) = 'e') then Last := Last + 1; if Last < Item'Last and then Item (Last + 1) = '-' then if not Positive_Only then Last := Last + 1; Get (Item, Last, Word_Unsigned (Result), Base => 10, Error => Error); -- ignore error Result := -Result; else Error := True; end if; else if Last < Item'Last and then Item (Last + 1) = '+' then Last := Last + 1; end if; Get (Item, Last, Word_Unsigned (Result), Base => 10, Error => Error); end if; else Result := 0; Error := False; end if; end Get_Exponent; procedure Get_Literal ( Item : String; Last : out Natural; Result : out Long_Long_Integer_Types.Word_Integer; Error : out Boolean) is Unsigned_Result : Word_Unsigned; begin Last := Item'First - 1; Skip_Spaces (Item, Last); if Last < Item'Last and then Item (Last + 1) = '-' then Last := Last + 1; Get_Literal_Without_Sign (Item, Last, Unsigned_Result, Error => Error); if not Error then if Unsigned_Result > -Word_Unsigned'Mod (Word_Integer'First) then Error := True; else Result := -Word_Integer (Unsigned_Result); end if; end if; else if Last < Item'Last and then Item (Last + 1) = '+' then Last := Last + 1; end if; Get_Literal_Without_Sign (Item, Last, Unsigned_Result, Error => Error); if not Error then if Unsigned_Result > Word_Unsigned (Word_Integer'Last) then Error := True; else Result := Word_Integer (Unsigned_Result); end if; end if; end if; end Get_Literal; procedure Get_Literal ( Item : String; Last : out Natural; Result : out Long_Long_Integer; Error : out Boolean) is begin if Standard'Word_Size < Long_Long_Integer'Size then -- optimized for 32bit declare Unsigned_Result : Long_Long_Unsigned; begin Last := Item'First - 1; Skip_Spaces (Item, Last); if Last < Item'Last and then Item (Last + 1) = '-' then Last := Last + 1; Get_Literal_Without_Sign (Item, Last, Unsigned_Result, Error => Error); if not Error then if Unsigned_Result > -Long_Long_Unsigned'Mod (Long_Long_Integer'First) then Error := True; else Result := -Long_Long_Integer (Unsigned_Result); end if; end if; else if Last < Item'Last and then Item (Last + 1) = '+' then Last := Last + 1; end if; Get_Literal_Without_Sign (Item, Last, Unsigned_Result, Error => Error); if not Error then if Unsigned_Result > Long_Long_Unsigned (Long_Long_Integer'Last) then Error := True; else Result := Long_Long_Integer (Unsigned_Result); end if; end if; end if; end; else -- optimized for 64bit Get_Literal (Item, Last, Word_Integer (Result), Error); end if; end Get_Literal; procedure Get_Literal ( Item : String; Last : out Natural; Result : out Long_Long_Integer_Types.Word_Unsigned; Error : out Boolean) is begin Last := Item'First - 1; Skip_Spaces (Item, Last); if Last < Item'Last and then Item (Last + 1) = '+' then Last := Last + 1; end if; Get_Literal_Without_Sign (Item, Last, Result, Error => Error); end Get_Literal; procedure Get_Literal ( Item : String; Last : out Natural; Result : out Long_Long_Integer_Types.Long_Long_Unsigned; Error : out Boolean) is begin if Standard'Word_Size < Long_Long_Integer'Size then -- optimized for 32bit Last := Item'First - 1; Skip_Spaces (Item, Last); if Last < Item'Last and then Item (Last + 1) = '+' then Last := Last + 1; end if; Get_Literal_Without_Sign (Item, Last, Result, Error => Error); else -- optimized for 64bit Get_Literal (Item, Last, Word_Unsigned (Result), Error); end if; end Get_Literal; end System.Formatting.Literals;
reznikmm/matreshka
Ada
6,961
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Table.Source_Service_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Table_Source_Service_Element_Node is begin return Self : Table_Source_Service_Element_Node do Matreshka.ODF_Table.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Table_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Table_Source_Service_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Enter_Table_Source_Service (ODF.DOM.Table_Source_Service_Elements.ODF_Table_Source_Service_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Enter_Node (Visitor, Control); end if; end Enter_Node; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Table_Source_Service_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Source_Service_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Table_Source_Service_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Leave_Table_Source_Service (ODF.DOM.Table_Source_Service_Elements.ODF_Table_Source_Service_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Leave_Node (Visitor, Control); end if; end Leave_Node; ---------------- -- Visit_Node -- ---------------- overriding procedure Visit_Node (Self : not null access Table_Source_Service_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then ODF.DOM.Iterators.Abstract_ODF_Iterator'Class (Iterator).Visit_Table_Source_Service (Visitor, ODF.DOM.Table_Source_Service_Elements.ODF_Table_Source_Service_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Visit_Node (Iterator, Visitor, Control); end if; end Visit_Node; begin Matreshka.DOM_Documents.Register_Element (Matreshka.ODF_String_Constants.Table_URI, Matreshka.ODF_String_Constants.Source_Service_Element, Table_Source_Service_Element_Node'Tag); end Matreshka.ODF_Table.Source_Service_Elements;
charlie5/lace
Ada
839
ads
with openGL.Camera, ada.Characters.latin_1; package openGL.Dolly -- -- A utility which moves a camera via the keyboard. -- is type Item (Camera : openGL.Camera.view) is tagged private; procedure Speed_is (Self : in out Item; Now : in Real); procedure evolve (Self : in out Item); function quit_Requested (Self : in Item) return Boolean; procedure get_last_Character (Self : in out Item; the_Character : out Character; Available : out Boolean); private type Item (Camera : openGL.Camera.view) is tagged record quit_Requested : Boolean := False; last_Character : Character := ada.Characters.Latin_1.NUL; Speed : Real := 1.0; end record; end openGL.Dolly;
AdaCore/Ada_Drivers_Library
Ada
3,474
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2016-2017, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ package MicroBit.Display is subtype Coord is Natural range 0 .. 4; procedure Set (X, Y : Coord); -- Set one pixel procedure Clear (X, Y : Coord); -- Clear one pixel procedure Clear; -- Clear all the pixels procedure Display (C : Character); -- Display a character on the screen Scroll_Text_Max_Length : constant := 128; -- Maximum length of a string displayed procedure Display (Str : String) with Pre => Str'Length <= Scroll_Text_Max_Length; -- Display a string on the screen and wait until the end of scrolling procedure Display_Async (Str : String) with Pre => Str'Length <= Scroll_Text_Max_Length; -- Start scrolling a string on the screen and return imediatly while the -- scroll animation continues in the background. procedure Shift_Left; -- Shift all the pixels to the left procedure Set_Animation_Step_Duration (Ms : Natural); -- Set the number of miliseconds between two animation steps function Animation_In_Progress return Boolean; -- Is there an animation in progress? end MicroBit.Display;
adamnemecek/GA_Ada
Ada
34,396
adb
with Interfaces; with Ada.Text_IO; use Ada.Text_IO; with Blade; with Multivector; with Multivector_Type_Base; package body C3GA is MV_Space_Dimension : constant Integer := 5; MV_Metric_Euclidean : constant Boolean := False; type Basis_Name is (NOb, E1b, E2b, E3b, NIb); type Grade_Name is (G0, G1, G2, G3, G4, G5); -- This array can be used to lookup the number of coordinates for -- a grade part of a general multivector MV_Grade_Size : constant array (0 .. 5) of Integer := (1, 5, 10, 10, 5, 1 ); -- This array can be used to lookup the number of coordinates -- based on a grade usage bitmap MV_Size : constant array (1 .. 64) of Integer := (0, 1, 5, 6, 10, 11, 15, 16, 10, 11, 15, 16, 20, 21, 25, 26, 5, 6, 10, 11, 15, 16, 20, 21, 15, 16, 20, 21, 25, 26, 30, 31, 1, 2, 6, 7, 11, 12, 16, 17, 11, 12, 16, 17, 21, 22, 26, 27, 6, 7, 11, 12, 16, 17, 21, 22, 16, 17, 21, 22, 26, 27, 31, 32); -- This array contains the order of basis elements in the general multivector -- Use it to answer : 'at what index do I find basis element (x) -- (x = basis vector bitmap)? MV_Basis_Element_Index_By_Bitmap : constant array (1 .. 32) of Integer := (0, 1, 2, 6, 3, 7, 9, 24, 4, 8, 11, 23, 10, 22, 25, 30, 5, 15, 12, 20, 13, 21, 18, 29, 14, 19, 17, 28, 16, 27, 26, 31); no_basis : constant Vector := (0.0, 0.0, 0.0, 0.0, 1.0); e1_basis : constant Vector := (0.0, 1.0, 0.0, 0.0, 0.0); e2_basis : constant Vector := (0.0, 0.0, 1.0, 0.0, 0.0); e3_basis : constant Vector := (0.0, 0.0, 0.0, 1.0, 0.0); ni_basis : constant Vector := (1.0, 0.0, 0.0, 0.0, 0.0); -- no_BV : constant C3GA.Multivector := Get_Basis_Vector (Blade.no); -- e1_BV : constant C3GA.Multivector := Get_Basis_Vector (Blade.e1); -- e2_BV : constant C3GA.Multivector := Get_Basis_Vector (Blade.e2); -- e3_BV : constant C3GA.Multivector := Get_Basis_Vector (Blade.e3); -- ni_BV : constant C3GA.Multivector := Get_Basis_Vector (Blade.ni); -- function Init (MV : Multivector.Multivector; Epsilon : float; -- Use_Algebra_Metric : Boolean; -- GU_Count : Integer) return MV_Type; -- ------------------------------------------------------------------------- function "+" (V1 : Vector; V2 : Vector) return Vector is begin return (V1 (1) + V2 (1), V1 (2) + V2 (2), V1 (3) + V2 (3), V1 (4) + V2 (4), V1 (5) + V2 (5)); end "+"; -- ------------------------------------------------------------------------- function "*" (F : Float; V : Vector) return Vector is begin return (F * V (1), F * V (2), F * V (3), F * V (4), F * V (5)); end "*"; -- ------------------------------------------------------------------------- function "*" (L : Line; S : Float) return Line is begin return (L.E1_E2_NI * S, L.E1_E3_NI * S, L.E2_E3_NI * S, L.E1_NO_NI * S, L.E2_NO_NI * S, L.E3_NO_NI * S); end "*"; -- ------------------------------------------------------------------------- function "*" (S : Float; L : Line) return Line is begin return L * S; end "*"; -- ------------------------------------------------------------------------- -- function C3GA_Point (V : Vector_E3GA) return Normalized_Point is -- thePoint : Normalized_Point; -- begin -- -- thePoint.Origin of a Normalized_Point is a constant 1.0 -- thePoint.E1 := V.Coordinates (1); -- thePoint.E2 := V.Coordinates (2); -- thePoint.E3 := V.Coordinates (3); -- thePoint.Inf := 0.5 * Norm_E2(V).Coordinates (1) * GA_Base_Types.NI; -- return thePoint; -- end C3GA_Point; -- ------------------------------------------------------------------------ function C3GA_Point (V : Vector_E3GA) return Normalized_Point is use Blade; NP : Normalized_Point; begin -- thePoint.Origin of a Normalized_Point is a constant 1.0 Multivector.Add_Blade (NP, Blade.New_Basis_Blade (C3_no, 1.0)); Multivector.Add_Blade (NP, Blade.New_Basis_Blade (C3_e1, V.Coordinates (1))); Multivector.Add_Blade (NP, Blade.New_Basis_Blade (C3_e2, V.Coordinates (2))); Multivector.Add_Blade (NP, Blade.New_Basis_Blade (C3_e3, V.Coordinates (3))); Multivector.Add_Blade (NP, Blade.New_Basis_Blade (C3_ni, 0.5 * Norm_E2 (V) * GA_Base_Types.NI)); return NP; end C3GA_Point; -- ------------------------------------------------------------------------ function Coord (S : Scalar) return float is begin return S.Coordinates (1); end Coord; -- ------------------------------------------------------------------------- function e1 return Multivector.Multivector is use Blade; Basis : Multivector.Vector; begin Multivector.Add_Blade (Basis, C3_no, 0.0); Multivector.Add_Blade (Basis, C3_e1, 1.0); Multivector.Add_Blade (Basis, C3_e2, 0.0); Multivector.Add_Blade (Basis, C3_e3, 0.0); Multivector.Add_Blade (Basis, C3_ni, 0.0); return Basis; end e1; -- ------------------------------------------------------------------------- function e1 (MV : Multivector.Multivector) return float is use Blade; Value : Float; OK : constant Boolean := Multivector.Component (MV, C3_Base'Enum_Rep (C3_e1), Value); begin return Value; end e1; -- ------------------------------------------------------------------------- function e2 return Multivector.Multivector is use Blade; Basis : Multivector.Vector; begin Multivector.Add_Blade (Basis, C3_no, 0.0); Multivector.Add_Blade (Basis, C3_e1, 0.0); Multivector.Add_Blade (Basis, C3_e2, 1.0); Multivector.Add_Blade (Basis, C3_e3, 0.0); Multivector.Add_Blade (Basis, C3_ni, 0.0); return Basis; end e2; -- ------------------------------------------------------------------------- function e2 (MV : Multivector.Multivector) return float is use Blade; Value : Float; OK : constant Boolean := Multivector.Component (MV, C3_Base'Enum_Rep (C3_e2), Value); begin return Value; end e2; -- ------------------------------------------------------------------------- function e3 return Multivector.Multivector is use Blade; Basis : Multivector.Vector; begin Multivector.Add_Blade (Basis, C3_no, 0.0); Multivector.Add_Blade (Basis, C3_e1, 0.0); Multivector.Add_Blade (Basis, C3_e2, 0.0); Multivector.Add_Blade (Basis, C3_e3, 1.0); Multivector.Add_Blade (Basis, C3_ni, 0.0); return Basis; end e3; -- ------------------------------------------------------------------------- function e3 (MV : Multivector.Multivector) return float is use Blade; Value : Float; OK : constant Boolean := Multivector.Component (MV, C3_Base'Enum_Rep (C3_e3), Value); begin return Value; end e3; -- ------------------------------------------------------------------------- function e1_e2 (MV : Multivector.Multivector) return float is use Blade; use GA_Maths; BM_E12 : constant Unsigned_Integer := Unsigned_Integer (C3_Base'Enum_Rep (C3_e1)) or Unsigned_Integer (C3_Base'Enum_Rep (C3_e2)); Value : Float; OK : constant Boolean := Multivector.Component (MV, BM_E12, Value); begin return Value; end e1_e2; -- ------------------------------------------------------------------------- function e1_e3 (MV : Multivector.Multivector) return float is use Blade; use GA_Maths; BM_E13 : constant Unsigned_Integer := Unsigned_Integer (E3_Base'Enum_Rep (E3_e1)) or Unsigned_Integer (E3_Base'Enum_Rep (E3_e3)); Value : Float; OK : constant Boolean := Multivector.Component (MV, BM_E13, Value); begin return Value; end e1_e3; -- ------------------------------------------------------------------------- function e2_e3 (MV : Multivector.Multivector) return float is use Blade; use GA_Maths; BM_E23 : constant Unsigned_Integer := Unsigned_Integer (E3_Base'Enum_Rep (E3_e2)) or Unsigned_Integer (E3_Base'Enum_Rep (E3_e3)); Value : Float; OK : constant Boolean := Multivector.Component (MV, BM_E23, Value); begin return Value; end e2_e3; -- ------------------------------------------------------------------------- function e1_e2_e3 (MV : Multivector.Multivector) return float is use Blade; use GA_Maths; BM : constant Unsigned_Integer := Unsigned_Integer (E3_Base'Enum_Rep (E3_e1)) or Unsigned_Integer (E3_Base'Enum_Rep (E3_e2)) or Unsigned_Integer (E3_Base'Enum_Rep (E3_e3)); Value : Float; OK : constant Boolean := Multivector.Component (MV, BM, Value); begin return Value; end e1_e2_e3; -- ------------------------------------------------------------------------- -- function Grade_Use (MV : Multivector) return GA_Maths.Unsigned_Integer is -- begin -- return MV.Grade_Use; -- end Grade_Use; -- ------------------------------------------------------------------------ -- function Init (MV : Multivector; Epsilon : float := 0.0) return MV_Type is -- use Interfaces; -- use GA_Maths; -- use Multivector_Type_Base; -- MV_Info : MV_Type; -- GU : GA_Maths.Grade_Usage := Grade_Use (MV); -- Count : array (Unsigned_Integer range 1 .. 2) of Integer := (0, 0); -- Count_Index : Unsigned_Integer := 0; -- Index : Unsigned_Integer := 0; -- Done : Boolean := False; -- begin -- MV_Info.M_Type := Multivector_Object; -- MV_Info.M_Grade_Use := GU; -- -- count grade part usage -- while GU /= 0 loop -- if (GU and GU_1) /= 0 then -- c3ga.cpp line 21731 -- Index := Count_Index and US_1; -- Count (Index) := Count (Index) + 1; -- end if; -- GU := Unsigned_Integer (Shift_Right (Unsigned_32 (GU), 1)); -- MV_Info.M_Grade := Integer (Count_Index); -- Count_Index := Count_Index + 1; -- end loop; -- -- -- if no grade part in use: zero blade -- if Count (1) = 0 and then Count (2) = 0 then -- this is a zero blade -- Put_Line ("C3GA.Init 1 Setting zero blade."); -- Set_Type_Base (MV_Info, True, Blade_MV, 0, GU, Even_Parity); -- Done := True; -- else -- -- Base.M_Zero = False by default -- if Count (1) /= 0 and then Count (2) /= 0 then -- -- Base.M_Parity = No_Parity by default -- Done := True; -- else -- if Count (1) = 0 then -- Put_Line ("C3GA.Init 1 Setting even parity."); -- MV_Info.M_Parity := Even_Parity; -- else -- -- Put_Line ("C3GA.Init 1 Setting odd parity."); -- MV_Info.M_Parity := Odd_Parity; -- end if; -- end if; -- end if; -- if not Done then -- MV_Info := Init (MV, Epsilon, True, Count (1) + Count (2)); -- end if; -- return MV_Info; -- exception -- when anError : others => -- Put_Line ("An exception occurred in C3GA.Init 1."); -- raise; -- end Init; ------------------------------------------------------------------------- -- function Init (MV : C3GA.Multivector; Epsilon : float; -- Use_Algebra_Metric : Boolean; -- GU_Count : Integer) return MV_Type is -- MV_Info : MV_Type; -- begin -- -- To be completed. -- return MV_Info; -- end Init; -- ------------------------------------------------------------------------- function E1_E2_NI (C : Circle) return float is begin return C.E1_E2_NI; end E1_E2_NI; -- ------------------------------------------------------------------------- function E3_E1_NI (C : Circle) return float is begin return C.E3_E1_NI; end E3_E1_NI; -- ------------------------------------------------------------------------- function E1_E2_E3 (C : Circle) return float is begin return C.E1_E2_E3; end E1_E2_E3; -- ------------------------------------------------------------------------- function E2_E3_NI (C : Circle) return float is begin return C.E2_E3_NI; end E2_E3_NI; -- ------------------------------------------------------------------------- function Get_Coord_1 (V : Vector_E3GA) return float is begin return V.Coordinates (1); end Get_Coord_1; -- ------------------------------------------------------------------------ function Get_Coord_2 (V : Vector_E3GA) return float is begin return V.Coordinates (2); end Get_Coord_2; -- ------------------------------------------------------------------------ function Get_Coord_3 (V : Vector_E3GA) return float is begin return V.Coordinates (3); end Get_Coord_3; -- ------------------------------------------------------------------------ function Get_Coords (V : Vector_E3GA) return GA_Maths.Array_3D is begin return (V.Coordinates (1), V.Coordinates (2), V.Coordinates (3)); end Get_Coords; -- ------------------------------------------------------------------------ -- function Get_Coords (NP : Normalized_Point) return Vector is -- begin -- return (1.0, NP.E1, NP.E2, NP.E3, NP.Inf); -- end Get_Coords; ------------------------------------------------------------------------ function Get_Coords (NP : Normalized_Point) return GA_Maths.Coords_Continuous_Array is use Multivector.Blade_List_Package; Blades : Multivector.Blade_List := Multivector.Get_Blade_List (NP); Curs : Cursor := Blades.First; Coords : GA_Maths.Coords_Continuous_Array (1 .. 4); Index : Integer := 0; begin while Has_Element (Curs) and Index < 4 loop Index := Index + 1; Coords (Index) := Blade.Weight (Element (Curs)); Next (Curs); end loop; return Coords; end Get_Coords; -- ------------------------------------------------------------------------ function ni return Multivector.Multivector is use Blade; Basis : Multivector.Vector; begin Multivector.Add_Blade (Basis, C3_no, 0.0); Multivector.Add_Blade (Basis, C3_e1, 0.0); Multivector.Add_Blade (Basis, C3_e2, 0.0); Multivector.Add_Blade (Basis, C3_e3, 0.0); Multivector.Add_Blade (Basis, C3_ni, 1.0); return Basis; end ni; -- ------------------------------------------------------------------------- function no return Multivector.Multivector is use Blade; Basis : Multivector.Vector; begin Multivector.Add_Blade (Basis, C3_no, 1.0); Multivector.Add_Blade (Basis, C3_e1, 0.0); Multivector.Add_Blade (Basis, C3_e2, 0.0); Multivector.Add_Blade (Basis, C3_e3, 0.0); Multivector.Add_Blade (Basis, C3_ni, 0.0); return Basis; end no; -- ------------------------------------------------------------------------- function NO_E1_E2 (C : Circle) return float is begin return C.NO_E1_E2; end NO_E1_E2; -- ------------------------------------------------------------------------- function NO_E1_E3 (C : Circle) return float is begin return C.NO_E1_E3; end NO_E1_E3; -- ------------------------------------------------------------------------- function NO_E1_NI (C : Circle) return float is begin return C.NO_E1_NI; end NO_E1_NI; -- ------------------------------------------------------------------------- function NO_E2_E3 (C : Circle) return float is begin return C.NO_E2_E3; end NO_E2_E3; -- ------------------------------------------------------------------------- function NO_E2_NI (C : Circle) return float is begin return C.NO_E2_NI; end NO_E2_NI; -- ------------------------------------------------------------------------- function NO_E3_NI (C : Circle) return float is begin return C.NO_E3_NI; end NO_E3_NI; -- ------------------------------------------------------------------------- function E1b (DP : Dual_Plane) return float is begin return DP.E1; end E1b; -- ------------------------------------------------------------------------- function E2b (DP : Dual_Plane) return float is begin return DP.E2; end E2b; -- ------------------------------------------------------------------------- function E3b (DP : Dual_Plane) return float is begin return DP.E3; end E3b; -- ------------------------------------------------------------------------- function NIb (DP : Dual_Plane) return GA_Base_Types.NI_T is begin return DP.Inf; end NIb; -- ------------------------------------------------------------------------- function E1_E2_NI (L : Line) return float is begin return L.E1_E2_NI; end E1_E2_NI; -- ------------------------------------------------------------------------- function E1_E3_NI (L : Line) return float is begin return L.E1_E3_NI; end E1_E3_NI; -- ------------------------------------------------------------------------- function E2_E3_NI (L : Line) return float is begin return L.E2_E3_NI; end E2_E3_NI; -- ------------------------------------------------------------------------- function E1_NO_NI (L : Line) return float is begin return L.E1_NO_NI; end E1_NO_NI; -- ------------------------------------------------------------------------- function E2_NO_NI (L : Line) return float is begin return L.E2_NO_NI; end E2_NO_NI; -- ------------------------------------------------------------------------- function E3_NO_NI (L : Line) return float is begin return L.E3_NO_NI; end E3_NO_NI; -- ------------------------------------------------------------------------- function NO_E1_E2_E3_NI (MV : Multivector.Multivector) return float is use GA_Maths; -- use Multivector.Blade_List_Package; -- Blades : constant Multivector.Blade_List -- := Multivector.Get_Blade_List (MV); -- thisBlade : Blade.Basis_Blade; GU : Grade_Usage := Multivector.Grade_Use (MV); GU_32 : constant Grade_Usage := 32; Grade_Size : Integer; MV2 : Multivector.Multivector; begin if (GU and GU_32) = 0 then return 0.0; else Grade_Size := MV_Grade_Size (Integer(GU and GU_32)); -- MV2 := Multivector.Get_Basis_Vector (Blade.Base'Enum_Val (Grade_Size)); return 0.0; end if; end NO_E1_E2_E3_NI; -- --------------------------------------------------------- function E1b (NP : Normalized_Point) return float is use Multivector.Blade_List_Package; Blades : constant Multivector.Blade_List:= Multivector.Get_Blade_List (NP); Curs : Cursor := Blades.First; -- ao begin Next (Curs); -- e1 return Blade.Weight (Element (Curs)); end E1b; -- ------------------------------------------------------------------------- function E2b (NP : Normalized_Point) return float is use Multivector.Blade_List_Package; Blades : constant Multivector.Blade_List:= Multivector.Get_Blade_List (NP); Curs : Cursor := Blades.First; -- ao begin Next (Curs); -- e1 Next (Curs); -- e2 return Blade.Weight (Element (Curs)); end E2b; -- ------------------------------------------------------------------------- function E3b (NP : Normalized_Point) return float is use Multivector.Blade_List_Package; Blades : constant Multivector.Blade_List:= Multivector.Get_Blade_List (NP); Curs : Cursor := Blades.First; -- ao begin Next (Curs); -- e1 Next (Curs); -- e2 Next (Curs); -- e3 return Blade.Weight (Element (Curs)); end E3b; -- ------------------------------------------------------------------------- function NIb (NP : Normalized_Point) return Float is use Multivector.Blade_List_Package; Blades : constant Multivector.Blade_List:= Multivector.Get_Blade_List (NP); Curs : Cursor := Blades.Last; -- ai begin return Blade.Weight (Element (Curs)); end NIb; -- ------------------------------------------------------------------------- function NOb (NP : Normalized_Point) return Float is begin return 1.0; end NOb; -- ------------------------------------------------------------------------- function E1_E2_E3_NI (S : Sphere) return float is begin return S.E1_E2_E3_NI; end E1_E2_E3_NI; -- ------------------------------------------------------------------------- function E1_E2_NO_NI (S : Sphere) return float is begin return S.E1_E2_NO_NI; end E1_E2_NO_NI; -- ------------------------------------------------------------------------- function E1_E3_NO_NI (S : Sphere) return float is begin return S.E1_E3_NO_NI; end E1_E3_NO_NI; -- ------------------------------------------------------------------------- function E2_E3_NO_NI (S : Sphere) return float is begin return S.E2_E3_NO_NI; end E2_E3_NO_NI; -- ------------------------------------------------------------------------- function E1_E2_E3_NO (S : Sphere) return float is begin return S.E1_E2_E3_NO; end E1_E2_E3_NO; -- ------------------------------------------------------------------------- -- function Norm_E (MV : Multivector) return Scalar is -- use GA_Maths; -- GU : Grade_Usage := Grade_Use (MV); -- Sum : Float := 0.0; -- E2 : Scalar; -- begin -- if (GU and GU_0) /= 0 then -- Sum := MV.Coordinates (1) * MV.Coordinates (1); -- end if; -- if (GU and GU_1) /= 0 then -- For index in 2 .. 6 loop -- Sum := Sum + MV.Coordinates (index) * MV.Coordinates (index); -- end loop; -- end if; -- if (GU and GU_2) /= 0 then -- For index in 7 .. 16 loop -- Sum := Sum + MV.Coordinates (index) * MV.Coordinates (index); -- end loop; -- end if; -- if (GU and GU_4) /= 0 then -- For index in 17 .. 26 loop -- Sum := Sum + MV.Coordinates (index) * MV.Coordinates (index); -- end loop; -- end if; -- if (GU and GU_8) /= 0 then -- For index in 27 .. 31 loop -- Sum := Sum + MV.Coordinates (index) * MV.Coordinates (index); -- end loop; -- end if; -- if (GU and GU_16) /= 0 then -- Sum := Sum + MV.Coordinates (32) * MV.Coordinates (32); -- end if; -- E2.Coordinates (1) := Sum; -- return E2; -- end Norm_E; -- ------------------------------------------------------------------------- function Norm_E2 (V : Vector_E3GA) return Float is theNorm : Float; begin theNorm := V.Coordinates (1) * V.Coordinates (1) + V.Coordinates (2) * V.Coordinates (2) + V.Coordinates (3) * V.Coordinates (3); return theNorm; end Norm_E2; -- ------------------------------------------------------------------------- procedure Set_Coords (V : out Vector_E3GA; C1, C2, C3 : float) is begin V.Coordinates (1) := C1; V.Coordinates (2) := C2; V.Coordinates (3) := C3; end Set_Coords; -- ------------------------------------------------------------------------- function Set_Coords (C1, C2, C3 : float) return Vector_E3GA is Vec : Vector_E3GA; begin Vec.Coordinates := (C1, C2, C3); return Vec; end Set_Coords; -- ------------------------------------------------------------------------- procedure Set_Coords (P : out Point; Origin, C1, C2, C3, Inf : float) is use GA_Base_Types; begin Set_NO (P.Origin, Origin); P.E1 := C1; P.E2 := C2; P.E3 := C3; P.Inf := Inf; end Set_Coords; -- ------------------------------------------------------------------------- -- procedure Set_Multivector (MV : out Multivector; NP : Normalized_Point) is -- begin -- MV.Coordinates (1) := 1.0; -- MV.Coordinates (2) := NP.E1; -- MV.Coordinates (3) := NP.E2; -- MV.Coordinates (4) := NP.E3; -- MV.Coordinates (5) := NP.Inf; -- end Set_Multivector; -- ------------------------------------------------------------------------- -- procedure Set_Multivector (MV : out Multivector; N : GA_Base_Types.NI_T) is -- begin -- MV.Coordinates (1) := 0.0; -- MV.Coordinates (2) := 0.0; -- MV.Coordinates (3) := 0.0; -- MV.Coordinates (4) := 0.0; -- MV.Coordinates (5) := GA_Base_Types.NI (N); -- end Set_Multivector; -- ------------------------------------------------------------------------- -- procedure Set_Multivector (MV : out Multivector; N : GA_Base_Types.NO_T) is -- begin -- MV.Coordinates (1) := GA_Base_Types.NO (N); -- MV.Coordinates (2) := 0.0; -- MV.Coordinates (3) := 0.0; -- MV.Coordinates (4) := 0.0; -- MV.Coordinates (5) := 0.0; -- end Set_Multivector; -- ------------------------------------------------------------------------- function Set_Normalized_Point (E1, E2, E3 : float; Inf : float := 1.0) return Normalized_Point is use Blade; NP : Normalized_Point; begin -- thePoint.Origin of a Normalized_Point is a constant 1.0 Multivector.Add_Blade (NP, Blade.New_Basis_Blade (C3_no, 1.0)); Multivector.Add_Blade (NP, Blade.New_Basis_Blade (C3_e1, E1)); Multivector.Add_Blade (NP, Blade.New_Basis_Blade (C3_e2, E2)); Multivector.Add_Blade (NP, Blade.New_Basis_Blade (C3_e3, E3)); Multivector.Add_Blade (NP, Blade.New_Basis_Blade (C3_ni, Inf)); return NP; end Set_Normalized_Point; -- ------------------------------------------------------------------------- function Set_Normalized_Point (Point : GA_Maths.Array_3D; Inf : float := 1.0) return Normalized_Point is use Blade; NP : Normalized_Point; begin Multivector.Add_Blade (NP, Blade.New_Basis_Blade (C3_no, 1.0)); Multivector.Add_Blade (NP, Blade.New_Basis_Blade (C3_e1, Point (1))); Multivector.Add_Blade (NP, Blade.New_Basis_Blade (C3_e2, Point (2))); Multivector.Add_Blade (NP, Blade.New_Basis_Blade (C3_e3, Point (3))); Multivector.Add_Blade (NP, Blade.New_Basis_Blade (C3_ni, Inf)); return NP; end Set_Normalized_Point; -- ------------------------------------------------------------------------- -- function Outer_Product (MV1, MV2 : Multivector) return Multivector is -- use GA_Maths; -- Coords : GA_Maths.Coords_Continuous_Array (1 .. 32); -- GU1 : Grade_Usage := MV1.Grade_Use; -- GU2 : Grade_Usage := MV2.Grade_Use; -- Size_1 : integer := MV_Size (Integer (MV1.Grade_Use)); -- Size_2 : integer := MV_Size (Integer (MV2.Grade_Use)); -- MV_GU : Grade_Usage := GU1 or GU2; -- Sum : Float := 0.0; -- Product : Multivector (MV_GU); -- -- function Grade_Used (MV : Multivector; Index : Integer) return Boolean is -- GU : Grade_Usage := MV1.Grade_Use; -- Result : Boolean := False; -- begin -- case Index is -- when 0 => Result := (GU and GU_0) /= 0; -- when 1 => Result := (GU and GU_1) /= 0; -- when 2 => Result := (GU and GU_2) /= 0; -- when 3 => Result := (GU and GU_4) /= 0; -- when 4 => Result := (GU and GU_8) /= 0; -- when 5 => Result := (GU and GU_16) /= 0; -- when others => -- Put_Line ("C3GA.Outer_Product Invalid Index"); -- end case; -- return Result; -- end Grade_Used; -- -- begin -- for Index2 in 1 ..32 loop -- if Grade_Used (MV2, Integer (GU1)) then -- for Index1 in 1 .. 32 loop -- null; -- end loop; -- end if; -- end loop; -- -- if (GU2 and GU_0) /= 0 then -- if (GU1 and GU_1) /= 0 then -- Coords (1) := MV1.Coordinates (1) * MV2.Coordinates (1); -- end if; -- if (GU1 and GU_1) /= 0 then -- For index in 2 .. 6 loop -- Coords (index) := MV1.Coordinates (index) * MV2.Coordinates (1); -- end loop; -- end if; -- if (GU1 and GU_2) /= 0 then -- For index in 7 .. 16 loop -- Coords (index) := MV1.Coordinates (index) * MV2.Coordinates (1); -- end loop; -- end if; -- if (GU1 and GU_4) /= 0 then -- For index in 17 .. 26 loop -- Coords (index) := MV1.Coordinates (index) * MV2.Coordinates (1); -- end loop; -- end if; -- if (GU1 and GU_8) /= 0 then -- For index in 27 .. 31 loop -- Coords (index) := MV1.Coordinates (index) * MV2.Coordinates (1); -- end loop; -- end if; -- if (GU1 and GU_16) /= 0 then -- Coords (32) := MV1.Coordinates (32) * MV2.Coordinates (1); -- end if; -- end if; -- -- if (GU2 and GU_1) /= 0 then -- if (GU1 and GU_1) /= 0 then -- For index in 2 .. 6 loop -- Coords (index) := Coords (index) + -- MV1.Coordinates (1) * MV2.Coordinates (index); -- end loop; -- end if; -- -- if (GU1 and GU_2) /= 0 then -- Coords (7) := Coords (7) + -- MV1.Coordinates (2) * MV2.Coordinates (3) - -- MV1.Coordinates (3) * MV2.Coordinates (2); -- Coords (8) := Coords (8) + -- MV1.Coordinates (2) * MV2.Coordinates (4) - -- MV1.Coordinates (4) * MV2.Coordinates (2); -- Coords (9) := Coords (9) + -- MV1.Coordinates (2) * MV2.Coordinates (5) - -- MV1.Coordinates (5) * MV2.Coordinates (2); -- Coords (10) := Coords (10) + -- MV1.Coordinates (3) * MV2.Coordinates (4) - -- MV1.Coordinates (4) * MV2.Coordinates (3); -- Coords (11) := Coords (11) + -- MV1.Coordinates (4) * MV2.Coordinates (5) - -- MV1.Coordinates (5) * MV2.Coordinates (4); -- Coords (12) := Coords (12) + -- MV1.Coordinates (5) * MV2.Coordinates (3) - -- MV1.Coordinates (3) * MV2.Coordinates (5); -- Coords (13) := Coords (13) + -- MV1.Coordinates (3) * MV2.Coordinates (6) - -- MV1.Coordinates (6) * MV2.Coordinates (3); -- end if; -- end if; -- return Product; -- end Outer_Product; -- ------------------------------------------------------------------------- function Unit_R (L : Line) return Line is use GA_Maths.Float_Functions; R_Sq : constant float := -(L.E1_NO_NI * L.E1_NO_NI + L.E2_NO_NI * L.E2_NO_NI + L.E3_NO_NI * L.E3_NO_NI); Inv : constant float := 1.0 / Sqrt (Abs (R_Sq)); begin return L * Inv; end Unit_R; -- ------------------------------------------------------------------------- -- function US_Normalized_Point (N : Normalized_Point) return Normalized_Point is -- thePoint : Normalized_Point := N; -- begin -- thePoint.Inf := 0.0; -- return thePoint; -- end US_Normalized_Point; -- -- -- ------------------------------------------------------------------------- -- -- function US_Set_Normalized_Point (E1, E2, E3 : Float) return Normalized_Point is -- NP : Normalized_Point; -- begin -- NP.E1 := E1; -- NP.E2 := E2; -- NP.E3 := E3; -- NP.Inf := 0.0; -- return NP; -- end US_Set_Normalized_Point; -- -- -- ------------------------------------------------------------------------- -- -- function US_Set_Normalized_Point (Point : Vector_E3GA) return Normalized_Point is -- NP : Normalized_Point; -- begin -- NP.E1 := Point.Coordinates (1); -- NP.E2 := Point.Coordinates (2); -- NP.E3 := Point.Coordinates (3); -- NP.Inf := 0.0; -- return NP; -- end US_Set_Normalized_Point; -- ------------------------------------------------------------------------- end C3GA;
AdaCore/training_material
Ada
682
adb
with Ada.Command_Line; use Ada.Command_Line; with Ada.Text_IO; use Ada.Text_IO; procedure Main is type Short_T is range -1_000 .. 1_000; Input : Short_T := Short_T'value (Ada.Command_Line.Argument (1)); function One (Num : Short_T) return Short_T; function Three (Num : Short_T) return Short_T is (if Num < Short_T'last then One (Num + 300) else Num); function Two (Num : Short_T) return Short_T is (if Num < Short_T'last then Three (Num + 200) else Num); function One (Num : Short_T) return Short_T is (if Num < Short_T'last then Two (Num + 100) else Num); begin Put_Line (Input'image & " => " & Short_T'image (Three (Input))); end Main;
zertovitch/hac
Ada
4,250
adb
-- This is a demo of multiple instances of HAC running in parallel. -- Run as: hac_multi >res_multi.csv -- and open the CSV file in your preferred spreadsheet software. -- -- See HAC for the full version of the command-line tool. with HAC_Sys.Builder, HAC_Sys.Defs, HAC_Sys.PCode.Interpreter; with HAT; with Ada.Calendar, Ada.Command_Line, Ada.Numerics.Float_Random, Ada.Streams.Stream_IO, Ada.Text_IO; procedure HAC_Multi is procedure Launch_Tasks is use Ada.Text_IO; sep : constant Character := ';'; task type HAC_Instance is entry Start (id : Positive); end HAC_Instance; task body HAC_Instance is use HAC_Sys.Builder, HAC_Sys.PCode.Interpreter; procedure No_Put (Item : Character) is null; procedure No_New_Line (Spacing : Positive_Count := 1) is null; package Current_IO_Console is new Console_Traits (Ada.Text_IO.End_Of_File, Ada.Text_IO.End_Of_Line, Current_IO_Get_Needs_Skip_Line, HAC_Sys.Defs.IIO.Get, HAC_Sys.Defs.RIO.Get, Ada.Text_IO.Get, Ada.Text_IO.Get_Immediate, Ada.Text_IO.Get_Line, Ada.Text_IO.Skip_Line, HAC_Sys.Defs.IIO.Put, HAC_Sys.Defs.RIO.Put, HAC_Sys.Defs.BIO.Put, No_Put, -- Ada.Text_IO.Put Ada.Text_IO.Put, No_New_Line -- Ada.Text_IO.New_Line ); package Custom_System_Calls is new System_Calls_Traits (Ada.Command_Line.Argument_Count, Ada.Command_Line.Argument, Ada.Command_Line.Command_Name, -- Wrong but not used anyway in this demo. HAT.Shell_Execute, HAT.Shell_Execute, -- This profile has an Output parameter. HAT.Directory_Separator ); use Ada.Calendar, Ada.Numerics.Float_Random, Ada.Streams.Stream_IO; task_id : Positive; tick : Time; gen : Generator; procedure Multi_Feedback ( Stack_Current, Stack_Total : in Natural; Wall_Clock : in Ada.Calendar.Time; User_Abort : out Boolean ) is pragma Unreferenced (Stack_Current, Stack_Total); begin User_Abort := False; if Wall_Clock - tick >= 0.005 then if Random (gen) > 0.999 then User_Abort := True; Put_Line ("A1" & sep & " Task" & sep & Integer'Image (task_id) & sep & " wants to abort the HAC VM."); end if; tick := Wall_Clock; end if; end Multi_Feedback; procedure Interpret_for_Multi is new Interpret (Multi_Feedback, Current_IO_Console, Custom_System_Calls ); Ada_file_name : constant String := "exm/mandelbrot.adb"; -- f : Ada.Streams.Stream_IO.File_Type; BD : Build_Data; post_mortem : Post_Mortem_Data; begin accept Start (id : Positive) do task_id := id; end Start; tick := Clock; Reset (gen); -- Open (f, In_File, Ada_file_name); Set_Main_Source_Stream (BD, Stream (f), Ada_file_name); Build_Main (BD); Close (f); -- if Build_Successful (BD) then Put_Line ("S" & sep & " Task" & sep & Integer'Image (task_id) & sep & " successful compilation. Running the VM."); Interpret_for_Multi (BD, post_mortem); if Image (post_mortem.Unhandled) = "User_Abort" then Put_Line ("A2" & sep & " Task" & sep & Integer'Image (task_id) & sep & " got ""User_Abort"" exception from HAC VM."); else Put_Line ("D" & sep & " Task" & sep & Integer'Image (task_id) & sep & " is done."); end if; end if; end HAC_Instance; hacs : array (1 .. 20) of HAC_Instance; begin Put_Line ("Event" & sep & " Task #" & sep & " Message"); for T in hacs'Range loop hacs (T).Start (T); delay 0.01; end loop; end Launch_Tasks; begin Launch_Tasks; end HAC_Multi;
reznikmm/matreshka
Ada
3,639
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with League.Holders.Generic_Holders; package AMF.DG.Holders.Skews is new League.Holders.Generic_Holders (AMF.DG.DG_Skew); pragma Preelaborate (AMF.DG.Holders.Skews);
AdaCore/libadalang
Ada
380
adb
with Pkg; use Pkg; with Pkg.Der; use Pkg.Der; procedure Test is X : U'Class := U'(null record); begin Foo (X); -- This used to resolve to `Foo` from pkg.ads because it was "used" first, -- but it should actually resolve to the declaration in pkg-der.ads -- because it's more accurate. pragma Test_Statement; X.Foo; pragma Test_Statement; end Test;
reznikmm/matreshka
Ada
3,618
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Elements.Generic_Hash; function AMF.Utp.Data_Partitions.Hash is new AMF.Elements.Generic_Hash (Utp_Data_Partition, Utp_Data_Partition_Access);
AdaCore/libadalang
Ada
186
ads
package Parents is type Parent is abstract tagged record A : Integer; end record; procedure Primitive (Self : Parent) is abstract; -- Parent procedure end Parents;
charlie5/lace
Ada
1,612
ads
with openGL.geometry.colored, openGL.Font, openGL.Palette; package openGL.Model.arrow.colored -- -- Models a colored arrow. -- is type Item is new openGL.Model.arrow.item with private; type View is access all Item'Class; --------- --- Forge -- function new_Arrow (Color : in openGL.Color := Palette.White; line_Width : in Real := 1.0; End_1, End_2 : in Vector_3 := Origin_3D) return View; -------------- --- Attributes -- overriding function to_GL_Geometries (Self : access Item; Textures : access Texture.name_Map_of_texture'Class; Fonts : in Font.font_id_Map_of_font) return Geometry.views; procedure end_Site_is (Self : in out Item; Now : in Vector_3; for_End : in Integer); function end_Site (Self : in Item; for_End : in Integer) return Vector_3; overriding procedure modify (Self : in out Item); overriding function is_Modified (Self : in Item) return Boolean; private type Item is new openGL.Model.arrow.item with record Color : openGL.Color; line_Width : Real; Vertices : aliased Geometry.colored.Vertex_array (1 .. 4); Geometry : access Geometry.colored.item'Class; is_Modified : Boolean := False; end record; procedure set_side_Bits (Self : in out Item); end openGL.Model.arrow.colored;
reznikmm/matreshka
Ada
3,689
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 League.Holders.Generic_Enumerations; package AMF.UML.Holders.Aggregation_Kinds is new League.Holders.Generic_Enumerations (AMF.UML.UML_Aggregation_Kind); pragma Preelaborate (AMF.UML.Holders.Aggregation_Kinds);
zhmu/ananas
Ada
4,329
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- G E N _ I L -- -- -- -- S p e c -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ pragma Warnings (Off); -- with clauses for children with Ada.Characters.Handling; use Ada.Characters.Handling; with Ada.Streams.Stream_IO; pragma Warnings (On); package Gen_IL is -- generate intermediate language -- This package and children generates the main intermediate language used -- by the GNAT compiler, which is a decorated syntax tree. -- The generated Ada packages are: -- -- Seinfo -- Sinfo.Nodes -- Einfo.Entities -- Nmake -- Seinfo_Tables -- -- We also generate C code: -- -- einfo.h -- sinfo.h -- snames.h -- -- It is necessary to look at this generated code in order to understand -- the compiler. In addition, it is necessary to look at comments in the -- spec and body of Gen_IL. -- -- Note that the Gen_IL "compiler" and the GNAT Ada compiler are separate -- programs, with no dependencies between them in either direction. That -- is, Gen_IL does not say "with" of GNAT units, and GNAT does not say -- "with Gen_IL". There are many things declared in Gen_IL and GNAT with -- the same name; these are typically related, but they are not the same -- thing. -- Misc declarations used throughout: type Root_Int is new Integer; function Image (X : Root_Int) return String; -- Without the extra blank. You can derive from Root_Int or the subtypes -- below, and inherit a convenient Image function that leaves out that -- blank. subtype Root_Nat is Root_Int range 0 .. Root_Int'Last; subtype Root_Pos is Root_Int range 1 .. Root_Int'Last; function Capitalize (S : String) return String; procedure Capitalize (S : in out String); -- Turns an identifier into Mixed_Case -- The following declares a minimal implementation of formatted output -- that is piggybacked on Ada.Streams.Stream_IO for bootstrap reasons. -- It uses LF as universal line terminator to make it host independent. type Sink is record File : Ada.Streams.Stream_IO.File_Type; Indent : Natural; New_Line : Boolean; end record; procedure Create_File (Buffer : in out Sink; Name : String); procedure Increase_Indent (Buffer : in out Sink; Amount : Natural); procedure Decrease_Indent (Buffer : in out Sink; Amount : Natural); procedure Put (Buffer : in out Sink; Item : String); LF : constant String := "" & ASCII.LF; end Gen_IL;
reznikmm/gela
Ada
17,528
adb
with Ada.Tags; with Gela.Compilations; with Gela.Elements.Defining_Names; with Gela.Environments; with Gela.Interpretations; with Gela.Lexical_Types; with Gela.Plain_Environments.Debug; with Gela.Property_Visiters; with Gela.Semantic_Types; with Gela.Types; with Gela.Type_Managers; with Gela.Types.Visitors; with Gela.Types.Simple; with Gela.Types.Arrays; with Gela.Types.Untagged_Records; package body Gela.Debug_Properties is procedure Put_Line (Text : String); procedure Put_Expression (Text : String); package Dump_Type is type Type_Visitor (Put_Line : access procedure (Text : String)) is new Gela.Types.Visitors.Type_Visitor with null record; overriding procedure Enumeration_Type (Self : in out Type_Visitor; Value : not null Gela.Types.Simple.Enumeration_Type_Access); overriding procedure Signed_Integer_Type (Self : in out Type_Visitor; Value : not null Gela.Types.Simple.Signed_Integer_Type_Access); overriding procedure Floating_Point_Type (Self : in out Type_Visitor; Value : not null Gela.Types.Simple.Floating_Point_Type_Access); overriding procedure Array_Type (Self : in out Type_Visitor; Value : not null Gela.Types.Arrays.Array_Type_Access); overriding procedure Untagged_Record (Self : in out Type_Visitor; Value : not null Gela.Types.Untagged_Records .Untagged_Record_Type_Access); overriding procedure Object_Access_Type (Self : in out Type_Visitor; Value : not null Gela.Types.Simple.Object_Access_Type_Access); overriding procedure Subprogram_Access_Type (Self : in out Type_Visitor; Value : not null Gela.Types.Simple.Subprogram_Access_Type_Access); end Dump_Type; package Dump_Property is type Property is (Up, Down, Env_In, Env_Out, Full_Name); type Property_Flags is array (Property) of Boolean; type Property_Visiter is new Gela.Property_Visiters.Property_Visiter with record Flags : Property_Flags := (others => False); end record; overriding procedure On_Down (Self : in out Property_Visiter; Element : Gela.Elements.Element_Access; Value : Gela.Interpretations.Interpretation_Index); overriding procedure On_Env_In (Self : in out Property_Visiter; Element : Gela.Elements.Element_Access; Value : Gela.Semantic_Types.Env_Index); overriding procedure On_Env_Out (Self : in out Property_Visiter; Element : Gela.Elements.Element_Access; Value : Gela.Semantic_Types.Env_Index); overriding procedure On_Full_Name (Self : in out Property_Visiter; Element : Gela.Elements.Element_Access; Value : Gela.Lexical_Types.Symbol); overriding procedure On_Up (Self : in out Property_Visiter; Element : Gela.Elements.Element_Access; Value : Gela.Interpretations.Interpretation_Set_Index); end Dump_Property; package Dump_Interpretation is type Visiter is new Gela.Interpretations.Down_Visiter with record Comp : not null Gela.Compilations.Compilation_Access; end record; overriding procedure On_Defining_Name (Self : in out Visiter; Name : Gela.Elements.Defining_Names.Defining_Name_Access; Down : Gela.Interpretations.Interpretation_Index_Array); overriding procedure On_Expression (Self : in out Visiter; Tipe : Gela.Semantic_Types.Type_View_Index; Kind : Gela.Interpretations.Unknown_Auxiliary_Apply_Kinds; Down : Gela.Interpretations.Interpretation_Index_Array); overriding procedure On_Expression_Category (Self : in out Visiter; Match : not null Gela.Interpretations.Type_Matcher_Access; Down : Gela.Interpretations.Interpretation_Index_Array); overriding procedure On_Attr_Function (Self : in out Visiter; Tipe : Gela.Types.Type_View_Access; Kind : Gela.Lexical_Types.Predefined_Symbols.Attribute; Down : Gela.Interpretations.Interpretation_Index_Array); overriding procedure On_Tuple (Self : in out Visiter; Down : Gela.Interpretations.Interpretation_Index_Array); end Dump_Interpretation; package body Dump_Property is overriding procedure On_Down (Self : in out Property_Visiter; Element : Gela.Elements.Element_Access; Value : Gela.Interpretations.Interpretation_Index) is Comp : constant Gela.Compilations.Compilation_Access := Element.Enclosing_Compilation; IM : constant Gela.Interpretations.Interpretation_Manager_Access := Comp.Context.Interpretation_Manager; IV : Dump_Interpretation.Visiter := (Comp => Comp); begin if Self.Flags (Down) = False then return; end if; Put_Line ("down:" & Gela.Interpretations.Interpretation_Index'Image (Value)); IM.Visit (Value, IV); end On_Down; overriding procedure On_Env_In (Self : in out Property_Visiter; Element : Gela.Elements.Element_Access; Value : Gela.Semantic_Types.Env_Index) is Comp : constant Gela.Compilations.Compilation_Access := Element.Enclosing_Compilation; Env : constant Gela.Environments.Environment_Set_Access := Comp.Context.Environment_Set; begin if Self.Flags (Env_In) = False then return; end if; Put_Line ("env_in:" & Gela.Semantic_Types.Env_Index'Image (Value)); Gela.Plain_Environments.Debug (Gela.Plain_Environments.Plain_Environment_Set_Access (Env), Value); end On_Env_In; overriding procedure On_Env_Out (Self : in out Property_Visiter; Element : Gela.Elements.Element_Access; Value : Gela.Semantic_Types.Env_Index) is Comp : constant Gela.Compilations.Compilation_Access := Element.Enclosing_Compilation; Env : constant Gela.Environments.Environment_Set_Access := Comp.Context.Environment_Set; begin if Self.Flags (Env_Out) = False then return; end if; Put_Line ("env_out:" & Gela.Semantic_Types.Env_Index'Image (Value)); Gela.Plain_Environments.Debug (Gela.Plain_Environments.Plain_Environment_Set_Access (Env), Value); end On_Env_Out; overriding procedure On_Full_Name (Self : in out Property_Visiter; Element : Gela.Elements.Element_Access; Value : Gela.Lexical_Types.Symbol) is pragma Unreferenced (Element); begin if Self.Flags (Full_Name) = False then return; end if; Put_Line ("full_name:" & Gela.Lexical_Types.Symbol'Image (Value)); end On_Full_Name; overriding procedure On_Up (Self : in out Property_Visiter; Element : Gela.Elements.Element_Access; Value : Gela.Interpretations.Interpretation_Set_Index) is Comp : constant Gela.Compilations.Compilation_Access := Element.Enclosing_Compilation; IM : constant Gela.Interpretations.Interpretation_Manager_Access := Comp.Context.Interpretation_Manager; TM : constant Gela.Type_Managers.Type_Manager_Access := Comp.Context.Types; begin if Self.Flags (Up) = False then return; end if; Put_Line ("up:" & Gela.Interpretations.Interpretation_Set_Index'Image (Value)); for J in IM.Each (Value) loop Put_Line (" INDEX:" & Gela.Interpretations.Interpretation_Index'Image (J.Get_Index)); if J.Is_Defining_Name then declare Name : constant Gela.Elements.Defining_Names. Defining_Name_Access := J.Defining_Name; Symbol : constant Gela.Lexical_Types.Symbol := Name.Full_Name; begin Put_Line (" Defining_Name " & Comp.Context.Symbols.Image (Symbol).To_UTF_8_String); end; elsif J.Is_Expression then declare use type Gela.Semantic_Types.Type_View_Index; use type Gela.Types.Type_View_Access; Tipe : constant Gela.Semantic_Types.Type_View_Index := J.Expression_Type; View : Gela.Types.Type_View_Access; DT : Dump_Type.Type_Visitor (Put_Expression'Access); begin if Tipe /= 0 then View := TM.Get (Tipe); end if; if View = null then Put_Line (" Expression NULL"); else View.Visit (DT); end if; end; elsif J.Is_Expression_Category then Put_Line (" Expression_Category: "); elsif J.Is_Symbol then Put_Line (" Symbol " & Comp.Context.Symbols.Image (J.Symbol).To_UTF_8_String); elsif J.Is_Profile then Put_Line (" Attr_Function " & Comp.Context.Symbols.Image (J.Attribute_Kind). To_UTF_8_String); end if; end loop; end On_Up; end Dump_Property; package body Dump_Interpretation is overriding procedure On_Defining_Name (Self : in out Visiter; Name : Gela.Elements.Defining_Names.Defining_Name_Access; Down : Gela.Interpretations.Interpretation_Index_Array) is Symbol : constant Gela.Lexical_Types.Symbol := Name.Full_Name; begin Put_Line (" Defining_Name " & Self.Comp.Context.Symbols.Image (Symbol).To_UTF_8_String); for J of Down loop Put_Line (" DOWN" & Gela.Interpretations.Interpretation_Index'Image (J)); end loop; end On_Defining_Name; overriding procedure On_Expression (Self : in out Visiter; Tipe : Gela.Semantic_Types.Type_View_Index; Kind : Gela.Interpretations.Unknown_Auxiliary_Apply_Kinds; Down : Gela.Interpretations.Interpretation_Index_Array) is use type Gela.Semantic_Types.Type_View_Index; use type Gela.Types.Type_View_Access; TM : constant Gela.Type_Managers.Type_Manager_Access := Self.Comp.Context.Types; View : Gela.Types.Type_View_Access; DT : Dump_Type.Type_Visitor (Put_Expression'Access); begin if Tipe /= 0 then View := TM.Get (Tipe); end if; if View = null then Put_Line (" Expression NULL"); else View.Visit (DT); end if; Put_Line (" Kind:" & Gela.Interpretations.Interpretation_Kinds'Image (Kind)); for J of Down loop Put_Line (" DOWN" & Gela.Interpretations.Interpretation_Index'Image (J)); end loop; end On_Expression; overriding procedure On_Expression_Category (Self : in out Visiter; Match : not null Gela.Interpretations.Type_Matcher_Access; Down : Gela.Interpretations.Interpretation_Index_Array) is pragma Unreferenced (Self, Match); begin Put_Line (" Expression_Category: "); for J of Down loop Put_Line (" DOWN" & Gela.Interpretations.Interpretation_Index'Image (J)); end loop; end On_Expression_Category; overriding procedure On_Attr_Function (Self : in out Visiter; Tipe : Gela.Types.Type_View_Access; Kind : Gela.Lexical_Types.Predefined_Symbols.Attribute; Down : Gela.Interpretations.Interpretation_Index_Array) is null; overriding procedure On_Tuple (Self : in out Visiter; Down : Gela.Interpretations.Interpretation_Index_Array) is pragma Unreferenced (Self); begin Put_Line (" Tuple"); for J of Down loop Put_Line (" DOWN" & Gela.Interpretations.Interpretation_Index'Image (J)); end loop; end On_Tuple; end Dump_Interpretation; package body Dump_Type is overriding procedure Enumeration_Type (Self : in out Type_Visitor; Value : not null Gela.Types.Simple.Enumeration_Type_Access) is begin if Value.Is_Character then Self.Put_Line ("Character"); else Self.Put_Line ("Enumeration"); end if; end Enumeration_Type; overriding procedure Signed_Integer_Type (Self : in out Type_Visitor; Value : not null Gela.Types.Simple.Signed_Integer_Type_Access) is begin if Value.Is_Universal then Self.Put_Line ("Universal_Integer"); else Self.Put_Line ("Signed_Integer"); end if; end Signed_Integer_Type; overriding procedure Floating_Point_Type (Self : in out Type_Visitor; Value : not null Gela.Types.Simple.Floating_Point_Type_Access) is begin if Value.Is_Universal then Self.Put_Line ("Universal_Real"); else Self.Put_Line ("Floating_Point"); end if; end Floating_Point_Type; overriding procedure Array_Type (Self : in out Type_Visitor; Value : not null Gela.Types.Arrays.Array_Type_Access) is pragma Unreferenced (Value); begin Self.Put_Line ("Array"); end Array_Type; overriding procedure Untagged_Record (Self : in out Type_Visitor; Value : not null Gela.Types.Untagged_Records .Untagged_Record_Type_Access) is pragma Unreferenced (Value); begin Self.Put_Line ("Untagged_Record"); end Untagged_Record; overriding procedure Object_Access_Type (Self : in out Type_Visitor; Value : not null Gela.Types.Simple.Object_Access_Type_Access) is pragma Unreferenced (Value); begin Self.Put_Line ("Object_Access"); end Object_Access_Type; overriding procedure Subprogram_Access_Type (Self : in out Type_Visitor; Value : not null Gela.Types.Simple.Subprogram_Access_Type_Access) is pragma Unreferenced (Value); begin Self.Put_Line ("Subprogram_Access"); end Subprogram_Access_Type; end Dump_Type; procedure Dump (Element : Gela.Elements.Element_Access; PV : access Dump_Property.Property_Visiter; EV : in out Gela.Property_Visiters.Visiter); ---------- -- Dump -- ---------- procedure Dump (Element : Gela.Elements.Element_Access; PV : access Dump_Property.Property_Visiter; EV : in out Gela.Property_Visiters.Visiter) is begin if not Element.Assigned then return; end if; declare N : constant Gela.Elements.Nested_Array := Element.Nested_Items; begin Put_Line (Ada.Tags.Expanded_Name (Element'Tag)); Element.Visit (EV); for J of N loop case J.Kind is when Gela.Elements.Nested_Element => Dump (J.Nested_Element, PV, EV); when Gela.Elements.Nested_Sequence => declare Pos : Gela.Elements.Element_Sequence_Cursor := J.Nested_Sequence.First; begin while Pos.Has_Element loop Dump (Pos.Element, PV, EV); Pos.Next; end loop; end; when Gela.Elements.Nested_Token => null; end case; end loop; end; end Dump; ---------- -- Dump -- ---------- procedure Dump (Element : Gela.Elements.Element_Access; Debug : League.Strings.Universal_String) is PV : aliased Dump_Property.Property_Visiter; EV : Gela.Property_Visiters.Visiter (PV'Access); begin for J in Dump_Property.Property loop if Debug.Index (Dump_Property.Property'Wide_Wide_Image (J)) > 0 then PV.Flags (J) := True; end if; end loop; Dump (Element, PV'Access, EV); end Dump; -------------------- -- Put_Expression -- -------------------- procedure Put_Expression (Text : String) is begin Put_Line (" Expression " & Text); end Put_Expression; -------------- -- Put_Line -- -------------- procedure Put_Line (Text : String) is procedure puts (Text : String); pragma Import (C, puts, "puts"); begin puts (Text & Character'Val (0)); end Put_Line; end Gela.Debug_Properties;
sebsgit/textproc
Ada
643
ads
with AUnit; use AUnit; with AUnit.Test_Cases; use AUnit.Test_Cases; package GpuInferenceTests is type TestCase is new AUnit.Test_Cases.Test_Case with null record; procedure Register_Tests(T: in out TestCase); function Name(T: TestCase) return Message_String; procedure initOpenCL(T: in out Test_Cases.Test_Case'Class); procedure testGpuWeightUpload(T: in out Test_Cases.Test_Case'Class); procedure testGpuWeightApply(T: in out Test_Cases.Test_Case'Class); procedure testGpuForward(T: in out Test_Cases.Test_Case'Class); procedure testGpuForwardLargeNN(T: in out Test_Cases.Test_Case'Class); end GpuInferenceTests;
wookey-project/ewok-legacy
Ada
1,481
ads
-- -- Copyright 2018 The wookey project team <[email protected]> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- with ewok.tasks_shared; package ewok.syscalls.ipc with spark_mode => off is procedure ipc_do_recv (caller_id : in ewok.tasks_shared.t_task_id; params : in t_parameters; blocking : in boolean; mode : in ewok.tasks_shared.t_task_mode); procedure ipc_do_send (caller_id : in ewok.tasks_shared.t_task_id; params : in out t_parameters; blocking : in boolean; mode : in ewok.tasks_shared.t_task_mode); procedure sys_ipc (caller_id : in ewok.tasks_shared.t_task_id; params : in out t_parameters; mode : in ewok.tasks_shared.t_task_mode); end ewok.syscalls.ipc;
reznikmm/matreshka
Ada
1,954
ads
with League.Strings; with UI.Widgets.Grid_Views; with UI.Grid_Models; package Grid is type My_Row is new UI.Grid_Models.Abstract_Row with record Index : Positive; end record; type My_Row_Access is access all My_Row; type Rows is array (1 .. 30) of My_Row_Access; type Grid_Model is new UI.Grid_Models.Grid_Model with record My_Row : Rows; end record; procedure Initialize (Self : in out Grid_Model); overriding function Column_Count (Self : not null access Grid_Model) return Natural; overriding function Row_Count (Self : not null access Grid_Model; Parent : UI.Grid_Models.Row_Access := null) return Natural; overriding function Row (Self : not null access Grid_Model; Index : Positive; Parent : UI.Grid_Models.Row_Access := null) return not null UI.Grid_Models.Row_Access; overriding function Row_Index (Self : not null access Grid_Model; Index : UI.Grid_Models.Row_Access) return Positive; overriding function Parent (Self : not null access Grid_Model; Index : not null UI.Grid_Models.Row_Access) return UI.Grid_Models.Row_Access; overriding procedure Visit_Cell (Self : not null access Grid_Model; Index : not null UI.Grid_Models.Row_Access; Column : Positive; Visiter : not null access UI.Grid_Models.Cell_Visiter'Class); type Grid_Header is new UI.Widgets.Grid_Views.Grid_Header with null record; overriding function Text (Self : not null access Grid_Header; Column : Positive) return League.Strings.Universal_String; overriding function Width (Self : not null access Grid_Header; Column : Positive) return Natural; overriding function Text_Align (Self : not null access Grid_Header; Column : Positive) return UI.Widgets.Grid_Views.Align; Header : aliased Grid_Header; Model : aliased Grid_Model; end Grid;
AdaCore/Ada_Drivers_Library
Ada
23,226
ads
-- Copyright (c) 2013, Nordic Semiconductor ASA -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- * Redistributions of source code must retain the above copyright notice, this -- list of conditions and the following disclaimer. -- -- * Redistributions in binary form must reproduce the above copyright notice, -- this list of conditions and the following disclaimer in the documentation -- and/or other materials provided with the distribution. -- -- * Neither the name of Nordic Semiconductor ASA nor the names of its -- contributors may be used to endorse or promote products derived from -- this software without specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- This spec has been automatically generated from nrf51.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package NRF_SVD.TWI is pragma Preelaborate; --------------- -- Registers -- --------------- -- Shortcut between BB event and the SUSPEND task. type SHORTS_BB_SUSPEND_Field is (-- Shortcut disabled. Disabled, -- Shortcut enabled. Enabled) with Size => 1; for SHORTS_BB_SUSPEND_Field use (Disabled => 0, Enabled => 1); -- Shortcut between BB event and the STOP task. type SHORTS_BB_STOP_Field is (-- Shortcut disabled. Disabled, -- Shortcut enabled. Enabled) with Size => 1; for SHORTS_BB_STOP_Field use (Disabled => 0, Enabled => 1); -- Shortcuts for TWI. type SHORTS_Register is record -- Shortcut between BB event and the SUSPEND task. BB_SUSPEND : SHORTS_BB_SUSPEND_Field := NRF_SVD.TWI.Disabled; -- Shortcut between BB event and the STOP task. BB_STOP : SHORTS_BB_STOP_Field := NRF_SVD.TWI.Disabled; -- unspecified Reserved_2_31 : HAL.UInt30 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SHORTS_Register use record BB_SUSPEND at 0 range 0 .. 0; BB_STOP at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; -- Enable interrupt on STOPPED event. type INTENSET_STOPPED_Field is (-- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENSET_STOPPED_Field use (Disabled => 0, Enabled => 1); -- Enable interrupt on STOPPED event. type INTENSET_STOPPED_Field_1 is (-- Reset value for the field Intenset_Stopped_Field_Reset, -- Enable interrupt on write. Set) with Size => 1; for INTENSET_STOPPED_Field_1 use (Intenset_Stopped_Field_Reset => 0, Set => 1); -- Enable interrupt on READY event. type INTENSET_RXDREADY_Field is (-- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENSET_RXDREADY_Field use (Disabled => 0, Enabled => 1); -- Enable interrupt on READY event. type INTENSET_RXDREADY_Field_1 is (-- Reset value for the field Intenset_Rxdready_Field_Reset, -- Enable interrupt on write. Set) with Size => 1; for INTENSET_RXDREADY_Field_1 use (Intenset_Rxdready_Field_Reset => 0, Set => 1); -- Enable interrupt on TXDSENT event. type INTENSET_TXDSENT_Field is (-- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENSET_TXDSENT_Field use (Disabled => 0, Enabled => 1); -- Enable interrupt on TXDSENT event. type INTENSET_TXDSENT_Field_1 is (-- Reset value for the field Intenset_Txdsent_Field_Reset, -- Enable interrupt on write. Set) with Size => 1; for INTENSET_TXDSENT_Field_1 use (Intenset_Txdsent_Field_Reset => 0, Set => 1); -- Enable interrupt on ERROR event. type INTENSET_ERROR_Field is (-- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENSET_ERROR_Field use (Disabled => 0, Enabled => 1); -- Enable interrupt on ERROR event. type INTENSET_ERROR_Field_1 is (-- Reset value for the field Intenset_Error_Field_Reset, -- Enable interrupt on write. Set) with Size => 1; for INTENSET_ERROR_Field_1 use (Intenset_Error_Field_Reset => 0, Set => 1); -- Enable interrupt on BB event. type INTENSET_BB_Field is (-- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENSET_BB_Field use (Disabled => 0, Enabled => 1); -- Enable interrupt on BB event. type INTENSET_BB_Field_1 is (-- Reset value for the field Intenset_Bb_Field_Reset, -- Enable interrupt on write. Set) with Size => 1; for INTENSET_BB_Field_1 use (Intenset_Bb_Field_Reset => 0, Set => 1); -- Enable interrupt on SUSPENDED event. type INTENSET_SUSPENDED_Field is (-- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENSET_SUSPENDED_Field use (Disabled => 0, Enabled => 1); -- Enable interrupt on SUSPENDED event. type INTENSET_SUSPENDED_Field_1 is (-- Reset value for the field Intenset_Suspended_Field_Reset, -- Enable interrupt on write. Set) with Size => 1; for INTENSET_SUSPENDED_Field_1 use (Intenset_Suspended_Field_Reset => 0, Set => 1); -- Interrupt enable set register. type INTENSET_Register is record -- unspecified Reserved_0_0 : HAL.Bit := 16#0#; -- Enable interrupt on STOPPED event. STOPPED : INTENSET_STOPPED_Field_1 := Intenset_Stopped_Field_Reset; -- Enable interrupt on READY event. RXDREADY : INTENSET_RXDREADY_Field_1 := Intenset_Rxdready_Field_Reset; -- unspecified Reserved_3_6 : HAL.UInt4 := 16#0#; -- Enable interrupt on TXDSENT event. TXDSENT : INTENSET_TXDSENT_Field_1 := Intenset_Txdsent_Field_Reset; -- unspecified Reserved_8_8 : HAL.Bit := 16#0#; -- Enable interrupt on ERROR event. ERROR : INTENSET_ERROR_Field_1 := Intenset_Error_Field_Reset; -- unspecified Reserved_10_13 : HAL.UInt4 := 16#0#; -- Enable interrupt on BB event. BB : INTENSET_BB_Field_1 := Intenset_Bb_Field_Reset; -- unspecified Reserved_15_17 : HAL.UInt3 := 16#0#; -- Enable interrupt on SUSPENDED event. SUSPENDED : INTENSET_SUSPENDED_Field_1 := Intenset_Suspended_Field_Reset; -- unspecified Reserved_19_31 : HAL.UInt13 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INTENSET_Register use record Reserved_0_0 at 0 range 0 .. 0; STOPPED at 0 range 1 .. 1; RXDREADY at 0 range 2 .. 2; Reserved_3_6 at 0 range 3 .. 6; TXDSENT at 0 range 7 .. 7; Reserved_8_8 at 0 range 8 .. 8; ERROR at 0 range 9 .. 9; Reserved_10_13 at 0 range 10 .. 13; BB at 0 range 14 .. 14; Reserved_15_17 at 0 range 15 .. 17; SUSPENDED at 0 range 18 .. 18; Reserved_19_31 at 0 range 19 .. 31; end record; -- Disable interrupt on STOPPED event. type INTENCLR_STOPPED_Field is (-- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENCLR_STOPPED_Field use (Disabled => 0, Enabled => 1); -- Disable interrupt on STOPPED event. type INTENCLR_STOPPED_Field_1 is (-- Reset value for the field Intenclr_Stopped_Field_Reset, -- Disable interrupt on write. Clear) with Size => 1; for INTENCLR_STOPPED_Field_1 use (Intenclr_Stopped_Field_Reset => 0, Clear => 1); -- Disable interrupt on RXDREADY event. type INTENCLR_RXDREADY_Field is (-- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENCLR_RXDREADY_Field use (Disabled => 0, Enabled => 1); -- Disable interrupt on RXDREADY event. type INTENCLR_RXDREADY_Field_1 is (-- Reset value for the field Intenclr_Rxdready_Field_Reset, -- Disable interrupt on write. Clear) with Size => 1; for INTENCLR_RXDREADY_Field_1 use (Intenclr_Rxdready_Field_Reset => 0, Clear => 1); -- Disable interrupt on TXDSENT event. type INTENCLR_TXDSENT_Field is (-- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENCLR_TXDSENT_Field use (Disabled => 0, Enabled => 1); -- Disable interrupt on TXDSENT event. type INTENCLR_TXDSENT_Field_1 is (-- Reset value for the field Intenclr_Txdsent_Field_Reset, -- Disable interrupt on write. Clear) with Size => 1; for INTENCLR_TXDSENT_Field_1 use (Intenclr_Txdsent_Field_Reset => 0, Clear => 1); -- Disable interrupt on ERROR event. type INTENCLR_ERROR_Field is (-- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENCLR_ERROR_Field use (Disabled => 0, Enabled => 1); -- Disable interrupt on ERROR event. type INTENCLR_ERROR_Field_1 is (-- Reset value for the field Intenclr_Error_Field_Reset, -- Disable interrupt on write. Clear) with Size => 1; for INTENCLR_ERROR_Field_1 use (Intenclr_Error_Field_Reset => 0, Clear => 1); -- Disable interrupt on BB event. type INTENCLR_BB_Field is (-- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENCLR_BB_Field use (Disabled => 0, Enabled => 1); -- Disable interrupt on BB event. type INTENCLR_BB_Field_1 is (-- Reset value for the field Intenclr_Bb_Field_Reset, -- Disable interrupt on write. Clear) with Size => 1; for INTENCLR_BB_Field_1 use (Intenclr_Bb_Field_Reset => 0, Clear => 1); -- Disable interrupt on SUSPENDED event. type INTENCLR_SUSPENDED_Field is (-- Interrupt disabled. Disabled, -- Interrupt enabled. Enabled) with Size => 1; for INTENCLR_SUSPENDED_Field use (Disabled => 0, Enabled => 1); -- Disable interrupt on SUSPENDED event. type INTENCLR_SUSPENDED_Field_1 is (-- Reset value for the field Intenclr_Suspended_Field_Reset, -- Disable interrupt on write. Clear) with Size => 1; for INTENCLR_SUSPENDED_Field_1 use (Intenclr_Suspended_Field_Reset => 0, Clear => 1); -- Interrupt enable clear register. type INTENCLR_Register is record -- unspecified Reserved_0_0 : HAL.Bit := 16#0#; -- Disable interrupt on STOPPED event. STOPPED : INTENCLR_STOPPED_Field_1 := Intenclr_Stopped_Field_Reset; -- Disable interrupt on RXDREADY event. RXDREADY : INTENCLR_RXDREADY_Field_1 := Intenclr_Rxdready_Field_Reset; -- unspecified Reserved_3_6 : HAL.UInt4 := 16#0#; -- Disable interrupt on TXDSENT event. TXDSENT : INTENCLR_TXDSENT_Field_1 := Intenclr_Txdsent_Field_Reset; -- unspecified Reserved_8_8 : HAL.Bit := 16#0#; -- Disable interrupt on ERROR event. ERROR : INTENCLR_ERROR_Field_1 := Intenclr_Error_Field_Reset; -- unspecified Reserved_10_13 : HAL.UInt4 := 16#0#; -- Disable interrupt on BB event. BB : INTENCLR_BB_Field_1 := Intenclr_Bb_Field_Reset; -- unspecified Reserved_15_17 : HAL.UInt3 := 16#0#; -- Disable interrupt on SUSPENDED event. SUSPENDED : INTENCLR_SUSPENDED_Field_1 := Intenclr_Suspended_Field_Reset; -- unspecified Reserved_19_31 : HAL.UInt13 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INTENCLR_Register use record Reserved_0_0 at 0 range 0 .. 0; STOPPED at 0 range 1 .. 1; RXDREADY at 0 range 2 .. 2; Reserved_3_6 at 0 range 3 .. 6; TXDSENT at 0 range 7 .. 7; Reserved_8_8 at 0 range 8 .. 8; ERROR at 0 range 9 .. 9; Reserved_10_13 at 0 range 10 .. 13; BB at 0 range 14 .. 14; Reserved_15_17 at 0 range 15 .. 17; SUSPENDED at 0 range 18 .. 18; Reserved_19_31 at 0 range 19 .. 31; end record; -- Byte received in RXD register before read of the last received byte -- (data loss). type ERRORSRC_OVERRUN_Field is (-- Error not present. Notpresent, -- Error present. Present) with Size => 1; for ERRORSRC_OVERRUN_Field use (Notpresent => 0, Present => 1); -- Byte received in RXD register before read of the last received byte -- (data loss). type ERRORSRC_OVERRUN_Field_1 is (-- Reset value for the field Errorsrc_Overrun_Field_Reset, -- Clear error on write. Clear) with Size => 1; for ERRORSRC_OVERRUN_Field_1 use (Errorsrc_Overrun_Field_Reset => 0, Clear => 1); -- NACK received after sending the address. type ERRORSRC_ANACK_Field is (-- Error not present. Notpresent, -- Error present. Present) with Size => 1; for ERRORSRC_ANACK_Field use (Notpresent => 0, Present => 1); -- NACK received after sending the address. type ERRORSRC_ANACK_Field_1 is (-- Reset value for the field Errorsrc_Anack_Field_Reset, -- Clear error on write. Clear) with Size => 1; for ERRORSRC_ANACK_Field_1 use (Errorsrc_Anack_Field_Reset => 0, Clear => 1); -- NACK received after sending a data byte. type ERRORSRC_DNACK_Field is (-- Error not present. Notpresent, -- Error present. Present) with Size => 1; for ERRORSRC_DNACK_Field use (Notpresent => 0, Present => 1); -- NACK received after sending a data byte. type ERRORSRC_DNACK_Field_1 is (-- Reset value for the field Errorsrc_Dnack_Field_Reset, -- Clear error on write. Clear) with Size => 1; for ERRORSRC_DNACK_Field_1 use (Errorsrc_Dnack_Field_Reset => 0, Clear => 1); -- Two-wire error source. Write error field to 1 to clear error. type ERRORSRC_Register is record -- Byte received in RXD register before read of the last received byte -- (data loss). OVERRUN : ERRORSRC_OVERRUN_Field_1 := Errorsrc_Overrun_Field_Reset; -- NACK received after sending the address. ANACK : ERRORSRC_ANACK_Field_1 := Errorsrc_Anack_Field_Reset; -- NACK received after sending a data byte. DNACK : ERRORSRC_DNACK_Field_1 := Errorsrc_Dnack_Field_Reset; -- unspecified Reserved_3_31 : HAL.UInt29 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ERRORSRC_Register use record OVERRUN at 0 range 0 .. 0; ANACK at 0 range 1 .. 1; DNACK at 0 range 2 .. 2; Reserved_3_31 at 0 range 3 .. 31; end record; -- Enable or disable W2M type ENABLE_ENABLE_Field is (-- Disabled. Disabled, -- Enabled. Enabled) with Size => 3; for ENABLE_ENABLE_Field use (Disabled => 0, Enabled => 5); -- Enable two-wire master. type ENABLE_Register is record -- Enable or disable W2M ENABLE : ENABLE_ENABLE_Field := NRF_SVD.TWI.Disabled; -- unspecified Reserved_3_31 : HAL.UInt29 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ENABLE_Register use record ENABLE at 0 range 0 .. 2; Reserved_3_31 at 0 range 3 .. 31; end record; subtype RXD_RXD_Field is HAL.UInt8; -- RX data register. type RXD_Register is record -- Read-only. *** Reading this field has side effects on other resources -- ***. RX data from last transfer. RXD : RXD_RXD_Field; -- unspecified Reserved_8_31 : HAL.UInt24; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for RXD_Register use record RXD at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype TXD_TXD_Field is HAL.UInt8; -- TX data register. type TXD_Register is record -- TX data for next transfer. TXD : TXD_TXD_Field := 16#0#; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for TXD_Register use record TXD at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype ADDRESS_ADDRESS_Field is HAL.UInt7; -- Address used in the two-wire transfer. type ADDRESS_Register is record -- Two-wire address. ADDRESS : ADDRESS_ADDRESS_Field := 16#0#; -- unspecified Reserved_7_31 : HAL.UInt25 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ADDRESS_Register use record ADDRESS at 0 range 0 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; -- Peripheral power control. type POWER_POWER_Field is (-- Module power disabled. Disabled, -- Module power enabled. Enabled) with Size => 1; for POWER_POWER_Field use (Disabled => 0, Enabled => 1); -- Peripheral power control. type POWER_Register is record -- Peripheral power control. POWER : POWER_POWER_Field := NRF_SVD.TWI.Disabled; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for POWER_Register use record POWER at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Two-wire interface master 0. type TWI_Peripheral is record -- Start 2-Wire master receive sequence. TASKS_STARTRX : aliased HAL.UInt32; -- Start 2-Wire master transmit sequence. TASKS_STARTTX : aliased HAL.UInt32; -- Stop 2-Wire transaction. TASKS_STOP : aliased HAL.UInt32; -- Suspend 2-Wire transaction. TASKS_SUSPEND : aliased HAL.UInt32; -- Resume 2-Wire transaction. TASKS_RESUME : aliased HAL.UInt32; -- Two-wire stopped. EVENTS_STOPPED : aliased HAL.UInt32; -- Two-wire ready to deliver new RXD byte received. EVENTS_RXDREADY : aliased HAL.UInt32; -- Two-wire finished sending last TXD byte. EVENTS_TXDSENT : aliased HAL.UInt32; -- Two-wire error detected. EVENTS_ERROR : aliased HAL.UInt32; -- Two-wire byte boundary. EVENTS_BB : aliased HAL.UInt32; -- Two-wire suspended. EVENTS_SUSPENDED : aliased HAL.UInt32; -- Shortcuts for TWI. SHORTS : aliased SHORTS_Register; -- Interrupt enable set register. INTENSET : aliased INTENSET_Register; -- Interrupt enable clear register. INTENCLR : aliased INTENCLR_Register; -- Two-wire error source. Write error field to 1 to clear error. ERRORSRC : aliased ERRORSRC_Register; -- Enable two-wire master. ENABLE : aliased ENABLE_Register; -- Pin select for SCL. PSELSCL : aliased HAL.UInt32; -- Pin select for SDA. PSELSDA : aliased HAL.UInt32; -- RX data register. RXD : aliased RXD_Register; -- TX data register. TXD : aliased TXD_Register; -- Two-wire frequency. FREQUENCY : aliased HAL.UInt32; -- Address used in the two-wire transfer. ADDRESS : aliased ADDRESS_Register; -- Peripheral power control. POWER : aliased POWER_Register; end record with Volatile; for TWI_Peripheral use record TASKS_STARTRX at 16#0# range 0 .. 31; TASKS_STARTTX at 16#8# range 0 .. 31; TASKS_STOP at 16#14# range 0 .. 31; TASKS_SUSPEND at 16#1C# range 0 .. 31; TASKS_RESUME at 16#20# range 0 .. 31; EVENTS_STOPPED at 16#104# range 0 .. 31; EVENTS_RXDREADY at 16#108# range 0 .. 31; EVENTS_TXDSENT at 16#11C# range 0 .. 31; EVENTS_ERROR at 16#124# range 0 .. 31; EVENTS_BB at 16#138# range 0 .. 31; EVENTS_SUSPENDED at 16#148# range 0 .. 31; SHORTS at 16#200# range 0 .. 31; INTENSET at 16#304# range 0 .. 31; INTENCLR at 16#308# range 0 .. 31; ERRORSRC at 16#4C4# range 0 .. 31; ENABLE at 16#500# range 0 .. 31; PSELSCL at 16#508# range 0 .. 31; PSELSDA at 16#50C# range 0 .. 31; RXD at 16#518# range 0 .. 31; TXD at 16#51C# range 0 .. 31; FREQUENCY at 16#524# range 0 .. 31; ADDRESS at 16#588# range 0 .. 31; POWER at 16#FFC# range 0 .. 31; end record; -- Two-wire interface master 0. TWI0_Periph : aliased TWI_Peripheral with Import, Address => TWI0_Base; -- Two-wire interface master 1. TWI1_Periph : aliased TWI_Peripheral with Import, Address => TWI1_Base; end NRF_SVD.TWI;
RREE/ada-util
Ada
1,849
adb
----------------------------------------------------------------------- -- log -- Log example -- Copyright (C) 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 Util.Log; with Util.Log.Loggers; procedure Log is use Util.Log; Log : constant Loggers.Logger := Loggers.Create ("log"); Log2 : constant Loggers.Logger := Loggers.Create ("log.util"); procedure Report; procedure Report is begin Log2.Debug ("Report is called (debug message must be visible)"); end Report; begin -- Initialization is optional. Get the log configuration by reading the property -- file 'samples/log4j.properties'. The 'log.util' logger will use a DEBUG level -- and write the message in 'result.log'. Util.Log.Loggers.Initialize ("samples/log4j.properties"); Log.Info ("Starting the log example, level is {0}", Log.Get_Level_Name); -- Next log will do nothing Log.Debug ("A debug message (this should be hidden): {0}", "None"); Log.Info ("Log2 has the level {0}", Log2.Get_Level_Name); Report; Log.Warn ("A warning message"); Log.Error ("An error message"); Log.Info ("Debug message written in 'result.log'"); end Log;
zhmu/ananas
Ada
3,887
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- ADA.WIDE_WIDE_TEXT_IO.ENUMERATION_AUX -- -- -- -- S p e c -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ -- This package contains the routines for Ada.Wide_Wide_Text_IO.Enumeration_IO -- that are shared among separate instantiations. private package Ada.Wide_Wide_Text_IO.Enumeration_Aux is procedure Get_Enum_Lit (File : File_Type; Buf : out Wide_Wide_String; Buflen : out Natural); -- Reads an enumeration literal value from the file, folds to upper case, -- and stores the result in Buf, setting Buflen to the number of stored -- characters (Buf has a lower bound of 1). If more than Buflen characters -- are present in the literal, Data_Error is raised. procedure Scan_Enum_Lit (From : Wide_Wide_String; Start : out Natural; Stop : out Natural); -- Scans an enumeration literal at the start of From, skipping any leading -- spaces. Sets Start to the first character, Stop to the last character. -- Raises End_Error if no enumeration literal is found. procedure Put (File : File_Type; Item : Wide_Wide_String; Width : Field; Set : Type_Set); -- Outputs the enumeration literal image stored in Item to the given File, -- using the given Width and Set parameters (Item is always in upper case). procedure Puts (To : out Wide_Wide_String; Item : Wide_Wide_String; Set : Type_Set); -- Stores the enumeration literal image stored in Item to the string To, -- padding with trailing spaces if necessary to fill To. Set is used to end Ada.Wide_Wide_Text_IO.Enumeration_Aux;
reznikmm/matreshka
Ada
2,077
ads
-- Copyright (c) 1990 Regents of the University of California. -- All rights reserved. -- -- This software was developed by John Self of the Arcadia project -- at the University of California, Irvine. -- -- Redistribution and use in source and binary forms are permitted -- provided that the above copyright notice and this paragraph are -- duplicated in all such forms and that any documentation, -- advertising materials, and other materials related to such -- distribution and use acknowledge that the software was developed -- by the University of California, Irvine. The name of the -- University may not be used to endorse or promote products derived -- from this software without specific prior written permission. -- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR -- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. -- TITLE external_file_manager -- AUTHOR: John Self (UCI) -- DESCRIPTION opens external files for other functions -- NOTES This package opens external files, and thus may be system dependent -- because of limitations on file names. -- This version is for the VADS 5.5 Ada development system. -- $Header: /co/ua/self/arcadia/aflex/ada/src/RCS/file_managerS.a,v 1.4 90/01/12 15:20:00 self Exp Locker: self $ with Ada.Wide_Wide_Text_IO; package External_File_Manager is procedure Get_IO_Spec_File (File : in out Ada.Wide_Wide_Text_IO.File_Type); procedure Get_IO_Body_File (File : in out Ada.Wide_Wide_Text_IO.File_Type); procedure Get_DFA_Spec_File (File : in out Ada.Wide_Wide_Text_IO.File_Type); procedure Get_DFA_Body_File (File : in out Ada.Wide_Wide_Text_IO.File_Type); procedure Get_Scanner_Spec_File (File : in out Ada.Wide_Wide_Text_IO.File_Type); procedure Get_Scanner_Body_File (File : in out Ada.Wide_Wide_Text_IO.File_Type); procedure Get_Backtrack_File (File : in out Ada.Wide_Wide_Text_IO.File_Type); procedure INITIALIZE_FILES; end External_File_Manager;
charlesdaniels/libagar
Ada
3,627
adb
------------------------------------------------------------------------------ -- AGAR CORE LIBRARY -- -- A G A R . C O R E . I N I T -- -- B o d y -- -- -- -- Copyright (c) 2018-2019, Julien Nadeau Carriere ([email protected]) -- -- Copyright (c) 2010, coreland ([email protected]) -- -- -- -- Permission to use, copy, modify, and/or distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- ------------------------------------------------------------------------------ package body Agar.Init is procedure Get_Version (Major : out Natural; Minor : out Natural; Patch : out Natural) is Version : aliased Agar_Version; begin AG_GetVersion (Version'Unchecked_Access); Major := Natural (Version.Major); Minor := Natural (Version.Minor); Patch := Natural (Version.Patch); end Get_Version; function Init_Core (Program_Name : in String; Verbose : in Boolean := False; Create_Directory : in Boolean := False; Software_Timers : in Boolean := False) return Boolean is Ch_Name : aliased C.char_array := C.To_C (Program_Name); C_Flags : C.unsigned := 0; begin if Verbose then C_Flags := C_Flags or AG_VERBOSE; end if; if Create_Directory then C_Flags := C_Flags or AG_CREATE_DATADIR; end if; if Software_Timers then C_Flags := C_Flags or AG_SOFT_TIMERS; end if; return 0 = AG_InitCore (Progname => CS.To_Chars_Ptr (Ch_Name'Unchecked_Access), Flags => C_Flags); end; function Init_Core (Verbose : in Boolean := False; Create_Directory : in Boolean := False; Software_Timers : in Boolean := False) return Boolean is C_Flags : C.unsigned := 0; begin if Verbose then C_Flags := C_Flags or AG_VERBOSE; end if; if Create_Directory then C_Flags := C_Flags or AG_CREATE_DATADIR; end if; if Software_Timers then C_Flags := C_Flags or AG_SOFT_TIMERS; end if; return 0 = AG_InitCore (Progname => CS.Null_Ptr, Flags => C_Flags); end; -- -- Proxy procedure to call 'Atexit_Callback' from C. -- procedure At_Exit_Proxy with Convention => C; Atexit_Callback : Atexit_Func_Access := null; procedure At_Exit_Proxy is begin if Atexit_Callback /= null then Atexit_Callback.all; end if; end At_Exit_Proxy; procedure At_Exit (Callback : Atexit_Func_Access) is begin Atexit_Callback := Callback; AG_AtExitFunc (At_Exit_Proxy'Access); end At_Exit; end Agar.Init;
burratoo/Acton
Ada
1,120
ads
------------------------------------------------------------------------------------------ -- -- -- OAK COMPONENTS -- -- -- -- OAK.OAK_TIME.INTERNAL -- -- -- -- Copyright (C) 2012-2021, Patrick Bernardi -- -- -- ------------------------------------------------------------------------------------------ with Ada.Unchecked_Conversion; with Oak.Core_Support_Package.Time; package Oak.Oak_Time.Internal with Pure is function To_Internal_Time is new Ada.Unchecked_Conversion (Oak.Oak_Time.Time, Oak.Core_Support_Package.Time.Oak_Time); end Oak.Oak_Time.Internal;
jrcarter/Ada_GUI
Ada
39,152
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 . C A N V A S . C O N T E X T _ 2 D -- -- -- -- 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.Strings.Unbounded; with Ada.Numerics; with Ada.Text_IO; with Ada_GUI.Gnoga.Server.Connection; with Parsers.Multiline_Source.XPM; with Parsers.Multiline_Source.Text_IO; package body Ada_GUI.Gnoga.Gui.Element.Canvas.Context_2D is procedure Data (Image_Data : in out Image_Data_Type; Value : in String); function Data (Image_Data : Image_Data_Type) return String; -- Raw data transfer of pixel data from Browser function String_To_Pixel_Data (Value : String; Width, Height : Positive) return Gnoga.Pixel_Data_Type; -- Translate raw result from browser to Pixel_Data_Type ---------------------------- -- Get_Drawing_Context_2D -- ---------------------------- procedure Get_Drawing_Context_2D (Context : in out Context_2D_Type; Canvas : in out Canvas_Type'Class) is GID : constant String := Gnoga.Server.Connection.New_GID; begin Context.Context_ID := Ada.Strings.Unbounded.To_Unbounded_String (GID); Context.Connection_ID := Canvas.Connection_ID; Gnoga.Server.Connection.Execute_Script (Context.Connection_ID, "gnoga['" & GID & "']=" & Canvas.jQuery & ".get(0).getContext('2d');"); end Get_Drawing_Context_2D; ---------------- -- Fill_Color -- ---------------- procedure Fill_Color (Context : in out Context_2D_Type; Value : in Gnoga.RGBA_Type) is begin Context.Fill_Color (Gnoga.To_String (Value)); end Fill_Color; procedure Fill_Color (Context : in out Context_2D_Type; Value : in String) is begin Context.Property ("fillStyle", Value); end Fill_Color; procedure Fill_Color (Context : in out Context_2D_Type; Value : in Gnoga.Colors.Color_Enumeration) is begin Context.Fill_Color (Gnoga.Colors.To_String (Value)); end Fill_Color; ------------------- -- Fill_Gradient -- ------------------- procedure Fill_Gradient (Context : in out Context_2D_Type; Value : in out Gradient_Type'Class) is begin Context.Execute ("fillStyle=gnoga['" & Ada.Strings.Unbounded.To_String (Value.Context_ID) & "'];"); end Fill_Gradient; ------------------- -- Fill_Pattern -- ------------------- procedure Fill_Pattern (Context : in out Context_2D_Type; Value : in out Pattern_Type'Class) is begin Context.Execute ("fillStyle=gnoga['" & Ada.Strings.Unbounded.To_String (Value.Context_ID) & "'];"); end Fill_Pattern; ------------------ -- Stroke_Color -- ------------------ procedure Stroke_Color (Context : in out Context_2D_Type; Value : in Gnoga.RGBA_Type) is begin Context.Stroke_Color (Gnoga.To_String (Value)); end Stroke_Color; procedure Stroke_Color (Context : in out Context_2D_Type; Value : in String) is begin Context.Property ("strokeStyle", Value); end Stroke_Color; procedure Stroke_Color (Context : in out Context_2D_Type; Value : in Gnoga.Colors.Color_Enumeration) is begin Context.Stroke_Color (Gnoga.Colors.To_String (Value)); end Stroke_Color; --------------------- -- Stroke_Gradient -- --------------------- procedure Stroke_Gradient (Context : in out Context_2D_Type; Value : in out Gradient_Type'Class) is begin Context.Execute ("strokeStyle=gnoga['" & Ada.Strings.Unbounded.To_String (Value.Context_ID) & "'];"); end Stroke_Gradient; ------------------- -- Stroke_Pattern -- ------------------- procedure Stroke_Pattern (Context : in out Context_2D_Type; Value : in out Pattern_Type'Class) is begin Context.Execute ("strokeStyle=gnoga['" & Ada.Strings.Unbounded.To_String (Value.Context_ID) & "'];"); end Stroke_Pattern; ------------------ -- Shadow_Color -- ------------------ procedure Shadow_Color (Context : in out Context_2D_Type; Value : in Gnoga.RGBA_Type) is begin Context.Shadow_Color (Gnoga.To_String (Value)); end Shadow_Color; procedure Shadow_Color (Context : in out Context_2D_Type; Value : in String) is begin Context.Property ("shadowColor", Value); end Shadow_Color; procedure Shadow_Color (Context : in out Context_2D_Type; Value : in Gnoga.Colors.Color_Enumeration) is begin Context.Shadow_Color (Gnoga.Colors.To_String (Value)); end Shadow_Color; ----------------- -- Shadow_Blur -- ----------------- procedure Shadow_Blur (Context : in out Context_2D_Type; Value : in Integer) is begin Context.Property ("shadowBlur", Value); end Shadow_Blur; --------------------- -- Shadow_Offset_X -- --------------------- procedure Shadow_Offset_X (Context : in out Context_2D_Type; Value : in Integer) is begin Context.Property ("shadowOffsetX", Value); end Shadow_Offset_X; --------------------- -- Shadow_Offset_Y -- --------------------- procedure Shadow_Offset_Y (Context : in out Context_2D_Type; Value : in Integer) is begin Context.Property ("shadowOffsetY", Value); end Shadow_Offset_Y; -------------- -- Line_Cap -- -------------- procedure Line_Cap (Context : in out Context_2D_Type; Value : in Line_Cap_Type) is begin Context.Property ("lineCap", Value'Img); end Line_Cap; --------------- -- Line_Join -- --------------- procedure Line_Join (Context : in out Context_2D_Type; Value : in Line_Join_Type) is begin Context.Property ("lineJoin", Value'Img); end Line_Join; ---------------- -- Line_Width -- ---------------- procedure Line_Width (Context : in out Context_2D_Type; Value : in Integer) is begin Context.Property ("lineWidth", Value); end Line_Width; ----------------- -- Miter_Limit -- ----------------- procedure Miter_Limit (Context : in out Context_2D_Type; Value : in Positive) is begin Context.Property ("miterLimit", Value); end Miter_Limit; ------------------- -- Set_Line_Dash -- ------------------- procedure Set_Line_Dash (Context : in out Context_2D_Type; Dash_List : in Dash_Array_Type) is function Dash_String (Index : Natural) return String; -- Iterate over Dash_List to create JS Array for setLineDash function Dash_String (Index : Natural) return String is begin if Index > Dash_List'Last then return ""; elsif Index = Dash_List'Last then return Natural'Image (Dash_List (Index)); else return Natural'Image (Dash_List (Index)) & ',' & Dash_String (Index + 1); end if; end Dash_String; begin Context.Execute ("setLineDash([" & Dash_String (Dash_List'First) & "]);"); end Set_Line_Dash; ---------- -- Font -- ---------- procedure Font (Context : in out Context_2D_Type; Family : in String := "sans-serif"; Height : in String := "10px"; 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 Context.Property ("font", Style'Img & " " & Variant'Img & " " & W (W'First + 7 .. W'Last) & " " & Height & " " & Family); end Font; procedure Font (Context : in out Context_2D_Type; System_Font : in System_Font_Type) is begin case System_Font is when Caption | Icon | Menu => Context.Property ("font", System_Font'Img); when Message_Box => Context.Property ("font", "message-box"); when Small_Caption => Context.Property ("font", "small-caption"); when Status_Bar => Context.Property ("font", "status-bar"); end case; end Font; -------------------- -- Text_Alignment -- -------------------- procedure Text_Alignment (Context : in out Context_2D_Type; Value : in Alignment_Type) is V : constant String := Value'Img; begin case Value is when Left | Right | Center => Context.Property ("textAlign", V); when At_Start | To_End => Context.Property ("textAlign", V ((V'First + 3) .. V'Last)); end case; end Text_Alignment; ------------------- -- Text_Baseline -- ------------------- procedure Text_Baseline (Context : in out Context_2D_Type; Value : in Baseline_Type) is begin Context.Property ("textBaseline", Value'Img); end Text_Baseline; ------------------ -- Global_Alpha -- ------------------ procedure Global_Alpha (Context : in out Context_2D_Type; Alpha : in Gnoga.Alpha_Type) is begin Context.Property ("globalAlpha", Alpha'Img); end Global_Alpha; -------------------------------- -- Global_Composite_Operation -- -------------------------------- procedure Global_Composite_Operation (Context : in out Context_2D_Type; Value : in Composite_Method_Type) is V : constant String := Value'Img; begin case Value is when Lighter | Copy => Context.Property ("globalCompositeOperation", V); when Source_Over | Source_Atop | Source_In | Source_Out => Context.Property ("globalCompositeOperation", "source-" & V ((V'First + 7) .. V'Last)); when Destination_Over | Destination_Atop | Destination_In | Destination_Out => Context.Property ("globalCompositeOperation", "destination-" & V ((V'First + 12) .. V'Last)); when Xor_Copy => Context.Property ("globalCompositeOperation", "xor"); end case; end Global_Composite_Operation; ---------------------------- -- Create_Linear_Gradient -- ---------------------------- procedure Create_Linear_Gradient (Gradient : in out Gradient_Type; Context : in out Context_2D_Type'Class; X_1 : in Integer; Y_1 : in Integer; X_2 : in Integer; Y_2 : in Integer) is GID : constant String := Gnoga.Server.Connection.New_GID; begin Gradient.Context_ID := Ada.Strings.Unbounded.To_Unbounded_String (GID); Gradient.Connection_ID := Context.Connection_ID; Gnoga.Server.Connection.Execute_Script (Context.Connection_ID, "gnoga['" & GID & "']=" & "gnoga['" & Ada.Strings.Unbounded.To_String (Context.Context_ID) & "'].createLinearGradient(" & X_1'Img & "," & Y_1'Img & "," & X_2'Img & "," & Y_2'Img & ");"); end Create_Linear_Gradient; ---------------------------- -- Create_Radial_Gradient -- ---------------------------- procedure Create_Radial_Gradient (Gradient : in out Gradient_Type; Context : in out Context_2D_Type'Class; X_1 : in Integer; Y_1 : in Integer; R_1 : in Integer; X_2 : in Integer; Y_2 : in Integer; R_2 : in Integer) is GID : constant String := Gnoga.Server.Connection.New_GID; begin Gradient.Context_ID := Ada.Strings.Unbounded.To_Unbounded_String (GID); Gradient.Connection_ID := Context.Connection_ID; Gnoga.Server.Connection.Execute_Script (Context.Connection_ID, "gnoga['" & GID & "']=" & "gnoga['" & Ada.Strings.Unbounded.To_String (Context.Context_ID) & "'].createRadialGradient(" & X_1'Img & "," & Y_1'Img & "," & R_1'Img & "," & X_2'Img & "," & Y_2'Img & "," & R_2'Img & ");"); end Create_Radial_Gradient; -------------------- -- Add_Color_Stop -- -------------------- procedure Add_Color_Stop (Gradient : in out Gradient_Type; Position : in Gnoga.Frational_Range_Type; Color : in Gnoga.RGBA_Type) is begin Gradient.Add_Color_Stop (Position, Gnoga.To_String (Color)); end Add_Color_Stop; procedure Add_Color_Stop (Gradient : in out Gradient_Type; Position : in Gnoga.Frational_Range_Type; Color : in String) is begin Gradient.Execute ("addColorStop (" & Position'Img & ", '" & Color & "');"); end Add_Color_Stop; procedure Add_Color_Stop (Gradient : in out Gradient_Type; Position : in Gnoga.Frational_Range_Type; Color : in Gnoga.Colors.Color_Enumeration) is begin Gradient.Add_Color_Stop (Position, Gnoga.Colors.To_String (Color)); end Add_Color_Stop; ---------------------------- -- Create_Radial_Gradient -- ---------------------------- procedure Create_Pattern (Pattern : in out Pattern_Type; Context : in out Context_2D_Type'Class; Image : in out Element_Type'Class; Repeat_Pattern : in Repeat_Type := Repeat) is GID : constant String := Gnoga.Server.Connection.New_GID; function Repeat_to_String return String; function Repeat_to_String return String is begin case Repeat_Pattern is when Repeat => return "repeat"; when Repeat_X_Only => return "repeat-x"; when Repeat_Y_Only => return "repeat-y"; when No_Repeat => return "no-repeat"; end case; end Repeat_to_String; begin Pattern.Context_ID := Ada.Strings.Unbounded.To_Unbounded_String (GID); Pattern.Connection_ID := Context.Connection_ID; Gnoga.Server.Connection.Execute_Script (Context.Connection_ID, "gnoga['" & GID & "']=" & "gnoga['" & Ada.Strings.Unbounded.To_String (Context.Context_ID) & "'].createPattern(" & Image.jQuery & ".get(0), '" & Repeat_to_String & "');"); end Create_Pattern; --------------- -- Rectangle -- --------------- procedure Rectangle (Context : in out Context_2D_Type; Rectangle : in Gnoga.Rectangle_Type) is begin Context.Execute ("rect (" & Rectangle.X'Img & "," & Rectangle.Y'Img & "," & Rectangle.Width'Img & "," & Rectangle.Height'Img & ");"); end Rectangle; -------------------- -- Fill_Rectangle -- -------------------- procedure Fill_Rectangle (Context : in out Context_2D_Type; Rectangle : in Gnoga.Rectangle_Type) is begin Context.Execute ("fillRect (" & Rectangle.X'Img & "," & Rectangle.Y'Img & "," & Rectangle.Width'Img & "," & Rectangle.Height'Img & ");"); end Fill_Rectangle; ---------------------- -- Stroke_Rectangle -- ---------------------- procedure Stroke_Rectangle (Context : in out Context_2D_Type; Rectangle : in Gnoga.Rectangle_Type) is begin Context.Execute ("strokeRect (" & Rectangle.X'Img & "," & Rectangle.Y'Img & "," & Rectangle.Width'Img & "," & Rectangle.Height'Img & ");"); end Stroke_Rectangle; --------------------- -- Clear_Rectangle -- --------------------- procedure Clear_Rectangle (Context : in out Context_2D_Type; Rectangle : in Gnoga.Rectangle_Type) is begin Context.Execute ("clearRect (" & Rectangle.X'Img & "," & Rectangle.Y'Img & "," & Rectangle.Width'Img & "," & Rectangle.Height'Img & ");"); end Clear_Rectangle; ---------- -- Fill -- ---------- procedure Fill (Context : in out Context_2D_Type) is begin Context.Execute ("fill();"); end Fill; ------------ -- Stroke -- ------------ procedure Stroke (Context : in out Context_2D_Type) is begin Context.Execute ("stroke();"); end Stroke; ---------------- -- Begin_Path -- ---------------- procedure Begin_Path (Context : in out Context_2D_Type) is begin Context.Execute ("beginPath();"); end Begin_Path; -------------- -- Move_To -- -------------- procedure Move_To (Context : in out Context_2D_Type; X, Y : Integer) is begin Context.Execute ("moveTo(" & X'Img & "," & Y'Img & ");"); end Move_To; ---------------- -- Close_Path -- ---------------- procedure Close_Path (Context : in out Context_2D_Type) is begin Context.Execute ("closePath()"); end Close_Path; -------------- -- Line_To -- -------------- procedure Line_To (Context : in out Context_2D_Type; X, Y : Integer) is begin Context.Execute ("lineTo(" & X'Img & "," & Y'Img & ");"); end Line_To; ---------- -- Clip -- ---------- procedure Clip (Context : in out Context_2D_Type) is begin Context.Execute ("clip();"); end Clip; ------------------------ -- Quadratic_Curve_To -- ------------------------ procedure Quadratic_Curve_To (Context : in out Context_2D_Type; CP_X, CP_Y, X, Y : Integer) is begin Context.Execute ("quadraticCurveTo(" & CP_X'Img & "," & CP_Y'Img & "," & X'Img & "," & Y'Img & ");"); end Quadratic_Curve_To; --------------------- -- Bezier_Curve_To -- --------------------- procedure Bezier_Curve_To (Context : in out Context_2D_Type; CP_X_1, CP_Y_1, CP_X_2, CP_Y_2 : in Integer; X, Y : in Integer) is begin Context.Execute ("bezierCurveTo(" & CP_X_1'Img & "," & CP_Y_1'Img & "," & CP_X_2'Img & "," & CP_Y_2'Img & "," & X'Img & "," & Y'Img & ");"); end Bezier_Curve_To; ----------------- -- Arc_Radians -- ----------------- procedure Arc_Radians (Context : in out Context_2D_Type; X, Y : in Integer; Radius : in Integer; Starting_Angle, Ending_Angle : in Float; Counter_Clockwise : in Boolean := False) is begin Context.Execute ("arc(" & X'Img & "," & Y'Img & "," & Radius'Img & "," & Starting_Angle'Img & "," & Ending_Angle'Img & "," & Counter_Clockwise'Img & ");"); end Arc_Radians; ----------------- -- Arc_Degrees -- ----------------- procedure Arc_Degrees (Context : in out Context_2D_Type; X, Y : in Integer; Radius : in Integer; Starting_Angle, Ending_Angle : in Float; Counter_Clockwise : in Boolean := False) is begin Arc_Radians (Context, X, Y, Radius, Starting_Angle * Ada.Numerics.Pi / 180.0, Ending_Angle * Ada.Numerics.Pi / 180.0, Counter_Clockwise); end Arc_Degrees; ------------ -- Arc_To -- ------------ procedure Arc_To (Context : in out Context_2D_Type; X_1, Y_1, X_2, Y_2 : in Integer; Radius : in Integer) is begin Context.Execute ("arcTo(" & X_1'Img & "," & Y_1'Img & "," & X_2'Img & "," & Y_2'Img & "," & Radius'Img & ");"); end Arc_To; ---------------- -- Polygon_To -- ---------------- procedure Polygon_To (Context : in out Context_2D_Type; Points : in Gnoga.Point_Array_Type) is Script : Ada.Strings.Unbounded.Unbounded_String; begin for Point of Points loop Ada.Strings.Unbounded.Append (Script, "gnoga['" & Context.ID & "'].lineTo(" & Point.X'Img & "," & Point.Y'Img & ");"); end loop; Gnoga.Server.Connection.Execute_Script (Context.Connection_ID, Ada.Strings.Unbounded.To_String (Script)); end Polygon_To; ---------------------- -- Is_Point_In_Path -- ---------------------- function Is_Point_In_Path (Context : Context_2D_Type; X, Y : Integer) return Boolean is begin return Context.Execute ("isPointInPath(" & X'Img & "," & Y'Img & ");") = "true"; end Is_Point_In_Path; ----------- -- Scale -- ----------- procedure Scale (Context : in out Context_2D_Type; Width, Height : Float) is begin Context.Execute ("scale (" & Width'Img & "," & Height'Img & ");"); end Scale; -------------------- -- Rotate_Radians -- -------------------- procedure Rotate_Radians (Context : in out Context_2D_Type; Radians : Float) is begin Context.Execute ("rotate(" & Radians'Img & ");"); end Rotate_Radians; -------------------- -- Rotate_Degrees -- -------------------- procedure Rotate_Degrees (Context : in out Context_2D_Type; Degrees : Float) is begin Rotate_Radians (Context, Degrees * Ada.Numerics.Pi / 180.0); end Rotate_Degrees; --------------- -- Translate -- --------------- procedure Translate (Context : in out Context_2D_Type; X, Y : Integer) is begin Context.Execute ("translate(" & X'Img & "," & Y'Img & ");"); end Translate; --------------- -- Transform -- --------------- procedure Transform (Context : in out Context_2D_Type; Scale_Horizontal, Skew_Horizontal : in Float; Scale_Vertical, Skew_Vertical : in Float; Move_Horizontal, Move_Vertical : in Float) is begin Context.Execute ("transform(" & Scale_Horizontal'Img & "," & Skew_Horizontal'Img & "," & Scale_Vertical'Img & "," & Skew_Vertical'Img & "," & Move_Horizontal'Img & "," & Move_Vertical'Img & ");"); end Transform; ------------------- -- Set_Transform -- ------------------- procedure Set_Transform (Context : in out Context_2D_Type; Scale_Horizontal, Skew_Horizontal : in Float; Scale_Vertical, Skew_Vertical : in Float; Move_Horizontal, Move_Vertical : in Float) is begin Context.Execute ("setTransform(" & Scale_Horizontal'Img & "," & Skew_Horizontal'Img & "," & Scale_Vertical'Img & "," & Skew_Vertical'Img & "," & Move_Horizontal'Img & "," & Move_Vertical'Img & ");"); end Set_Transform; procedure Fill_Text (Context : in out Context_2D_Type; Text : in String; X, Y : in Integer; Max_Length : in Natural := 0) is function Max_To_String return String; function Max_To_String return String is begin if Max_Length > 0 then return "," & Max_Length'Img; else return ""; end if; end Max_To_String; begin Context.Execute ("fillText('" & Escape_Quotes (Text) & "'," & X'Img & "," & Y'Img & Max_To_String & ");"); end Fill_Text; procedure Stroke_Text (Context : in out Context_2D_Type; Text : in String; X, Y : in Integer; Max_Length : in Natural := 0) is function Max_To_String return String; function Max_To_String return String is begin if Max_Length > 0 then return "," & Max_Length'Img; else return ""; end if; end Max_To_String; begin Context.Execute ("strokeText('" & Escape_Quotes (Text) & "'," & X'Img & "," & Y'Img & Max_To_String & ");"); end Stroke_Text; function Measure_Text_Width (Context : Context_2D_Type; Text : String) return Float is begin return Float'Value (Gnoga.Server.Connection.Execute_Script (ID => Context.Connection_ID, Script => "gnoga['" & Ada.Strings.Unbounded.To_String (Context.Context_ID) & "'].measureText ('" & Escape_Quotes (Text) & "').width")); end Measure_Text_Width; ---------------- -- Draw_Image -- ---------------- procedure Draw_Image (Context : in out Context_2D_Type'Class; Image : in out Element_Type'Class; X, Y : in Integer) is begin Context.Execute ("drawImage (" & Image.jQuery & ".get(0)," & X'Img & "," & Y'Img & ")"); end Draw_Image; procedure Draw_Image (Context : in out Context_2D_Type'Class; Image : in out Element_Type'Class; X, Y : in Integer; Width : in Natural; Height : in Natural) is begin Context.Execute ("drawImage (" & Image.jQuery & ".get(0)," & X'Img & "," & Y'Img & "," & Width'Img & "," & Height'Img & ")"); end Draw_Image; ----------------------- -- Create_Image_Data -- ----------------------- procedure Create_Image_Data (Context : in out Context_2D_Type; Image_Data : in out Image_Data_Type'Class; Width, Height : in Integer) is GID : constant String := Gnoga.Server.Connection.New_GID; begin Image_Data.Context_ID := Ada.Strings.Unbounded.To_Unbounded_String (GID); Image_Data.Connection_ID := Context.Connection_ID; Gnoga.Server.Connection.Execute_Script (Context.Connection_ID, "gnoga['" & GID & "']=gnoga['" & Context.ID & "'].createImageData(" & Width'Img & "," & Height'Img & ")"); end Create_Image_Data; -------------------------- -- String_To_Pixel_Data -- -------------------------- function String_To_Pixel_Data (Value : String; Width, Height : Positive) return Gnoga.Pixel_Data_Type is use Ada.Strings.Fixed; D : Gnoga.Pixel_Data_Type (1 .. Width, 1 .. Height); S : Integer := Value'First; F : Integer := Value'First - 1; function Split return Color_Type; -- Split string and extract values function Split return Color_Type is begin S := F + 1; F := Index (Source => Value, Pattern => ",", From => S); if F = 0 then F := Value'Last; return Color_Type'Value (Value (S .. F)); end if; return Color_Type'Value (Value (S .. F - 1)); end Split; begin for X in 1 .. Width loop for Y in 1 .. Height loop D (X, Y) := (Split, Split, Split, Split); end loop; end loop; return D; end String_To_Pixel_Data; ----------- -- Pixel -- ----------- function Pixel (Context : Context_2D_Type; X, Y : Integer) return Gnoga.Pixel_Type is D : constant String := Gnoga.Server.Connection.Execute_Script (Context.Connection_ID, "Array.prototype.join.call" & "(gnoga['" & Context.ID & "'].getImageData(" & X'Img & "," & Y'Img & ",1,1).data);"); P : constant Gnoga.Pixel_Data_Type := String_To_Pixel_Data (D, 1, 1); begin return P (1, 1); end Pixel; procedure Pixel (Context : in out Context_2D_Type; X, Y : in Integer; Color : in Gnoga.Pixel_Type) is begin Gnoga.Server.Connection.Execute_Script (Context.Connection_ID, "var p=gnoga['" & Context.ID & "'].createImageData(1,1); " & "p.data.set (('" & Color.Red'Img & "," & Color.Green'Img & "," & Color.Blue'Img & "," & Color.Alpha'Img & "').split(',')); " & "gnoga['" & Context.ID & "'].putImageData(p," & X'Img & "," & Y'Img & ")"); end Pixel; procedure Pixel (Context : in out Context_2D_Type; X, Y : in Integer; Color : in Gnoga.Colors.Color_Enumeration) is C : constant Gnoga.Pixel_Type := Gnoga.To_Pixel (Gnoga.Colors.To_RGBA (Color)); begin Pixel (Context, X, Y, C); end Pixel; -------------------- -- Get_Image_Data -- -------------------- procedure Get_Image_Data (Context : in out Context_2D_Type; Image_Data : in out Image_Data_Type'Class; Left, Top : in Integer; Width, Height : in Integer) is GID : constant String := Gnoga.Server.Connection.New_GID; begin Image_Data.Context_ID := Ada.Strings.Unbounded.To_Unbounded_String (GID); Image_Data.Connection_ID := Context.Connection_ID; Gnoga.Server.Connection.Execute_Script (Context.Connection_ID, "gnoga['" & GID & "']=gnoga['" & Context.ID & "'].getImageData(" & Left'Img & "," & Top'Img & "," & Width'Img & "," & Height'Img & ")"); end Get_Image_Data; -------------------- -- Put_Image_Data -- -------------------- procedure Put_Image_Data (Context : in out Context_2D_Type; Image_Data : in out Image_Data_Type'Class; Left, Top : in Integer) is begin Context.Execute ("putImageData(gnoga['" & Image_Data.ID & "']," & Left'Img & "," & Top'Img & ")"); end Put_Image_Data; ----------- -- Width -- ----------- function Width (Image_Data : Image_Data_Type) return Natural is begin return Image_Data.Property ("width"); end Width; ------------ -- Height -- ------------ function Height (Image_Data : Image_Data_Type) return Natural is begin return Image_Data.Property ("height"); end Height; ---------- -- Data -- ---------- procedure Data (Image_Data : in out Image_Data_Type; Value : in String) is begin Gnoga.Server.Connection.Execute_Script (Image_Data.Connection_ID, "gnoga['" & Image_Data.ID & "'].data.set (('" & Value & "').split(','))"); end Data; function Data (Image_Data : Image_Data_Type) return String is begin return Gnoga.Server.Connection.Execute_Script (Image_Data.Connection_ID, "Array.prototype.join.call (gnoga['" & Image_Data.ID & "'].data)"); end Data; procedure Data (Image_Data : in out Image_Data_Type; Value : in Gnoga.Pixel_Data_Type) is C : constant String := ","; S : String (1 .. 16 * Value'Length (1) * Value'Length (2)); P : Positive := 1; begin for X in 1 .. Value'Length (1) loop for Y in 1 .. Value'Length (2) loop declare T : constant String := Gnoga.Left_Trim (Value (X, Y).Red'Img) & C & Gnoga.Left_Trim (Value (X, Y).Green'Img) & C & Gnoga.Left_Trim (Value (X, Y).Blue'Img) & C & Gnoga.Left_Trim (Value (X, Y).Alpha'Img) & C; begin S (P .. P + T'Length - 1) := T; P := P + T'Length; end; end loop; end loop; Data (Image_Data, S (1 .. P - 2)); end Data; function Data (Image_Data : Image_Data_Type) return Gnoga.Pixel_Data_Type is begin return String_To_Pixel_Data (Data (Image_Data), Image_Data.Width, Image_Data.Height); end Data; ------------------ -- New_From_XPM -- ------------------ procedure New_From_XPM (Image : out Gnoga.Pixel_Data_Access; File_Name : String) is use Parsers.Multiline_Source.XPM; use Parsers.Multiline_Source.Text_IO; use Ada.Text_IO; function To_Red (Value : RGB_Color) return Gnoga.Color_Type is (Gnoga.Color_Type (Value / 16#10000#)); function To_Green (Value : RGB_Color) return Gnoga.Color_Type is (Gnoga.Color_Type ((Value mod 16#10000#) / 16#100#)); function To_Blue (Value : RGB_Color) return Gnoga.Color_Type is (Gnoga.Color_Type (Value mod 16#100#)); XPM_File : aliased File_Type; begin Open (XPM_File, In_File, File_Name); declare XPM_Source : aliased Parsers.Multiline_Source.Text_IO.Source (XPM_File'Access); XPM_Header : constant Descriptor := Get (XPM_Source'Access); XMP_Map : constant Color_Tables.Table := Get (XPM_Source'Access, XPM_Header); XPM_Image : constant Pixel_Buffer := Get (XPM_Source'Access, XPM_Header, XMP_Map); begin Image := new Gnoga.Pixel_Data_Type (1 .. XPM_Header.Width, 1 .. XPM_Header.Height); for X in Image'Range (1) loop for Y in Image'Range (2) loop Image (X, Y) := (To_Red (XPM_Image (X, Y)), To_Green (XPM_Image (X, Y)), To_Blue (XPM_Image (X, Y)), Alpha => 255); end loop; end loop; end; Close (XPM_File); end New_From_XPM; ---------- -- Save -- ---------- procedure Save (Context : in out Context_2D_Type) is begin Context.Execute ("save();"); end Save; ------------- -- Restore -- ------------- procedure Restore (Context : in out Context_2D_Type) is begin Context.Execute ("restore();"); end Restore; end Ada_GUI.Gnoga.Gui.Element.Canvas.Context_2D;
reznikmm/matreshka
Ada
3,669
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Number_Quarter_Elements is pragma Preelaborate; type ODF_Number_Quarter is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Number_Quarter_Access is access all ODF_Number_Quarter'Class with Storage_Size => 0; end ODF.DOM.Number_Quarter_Elements;
zhmu/ananas
Ada
7,302
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . W I D T H _ I -- -- -- -- 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.Numerics.Big_Numbers.Big_Integers_Ghost; use Ada.Numerics.Big_Numbers.Big_Integers_Ghost; function System.Width_I (Lo, Hi : Int) return Natural is -- Ghost code, loop invariants and assertions in this unit are meant for -- analysis only, not for run-time checking, as it would be too costly -- otherwise. This is enforced by setting the assertion policy to Ignore. pragma Assertion_Policy (Ghost => Ignore, Loop_Invariant => Ignore, Assert => Ignore); ----------------------- -- Local Subprograms -- ----------------------- package Signed_Conversion is new Signed_Conversions (Int => Int); function Big (Arg : Int) return Big_Integer renames Signed_Conversion.To_Big_Integer; -- Maximum value of exponent for 10 that fits in Uns'Base function Max_Log10 return Natural is (case Int'Base'Size is when 8 => 2, when 16 => 4, when 32 => 9, when 64 => 19, when 128 => 38, when others => raise Program_Error) with Ghost; ------------------ -- Local Lemmas -- ------------------ procedure Lemma_Lower_Mult (A, B, C : Big_Natural) with Ghost, Pre => A <= B, Post => A * C <= B * C; procedure Lemma_Div_Commutation (X, Y : Int) with Ghost, Pre => X >= 0 and Y > 0, Post => Big (X) / Big (Y) = Big (X / Y); procedure Lemma_Div_Twice (X : Big_Natural; Y, Z : Big_Positive) with Ghost, Post => X / Y / Z = X / (Y * Z); ---------------------- -- Lemma_Lower_Mult -- ---------------------- procedure Lemma_Lower_Mult (A, B, C : Big_Natural) is null; --------------------------- -- Lemma_Div_Commutation -- --------------------------- procedure Lemma_Div_Commutation (X, Y : Int) is null; --------------------- -- Lemma_Div_Twice -- --------------------- procedure Lemma_Div_Twice (X : Big_Natural; Y, Z : Big_Positive) is XY : constant Big_Natural := X / Y; YZ : constant Big_Natural := Y * Z; XYZ : constant Big_Natural := X / Y / Z; R : constant Big_Natural := (XY rem Z) * Y + (X rem Y); begin pragma Assert (X = XY * Y + (X rem Y)); pragma Assert (XY = XY / Z * Z + (XY rem Z)); pragma Assert (X = XYZ * YZ + R); pragma Assert ((XY rem Z) * Y <= (Z - 1) * Y); pragma Assert (R <= YZ - 1); pragma Assert (X / YZ = (XYZ * YZ + R) / YZ); pragma Assert (X / YZ = XYZ + R / YZ); end Lemma_Div_Twice; -- Local variables W : Natural; T : Int; -- Local ghost variables Max_W : constant Natural := Max_Log10 with Ghost; Big_10 : constant Big_Integer := Big (10) with Ghost; Pow : Big_Integer := 1 with Ghost; T_Init : constant Int := Int'Max (abs (Int'Max (Lo, Int'First + 1)), abs (Int'Max (Hi, Int'First + 1))) with Ghost; -- Start of processing for System.Width_I begin if Lo > Hi then return 0; else -- Minimum value is 2, one for sign, one for digit W := 2; -- Get max of absolute values, but avoid bomb if we have the maximum -- negative number (note that First + 1 has same digits as First) T := Int'Max ( abs (Int'Max (Lo, Int'First + 1)), abs (Int'Max (Hi, Int'First + 1))); -- Increase value if more digits required while T >= 10 loop Lemma_Div_Commutation (T, 10); Lemma_Div_Twice (Big (T_Init), Big_10 ** (W - 2), Big_10); T := T / 10; W := W + 1; Pow := Pow * 10; pragma Loop_Invariant (T >= 0); pragma Loop_Invariant (W in 3 .. Max_W + 3); pragma Loop_Invariant (Pow = Big_10 ** (W - 2)); pragma Loop_Invariant (Big (T) = Big (T_Init) / Pow); pragma Loop_Variant (Decreases => T); end loop; declare F : constant Big_Integer := Big_10 ** (W - 2) with Ghost; Q : constant Big_Integer := Big (T_Init) / F with Ghost; R : constant Big_Integer := Big (T_Init) rem F with Ghost; begin pragma Assert (Q < Big_10); pragma Assert (Big (T_Init) = Q * F + R); Lemma_Lower_Mult (Q, Big (9), F); pragma Assert (Big (T_Init) <= Big (9) * F + F - 1); pragma Assert (Big (T_Init) < Big_10 * F); pragma Assert (Big_10 * F = Big_10 ** (W - 1)); end; -- This is an expression of the functional postcondition for Width_I, -- which cannot be expressed readily as a postcondition as this would -- require making the instantiation Signed_Conversion and function Big -- available from the spec. pragma Assert (Big (Int'Max (Lo, Int'First + 1)) < Big_10 ** (W - 1)); pragma Assert (Big (Int'Max (Hi, Int'First + 1)) < Big_10 ** (W - 1)); return W; end if; end System.Width_I;
seipy/ada-voxel-space-demo
Ada
3,337
adb
with Interfaces; use Interfaces; with Ada.Real_Time; use Ada.Real_Time; with Ada_Voxel; with SDL_Display; with Color_Map; with Height_Map; with Keyboard; with Ada.Numerics.Generic_Elementary_Functions; procedure Main is Screen_Width : constant := 800; Screen_Height : constant := 600; package Float_Functions is new Ada.Numerics.Generic_Elementary_Functions (Float); package Display is new SDL_Display (Screen_Width, Screen_Height); function Color_Map (X, Y : Integer) return Display.SDL_Pixel; function Height_Map (X, Y : Integer) return Integer; package Voxel is new Ada_Voxel (Color => Display.SDL_Pixel, Screen_Width => Screen_Width, Screen_Height => Screen_Height, Color_Map => Color_Map, Height_Map => Height_Map, Draw_Vertical_Line => Display.Draw_Vertical_Line); --------------- -- Color_Map -- --------------- function Color_Map (X, Y : Integer) return Display.SDL_Pixel is C : constant Unsigned_8 := Standard.Color_Map.Map ((Integer (X) mod 1024) + 1024 * (Integer (Y) mod 1024)); RGB : constant Standard.Color_Map.RGB := Standard.Color_Map.Palette (C); begin return Display.To_SDL_Color (RGB.R, RGB.G, RGB.B); end Color_Map; ---------------- -- Height_Map -- ---------------- function Height_Map (X, Y : Integer) return Integer is begin return Integer (Standard.Height_Map.Map ((Integer (X) mod 1024) + 1024 * (Integer (Y) mod 1024))); end Height_Map; Cam_X : Float := 1060.0; Cam_Y : Float := -350.0; Cam_Angle : Float := 5.4; Cam_Height : Float := 120.0; Period : constant Time_Span := To_Time_Span (1.0 / 60.0); Next_Release : Time := Clock + Period; begin loop Keyboard.Update; if Keyboard.Pressed (Keyboard.Up) then Cam_Height := Cam_Height + 0.75; end if; if Keyboard.Pressed (Keyboard.Down) then Cam_Height := Cam_Height - 0.75; end if; if Keyboard.Pressed (Keyboard.Left) then Cam_Angle := Cam_Angle + 0.03; end if; if Keyboard.Pressed (Keyboard.Right) then Cam_Angle := Cam_Angle - 0.03; end if; if Keyboard.Pressed (Keyboard.Forward) then Cam_X := Cam_X - Float_Functions.Sin (Cam_Angle); Cam_Y := Cam_Y - Float_Functions.Cos (Cam_Angle); end if; if Keyboard.Pressed (Keyboard.Backward) then Cam_X := Cam_X + Float_Functions.Sin (Cam_Angle); Cam_Y := Cam_Y + Float_Functions.Cos (Cam_Angle); end if; if Keyboard.Pressed (Keyboard.Esc) then return; end if; if Cam_Height < Float (Height_Map (Integer (Cam_X), Integer (Cam_Y))) + 15.0 then Cam_Height := Float (Height_Map (Integer (Cam_X), Integer (Cam_Y))) + 15.0; end if; Display.Start_Render; Display.Fill (Display.To_SDL_Color (135, 206, 250)); Voxel.Render (Cam_X, Cam_Y, Cam_Angle, Cam_Height, Horizon => 60.0, Distance => 400.0, Scale_Height => 200.0); Display.End_Render; -- delay until Next_Release; -- Next_Release := Next_Release + Period; end loop; end Main;
soccasys/Ada_Drivers_Library
Ada
1,939
ads
-- This package was generated by the Ada_Drivers_Library project wizard script package ADL_Config is Vendor : constant String := "STMicro"; -- From board definition Max_Mount_Points : constant := 2; -- From default value Max_Mount_Name_Length : constant := 128; -- From default value Runtime_Profile : constant String := "ravenscar-sfp"; -- From command line Device_Name : constant String := "STM32F405RGTx"; -- From board definition Device_Family : constant String := "STM32F4"; -- From board definition Has_Ravenscar_SFP_Runtime : constant String := "True"; -- From board definition Runtime_Name : constant String := "ravenscar-sfp-feather_stm32f405"; -- From default value Has_Ravenscar_Full_Runtime : constant String := "True"; -- From board definition CPU_Core : constant String := "ARM Cortex-M4F"; -- From mcu definition Board : constant String := "Feather_STM32F405"; -- From command line Has_ZFP_Runtime : constant String := "False"; -- From board definition Number_Of_Interrupts : constant := 0; -- From default value High_Speed_External_Clock : constant := 12000000; -- From board definition Use_Startup_Gen : constant Boolean := False; -- From command line Max_Path_Length : constant := 1024; -- From default value Runtime_Name_Suffix : constant String := "feather_stm32f405"; -- From board definition Architecture : constant String := "ARM"; -- From board definition end ADL_Config;
reznikmm/matreshka
Ada
4,169
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Text_Protection_Key_Digest_Algorithm_Attributes; package Matreshka.ODF_Text.Protection_Key_Digest_Algorithm_Attributes is type Text_Protection_Key_Digest_Algorithm_Attribute_Node is new Matreshka.ODF_Text.Abstract_Text_Attribute_Node and ODF.DOM.Text_Protection_Key_Digest_Algorithm_Attributes.ODF_Text_Protection_Key_Digest_Algorithm_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Text_Protection_Key_Digest_Algorithm_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Text_Protection_Key_Digest_Algorithm_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Text.Protection_Key_Digest_Algorithm_Attributes;
melwyncarlo/ProjectEuler
Ada
303
adb
with Ada.Text_IO; with Ada.Integer_Text_IO; -- Copyright 2021 Melwyn Francis Carlo procedure A057 is use Ada.Text_IO; use Ada.Integer_Text_IO; Str : constant String (1 .. 12) := "Hello World "; Num : constant Integer := 2021; begin Put (Str); Put (Num, Width => 0); end A057;
reznikmm/matreshka
Ada
70
ads
package Properties.Clauses is pragma Pure; end Properties.Clauses;
Rodeo-McCabe/orka
Ada
1,465
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2018 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with Orka.Jobs.System; package Orka_Test.Package_9_Jobs is package Job_System is new Orka.Jobs.System (Maximum_Queued_Jobs => 4, Maximum_Job_Graphs => 1); type Test_Parallel_Job is new Orka.Jobs.Abstract_Parallel_Job with null record; function Clone_Job (Job : Orka.Jobs.Parallel_Job_Ptr; Length : Positive) return Orka.Jobs.Dependency_Array; overriding procedure Execute (Object : Test_Parallel_Job; Context : Orka.Jobs.Execution_Context'Class; From, To : Positive); type Test_Sequential_Job is new Orka.Jobs.Abstract_Job with record ID : Natural; end record; overriding procedure Execute (Object : Test_Sequential_Job; Context : Orka.Jobs.Execution_Context'Class); end Orka_Test.Package_9_Jobs;
ohenley/ada-util
Ada
15,044
adb
----------------------------------------------------------------------- -- util-files -- Various File Utility Packages -- Copyright (C) 2001, 2002, 2003, 2009, 2010, 2011, 2012, 2015, 2017 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Directories; with Ada.Strings.Fixed; with Ada.Streams; with Ada.Streams.Stream_IO; with Ada.Text_IO; with Util.Strings.Tokenizers; package body Util.Files is -- ------------------------------ -- Read a complete file into a string. -- The <b>Max_Size</b> parameter indicates the maximum size that is read. -- ------------------------------ procedure Read_File (Path : in String; Into : out Unbounded_String; Max_Size : in Natural := 0) is use Ada.Streams; use Ada.Streams.Stream_IO; F : File_Type; Buffer : Stream_Element_Array (1 .. 10_000); Pos : Positive_Count := 1; Last : Stream_Element_Offset; Space : Natural; begin if Max_Size = 0 then Space := Natural'Last; else Space := Max_Size; end if; Open (Name => Path, File => F, Mode => In_File); loop Read (File => F, Item => Buffer, From => Pos, Last => Last); if Natural (Last) > Space then Last := Stream_Element_Offset (Space); end if; for I in 1 .. Last loop Append (Into, Character'Val (Buffer (I))); end loop; exit when Last < Buffer'Length; Pos := Pos + Positive_Count (Last); end loop; Close (F); exception when others => if Is_Open (F) then Close (F); end if; raise; end Read_File; -- ------------------------------ -- Read the file with the given path, one line at a time and execute the <b>Process</b> -- procedure with each line as argument. -- ------------------------------ procedure Read_File (Path : in String; Process : not null access procedure (Line : in String)) is File : Ada.Text_IO.File_Type; begin Ada.Text_IO.Open (File => File, Mode => Ada.Text_IO.In_File, Name => Path); while not Ada.Text_IO.End_Of_File (File) loop Process (Ada.Text_IO.Get_Line (File)); end loop; Ada.Text_IO.Close (File); end Read_File; -- ------------------------------ -- Read the file with the given path, one line at a time and append each line to -- the <b>Into</b> vector. -- ------------------------------ procedure Read_File (Path : in String; Into : in out Util.Strings.Vectors.Vector) is procedure Append (Line : in String); procedure Append (Line : in String) is begin Into.Append (Line); end Append; begin Read_File (Path, Append'Access); end Read_File; -- ------------------------------ -- Save the string into a file creating the file if necessary -- ------------------------------ procedure Write_File (Path : in String; Content : in String) is use Ada.Streams; use Ada.Streams.Stream_IO; use Ada.Directories; F : File_Type; Buffer : Stream_Element_Array (Stream_Element_Offset (Content'First) .. Stream_Element_Offset (Content'Last)); Dir : constant String := Containing_Directory (Path); begin if not Exists (Dir) then Create_Path (Dir); end if; Create (File => F, Name => Path); for I in Content'Range loop Buffer (Stream_Element_Offset (I)) := Stream_Element (Character'Pos (Content (I))); end loop; Write (F, Buffer); Close (F); exception when others => if Is_Open (F) then Close (F); end if; raise; end Write_File; -- ------------------------------ -- Save the string into a file creating the file if necessary -- ------------------------------ procedure Write_File (Path : in String; Content : in Unbounded_String) is begin Write_File (Path, Ada.Strings.Unbounded.To_String (Content)); end Write_File; -- ------------------------------ -- Iterate over the search directories defined in <b>Paths</b> and execute -- <b>Process</b> with each directory until it returns <b>True</b> in <b>Done</b> -- or the last search directory is found. Each search directory -- is separated by ';' (yes, even on Unix). When <b>Going</b> is set to Backward, the -- directories are searched in reverse order. -- ------------------------------ procedure Iterate_Path (Path : in String; Process : not null access procedure (Dir : in String; Done : out Boolean); Going : in Direction := Ada.Strings.Forward) is begin Util.Strings.Tokenizers.Iterate_Tokens (Content => Path, Pattern => ";", Process => Process, Going => Going); end Iterate_Path; -- ------------------------------ -- Find the file in one of the search directories. Each search directory -- is separated by ';' (yes, even on Unix). -- Returns the path to be used for reading the file. -- ------------------------------ function Find_File_Path (Name : String; Paths : String) return String is use Ada.Strings.Fixed; Sep_Pos : Natural; Pos : Positive := Paths'First; Last : constant Natural := Paths'Last; begin while Pos <= Last loop Sep_Pos := Index (Paths, ";", Pos); if Sep_Pos = 0 then Sep_Pos := Last; else Sep_Pos := Sep_Pos - 1; end if; declare use Ada.Directories; Path : constant String := Util.Files.Compose (Paths (Pos .. Sep_Pos), Name); begin if Exists (Path) and then Kind (Path) = Ordinary_File then return Path; end if; exception when Name_Error => null; end; Pos := Sep_Pos + 2; end loop; return Name; end Find_File_Path; -- ------------------------------ -- Iterate over the search directories defined in <b>Path</b> and search -- for files matching the pattern defined by <b>Pattern</b>. For each file, -- execute <b>Process</b> with the file basename and the full file path. -- Stop iterating when the <b>Process</b> procedure returns True. -- Each search directory is separated by ';'. When <b>Going</b> is set to Backward, the -- directories are searched in reverse order. -- ------------------------------ procedure Iterate_Files_Path (Pattern : in String; Path : in String; Process : not null access procedure (Name : in String; File : in String; Done : out Boolean); Going : in Direction := Ada.Strings.Forward) is procedure Find_Files (Dir : in String; Done : out Boolean); -- ------------------------------ -- Find the files matching the pattern in <b>Dir</b>. -- ------------------------------ procedure Find_Files (Dir : in String; Done : out Boolean) is use Ada.Directories; Filter : constant Filter_Type := (Ordinary_File => True, others => False); Ent : Directory_Entry_Type; Search : Search_Type; begin Done := False; Start_Search (Search, Directory => Dir, Pattern => Pattern, Filter => Filter); while More_Entries (Search) loop Get_Next_Entry (Search, Ent); declare Name : constant String := Simple_Name (Ent); File_Path : constant String := Full_Name (Ent); begin Process (Name, File_Path, Done); exit when Done; end; end loop; end Find_Files; begin Iterate_Path (Path => Path, Process => Find_Files'Access, Going => Going); end Iterate_Files_Path; -- ------------------------------ -- Find the files which match the pattern in the directories specified in the -- search path <b>Path</b>. Each search directory is separated by ';'. -- File names are added to the string set in <b>Into</b>. -- ------------------------------ procedure Find_Files_Path (Pattern : in String; Path : in String; Into : in out Util.Strings.Maps.Map) is procedure Add_File (Name : in String; File_Path : in String; Done : out Boolean); -- ------------------------------ -- Find the files matching the pattern in <b>Dir</b>. -- ------------------------------ procedure Add_File (Name : in String; File_Path : in String; Done : out Boolean) is begin if not Into.Contains (Name) then Into.Insert (Name, File_Path); end if; Done := False; end Add_File; begin Iterate_Files_Path (Pattern => Pattern, Path => Path, Process => Add_File'Access); end Find_Files_Path; -- ------------------------------ -- Compose an existing path by adding the specified name to each path component -- and return a new paths having only existing directories. Each directory is -- separated by ';'. -- If the composed path exists, it is added to the result path. -- Example: -- paths = 'web;regtests' name = 'info' -- result = 'web/info;regtests/info' -- Returns the composed path. -- ------------------------------ function Compose_Path (Paths : in String; Name : in String) return String is procedure Compose (Dir : in String; Done : out Boolean); Result : Unbounded_String; -- ------------------------------ -- Build the new path by checking if <b>Name</b> exists in <b>Dir</b> -- and appending the new path in the <b>Result</b>. -- ------------------------------ procedure Compose (Dir : in String; Done : out Boolean) is use Ada.Directories; Path : constant String := Util.Files.Compose (Dir, Name); begin Done := False; if Exists (Path) and then Kind (Path) = Directory then if Length (Result) > 0 then Append (Result, ';'); end if; Append (Result, Path); end if; exception when Name_Error => null; end Compose; begin Iterate_Path (Path => Paths, Process => Compose'Access); return To_String (Result); end Compose_Path; -- ------------------------------ -- Returns the name of the external file with the specified directory -- and the name. Unlike the Ada.Directories.Compose, the name can represent -- a relative path and thus include directory separators. -- ------------------------------ function Compose (Directory : in String; Name : in String) return String is begin if Name'Length = 0 then return Directory; elsif Directory'Length = 0 then return Name; elsif Directory = "." or else Directory = "./" then if Name (Name'First) = '/' then return Compose (Directory, Name (Name'First + 1 .. Name'Last)); else return Name; end if; elsif Directory (Directory'Last) = '/' and then Name (Name'First) = '/' then return Directory & Name (Name'First + 1 .. Name'Last); elsif Directory (Directory'Last) = '/' or else Name (Name'First) = '/' then return Directory & Name; else return Directory & "/" & Name; end if; end Compose; -- ------------------------------ -- Returns a relative path whose origin is defined by <b>From</b> and which refers -- to the absolute path referenced by <b>To</b>. Both <b>From</b> and <b>To</b> are -- assumed to be absolute pathes. Returns the absolute path <b>To</b> if the relative -- path could not be found. Both paths must have at least one root component in common. -- ------------------------------ function Get_Relative_Path (From : in String; To : in String) return String is Result : Unbounded_String; Last : Natural := 0; begin for I in From'Range loop if I > To'Last or else From (I) /= To (I) then -- Nothing in common, return the absolute path <b>To</b>. if Last <= From'First + 1 then return To; end if; for J in Last .. From'Last - 1 loop if From (J) = '/' or From (J) = '\' then Append (Result, "../"); end if; end loop; if Last <= To'Last and From (I) /= '/' and From (I) /= '\' then Append (Result, "../"); Append (Result, To (Last .. To'Last)); end if; return To_String (Result); elsif I < From'Last and then (From (I) = '/' or From (I) = '\') then Last := I + 1; end if; end loop; if To'Last = From'Last or (To'Last = From'Last + 1 and (To (To'Last) = '/' or To (To'Last) = '\')) then return "."; elsif Last = 0 then return To; elsif To (From'Last + 1) = '/' or To (From'Last + 1) = '\' then return To (From'Last + 2 .. To'Last); else return To (Last .. To'Last); end if; end Get_Relative_Path; end Util.Files;
reznikmm/matreshka
Ada
7,125
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ -- A protocol transition specifies a legal transition for an operation. -- Transitions of protocol state machines have the following information: a -- pre condition (guard), on trigger, and a post condition. Every protocol -- transition is associated to zero or one operation (referred -- BehavioralFeature) that belongs to the context classifier of the protocol -- state machine. ------------------------------------------------------------------------------ limited with AMF.UML.Constraints; limited with AMF.UML.Operations.Collections; with AMF.UML.Transitions; package AMF.UML.Protocol_Transitions is pragma Preelaborate; type UML_Protocol_Transition is limited interface and AMF.UML.Transitions.UML_Transition; type UML_Protocol_Transition_Access is access all UML_Protocol_Transition'Class; for UML_Protocol_Transition_Access'Storage_Size use 0; not overriding function Get_Post_Condition (Self : not null access constant UML_Protocol_Transition) return AMF.UML.Constraints.UML_Constraint_Access is abstract; -- Getter of ProtocolTransition::postCondition. -- -- Specifies the post condition of the transition which is the condition -- that should be obtained once the transition is triggered. This post -- condition is part of the post condition of the operation connected to -- the transition. not overriding procedure Set_Post_Condition (Self : not null access UML_Protocol_Transition; To : AMF.UML.Constraints.UML_Constraint_Access) is abstract; -- Setter of ProtocolTransition::postCondition. -- -- Specifies the post condition of the transition which is the condition -- that should be obtained once the transition is triggered. This post -- condition is part of the post condition of the operation connected to -- the transition. not overriding function Get_Pre_Condition (Self : not null access constant UML_Protocol_Transition) return AMF.UML.Constraints.UML_Constraint_Access is abstract; -- Getter of ProtocolTransition::preCondition. -- -- Specifies the precondition of the transition. It specifies the -- condition that should be verified before triggering the transition. -- This guard condition added to the source state will be evaluated as -- part of the precondition of the operation referred by the transition if -- any. not overriding procedure Set_Pre_Condition (Self : not null access UML_Protocol_Transition; To : AMF.UML.Constraints.UML_Constraint_Access) is abstract; -- Setter of ProtocolTransition::preCondition. -- -- Specifies the precondition of the transition. It specifies the -- condition that should be verified before triggering the transition. -- This guard condition added to the source state will be evaluated as -- part of the precondition of the operation referred by the transition if -- any. not overriding function Get_Referred (Self : not null access constant UML_Protocol_Transition) return AMF.UML.Operations.Collections.Set_Of_UML_Operation is abstract; -- Getter of ProtocolTransition::referred. -- -- This association refers to the associated operation. It is derived from -- the operation of the call trigger when applicable. not overriding function Referred (Self : not null access constant UML_Protocol_Transition) return AMF.UML.Operations.Collections.Set_Of_UML_Operation is abstract; -- Operation ProtocolTransition::referred. -- -- Missing derivation for ProtocolTransition::/referred : Operation end AMF.UML.Protocol_Transitions;
AdaCore/gpr
Ada
90
adb
with Ada.Text_IO; procedure Print is begin Ada.Text_IO.Put_Line ("print"); end Print;
faelys/natools
Ada
5,380
adb
------------------------------------------------------------------------------ -- Copyright (c) 2015, Natacha Porté -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- ------------------------------------------------------------------------------ with Natools.S_Expressions.Interpreter_Loop; function Natools.S_Expressions.Conditionals.Generic_Evaluate (Context : in Context_Type; Expression : in out Lockable.Descriptor'Class) return Boolean is type State_Type is record Result : Boolean; Conjunction : Boolean; end record; procedure Evaluate_Element (State : in out State_Type; Context : in Context_Type; Name : in Atom); -- Evaluate a name as part of an "and" or "or" operation procedure Evaluate_Element (State : in out State_Type; Context : in Context_Type; Name : in Atom; Arguments : in out Lockable.Descriptor'Class); -- Evaluate a name as part of an "and" or "or" operation function Internal_Evaluate (Context : in Context_Type; Name : in Atom) return Boolean; -- Evaluate a boolean name or a context name function Internal_Evaluate (Context : in Context_Type; Name : in Atom; Arguments : in out Lockable.Descriptor'Class) return Boolean; -- Evaluate a boolean function or a context function procedure Run is new Natools.S_Expressions.Interpreter_Loop (State_Type, Context_Type, Evaluate_Element, Evaluate_Element); ------------------------------ -- Local Helper Subprograms -- ------------------------------ procedure Evaluate_Element (State : in out State_Type; Context : in Context_Type; Name : in Atom) is begin if State.Result = State.Conjunction then State.Result := Internal_Evaluate (Context, Name); end if; end Evaluate_Element; procedure Evaluate_Element (State : in out State_Type; Context : in Context_Type; Name : in Atom; Arguments : in out Lockable.Descriptor'Class) is begin if State.Result = State.Conjunction then State.Result := Internal_Evaluate (Context, Name, Arguments); end if; end Evaluate_Element; function Internal_Evaluate (Context : in Context_Type; Name : in Atom) return Boolean is S_Name : constant String := To_String (Name); begin if S_Name = "true" then return True; elsif S_Name = "false" then return False; else return Simple_Evaluate (Context, Name); end if; end Internal_Evaluate; function Internal_Evaluate (Context : in Context_Type; Name : in Atom; Arguments : in out Lockable.Descriptor'Class) return Boolean is State : State_Type; S_Name : constant String := To_String (Name); begin if S_Name = "and" then State := (True, True); Run (Arguments, State, Context); return State.Result; elsif S_Name = "or" then State := (False, False); Run (Arguments, State, Context); return State.Result; elsif S_Name = "not" then return not Generic_Evaluate (Context, Arguments); else return Parametric_Evaluate (Context, Name, Arguments); end if; end Internal_Evaluate; ------------------- -- Function Body -- ------------------- Event : Events.Event; Lock : Lockable.Lock_State; Result : Boolean; begin case Expression.Current_Event is when Events.Add_Atom => Result := Internal_Evaluate (Context, Expression.Current_Atom); when Events.Open_List => Expression.Lock (Lock); begin Expression.Next (Event); if Event = Events.Add_Atom then declare Name : constant Atom := Expression.Current_Atom; begin Expression.Next (Event); Result := Internal_Evaluate (Context, Name, Expression); end; end if; exception when others => Expression.Unlock (Lock, False); raise; end; Expression.Unlock (Lock); when Events.Close_List | Events.Error | Events.End_Of_Input => raise Constraint_Error with "Conditional on empty expression"; end case; return Result; end Natools.S_Expressions.Conditionals.Generic_Evaluate;
AdaCore/libadalang
Ada
696
adb
package body Foo is procedure Bar is package Pkg_No_Body is I : Integer; end Pkg_No_Body; package Pkg_Body is procedure Process; end Pkg_Body; package body Pkg_Body is procedure Process is begin null; end Process; end Pkg_Body; begin declare package Nested_Pkg is procedure Process; end Nested_Pkg; package body Nested_Pkg is procedure Process is begin null; end Process; end Nested_Pkg; begin Nested_Pkg.Process; end; Pkg_Body.Process; end Bar; end Foo;
adithyap/coursework
Ada
525
ads
package Sort is SIZE : constant Integer := 40; SubType v_range is Integer Range -500..500; type m_array is array(1..SIZE) of v_range; procedure MergeSort(A : in out m_array); -- Internal functions procedure MergeSort(A : in out m_array; startIndex : Integer; endIndex : Integer); procedure ParallelMergeSort(A : in out m_array; startIndex : Integer; midIndex : Integer; endIndex : Integer); procedure Merge(A : in out m_array; startIndex, midIndex, endIndex : in Integer); end sort;
reznikmm/matreshka
Ada
3,759
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Text_Linenumbering_Configuration_Elements is pragma Preelaborate; type ODF_Text_Linenumbering_Configuration is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Text_Linenumbering_Configuration_Access is access all ODF_Text_Linenumbering_Configuration'Class with Storage_Size => 0; end ODF.DOM.Text_Linenumbering_Configuration_Elements;
tum-ei-rcs/StratoX
Ada
2,680
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of STMicroelectronics nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- This file provides utility functions for ARM Cortex microcontrollers package Memory_Barriers is procedure Data_Synchronization_Barrier with Inline; -- Injects instruction "DSB Sy" i.e., a "full system" domain barrier procedure DSB renames Data_Synchronization_Barrier; end Memory_Barriers;
sungyeon/drake
Ada
1,907
ads
pragma License (Unrestricted); -- runtime unit for ZCX (or SjLj, or Win64 SEH) with C.unwind; package System.Unwind.Representation is pragma Preelaborate; subtype Unwind_Exception_Class is C.unwind.Unwind_Exception_Class; -- (a-exexpr-gcc.adb) GNAT_Exception_Class : constant := 16#474e552d41646100#; -- equivalent to GNAT_GCC_Exception (a-excmac-gcc.adb) type Machine_Occurrence is record Header : aliased C.unwind.struct_Unwind_Exception; Occurrence : aliased Exception_Occurrence; Stack_Guard : Address; -- for skipping on stack overflow -- shortcut for phase2 (see exception.c in libobjc) landing_pad : C.unwind.Unwind_Ptr; ttype_filter : C.unwind.Unwind_Sword; end record with Convention => C; pragma Suppress_Initialization (Machine_Occurrence); type Machine_Occurrence_Access is access all Machine_Occurrence; for Machine_Occurrence_Access'Storage_Size use 0; -- by -fdump-tree-all, try ... exception be expanded below: -- try -- { -- ... user code ... -- } -- catch -- { -- ... .builtin_eh_filter ... -- catch (&exception_name ex. program_error) -- { -- { -- void * EXPTR = .builtin_eh_pointer (0); -- try -- { -- void * EXPTR = .builtin_eh_pointer (0); -- .gnat_begin_handler (EXPTR); -- -- system.soft_links.abort_undefer (); -- -- [gcc-4.7] abort_undefer is not called if zcx -- ... user code ... -- } -- finally -- { -- .gnat_end_handler (EXPTR); -- ... builtin_unwind_resume ... -- } -- } -- } -- ... builtin_unwind_resume ... -- } end System.Unwind.Representation;
foundations/netgear-r6800
Ada
15,828
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.1.1.1 2009-05-05 05:06:59 gavin_zhang 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, becouse 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;
peterfrankjohnson/kernel
Ada
53
ads
package Midnite is procedure kstart; end Midnite;
reznikmm/matreshka
Ada
6,820
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_Text.Deletion_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_Deletion_Element_Node is begin return Self : Text_Deletion_Element_Node do Matreshka.ODF_Text.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Text_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Text_Deletion_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_Text_Deletion (ODF.DOM.Text_Deletion_Elements.ODF_Text_Deletion_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 Text_Deletion_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Deletion_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Text_Deletion_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_Text_Deletion (ODF.DOM.Text_Deletion_Elements.ODF_Text_Deletion_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 Text_Deletion_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_Text_Deletion (Visitor, ODF.DOM.Text_Deletion_Elements.ODF_Text_Deletion_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.Text_URI, Matreshka.ODF_String_Constants.Deletion_Element, Text_Deletion_Element_Node'Tag); end Matreshka.ODF_Text.Deletion_Elements;
stcarrez/ada-el
Ada
3,989
ads
----------------------------------------------------------------------- -- el-contexts -- Contexts for evaluating an expression -- Copyright (C) 2009, 2010, 2011, 2012, 2018, 2021 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. ----------------------------------------------------------------------- -- The expression context provides information to resolve runtime -- information when evaluating an expression. The context provides -- a resolver whose role is to find variables given their name. with EL.Objects; with Util.Beans.Basic; with Ada.Strings.Unbounded; with Ada.Exceptions; with EL.Functions; limited with EL.Variables; package EL.Contexts is pragma Preelaborate; use Ada.Strings.Unbounded; type ELContext is limited interface; -- ------------------------------ -- Expression Resolver -- ------------------------------ -- Enables customization of variable and property resolution -- behavior for EL expression evaluation. type ELResolver is limited interface; type ELResolver_Access is access all ELResolver'Class; -- Get the value associated with a base object and a given property. function Get_Value (Resolver : ELResolver; Context : ELContext'Class; Base : access Util.Beans.Basic.Readonly_Bean'Class; Name : Unbounded_String) return EL.Objects.Object is abstract; -- Set the value associated with a base object and a given property. procedure Set_Value (Resolver : in out ELResolver; Context : in ELContext'Class; Base : access Util.Beans.Basic.Bean'Class; Name : in Unbounded_String; Value : in EL.Objects.Object) is abstract; -- ------------------------------ -- Expression Context -- ------------------------------ -- Context information for expression evaluation. type ELContext_Access is access all ELContext'Class; -- Retrieves the ELResolver associated with this ELcontext. function Get_Resolver (Context : ELContext) return ELResolver_Access is abstract; -- Retrieves the VariableMapper associated with this ELContext. function Get_Variable_Mapper (Context : ELContext) return access EL.Variables.Variable_Mapper'Class is abstract; -- Set the variable mapper associated with this ELContext. procedure Set_Variable_Mapper (Context : in out ELContext; Mapper : access EL.Variables.Variable_Mapper'Class) is abstract; -- Retrieves the FunctionMapper associated with this ELContext. -- The FunctionMapper is only used when parsing an expression. function Get_Function_Mapper (Context : ELContext) return EL.Functions.Function_Mapper_Access is abstract; -- Set the function mapper associated with this ELContext. procedure Set_Function_Mapper (Context : in out ELContext; Mapper : access EL.Functions.Function_Mapper'Class) is abstract; -- Handle the exception during expression evaluation. The handler can ignore the -- exception or raise it. procedure Handle_Exception (Context : in ELContext; Ex : in Ada.Exceptions.Exception_Occurrence) is abstract; end EL.Contexts;
reznikmm/matreshka
Ada
6,862
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_Office.Settings_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Office_Settings_Element_Node is begin return Self : Office_Settings_Element_Node do Matreshka.ODF_Office.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Office_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Office_Settings_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_Office_Settings (ODF.DOM.Office_Settings_Elements.ODF_Office_Settings_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 Office_Settings_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Settings_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Office_Settings_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_Office_Settings (ODF.DOM.Office_Settings_Elements.ODF_Office_Settings_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 Office_Settings_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_Office_Settings (Visitor, ODF.DOM.Office_Settings_Elements.ODF_Office_Settings_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.Office_URI, Matreshka.ODF_String_Constants.Settings_Element, Office_Settings_Element_Node'Tag); end Matreshka.ODF_Office.Settings_Elements;
persan/A-gst
Ada
9,689
ads
pragma Ada_2005; pragma Style_Checks (Off); pragma Warnings (Off); with Interfaces.C; use Interfaces.C; with glib; with glib; with glib.Values; with System; with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbin_h; with GStreamer.GST_Low_Level.gstreamer_0_10_gst_basecamerabinsrc_gstcamerabin_enum_h; -- limited -- with GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h; limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h; limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h; limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_basecamerabinsrc_gstcamerabinpreview_h; limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h; package GStreamer.GST_Low_Level.gstreamer_0_10_gst_basecamerabinsrc_gstbasecamerasrc_h is -- unsupported macro: GST_TYPE_BASE_CAMERA_SRC (gst_base_camera_src_get_type()) -- arg-macro: function GST_BASE_CAMERA_SRC (obj) -- return G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_CAMERA_SRC,GstBaseCameraSrc); -- arg-macro: function GST_BASE_CAMERA_SRC_GET_CLASS (obj) -- return G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_BASE_CAMERA_SRC, GstBaseCameraSrcClass); -- arg-macro: function GST_BASE_CAMERA_SRC_CLASS (klass) -- return G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_CAMERA_SRC,GstBaseCameraSrcClass); -- arg-macro: function GST_IS_BASE_CAMERA_SRC (obj) -- return G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_CAMERA_SRC); -- arg-macro: function GST_IS_BASE_CAMERA_SRC_CLASS (klass) -- return G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_CAMERA_SRC); -- arg-macro: function GST_BASE_CAMERA_SRC_CAST (obj) -- return (GstBaseCameraSrc *) (obj); GST_BASE_CAMERA_SRC_VIEWFINDER_PAD_NAME : aliased constant String := "vfsrc" & ASCII.NUL; -- gst/basecamerabinsrc/gstbasecamerasrc.h:56 GST_BASE_CAMERA_SRC_IMAGE_PAD_NAME : aliased constant String := "imgsrc" & ASCII.NUL; -- gst/basecamerabinsrc/gstbasecamerasrc.h:57 GST_BASE_CAMERA_SRC_VIDEO_PAD_NAME : aliased constant String := "vidsrc" & ASCII.NUL; -- gst/basecamerabinsrc/gstbasecamerasrc.h:58 GST_BASE_CAMERA_SRC_PREVIEW_MESSAGE_NAME : aliased constant String := "preview-image" & ASCII.NUL; -- gst/basecamerabinsrc/gstbasecamerasrc.h:60 MIN_ZOOM : constant := 1.0; -- gst/basecamerabinsrc/gstbasecamerasrc.h:129 MAX_ZOOM : constant := 10.0; -- gst/basecamerabinsrc/gstbasecamerasrc.h:130 -- unsupported macro: ZOOM_1X MIN_ZOOM -- * GStreamer -- * Copyright (C) 2010 Texas Instruments, Inc -- * Copyright (C) 2011 Thiago Santos <[email protected]> -- * -- * This library is free software; you can redistribute it and/or -- * modify it under the terms of the GNU Library General Public -- * License as published by the Free Software Foundation; either -- * version 2 of the License, or (at your option) any later version. -- * -- * This library is distributed in the hope that it will be useful, -- * but WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * Library General Public License for more details. -- * -- * You should have received a copy of the GNU Library General Public -- * License along with this library; if not, write to the -- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- * Boston, MA 02111-1307, USA. -- function gst_base_camera_src_get_type return GLIB.GType; -- gst/basecamerabinsrc/gstbasecamerasrc.h:51 pragma Import (C, gst_base_camera_src_get_type, "gst_base_camera_src_get_type"); type GstBaseCameraSrc; type u_GstBaseCameraSrc_u_gst_reserved_array is array (0 .. 19) of System.Address; --subtype GstBaseCameraSrc is u_GstBaseCameraSrc; -- gst/basecamerabinsrc/gstbasecamerasrc.h:53 type GstBaseCameraSrcClass; type u_GstBaseCameraSrcClass_u_gst_reserved_array is array (0 .. 19) of System.Address; --subtype GstBaseCameraSrcClass is u_GstBaseCameraSrcClass; -- gst/basecamerabinsrc/gstbasecamerasrc.h:54 --* -- * GstBaseCameraSrc: -- type GstBaseCameraSrc is record parent : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbin_h.GstBin; -- gst/basecamerabinsrc/gstbasecamerasrc.h:67 mode : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_basecamerabinsrc_gstcamerabin_enum_h.GstCameraBinMode; -- gst/basecamerabinsrc/gstbasecamerasrc.h:69 capturing : aliased GLIB.gboolean; -- gst/basecamerabinsrc/gstbasecamerasrc.h:71 capturing_mutex : access GStreamer.GST_Low_Level.glib_2_0_glib_gthread_h.GMutex; -- gst/basecamerabinsrc/gstbasecamerasrc.h:72 preview_caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps; -- gst/basecamerabinsrc/gstbasecamerasrc.h:75 post_preview : aliased GLIB.gboolean; -- gst/basecamerabinsrc/gstbasecamerasrc.h:76 preview_filter : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstelement_h.GstElement; -- gst/basecamerabinsrc/gstbasecamerasrc.h:77 preview_pipeline : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_basecamerabinsrc_gstcamerabinpreview_h.GstCameraBinPreviewPipelineData; -- gst/basecamerabinsrc/gstbasecamerasrc.h:78 width : aliased GLIB.gint; -- gst/basecamerabinsrc/gstbasecamerasrc.h:81 height : aliased GLIB.gint; -- gst/basecamerabinsrc/gstbasecamerasrc.h:82 zoom : aliased GLIB.gfloat; -- gst/basecamerabinsrc/gstbasecamerasrc.h:84 max_zoom : aliased GLIB.gfloat; -- gst/basecamerabinsrc/gstbasecamerasrc.h:85 u_gst_reserved : u_GstBaseCameraSrc_u_gst_reserved_array; -- gst/basecamerabinsrc/gstbasecamerasrc.h:87 end record; pragma Convention (C_Pass_By_Copy, GstBaseCameraSrc); -- gst/basecamerabinsrc/gstbasecamerasrc.h:65 -- Preview convert pipeline -- Resolution of the buffers configured to camerabin --* -- * GstBaseCameraSrcClass: -- * @construct_pipeline: construct pipeline -- * @setup_pipeline: configure pipeline for the chosen settings -- * @set_zoom: set the zoom -- * @set_mode: set the mode -- type GstBaseCameraSrcClass is record parent : aliased GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbin_h.GstBinClass; -- gst/basecamerabinsrc/gstbasecamerasrc.h:100 construct_pipeline : access function (arg1 : access GstBaseCameraSrc) return GLIB.gboolean; -- gst/basecamerabinsrc/gstbasecamerasrc.h:103 setup_pipeline : access function (arg1 : access GstBaseCameraSrc) return GLIB.gboolean; -- gst/basecamerabinsrc/gstbasecamerasrc.h:106 set_zoom : access procedure (arg1 : access GstBaseCameraSrc; arg2 : GLIB.gfloat); -- gst/basecamerabinsrc/gstbasecamerasrc.h:109 set_mode : access function (arg1 : access GstBaseCameraSrc; arg2 : GStreamer.GST_Low_Level.gstreamer_0_10_gst_basecamerabinsrc_gstcamerabin_enum_h.GstCameraBinMode) return GLIB.gboolean; -- gst/basecamerabinsrc/gstbasecamerasrc.h:113 set_preview : access function (arg1 : access GstBaseCameraSrc; arg2 : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps) return GLIB.gboolean; -- gst/basecamerabinsrc/gstbasecamerasrc.h:117 start_capture : access function (arg1 : access GstBaseCameraSrc) return GLIB.gboolean; -- gst/basecamerabinsrc/gstbasecamerasrc.h:120 stop_capture : access procedure (arg1 : access GstBaseCameraSrc); -- gst/basecamerabinsrc/gstbasecamerasrc.h:123 u_gst_reserved : u_GstBaseCameraSrcClass_u_gst_reserved_array; -- gst/basecamerabinsrc/gstbasecamerasrc.h:125 end record; pragma Convention (C_Pass_By_Copy, GstBaseCameraSrcClass); -- gst/basecamerabinsrc/gstbasecamerasrc.h:98 -- Construct pipeline. (called in GST_STATE_CHANGE_NULL_TO_READY) Optional. -- (called in GST_STATE_CHANGE_READY_TO_PAUSED). Optional. -- Set the zoom. If set, called when changing 'zoom' property. Optional. -- Set the mode. If set, called when changing 'mode' property. Optional. -- Set preview caps. If set, called called when setting new 'preview-caps'. Optional. -- Called by the handler for 'start-capture'. Mandatory. -- Called by the handler for 'stop-capture'. Mandatory. function gst_base_camera_src_set_mode (self : access GstBaseCameraSrc; mode : GStreamer.GST_Low_Level.gstreamer_0_10_gst_basecamerabinsrc_gstcamerabin_enum_h.GstCameraBinMode) return GLIB.gboolean; -- gst/basecamerabinsrc/gstbasecamerasrc.h:133 pragma Import (C, gst_base_camera_src_set_mode, "gst_base_camera_src_set_mode"); procedure gst_base_camera_src_setup_zoom (self : access GstBaseCameraSrc); -- gst/basecamerabinsrc/gstbasecamerasrc.h:134 pragma Import (C, gst_base_camera_src_setup_zoom, "gst_base_camera_src_setup_zoom"); procedure gst_base_camera_src_setup_preview (self : access GstBaseCameraSrc; preview_caps : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstcaps_h.GstCaps); -- gst/basecamerabinsrc/gstbasecamerasrc.h:135 pragma Import (C, gst_base_camera_src_setup_preview, "gst_base_camera_src_setup_preview"); procedure gst_base_camera_src_finish_capture (self : access GstBaseCameraSrc); -- gst/basecamerabinsrc/gstbasecamerasrc.h:136 pragma Import (C, gst_base_camera_src_finish_capture, "gst_base_camera_src_finish_capture"); procedure gst_base_camera_src_post_preview (self : access GstBaseCameraSrc; buf : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer); -- gst/basecamerabinsrc/gstbasecamerasrc.h:139 pragma Import (C, gst_base_camera_src_post_preview, "gst_base_camera_src_post_preview"); -- XXX add methods to get/set img capture and vid capture caps.. end GStreamer.GST_Low_Level.gstreamer_0_10_gst_basecamerabinsrc_gstbasecamerasrc_h;
reznikmm/matreshka
Ada
6,841
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Table.Last_Row_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Table_Last_Row_Element_Node is begin return Self : Table_Last_Row_Element_Node do Matreshka.ODF_Table.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Table_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Table_Last_Row_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Enter_Table_Last_Row (ODF.DOM.Table_Last_Row_Elements.ODF_Table_Last_Row_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Enter_Node (Visitor, Control); end if; end Enter_Node; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Table_Last_Row_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Last_Row_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Table_Last_Row_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Leave_Table_Last_Row (ODF.DOM.Table_Last_Row_Elements.ODF_Table_Last_Row_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Leave_Node (Visitor, Control); end if; end Leave_Node; ---------------- -- Visit_Node -- ---------------- overriding procedure Visit_Node (Self : not null access Table_Last_Row_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then ODF.DOM.Iterators.Abstract_ODF_Iterator'Class (Iterator).Visit_Table_Last_Row (Visitor, ODF.DOM.Table_Last_Row_Elements.ODF_Table_Last_Row_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Visit_Node (Iterator, Visitor, Control); end if; end Visit_Node; begin Matreshka.DOM_Documents.Register_Element (Matreshka.ODF_String_Constants.Table_URI, Matreshka.ODF_String_Constants.Last_Row_Element, Table_Last_Row_Element_Node'Tag); end Matreshka.ODF_Table.Last_Row_Elements;
stcarrez/dynamo
Ada
1,734
ads
-- part of AdaYaml, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "copying.txt" package Yaml.Tags is Question_Mark : constant Text.Reference; -- "?" Exclamation_Mark : constant Text.Reference; -- "!" Mapping : constant Text.Reference; -- "!!map" Sequence : constant Text.Reference; -- "!!seq" String : constant Text.Reference; -- "!!str" Boolean : constant Text.Reference; -- "!!bool" Null_Tag : constant Text.Reference; -- "!!null" private Question_Mark_Holder : constant Text.Constant_Instance := Text.Hold ("?"); Exclamation_Mark_Holder : constant Text.Constant_Instance := Text.Hold ("!"); Mapping_Holder : constant Text.Constant_Instance := Text.Hold ("tag:yaml.org,2002:map"); Sequence_Holder : constant Text.Constant_Instance := Text.Hold ("tag:yaml.org,2002:seq"); String_Holder : constant Text.Constant_Instance := Text.Hold ("tag:yaml.org,2002:str"); Boolean_Holder : constant Text.Constant_Instance := Text.Hold ("tag:yaml.org,2002:bool"); Null_Holder : constant Text.Constant_Instance := Text.Hold ("tag:yaml.org,2002:null"); Question_Mark : constant Text.Reference := Text.Held (Question_Mark_Holder); Exclamation_Mark : constant Text.Reference := Text.Held (Exclamation_Mark_Holder); Mapping : constant Text.Reference := Text.Held (Mapping_Holder); Sequence : constant Text.Reference := Text.Held (Sequence_Holder); String : constant Text.Reference := Text.Held (String_Holder); Boolean : constant Text.Reference := Text.Held (Boolean_Holder); Null_Tag : constant Text.Reference := Text.Held (Null_Holder); end Yaml.Tags;
stcarrez/dynamo
Ada
1,496
ads
----------------------------------------------------------------------- -- gen -- Code Generator -- Copyright (C) 2009, 2010, 2011, 2021 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; package Gen is subtype UString is Ada.Strings.Unbounded.Unbounded_String; function To_UString (Value : in String) return UString renames Ada.Strings.Unbounded.To_Unbounded_String; function To_String (Value : in UString) return String renames Ada.Strings.Unbounded.To_String; function Length (Value : in UString) return Natural renames Ada.Strings.Unbounded.Length; function "=" (Left, Right : in UString) return Boolean renames Ada.Strings.Unbounded."="; function "=" (Left : in UString; Right : in String) return Boolean renames Ada.Strings.Unbounded."="; end Gen;
jwarwick/aoc_2020
Ada
5,297
adb
-- AoC 2020, Day 22 with Ada.Text_IO; with Ada.Containers.Vectors; with Ada.Containers.Hashed_Sets; use Ada.Containers; with Ada.Strings.Hash; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; package body Day is package TIO renames Ada.Text_IO; package Deck_Vectors is new Ada.Containers.Vectors (Index_Type => Natural, Element_Type => Natural); use Deck_Vectors; type State is record player1 : Deck_Vectors.Vector; player2 : Deck_Vectors.Vector; end record; function state_hash(item : in State) return Hash_Type is h : Unbounded_String := Null_Unbounded_String; begin for c of item.player1 loop h := h & c'IMAGE; end loop; h := h & '-'; for c of item.player2 loop h := h & c'IMAGE; end loop; return Ada.Strings.Hash(to_string(h)); end state_hash; package State_Sets is new Ada.Containers.Hashed_Sets (Element_Type => State, Hash => state_hash, Equivalent_Elements => "="); use State_Sets; pragma Warnings (Off, "procedure ""put_line"" is not referenced"); procedure put_line(d : in Deck_Vectors.Vector) is pragma Warnings (On, "procedure ""put_line"" is not referenced"); begin for card of d loop TIO.put(card'IMAGE & ", "); end loop; TIO.new_line; end put_line; procedure load_deck(file : in out TIO.File_Type; p : in out Deck_Vectors.Vector) is begin p.clear; while not TIO.end_of_file(file) loop declare line : constant String := TIO.get_line(file); begin if line'length = 0 then exit; end if; if line(1) /= 'P' then p.append(Natural'Value(line)); end if; end; end loop; end load_deck; procedure load_decks(filename : in String; p1, p2 : in out Deck_Vectors.Vector) is file : TIO.File_Type; begin TIO.open(File => file, Mode => TIO.In_File, Name => filename); load_deck(file, p1); load_deck(file, p2); TIO.close(file); end load_decks; function score(deck : in Deck_Vectors.Vector) return Natural is cnt : Natural := Natural(deck.length); sum : Natural := 0; begin for c of deck loop sum := sum + (c * cnt); cnt := cnt - 1; end loop; return sum; end score; function score(p1, p2 : in Deck_Vectors.Vector) return Natural is begin if p1.length = 0 then return score(p2); else return score(p1); end if; end score; procedure take_cards(winner, loser : in out Deck_Vectors.Vector) is begin winner.append(winner.first_element); winner.append(loser.first_element); winner.delete(winner.first_index); loser.delete(loser.first_index); end take_cards; procedure battle(player1, player2 : in out Deck_Vectors.Vector) is begin while player1.length > 0 and player2.length > 0 loop if player1.first_element > player2.first_element then take_cards(player1, player2); else take_cards(player2, player1); end if; end loop; end battle; function should_recurse(p1, p2 : in Deck_Vectors.Vector) return Boolean is begin return p1.first_element < Natural(p1.length) and p2.first_element < Natural(p2.length); end should_recurse; function reduced(d : in Deck_Vectors.Vector) return Deck_Vectors.Vector is new_d : Deck_Vectors.Vector := Empty_Vector; first : constant Natural := d.first_index + 1; last : constant Natural := d.first_index + d.first_element; begin for idx in first..last loop new_d.append(d(idx)); end loop; return new_d; end reduced; function recursive_battle(player1, player2 : in out Deck_Vectors.Vector) return Boolean is past_states : State_Sets.Set := Empty_Set; begin while player1.length > 0 and player2.length > 0 loop declare s : constant State := State'(player1 => player1, player2 => player2); p1_wins : Boolean; begin if past_states.contains(s) then return true; end if; past_states.insert(s); if should_recurse(player1, player2) then declare new_p1 : Deck_Vectors.Vector := reduced(player1); new_p2 : Deck_Vectors.Vector := reduced(player2); begin p1_wins := recursive_battle(new_p1, new_p2); end; else p1_wins := player1.first_element > player2.first_element; end if; if p1_wins then take_cards(player1, player2); else take_cards(player2, player1); end if; end; end loop; return player1.length > 0; end recursive_battle; function combat(filename : in String) return Natural is player1 : Deck_Vectors.Vector; player2 : Deck_Vectors.Vector; begin load_decks(filename, player1, player2); battle(player1, player2); return score(player1, player2); end combat; function recursive_combat(filename : in String) return Natural is player1 : Deck_Vectors.Vector; player2 : Deck_Vectors.Vector; begin load_decks(filename, player1, player2); if recursive_battle(player1, player2) then TIO.put_line("Player 1 wins"); else TIO.put_line("Player 2 wins"); end if; return score(player1, player2); end recursive_combat; end Day;
AdaCore/libadalang
Ada
44
ads
package Pkg is procedure Dummy; end Pkg;
adamnemecek/GA_Ada
Ada
450
ads
with C3GA; with Multivector; with Multivector_Analyze; use Multivector_Analyze; package Multivector_Analyze_C3GA is procedure Analyze (theAnalysis : in out MV_Analysis; MV : Multivector.Multivector; Probe : C3GA.Normalized_Point; Flags : Flag_Type := (Flag_Invalid, false); Epsilon : float := Default_Epsilon); end Multivector_Analyze_C3GA;
reznikmm/matreshka
Ada
7,831
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. ------------------------------------------------------------------------------ -- The most general class for UML diagram interchange. ------------------------------------------------------------------------------ with AMF.DI.Diagram_Elements; limited with AMF.UML.Elements.Collections; limited with AMF.UMLDI.UML_Diagram_Elements.Collections; limited with AMF.UMLDI.UML_Styles; package AMF.UMLDI.UML_Diagram_Elements is pragma Preelaborate; type UMLDI_UML_Diagram_Element is limited interface and AMF.DI.Diagram_Elements.DI_Diagram_Element; type UMLDI_UML_Diagram_Element_Access is access all UMLDI_UML_Diagram_Element'Class; for UMLDI_UML_Diagram_Element_Access'Storage_Size use 0; not overriding function Get_Is_Icon (Self : not null access constant UMLDI_UML_Diagram_Element) return Boolean is abstract; -- Getter of UMLDiagramElement::isIcon. -- -- For modelElements that have an option to be shown with shapes other -- than rectangles, such as Actors, or with other identifying shapes -- inside them, such as arrows distinguishing InputPins and OutputPins, or -- edges that have an option to be shown with lines other than solid with -- open arrow heads, such as Realization. A value of true for isIcon -- indicates the alternative notation shall be shown. not overriding procedure Set_Is_Icon (Self : not null access UMLDI_UML_Diagram_Element; To : Boolean) is abstract; -- Setter of UMLDiagramElement::isIcon. -- -- For modelElements that have an option to be shown with shapes other -- than rectangles, such as Actors, or with other identifying shapes -- inside them, such as arrows distinguishing InputPins and OutputPins, or -- edges that have an option to be shown with lines other than solid with -- open arrow heads, such as Realization. A value of true for isIcon -- indicates the alternative notation shall be shown. not overriding function Get_Local_Style (Self : not null access constant UMLDI_UML_Diagram_Element) return AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access is abstract; -- Getter of UMLDiagramElement::localStyle. -- -- Restricts owned styles to UMLStyles. not overriding procedure Set_Local_Style (Self : not null access UMLDI_UML_Diagram_Element; To : AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access) is abstract; -- Setter of UMLDiagramElement::localStyle. -- -- Restricts owned styles to UMLStyles. not overriding function Get_Model_Element (Self : not null access constant UMLDI_UML_Diagram_Element) return AMF.UML.Elements.Collections.Set_Of_UML_Element is abstract; -- Getter of UMLDiagramElement::modelElement. -- -- Restricts UMLDiagramElements to show UML Elements, rather than other -- language elements. not overriding function Get_Owned_Element (Self : not null access constant UMLDI_UML_Diagram_Element) return AMF.UMLDI.UML_Diagram_Elements.Collections.Ordered_Set_Of_UMLDI_UML_Diagram_Element is abstract; -- Getter of UMLDiagramElement::ownedElement. -- -- Restricts UMLDiagramElements to own only UMLDiagramElements. not overriding function Get_Owning_Element (Self : not null access constant UMLDI_UML_Diagram_Element) return AMF.UMLDI.UML_Diagram_Elements.UMLDI_UML_Diagram_Element_Access is abstract; -- Getter of UMLDiagramElement::owningElement. -- -- Restricts UMLDiagramElements to be owned by only UMLDiagramElements. not overriding procedure Set_Owning_Element (Self : not null access UMLDI_UML_Diagram_Element; To : AMF.UMLDI.UML_Diagram_Elements.UMLDI_UML_Diagram_Element_Access) is abstract; -- Setter of UMLDiagramElement::owningElement. -- -- Restricts UMLDiagramElements to be owned by only UMLDiagramElements. not overriding function Get_Shared_Style (Self : not null access constant UMLDI_UML_Diagram_Element) return AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access is abstract; -- Getter of UMLDiagramElement::sharedStyle. -- -- Restricts shared styles to UMLStyles. not overriding procedure Set_Shared_Style (Self : not null access UMLDI_UML_Diagram_Element; To : AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access) is abstract; -- Setter of UMLDiagramElement::sharedStyle. -- -- Restricts shared styles to UMLStyles. end AMF.UMLDI.UML_Diagram_Elements;
zhmu/ananas
Ada
201
ads
-- { dg-do compile } package Static_Initializer4 is type R is tagged record b : Boolean; end record; type NR is new R with null record; C : NR := (b => True); end Static_Initializer4;
sungyeon/drake
Ada
265
ads
pragma License (Unrestricted); -- implementation unit specialized for Windows function System.System_Allocators.Allocated_Size ( Storage_Address : Address) return Storage_Elements.Storage_Count; pragma Preelaborate (System.System_Allocators.Allocated_Size);
AdaCore/langkit
Ada
1,013
adb
-- -- Copyright (C) 2014-2022, AdaCore -- SPDX-License-Identifier: Apache-2.0 -- with Ada.Text_IO; use Ada.Text_IO; package body Langkit_Support.Adalog.Debug is Runtime_Debug_State : Debug_State_Type := None; ----------- -- Trace -- ----------- procedure Trace (Str : String) is begin if Debug then Put_Line (Str); end if; end Trace; ----------- -- Debug -- ----------- function Debug return Boolean is begin return Debug_Enabled and then Runtime_Debug_State in Trace .. Step_At_First_Unsat; end Debug; --------------------- -- Set_Debug_State -- --------------------- procedure Set_Debug_State (Val : Debug_State_Type) is begin Runtime_Debug_State := Val; end Set_Debug_State; --------------------- -- Is_Step_Mode_On -- --------------------- function Debug_State return Debug_State_Type is (if Debug_Enabled then Runtime_Debug_State else None); end Langkit_Support.Adalog.Debug;
reznikmm/matreshka
Ada
10,453
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with AMF.Visitors.CMOF_Iterators; with AMF.Visitors.CMOF_Visitors; package body AMF.Internals.CMOF_Element_Imports is ------------------- -- Enter_Element -- ------------------- overriding procedure Enter_Element (Self : not null access constant CMOF_Element_Import_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.CMOF_Visitors.CMOF_Visitor'Class then AMF.Visitors.CMOF_Visitors.CMOF_Visitor'Class (Visitor).Enter_Element_Import (AMF.CMOF.Element_Imports.CMOF_Element_Import_Access (Self), Control); end if; end Enter_Element; ------------------- -- Leave_Element -- ------------------- overriding procedure Leave_Element (Self : not null access constant CMOF_Element_Import_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.CMOF_Visitors.CMOF_Visitor'Class then AMF.Visitors.CMOF_Visitors.CMOF_Visitor'Class (Visitor).Leave_Element_Import (AMF.CMOF.Element_Imports.CMOF_Element_Import_Access (Self), Control); end if; end Leave_Element; ------------------- -- Visit_Element -- ------------------- overriding procedure Visit_Element (Self : not null access constant CMOF_Element_Import_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.CMOF_Iterators.CMOF_Iterator'Class then AMF.Visitors.CMOF_Iterators.CMOF_Iterator'Class (Iterator).Visit_Element_Import (Visitor, AMF.CMOF.Element_Imports.CMOF_Element_Import_Access (Self), Control); end if; end Visit_Element; ------------------------ -- All_Owned_Elements -- ------------------------ overriding function All_Owned_Elements (Self : not null access constant CMOF_Element_Import_Proxy) return AMF.CMOF.Elements.Collections.Set_Of_CMOF_Element is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "All_Owned_Elements unimplemented"); raise Program_Error; return All_Owned_Elements (Self); end All_Owned_Elements; ------------------------- -- Get_Related_Element -- ------------------------- overriding function Get_Related_Element (Self : not null access constant CMOF_Element_Import_Proxy) return AMF.CMOF.Elements.Collections.Set_Of_CMOF_Element is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Get_Related_Element unimplemented"); raise Program_Error; return Get_Related_Element (Self); end Get_Related_Element; -------------------- -- Get_Visibility -- -------------------- overriding function Get_Visibility (Self : not null access constant CMOF_Element_Import_Proxy) return CMOF.CMOF_Visibility_Kind is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Get_Visibility unimplemented"); raise Program_Error; return Get_Visibility (Self); end Get_Visibility; -------------------- -- Set_Visibility -- -------------------- overriding procedure Set_Visibility (Self : not null access CMOF_Element_Import_Proxy; To : CMOF.CMOF_Visibility_Kind) is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Set_Visibility unimplemented"); raise Program_Error; end Set_Visibility; --------------- -- Get_Alias -- --------------- overriding function Get_Alias (Self : not null access constant CMOF_Element_Import_Proxy) return Optional_String is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Get_Alias unimplemented"); raise Program_Error; return Get_Alias (Self); end Get_Alias; --------------- -- Set_Alias -- --------------- overriding procedure Set_Alias (Self : not null access CMOF_Element_Import_Proxy; To : Optional_String) is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Set_Alias unimplemented"); raise Program_Error; end Set_Alias; -------------------------- -- Get_Imported_Element -- -------------------------- overriding function Get_Imported_Element (Self : not null access constant CMOF_Element_Import_Proxy) return AMF.CMOF.Packageable_Elements.CMOF_Packageable_Element_Access is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Get_Imported_Element unimplemented"); raise Program_Error; return Get_Imported_Element (Self); end Get_Imported_Element; -------------------------- -- Set_Imported_Element -- -------------------------- overriding procedure Set_Imported_Element (Self : not null access CMOF_Element_Import_Proxy; To : AMF.CMOF.Packageable_Elements.CMOF_Packageable_Element_Access) is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Set_Imported_Element unimplemented"); raise Program_Error; end Set_Imported_Element; ----------------------------- -- Get_Importing_Namespace -- ----------------------------- overriding function Get_Importing_Namespace (Self : not null access constant CMOF_Element_Import_Proxy) return AMF.CMOF.Namespaces.CMOF_Namespace_Access is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Get_Importing_Namespace unimplemented"); raise Program_Error; return Get_Importing_Namespace (Self); end Get_Importing_Namespace; ----------------------------- -- Set_Importing_Namespace -- ----------------------------- overriding procedure Set_Importing_Namespace (Self : not null access CMOF_Element_Import_Proxy; To : AMF.CMOF.Namespaces.CMOF_Namespace_Access) is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Set_Importing_Namespace unimplemented"); raise Program_Error; end Set_Importing_Namespace; -------------- -- Get_Name -- -------------- overriding function Get_Name (Self : not null access constant CMOF_Element_Import_Proxy) return League.Strings.Universal_String is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Get_Name unimplemented"); raise Program_Error; return Get_Name (Self); end Get_Name; end AMF.Internals.CMOF_Element_Imports;
damaki/libkeccak
Ada
7,165
adb
------------------------------------------------------------------------------- -- 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 Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Text_IO; with Ada.Unchecked_Deallocation; with Interfaces; use Interfaces; with Keccak.Types; with Test_Vectors; use Test_Vectors; package body KMAC_Runner is procedure Free is new Ada.Unchecked_Deallocation (Object => Keccak.Types.Byte_Array, Name => Byte_Array_Access); procedure Run_Tests (File_Name : in String; XOF : in Boolean; Num_Passed : out Natural; Num_Failed : out Natural) is use type Keccak.Types.Byte_Array; package Integer_IO is new Ada.Text_IO.Integer_IO (Integer); S_Key : constant Unbounded_String := To_Unbounded_String ("S"); InLen_Key : constant Unbounded_String := To_Unbounded_String ("InLen"); In_Key : constant Unbounded_String := To_Unbounded_String ("In"); KeyLen_Key : constant Unbounded_String := To_Unbounded_String ("KeyLen"); Key_Key : constant Unbounded_String := To_Unbounded_String ("Key"); OutLen_Key : constant Unbounded_String := To_Unbounded_String ("OutLen"); Out_Key : constant Unbounded_String := To_Unbounded_String ("Out"); Schema : Test_Vectors.Schema_Maps.Map; Tests : Test_Vectors.Lists.List; Ctx : KMAC.Context; Output : Byte_Array_Access; OutLen : Natural; begin Num_Passed := 0; Num_Failed := 0; -- Setup schema Schema.Insert (Key => S_Key, New_Item => Schema_Entry'(VType => String_Type, Required => True, Is_List => False)); Schema.Insert (Key => KeyLen_Key, New_Item => Schema_Entry'(VType => Integer_Type, Required => True, Is_List => False)); Schema.Insert (Key => Key_Key, New_Item => Schema_Entry'(VType => Hex_Array_Type, Required => True, Is_List => False)); Schema.Insert (Key => InLen_Key, New_Item => Schema_Entry'(VType => Integer_Type, Required => True, Is_List => False)); Schema.Insert (Key => In_Key, New_Item => Schema_Entry'(VType => Hex_Array_Type, Required => True, Is_List => False)); Schema.Insert (Key => OutLen_Key, New_Item => Schema_Entry'(VType => Integer_Type, Required => True, Is_List => False)); Schema.Insert (Key => Out_Key, New_Item => Schema_Entry'(VType => Hex_Array_Type, Required => True, Is_List => False)); -- Load the test file using the file name given on the command line Ada.Text_IO.Put_Line ("Loading file: " & File_Name); Test_Vectors.Load (File_Name => File_Name, Schema => Schema, Vectors_List => Tests); Ada.Text_IO.Put ("Running "); Integer_IO.Put (Integer (Tests.Length), Width => 0); Ada.Text_IO.Put_Line (" tests ..."); -- Run each test. for C of Tests loop KMAC.Init (Ctx => Ctx, Key => C.Element (Key_Key).First_Element.Hex.all, Customization => To_String (C.Element (S_Key).First_Element.Str)); KMAC.Update (Ctx => Ctx, Message => C.Element (In_Key).First_Element.Hex.all); Output := new Keccak.Types.Byte_Array (C.Element (Out_Key).First_Element.Hex.all'Range); if XOF then KMAC.Extract (Ctx, Output.all); else KMAC.Finish (Ctx, Output.all); end if; -- Mask any unused bits from the output. OutLen := C.Element (OutLen_Key).First_Element.Int; if OutLen mod 8 /= 0 then Output.all (Output.all'Last) := Output.all (Output.all'Last) and Keccak.Types.Byte ((2**(OutLen mod 8)) - 1); end if; -- Check output if Output.all = C.Element (Out_Key).First_Element.Hex.all then Num_Passed := Num_Passed + 1; else Num_Failed := Num_Failed + 1; -- Display a message on failure to help with debugging. Ada.Text_IO.Put ("FAILURE (Input bit-len: "); Integer_IO.Put (C.Element (InLen_Key).First_Element.Int, Width => 0); Ada.Text_IO.Put_Line (")"); Ada.Text_IO.Put (" Expected MD: "); Ada.Text_IO.Put (Byte_Array_To_String (C.Element (Out_Key).First_Element.Hex.all)); Ada.Text_IO.New_Line; Ada.Text_IO.Put (" Actual MD: "); Ada.Text_IO.Put (Byte_Array_To_String (Output.all)); Ada.Text_IO.New_Line; end if; Free (Output); end loop; end Run_Tests; end KMAC_Runner;
reznikmm/matreshka
Ada
7,000
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_Text.User_Index_Source_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_User_Index_Source_Element_Node is begin return Self : Text_User_Index_Source_Element_Node do Matreshka.ODF_Text.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Text_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Text_User_Index_Source_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_Text_User_Index_Source (ODF.DOM.Text_User_Index_Source_Elements.ODF_Text_User_Index_Source_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 Text_User_Index_Source_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.User_Index_Source_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Text_User_Index_Source_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_Text_User_Index_Source (ODF.DOM.Text_User_Index_Source_Elements.ODF_Text_User_Index_Source_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 Text_User_Index_Source_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_Text_User_Index_Source (Visitor, ODF.DOM.Text_User_Index_Source_Elements.ODF_Text_User_Index_Source_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.Text_URI, Matreshka.ODF_String_Constants.User_Index_Source_Element, Text_User_Index_Source_Element_Node'Tag); end Matreshka.ODF_Text.User_Index_Source_Elements;
stcarrez/ada-el
Ada
12,331
ads
----------------------------------------------------------------------- -- el-expressions-nodes -- Expression Nodes -- Copyright (C) 2009, 2010, 2011, 2012, 2013, 2020, 2021 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. ----------------------------------------------------------------------- -- The 'ELNode' describes an expression that can later be evaluated -- on an expression context. Expressions are parsed and translated -- to a read-only tree. with EL.Functions; with Ada.Strings.Wide_Wide_Unbounded; private with Ada.Strings.Unbounded; with Util.Concurrent.Counters; private package EL.Expressions.Nodes is pragma Preelaborate; use EL.Functions; use Ada.Strings.Wide_Wide_Unbounded; use Ada.Strings.Unbounded; type Reduction; type ELNode is abstract tagged limited record Ref_Counter : Util.Concurrent.Counters.Counter; end record; type ELNode_Access is access all ELNode'Class; type Reduction is record Node : ELNode_Access; Value : EL.Objects.Object; end record; -- Evaluate a node on a given context. If function Get_Safe_Value (Expr : in ELNode; Context : in ELContext'Class) return Object; -- Evaluate a node on a given context. function Get_Value (Expr : in ELNode; Context : in ELContext'Class) return Object is abstract; -- Reduce the expression by eliminating variables which are known -- and computing constant expressions. Returns either a new expression -- tree or a constant value. function Reduce (Expr : access ELNode; Context : in ELContext'Class) return Reduction is abstract; -- Delete the expression tree (calls Delete (ELNode_Access) recursively). procedure Delete (Node : in out ELNode) is abstract; -- Delete the expression tree. Free the memory allocated by nodes -- of the expression tree. Clears the node pointer. procedure Delete (Node : in out ELNode_Access); -- ------------------------------ -- Unary expression node -- ------------------------------ type ELUnary is new ELNode with private; type Unary_Node is (EL_VOID, EL_NOT, EL_MINUS, EL_EMPTY); -- Evaluate a node on a given context. overriding function Get_Value (Expr : ELUnary; Context : ELContext'Class) return Object; -- Reduce the expression by eliminating variables which are known -- and computing constant expressions. Returns either a new expression -- tree or a constant value. overriding function Reduce (Expr : access ELUnary; Context : in ELContext'Class) return Reduction; overriding procedure Delete (Node : in out ELUnary); -- ------------------------------ -- Binary expression node -- ------------------------------ type ELBinary is new ELNode with private; type Binary_Node is (EL_EQ, EL_NE, EL_LE, EL_LT, EL_GE, EL_GT, EL_ADD, EL_SUB, EL_MUL, EL_DIV, EL_MOD, EL_AND, EL_OR, EL_LAND, EL_LOR, EL_CONCAT); -- Evaluate a node on a given context. overriding function Get_Value (Expr : ELBinary; Context : ELContext'Class) return Object; -- Reduce the expression by eliminating variables which are known -- and computing constant expressions. Returns either a new expression -- tree or a constant value. overriding function Reduce (Expr : access ELBinary; Context : in ELContext'Class) return Reduction; overriding procedure Delete (Node : in out ELBinary); -- ------------------------------ -- Ternary expression node -- ------------------------------ type ELTernary is new ELNode with private; -- Evaluate a node on a given context. overriding function Get_Value (Expr : ELTernary; Context : ELContext'Class) return Object; -- Reduce the expression by eliminating variables which are known -- and computing constant expressions. Returns either a new expression -- tree or a constant value. overriding function Reduce (Expr : access ELTernary; Context : in ELContext'Class) return Reduction; overriding procedure Delete (Node : in out ELTernary); -- ------------------------------ -- Variable to be looked at in the expression context -- ------------------------------ type ELVariable is new ELNode with private; -- Evaluate a node on a given context. overriding function Get_Value (Expr : ELVariable; Context : ELContext'Class) return Object; -- Reduce the expression by eliminating variables which are known -- and computing constant expressions. Returns either a new expression -- tree or a constant value. overriding function Reduce (Expr : access ELVariable; Context : in ELContext'Class) return Reduction; overriding procedure Delete (Node : in out ELVariable); -- ------------------------------ -- Value property referring to a variable -- ------------------------------ type ELValue (Len : Natural) is new ELNode with private; type ELValue_Access is access all ELValue'Class; -- Check if the target bean is a readonly bean. function Is_Readonly (Node : in ELValue; Context : in ELContext'Class) return Boolean; -- Get the variable name. function Get_Variable_Name (Node : in ELValue) return String; -- Evaluate the node and return a method info with -- the bean object and the method binding. function Get_Method_Info (Node : in ELValue; Context : in ELContext'Class) return Method_Info; -- Evaluate a node on a given context. overriding function Get_Value (Expr : ELValue; Context : ELContext'Class) return Object; -- Evaluate the node and set the value on the associated bean. -- Raises Invalid_Variable if the target object is not a bean. -- Raises Invalid_Expression if the target bean is not writable. procedure Set_Value (Node : in ELValue; Context : in ELContext'Class; Value : in Objects.Object); -- Reduce the expression by eliminating variables which are known -- and computing constant expressions. Returns either a new expression -- tree or a constant value. overriding function Reduce (Expr : access ELValue; Context : in ELContext'Class) return Reduction; overriding procedure Delete (Node : in out ELValue); -- ------------------------------ -- Literal object (integer, boolean, float, string) -- ------------------------------ type ELObject is new ELNode with private; -- Evaluate a node on a given context. overriding function Get_Value (Expr : ELObject; Context : ELContext'Class) return Object; -- Reduce the expression by eliminating variables which are known -- and computing constant expressions. Returns either a new expression -- tree or a constant value. overriding function Reduce (Expr : access ELObject; Context : in ELContext'Class) return Reduction; overriding procedure Delete (Node : in out ELObject); -- ------------------------------ -- Function call with up to 4 arguments -- ------------------------------ type ELFunction is new ELNode with private; -- Evaluate a node on a given context. overriding function Get_Value (Expr : ELFunction; Context : ELContext'Class) return Object; -- Reduce the expression by eliminating variables which are known -- and computing constant expressions. Returns either a new expression -- tree or a constant value. overriding function Reduce (Expr : access ELFunction; Context : in ELContext'Class) return Reduction; overriding procedure Delete (Node : in out ELFunction); -- Create constant nodes function Create_Node (Value : Boolean) return ELNode_Access; function Create_Node (Value : Long_Long_Integer) return ELNode_Access; function Create_Node (Value : String) return ELNode_Access; function Create_Node (Value : Wide_Wide_String) return ELNode_Access; function Create_Node (Value : Long_Float) return ELNode_Access; function Create_Node (Value : Unbounded_Wide_Wide_String) return ELNode_Access; function Create_Variable (Name : in Wide_Wide_String) return ELNode_Access; function Create_Value (Variable : in ELNode_Access; Name : in Wide_Wide_String) return ELNode_Access; -- Create unary expressions function Create_Node (Of_Type : Unary_Node; Expr : ELNode_Access) return ELNode_Access; -- Create binary expressions function Create_Node (Of_Type : Binary_Node; Left : ELNode_Access; Right : ELNode_Access) return ELNode_Access; -- Create a ternary expression. function Create_Node (Cond : ELNode_Access; Left : ELNode_Access; Right : ELNode_Access) return ELNode_Access; -- Create a function call function Create_Node (Func : EL.Functions.Function_Access; Arg1 : ELNode_Access) return ELNode_Access; -- Create a function call function Create_Node (Func : EL.Functions.Function_Access; Arg1 : ELNode_Access; Arg2 : ELNode_Access) return ELNode_Access; -- Create a function call function Create_Node (Func : EL.Functions.Function_Access; Arg1 : ELNode_Access; Arg2 : ELNode_Access; Arg3 : ELNode_Access) return ELNode_Access; -- Create a function call function Create_Node (Func : EL.Functions.Function_Access; Arg1 : ELNode_Access; Arg2 : ELNode_Access; Arg3 : ELNode_Access; Arg4 : ELNode_Access) return ELNode_Access; private type ELUnary is new ELNode with record Kind : Unary_Node; Node : ELNode_Access; end record; -- ------------------------------ -- Binary nodes -- ------------------------------ type ELBinary is new ELNode with record Kind : Binary_Node; Left : ELNode_Access; Right : ELNode_Access; end record; -- ------------------------------ -- Ternary expression -- ------------------------------ type ELTernary is new ELNode with record Cond : ELNode_Access; Left : ELNode_Access; Right : ELNode_Access; end record; -- #{bean.name} - Bean name, Bean property -- #{bean[12]} - Bean name, -- Variable to be looked at in the expression context type ELVariable is new ELNode with record Name : Unbounded_String; end record; type ELVariable_Access is access all ELVariable; type ELValue (Len : Natural) is new ELNode with record Variable : ELNode_Access; Name : String (1 .. Len); end record; -- A literal object (integer, boolean, float, String) type ELObject is new ELNode with record Value : Object; end record; -- A function call with up to 4 arguments. type ELFunction is new ELNode with record Func : EL.Functions.Function_Access; Arg1 : ELNode_Access; Arg2 : ELNode_Access; Arg3 : ELNode_Access; Arg4 : ELNode_Access; end record; end EL.Expressions.Nodes;
reznikmm/matreshka
Ada
3,609
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.Observations.Hash is new AMF.Elements.Generic_Hash (UML_Observation, UML_Observation_Access);
osannolik/Ada_Drivers_Library
Ada
9,291
ads
-- This spec has been automatically generated from STM32F446x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.SYSCFG is pragma Preelaborate; --------------- -- Registers -- --------------- subtype MEMRM_MEM_MODE_Field is HAL.UInt3; subtype MEMRM_SWP_FMC_Field is HAL.UInt2; -- memory remap register type MEMRM_Register is record -- Memory mapping selection MEM_MODE : MEMRM_MEM_MODE_Field := 16#0#; -- unspecified Reserved_3_7 : HAL.UInt5 := 16#0#; -- Flash bank mode selection FB_MODE : Boolean := False; -- unspecified Reserved_9_9 : HAL.Bit := 16#0#; -- FMC memory mapping swap SWP_FMC : MEMRM_SWP_FMC_Field := 16#0#; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for MEMRM_Register use record MEM_MODE at 0 range 0 .. 2; Reserved_3_7 at 0 range 3 .. 7; FB_MODE at 0 range 8 .. 8; Reserved_9_9 at 0 range 9 .. 9; SWP_FMC at 0 range 10 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; -- peripheral mode configuration register type PMC_Register is record -- unspecified Reserved_0_15 : HAL.UInt16 := 16#0#; -- ADC1DC2 ADC1DC2 : Boolean := False; -- ADC2DC2 ADC2DC2 : Boolean := False; -- ADC3DC2 ADC3DC2 : Boolean := False; -- unspecified Reserved_19_22 : HAL.UInt4 := 16#0#; -- Ethernet PHY interface selection MII_RMII_SEL : Boolean := False; -- unspecified Reserved_24_31 : HAL.UInt8 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for PMC_Register use record Reserved_0_15 at 0 range 0 .. 15; ADC1DC2 at 0 range 16 .. 16; ADC2DC2 at 0 range 17 .. 17; ADC3DC2 at 0 range 18 .. 18; Reserved_19_22 at 0 range 19 .. 22; MII_RMII_SEL at 0 range 23 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; -- EXTICR1_EXTI array element subtype EXTICR1_EXTI_Element is HAL.UInt4; -- EXTICR1_EXTI array type EXTICR1_EXTI_Field_Array is array (0 .. 3) of EXTICR1_EXTI_Element with Component_Size => 4, Size => 16; -- Type definition for EXTICR1_EXTI type EXTICR1_EXTI_Field (As_Array : Boolean := False) is record case As_Array is when False => -- EXTI as a value Val : HAL.UInt16; when True => -- EXTI as an array Arr : EXTICR1_EXTI_Field_Array; end case; end record with Unchecked_Union, Size => 16; for EXTICR1_EXTI_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- external interrupt configuration register 1 type EXTICR1_Register is record -- EXTI x configuration (x = 0 to 3) EXTI : EXTICR1_EXTI_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for EXTICR1_Register use record EXTI at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -- EXTICR2_EXTI array element subtype EXTICR2_EXTI_Element is HAL.UInt4; -- EXTICR2_EXTI array type EXTICR2_EXTI_Field_Array is array (4 .. 7) of EXTICR2_EXTI_Element with Component_Size => 4, Size => 16; -- Type definition for EXTICR2_EXTI type EXTICR2_EXTI_Field (As_Array : Boolean := False) is record case As_Array is when False => -- EXTI as a value Val : HAL.UInt16; when True => -- EXTI as an array Arr : EXTICR2_EXTI_Field_Array; end case; end record with Unchecked_Union, Size => 16; for EXTICR2_EXTI_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- external interrupt configuration register 2 type EXTICR2_Register is record -- EXTI x configuration (x = 4 to 7) EXTI : EXTICR2_EXTI_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for EXTICR2_Register use record EXTI at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -- EXTICR3_EXTI array element subtype EXTICR3_EXTI_Element is HAL.UInt4; -- EXTICR3_EXTI array type EXTICR3_EXTI_Field_Array is array (8 .. 11) of EXTICR3_EXTI_Element with Component_Size => 4, Size => 16; -- Type definition for EXTICR3_EXTI type EXTICR3_EXTI_Field (As_Array : Boolean := False) is record case As_Array is when False => -- EXTI as a value Val : HAL.UInt16; when True => -- EXTI as an array Arr : EXTICR3_EXTI_Field_Array; end case; end record with Unchecked_Union, Size => 16; for EXTICR3_EXTI_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- external interrupt configuration register 3 type EXTICR3_Register is record -- EXTI x configuration (x = 8 to 11) EXTI : EXTICR3_EXTI_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for EXTICR3_Register use record EXTI at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -- EXTICR4_EXTI array element subtype EXTICR4_EXTI_Element is HAL.UInt4; -- EXTICR4_EXTI array type EXTICR4_EXTI_Field_Array is array (12 .. 15) of EXTICR4_EXTI_Element with Component_Size => 4, Size => 16; -- Type definition for EXTICR4_EXTI type EXTICR4_EXTI_Field (As_Array : Boolean := False) is record case As_Array is when False => -- EXTI as a value Val : HAL.UInt16; when True => -- EXTI as an array Arr : EXTICR4_EXTI_Field_Array; end case; end record with Unchecked_Union, Size => 16; for EXTICR4_EXTI_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- external interrupt configuration register 4 type EXTICR4_Register is record -- EXTI x configuration (x = 12 to 15) EXTI : EXTICR4_EXTI_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for EXTICR4_Register use record EXTI at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -- Compensation cell control register type CMPCR_Register is record -- Read-only. Compensation cell power-down CMP_PD : Boolean; -- unspecified Reserved_1_7 : HAL.UInt7; -- Read-only. READY READY : Boolean; -- unspecified Reserved_9_31 : HAL.UInt23; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CMPCR_Register use record CMP_PD at 0 range 0 .. 0; Reserved_1_7 at 0 range 1 .. 7; READY at 0 range 8 .. 8; Reserved_9_31 at 0 range 9 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- System configuration controller type SYSCFG_Peripheral is record -- memory remap register MEMRM : aliased MEMRM_Register; -- peripheral mode configuration register PMC : aliased PMC_Register; -- external interrupt configuration register 1 EXTICR1 : aliased EXTICR1_Register; -- external interrupt configuration register 2 EXTICR2 : aliased EXTICR2_Register; -- external interrupt configuration register 3 EXTICR3 : aliased EXTICR3_Register; -- external interrupt configuration register 4 EXTICR4 : aliased EXTICR4_Register; -- Compensation cell control register CMPCR : aliased CMPCR_Register; end record with Volatile; for SYSCFG_Peripheral use record MEMRM at 16#0# range 0 .. 31; PMC at 16#4# range 0 .. 31; EXTICR1 at 16#8# range 0 .. 31; EXTICR2 at 16#C# range 0 .. 31; EXTICR3 at 16#10# range 0 .. 31; EXTICR4 at 16#14# range 0 .. 31; CMPCR at 16#20# range 0 .. 31; end record; -- System configuration controller SYSCFG_Periph : aliased SYSCFG_Peripheral with Import, Address => System'To_Address (16#40013800#); end STM32_SVD.SYSCFG;
AdaCore/libadalang
Ada
589
ads
package Invalid is I1 : constant Integer := Foo (1); --% node.f_default_expr.p_eval_as_int I2 : constant Integer := Integer (); --% node.previous_sibling.previous_sibling.f_default_expr.p_eval_as_int I3 : constant Integer := Integer (True); --% node.f_default_expr.p_eval_as_int B1 : constant Boolean := Boolean (1); --% node.f_default_expr.p_eval_as_int B2 : constant Boolean := Boolean (1.0); --% node.f_default_expr.p_eval_as_int type Rec is null record; R1 : constant Rec := Rec (True); --% node.f_default_expr.p_eval_as_int end Invalid;
Letractively/ada-el
Ada
4,167
adb
----------------------------------------------------------------------- -- EL.Methods.Proc_In -- Procedure Binding with 1 in argument -- Copyright (C) 2010, 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. ----------------------------------------------------------------------- package body EL.Methods.Proc_In is use EL.Expressions; -- ------------------------------ -- Returns True if the method is a valid method which accepts the arguments -- defined by the package instantiation. -- ------------------------------ function Is_Valid (Method : in EL.Expressions.Method_Info) return Boolean is begin if Method.Binding = null then return False; else return Method.Binding.all in Binding'Class; end if; end Is_Valid; -- ------------------------------ -- Execute the method describe by the method binding object. -- The method signature is: -- -- procedure F (Obj : in out <Bean>; -- Param : in Param1_Type); -- -- where <Bean> inherits from <b>Readonly_Bean</b> -- (See <b>Bind</b> package) -- -- Raises <b>Invalid_Method</b> if the method referenced by -- the method expression does not exist or does not match -- the signature. -- ------------------------------ procedure Execute (Method : in EL.Expressions.Method_Info; Param : in Param1_Type) is begin if Method.Binding = null then raise EL.Expressions.Invalid_Method with "Method not found"; end if; -- If the binding has the wrong type, we are trying to invoke -- a method with a different signature. if not (Method.Binding.all in Binding'Class) then raise EL.Expressions.Invalid_Method with "Invalid signature for method '" & Method.Binding.Name.all & "'"; end if; declare Proxy : constant Binding_Access := Binding (Method.Binding.all)'Access; begin Proxy.Method (Method.Object, Param); end; end Execute; -- ------------------------------ -- Execute the method describe by the method expression -- and with the given context. The method signature is: -- -- procedure F (Obj : in out <Bean>; -- Param : in Param1_Type); -- -- where <Bean> inherits from <b>Readonly_Bean</b> -- (See <b>Bind</b> package) -- -- Raises <b>Invalid_Method</b> if the method referenced by -- the method expression does not exist or does not match -- the signature. -- ------------------------------ procedure Execute (Method : in EL.Expressions.Method_Expression'Class; Param : in Param1_Type; Context : in EL.Contexts.ELContext'Class) is Info : constant Method_Info := Method.Get_Method_Info (Context); begin Execute (Info, Param); end Execute; -- ------------------------------ -- Proxy for the binding. -- The proxy declares the binding definition that links -- the name to the function and it implements the necessary -- object conversion to translate the <b>Readonly_Bean</b> -- object to the target object type. -- ------------------------------ package body Bind is procedure Method_Access (O : access Util.Beans.Basic.Readonly_Bean'Class; P1 : in Param1_Type) is Object : constant access Bean := Bean (O.all)'Access; begin Method (Object.all, P1); end Method_Access; end Bind; end EL.Methods.Proc_In;
zhmu/ananas
Ada
18,640
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . S T R I N G S . W I D E _ W I D E _ U N B O U N D E D -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- -- apply solely to the contents of the part following the private keyword. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This version is supported on: -- - all Alpha platforms -- - all ia64 platforms -- - all PowerPC platforms -- - all SPARC V9 platforms -- - all x86 platforms -- - all x86_64 platforms with Ada.Strings.Wide_Wide_Maps; private with Ada.Finalization; private with System.Atomic_Counters; package Ada.Strings.Wide_Wide_Unbounded is pragma Preelaborate; type Unbounded_Wide_Wide_String is private; pragma Preelaborable_Initialization (Unbounded_Wide_Wide_String); Null_Unbounded_Wide_Wide_String : constant Unbounded_Wide_Wide_String; function Length (Source : Unbounded_Wide_Wide_String) return Natural; type Wide_Wide_String_Access is access all Wide_Wide_String; procedure Free (X : in out Wide_Wide_String_Access); -------------------------------------------------------- -- Conversion, Concatenation, and Selection Functions -- -------------------------------------------------------- function To_Unbounded_Wide_Wide_String (Source : Wide_Wide_String) return Unbounded_Wide_Wide_String; function To_Unbounded_Wide_Wide_String (Length : Natural) return Unbounded_Wide_Wide_String; function To_Wide_Wide_String (Source : Unbounded_Wide_Wide_String) return Wide_Wide_String; procedure Set_Unbounded_Wide_Wide_String (Target : out Unbounded_Wide_Wide_String; Source : Wide_Wide_String); pragma Ada_05 (Set_Unbounded_Wide_Wide_String); procedure Append (Source : in out Unbounded_Wide_Wide_String; New_Item : Unbounded_Wide_Wide_String); procedure Append (Source : in out Unbounded_Wide_Wide_String; New_Item : Wide_Wide_String); procedure Append (Source : in out Unbounded_Wide_Wide_String; New_Item : Wide_Wide_Character); function "&" (Left : Unbounded_Wide_Wide_String; Right : Unbounded_Wide_Wide_String) return Unbounded_Wide_Wide_String; function "&" (Left : Unbounded_Wide_Wide_String; Right : Wide_Wide_String) return Unbounded_Wide_Wide_String; function "&" (Left : Wide_Wide_String; Right : Unbounded_Wide_Wide_String) return Unbounded_Wide_Wide_String; function "&" (Left : Unbounded_Wide_Wide_String; Right : Wide_Wide_Character) return Unbounded_Wide_Wide_String; function "&" (Left : Wide_Wide_Character; Right : Unbounded_Wide_Wide_String) return Unbounded_Wide_Wide_String; function Element (Source : Unbounded_Wide_Wide_String; Index : Positive) return Wide_Wide_Character; procedure Replace_Element (Source : in out Unbounded_Wide_Wide_String; Index : Positive; By : Wide_Wide_Character); function Slice (Source : Unbounded_Wide_Wide_String; Low : Positive; High : Natural) return Wide_Wide_String; function Unbounded_Slice (Source : Unbounded_Wide_Wide_String; Low : Positive; High : Natural) return Unbounded_Wide_Wide_String; pragma Ada_05 (Unbounded_Slice); procedure Unbounded_Slice (Source : Unbounded_Wide_Wide_String; Target : out Unbounded_Wide_Wide_String; Low : Positive; High : Natural); pragma Ada_05 (Unbounded_Slice); function "=" (Left : Unbounded_Wide_Wide_String; Right : Unbounded_Wide_Wide_String) return Boolean; function "=" (Left : Unbounded_Wide_Wide_String; Right : Wide_Wide_String) return Boolean; function "=" (Left : Wide_Wide_String; Right : Unbounded_Wide_Wide_String) return Boolean; function "<" (Left : Unbounded_Wide_Wide_String; Right : Unbounded_Wide_Wide_String) return Boolean; function "<" (Left : Unbounded_Wide_Wide_String; Right : Wide_Wide_String) return Boolean; function "<" (Left : Wide_Wide_String; Right : Unbounded_Wide_Wide_String) return Boolean; function "<=" (Left : Unbounded_Wide_Wide_String; Right : Unbounded_Wide_Wide_String) return Boolean; function "<=" (Left : Unbounded_Wide_Wide_String; Right : Wide_Wide_String) return Boolean; function "<=" (Left : Wide_Wide_String; Right : Unbounded_Wide_Wide_String) return Boolean; function ">" (Left : Unbounded_Wide_Wide_String; Right : Unbounded_Wide_Wide_String) return Boolean; function ">" (Left : Unbounded_Wide_Wide_String; Right : Wide_Wide_String) return Boolean; function ">" (Left : Wide_Wide_String; Right : Unbounded_Wide_Wide_String) return Boolean; function ">=" (Left : Unbounded_Wide_Wide_String; Right : Unbounded_Wide_Wide_String) return Boolean; function ">=" (Left : Unbounded_Wide_Wide_String; Right : Wide_Wide_String) return Boolean; function ">=" (Left : Wide_Wide_String; Right : Unbounded_Wide_Wide_String) return Boolean; ------------------------ -- Search Subprograms -- ------------------------ function Index (Source : Unbounded_Wide_Wide_String; Pattern : Wide_Wide_String; Going : Direction := Forward; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping := Wide_Wide_Maps.Identity) return Natural; function Index (Source : Unbounded_Wide_Wide_String; Pattern : Wide_Wide_String; Going : Direction := Forward; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function) return Natural; function Index (Source : Unbounded_Wide_Wide_String; Set : Wide_Wide_Maps.Wide_Wide_Character_Set; Test : Membership := Inside; Going : Direction := Forward) return Natural; function Index (Source : Unbounded_Wide_Wide_String; Pattern : Wide_Wide_String; From : Positive; Going : Direction := Forward; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping := Wide_Wide_Maps.Identity) return Natural; pragma Ada_05 (Index); function Index (Source : Unbounded_Wide_Wide_String; Pattern : Wide_Wide_String; From : Positive; Going : Direction := Forward; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function) return Natural; pragma Ada_05 (Index); function Index (Source : Unbounded_Wide_Wide_String; Set : Wide_Wide_Maps.Wide_Wide_Character_Set; From : Positive; Test : Membership := Inside; Going : Direction := Forward) return Natural; pragma Ada_05 (Index); function Index_Non_Blank (Source : Unbounded_Wide_Wide_String; Going : Direction := Forward) return Natural; function Index_Non_Blank (Source : Unbounded_Wide_Wide_String; From : Positive; Going : Direction := Forward) return Natural; pragma Ada_05 (Index_Non_Blank); function Count (Source : Unbounded_Wide_Wide_String; Pattern : Wide_Wide_String; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping := Wide_Wide_Maps.Identity) return Natural; function Count (Source : Unbounded_Wide_Wide_String; Pattern : Wide_Wide_String; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function) return Natural; function Count (Source : Unbounded_Wide_Wide_String; Set : Wide_Wide_Maps.Wide_Wide_Character_Set) return Natural; procedure Find_Token (Source : Unbounded_Wide_Wide_String; Set : Wide_Wide_Maps.Wide_Wide_Character_Set; From : Positive; Test : Membership; First : out Positive; Last : out Natural); pragma Ada_2012 (Find_Token); procedure Find_Token (Source : Unbounded_Wide_Wide_String; Set : Wide_Wide_Maps.Wide_Wide_Character_Set; Test : Membership; First : out Positive; Last : out Natural); ------------------------------------ -- String Translation Subprograms -- ------------------------------------ function Translate (Source : Unbounded_Wide_Wide_String; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping) return Unbounded_Wide_Wide_String; procedure Translate (Source : in out Unbounded_Wide_Wide_String; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping); function Translate (Source : Unbounded_Wide_Wide_String; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function) return Unbounded_Wide_Wide_String; procedure Translate (Source : in out Unbounded_Wide_Wide_String; Mapping : Wide_Wide_Maps.Wide_Wide_Character_Mapping_Function); --------------------------------------- -- String Transformation Subprograms -- --------------------------------------- function Replace_Slice (Source : Unbounded_Wide_Wide_String; Low : Positive; High : Natural; By : Wide_Wide_String) return Unbounded_Wide_Wide_String; procedure Replace_Slice (Source : in out Unbounded_Wide_Wide_String; Low : Positive; High : Natural; By : Wide_Wide_String); function Insert (Source : Unbounded_Wide_Wide_String; Before : Positive; New_Item : Wide_Wide_String) return Unbounded_Wide_Wide_String; procedure Insert (Source : in out Unbounded_Wide_Wide_String; Before : Positive; New_Item : Wide_Wide_String); function Overwrite (Source : Unbounded_Wide_Wide_String; Position : Positive; New_Item : Wide_Wide_String) return Unbounded_Wide_Wide_String; procedure Overwrite (Source : in out Unbounded_Wide_Wide_String; Position : Positive; New_Item : Wide_Wide_String); function Delete (Source : Unbounded_Wide_Wide_String; From : Positive; Through : Natural) return Unbounded_Wide_Wide_String; procedure Delete (Source : in out Unbounded_Wide_Wide_String; From : Positive; Through : Natural); function Trim (Source : Unbounded_Wide_Wide_String; Side : Trim_End) return Unbounded_Wide_Wide_String; procedure Trim (Source : in out Unbounded_Wide_Wide_String; Side : Trim_End); function Trim (Source : Unbounded_Wide_Wide_String; Left : Wide_Wide_Maps.Wide_Wide_Character_Set; Right : Wide_Wide_Maps.Wide_Wide_Character_Set) return Unbounded_Wide_Wide_String; procedure Trim (Source : in out Unbounded_Wide_Wide_String; Left : Wide_Wide_Maps.Wide_Wide_Character_Set; Right : Wide_Wide_Maps.Wide_Wide_Character_Set); function Head (Source : Unbounded_Wide_Wide_String; Count : Natural; Pad : Wide_Wide_Character := Wide_Wide_Space) return Unbounded_Wide_Wide_String; procedure Head (Source : in out Unbounded_Wide_Wide_String; Count : Natural; Pad : Wide_Wide_Character := Wide_Wide_Space); function Tail (Source : Unbounded_Wide_Wide_String; Count : Natural; Pad : Wide_Wide_Character := Wide_Wide_Space) return Unbounded_Wide_Wide_String; procedure Tail (Source : in out Unbounded_Wide_Wide_String; Count : Natural; Pad : Wide_Wide_Character := Wide_Wide_Space); function "*" (Left : Natural; Right : Wide_Wide_Character) return Unbounded_Wide_Wide_String; function "*" (Left : Natural; Right : Wide_Wide_String) return Unbounded_Wide_Wide_String; function "*" (Left : Natural; Right : Unbounded_Wide_Wide_String) return Unbounded_Wide_Wide_String; private pragma Inline (Length); package AF renames Ada.Finalization; type Shared_Wide_Wide_String (Max_Length : Natural) is limited record Counter : System.Atomic_Counters.Atomic_Counter; -- Reference counter Last : Natural := 0; Data : Wide_Wide_String (1 .. Max_Length); -- Last is the index of last significant element of the Data. All -- elements with larger indexes are just extra room for expansion. end record; type Shared_Wide_Wide_String_Access is access all Shared_Wide_Wide_String; procedure Reference (Item : not null Shared_Wide_Wide_String_Access); -- Increment reference counter. procedure Unreference (Item : not null Shared_Wide_Wide_String_Access); -- Decrement reference counter. Deallocate Item when reference counter is -- zero. function Can_Be_Reused (Item : Shared_Wide_Wide_String_Access; Length : Natural) return Boolean; -- Returns True if Shared_Wide_Wide_String can be reused. There are two -- criteria when Shared_Wide_Wide_String can be reused: its reference -- counter must be one (thus Shared_Wide_Wide_String is owned exclusively) -- and its size is sufficient to store string with specified length -- effectively. function Allocate (Max_Length : Natural) return Shared_Wide_Wide_String_Access; -- Allocates new Shared_Wide_Wide_String with at least specified maximum -- length. Actual maximum length of the allocated Shared_Wide_Wide_String -- can be slightly greater. Returns reference to -- Empty_Shared_Wide_Wide_String when requested length is zero. Empty_Shared_Wide_Wide_String : aliased Shared_Wide_Wide_String (0); function To_Unbounded (S : Wide_Wide_String) return Unbounded_Wide_Wide_String renames To_Unbounded_Wide_Wide_String; -- This renames are here only to be used in the pragma Stream_Convert. type Unbounded_Wide_Wide_String is new AF.Controlled with record Reference : Shared_Wide_Wide_String_Access := Empty_Shared_Wide_Wide_String'Access; end record; -- The Unbounded_Wide_Wide_String uses several techniques to increase speed -- of the application: -- - implicit sharing or copy-on-write. Unbounded_Wide_Wide_String -- contains only the reference to the data which is shared between -- several instances. The shared data is reallocated only when its value -- is changed and the object mutation can't be used or it is inefficient -- to use it; -- - object mutation. Shared data object can be reused without memory -- reallocation when all of the following requirements are meat: -- - shared data object don't used anywhere longer; -- - its size is sufficient to store new value; -- - the gap after reuse is less than some threshold. -- - memory preallocation. Most of used memory allocation algorithms -- aligns allocated segment on the some boundary, thus some amount of -- additional memory can be preallocated without any impact. Such -- preallocated memory can used later by Append/Insert operations -- without reallocation. -- Reference counting uses GCC builtin atomic operations, which allows safe -- sharing of internal data between Ada tasks. Nevertheless, this does not -- make objects of Unbounded_String thread-safe: an instance cannot be -- accessed by several tasks simultaneously. pragma Stream_Convert (Unbounded_Wide_Wide_String, To_Unbounded, To_Wide_Wide_String); -- Provide stream routines without dragging in Ada.Streams pragma Finalize_Storage_Only (Unbounded_Wide_Wide_String); -- Finalization is required only for freeing storage overriding procedure Initialize (Object : in out Unbounded_Wide_Wide_String); overriding procedure Adjust (Object : in out Unbounded_Wide_Wide_String); overriding procedure Finalize (Object : in out Unbounded_Wide_Wide_String); pragma Inline (Initialize, Adjust); Null_Unbounded_Wide_Wide_String : constant Unbounded_Wide_Wide_String := (AF.Controlled with Reference => Empty_Shared_Wide_Wide_String' Access); end Ada.Strings.Wide_Wide_Unbounded;
AdaCore/training_material
Ada
1,057
adb
with Ada.Directories; use Ada.Directories; with Ada.Containers.Ordered_Sets; with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with BMP_File_IO; package body Movies is function Load_From (Path : String) return Movie_T is begin return (others => <>); -- TODO end Load_From; function Frames_Number (M : Movie_T) return Frame_T is begin return Frame_T'First; -- TODO end Frames_Number; -- TODO -- Use a Ada.Container to store all the files related to the movie -- (BMP files stored in the movie's directory). -- -- Those files should be in order of their names, but be careful -- that a naive string sort would put "toto_9.bmp" > "toto_10.bmp" function Frame (M : Movie_T; F : Frame_T) return Surface_T is begin -- TODO -- To find *.bmp files, use the Ada.Directories search -- https://www.adaic.org/resources/add_content/standards/12rm/html/RM-A-16.html#p101 return (others => <>); end Frame; end Movies;
reznikmm/matreshka
Ada
6,426
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This package provides subprograms to extract julian day number and time -- inside day from X/Open representation and to construct X/Open -- representation from julian day number and time inside day. -- -- Subprograms in this package handles leap seconds also. -- -- Note: for convenience, julian day starts at midnight, not noon. ------------------------------------------------------------------------------ package Matreshka.Internals.Calendars.Times is pragma Preelaborate; subtype Hour_Number is Integer range 0 .. 23; subtype Minute_Number is Integer range 0 .. 59; subtype Second_Number is Integer range 0 .. 60; subtype Nano_Second_100_Number is Integer range 0 .. 9_999_999; function Create (Zone : not null Time_Zone_Access; Julian_Day : Julian_Day_Number; Hour : Hour_Number; Minute : Minute_Number; Second : Second_Number; Nano_100 : Nano_Second_100_Number) return Absolute_Time; -- Creates absolute time from giving components. function Julian_Day (Stamp : Absolute_Time; Zone : not null Time_Zone_Access) return Julian_Day_Number; -- Returns julian day number of the specified X/Open time. function Hour (Stamp : Absolute_Time; Zone : not null Time_Zone_Access) return Hour_Number; function Hour (Time : Relative_Time) return Hour_Number; -- Returns the hour part (0 to 23) of the time. function Minute (Stamp : Absolute_Time; Zone : not null Time_Zone_Access) return Minute_Number; function Minute (Time : Relative_Time) return Minute_Number; -- Returns the minute part (0 to 59) of the time. function Second (Stamp : Absolute_Time; Zone : not null Time_Zone_Access) return Second_Number; function Second (Time : Relative_Time; Leap : Relative_Time) return Second_Number; -- Returns the second part (0 to 60) of the time. function Nanosecond_100 (Time : Relative_Time; Leap : Relative_Time) return Nano_Second_100_Number; function Nanosecond_100 (Stamp : Absolute_Time; Zone : not null Time_Zone_Access) return Nano_Second_100_Number; -- Returns the second fraction part (0 to 9_999_999) of the time. procedure Split (Zone : not null Time_Zone_Access; Stamp : Absolute_Time; Julian_Day : out Julian_Day_Number; Time : out Relative_Time; Leap : out Relative_Time); -- Splits stamp onto julian day number, relative time and leap second -- fraction. procedure Split (Zone : not null Time_Zone_Access; Stamp : Absolute_Time; Julian_Day : out Julian_Day_Number; Hour : out Hour_Number; Minute : out Minute_Number; Second : out Second_Number; Nanosecond_100 : out Nano_Second_100_Number); -- Splits stamp onto julian day number and splitted time inside day. Leap -- second is returned as Second equal to 60. It is not necessary last -- second of the day due to timezone correction. end Matreshka.Internals.Calendars.Times;
likai3g/afmt
Ada
101
ads
with Fmt.Generic_Float_Argument; package Fmt.Float_Argument is new Generic_Float_Argument(Float);
AdaCore/libadalang
Ada
42,681
adb
------------------------------------------------------------------------------ -- -- -- POLYORB COMPONENTS -- -- -- -- B A C K E N D . B E _ C O R B A _ A D A . C O M M O N -- -- -- -- B o d y -- -- -- -- Copyright (C) 2006-2013, Free Software Foundation, Inc. -- -- -- -- This 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. This software is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- -- License for more details. -- -- -- -- 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/>. -- -- -- -- PolyORB is maintained by AdaCore -- -- (email: [email protected]) -- -- -- ------------------------------------------------------------------------------ with Namet; use Namet; with Values; with Frontend.Nodes; use Frontend.Nodes; with Frontend.Nutils; with Backend.BE_CORBA_Ada.Nutils; use Backend.BE_CORBA_Ada.Nutils; with Backend.BE_CORBA_Ada.Nodes; use Backend.BE_CORBA_Ada.Nodes; with Backend.BE_CORBA_Ada.IDL_To_Ada; use Backend.BE_CORBA_Ada.IDL_To_Ada; with Backend.BE_CORBA_Ada.Runtime; use Backend.BE_CORBA_Ada.Runtime; package body Backend.BE_CORBA_Ada.Common is package FEN renames Frontend.Nodes; package FEU renames Frontend.Nutils; ------------------------------------- -- Cast_Variable_From_PolyORB_Type -- ------------------------------------- function Cast_Variable_From_PolyORB_Type (Var_Name : Name_Id; Var_Type : Node_Id) return Node_Id is N : Node_Id; Orig_Type : Node_Id; Direct_Type_Node : Node_Id; begin N := Make_Identifier (Var_Name); Orig_Type := FEU.Get_Original_Type_Specifier (Var_Type); if FEN.Kind (Var_Type) = K_Simple_Declarator or else FEN.Kind (Var_Type) = K_Complex_Declarator then Direct_Type_Node := Type_Spec (Declaration (Var_Type)); else Direct_Type_Node := Var_Type; end if; case FEN.Kind (Orig_Type) is when K_String => begin N := Make_Subprogram_Call (RE (RE_To_Standard_String_1), New_List (N)); if FEN.Kind (Direct_Type_Node) /= K_String then declare Ada_Type : constant Node_Id := Map_Expanded_Name (Direct_Type_Node); TCS : constant Node_Id := Make_Selected_Component (Copy_Node (Prefix (Ada_Type)), Make_Identifier (SN (S_To_CORBA_String))); -- To_CORBA_String primitive inherited from the -- CORBA.String type. begin N := Make_Subprogram_Call (TCS, New_List (N)); -- We use qualified expression to avoid conflicts with -- types derived from String in the spec of package CORBA -- (RepositoryId, ScopedName...) N := Make_Qualified_Expression (Ada_Type, N); end; else N := Make_Subprogram_Call (RE (RE_To_CORBA_String), New_List (N)); N := Make_Qualified_Expression (RE (RE_String_0), N); end if; end; when K_String_Type => declare Str_Package_Node : Node_Id; Str_Convert_Subp : Node_Id; begin -- Getting the instantiated package node Str_Package_Node := Defining_Identifier (Instantiation_Node (BE_Node (Orig_Type))); -- Getting the conversion subprogram Str_Convert_Subp := Make_Selected_Component (Str_Package_Node, Make_Identifier (SN (S_To_Bounded_String))); N := Make_Subprogram_Call (RE (RE_To_Standard_String_1), New_List (N)); N := Make_Subprogram_Call (Str_Convert_Subp, New_List (N)); N := Make_Subprogram_Call (Map_Expanded_Name (Direct_Type_Node), New_List (N)); end; when K_Wide_String => begin N := Make_Subprogram_Call (RE (RE_To_Standard_Wide_String_1), New_List (N)); if FEN.Kind (Direct_Type_Node) /= K_Wide_String then declare Ada_Type : constant Node_Id := Map_Expanded_Name (Direct_Type_Node); TCWS : constant Node_Id := Make_Selected_Component (Copy_Node (Prefix (Ada_Type)), Make_Identifier (SN (S_To_CORBA_Wide_String))); -- To_CORBA_Wide_String primitive inherited from the -- CORBA.Wide_String type. begin N := Make_Subprogram_Call (TCWS, New_List (N)); N := Make_Qualified_Expression (Ada_Type, N); end; else N := Make_Subprogram_Call (RE (RE_To_CORBA_Wide_String), New_List (N)); N := Make_Qualified_Expression (RE (RE_Wide_String), N); end if; end; when K_Wide_String_Type => declare Str_Package_Node : Node_Id; Str_Convert_Subp : Node_Id; begin -- Getting the instantiated package node Str_Package_Node := Defining_Identifier (Instantiation_Node (BE_Node (Orig_Type))); -- Getting the conversion subprogram Str_Convert_Subp := Make_Selected_Component (Str_Package_Node, Make_Identifier (SN (S_To_Bounded_Wide_String))); N := Make_Subprogram_Call (RE (RE_To_Standard_Wide_String_1), New_List (N)); N := Make_Subprogram_Call (Str_Convert_Subp, New_List (N)); N := Make_Subprogram_Call (Map_Expanded_Name (Direct_Type_Node), New_List (N)); end; when K_Long | K_Long_Long | K_Unsigned_Long | K_Unsigned_Long_Long | K_Float | K_Double | K_Long_Double | K_Char | K_Wide_Char | K_Octet | K_Sequence_Type | K_Short | K_Unsigned_Short | K_Boolean | K_Fixed_Point_Type | K_Any => declare CORBA_Type : constant Node_Id := Map_Expanded_Name (Direct_Type_Node); begin N := Make_Subprogram_Call (CORBA_Type, New_List (N)); end; -- For Objects and interfaces, there is no need to cast -- to the original type because the type definition is -- done by means of 'subtype' and not 'type ... is new -- ...' when K_Object => begin N := Make_Subprogram_Call (RE (RE_To_CORBA_Ref), New_List (N)); end; when K_Interface_Declaration | K_Forward_Interface_Declaration => -- Check whether we are dealing with a TypeCode if Get_Predefined_CORBA_Entity (Orig_Type) = RE_Object then N := Make_Subprogram_Call (RE (RE_To_CORBA_Object), New_List (N)); else declare To_Ref_Node : constant Node_Id := Get_To_Ref_Node (Direct_Type_Node); begin N := Make_Subprogram_Call (RE (RE_To_CORBA_Ref), New_List (N)); N := Make_Subprogram_Call (To_Ref_Node, New_List (N)); end; end if; when K_Enumeration_Type => declare CORBA_Type : constant Node_Id := Map_Expanded_Name (Direct_Type_Node); M : Node_Id; begin -- Even if the type is not directly an enumeration and -- is defined basing on an enumeration, we still have -- access to the 'Val attribute. So there is no need -- to cast the variable to the original enumeration -- type. M := Make_Attribute_Reference (CORBA_Type, A_Val); N := Make_Subprogram_Call (M, New_List (N)); end; when others => null; end case; return N; end Cast_Variable_From_PolyORB_Type; ----------------------------------- -- Cast_Variable_To_PolyORB_Type -- ----------------------------------- function Cast_Variable_To_PolyORB_Type (Var_Node : Node_Id; Var_Type : Node_Id) return Node_Id is N : Node_Id; Orig_Type : Node_Id; begin N := Var_Node; Orig_Type := FEU.Get_Original_Type_Specifier (Var_Type); case FEN.Kind (Orig_Type) is when K_Long => begin N := Make_Type_Conversion (RE (RE_Long_1), N); end; when K_Long_Long => begin N := Make_Type_Conversion (RE (RE_Long_Long_1), N); end; when K_Unsigned_Long => begin N := Make_Type_Conversion (RE (RE_Unsigned_Long_1), N); end; when K_Unsigned_Long_Long => begin N := Make_Type_Conversion (RE (RE_Unsigned_Long_Long_1), N); end; when K_Short => begin N := Make_Type_Conversion (RE (RE_Short_1), N); end; when K_Unsigned_Short => begin N := Make_Type_Conversion (RE (RE_Unsigned_Short_1), N); end; when K_Float => begin N := Make_Type_Conversion (RE (RE_Float_1), N); end; when K_Double => begin N := Make_Type_Conversion (RE (RE_Double_1), N); end; when K_Long_Double => begin N := Make_Type_Conversion (RE (RE_Long_Double_1), N); end; when K_Char => begin N := Make_Type_Conversion (RE (RE_Char_1), N); end; when K_Wide_Char => begin N := Make_Type_Conversion (RE (RE_Wchar_1), N); end; when K_Octet => begin N := Make_Type_Conversion (RE (RE_Octet_1), N); end; when K_Boolean => begin N := Make_Type_Conversion (RE (RE_Boolean_1), N); end; when K_Fixed_Point_Type => declare FP_Type_Node : Node_Id; begin -- Getting the fixed point type FP_Type_Node := Expand_Designator (Type_Def_Node (BE_Node (Orig_Type))); N := Make_Type_Conversion (FP_Type_Node, N); end; when K_Object => begin N := Make_Subprogram_Call (RE (RE_To_PolyORB_Ref), New_List (N)); end; when K_Interface_Declaration | K_Forward_Interface_Declaration => -- Check whether we are dealing with a TypeCode if Get_Predefined_CORBA_Entity (Orig_Type) = RE_Object then N := Make_Subprogram_Call (RE (RE_Object_Of_1), New_List (Make_Subprogram_Call (RE (RE_To_PolyORB_Object), New_List (N)))); else N := Make_Type_Conversion (RE (RE_Ref_2), N); N := Make_Subprogram_Call (RE (RE_To_PolyORB_Ref), New_List (N)); end if; when K_Enumeration_Type => declare Ada_Enum_Type : constant Node_Id := Expand_Designator (Type_Def_Node (BE_Node (Identifier (Orig_Type)))); M : Node_Id; begin if FEN.Kind (Var_Type) = K_Scoped_Name and then FEN.Kind (Reference (Var_Type)) /= K_Enumeration_Type then N := Make_Type_Conversion (Ada_Enum_Type, N); end if; -- Even if the type is not directly an enumeration and -- is defined basing on an enumeration, we still have -- access to the 'Pos' attribute. So there is no need -- to cast the variable to the original enumeration -- type. M := Make_Attribute_Reference (Ada_Enum_Type, A_Pos); M := Make_Subprogram_Call (M, New_List (N)); N := Make_Type_Conversion (RE (RE_Unsigned_Long_1), M); end; when K_String => begin if FEN.Kind (Var_Type) /= K_String then N := Make_Type_Conversion (RE (RE_String_0), N); end if; N := Make_Subprogram_Call (RE (RE_To_Standard_String), New_List (N)); N := Make_Subprogram_Call (RE (RE_To_PolyORB_String), New_List (N)); end; when K_String_Type => declare Str_Package_Node : Node_Id; Str_Type : Node_Id; Str_Convert_Subp : Node_Id; begin -- Getting the instantiated package node Str_Package_Node := Defining_Identifier (Instantiation_Node (BE_Node (Orig_Type))); -- Getting the conversion subprogram Str_Type := Make_Selected_Component (Str_Package_Node, Make_Identifier (TN (T_Bounded_String))); Str_Convert_Subp := Make_Selected_Component (Str_Package_Node, Make_Identifier (SN (S_To_String))); N := Make_Type_Conversion (Str_Type, N); N := Make_Subprogram_Call (Str_Convert_Subp, New_List (N)); N := Make_Subprogram_Call (RE (RE_To_PolyORB_String), New_List (N)); end; when K_Wide_String => begin if FEN.Kind (Var_Type) /= K_Wide_String then N := Make_Type_Conversion (RE (RE_Wide_String), N); end if; N := Make_Subprogram_Call (RE (RE_To_Standard_Wide_String), New_List (N)); N := Make_Subprogram_Call (RE (RE_To_PolyORB_Wide_String), New_List (N)); end; when K_Wide_String_Type => declare Str_Package_Node : Node_Id; Str_Type : Node_Id; Str_Convert_Subp : Node_Id; begin -- Getting the instantiated package node Str_Package_Node := Defining_Identifier (Instantiation_Node (BE_Node (Orig_Type))); -- Getting the conversion subprogram Str_Type := Make_Selected_Component (Str_Package_Node, Make_Identifier (TN (T_Bounded_Wide_String))); Str_Convert_Subp := Make_Selected_Component (Str_Package_Node, Make_Identifier (SN (S_To_Wide_String))); N := Make_Type_Conversion (Str_Type, N); N := Make_Subprogram_Call (Str_Convert_Subp, New_List (N)); N := Make_Subprogram_Call (RE (RE_To_PolyORB_Wide_String), New_List (N)); end; when K_Sequence_Type => declare Seq_Package_Node : Node_Id; Seq_Type : Node_Id; begin -- Getting the instantiated package node Seq_Package_Node := Expand_Designator (Instantiation_Node (BE_Node (Orig_Type))); -- Sequence type Seq_Type := Make_Selected_Component (Seq_Package_Node, Make_Identifier (TN (T_Sequence))); N := Make_Type_Conversion (Seq_Type, N); end; when K_Any => begin N := Make_Type_Conversion (RE (RE_Any_1), N); end; when others => null; end case; return N; end Cast_Variable_To_PolyORB_Type; ----------- -- Is_In -- ----------- function Is_In (Par_Mode : Mode_Id) return Boolean is begin return Par_Mode = Mode_In or else Par_Mode = Mode_Inout; end Is_In; ------------ -- Is_Out -- ------------ function Is_Out (Par_Mode : Mode_Id) return Boolean is begin return Par_Mode = Mode_Out or else Par_Mode = Mode_Inout; end Is_Out; ---------------------------- -- Contains_In_Parameters -- ---------------------------- function Contains_In_Parameters (E : Node_Id) return Boolean is pragma Assert (FEN.Kind (E) = K_Operation_Declaration); Parameter : Node_Id; Result : Boolean := False; begin Parameter := First_Entity (Parameters (E)); while Present (Parameter) loop if Is_In (FEN.Parameter_Mode (Parameter)) then Result := True; exit; end if; Parameter := Next_Entity (Parameter); end loop; return Result; end Contains_In_Parameters; ----------------------------- -- Contains_Out_Parameters -- ----------------------------- function Contains_Out_Parameters (E : Node_Id) return Boolean is pragma Assert (FEN.Kind (E) = K_Operation_Declaration); Parameter : Node_Id; Result : Boolean := False; begin Parameter := First_Entity (Parameters (E)); while Present (Parameter) loop if Is_Out (FEN.Parameter_Mode (Parameter)) then Result := True; exit; end if; Parameter := Next_Entity (Parameter); end loop; return Result; end Contains_Out_Parameters; -------------------------- -- Make_type_Designator -- -------------------------- function Make_Type_Designator (N : Node_Id; Declarator : Node_Id := No_Node) return Node_Id is Rewinded_Type : Node_Id; M : Node_Id; begin Set_Aligned_Spec; Rewinded_Type := FEU.Get_Original_Type_Specifier (N); if Present (Declarator) and then FEN.Kind (Declarator) = K_Complex_Declarator then declare Designator : Node_Id; Decl_Name : Name_Id; Type_Node : Node_Id; begin Decl_Name := To_Ada_Name (IDL_Name (FEN.Identifier (Declarator))); Designator := Make_Type_Designator (N); Get_Name_String (Decl_Name); Add_Str_To_Name_Buffer ("_Array"); Decl_Name := Name_Find; Type_Node := Make_Full_Type_Declaration (Defining_Identifier => Make_Defining_Identifier (Decl_Name), Type_Definition => Make_Array_Type_Definition (Map_Range_Constraints (FEN.Array_Sizes (Declarator)), Designator)); -- We make a link between the identifier and the type -- declaration. This link is useful for the generation -- of the From_Any and To_Any functions and the TC_XXX -- constant necessary for user defined types. Append_To (Visible_Part (Current_Package), Type_Node); Designator := Make_Selected_Component (Defining_Identifier (Stubs_Package (Current_Entity)), Defining_Identifier (Type_Node)); return Designator; end; end if; case FEN.Kind (Rewinded_Type) is when K_String => return RE (RE_String_10); when K_Sequence_Type => M := Make_Selected_Component (Defining_Identifier (Aligned_Package (Current_Entity)), Make_Identifier (IDL_Name (Identifier (N)))); return M; when K_Long => return RE (RE_Long_10); when K_Short => return RE (RE_Short_10); when K_Boolean => return RE (RE_Boolean_10); when K_Octet => return RE (RE_Octet_10); when K_Char => return RE (RE_Char_10); when K_Wide_Char => return RE (RE_Wchar_10); when K_Unsigned_Short => return RE (RE_Unsigned_Short_10); when K_Unsigned_Long | K_Enumeration_Type => return RE (RE_Unsigned_Long_10); when K_Long_Long => return RE (RE_Long_Long_10); when K_Unsigned_Long_Long => return RE (RE_Unsigned_Long_Long_10); when K_Long_Double => return RE (RE_Long_Double_10); when K_Float => return RE (RE_Float_10); when K_Double => return RE (RE_Double_10); when K_Complex_Declarator => M := Make_Selected_Component (Defining_Identifier (Aligned_Package (Current_Entity)), Make_Identifier (IDL_Name (Identifier (N)))); return M; when K_String_Type | K_Wide_String_Type | K_Structure_Type | K_Union_Type | K_Fixed_Point_Type => M := Make_Selected_Component (Defining_Identifier (Aligned_Package (Current_Entity)), Make_Identifier (IDL_Name (Identifier (N)))); return M; when K_Object => -- XXX is it right ? M := Make_Selected_Component (Defining_Identifier (Aligned_Package (Current_Entity)), Make_Identifier (FEN.Image (Base_Type (Rewinded_Type)))); return M; when K_Interface_Declaration => -- XXX is it right ? M := Make_Selected_Component (Defining_Identifier (Aligned_Package (Current_Entity)), Make_Identifier (IDL_Name (Identifier (Rewinded_Type)))); return M; when others => -- If any problem print the node kind here raise Program_Error; end case; end Make_Type_Designator; ------------------------------------------- -- Cast_Variable_To_PolyORB_Aligned_Type -- ------------------------------------------- function Cast_Variable_To_PolyORB_Aligned_Type (Var_Node : Node_Id; Var_Type : Node_Id) return Node_Id is N : Node_Id; Orig_Type : Node_Id; begin N := Var_Node; Orig_Type := FEU.Get_Original_Type_Specifier (Var_Type); case FEN.Kind (Orig_Type) is when K_Long => begin N := Make_Type_Conversion (RE (RE_Long_10), N); end; when K_Long_Long => begin N := Make_Type_Conversion (RE (RE_Long_Long_10), N); end; when K_Unsigned_Long => begin N := Make_Type_Conversion (RE (RE_Unsigned_Long_10), N); end; when K_Unsigned_Long_Long => begin N := Make_Type_Conversion (RE (RE_Unsigned_Long_Long_10), N); end; when K_Short => begin N := Make_Type_Conversion (RE (RE_Short_10), N); end; when K_Unsigned_Short => begin N := Make_Type_Conversion (RE (RE_Unsigned_Short_10), N); end; when K_Float => begin N := Make_Type_Conversion (RE (RE_Float_10), N); end; when K_Double => begin N := Make_Type_Conversion (RE (RE_Double_10), N); end; when K_Long_Double => begin N := Make_Type_Conversion (RE (RE_Long_Double_10), N); end; when K_Char => begin N := Make_Type_Conversion (RE (RE_Char_10), N); end; when K_Octet => begin N := Make_Type_Conversion (RE (RE_Octet_10), N); end; when K_Boolean => begin N := Make_Type_Conversion (RE (RE_Boolean_10), N); end; when K_Fixed_Point_Type => declare FP_Type_Node : Node_Id; begin -- Getting the fixed point type FP_Type_Node := Expand_Designator (Type_Def_Node (BE_Node (Orig_Type))); N := Make_Type_Conversion (FP_Type_Node, N); end; when K_Enumeration_Type => declare Ada_Enum_Type : constant Node_Id := Expand_Designator (Type_Def_Node (BE_Node (Identifier (Orig_Type)))); M : Node_Id; begin if FEN.Kind (Var_Type) = K_Scoped_Name and then FEN.Kind (Reference (Var_Type)) /= K_Enumeration_Type then N := Make_Type_Conversion (Ada_Enum_Type, N); end if; -- Even if the type is not directly an enumeration and -- is defined basing on an enumeration, we still have -- access to the 'Pos' attribute. So there is no need -- to cast the variable to the original enumeration -- type. M := Make_Attribute_Reference (Ada_Enum_Type, A_Pos); M := Make_Subprogram_Call (M, New_List (N)); N := Make_Type_Conversion (RE (RE_Unsigned_Long_10), M); end; when K_String => begin if FEN.Kind (Var_Type) /= K_String then N := Make_Type_Conversion (RE (RE_String_0), N); end if; N := Make_Subprogram_Call (RE (RE_To_Standard_String), New_List (N)); end; when K_String_Type => declare Str_Package_Node : Node_Id; Str_Type : Node_Id; Str_Convert_Subp : Node_Id; begin -- Getting the instantiated package node Str_Package_Node := Defining_Identifier (Instantiation_Node (BE_Node (Orig_Type))); -- Getting the conversion subprogram Str_Type := Make_Selected_Component (Str_Package_Node, Make_Identifier (TN (T_Bounded_String))); Str_Convert_Subp := Make_Selected_Component (Str_Package_Node, Make_Identifier (SN (S_To_String))); N := Make_Type_Conversion (Str_Type, N); N := Make_Subprogram_Call (Str_Convert_Subp, New_List (N)); N := Make_Subprogram_Call (RE (RE_To_PolyORB_String), New_List (N)); end; when K_Sequence_Type => declare Seq_Package_Node : Node_Id; Seq_Type : Node_Id; begin -- Getting the instantiated package node in aligned -- backend. Seq_Package_Node := Expand_Designator (Instantiation_Node (BE_Node (Orig_Type))); -- Sequence type Seq_Type := Make_Selected_Component (Seq_Package_Node, Make_Identifier (TN (T_Sequence))); N := Make_Type_Conversion (Seq_Type, N); end; when others => null; end case; return N; end Cast_Variable_To_PolyORB_Aligned_Type; ------------------- -- Marshall_Args -- ------------------- procedure Marshall_Args (Stat : List_Id; Var_Type : Node_Id; Var : Node_Id; Var_Exp : Node_Id := No_Node) is Rewinded_Type : Node_Id; C : Node_Id; N : Node_Id; M : Node_Id; begin Rewinded_Type := FEU.Get_Original_Type_Specifier (Var_Type); case FEN.Kind (Rewinded_Type) is when K_Structure_Type => declare Member : Node_Id; begin Member := First_Entity (Members (Rewinded_Type)); while Present (Member) loop C := Make_Selected_Component (Var, Make_Identifier (IDL_Name (Identifier (First_Entity (Declarators (Member)))))); if Var_Exp /= No_Node then M := Make_Selected_Component (Var_Exp, Make_Identifier (IDL_Name (Identifier (First_Entity (Declarators (Member)))))); Marshall_Args (Stat, Type_Spec (Member), C, M); else Marshall_Args (Stat, Type_Spec (Member), C); end if; Member := Next_Entity (Member); end loop; return; end; when K_Union_Type => declare L : List_Id; Literal_Parent : Node_Id := No_Node; Choices : List_Id; Switch_Alternatives : List_Id; Switch_Node : Node_Id; Switch_Case : Node_Id; Has_Default : Boolean := False; begin Switch_Node := Make_Identifier (FEN.Switch_Name (Rewinded_Type)); if Var_Exp /= No_Node then Switch_Node := Make_Selected_Component (Var_Exp, Switch_Node); else Switch_Node := Make_Selected_Component (Var, Switch_Node); end if; C := FEU.Get_Original_Type_Specifier (Switch_Type_Spec (Rewinded_Type)); if FEN.Kind (C) = K_Enumeration_Type then Literal_Parent := Map_Expanded_Name (Scope_Entity (Identifier (C))); end if; Switch_Alternatives := New_List; Switch_Case := First_Entity (Switch_Type_Body (Rewinded_Type)); while Present (Switch_Case) loop Map_Choice_List (Labels (Switch_Case), Literal_Parent, Choices, Has_Default); L := New_List; C := Make_Selected_Component (Var, Make_Identifier (IDL_Name (Identifier (Declarator (Element (Switch_Case)))))); if Var_Exp /= No_Node then M := Make_Selected_Component (Var_Exp, Make_Identifier (IDL_Name (Identifier (Declarator (Element (Switch_Case)))))); Marshall_Args (L, Type_Spec (Element (Switch_Case)), C, M); else Marshall_Args (L, Type_Spec (Element (Switch_Case)), C); end if; -- Building the switch alternative Append_To (Switch_Alternatives, Make_Case_Statement_Alternative (Choices, L)); Switch_Case := Next_Entity (Switch_Case); end loop; -- Add an empty when others clause to keep the compiler happy if not Has_Default then Append_To (Switch_Alternatives, Make_Case_Statement_Alternative (No_List, No_List)); end if; N := Make_Case_Statement (Switch_Node, Switch_Alternatives); Append_To (Stat, N); return; end; when K_String => if Var_Exp /= No_Node then M := Cast_Variable_To_PolyORB_Aligned_Type (Var_Exp, Var_Type); else M := Cast_Variable_To_PolyORB_Aligned_Type (Var, Var_Type); end if; C := RE (RE_Nul); M := Make_Expression (M, Op_And_Symbol, C); C := Cast_Variable_To_PolyORB_Aligned_Type (Var, Var_Type); N := Make_Selected_Component (PN (P_Content), Fully_Qualified_Name (Var)); if Var_Exp /= No_Node then N := Make_Selected_Component (VN (V_Args_Out), Fully_Qualified_Name (N)); else N := Make_Selected_Component (VN (V_Args_In), Fully_Qualified_Name (N)); end if; N := Make_Assignment_Statement (N, M); Append_To (Stat, N); return; when K_Sequence_Type => declare Range_Constraint : Node_Id; Index_Node : Node_Id; K : Node_Id; begin Set_Str_To_Name_Buffer ("J"); Index_Node := Make_Defining_Identifier (Name_Find); if Var_Exp /= No_Node then N := Make_Subprogram_Call (RE (RE_Length_2), New_List (Var_Exp)); else N := Make_Subprogram_Call (RE (RE_Length_2), New_List (Var)); end if; N := Make_Type_Conversion (RE (RE_Unsigned_Long_10), N); Range_Constraint := Make_Range_Constraint (Make_Literal (Int1_Val), N); N := Make_Selected_Component (PN (P_Content), Fully_Qualified_Name (Var)); if Var_Exp /= No_Node then N := Make_Selected_Component (VN (V_Args_Out), Fully_Qualified_Name (N)); N := Make_Identifier (Fully_Qualified_Name (N)); N := Make_Subprogram_Call (N, New_List (Index_Node)); M := Make_Identifier (Fully_Qualified_Name (Var_Exp)); K := Make_Type_Conversion (RE (RE_Integer), Index_Node); M := Make_Subprogram_Call (RE (RE_Get_Element), New_List (M, K)); M := Cast_Variable_To_PolyORB_Aligned_Type (M, Type_Spec (Type_Spec (Declaration (Reference (Var_Type))))); N := Make_Assignment_Statement (N, M); else N := Make_Selected_Component (VN (V_Args_In), Fully_Qualified_Name (N)); N := Make_Identifier (Fully_Qualified_Name (N)); N := Make_Subprogram_Call (N, New_List (Index_Node)); M := Make_Identifier (Fully_Qualified_Name (Var)); K := Make_Type_Conversion (RE (RE_Integer), Index_Node); M := Make_Subprogram_Call (RE (RE_Get_Element), New_List (M, K)); M := Cast_Variable_To_PolyORB_Aligned_Type (M, Type_Spec (Type_Spec (Declaration (Reference (Var_Type))))); N := Make_Assignment_Statement (N, M); end if; N := Make_For_Statement (Index_Node, Range_Constraint, New_List (N)); Append_To (Stat, N); return; end; when K_Complex_Declarator => M := Make_Selected_Component (Defining_Identifier (Aligned_Package (Current_Entity)), Make_Identifier (IDL_Name (Identifier (Var_Type)))); M := Make_Subprogram_Call (M, New_List (Var)); when others => if Var_Exp /= No_Node then M := Cast_Variable_To_PolyORB_Aligned_Type (Var_Exp, Var_Type); else M := Cast_Variable_To_PolyORB_Aligned_Type (Var, Var_Type); end if; C := Cast_Variable_To_PolyORB_Aligned_Type (Var, Var_Type); end case; N := Make_Identifier (Fully_Qualified_Name (Var)); if Var_Exp /= No_Node then N := Make_Selected_Component (VN (V_Args_Out), Fully_Qualified_Name (Var)); else N := Make_Selected_Component (VN (V_Args_Out), Fully_Qualified_Name (Var)); end if; N := Make_Assignment_Statement (N, M); Append_To (Stat, N); end Marshall_Args; ----------------------------- -- Get_Discriminants_Value -- ----------------------------- procedure Get_Discriminants_Value (P : Node_Id; N : Node_Id; L : List_Id; Ret : Boolean := False) is Rewinded_Type : Node_Id; Var : Node_Id; M : Node_Id; C : Node_Id; begin -- Handle the case of non void operation having OUT parameters if FEN.Kind (P) = K_Parameter_Declaration then Var := Map_Defining_Identifier (Declarator (P)); else Var := Make_Defining_Identifier (PN (P_Returns)); end if; Rewinded_Type := FEU.Get_Original_Type_Specifier (N); case FEN.Kind (Rewinded_Type) is when K_Union_Type => declare Member : Node_Id; begin Member := First_Entity (Switch_Type_Body (Rewinded_Type)); while Present (Member) loop M := Make_Selected_Component (Var, Make_Defining_Identifier (IDL_Name (Identifier (Declarator (Element (Member)))))); Get_Discriminants_Value (M, Type_Spec (Element (Member)), L); Member := Next_Entity (Member); end loop; M := Make_Selected_Component (Var, Make_Identifier (FEN.Switch_Name (Rewinded_Type))); C := Switch_Type_Spec (Rewinded_Type); M := Cast_Variable_To_PolyORB_Aligned_Type (M, C); Append_To (L, M); end; when K_Structure_Type => declare Member : Node_Id; begin Member := First_Entity (Members (Rewinded_Type)); while Present (Member) loop M := Make_Selected_Component (Var, Make_Identifier (IDL_Name (Identifier (First_Entity (Declarators (Member)))))); Get_Discriminants_Value (M, Type_Spec (Member), L, Ret); Member := Next_Entity (Member); end loop; end; when K_String | K_Wide_String => C := Make_Attribute_Reference (Make_Subprogram_Call (RE (RE_To_Standard_String), New_List (Var)), A_Length); C := Make_Expression (C, Op_Plus, Make_Literal (Values.New_Integer_Value (1, 1, 10))); Append_To (L, C); when K_Sequence_Type => if not Present (Max_Size (Rewinded_Type)) then C := Make_Subprogram_Call (RE (RE_Length_2), New_List (Var)); C := Make_Type_Conversion (RE (RE_Unsigned_Long_10), C); Append_To (L, C); end if; when others => null; end case; end Get_Discriminants_Value; end Backend.BE_CORBA_Ada.Common;
reznikmm/matreshka
Ada
3,739
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Text_Animation_Steps_Attributes is pragma Preelaborate; type ODF_Text_Animation_Steps_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Text_Animation_Steps_Attribute_Access is access all ODF_Text_Animation_Steps_Attribute'Class with Storage_Size => 0; end ODF.DOM.Text_Animation_Steps_Attributes;
reznikmm/matreshka
Ada
3,709
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Text_Modification_Time_Elements is pragma Preelaborate; type ODF_Text_Modification_Time is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Text_Modification_Time_Access is access all ODF_Text_Modification_Time'Class with Storage_Size => 0; end ODF.DOM.Text_Modification_Time_Elements;
stcarrez/mat
Ada
6,509
ads
----------------------------------------------------------------------- -- mat-events-probes -- Event probes -- Copyright (C) 2014, 2015, 2023 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Containers; with Ada.Containers.Hashed_Maps; with Ada.Containers.Indefinite_Hashed_Maps; with Ada.Strings.Hash; with Ada.Finalization; with MAT.Types; with MAT.Events.Targets; with MAT.Readers; with MAT.Frames.Targets; package MAT.Events.Probes is ----------------- -- Abstract probe definition ----------------- type Probe_Type is abstract tagged limited private; type Probe_Type_Access is access all Probe_Type'Class; -- Extract the probe information from the message. procedure Extract (Probe : in Probe_Type; Params : in MAT.Events.Const_Attribute_Table_Access; Msg : in out MAT.Readers.Message_Type; Event : in out Target_Event_Type) is abstract; procedure Execute (Probe : in Probe_Type; Event : in out Target_Event_Type) is abstract; -- Update the Size and Prev_Id information in the event identified by <tt>Id</tt>. -- Update the event represented by <tt>Prev_Id</tt> so that its Next_Id refers -- to the <tt>Id</tt> event. procedure Update_Event (Probe : in Probe_Type; Id : in MAT.Events.Event_Id_Type; Size : in MAT.Types.Target_Size; Prev_Id : in MAT.Events.Event_Id_Type); ----------------- -- Probe Manager ----------------- type Probe_Manager_Type is abstract new Ada.Finalization.Limited_Controlled with private; type Probe_Manager_Type_Access is access all Probe_Manager_Type'Class; -- Initialize the probe manager instance. overriding procedure Initialize (Manager : in out Probe_Manager_Type); -- Register the probe to handle the event identified by the given name. -- The event is mapped to the given id and the attributes table is used -- to setup the mapping from the data stream attributes. procedure Register_Probe (Into : in out Probe_Manager_Type; Probe : in Probe_Type_Access; Name : in String; Id : in MAT.Events.Probe_Index_Type; Model : in MAT.Events.Const_Attribute_Table_Access); procedure Dispatch_Message (Client : in out Probe_Manager_Type; Msg : in out MAT.Readers.Message_Type); -- Read a list of event definitions from the stream and configure the reader. procedure Read_Event_Definitions (Client : in out Probe_Manager_Type; Msg : in out MAT.Readers.Message_Type); -- Get the target events. function Get_Target_Events (Client : in Probe_Manager_Type) return MAT.Events.Targets.Target_Events_Access; -- Get the target frames. function Get_Target_Frames (Client : in Probe_Manager_Type) return MAT.Frames.Targets.Target_Frames_Access; -- Read a message from the stream. procedure Read_Message (Reader : in out Probe_Manager_Type; Msg : in out MAT.Readers.Message_Type) is abstract; -- Get the size of a target address (4 or 8 bytes). function Get_Address_Size (Client : in Probe_Manager_Type) return MAT.Events.Attribute_Type; type Reader_List_Type is limited interface; type Reader_List_Type_Access is access all Reader_List_Type'Class; -- Initialize the target object to manage the memory slots, the stack frames -- and setup the reader to analyze the memory and other events. procedure Initialize (List : in out Reader_List_Type; Manager : in out Probe_Manager_Type'Class) is abstract; private type Probe_Type is abstract tagged limited record Owner : Probe_Manager_Type_Access := null; end record; -- Record a probe type Probe_Handler is record Probe : Probe_Type_Access; Id : MAT.Events.Probe_Index_Type; Attributes : MAT.Events.Const_Attribute_Table_Access; Mapping : MAT.Events.Attribute_Table_Ptr; end record; function Hash (Key : in MAT.Types.Uint16) return Ada.Containers.Hash_Type; package Probe_Maps is new Ada.Containers.Indefinite_Hashed_Maps (Key_Type => String, Element_Type => Probe_Handler, Hash => Ada.Strings.Hash, Equivalent_Keys => "="); -- Runtime handlers associated with the events. package Handler_Maps is new Ada.Containers.Hashed_Maps (Key_Type => MAT.Types.Uint16, Element_Type => Probe_Handler, Hash => Hash, Equivalent_Keys => "="); type Probe_Manager_Type is abstract new Ada.Finalization.Limited_Controlled with record Probes : Probe_Maps.Map; Handlers : Handler_Maps.Map; Version : MAT.Types.Uint16; Flags : MAT.Types.Uint16; Addr_Size : MAT.Events.Attribute_Type; Probe : MAT.Events.Attribute_Table_Ptr; Frame : MAT.Events.Frame_Info_Access; Events : MAT.Events.Targets.Target_Events_Access; Event : Target_Event_Type; Frames : MAT.Frames.Targets.Target_Frames_Access; end record; -- Read an event definition from the stream and configure the reader. procedure Read_Definition (Client : in out Probe_Manager_Type; Msg : in out MAT.Readers.Message); end MAT.Events.Probes;
AdaDoom3/wayland_ada_binding
Ada
4,259
adb
------------------------------------------------------------------------------ -- Copyright (C) 2015-2016, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify it -- -- under terms of the GNU General Public License as published by the Free -- -- Software Foundation; either version 3, or (at your option) any later -- -- version. This library is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- ------------------------------------------------------------------------------ with Ada.Unchecked_Conversion; with Ada.Unchecked_Deallocation; with System; package body Conts.Elements.Arrays is package body Fat_Pointers is type C_Fat_Pointer is record Data, Bounds : System.Address; end record; type Array_Access is access all Array_Type; pragma No_Strict_Aliasing (Array_Access); pragma Warnings (Off); -- strict aliasing function To_FP is new Ada.Unchecked_Conversion (C_Fat_Pointer, Array_Access); pragma Warnings (On); -- strict aliasing procedure Set (FP : in out Fat_Pointer; A : Array_Type) is begin FP.Data (1 .. A'Length) := A; FP.Bounds := (1, A'Length); end Set; function Get (FP : not null access constant Fat_Pointer) return Constant_Ref_Type is F : constant C_Fat_Pointer := (FP.Data'Address, FP.Bounds'Address); AC : constant Array_Access := To_FP (F); begin return Constant_Ref_Type'(Element => AC); end Get; end Fat_Pointers; package body Impl is procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Array_Type, Array_Access); --------------- -- To_Stored -- --------------- function To_Stored (A : Array_Type) return Stored_Array is begin if A'Length <= Short_Size then return S : Stored_Array (Short_Array) do Fat_Pointers.Set (S.Short, A); end return; else return S : Stored_Array (Long_Array) do S.Long := new Array_Type'(A); end return; end if; end To_Stored; ------------ -- To_Ref -- ------------ function To_Ref (S : Stored_Array) return Constant_Ref_Type is begin if S.Kind = Short_Array then return Fat_Pointers.Get (S.Short'Access); else return Constant_Ref_Type'(Element => S.Long); end if; end To_Ref; ---------- -- Copy -- ---------- function Copy (S : Stored_Array) return Stored_Array is begin case S.Kind is when Short_Array => return S; when Long_Array => return R : Stored_Array (Long_Array) do R.Long := new Array_Type'(S.Long.all); end return; end case; end Copy; ------------- -- Release -- ------------- procedure Release (S : in out Stored_Array) is begin if S.Kind = Long_Array then Unchecked_Free (S.Long); end if; end Release; end Impl; end Conts.Elements.Arrays;
reznikmm/matreshka
Ada
3,709
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Text_Page_Variable_Set_Elements is pragma Preelaborate; type ODF_Text_Page_Variable_Set is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Text_Page_Variable_Set_Access is access all ODF_Text_Page_Variable_Set'Class with Storage_Size => 0; end ODF.DOM.Text_Page_Variable_Set_Elements;
faicaltoubali/ENSEEIHT
Ada
5,024
adb
with arbre_binaire; with Ada.Text_IO ; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; procedure test_arbre_binaire is procedure Afficher_Entier ( entier : Integer) is begin Put( entier ); end Afficher_Entier ; package arbre_binaire_entier is new arbre_binaire( Integer, Afficher_Entier ); use arbre_binaire_entier ; Arbre : T_Abr; -- Construire un arbre binaire, l'arbre à construire est le suivant : -- -- 1 -- 3 2 -- 7 6 5 4 -- Afficher l'arbre binaire après construction procedure Construire_Arbre_Binaire ( Arbre : out T_Abr ) is begin Put("Construire l'arbre");New_Line; Initialiser ( Arbre ); Pragma Assert ( Vide ( Arbre ) ); Pragma Assert ( Taille ( Arbre ) = 0 ); Creer_Arbre ( Arbre , 1 ); Ajouter_Fils_Droit ( Arbre , 1, 2 ); Ajouter_Fils_Gauche ( Arbre , 1,3 ); Ajouter_Fils_Droit ( Arbre,2, 4); Ajouter_Fils_Gauche ( Arbre,2, 5); Ajouter_Fils_Droit (Arbre , 3 , 6); Ajouter_Fils_Gauche ( Arbre , 3 , 7); Pragma Assert ( Not Vide ( Arbre ) ); Pragma Assert ( Taille ( Arbre ) = 7 ); Afficher_Arbre_Binaire ( Arbre , 1 ); New_Line; end Construire_Arbre_Binaire; -- Vider l'arbre binaire construit procedure Vider_Arbre_Binaire_Test is begin Put ("Tester Vider_Arbre_Test");New_Line; Construire_Arbre_Binaire ( Arbre ); Vider_Arbre ( Arbre ); Pragma Assert ( Vide ( Arbre )); Pragma Assert ( Taille ( Arbre ) = 0 ); Afficher_Arbre_Binaire ( Arbre , 1 );New_Line; Put_line ("=> Succès : Fin du test de Vider_Arbre_Test");New_Line; end Vider_Arbre_Binaire_Test; -- Modifier l'arbre binaire construit par le suivant : -- -- 1 -- 3 15 -- 0 8 10 4 -- Afficher l'arbre binaire après construction -- Vider l'arbre après la fin du test procedure Modifier_Arbre_Binaire_Test is begin Put ( "Tester Modifier Arbre_Binaire_Test");New_Line; Construire_Arbre_Binaire ( Arbre ); Modifier ( Arbre , 2 , 15 ); Modifier ( Arbre , 5 , 10 ); Modifier ( Arbre , 6 , 8 ); Modifier ( Arbre , 7 , 0 ); Pragma Assert ( Not Vide( Arbre ) ); Pragma Assert ( Taille ( Arbre ) = 7 ); Afficher_Arbre_Binaire ( Arbre , 1 ); New_Line ; Pragma Assert ( Avoir_Cle ( Arbre_Cle ( Arbre , 15 ),15) = 15 ); Pragma Assert ( Avoir_Cle ( Arbre_Cle ( Arbre , 1 ),1) = 1 ); Pragma Assert ( Avoir_Cle ( Arbre_Cle ( Arbre , 3 ),3) = 3 ); Put_line ("=> Succès : Fin du test de Modifier_Arbre_Binaire_Test"); New_Line; Vider_Arbre ( Arbre ); Pragma Assert ( Vide ( Arbre )); New_Line; end Modifier_Arbre_Binaire_Test ; -- Modifier l'arbre binaire construit en supprimant quelques clés . -- -- 1 -- 3 2 -- 7 4 -- Afficher l'arbre binaire après construction -- Vider l'arbre après la fin du test procedure Supprimer_Arbre_Binaire_Test is begin Put ("Tester Supprimer_Arbre_Binaire_Test" );New_line; Construire_Arbre_Binaire ( Arbre ); Supprimer ( Arbre , 5 ); Pragma Assert ( Taille ( Arbre ) = 6 ); Supprimer ( Arbre , 6 ); Pragma Assert ( Taille ( Arbre ) = 5 ); Afficher_Arbre_Binaire ( Arbre , 1 ); Vider_Arbre ( Arbre ); Pragma Assert ( Vide ( Arbre ) ); New_line; Put_line ("=> Succès : Fin du test Supprimer_Arbre_Binaire_Test" );New_line; end Supprimer_Arbre_Binaire_Test; -- Modifier l'arbre binaire construit en supprimant quelques clés . -- -- 1 -- 3 2 -- 5 10 -- -- Verifier si les clés 4 ,6 et 7 existe encore après la modification -- Afficher l'arbre binaire après construction -- Vider l'arbre après la fin du test procedure Existe_Arbre_Binaire_Test is begin Put ("Tester Existe_Arbre_Binaire_Test ");New_Line; Construire_Arbre_Binaire ( Arbre ); Modifier ( Arbre , 4 , 10 ); Pragma Assert ( not Existe ( Arbre , 4 )); Pragma Assert ( Existe ( Arbre , 10 )); Supprimer ( Arbre , 6 ); Supprimer ( Arbre , 7 ); Pragma Assert ( not Existe ( Arbre , 6 )); Pragma Assert ( not Existe ( Arbre , 7 )); Afficher_Arbre_Binaire ( Arbre , 1 );New_Line; Vider_Arbre ( Arbre ); Pragma Assert ( Taille ( Arbre ) = 0 ); Put_line ("=> Succès : Fin du test de Existe_Arbre_Binaire");New_Line; end Existe_Arbre_Binaire_Test; begin Construire_Arbre_Binaire ( Arbre ); Vider_Arbre_Binaire_Test; Modifier_Arbre_Binaire_Test; Supprimer_Arbre_Binaire_Test; Existe_Arbre_Binaire_Test; end test_arbre_binaire;
stcarrez/dynamo
Ada
13,396
ads
----------------------------------------------------------------------- -- gen-model-packages -- Packages holding model, query representation -- Copyright (C) 2009 - 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Containers.Hashed_Maps; with Ada.Strings.Unbounded.Hash; with Util.Beans.Objects; with Util.Beans.Objects.Vectors; with Util.Strings.Sets; with Gen.Model.List; with Gen.Model.Mappings; limited with Gen.Model.Enums; limited with Gen.Model.Tables; limited with Gen.Model.Queries; limited with Gen.Model.Beans; limited with Gen.Model.Stypes; package Gen.Model.Packages is -- ------------------------------ -- Model Definition -- ------------------------------ -- The <b>Model_Definition</b> contains the complete model from one or -- several files. It maintains a list of Ada packages that must be generated. type Model_Definition is new Definition with private; type Model_Definition_Access is access all Model_Definition'Class; -- Validate the definition by checking and reporting problems to the logger interface. overriding procedure Validate (Def : in out Model_Definition; Log : in out Util.Log.Logging'Class); -- ------------------------------ -- Package Definition -- ------------------------------ -- The <b>Package_Definition</b> holds the tables, queries and other information -- that must be generated for a given Ada package. type Package_Definition is new Definition with private; type Package_Definition_Access is access all Package_Definition'Class; -- Get the value identified by the name. -- If the name cannot be found, the method should return the Null object. overriding function Get_Value (From : in Package_Definition; Name : in String) return UBO.Object; -- Prepare the generation of the package: -- o identify the column types which are used -- o build a list of package for the with clauses. overriding procedure Prepare (O : in out Package_Definition); -- Validate the definition by checking and reporting problems to the logger interface. overriding procedure Validate (Def : in out Package_Definition; Log : in out Util.Log.Logging'Class); -- Initialize the package instance overriding procedure Initialize (O : in out Package_Definition); -- Find the type identified by the name. function Find_Type (From : in Package_Definition; Name : in UString) return Gen.Model.Mappings.Mapping_Definition_Access; -- Get the model which contains all the package definitions. function Get_Model (From : in Package_Definition) return Model_Definition_Access; -- Returns True if the package is a pre-defined package and must not be generated. function Is_Predefined (From : in Package_Definition) return Boolean; -- Set the package as a pre-defined package. procedure Set_Predefined (From : in out Package_Definition); -- Get the value identified by the name. -- If the name cannot be found, the method should return the Null object. overriding function Get_Value (From : Model_Definition; Name : String) return UBO.Object; -- Initialize the model definition instance. overriding procedure Initialize (O : in out Model_Definition); -- Returns True if the model contains at least one package. function Has_Packages (O : in Model_Definition) return Boolean; -- Register or find the package knowing its name procedure Register_Package (O : in out Model_Definition; Name : in UString; Result : out Package_Definition_Access); -- Register the declaration of the given enum in the model. procedure Register_Enum (O : in out Model_Definition; Enum : access Gen.Model.Enums.Enum_Definition'Class); -- Register the declaration of the given data type in the model. procedure Register_Stype (O : in out Model_Definition; Stype : access Gen.Model.Stypes.Stype_Definition'Class); -- Register the declaration of the given table in the model. procedure Register_Table (O : in out Model_Definition; Table : access Gen.Model.Tables.Table_Definition'Class); -- Register the declaration of the given query in the model. procedure Register_Query (O : in out Model_Definition; Table : access Gen.Model.Queries.Query_File_Definition'Class); -- Register the declaration of the given bean in the model. procedure Register_Bean (O : in out Model_Definition; Bean : access Gen.Model.Beans.Bean_Definition'Class); -- Register a type mapping. The <b>From</b> type describes a type in the XML -- configuration files (hibernate, query, ...) and the <b>To</b> represents the -- corresponding Ada type. procedure Register_Type (O : in out Model_Definition; From : in String; To : in String); -- Find the type identified by the name. function Find_Type (From : in Model_Definition; Name : in UString) return Gen.Model.Mappings.Mapping_Definition_Access; -- Set the directory name associated with the model. This directory name allows to -- save and build a model in separate directories for the application, the unit tests -- and others. procedure Set_Dirname (O : in out Model_Definition; Target_Dir : in String; Model_Dir : in String); -- Get the directory name associated with the model. function Get_Dirname (O : in Model_Definition) return String; -- Get the directory name which contains the model. function Get_Model_Directory (O : in Model_Definition) return String; -- Enable the generation of the Ada package given by the name. By default all the Ada -- packages found in the model are generated. When called, this enables the generation -- only for the Ada packages registered here. procedure Enable_Package_Generation (Model : in out Model_Definition; Name : in String); -- Returns True if the generation is enabled for the given package name. function Is_Generation_Enabled (Model : in Model_Definition; Name : in String) return Boolean; -- Iterate over the model tables. procedure Iterate_Tables (Model : in Model_Definition; Process : not null access procedure (Item : in out Tables.Table_Definition)); -- Iterate over the model enums. procedure Iterate_Enums (Model : in Model_Definition; Process : not null access procedure (Item : in out Enums.Enum_Definition)); -- Prepare the generation of the package: -- o identify the column types which are used -- o build a list of package for the with clauses. overriding procedure Prepare (O : in out Model_Definition); package Package_Map is new Ada.Containers.Hashed_Maps (Key_Type => UString, Element_Type => Package_Definition_Access, Hash => Ada.Strings.Unbounded.Hash, Equivalent_Keys => "="); subtype Package_Cursor is Package_Map.Cursor; -- Get the first package of the model definition. function First (From : Model_Definition) return Package_Cursor; -- Returns true if the package cursor contains a valid package function Has_Element (Position : Package_Cursor) return Boolean renames Package_Map.Has_Element; -- Returns the package definition. function Element (Position : Package_Cursor) return Package_Definition_Access renames Package_Map.Element; -- Move the iterator to the next package definition. procedure Next (Position : in out Package_Cursor) renames Package_Map.Next; private package Table_List is new Gen.Model.List (T => Definition, T_Access => Definition_Access); -- Returns False if the <tt>Left</tt> table does not depend on <tt>Right</tt>. -- Returns True if the <tt>Left</tt> table depends on the <tt>Right</tt> table. function Dependency_Compare (Left, Right : in Definition_Access) return Boolean; -- Sort the tables on their dependency. procedure Dependency_Sort is new Table_List.Sort_On ("<" => Dependency_Compare); subtype Table_List_Definition is Table_List.List_Definition; subtype Enum_List_Definition is Table_List.List_Definition; subtype Types_List_Definition is Table_List.List_Definition; subtype Stype_List_Definition is Table_List.List_Definition; type List_Object is new Util.Beans.Basic.List_Bean with record Values : UBO.Vectors.Vector; Row : Natural; Value_Bean : UBO.Object; end record; -- Get the number of elements in the list. overriding function Get_Count (From : in List_Object) return Natural; -- Set the current row index. Valid row indexes start at 1. overriding procedure Set_Row_Index (From : in out List_Object; Index : in Natural); -- Get the element at the current row index. overriding function Get_Row (From : in List_Object) return UBO.Object; -- Get the value identified by the name. -- If the name cannot be found, the method should return the Null object. overriding function Get_Value (From : in List_Object; Name : in String) return UBO.Object; type Package_Definition is new Definition with record -- Enums defined in the package. Enums : aliased Enum_List_Definition; Enums_Bean : UBO.Object; -- Simple data types defined in the package. Stypes : aliased Stype_List_Definition; Stypes_Bean : UBO.Object; -- Hibernate tables Tables : aliased Table_List_Definition; Tables_Bean : UBO.Object; -- Custom queries Queries : aliased Table_List_Definition; Queries_Bean : UBO.Object; -- Ada Beans Beans : aliased Table_List_Definition; Beans_Bean : UBO.Object; -- A list of external packages which are used (used for with clause generation). Used_Spec_Types : aliased List_Object; Used_Spec : UBO.Object; -- A list of external packages which are used (used for with clause generation). Used_Body_Types : aliased List_Object; Used_Body : UBO.Object; -- A map of all types defined in this package. Types : Gen.Model.Mappings.Mapping_Maps.Map; -- The base name for the package (ex: gen-model-users) Base_Name : UString; -- The global model (used to resolve types from other packages). Model : Model_Definition_Access; -- True if the package uses Ada.Calendar.Time Uses_Calendar_Time : Boolean := False; -- True if the package is a pre-defined package (ie, defined by a UML profile). Is_Predefined : Boolean := False; end record; type Model_Definition is new Definition with record -- List of all enums. Enums : aliased Enum_List_Definition; Enums_Bean : UBO.Object; -- Simple data types defined in the package. Stypes : aliased Stype_List_Definition; Stypes_Bean : UBO.Object; -- List of all tables. Tables : aliased Table_List_Definition; Tables_Bean : UBO.Object; -- List of all queries. Queries : aliased Table_List_Definition; Queries_Bean : UBO.Object; -- Ada Beans Beans : aliased Table_List_Definition; Beans_Bean : UBO.Object; -- Map of all packages. Packages : Package_Map.Map; -- Directory associated with the model ('src', 'samples', 'regtests', ...). Dir_Name : UString; -- Directory that contains the SQL and model files. DB_Name : UString; -- When not empty, a list of packages that must be taken into account for the generation. -- By default all packages and tables defined in the model are generated. Gen_Packages : Util.Strings.Sets.Set; end record; end Gen.Model.Packages;
Rodeo-McCabe/orka
Ada
17,257
ads
-- SPDX-License-Identifier: BSD-3-Clause -- -- Copyright (c) 2017 Eric Bruneton -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions -- are met: -- 1. Redistributions of source code must retain the above copyright -- notice, this list of conditions and the following disclaimer. -- 2. Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- 3. Neither the name of the copyright holders 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. -- The shader returned by Get_Shader provides the following -- functions (that you need to forward declare in your own shaders to be able to -- compile them separately): -- -- // Returns the radiance of the Sun, outside the atmosphere. -- vec3 GetSolarRadiance(); -- -- // Returns the sky radiance along the segment from 'camera' to the nearest -- // atmosphere boundary in direction 'view_ray', as well as the transmittance -- // along this segment. -- vec3 GetSkyRadiance(vec3 camera, vec3 view_ray, double shadow_length, -- vec3 sun_direction, out vec3 transmittance, out bool intersects_ground); -- -- // Returns the sky radiance along the segment from 'camera' to 'p', as well as -- // the transmittance along this segment. -- vec3 GetSkyRadianceToPoint(vec3 camera, vec3 p, double shadow_length, -- vec3 sun_direction, out vec3 transmittance); -- -- // Returns the sun and sky irradiance received on a surface patch located at 'p' -- // and whose normal vector is 'normal'. -- vec3 GetSunAndSkyIrradiance(vec3 p, vec3 normal, vec3 sun_direction, -- out vec3 sky_irradiance); -- -- // Returns the luminance of the Sun, outside the atmosphere. -- vec3 GetSolarLuminance(); -- -- // Returns the sky luminance along the segment from 'camera' to the nearest -- // atmosphere boundary in direction 'view_ray', as well as the transmittance -- // along this segment. -- vec3 GetSkyLuminance(vec3 camera, vec3 view_ray, double shadow_length, -- vec3 sun_direction, out vec3 transmittance, out bool intersects_ground); -- -- // Returns the sky luminance along the segment from 'camera' to 'p', as well as -- // the transmittance along this segment. -- vec3 GetSkyLuminanceToPoint(vec3 camera, vec3 p, double shadow_length, -- vec3 sun_direction, out vec3 transmittance); -- -- // Returns the sun and sky illuminance received on a surface patch located at -- // 'p' and whose normal vector is 'normal'. -- vec3 GetSunAndSkyIlluminance(vec3 p, vec3 normal, vec3 sun_direction, -- out vec3 sky_illuminance); -- -- where -- -- - camera and p must be expressed in a reference frame where the planet center -- is at the origin, and measured in the unit passed to the constructor's -- length_unit_in_meters argument. camera can be in space, but p must be -- inside the atmosphere -- -- - view_ray, sun_direction and normal are unit direction vectors expressed -- in the same reference frame (with sun_direction pointing *towards* the Sun) -- -- - shadow_length is the length along the segment which is in shadow, measured -- in the unit passed to the constructor's length_unit_in_meters argument -- -- and where -- -- - the first 4 functions return spectral radiance and irradiance values -- (in $W.m^{-2}.sr^{-1}.nm^{-1}$ and $W.m^{-2}.nm^{-1}$), at the 3 wavelengths -- K_Lambda_R, K_Lambda_G, K_Lambda_B (in this order) -- -- - the other functions return luminance and illuminance values (in -- $cd.m^{-2}$ and $lx$) in linear [sRGB](https://en.wikipedia.org/wiki/SRGB) -- space (i.e. before adjustments for gamma correction) -- -- - all the functions return the (unitless) transmittance of the atmosphere -- along the specified segment at the 3 wavelengths K_Lambda_R, -- K_Lambda_G, K_Lambda_B (in this order) -- -- Note: The precomputed atmosphere textures can store either irradiance -- or illuminance values (see the Num_Precomputed_Wavelengths parameter): -- -- - when using irradiance values, the RGB channels of these textures contain -- spectral irradiance values, in $W.m^{-2}.nm^{-1}$, at the 3 wavelengths -- K_Lambda_R, K_Lambda_G, K_Lambda_B (in this order). The API functions -- returning radiance values return these precomputed values (times the -- phase functions), while the API functions returning luminance values use -- the approximation described in -- "A Qualitative and Quantitative Evaluation of 8 Clear Sky Models" [1], -- section 14.3, to convert 3 radiance values to linear sRGB luminance values -- -- - when using illuminance values, the RGB channels of these textures contain -- illuminance values, in $lx$, in linear sRGB space. These illuminance values -- are precomputed as described in -- "Real-time Spectral Scattering in Large-scale Natural Participating Media" [2], -- section 4.4 (i.e. Num_Precomputed_Wavelengths irradiance values are -- precomputed, and then converted to sRGB via a numerical integration of this -- spectrum with the CIE color matching functions). The API functions returning -- luminance values return these precomputed values (times the phase functions), -- while *the API functions returning radiance values are not provided* -- -- [1] https://arxiv.org/pdf/1612.04336.pdf -- [2] http://www.oskee.wz.cz/stranka/uploads/SCCG10ElekKmoch.pdf private with GL.Low_Level.Enums; private with GL.Objects.Textures; private with GL.Objects.Samplers; with Ada.Containers.Vectors; with GL.Types; with Orka.Resources.Locations; with Orka.Rendering.Programs.Modules; package Orka.Features.Atmosphere is pragma Preelaborate; type Luminance_Type is (None, Approximate, Precomputed); use GL.Types; type Density_Profile_Layer is record Width, Exp_Term, Exp_Scale, Linear_Term, Constant_Term : Double := 0.0; end record; -- An atmosphere layer of Width (in m), and whose density is defined as -- Exp_Term * exp(Exp_Scale * h) + Linear_Term * h + Constant_Term, -- clamped to [0,1], and where h is the altitude (in m). Exp_Term and -- Constant_Term are unitless, while Exp_Scale and Linear_Term are in m^-1. use type Ada.Containers.Count_Type; package Double_Vectors is new Ada.Containers.Vectors (Natural, Double); package Density_Vectors is new Ada.Containers.Vectors (Natural, Density_Profile_Layer); type Model_Data (Samples : Ada.Containers.Count_Type) is record Luminance : Luminance_Type; Wavelengths : Double_Vectors.Vector; -- The wavelength values, in nanometers, and sorted in increasing order, for -- which the solar_irradiance, rayleigh_scattering, mie_scattering, -- mie_extinction and ground_albedo samples are provided. If your shaders -- use luminance values (as opposed to radiance values, see above), use a -- large number of wavelengths (e.g. between 15 and 50) to get accurate -- results (this number of wavelengths has absolutely no impact on the -- shader performance). Solar_Irradiance : Double_Vectors.Vector; -- Solar irradiance at the top of the atmosphere, in W/m^2/nm. This -- vector must have the same size as the wavelengths parameter. Sun_Angular_Radius : Double; -- Sun's angular radius in radians. Warning: the implementation uses -- approximations that are valid only if this value is smaller than 0.1. Bottom_Radius : Double; -- Distance between the planet center and the bottom of the atmosphere, in m Top_Radius : Double; -- Distance between the planet center and the top of the atmosphere, in m Rayleigh_Density : Density_Vectors.Vector; -- The density profile of air molecules, i.e. a function from altitude to -- dimensionless values between 0 (null density) and 1 (maximum density). -- Layers must be sorted from bottom to top. The width of the last layer is -- ignored, i.e. it always extend to the top atmosphere boundary. At most 2 -- layers can be specified. Rayleigh_Scattering : Double_Vectors.Vector; -- The scattering coefficient of air molecules at the altitude where their -- density is maximum (usually the bottom of the atmosphere), as a function -- of wavelength, in m^-1. The scattering coefficient at altitude h is equal -- to 'rayleigh_scattering' times 'rayleigh_density' at this altitude. This -- vector must have the same size as the wavelengths parameter. Mie_Density : Density_Vectors.Vector; -- The density profile of aerosols, i.e. a function from altitude to -- dimensionless values between 0 (null density) and 1 (maximum density). -- Layers must be sorted from bottom to top. The width of the last layer is -- ignored, i.e. it always extend to the top atmosphere boundary. At most 2 -- layers can be specified. Mie_Scattering : Double_Vectors.Vector; -- The scattering coefficient of aerosols at the altitude where their -- density is maximum (usually the bottom of the atmosphere), as a function -- of wavelength, in m^-1. The scattering coefficient at altitude h is equal -- to 'mie_scattering' times 'mie_density' at this altitude. This vector -- must have the same size as the wavelengths parameter. Mie_Extinction : Double_Vectors.Vector; -- The extinction coefficient of aerosols at the altitude where their -- density is maximum (usually the bottom of the atmosphere), as a function -- of wavelength, in m^-1. The extinction coefficient at altitude h is equal -- to 'mie_extinction' times 'mie_density' at this altitude. This vector -- must have the same size as the wavelengths parameter. Mie_Phase_Function_G : Double; -- The asymetry parameter for the Cornette-Shanks phase function for the -- aerosols. Absorption_Density : Density_Vectors.Vector; -- The density profile of air molecules that absorb light (e.g. ozone), i.e. -- a function from altitude to dimensionless values between 0 (null density) -- and 1 (maximum density). Layers must be sorted from bottom to top. The -- width of the last layer is ignored, i.e. it always extend to the top -- atmosphere boundary. At most 2 layers can be specified. Absorption_Extinction : Double_Vectors.Vector; -- The extinction coefficient of molecules that absorb light (e.g. ozone) at -- the altitude where their density is maximum, as a function of wavelength, -- in m^-1. The extinction coefficient at altitude h is equal to -- 'absorption_extinction' times 'absorption_density' at this altitude. This -- vector must have the same size as the wavelengths parameter. Ground_Albedo : Double_Vectors.Vector; -- The average albedo of the ground, as a function of wavelength. This -- vector must have the same size as the wavelengths parameter. Max_Sun_Zenith_Angle : Double; -- The maximum Sun zenith angle for which atmospheric scattering must be -- precomputed, in radians (for maximum precision, use the smallest Sun -- zenith angle yielding negligible sky light radiance values. For instance, -- for the Earth case, 102 degrees is a good choice for most cases (120 -- degrees is necessary for very high exposure values). Length_Unit_In_Meters : Double; -- The length unit used in your shaders and meshes. This is the length unit -- which must be used when calling the atmosphere model shader functions. Num_Precomputed_Wavelengths : GL.Types.UInt; -- The number of wavelengths for which atmospheric scattering must be -- precomputed (the temporary GPU memory used during precomputations, and -- the GPU memory used by the precomputed results, is independent of this -- number, but the precomputation time is directly proportional to this -- number): -- - if this number is less than or equal to 3, scattering is precomputed -- for 3 wavelengths, and stored as irradiance values. Then both the -- radiance-based and the luminance-based API functions are provided (see -- the above note). -- - otherwise, scattering is precomputed for this number of wavelengths -- (rounded up to a multiple of 3), integrated with the CIE color matching -- functions, and stored as illuminance values. Then only the -- luminance-based API functions are provided (see the above note). Combine_Scattering_Textures : Boolean; -- Whether to pack the (red component of the) single Mie scattering with the -- Rayleigh and multiple scattering in a single texture, or to store the -- (3 components of the) single Mie scattering in a separate texture. Half_Precision : Boolean; -- Whether to use half precision floats (16 bits) or single precision floats -- (32 bits) for the precomputed textures. Half precision is sufficient for -- most cases, except for very high exposure values. end record with Dynamic_Predicate => Model_Data.Rayleigh_Density.Length <= 2 and Model_Data.Absorption_Density.Length <= 2 and Model_Data.Sun_Angular_Radius < 0.1 and Model_Data.Wavelengths.Length = Model_Data.Samples and Model_Data.Solar_Irradiance.Length = Model_Data.Samples and Model_Data.Rayleigh_Scattering.Length = Model_Data.Samples and Model_Data.Mie_Scattering.Length = Model_Data.Samples and Model_Data.Mie_Extinction.Length = Model_Data.Samples and Model_Data.Absorption_Extinction.Length = Model_Data.Samples and Model_Data.Ground_Albedo.Length = Model_Data.Samples; type Precomputed_Textures is private; procedure Bind_Textures (Object : Precomputed_Textures); type Model (Data : not null access constant Model_Data) is tagged limited private; function Create_Model (Data : not null access constant Model_Data; Location : Resources.Locations.Location_Ptr) return Model; function Compute_Textures (Object : Model; Scattering_Orders : Natural := 4) return Precomputed_Textures; function Get_Shader (Object : Model) return Rendering.Programs.Modules.Module; procedure Convert_Spectrum_To_Linear_SRGB (Data : Model_Data; R, G, B : out Double); -- Utility method to convert a function of the wavelength to linear sRGB -- -- Wavelengths and solar irradiance must have the same size. The integral of -- Spectrum times each CIE_2_Deg_Color_Matching_Functions (and times -- Max_Luminous_Efficacy) is computed to get XYZ values, which are then -- converted to linear sRGB with the XYZ_To_SRGB matrix. -- -- For white balance, divide R, G, and B by the average of the three numbers private package Textures renames GL.Objects.Textures; package LE renames GL.Low_Level.Enums; type Precomputed_Textures is record Sampler : GL.Objects.Samplers.Sampler; Combine_Scattering : Boolean; Transmittance_Texture : Textures.Texture (LE.Texture_2D); Scattering_Texture : Textures.Texture (LE.Texture_3D); Irradiance_Texture : Textures.Texture (LE.Texture_2D); Optional_Single_Mie_Scattering_Texture : Textures.Texture (LE.Texture_3D); -- Unused if Combine_Scattering is True end record; type Model (Data : not null access constant Model_Data) is tagged limited record Data_Definitions : Resources.Byte_Array_Pointers.Pointer; Data_Functions : Resources.Byte_Array_Pointers.Pointer; Location : Resources.Locations.Location_Access; Sky_K_R, Sky_K_G, Sky_K_B : GL.Types.Double; Sun_K_R, Sun_K_G, Sun_K_B : GL.Types.Double; end record; function Create_Sampler return GL.Objects.Samplers.Sampler; K_Lambda_Min : constant Double := 360.0; K_Lambda_Max : constant Double := 830.0; end Orka.Features.Atmosphere;
Fabien-Chouteau/tiled-code-gen
Ada
4,751
ads
------------------------------------------------------------------------------ -- -- -- tiled-code-gen -- -- -- -- Copyright (C) 2018 Fabien Chouteau -- -- -- -- -- -- 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 DOM.Core; with TCG.Tilesets; private with Ada.Containers.Vectors; package TCG.Object_Groups is type Object_Kind is (Rectangle_Obj, Point_Obj, Ellipse_Obj, Polygon_Obj, Tile_Obj, Text_Obj); type Point is record X, Y : Float; end record; type Polygon is array (Positive range <>) of Point; type Polygon_Access is access all Polygon; type String_Access is access all String; type Object (Kind : Object_Kind := Rectangle_Obj) is record Name : String_Access; Id : Natural; Pt : Point; Width, Height : Float; Points : Polygon_Access; Str : String_Access; Flip_Vertical : Boolean; Flip_Horizontal : Boolean; Tile_Id : TCG.Tilesets.Map_Tile_Id; end record; type Object_Group_Id is new Integer; type Object_Group is private; No_Layer : constant Object_Group; function Load (Root : DOM.Core.Node) return Object_Group; function Name (This : Object_Group) return String with Pre => This /= No_Layer; function Id (This : Object_Group) return Object_Group_Id with Pre => This /= No_Layer; function Length (This : Object_Group) return Natural; function First_Index (This : Object_Group) return Natural with Pre => This /= No_Layer and then Length (This) /= 0; function Last_Index (This : Object_Group) return Natural with Pre => This /= No_Layer and then Length (This) /= 0; function Get_Object (This : Object_Group; Index : Natural) return Object with Pre => This /= No_Layer and then Length (This) /= 0 and then Index in First_Index (This) .. Last_Index (This); private package Object_Vector_Package is new Ada.Containers.Vectors (Natural, Object); type Group_Data is record Name : String_Access := null; Id : Object_Group_Id; Objects : Object_Vector_Package.Vector; end record; type Object_Group is access all Group_Data; No_Layer : constant Object_Group := null; end TCG.Object_Groups;
AdaCore/libadalang
Ada
133
adb
procedure Test is X : Integer; B : Boolean := ">=" (Left => X, Right => X); pragma Test_Statement; begin null; end Test;
ohenley/awt
Ada
6,439
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2021 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with Ada.Finalization; with Ada.Strings.Unbounded; with Wayland.Cursor; with Wayland.Enums.Client; with Wayland.Protocols.Client; with Wayland.Protocols.Idle_Inhibit_Unstable_V1; with Wayland.Protocols.Pointer_Constraints_Unstable_V1; with Wayland.Protocols.Presentation_Time; with Wayland.Protocols.Relative_Pointer_Unstable_V1; with Wayland.Protocols.Xdg_Decoration_Unstable_V1; with Wayland.Protocols.Xdg_Shell; with AWT.Inputs; with AWT.Monitors; with AWT.Wayland.Windows; private package AWT.Registry is pragma Preelaborate; pragma Elaborate_Body; UTF_8_Mime_Type : constant String := "text/plain;charset=utf-8"; URIs_Mime_Type : constant String := "text/uri-list"; subtype Unsigned_32 is Standard.Wayland.Unsigned_32; package SU renames Ada.Strings.Unbounded; package WC renames Standard.Wayland.Cursor; package WE renames Standard.Wayland.Enums; package WP renames Standard.Wayland.Protocols; package II renames WP.Idle_Inhibit_Unstable_V1; package RP renames WP.Relative_Pointer_Unstable_V1; package XD renames WP.Xdg_Decoration_Unstable_V1; package PC renames WP.Pointer_Constraints_Unstable_V1; type Seat_Devices; type Seat_With_Seat (Seat : not null access Seat_Devices) is new WP.Client.Seat with null record; type Keyboard_With_Seat (Seat : not null access Seat_Devices) is new WP.Client.Keyboard with null record; type Pointer_With_Seat (Seat : not null access Seat_Devices) is new WP.Client.Pointer with null record; type Touch_With_Seat (Seat : not null access Seat_Devices) is new WP.Client.Touch with null record; type Relative_Pointer_With_Seat (Seat : not null access Seat_Devices) is new RP.Relative_Pointer_V1 with null record; type Pointer_Scrolling is array (AWT.Inputs.Dimension) of Boolean; type Seat_Devices is tagged limited record Window : access AWT.Wayland.Windows.Wayland_Window; Keyboard_Window : access AWT.Wayland.Windows.Wayland_Window; Drag_Drop_Window : access AWT.Wayland.Windows.Wayland_Window; Seat : Seat_With_Seat (Seat_Devices'Access); Capabilities : WE.Client.Seat_Capability := (others => False); Keyboard : Keyboard_With_Seat (Seat_Devices'Access); Pointer : Pointer_With_Seat (Seat_Devices'Access); Touch : Touch_With_Seat (Seat_Devices'Access); Data_Device : WP.Client.Data_Device; Data_Offer : WP.Client.Data_Offer; Clipboard_Mime_Type_Valid : Boolean := False; Drag_Drop_Mime_Type_Valid : Boolean := False; Supported_Drag_Drop_Actions : AWT.Inputs.Actions := (others => False); Valid_Drag_Drop_Action : AWT.Inputs.Action_Kind := AWT.Inputs.None; Relative_Pointer : Relative_Pointer_With_Seat (Seat_Devices'Access); Pointer_State : AWT.Inputs.Pointer_State; Scroll_Discrete : Boolean := False; Scrolling : Pointer_Scrolling; Pointer_Enter_Serial : Unsigned_32; -- Needed when setting a cursor Keyboard_Enter_Serial : Unsigned_32; -- Needed for clipboard and drag and drop Keyboard_State : AWT.Inputs.Keyboard_State; end record; type Monitor_Device; type Output_With_Monitor (Monitor : not null access Monitor_Device) is new WP.Client.Output with null record; type Monitor_Device is limited new AWT.Monitors.Monitor with record Output : Output_With_Monitor (Monitor_Device'Access); Pending_State, Current_State : AWT.Monitors.Monitor_State; -- Geometry Physical_Width : Natural; Physical_Height : Natural; Subpixel : WE.Client.Output_Subpixel; Transform : WE.Client.Output_Transform; Initialized : Boolean := True; end record; overriding function Is_Connected (Object : Monitor_Device) return Boolean; overriding function ID (Object : Monitor_Device) return Natural; overriding function State (Object : Monitor_Device) return AWT.Monitors.Monitor_State; type Monitor_Array is array (Positive range <>) of aliased Monitor_Device; type Compositor (Maximum_Monitors : Positive) is limited new Ada.Finalization.Limited_Controlled with record Display : aliased WP.Client.Display; Registry : WP.Client.Registry; Compositor : WP.Client.Compositor; Shm : WP.Client.Shm; Data_Device_Manager : WP.Client.Data_Device_Manager; Data_Source : WP.Client.Data_Source; Seat : Seat_Devices; Monitors : Monitor_Array (1 .. Maximum_Monitors); Inhibit_Manager : II.Idle_Inhibit_Manager_V1; Presentation : WP.Presentation_Time.Presentation; Pointer_Constraints : PC.Pointer_Constraints_V1; Relative_Pointer_Manager : RP.Relative_Pointer_Manager_V1; XDG_Shell : WP.Xdg_Shell.Xdg_Wm_Base; XDG_Decoration_Manager : XD.Decoration_Manager_V1; Cursor_Theme : WC.Cursor_Theme; Initialized : Boolean := False; end record; pragma Preelaborable_Initialization (Compositor); overriding procedure Finalize (Object : in out Compositor); package Surface_Data is new WP.Client.Surface_User_Data (AWT.Wayland.Windows.Surface_With_Window); package Output_Data is new WP.Client.Output_User_Data (Output_With_Monitor); Global : Compositor (Maximum_Monitors => 16); Registry_Callback : AWT.Wayland.On_Available_Interface; Monitor_Listener : AWT.Monitors.Monitor_Event_Listener_Ptr; procedure Initialize; function Is_Initialized return Boolean; function Process_Events return Boolean; function Process_Events (Timeout : Duration) return Boolean; function Monitors return AWT.Monitors.Monitor_Array; end AWT.Registry;
buotex/BICEPS
Ada
3,332
adb
---------------------------------------------------------------- -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- -- -- -- Open source license information is in the zlib.ads file. -- ---------------------------------------------------------------- -- $Id: zlib-thin.adb,v 1.1 2008/06/11 20:00:39 chambers Exp $ package body ZLib.Thin is ZLIB_VERSION : constant Chars_Ptr := zlibVersion; Z_Stream_Size : constant Int := Z_Stream'Size / System.Storage_Unit; -------------- -- Avail_In -- -------------- function Avail_In (Strm : in Z_Stream) return UInt is begin return Strm.Avail_In; end Avail_In; --------------- -- Avail_Out -- --------------- function Avail_Out (Strm : in Z_Stream) return UInt is begin return Strm.Avail_Out; end Avail_Out; ------------------ -- Deflate_Init -- ------------------ function Deflate_Init (strm : Z_Streamp; level : Int; method : Int; windowBits : Int; memLevel : Int; strategy : Int) return Int is begin return deflateInit2 (strm, level, method, windowBits, memLevel, strategy, ZLIB_VERSION, Z_Stream_Size); end Deflate_Init; ------------------ -- Inflate_Init -- ------------------ function Inflate_Init (strm : Z_Streamp; windowBits : Int) return Int is begin return inflateInit2 (strm, windowBits, ZLIB_VERSION, Z_Stream_Size); end Inflate_Init; ------------------------ -- Last_Error_Message -- ------------------------ function Last_Error_Message (Strm : in Z_Stream) return String is use Interfaces.C.Strings; begin if Strm.msg = Null_Ptr then return ""; else return Value (Strm.msg); end if; end Last_Error_Message; ------------ -- Set_In -- ------------ procedure Set_In (Strm : in out Z_Stream; Buffer : in Voidp; Size : in UInt) is begin Strm.Next_In := Buffer; Strm.Avail_In := Size; end Set_In; ------------------ -- Set_Mem_Func -- ------------------ procedure Set_Mem_Func (Strm : in out Z_Stream; Opaque : in Voidp; Alloc : in alloc_func; Free : in free_func) is begin Strm.opaque := Opaque; Strm.zalloc := Alloc; Strm.zfree := Free; end Set_Mem_Func; ------------- -- Set_Out -- ------------- procedure Set_Out (Strm : in out Z_Stream; Buffer : in Voidp; Size : in UInt) is begin Strm.Next_Out := Buffer; Strm.Avail_Out := Size; end Set_Out; -------------- -- Total_In -- -------------- function Total_In (Strm : in Z_Stream) return ULong is begin return Strm.Total_In; end Total_In; --------------- -- Total_Out -- --------------- function Total_Out (Strm : in Z_Stream) return ULong is begin return Strm.Total_Out; end Total_Out; end ZLib.Thin;
sparre/Command-Line-Parser-Generator
Ada
383
adb
-- Copyright: JSA Research & Innovation <[email protected]> -- License: Beer Ware pragma License (Unrestricted); with Ada.Strings.Wide_Fixed; package body Command_Line_Parser_Generator is function Trim (Item : in Wide_String) return Wide_String is use Ada.Strings; begin return Wide_Fixed.Trim (Item, Both); end Trim; end Command_Line_Parser_Generator;
ph0sph8/amass
Ada
2,682
ads
-- Copyright 2017 Jeff Foley. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. local json = require("json") name = "SecurityTrails" type = "api" function start() setratelimit(1) end function vertical(ctx, domain) if (api == nil or api.key == "") then return end local resp local vurl = verturl(domain) -- Check if the response data is in the graph database if (api.ttl ~= nil and api.ttl > 0) then resp = obtain_response(vurl, api.ttl) end if (resp == nil or resp == "") then local err resp, err = request({ url=vurl, headers={ APIKEY=api.key, ['Content-Type']="application/json", }, }) if (err ~= nil and err ~= "") then return end if (api.ttl ~= nil and api.ttl > 0) then cache_response(vurl, resp) end end local j = json.decode(resp) if (j == nil or #(j.subdomains) == 0) then return end for i, sub in pairs(j.subdomains) do sendnames(ctx, sub .. "." .. domain) end end function verturl(domain) return "https://api.securitytrails.com/v1/domain/" .. domain .. "/subdomains" end function sendnames(ctx, content) local names = find(content, subdomainre) if names == nil then return end for i, v in pairs(names) do newname(ctx, v) end end function horizontal(ctx, domain) if (api == nil or api.key == "") then return end local resp local hurl = horizonurl(domain) -- Check if the response data is in the graph database if (api.ttl ~= nil and api.ttl > 0) then resp = obtain_response(hurl, api.ttl) end if (resp == nil or resp == "") then local err resp, err = request({ url=hurl, headers={ APIKEY=api.key, ['Content-Type']="application/json", }, }) if (err ~= nil and err ~= "") then return end if (api.ttl ~= nil and api.ttl > 0) then cache_response(hurl, resp) end end local j = json.decode(resp) if (j == nil or #(j.records) == 0) then return end assoc = {} for i, r in pairs(j.records) do if r.hostname ~= "" then table.insert(assoc, r.hostname) end end for i, a in pairs(assoc) do associated(ctx, domain, a) end end function horizonurl(domain) return "https://api.securitytrails.com/v1/domain/" .. domain .. "/associated" end
lumalisan/EspeblancaYLos7PPs
Ada
284
ads
package def_monitor is protected type Monitor is entry menjar; entry fer_menjar; entry passetjada; entry treballar_mina; private cadires : Integer := 4; menjades : Integer := 2; assegut : Boolean := false; servit : Boolean := false; end Monitor; end def_monitor;
AaronC98/PlaneSystem
Ada
5,151
adb
------------------------------------------------------------------------------ -- Ada Web Server -- -- -- -- Copyright (C) 2007-2016, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 3, or (at your option) any -- -- later version. This library is distributed in the hope that it will be -- -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ------------------------------------------------------------------------------ with GNAT.Regpat; with AWS.Translator; package body AWS.Resources.Streams.Pipe is ----------- -- Close -- ----------- overriding procedure Close (Resource : in out Stream_Type) is ED : constant OS_Lib.File_Descriptor := Expect.Get_Error_Fd (Resource.Pid); Code : Integer; Err : aliased String (1 .. 4096); Last : constant Natural := OS_Lib.Read (ED, Err'Address, Err'Length); begin Expect.Close (Resource.Pid, Code); if Resource.On_Error /= null and then (Code /= 0 or else Last > 0) then Resource.On_Error (Code, Err (1 .. Last)); end if; end Close; ----------------- -- End_Of_File -- ----------------- overriding function End_Of_File (Resource : Stream_Type) return Boolean is begin return Resource.EOF; end End_Of_File; ---------- -- Open -- ---------- procedure Open (Pipe : out Stream_Type; Command : String; Args : OS_Lib.Argument_List; Timeout : Integer := 10_000; On_Error : On_Error_Callback := null) is begin Expect.Non_Blocking_Spawn (Pipe.Pid, Command, Args); Pipe.EOF := False; Pipe.Timeout := Timeout; Pipe.On_Error := On_Error; end Open; ---------- -- Read -- ---------- overriding procedure Read (Resource : in out Stream_Type; Buffer : out Stream_Element_Array; Last : out Stream_Element_Offset) is Regexp : constant Regpat.Pattern_Matcher := Regpat.Compile (".+", Flags => Regpat.Single_Line); Result : Expect.Expect_Match; begin while Length (Resource.Buffer) < Buffer'Length loop begin Expect.Expect (Resource.Pid, Result, Regexp, Resource.Timeout); exception when Expect.Process_Died => Resource.EOF := True; exit; end; case Result is when 1 => Append (Resource.Buffer, Expect.Expect_Out (Resource.Pid)); when Expect.Expect_Timeout => Last := Buffer'First - 1; return; when others => Last := Buffer'First - 1; return; end case; end loop; declare L : constant Natural := Length (Resource.Buffer); begin if Buffer'Length >= L then Last := Buffer'First + Stream_Element_Offset (L) - 1; Buffer (Buffer'First .. Last) := Translator.To_Stream_Element_Array (To_String (Resource.Buffer)); Resource.Buffer := Null_Unbounded_String; else Buffer := Translator.To_Stream_Element_Array (Slice (Resource.Buffer, 1, Buffer'Length)); Last := Buffer'Last; Delete (Resource.Buffer, 1, Buffer'Length); end if; end; end Read; end AWS.Resources.Streams.Pipe;
zhmu/ananas
Ada
4,809
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- I N T E R F A C E S . F O R T R A N -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ package body Interfaces.Fortran is ------------ -- To_Ada -- ------------ -- Single character case function To_Ada (Item : Character_Set) return Character is begin return Character (Item); end To_Ada; -- String case (function returning converted result) function To_Ada (Item : Fortran_Character) return String is T : String (1 .. Item'Length); begin for J in T'Range loop T (J) := Character (Item (J - 1 + Item'First)); end loop; return T; end To_Ada; -- String case (procedure copying converted string to given buffer) procedure To_Ada (Item : Fortran_Character; Target : out String; Last : out Natural) is begin if Item'Length = 0 then Last := 0; return; elsif Target'Length = 0 then raise Constraint_Error; else Last := Target'First - 1; for J in Item'Range loop Last := Last + 1; if Last > Target'Last then raise Constraint_Error; else Target (Last) := Character (Item (J)); end if; end loop; end if; end To_Ada; ---------------- -- To_Fortran -- ---------------- -- Character case function To_Fortran (Item : Character) return Character_Set is begin return Character_Set (Item); end To_Fortran; -- String case (function returning converted result) function To_Fortran (Item : String) return Fortran_Character is T : Fortran_Character (1 .. Item'Length); begin for J in T'Range loop T (J) := Character_Set (Item (J - 1 + Item'First)); end loop; return T; end To_Fortran; -- String case (procedure copying converted string to given buffer) procedure To_Fortran (Item : String; Target : out Fortran_Character; Last : out Natural) is begin if Item'Length = 0 then Last := 0; return; elsif Target'Length = 0 then raise Constraint_Error; else Last := Target'First - 1; for J in Item'Range loop Last := Last + 1; if Last > Target'Last then raise Constraint_Error; else Target (Last) := Character_Set (Item (J)); end if; end loop; end if; end To_Fortran; end Interfaces.Fortran;
reznikmm/matreshka
Ada
3,545
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014-2105, 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 Servlet.Event_Listeners is pragma Preelaborate; type Event_Listener is limited interface; type Event_Listener_Access is access all Event_Listener'Class; end Servlet.Event_Listeners;
MinimSecure/unum-sdk
Ada
924
adb
-- Copyright 2008-2016 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. package body Pck is function Ident (I : Integer) return Integer is begin return I; end Ident; procedure Do_Nothing (A : System.Address) is begin null; end Do_Nothing; end Pck;
AdaCore/libadalang
Ada
841
adb
-- Check that the project partitionner works on projects containing C units with Ada.Text_IO; use Ada.Text_IO; with GNATCOLL.Projects; use GNATCOLL.Projects; with GNATCOLL.VFS; use GNATCOLL.VFS; with Libadalang.Project_Provider; use Libadalang.Project_Provider; procedure Main is Tree : Project_Tree_Access := new Project_Tree; Env : Project_Environment_Access; PAPs : Provider_And_Projects_Array_Access; begin Put_Line ("Loading the project:"); Initialize (Env); Load (Tree.all, Create (+"ap.gpr"), Env); PAPs := Create_Project_Unit_Providers (Tree); for I in PAPs'Range loop Put (" *"); for P of PAPs (I).Projects.all loop Put (" "); Put (P.Name); end loop; New_Line; end loop; Free (PAPs); Free (Tree); Free (Env); Put_Line ("Done."); end Main;
Arles96/PCompiladores
Ada
333
adb
procedure prueba2 is x:Integer := 0; procedure Minimo2 () is y:Integer; function Minimo (a, b: Integer) return Integer is yy:Integer; begin az := 12; end Minimo; begin az := 12; end Minimo2; procedure Minimo4 () is yt:Integer; begin az := 12; end Minimo4; begin x := 1; end prueba2;
reznikmm/matreshka
Ada
4,067
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.Chart_Error_Lower_Limit_Attributes; package Matreshka.ODF_Chart.Error_Lower_Limit_Attributes is type Chart_Error_Lower_Limit_Attribute_Node is new Matreshka.ODF_Chart.Abstract_Chart_Attribute_Node and ODF.DOM.Chart_Error_Lower_Limit_Attributes.ODF_Chart_Error_Lower_Limit_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Chart_Error_Lower_Limit_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Chart_Error_Lower_Limit_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Chart.Error_Lower_Limit_Attributes;
Fabien-Chouteau/lvgl-ada
Ada
2,959
ads
with System; package Lv.Tasks is type Instance is private; type Prio_T is (Prio_Off, Prio_Lowest, Prio_Low, Prio_Mid, Prio_High, Prio_Highest, Prio_Num); -- Call it periodically to handle lv_tasks. procedure Handler; -- Create a new lv_task -- @param task a function which is the task itself -- @param period call period in ms unit -- @param prio priority of the task (LV_TASK_PRIO_OFF means the task is stopped) -- @param param free parameter -- @return pointer to the new task function Create (Proc : access procedure (Param : System.Address); Period : Uint32_T; Prio : Prio_T; Param : System.Address) return Instance; -- Delete a lv_task -- @param lv_task_p pointer to task created by lv_task_p procedure Del (Self : Instance); -- Set new priority for a lv_task -- @param lv_task_p pointer to a lv_task -- @param prio the new priority procedure Set_Prio (Self : Instance; Prio : Prio_T); -- Set new period for a lv_task -- @param lv_task_p pointer to a lv_task -- @param period the new period procedure Set_Period (Self : Instance; Period : Uint32_T); -- Make a lv_task ready. It will not wait its period. -- @param lv_task_p pointer to a lv_task. procedure Ready (Self : Instance); -- Delete the lv_task after one call -- @param lv_task_p pointer to a lv_task. procedure Once (Self : Instance); -- Reset a lv_task. -- It will be called the previously set period milliseconds later. -- @param lv_task_p pointer to a lv_task. procedure Reset (Self : Instance); -- Enable or disable the whole lv_task handling -- @param en: true: lv_task handling is running, false: lv_task handling is suspended procedure Enable (En : U_Bool); -- Get idle percentage -- @return the lv_task idle in percentage function Get_Idle return Uint8_T; private type Instance is new System.Address; -- This Init is already called in lv_init() procedure Init; ------------- -- Imports -- ------------- pragma Import (C, Handler, "lv_task_handler"); pragma Import (C, Create, "lv_task_create"); pragma Import (C, Del, "lv_task_del"); pragma Import (C, Set_Prio, "lv_task_set_prio"); pragma Import (C, Set_Period, "lv_task_set_period"); pragma Import (C, Ready, "lv_task_ready"); pragma Import (C, Once, "lv_task_once"); pragma Import (C, Reset, "lv_task_reset"); pragma Import (C, Enable, "lv_task_enable"); pragma Import (C, Get_Idle, "lv_task_get_idle"); pragma Import (C, Init, "lv_task_init"); for Prio_T'Size use 8; for Prio_T use (Prio_Off => 0, Prio_Lowest => 1, Prio_Low => 2, Prio_Mid => 3, Prio_High => 4, Prio_Highest => 5, Prio_Num => 6); end Lv.Tasks;
marcello-s/AeonFlux
Ada
397
ads
-- Copyright (c) 2015-2019 Marcel Schneider -- for details see License.txt with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Position; use Position; with Tokens; use Tokens; package TokenValue is type Object is record SourcePosition : Position.Object; TokenId : Token; Literal : Unbounded_String; Message : Unbounded_String; end record; end TokenValue;
io7m/coreland-vector-ada
Ada
1,502
adb
package body vector.mult_scalar is -- C imports procedure vec_mult_scalar_f (a : in out vector_f_t; sc : scalar_f_t; n : ic.int); pragma import (c, vec_mult_scalar_f, "vec_multscNf_aligned"); procedure vec_mult_scalar_fx (a : vector_f_t; x : out vector_f_t; sc : scalar_f_t; n : ic.int); pragma import (c, vec_mult_scalar_fx, "vec_multscNfx_aligned"); procedure vec_mult_scalar_d (a : in out vector_d_t; sc : scalar_d_t; n : ic.int); pragma import (c, vec_mult_scalar_d, "vec_multscNd_aligned"); procedure vec_mult_scalar_dx (a : vector_d_t; x : out vector_d_t; sc : scalar_d_t; n : ic.int); pragma import (c, vec_mult_scalar_dx, "vec_multscNdx_aligned"); -- mult scalar, in place procedure f (a : in out vector_f_t; sc : scalar_f_t) is begin vec_mult_scalar_f (a, sc, ic.int (size)); end f; pragma inline (f); procedure d (a : in out vector_d_t; sc : scalar_d_t) is begin vec_mult_scalar_d (a, sc, ic.int (size)); end d; pragma inline (d); -- mult scalar, external storage procedure f_ext (a : vector_f_t; x : out vector_f_t; sc : scalar_f_t) is begin vec_mult_scalar_fx (a, x, sc, ic.int (size)); end f_ext; pragma inline (f_ext); procedure d_ext (a : vector_d_t; x : out vector_d_t; sc : scalar_d_t) is begin vec_mult_scalar_dx (a, x, sc, ic.int (size)); end d_ext; pragma inline (d_ext); end vector.mult_scalar;
AdaCore/libadalang
Ada
89
ads
package Pkg7 is pragma Pure (Pkg7); end Pkg7; --% node.unit.root.p_is_preelaborable()