repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
charlie5/lace
Ada
1,374
ads
generic package any_Math.any_Geometry -- -- Provides a namespace and core types for geometry. -- is pragma Pure; subtype Vertex_Id is Index; type Vertex_Ids is array (Index range <>) of Vertex_Id; subtype Triangle is Vertex_Ids (1 .. 3); type Triangles is array (Index range <>) of Triangle; function Image (Self : in Triangle) return String; function Image (Self : in Triangles) return String; -------- -- Model -- type Model_Options is tagged null record; default_Model_Options : constant Model_Options; type Model_Triangles (Triangle_Count : Index) is tagged record Triangles : any_Geometry.Triangles (1 .. Triangle_Count); end record; function Image (Self : in Model_Triangles) return String; type Model is abstract tagged record Triangles : access Model_Triangles'Class; end record; function Image (Self : in Model) return String; ---------------- -- Geometry Item -- type Item is abstract tagged private; procedure destroy (Self : in out Item) is abstract; procedure expand (Self : access Item; By : in Real) is abstract; private type Item is abstract tagged record null; end record; default_Model_Options : constant Model_Options := (others => <>); end any_Math.any_Geometry;
Fabien-Chouteau/tiled-code-gen
Ada
2,633
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. -- -- -- ------------------------------------------------------------------------------ package TCG is end TCG;
burratoo/Acton
Ada
3,177
ads
------------------------------------------------------------------------------------------ -- -- -- OAK COMPONENTS -- -- -- -- OAK.SCHEDULER -- -- -- -- Copyright (C) 2010-2021, Patrick Bernardi -- -- -- ------------------------------------------------------------------------------------------ with Oak.Agent; use Oak.Agent; with Oak.Message; use Oak.Message; with System; use System; with System.Multiprocessors; package Oak.Scheduler with Preelaborate is ----------------- -- Subprograms -- ----------------- procedure Add_Agent_To_Scheduler (Agent : in Oak_Agent_Id; Place_At : in Queue_End := Back); -- Adds the specified Agent to its scheduler agent (which the Agent -- contains a reference to). procedure Add_Agents_To_Scheduler (Agents : in Oak_Agent_Id) with Inline; -- Adds a list of Agents to their respective scheduler agents. List is -- linked through agents' Next_Agent link. procedure Check_Sechduler_Agents_For_Next_Agent_To_Run (Next_Agent_To_Run : out Oak_Agent_Id; Top_Priority : out Any_Priority) with Inline; -- Queries the system's scheduler agents for the next task to run. Does not -- run the scheduler agents themselves, instead it relies on the cached -- results of the last run. Checks the scheduler agents for the next agent -- to run from the specified agent onwards. If the head of the Scheduler -- Table is provided, then the search begins with the highest priority -- scheduler agent. function Find_Scheduler_For_System_Priority (Priority : Any_Priority; CPU : System.Multiprocessors.CPU_Range) return Scheduler_Id_With_No with Inline; -- Finds the scheduler agent responsible for the givin Ada priority. procedure Inform_Scheduler_Agent_Has_Changed_State (Changed_Agent : in Oak_Agent_Id) with Inline; -- Notifies the scheduler responsible for the given task that the task has -- changed state. procedure New_Scheduler_Cycle (Scheduler : in Scheduler_Id); -- Starts a new cycle for the scheduler agent. procedure Post_Run_Scheduler_Agent (Agent : in Scheduler_Id; Message : in Oak_Message); -- Perform kernel-level scheduler operations as a result of running a -- scheduler agent. procedure Remove_Agent_From_Scheduler (Agent : in Oak_Agent_Id) with Inline; -- Removes the agent from its scheduler. procedure Service_Scheduler_Agent_Timer (Scheduler : in Scheduler_Id); -- Runs the scheduler that requested to be run through a Scheduler Timer. end Oak.Scheduler;
zhmu/ananas
Ada
36,568
adb
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- ADA.CONTAINERS.RESTRICTED_DOUBLY_LINKED_LISTS -- -- -- -- B o d y -- -- -- -- Copyright (C) 2004-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.Containers.Stable_Sorting; use Ada.Containers.Stable_Sorting; with System; use type System.Address; package body Ada.Containers.Restricted_Doubly_Linked_Lists is ----------------------- -- Local Subprograms -- ----------------------- procedure Allocate (Container : in out List'Class; New_Item : Element_Type; New_Node : out Count_Type); procedure Free (Container : in out List'Class; X : Count_Type); procedure Insert_Internal (Container : in out List'Class; Before : Count_Type; New_Node : Count_Type); function Vet (Position : Cursor) return Boolean; --------- -- "=" -- --------- function "=" (Left, Right : List) return Boolean is LN : Node_Array renames Left.Nodes; RN : Node_Array renames Right.Nodes; LI : Count_Type := Left.First; RI : Count_Type := Right.First; begin if Left'Address = Right'Address then return True; end if; if Left.Length /= Right.Length then return False; end if; for J in 1 .. Left.Length loop if LN (LI).Element /= RN (RI).Element then return False; end if; LI := LN (LI).Next; RI := RN (RI).Next; end loop; return True; end "="; -------------- -- Allocate -- -------------- procedure Allocate (Container : in out List'Class; New_Item : Element_Type; New_Node : out Count_Type) is N : Node_Array renames Container.Nodes; begin if Container.Free >= 0 then New_Node := Container.Free; N (New_Node).Element := New_Item; Container.Free := N (New_Node).Next; else New_Node := abs Container.Free; N (New_Node).Element := New_Item; Container.Free := Container.Free - 1; end if; end Allocate; ------------ -- Append -- ------------ procedure Append (Container : in out List; New_Item : Element_Type; Count : Count_Type := 1) is begin Insert (Container, No_Element, New_Item, Count); end Append; ------------ -- Assign -- ------------ procedure Assign (Target : in out List; Source : List) is begin if Target'Address = Source'Address then return; end if; if Target.Capacity < Source.Length then raise Constraint_Error; -- ??? end if; Clear (Target); declare N : Node_Array renames Source.Nodes; J : Count_Type := Source.First; begin while J /= 0 loop Append (Target, N (J).Element); J := N (J).Next; end loop; end; end Assign; ----------- -- Clear -- ----------- procedure Clear (Container : in out List) is N : Node_Array renames Container.Nodes; X : Count_Type; begin if Container.Length = 0 then pragma Assert (Container.First = 0); pragma Assert (Container.Last = 0); -- pragma Assert (Container.Busy = 0); -- pragma Assert (Container.Lock = 0); return; end if; pragma Assert (Container.First >= 1); pragma Assert (Container.Last >= 1); pragma Assert (N (Container.First).Prev = 0); pragma Assert (N (Container.Last).Next = 0); -- if Container.Busy > 0 then -- raise Program_Error; -- end if; while Container.Length > 1 loop X := Container.First; Container.First := N (X).Next; N (Container.First).Prev := 0; Container.Length := Container.Length - 1; Free (Container, X); end loop; X := Container.First; Container.First := 0; Container.Last := 0; Container.Length := 0; Free (Container, X); end Clear; -------------- -- Contains -- -------------- function Contains (Container : List; Item : Element_Type) return Boolean is begin return Find (Container, Item) /= No_Element; end Contains; ------------ -- Delete -- ------------ procedure Delete (Container : in out List; Position : in out Cursor; Count : Count_Type := 1) is N : Node_Array renames Container.Nodes; X : Count_Type; begin if Position.Node = 0 then raise Constraint_Error; end if; if Position.Container /= Container'Unrestricted_Access then raise Program_Error; end if; pragma Assert (Vet (Position), "bad cursor in Delete"); if Position.Node = Container.First then Delete_First (Container, Count); Position := No_Element; return; end if; if Count = 0 then Position := No_Element; return; end if; -- if Container.Busy > 0 then -- raise Program_Error; -- end if; pragma Assert (Container.First >= 1); pragma Assert (Container.Last >= 1); pragma Assert (N (Container.First).Prev = 0); pragma Assert (N (Container.Last).Next = 0); for Index in 1 .. Count loop pragma Assert (Container.Length >= 2); X := Position.Node; Container.Length := Container.Length - 1; if X = Container.Last then Position := No_Element; Container.Last := N (X).Prev; N (Container.Last).Next := 0; Free (Container, X); return; end if; Position.Node := N (X).Next; N (N (X).Next).Prev := N (X).Prev; N (N (X).Prev).Next := N (X).Next; Free (Container, X); end loop; Position := No_Element; end Delete; ------------------ -- Delete_First -- ------------------ procedure Delete_First (Container : in out List; Count : Count_Type := 1) is N : Node_Array renames Container.Nodes; X : Count_Type; begin if Count >= Container.Length then Clear (Container); return; end if; if Count = 0 then return; end if; -- if Container.Busy > 0 then -- raise Program_Error; -- end if; for I in 1 .. Count loop X := Container.First; pragma Assert (N (N (X).Next).Prev = Container.First); Container.First := N (X).Next; N (Container.First).Prev := 0; Container.Length := Container.Length - 1; Free (Container, X); end loop; end Delete_First; ----------------- -- Delete_Last -- ----------------- procedure Delete_Last (Container : in out List; Count : Count_Type := 1) is N : Node_Array renames Container.Nodes; X : Count_Type; begin if Count >= Container.Length then Clear (Container); return; end if; if Count = 0 then return; end if; -- if Container.Busy > 0 then -- raise Program_Error; -- end if; for I in 1 .. Count loop X := Container.Last; pragma Assert (N (N (X).Prev).Next = Container.Last); Container.Last := N (X).Prev; N (Container.Last).Next := 0; Container.Length := Container.Length - 1; Free (Container, X); end loop; end Delete_Last; ------------- -- Element -- ------------- function Element (Position : Cursor) return Element_Type is begin if Position.Node = 0 then raise Constraint_Error; end if; pragma Assert (Vet (Position), "bad cursor in Element"); declare N : Node_Array renames Position.Container.Nodes; begin return N (Position.Node).Element; end; end Element; ---------- -- Find -- ---------- function Find (Container : List; Item : Element_Type; Position : Cursor := No_Element) return Cursor is Nodes : Node_Array renames Container.Nodes; Node : Count_Type := Position.Node; begin if Node = 0 then Node := Container.First; else if Position.Container /= Container'Unrestricted_Access then raise Program_Error; end if; pragma Assert (Vet (Position), "bad cursor in Find"); end if; while Node /= 0 loop if Nodes (Node).Element = Item then return Cursor'(Container'Unrestricted_Access, Node); end if; Node := Nodes (Node).Next; end loop; return No_Element; end Find; ----------- -- First -- ----------- function First (Container : List) return Cursor is begin if Container.First = 0 then return No_Element; end if; return Cursor'(Container'Unrestricted_Access, Container.First); end First; ------------------- -- First_Element -- ------------------- function First_Element (Container : List) return Element_Type is N : Node_Array renames Container.Nodes; begin if Container.First = 0 then raise Constraint_Error; end if; return N (Container.First).Element; end First_Element; ---------- -- Free -- ---------- procedure Free (Container : in out List'Class; X : Count_Type) is pragma Assert (X > 0); pragma Assert (X <= Container.Capacity); N : Node_Array renames Container.Nodes; begin N (X).Prev := -1; -- Node is deallocated (not on active list) if Container.Free >= 0 then N (X).Next := Container.Free; Container.Free := X; elsif X + 1 = abs Container.Free then N (X).Next := 0; -- Not strictly necessary, but marginally safer Container.Free := Container.Free + 1; else Container.Free := abs Container.Free; if Container.Free > Container.Capacity then Container.Free := 0; else for I in Container.Free .. Container.Capacity - 1 loop N (I).Next := I + 1; end loop; N (Container.Capacity).Next := 0; end if; N (X).Next := Container.Free; Container.Free := X; end if; end Free; --------------------- -- Generic_Sorting -- --------------------- package body Generic_Sorting is --------------- -- Is_Sorted -- --------------- function Is_Sorted (Container : List) return Boolean is Nodes : Node_Array renames Container.Nodes; Node : Count_Type := Container.First; begin for I in 2 .. Container.Length loop if Nodes (Nodes (Node).Next).Element < Nodes (Node).Element then return False; end if; Node := Nodes (Node).Next; end loop; return True; end Is_Sorted; ---------- -- Sort -- ---------- procedure Sort (Container : in out List) is N : Node_Array renames Container.Nodes; begin if Container.Length <= 1 then return; end if; -- if Container.Busy > 0 then -- raise Program_Error; -- end if; declare package Descriptors is new List_Descriptors (Node_Ref => Count_Type, Nil => 0); use Descriptors; function Next (Idx : Count_Type) return Count_Type is (N (Idx).Next); procedure Set_Next (Idx : Count_Type; Next : Count_Type) with Inline; procedure Set_Prev (Idx : Count_Type; Prev : Count_Type) with Inline; function "<" (L, R : Count_Type) return Boolean is (N (L).Element < N (R).Element); procedure Update_Container (List : List_Descriptor) with Inline; procedure Set_Next (Idx : Count_Type; Next : Count_Type) is begin N (Idx).Next := Next; end Set_Next; procedure Set_Prev (Idx : Count_Type; Prev : Count_Type) is begin N (Idx).Prev := Prev; end Set_Prev; procedure Update_Container (List : List_Descriptor) is begin Container.First := List.First; Container.Last := List.Last; Container.Length := List.Length; end Update_Container; procedure Sort_List is new Doubly_Linked_List_Sort; begin Sort_List (List_Descriptor'(First => Container.First, Last => Container.Last, Length => Container.Length)); end; pragma Assert (N (Container.First).Prev = 0); pragma Assert (N (Container.Last).Next = 0); end Sort; end Generic_Sorting; ----------------- -- Has_Element -- ----------------- function Has_Element (Position : Cursor) return Boolean is begin pragma Assert (Vet (Position), "bad cursor in Has_Element"); return Position.Node /= 0; end Has_Element; ------------ -- Insert -- ------------ procedure Insert (Container : in out List; Before : Cursor; New_Item : Element_Type; Position : out Cursor; Count : Count_Type := 1) is First_Node : Count_Type; New_Node : Count_Type; begin if Before.Container /= null then if Before.Container /= Container'Unrestricted_Access then raise Program_Error; end if; pragma Assert (Vet (Before), "bad cursor in Insert"); end if; if Count = 0 then Position := Before; return; end if; if Container.Length > Container.Capacity - Count then raise Constraint_Error; end if; -- if Container.Busy > 0 then -- raise Program_Error; -- end if; Allocate (Container, New_Item, New_Node); First_Node := New_Node; Insert_Internal (Container, Before.Node, New_Node); for Index in 2 .. Count loop Allocate (Container, New_Item, New_Node); Insert_Internal (Container, Before.Node, New_Node); end loop; Position := Cursor'(Container'Unrestricted_Access, First_Node); end Insert; procedure Insert (Container : in out List; Before : Cursor; New_Item : Element_Type; Count : Count_Type := 1) is Position : Cursor; begin Insert (Container, Before, New_Item, Position, Count); end Insert; procedure Insert (Container : in out List; Before : Cursor; Position : out Cursor; Count : Count_Type := 1) is New_Item : Element_Type; -- Do we need to reinit node ??? pragma Warnings (Off, New_Item); begin Insert (Container, Before, New_Item, Position, Count); end Insert; --------------------- -- Insert_Internal -- --------------------- procedure Insert_Internal (Container : in out List'Class; Before : Count_Type; New_Node : Count_Type) is N : Node_Array renames Container.Nodes; begin if Container.Length = 0 then pragma Assert (Before = 0); pragma Assert (Container.First = 0); pragma Assert (Container.Last = 0); Container.First := New_Node; Container.Last := New_Node; N (Container.First).Prev := 0; N (Container.Last).Next := 0; elsif Before = 0 then pragma Assert (N (Container.Last).Next = 0); N (Container.Last).Next := New_Node; N (New_Node).Prev := Container.Last; Container.Last := New_Node; N (Container.Last).Next := 0; elsif Before = Container.First then pragma Assert (N (Container.First).Prev = 0); N (Container.First).Prev := New_Node; N (New_Node).Next := Container.First; Container.First := New_Node; N (Container.First).Prev := 0; else pragma Assert (N (Container.First).Prev = 0); pragma Assert (N (Container.Last).Next = 0); N (New_Node).Next := Before; N (New_Node).Prev := N (Before).Prev; N (N (Before).Prev).Next := New_Node; N (Before).Prev := New_Node; end if; Container.Length := Container.Length + 1; end Insert_Internal; -------------- -- Is_Empty -- -------------- function Is_Empty (Container : List) return Boolean is begin return Container.Length = 0; end Is_Empty; ------------- -- Iterate -- ------------- procedure Iterate (Container : List; Process : not null access procedure (Position : Cursor)) is C : List renames Container'Unrestricted_Access.all; N : Node_Array renames C.Nodes; -- B : Natural renames C.Busy; Node : Count_Type := Container.First; Index : Count_Type := 0; Index_Max : constant Count_Type := Container.Length; begin if Index_Max = 0 then pragma Assert (Node = 0); return; end if; loop pragma Assert (Node /= 0); Process (Cursor'(C'Unchecked_Access, Node)); pragma Assert (Container.Length = Index_Max); pragma Assert (N (Node).Prev /= -1); Node := N (Node).Next; Index := Index + 1; if Index = Index_Max then pragma Assert (Node = 0); return; end if; end loop; end Iterate; ---------- -- Last -- ---------- function Last (Container : List) return Cursor is begin if Container.Last = 0 then return No_Element; end if; return Cursor'(Container'Unrestricted_Access, Container.Last); end Last; ------------------ -- Last_Element -- ------------------ function Last_Element (Container : List) return Element_Type is N : Node_Array renames Container.Nodes; begin if Container.Last = 0 then raise Constraint_Error; end if; return N (Container.Last).Element; end Last_Element; ------------ -- Length -- ------------ function Length (Container : List) return Count_Type is begin return Container.Length; end Length; ---------- -- Next -- ---------- procedure Next (Position : in out Cursor) is begin Position := Next (Position); end Next; function Next (Position : Cursor) return Cursor is begin if Position.Node = 0 then return No_Element; end if; pragma Assert (Vet (Position), "bad cursor in Next"); declare Nodes : Node_Array renames Position.Container.Nodes; Node : constant Count_Type := Nodes (Position.Node).Next; begin if Node = 0 then return No_Element; end if; return Cursor'(Position.Container, Node); end; end Next; ------------- -- Prepend -- ------------- procedure Prepend (Container : in out List; New_Item : Element_Type; Count : Count_Type := 1) is begin Insert (Container, First (Container), New_Item, Count); end Prepend; -------------- -- Previous -- -------------- procedure Previous (Position : in out Cursor) is begin Position := Previous (Position); end Previous; function Previous (Position : Cursor) return Cursor is begin if Position.Node = 0 then return No_Element; end if; pragma Assert (Vet (Position), "bad cursor in Previous"); declare Nodes : Node_Array renames Position.Container.Nodes; Node : constant Count_Type := Nodes (Position.Node).Prev; begin if Node = 0 then return No_Element; end if; return Cursor'(Position.Container, Node); end; end Previous; ------------------- -- Query_Element -- ------------------- procedure Query_Element (Position : Cursor; Process : not null access procedure (Element : Element_Type)) is begin if Position.Node = 0 then raise Constraint_Error; end if; pragma Assert (Vet (Position), "bad cursor in Query_Element"); declare C : List renames Position.Container.all'Unrestricted_Access.all; N : Node_Type renames C.Nodes (Position.Node); begin Process (N.Element); pragma Assert (N.Prev >= 0); end; end Query_Element; --------------------- -- Replace_Element -- --------------------- procedure Replace_Element (Container : in out List; Position : Cursor; New_Item : Element_Type) is begin if Position.Container = null then raise Constraint_Error; end if; if Position.Container /= Container'Unrestricted_Access then raise Program_Error; end if; -- if Container.Lock > 0 then -- raise Program_Error; -- end if; pragma Assert (Vet (Position), "bad cursor in Replace_Element"); declare N : Node_Array renames Container.Nodes; begin N (Position.Node).Element := New_Item; end; end Replace_Element; ---------------------- -- Reverse_Elements -- ---------------------- procedure Reverse_Elements (Container : in out List) is N : Node_Array renames Container.Nodes; I : Count_Type := Container.First; J : Count_Type := Container.Last; procedure Swap (L, R : Count_Type); ---------- -- Swap -- ---------- procedure Swap (L, R : Count_Type) is LN : constant Count_Type := N (L).Next; LP : constant Count_Type := N (L).Prev; RN : constant Count_Type := N (R).Next; RP : constant Count_Type := N (R).Prev; begin if LP /= 0 then N (LP).Next := R; end if; if RN /= 0 then N (RN).Prev := L; end if; N (L).Next := RN; N (R).Prev := LP; if LN = R then pragma Assert (RP = L); N (L).Prev := R; N (R).Next := L; else N (L).Prev := RP; N (RP).Next := L; N (R).Next := LN; N (LN).Prev := R; end if; end Swap; -- Start of processing for Reverse_Elements begin if Container.Length <= 1 then return; end if; pragma Assert (N (Container.First).Prev = 0); pragma Assert (N (Container.Last).Next = 0); -- if Container.Busy > 0 then -- raise Program_Error; -- end if; Container.First := J; Container.Last := I; loop Swap (L => I, R => J); J := N (J).Next; exit when I = J; I := N (I).Prev; exit when I = J; Swap (L => J, R => I); I := N (I).Next; exit when I = J; J := N (J).Prev; exit when I = J; end loop; pragma Assert (N (Container.First).Prev = 0); pragma Assert (N (Container.Last).Next = 0); end Reverse_Elements; ------------------ -- Reverse_Find -- ------------------ function Reverse_Find (Container : List; Item : Element_Type; Position : Cursor := No_Element) return Cursor is N : Node_Array renames Container.Nodes; Node : Count_Type := Position.Node; begin if Node = 0 then Node := Container.Last; else if Position.Container /= Container'Unrestricted_Access then raise Program_Error; end if; pragma Assert (Vet (Position), "bad cursor in Reverse_Find"); end if; while Node /= 0 loop if N (Node).Element = Item then return Cursor'(Container'Unrestricted_Access, Node); end if; Node := N (Node).Prev; end loop; return No_Element; end Reverse_Find; --------------------- -- Reverse_Iterate -- --------------------- procedure Reverse_Iterate (Container : List; Process : not null access procedure (Position : Cursor)) is C : List renames Container'Unrestricted_Access.all; N : Node_Array renames C.Nodes; -- B : Natural renames C.Busy; Node : Count_Type := Container.Last; Index : Count_Type := 0; Index_Max : constant Count_Type := Container.Length; begin if Index_Max = 0 then pragma Assert (Node = 0); return; end if; loop pragma Assert (Node > 0); Process (Cursor'(C'Unchecked_Access, Node)); pragma Assert (Container.Length = Index_Max); pragma Assert (N (Node).Prev /= -1); Node := N (Node).Prev; Index := Index + 1; if Index = Index_Max then pragma Assert (Node = 0); return; end if; end loop; end Reverse_Iterate; ------------ -- Splice -- ------------ procedure Splice (Container : in out List; Before : Cursor; Position : in out Cursor) is N : Node_Array renames Container.Nodes; begin if Before.Container /= null then if Before.Container /= Container'Unrestricted_Access then raise Program_Error; end if; pragma Assert (Vet (Before), "bad Before cursor in Splice"); end if; if Position.Node = 0 then raise Constraint_Error; end if; if Position.Container /= Container'Unrestricted_Access then raise Program_Error; end if; pragma Assert (Vet (Position), "bad Position cursor in Splice"); if Position.Node = Before.Node or else N (Position.Node).Next = Before.Node then return; end if; pragma Assert (Container.Length >= 2); -- if Container.Busy > 0 then -- raise Program_Error; -- end if; if Before.Node = 0 then pragma Assert (Position.Node /= Container.Last); if Position.Node = Container.First then Container.First := N (Position.Node).Next; N (Container.First).Prev := 0; else N (N (Position.Node).Prev).Next := N (Position.Node).Next; N (N (Position.Node).Next).Prev := N (Position.Node).Prev; end if; N (Container.Last).Next := Position.Node; N (Position.Node).Prev := Container.Last; Container.Last := Position.Node; N (Container.Last).Next := 0; return; end if; if Before.Node = Container.First then pragma Assert (Position.Node /= Container.First); if Position.Node = Container.Last then Container.Last := N (Position.Node).Prev; N (Container.Last).Next := 0; else N (N (Position.Node).Prev).Next := N (Position.Node).Next; N (N (Position.Node).Next).Prev := N (Position.Node).Prev; end if; N (Container.First).Prev := Position.Node; N (Position.Node).Next := Container.First; Container.First := Position.Node; N (Container.First).Prev := 0; return; end if; if Position.Node = Container.First then Container.First := N (Position.Node).Next; N (Container.First).Prev := 0; elsif Position.Node = Container.Last then Container.Last := N (Position.Node).Prev; N (Container.Last).Next := 0; else N (N (Position.Node).Prev).Next := N (Position.Node).Next; N (N (Position.Node).Next).Prev := N (Position.Node).Prev; end if; N (N (Before.Node).Prev).Next := Position.Node; N (Position.Node).Prev := N (Before.Node).Prev; N (Before.Node).Prev := Position.Node; N (Position.Node).Next := Before.Node; pragma Assert (N (Container.First).Prev = 0); pragma Assert (N (Container.Last).Next = 0); end Splice; ---------- -- Swap -- ---------- procedure Swap (Container : in out List; I, J : Cursor) is begin if I.Node = 0 or else J.Node = 0 then raise Constraint_Error; end if; if I.Container /= Container'Unrestricted_Access or else J.Container /= Container'Unrestricted_Access then raise Program_Error; end if; if I.Node = J.Node then return; end if; -- if Container.Lock > 0 then -- raise Program_Error; -- end if; pragma Assert (Vet (I), "bad I cursor in Swap"); pragma Assert (Vet (J), "bad J cursor in Swap"); declare N : Node_Array renames Container.Nodes; EI : Element_Type renames N (I.Node).Element; EJ : Element_Type renames N (J.Node).Element; EI_Copy : constant Element_Type := EI; begin EI := EJ; EJ := EI_Copy; end; end Swap; ---------------- -- Swap_Links -- ---------------- procedure Swap_Links (Container : in out List; I, J : Cursor) is begin if I.Node = 0 or else J.Node = 0 then raise Constraint_Error; end if; if I.Container /= Container'Unrestricted_Access or else I.Container /= J.Container then raise Program_Error; end if; if I.Node = J.Node then return; end if; -- if Container.Busy > 0 then -- raise Program_Error; -- end if; pragma Assert (Vet (I), "bad I cursor in Swap_Links"); pragma Assert (Vet (J), "bad J cursor in Swap_Links"); declare I_Next : constant Cursor := Next (I); J_Copy : Cursor := J; pragma Warnings (Off, J_Copy); begin if I_Next = J then Splice (Container, Before => I, Position => J_Copy); else declare J_Next : constant Cursor := Next (J); I_Copy : Cursor := I; pragma Warnings (Off, I_Copy); begin if J_Next = I then Splice (Container, Before => J, Position => I_Copy); else pragma Assert (Container.Length >= 3); Splice (Container, Before => I_Next, Position => J_Copy); Splice (Container, Before => J_Next, Position => I_Copy); end if; end; end if; end; end Swap_Links; -------------------- -- Update_Element -- -------------------- procedure Update_Element (Container : in out List; Position : Cursor; Process : not null access procedure (Element : in out Element_Type)) is begin if Position.Node = 0 then raise Constraint_Error; end if; if Position.Container /= Container'Unrestricted_Access then raise Program_Error; end if; pragma Assert (Vet (Position), "bad cursor in Update_Element"); declare N : Node_Type renames Container.Nodes (Position.Node); begin Process (N.Element); pragma Assert (N.Prev >= 0); end; end Update_Element; --------- -- Vet -- --------- function Vet (Position : Cursor) return Boolean is begin if Position.Node = 0 then return Position.Container = null; end if; if Position.Container = null then return False; end if; declare L : List renames Position.Container.all; N : Node_Array renames L.Nodes; begin if L.Length = 0 then return False; end if; if L.First = 0 then return False; end if; if L.Last = 0 then return False; end if; if Position.Node > L.Capacity then return False; end if; if N (Position.Node).Prev < 0 or else N (Position.Node).Prev > L.Capacity then return False; end if; if N (Position.Node).Next > L.Capacity then return False; end if; if N (L.First).Prev /= 0 then return False; end if; if N (L.Last).Next /= 0 then return False; end if; if N (Position.Node).Prev = 0 and then Position.Node /= L.First then return False; end if; if N (Position.Node).Next = 0 and then Position.Node /= L.Last then return False; end if; if L.Length = 1 then return L.First = L.Last; end if; if L.First = L.Last then return False; end if; if N (L.First).Next = 0 then return False; end if; if N (L.Last).Prev = 0 then return False; end if; if N (N (L.First).Next).Prev /= L.First then return False; end if; if N (N (L.Last).Prev).Next /= L.Last then return False; end if; if L.Length = 2 then if N (L.First).Next /= L.Last then return False; end if; if N (L.Last).Prev /= L.First then return False; end if; return True; end if; if N (L.First).Next = L.Last then return False; end if; if N (L.Last).Prev = L.First then return False; end if; if Position.Node = L.First then return True; end if; if Position.Node = L.Last then return True; end if; if N (Position.Node).Next = 0 then return False; end if; if N (Position.Node).Prev = 0 then return False; end if; if N (N (Position.Node).Next).Prev /= Position.Node then return False; end if; if N (N (Position.Node).Prev).Next /= Position.Node then return False; end if; if L.Length = 3 then if N (L.First).Next /= Position.Node then return False; end if; if N (L.Last).Prev /= Position.Node then return False; end if; end if; return True; end; end Vet; end Ada.Containers.Restricted_Doubly_Linked_Lists;
zhmu/ananas
Ada
20,890
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . T A S K I N G . E N T R Y _ C A L L S -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ with System.Task_Primitives.Operations; with System.Tasking.Initialization; with System.Tasking.Protected_Objects.Entries; with System.Tasking.Protected_Objects.Operations; with System.Tasking.Queuing; with System.Tasking.Utilities; package body System.Tasking.Entry_Calls is package STPO renames System.Task_Primitives.Operations; use Protected_Objects.Entries; use Protected_Objects.Operations; -- DO NOT use Protected_Objects.Lock or Protected_Objects.Unlock -- internally. Those operations will raise Program_Error, which -- we are not prepared to handle inside the RTS. Instead, use -- System.Task_Primitives lock operations directly on Protection.L. ----------------------- -- Local Subprograms -- ----------------------- procedure Lock_Server (Entry_Call : Entry_Call_Link); -- This locks the server targeted by Entry_Call -- -- This may be a task or a protected object, depending on the target of the -- original call or any subsequent requeues. -- -- This routine is needed because the field specifying the server for this -- call must be protected by the server's mutex. If it were protected by -- the caller's mutex, accessing the server's queues would require locking -- the caller to get the server, locking the server, and then accessing the -- queues. This involves holding two ATCB locks at once, something which we -- can guarantee that it will always be done in the same order, or locking -- a protected object while we hold an ATCB lock, something which is not -- permitted. Since the server cannot be obtained reliably, it must be -- obtained unreliably and then checked again once it has been locked. -- -- This should only be called by the Entry_Call.Self. -- It should be holding no other ATCB locks at the time. procedure Unlock_Server (Entry_Call : Entry_Call_Link); -- STPO.Unlock the server targeted by Entry_Call. The server must -- be locked before calling this. procedure Unlock_And_Update_Server (Self_ID : Task_Id; Entry_Call : Entry_Call_Link); -- Similar to Unlock_Server, but services entry calls if the -- server is a protected object. procedure Check_Pending_Actions_For_Entry_Call (Self_ID : Task_Id; Entry_Call : Entry_Call_Link); -- This procedure performs priority change of a queued call and dequeuing -- of an entry call when the call is cancelled. If the call is dequeued the -- state should be set to Cancelled. Call only with abort deferred and -- holding lock of Self_ID. This is a bit of common code for all entry -- calls. The effect is to do any deferred base priority change operation, -- in case some other task called STPO.Set_Priority while the current task -- had abort deferred, and to dequeue the call if the call has been -- aborted. procedure Poll_Base_Priority_Change_At_Entry_Call (Self_ID : Task_Id; Entry_Call : Entry_Call_Link); pragma Inline (Poll_Base_Priority_Change_At_Entry_Call); -- A specialized version of Poll_Base_Priority_Change, that does the -- optional entry queue reordering. Has to be called with the Self_ID's -- ATCB write-locked. May temporarily release the lock. --------------------- -- Check_Exception -- --------------------- procedure Check_Exception (Self_ID : Task_Id; Entry_Call : Entry_Call_Link) is pragma Warnings (Off, Self_ID); use type Ada.Exceptions.Exception_Id; procedure Internal_Raise (X : Ada.Exceptions.Exception_Id); pragma Import (C, Internal_Raise, "__gnat_raise_with_msg"); E : constant Ada.Exceptions.Exception_Id := Entry_Call.Exception_To_Raise; begin -- pragma Assert (Self_ID.Deferral_Level = 0); -- The above may be useful for debugging, but the Florist packages -- contain critical sections that defer abort and then do entry calls, -- which causes the above Assert to trip. if E /= Ada.Exceptions.Null_Id then Internal_Raise (E); end if; end Check_Exception; ------------------------------------------ -- Check_Pending_Actions_For_Entry_Call -- ------------------------------------------ procedure Check_Pending_Actions_For_Entry_Call (Self_ID : Task_Id; Entry_Call : Entry_Call_Link) is begin pragma Assert (Self_ID = Entry_Call.Self); Poll_Base_Priority_Change_At_Entry_Call (Self_ID, Entry_Call); if Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level and then Entry_Call.State = Now_Abortable then STPO.Unlock (Self_ID); Lock_Server (Entry_Call); if Queuing.Onqueue (Entry_Call) and then Entry_Call.State = Now_Abortable then Queuing.Dequeue_Call (Entry_Call); Entry_Call.State := (if Entry_Call.Cancellation_Attempted then Cancelled else Done); Unlock_And_Update_Server (Self_ID, Entry_Call); else Unlock_Server (Entry_Call); end if; STPO.Write_Lock (Self_ID); end if; end Check_Pending_Actions_For_Entry_Call; ----------------- -- Lock_Server -- ----------------- procedure Lock_Server (Entry_Call : Entry_Call_Link) is Test_Task : Task_Id; Test_PO : Protection_Entries_Access; Ceiling_Violation : Boolean; Failures : Integer := 0; begin Test_Task := Entry_Call.Called_Task; loop if Test_Task = null then -- Entry_Call was queued on a protected object, or in transition, -- when we last fetched Test_Task. Test_PO := To_Protection (Entry_Call.Called_PO); if Test_PO = null then -- We had very bad luck, interleaving with TWO different -- requeue operations. Go around the loop and try again. STPO.Yield; else Lock_Entries_With_Status (Test_PO, Ceiling_Violation); -- ??? -- The following code allows Lock_Server to be called when -- cancelling a call, to allow for the possibility that the -- priority of the caller has been raised beyond that of the -- protected entry call by Ada.Dynamic_Priorities.Set_Priority. -- If the current task has a higher priority than the ceiling -- of the protected object, temporarily lower it. It will -- be reset in Unlock. if Ceiling_Violation then declare Current_Task : constant Task_Id := STPO.Self; Old_Base_Priority : System.Any_Priority; begin STPO.Write_Lock (Current_Task); Old_Base_Priority := Current_Task.Common.Base_Priority; Current_Task.New_Base_Priority := Test_PO.Ceiling; System.Tasking.Initialization.Change_Base_Priority (Current_Task); STPO.Unlock (Current_Task); -- Following lock should not fail Lock_Entries (Test_PO); Test_PO.Old_Base_Priority := Old_Base_Priority; Test_PO.Pending_Action := True; end; end if; exit when To_Address (Test_PO) = Entry_Call.Called_PO; Unlock_Entries (Test_PO); end if; else STPO.Write_Lock (Test_Task); exit when Test_Task = Entry_Call.Called_Task; STPO.Unlock (Test_Task); end if; Test_Task := Entry_Call.Called_Task; Failures := Failures + 1; pragma Assert (Failures <= 5); end loop; end Lock_Server; --------------------------------------------- -- Poll_Base_Priority_Change_At_Entry_Call -- --------------------------------------------- procedure Poll_Base_Priority_Change_At_Entry_Call (Self_ID : Task_Id; Entry_Call : Entry_Call_Link) is begin if Self_ID.Pending_Priority_Change then -- Check for ceiling violations ??? Self_ID.Pending_Priority_Change := False; -- Requeue the entry call at the new priority. We need to requeue -- even if the new priority is the same than the previous (see ACATS -- test cxd4006). STPO.Unlock (Self_ID); Lock_Server (Entry_Call); Queuing.Requeue_Call_With_New_Prio (Entry_Call, STPO.Get_Priority (Self_ID)); Unlock_And_Update_Server (Self_ID, Entry_Call); STPO.Write_Lock (Self_ID); end if; end Poll_Base_Priority_Change_At_Entry_Call; -------------------- -- Reset_Priority -- -------------------- procedure Reset_Priority (Acceptor : Task_Id; Acceptor_Prev_Priority : Rendezvous_Priority) is begin pragma Assert (Acceptor = STPO.Self); -- Since we limit this kind of "active" priority change to be done -- by the task for itself, we don't need to lock Acceptor. if Acceptor_Prev_Priority /= Priority_Not_Boosted then STPO.Set_Priority (Acceptor, Acceptor_Prev_Priority, Loss_Of_Inheritance => True); end if; end Reset_Priority; ------------------------------ -- Try_To_Cancel_Entry_Call -- ------------------------------ procedure Try_To_Cancel_Entry_Call (Succeeded : out Boolean) is Entry_Call : Entry_Call_Link; Self_ID : constant Task_Id := STPO.Self; use type Ada.Exceptions.Exception_Id; begin Entry_Call := Self_ID.Entry_Calls (Self_ID.ATC_Nesting_Level)'Access; -- Experimentation has shown that abort is sometimes (but not -- always) already deferred when Cancel_xxx_Entry_Call is called. -- That may indicate an error. Find out what is going on. ??? pragma Assert (Entry_Call.Mode = Asynchronous_Call); Initialization.Defer_Abort_Nestable (Self_ID); STPO.Write_Lock (Self_ID); Entry_Call.Cancellation_Attempted := True; if Self_ID.Pending_ATC_Level >= Entry_Call.Level then Self_ID.Pending_ATC_Level := Entry_Call.Level - 1; end if; Entry_Calls.Wait_For_Completion (Entry_Call); STPO.Unlock (Self_ID); Succeeded := Entry_Call.State = Cancelled; Initialization.Undefer_Abort_Nestable (Self_ID); -- Ideally, abort should no longer be deferred at this point, so we -- should be able to call Check_Exception. The loop below should be -- considered temporary, to work around the possibility that abort -- may be deferred more than one level deep ??? if Entry_Call.Exception_To_Raise /= Ada.Exceptions.Null_Id then while Self_ID.Deferral_Level > 0 loop System.Tasking.Initialization.Undefer_Abort_Nestable (Self_ID); end loop; Entry_Calls.Check_Exception (Self_ID, Entry_Call); end if; end Try_To_Cancel_Entry_Call; ------------------------------ -- Unlock_And_Update_Server -- ------------------------------ procedure Unlock_And_Update_Server (Self_ID : Task_Id; Entry_Call : Entry_Call_Link) is Called_PO : Protection_Entries_Access; Caller : Task_Id; begin if Entry_Call.Called_Task /= null then STPO.Unlock (Entry_Call.Called_Task); else Called_PO := To_Protection (Entry_Call.Called_PO); PO_Service_Entries (Self_ID, Called_PO, False); if Called_PO.Pending_Action then Called_PO.Pending_Action := False; Caller := STPO.Self; STPO.Write_Lock (Caller); Caller.New_Base_Priority := Called_PO.Old_Base_Priority; Initialization.Change_Base_Priority (Caller); STPO.Unlock (Caller); end if; Unlock_Entries (Called_PO); end if; end Unlock_And_Update_Server; ------------------- -- Unlock_Server -- ------------------- procedure Unlock_Server (Entry_Call : Entry_Call_Link) is Caller : Task_Id; Called_PO : Protection_Entries_Access; begin if Entry_Call.Called_Task /= null then STPO.Unlock (Entry_Call.Called_Task); else Called_PO := To_Protection (Entry_Call.Called_PO); if Called_PO.Pending_Action then Called_PO.Pending_Action := False; Caller := STPO.Self; STPO.Write_Lock (Caller); Caller.New_Base_Priority := Called_PO.Old_Base_Priority; Initialization.Change_Base_Priority (Caller); STPO.Unlock (Caller); end if; Unlock_Entries (Called_PO); end if; end Unlock_Server; ------------------------- -- Wait_For_Completion -- ------------------------- procedure Wait_For_Completion (Entry_Call : Entry_Call_Link) is Self_Id : constant Task_Id := Entry_Call.Self; begin -- If this is a conditional call, it should be cancelled when it -- becomes abortable. This is checked in the loop below. Self_Id.Common.State := Entry_Caller_Sleep; -- Try to remove calls to Sleep in the loop below by letting the caller -- a chance of getting ready immediately, using Unlock & Yield. -- See similar action in Wait_For_Call & Timed_Selective_Wait. STPO.Unlock (Self_Id); if Entry_Call.State < Done then STPO.Yield; end if; STPO.Write_Lock (Self_Id); loop Check_Pending_Actions_For_Entry_Call (Self_Id, Entry_Call); exit when Entry_Call.State >= Done; STPO.Sleep (Self_Id, Entry_Caller_Sleep); end loop; Self_Id.Common.State := Runnable; Utilities.Exit_One_ATC_Level (Self_Id); end Wait_For_Completion; -------------------------------------- -- Wait_For_Completion_With_Timeout -- -------------------------------------- procedure Wait_For_Completion_With_Timeout (Entry_Call : Entry_Call_Link; Wakeup_Time : Duration; Mode : Delay_Modes; Yielded : out Boolean) is Self_Id : constant Task_Id := Entry_Call.Self; Timedout : Boolean := False; begin -- This procedure waits for the entry call to be served, with a timeout. -- It tries to cancel the call if the timeout expires before the call is -- served. -- If we wake up from the timed sleep operation here, it may be for -- several possible reasons: -- 1) The entry call is done being served. -- 2) There is an abort or priority change to be served. -- 3) The timeout has expired (Timedout = True) -- 4) There has been a spurious wakeup. -- Once the timeout has expired we may need to continue to wait if the -- call is already being serviced. In that case, we want to go back to -- sleep, but without any timeout. The variable Timedout is used to -- control this. If the Timedout flag is set, we do not need to -- STPO.Sleep with a timeout. We just sleep until we get a wakeup for -- some status change. -- The original call may have become abortable after waking up. We want -- to check Check_Pending_Actions_For_Entry_Call again in any case. pragma Assert (Entry_Call.Mode = Timed_Call); Yielded := False; Self_Id.Common.State := Entry_Caller_Sleep; -- Looping is necessary in case the task wakes up early from the timed -- sleep, due to a "spurious wakeup". Spurious wakeups are a weakness of -- POSIX condition variables. A thread waiting for a condition variable -- is allowed to wake up at any time, not just when the condition is -- signaled. See same loop in the ordinary Wait_For_Completion, above. loop Check_Pending_Actions_For_Entry_Call (Self_Id, Entry_Call); exit when Entry_Call.State >= Done; STPO.Timed_Sleep (Self_Id, Wakeup_Time, Mode, Entry_Caller_Sleep, Timedout, Yielded); if Timedout then -- Try to cancel the call (see Try_To_Cancel_Entry_Call for -- corresponding code in the ATC case). Entry_Call.Cancellation_Attempted := True; -- Reset Entry_Call.State so that the call is marked as cancelled -- by Check_Pending_Actions_For_Entry_Call below. if Entry_Call.State < Was_Abortable then Entry_Call.State := Now_Abortable; end if; if Self_Id.Pending_ATC_Level >= Entry_Call.Level then Self_Id.Pending_ATC_Level := Entry_Call.Level - 1; end if; -- The following loop is the same as the loop and exit code -- from the ordinary Wait_For_Completion. If we get here, we -- have timed out but we need to keep waiting until the call -- has actually completed or been cancelled successfully. loop Check_Pending_Actions_For_Entry_Call (Self_Id, Entry_Call); exit when Entry_Call.State >= Done; STPO.Sleep (Self_Id, Entry_Caller_Sleep); end loop; Self_Id.Common.State := Runnable; Utilities.Exit_One_ATC_Level (Self_Id); return; end if; end loop; -- This last part is the same as ordinary Wait_For_Completion, -- and is only executed if the call completed without timing out. Self_Id.Common.State := Runnable; Utilities.Exit_One_ATC_Level (Self_Id); end Wait_For_Completion_With_Timeout; -------------------------- -- Wait_Until_Abortable -- -------------------------- procedure Wait_Until_Abortable (Self_ID : Task_Id; Call : Entry_Call_Link) is begin pragma Assert (Self_ID.ATC_Nesting_Level > Level_No_ATC_Occurring); pragma Assert (Call.Mode = Asynchronous_Call); STPO.Write_Lock (Self_ID); Self_ID.Common.State := Entry_Caller_Sleep; loop Check_Pending_Actions_For_Entry_Call (Self_ID, Call); exit when Call.State >= Was_Abortable; STPO.Sleep (Self_ID, Async_Select_Sleep); end loop; Self_ID.Common.State := Runnable; STPO.Unlock (Self_ID); end Wait_Until_Abortable; end System.Tasking.Entry_Calls;
reznikmm/matreshka
Ada
3,714
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Text_Use_Tables_Attributes is pragma Preelaborate; type ODF_Text_Use_Tables_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Text_Use_Tables_Attribute_Access is access all ODF_Text_Use_Tables_Attribute'Class with Storage_Size => 0; end ODF.DOM.Text_Use_Tables_Attributes;
mmarx/lovelace
Ada
1,948
ads
with Interfaces.C; use Interfaces.C; with x86_64_linux_gnu_bits_types_h; limited with x86_64_linux_gnu_bits_resource_h; package sys_resource_h is subtype id_t is x86_64_linux_gnu_bits_types_h.uu_id_t; -- /usr/include/sys/resource.h:28 subtype uu_rlimit_resource_t is int; -- /usr/include/sys/resource.h:43 subtype uu_rusage_who_t is int; -- /usr/include/sys/resource.h:44 subtype uu_priority_which_t is int; -- /usr/include/sys/resource.h:45 function getrlimit (uu_resource : uu_rlimit_resource_t; uu_rlimits : access x86_64_linux_gnu_bits_resource_h.rlimit) return int; -- /usr/include/sys/resource.h:51 pragma Import (C, getrlimit, "getrlimit"); function getrlimit64 (uu_resource : uu_rlimit_resource_t; uu_rlimits : access x86_64_linux_gnu_bits_resource_h.rlimit64) return int; -- /usr/include/sys/resource.h:62 pragma Import (C, getrlimit64, "getrlimit64"); function setrlimit (uu_resource : uu_rlimit_resource_t; uu_rlimits : access constant x86_64_linux_gnu_bits_resource_h.rlimit) return int; -- /usr/include/sys/resource.h:70 pragma Import (C, setrlimit, "setrlimit"); function setrlimit64 (uu_resource : uu_rlimit_resource_t; uu_rlimits : access constant x86_64_linux_gnu_bits_resource_h.rlimit64) return int; -- /usr/include/sys/resource.h:82 pragma Import (C, setrlimit64, "setrlimit64"); function getrusage (uu_who : uu_rusage_who_t; uu_usage : access x86_64_linux_gnu_bits_resource_h.rusage) return int; -- /usr/include/sys/resource.h:88 pragma Import (C, getrusage, "getrusage"); function getpriority (uu_which : uu_priority_which_t; uu_who : id_t) return int; -- /usr/include/sys/resource.h:94 pragma Import (C, getpriority, "getpriority"); function setpriority (uu_which : uu_priority_which_t; uu_who : id_t; uu_prio : int) return int; -- /usr/include/sys/resource.h:98 pragma Import (C, setpriority, "setpriority"); end sys_resource_h;
Rodeo-McCabe/orka
Ada
4,656
adb
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2017 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. package body Orka.glTF.Accessors is function Unsigned_Type (Value : Component_Kind) return GL.Types.Index_Type is begin case Value is when Unsigned_Short => return GL.Types.UShort_Type; when Unsigned_Int => return GL.Types.UInt_Type; when others => -- Note: Unsigned_Byte is not supported for commonality with Vulkan raise Constraint_Error with "accessor.componentType is not ushort or uint"; end case; end Unsigned_Type; function Create_Bounds (Bounds : Types.JSON_Value) return Transforms.Vector4 is Key : constant array (Positive range 1 .. 4) of Index_Homogeneous := (1 => X, 2 => Y, 3 => Z, 4 => W); begin return Result : Transforms.Vector4 := Transforms.Zero_Direction do for Index in 1 .. Bounds.Length loop Result (Key (Index)) := Bounds.Get (Index).Value; end loop; end return; end Create_Bounds; function Create_Accessor (Object : Types.JSON_Value) return Accessor is View : constant Long_Integer := Object.Get ("bufferView").Value; Offset : constant Long_Integer := Object.Get ("byteOffset", 0).Value; pragma Assert (Offset mod 4 = 0); Component_Type : constant Long_Integer := Object.Get ("componentType").Value; Element_Type : constant String := Object.Get ("type").Value; Component : Component_Kind; Kind : Attribute_Kind; begin case Component_Type is when 5120 => Component := Byte; when 5121 => Component := Unsigned_Byte; when 5122 => Component := Short; when 5123 => Component := Unsigned_Short; when 5125 => Component := Unsigned_Int; when 5126 => Component := Float; when others => raise Constraint_Error with "Invalid accessor.componentType"; end case; if Element_Type = "SCALAR" then Kind := Scalar; elsif Element_Type = "VEC2" then Kind := Vector2; elsif Element_Type = "VEC3" then Kind := Vector3; elsif Element_Type = "VEC4" then Kind := Vector4; elsif Element_Type = "MAT2" then Kind := Matrix2; elsif Element_Type = "MAT3" then Kind := Matrix3; elsif Element_Type = "MAT4" then Kind := Matrix4; else raise Constraint_Error with "Invalid accessor.type"; end if; return Result : Accessor (Kind in Scalar .. Vector4) do Result.View := Natural (View); Result.Offset := Natural (Offset); Result.Component := Component; Result.Kind := Kind; Result.Normalized := Object.Get ("normalized", False).Value; Result.Count := Positive (Long_Integer'(Object.Get ("count").Value)); Result.Min_Bounds := Create_Bounds (Object.Get ("min")); Result.Max_Bounds := Create_Bounds (Object.Get ("max")); end return; end Create_Accessor; function Get_Accessors (Accessors : Types.JSON_Value) return Accessor_Vectors.Vector is Result : Accessor_Vectors.Vector (Capacity => Accessors.Length); begin for Accessor of Accessors loop -- TODO accessor.byteOffset + bufferView.byteOffset mod componentType = 0 -- -- TODO byteStride optional: if not defined, then values are tightly packed: -- = accessor.componentType * bytes(accessor.kind) -- bufferView.byteStride mod accessor.componentType = 0 -- -- TODO accessor.byteOffset + STRIDE * (accessor.count - 1) + SIZE_OF_ELEMENT <= bufferView.length if Accessor.Contains ("sparse") then raise Constraint_Error with "Sparse accessor is not supported"; end if; Result.Append (Create_Accessor (Accessor)); end loop; return Result; end Get_Accessors; end Orka.glTF.Accessors;
zhmu/ananas
Ada
22,649
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . S T R I N G S . S E A R C H -- -- -- -- 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 search functions from Ada.Strings.Fixed. They -- are separated out because they are shared by Ada.Strings.Bounded and -- Ada.Strings.Unbounded, and we don't want to drag in other irrelevant stuff -- from Ada.Strings.Fixed when using the other two packages. Although user -- programs should access these subprograms via one of the standard string -- packages, we do not make this a private package, since ghost function -- Match is used in the contracts of the standard string packages. -- Preconditions in this unit are meant for analysis only, not for run-time -- checking, so that the expected exceptions are raised. This is enforced -- by setting the corresponding assertion policy to Ignore. Postconditions, -- contract cases and ghost code should not be executed at runtime as well, -- in order not to slow down the execution of these functions. pragma Assertion_Policy (Pre => Ignore, Post => Ignore, Contract_Cases => Ignore, Ghost => Ignore); with Ada.Strings.Maps; use type Ada.Strings.Maps.Character_Mapping_Function; package Ada.Strings.Search with SPARK_Mode is pragma Preelaborate; -- The ghost function Match tells whether the slice of Source starting at -- From and of length Pattern'Length matches with Pattern with respect to -- Mapping. Pattern should be non-empty and the considered slice should be -- fully included in Source'Range. function Match (Source : String; Pattern : String; Mapping : Maps.Character_Mapping_Function; From : Integer) return Boolean is (for all K in Pattern'Range => Pattern (K) = Mapping (Source (From + (K - Pattern'First)))) with Ghost, Pre => Mapping /= null and then Pattern'Length > 0 and then Source'Length > 0 and then From in Source'First .. Source'Last - (Pattern'Length - 1), Global => null; function Match (Source : String; Pattern : String; Mapping : Maps.Character_Mapping; From : Integer) return Boolean is (for all K in Pattern'Range => Pattern (K) = Ada.Strings.Maps.Value (Mapping, Source (From + (K - Pattern'First)))) with Ghost, Pre => Pattern'Length > 0 and then Source'Length > 0 and then From in Source'First .. Source'Last - (Pattern'Length - 1), Global => null; function Is_Identity (Mapping : Maps.Character_Mapping) return Boolean with Post => (if Is_Identity'Result then (for all K in Character => Ada.Strings.Maps.Value (Mapping, K) = K)), Global => null; function Index (Source : String; Pattern : String; Going : Direction := Forward; Mapping : Maps.Character_Mapping := Maps.Identity) return Natural with Pre => Pattern'Length > 0, Post => Index'Result in 0 | Source'Range, Contract_Cases => -- If Source is the empty string, then 0 is returned (Source'Length = 0 => Index'Result = 0, -- If some slice of Source matches Pattern, then a valid index is -- returned. Source'Length > 0 and then (for some J in Source'First .. Source'Last - (Pattern'Length - 1) => Match (Source, Pattern, Mapping, J)) => -- The result is in the considered range of Source Index'Result in Source'First .. Source'Last - (Pattern'Length - 1) -- The slice beginning at the returned index matches Pattern and then Match (Source, Pattern, Mapping, Index'Result) -- The result is the smallest or largest index which satisfies -- the matching, respectively when Going = Forward and Going = -- Backward. and then (for all J in Source'Range => (if (if Going = Forward then J <= Index'Result - 1 else J - 1 in Index'Result .. Source'Last - Pattern'Length) then not (Match (Source, Pattern, Mapping, J)))), -- Otherwise, 0 is returned others => Index'Result = 0), Global => null; function Index (Source : String; Pattern : String; Going : Direction := Forward; Mapping : Maps.Character_Mapping_Function) return Natural with Pre => Pattern'Length > 0 and then Mapping /= null, Post => Index'Result in 0 | Source'Range, Contract_Cases => -- If Source is the null string, then 0 is returned (Source'Length = 0 => Index'Result = 0, -- If some slice of Source matches Pattern, then a valid index is -- returned. Source'Length > 0 and then (for some J in Source'First .. Source'Last - (Pattern'Length - 1) => Match (Source, Pattern, Mapping, J)) => -- The result is in the considered range of Source Index'Result in Source'First .. Source'Last - (Pattern'Length - 1) -- The slice beginning at the returned index matches Pattern and then Match (Source, Pattern, Mapping, Index'Result) -- The result is the smallest or largest index which satisfies -- the matching, respectively when Going = Forward and Going = -- Backward. and then (for all J in Source'Range => (if (if Going = Forward then J <= Index'Result - 1 else J - 1 in Index'Result .. Source'Last - Pattern'Length) then not (Match (Source, Pattern, Mapping, J)))), -- Otherwise, 0 is returned others => Index'Result = 0), Global => null; function Index (Source : String; Set : Maps.Character_Set; Test : Membership := Inside; Going : Direction := Forward) return Natural with Post => Index'Result in 0 | Source'Range, Contract_Cases => -- If no character of Source satisfies the property Test on Set, then -- 0 is returned. ((for all C of Source => (Test = Inside) /= Ada.Strings.Maps.Is_In (C, Set)) => Index'Result = 0, -- Otherwise, an index in the range of Source is returned others => -- The result is in the range of Source Index'Result in Source'Range -- The character at the returned index satisfies the property -- Test on Set. and then (Test = Inside) = Ada.Strings.Maps.Is_In (Source (Index'Result), Set) -- The result is the smallest or largest index which satisfies -- the property, respectively when Going = Forward and Going = -- Backward. and then (for all J in Source'Range => (if J /= Index'Result and then (J < Index'Result) = (Going = Forward) then (Test = Inside) /= Ada.Strings.Maps.Is_In (Source (J), Set)))), Global => null; function Index (Source : String; Pattern : String; From : Positive; Going : Direction := Forward; Mapping : Maps.Character_Mapping := Maps.Identity) return Natural with Pre => Pattern'Length > 0 and then (if Source'Length > 0 then From in Source'Range), Post => Index'Result in 0 | Source'Range, Contract_Cases => -- If Source is the empty string, then 0 is returned (Source'Length = 0 => Index'Result = 0, -- If some slice of Source matches Pattern, then a valid index is -- returned. Source'Length > 0 and then (for some J in (if Going = Forward then From else Source'First) .. (if Going = Forward then Source'Last else From) - (Pattern'Length - 1) => Match (Source, Pattern, Mapping, J)) => -- The result is in the considered range of Source Index'Result in (if Going = Forward then From else Source'First) .. (if Going = Forward then Source'Last else From) - (Pattern'Length - 1) -- The slice beginning at the returned index matches Pattern and then Match (Source, Pattern, Mapping, Index'Result) -- The result is the smallest or largest index which satisfies -- the matching, respectively when Going = Forward and Going = -- Backward. and then (for all J in Source'Range => (if (if Going = Forward then J in From .. Index'Result - 1 else J - 1 in Index'Result .. From - Pattern'Length) then not (Match (Source, Pattern, Mapping, J)))), -- Otherwise, 0 is returned others => Index'Result = 0), Global => null; function Index (Source : String; Pattern : String; From : Positive; Going : Direction := Forward; Mapping : Maps.Character_Mapping_Function) return Natural with Pre => Pattern'Length > 0 and then Mapping /= null and then (if Source'Length > 0 then From in Source'Range), Post => Index'Result in 0 | Source'Range, Contract_Cases => -- If Source is the empty string, then 0 is returned (Source'Length = 0 => Index'Result = 0, -- If some slice of Source matches Pattern, then a valid index is -- returned. Source'Length > 0 and then (for some J in (if Going = Forward then From else Source'First) .. (if Going = Forward then Source'Last else From) - (Pattern'Length - 1) => Match (Source, Pattern, Mapping, J)) => -- The result is in the considered range of Source Index'Result in (if Going = Forward then From else Source'First) .. (if Going = Forward then Source'Last else From) - (Pattern'Length - 1) -- The slice beginning at the returned index matches Pattern and then Match (Source, Pattern, Mapping, Index'Result) -- The result is the smallest or largest index which satisfies -- the matching, respectively when Going = Forward and Going = -- Backwards. and then (for all J in Source'Range => (if (if Going = Forward then J in From .. Index'Result - 1 else J - 1 in Index'Result .. From - Pattern'Length) then not (Match (Source, Pattern, Mapping, J)))), -- Otherwise, 0 is returned others => Index'Result = 0), Global => null; function Index (Source : String; Set : Maps.Character_Set; From : Positive; Test : Membership := Inside; Going : Direction := Forward) return Natural with Pre => (if Source'Length > 0 then From in Source'Range), Post => Index'Result in 0 | Source'Range, Contract_Cases => -- If Source is the empty string, or no character of the considered -- slice of Source satisfies the property Test on Set, then 0 is -- returned. (Source'Length = 0 or else (for all J in Source'Range => (if J = From or else (J > From) = (Going = Forward) then (Test = Inside) /= Ada.Strings.Maps.Is_In (Source (J), Set))) => Index'Result = 0, -- Otherwise, an index in the considered range of Source is returned others => -- The result is in the considered range of Source Index'Result in Source'Range and then (Index'Result = From or else (Index'Result > From) = (Going = Forward)) -- The character at the returned index satisfies the property -- Test on Set and then (Test = Inside) = Ada.Strings.Maps.Is_In (Source (Index'Result), Set) -- The result is the smallest or largest index which satisfies -- the property, respectively when Going = Forward and Going = -- Backward. and then (for all J in Source'Range => (if J /= Index'Result and then (J < Index'Result) = (Going = Forward) and then (J = From or else (J > From) = (Going = Forward)) then (Test = Inside) /= Ada.Strings.Maps.Is_In (Source (J), Set)))), Global => null; function Index_Non_Blank (Source : String; Going : Direction := Forward) return Natural with Post => Index_Non_Blank'Result in 0 | Source'Range, Contract_Cases => -- If all characters of Source are Space characters, then 0 is -- returned. ((for all C of Source => C = ' ') => Index_Non_Blank'Result = 0, -- Otherwise, a valid index is returned others => -- The result is in the range of Source Index_Non_Blank'Result in Source'Range -- The character at the returned index is not a Space character and then Source (Index_Non_Blank'Result) /= ' ' -- The result is the smallest or largest index which is not a -- Space character, respectively when Going = Forward and -- Going = Backward. and then (for all J in Source'Range => (if J /= Index_Non_Blank'Result and then (J < Index_Non_Blank'Result) = (Going = Forward) then Source (J) = ' '))), Global => null; function Index_Non_Blank (Source : String; From : Positive; Going : Direction := Forward) return Natural with Pre => (if Source'Length /= 0 then From in Source'Range), Post => Index_Non_Blank'Result in 0 | Source'Range, Contract_Cases => -- If Source is the null string, or all characters in the considered -- slice of Source are Space characters, then 0 is returned. (Source'Length = 0 or else (for all J in Source'Range => (if J = From or else (J > From) = (Going = Forward) then Source (J) = ' ')) => Index_Non_Blank'Result = 0, -- Otherwise, a valid index is returned others => -- The result is in the considered range of Source Index_Non_Blank'Result in Source'Range and then (Index_Non_Blank'Result = From or else (Index_Non_Blank'Result > From) = (Going = Forward)) -- The character at the returned index is not a Space character and then Source (Index_Non_Blank'Result) /= ' ' -- The result is the smallest or largest index which is not a -- Space character, respectively when Going = Forward and -- Going = Backward. and then (for all J in Source'Range => (if J /= Index_Non_Blank'Result and then (J < Index_Non_Blank'Result) = (Going = Forward) and then (J = From or else (J > From) = (Going = Forward)) then Source (J) = ' '))), Global => null; function Count (Source : String; Pattern : String; Mapping : Maps.Character_Mapping := Maps.Identity) return Natural with Pre => Pattern'Length > 0, Global => null; function Count (Source : String; Pattern : String; Mapping : Maps.Character_Mapping_Function) return Natural with Pre => Pattern'Length > 0 and then Mapping /= null, Global => null; function Count (Source : String; Set : Maps.Character_Set) return Natural with Global => null; procedure Find_Token (Source : String; Set : Maps.Character_Set; From : Positive; Test : Membership; First : out Positive; Last : out Natural) with Pre => (if Source'Length /= 0 then From in Source'Range), Contract_Cases => -- If Source is the empty string, or if no character of the considered -- slice of Source satisfies the property Test on Set, then First is -- set to From and Last is set to 0. (Source'Length = 0 or else (for all C of Source (From .. Source'Last) => (Test = Inside) /= Ada.Strings.Maps.Is_In (C, Set)) => First = From and then Last = 0, -- Otherwise, First and Last are set to valid indexes others => -- First and Last are in the considered range of Source First in From .. Source'Last and then Last in First .. Source'Last -- No character between From and First satisfies the property Test -- on Set. and then (for all C of Source (From .. First - 1) => (Test = Inside) /= Ada.Strings.Maps.Is_In (C, Set)) -- All characters between First and Last satisfy the property Test -- on Set. and then (for all C of Source (First .. Last) => (Test = Inside) = Ada.Strings.Maps.Is_In (C, Set)) -- If Last is not Source'Last, then the character at position -- Last + 1 does not satify the property Test on Set. and then (if Last < Source'Last then (Test = Inside) /= Ada.Strings.Maps.Is_In (Source (Last + 1), Set))), Global => null; procedure Find_Token (Source : String; Set : Maps.Character_Set; Test : Membership; First : out Positive; Last : out Natural) with Pre => Source'First > 0, Contract_Cases => -- If Source is the empty string, or if no character of Source -- satisfies the property Test on Set, then First is set to From -- and Last is set to 0. (Source'Length = 0 or else (for all C of Source => (Test = Inside) /= Ada.Strings.Maps.Is_In (C, Set)) => First = Source'First and then Last = 0, -- Otherwise, First and Last are set to valid indexes others => -- First and Last are in the considered range of Source First in Source'Range and then Last in First .. Source'Last -- No character before First satisfies the property Test on Set and then (for all C of Source (Source'First .. First - 1) => (Test = Inside) /= Ada.Strings.Maps.Is_In (C, Set)) -- All characters between First and Last satisfy the property Test -- on Set. and then (for all C of Source (First .. Last) => (Test = Inside) = Ada.Strings.Maps.Is_In (C, Set)) -- If Last is not Source'Last, then the character at position -- Last + 1 does not satify the property Test on Set. and then (if Last < Source'Last then (Test = Inside) /= Ada.Strings.Maps.Is_In (Source (Last + 1), Set))), Global => null; end Ada.Strings.Search;
dkm/atomic
Ada
359
ads
private with Interfaces; package Atomic.Critical_Section with Preelaborate is type Interrupt_State is private; procedure Enter (State : out Interrupt_State) with Inline_Always; procedure Leave (State : Interrupt_State) with Inline_Always; private type Interrupt_State is new Interfaces.Unsigned_32; end Atomic.Critical_Section;
AdaCore/Ada_Drivers_Library
Ada
22,535
ads
-- This spec has been automatically generated from STM32F7x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.SAI is pragma Preelaborate; --------------- -- Registers -- --------------- subtype GCR_SYNCIN_Field is HAL.UInt2; subtype GCR_SYNCOUT_Field is HAL.UInt2; -- Global configuration register type GCR_Register is record -- Synchronization inputs SYNCIN : GCR_SYNCIN_Field := 16#0#; -- unspecified Reserved_2_3 : HAL.UInt2 := 16#0#; -- Synchronization outputs SYNCOUT : GCR_SYNCOUT_Field := 16#0#; -- unspecified Reserved_6_31 : HAL.UInt26 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for GCR_Register use record SYNCIN at 0 range 0 .. 1; Reserved_2_3 at 0 range 2 .. 3; SYNCOUT at 0 range 4 .. 5; Reserved_6_31 at 0 range 6 .. 31; end record; subtype ACR1_MODE_Field is HAL.UInt2; subtype ACR1_PRTCFG_Field is HAL.UInt2; subtype ACR1_DS_Field is HAL.UInt3; subtype ACR1_SYNCEN_Field is HAL.UInt2; subtype ACR1_MCJDIV_Field is HAL.UInt4; -- AConfiguration register 1 type ACR1_Register is record -- Audio block mode MODE : ACR1_MODE_Field := 16#0#; -- Protocol configuration PRTCFG : ACR1_PRTCFG_Field := 16#0#; -- unspecified Reserved_4_4 : HAL.Bit := 16#0#; -- Data size DS : ACR1_DS_Field := 16#2#; -- Least significant bit first LSBFIRST : Boolean := False; -- Clock strobing edge CKSTR : Boolean := False; -- Synchronization enable SYNCEN : ACR1_SYNCEN_Field := 16#0#; -- Mono mode MONO : Boolean := False; -- Output drive OutDri : Boolean := False; -- unspecified Reserved_14_15 : HAL.UInt2 := 16#0#; -- Audio block A enable SAIAEN : Boolean := False; -- DMA enable DMAEN : Boolean := False; -- unspecified Reserved_18_18 : HAL.Bit := 16#0#; -- No divider NODIV : Boolean := False; -- Master clock divider MCJDIV : ACR1_MCJDIV_Field := 16#0#; -- unspecified Reserved_24_31 : HAL.UInt8 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ACR1_Register use record MODE at 0 range 0 .. 1; PRTCFG at 0 range 2 .. 3; Reserved_4_4 at 0 range 4 .. 4; DS at 0 range 5 .. 7; LSBFIRST at 0 range 8 .. 8; CKSTR at 0 range 9 .. 9; SYNCEN at 0 range 10 .. 11; MONO at 0 range 12 .. 12; OutDri at 0 range 13 .. 13; Reserved_14_15 at 0 range 14 .. 15; SAIAEN at 0 range 16 .. 16; DMAEN at 0 range 17 .. 17; Reserved_18_18 at 0 range 18 .. 18; NODIV at 0 range 19 .. 19; MCJDIV at 0 range 20 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; subtype ACR2_FTH_Field is HAL.UInt3; subtype ACR2_MUTECN_Field is HAL.UInt6; subtype ACR2_COMP_Field is HAL.UInt2; -- AConfiguration register 2 type ACR2_Register is record -- FIFO threshold FTH : ACR2_FTH_Field := 16#0#; -- FIFO flush FFLUS : Boolean := False; -- Tristate management on data line TRIS : Boolean := False; -- Mute MUTE : Boolean := False; -- Mute value MUTEVAL : Boolean := False; -- Mute counter MUTECN : ACR2_MUTECN_Field := 16#0#; -- Complement bit CPL : Boolean := False; -- Companding mode COMP : ACR2_COMP_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ACR2_Register use record FTH at 0 range 0 .. 2; FFLUS at 0 range 3 .. 3; TRIS at 0 range 4 .. 4; MUTE at 0 range 5 .. 5; MUTEVAL at 0 range 6 .. 6; MUTECN at 0 range 7 .. 12; CPL at 0 range 13 .. 13; COMP at 0 range 14 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype AFRCR_FRL_Field is HAL.UInt8; subtype AFRCR_FSALL_Field is HAL.UInt7; -- AFRCR type AFRCR_Register is record -- Frame length FRL : AFRCR_FRL_Field := 16#7#; -- Frame synchronization active level length FSALL : AFRCR_FSALL_Field := 16#0#; -- unspecified Reserved_15_15 : HAL.Bit := 16#0#; -- Frame synchronization definition FSDEF : Boolean := False; -- Frame synchronization polarity FSPOL : Boolean := False; -- Frame synchronization offset FSOFF : Boolean := False; -- unspecified Reserved_19_31 : HAL.UInt13 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for AFRCR_Register use record FRL at 0 range 0 .. 7; FSALL at 0 range 8 .. 14; Reserved_15_15 at 0 range 15 .. 15; FSDEF at 0 range 16 .. 16; FSPOL at 0 range 17 .. 17; FSOFF at 0 range 18 .. 18; Reserved_19_31 at 0 range 19 .. 31; end record; subtype ASLOTR_FBOFF_Field is HAL.UInt5; subtype ASLOTR_SLOTSZ_Field is HAL.UInt2; subtype ASLOTR_NBSLOT_Field is HAL.UInt4; subtype ASLOTR_SLOTEN_Field is HAL.UInt16; -- ASlot register type ASLOTR_Register is record -- First bit offset FBOFF : ASLOTR_FBOFF_Field := 16#0#; -- unspecified Reserved_5_5 : HAL.Bit := 16#0#; -- Slot size SLOTSZ : ASLOTR_SLOTSZ_Field := 16#0#; -- Number of slots in an audio frame NBSLOT : ASLOTR_NBSLOT_Field := 16#0#; -- unspecified Reserved_12_15 : HAL.UInt4 := 16#0#; -- Slot enable SLOTEN : ASLOTR_SLOTEN_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ASLOTR_Register use record FBOFF at 0 range 0 .. 4; Reserved_5_5 at 0 range 5 .. 5; SLOTSZ at 0 range 6 .. 7; NBSLOT at 0 range 8 .. 11; Reserved_12_15 at 0 range 12 .. 15; SLOTEN at 0 range 16 .. 31; end record; -- AInterrupt mask register2 type AIM_Register is record -- Overrun/underrun interrupt enable OVRUDRIE : Boolean := False; -- Mute detection interrupt enable MUTEDET : Boolean := False; -- Wrong clock configuration interrupt enable WCKCFG : Boolean := False; -- FIFO request interrupt enable FREQIE : Boolean := False; -- Codec not ready interrupt enable CNRDYIE : Boolean := False; -- Anticipated frame synchronization detection interrupt enable AFSDETIE : Boolean := False; -- Late frame synchronization detection interrupt enable LFSDET : Boolean := False; -- unspecified Reserved_7_31 : HAL.UInt25 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for AIM_Register use record OVRUDRIE at 0 range 0 .. 0; MUTEDET at 0 range 1 .. 1; WCKCFG at 0 range 2 .. 2; FREQIE at 0 range 3 .. 3; CNRDYIE at 0 range 4 .. 4; AFSDETIE at 0 range 5 .. 5; LFSDET at 0 range 6 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; subtype ASR_FLVL_Field is HAL.UInt3; -- AStatus register type ASR_Register is record -- Overrun / underrun OVRUDR : Boolean := False; -- Mute detection MUTEDET : Boolean := False; -- Wrong clock configuration flag. This bit is read only. WCKCFG : Boolean := False; -- FIFO request FREQ : Boolean := False; -- Codec not ready CNRDY : Boolean := False; -- Anticipated frame synchronization detection AFSDET : Boolean := False; -- Late frame synchronization detection LFSDET : Boolean := False; -- unspecified Reserved_7_15 : HAL.UInt9 := 16#0#; -- FIFO level threshold FLVL : ASR_FLVL_Field := 16#0#; -- unspecified Reserved_19_31 : HAL.UInt13 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ASR_Register use record OVRUDR at 0 range 0 .. 0; MUTEDET at 0 range 1 .. 1; WCKCFG at 0 range 2 .. 2; FREQ at 0 range 3 .. 3; CNRDY at 0 range 4 .. 4; AFSDET at 0 range 5 .. 5; LFSDET at 0 range 6 .. 6; Reserved_7_15 at 0 range 7 .. 15; FLVL at 0 range 16 .. 18; Reserved_19_31 at 0 range 19 .. 31; end record; -- AClear flag register type ACLRFR_Register is record -- Clear overrun / underrun OVRUDR : Boolean := False; -- Mute detection flag MUTEDET : Boolean := False; -- Clear wrong clock configuration flag WCKCFG : Boolean := False; -- unspecified Reserved_3_3 : HAL.Bit := 16#0#; -- Clear codec not ready flag CNRDY : Boolean := False; -- Clear anticipated frame synchronization detection flag. CAFSDET : Boolean := False; -- Clear late frame synchronization detection flag LFSDET : Boolean := False; -- unspecified Reserved_7_31 : HAL.UInt25 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ACLRFR_Register use record OVRUDR at 0 range 0 .. 0; MUTEDET at 0 range 1 .. 1; WCKCFG at 0 range 2 .. 2; Reserved_3_3 at 0 range 3 .. 3; CNRDY at 0 range 4 .. 4; CAFSDET at 0 range 5 .. 5; LFSDET at 0 range 6 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; subtype BCR1_MODE_Field is HAL.UInt2; subtype BCR1_PRTCFG_Field is HAL.UInt2; subtype BCR1_DS_Field is HAL.UInt3; subtype BCR1_SYNCEN_Field is HAL.UInt2; subtype BCR1_MCJDIV_Field is HAL.UInt4; -- BConfiguration register 1 type BCR1_Register is record -- Audio block mode MODE : BCR1_MODE_Field := 16#0#; -- Protocol configuration PRTCFG : BCR1_PRTCFG_Field := 16#0#; -- unspecified Reserved_4_4 : HAL.Bit := 16#0#; -- Data size DS : BCR1_DS_Field := 16#2#; -- Least significant bit first LSBFIRST : Boolean := False; -- Clock strobing edge CKSTR : Boolean := False; -- Synchronization enable SYNCEN : BCR1_SYNCEN_Field := 16#0#; -- Mono mode MONO : Boolean := False; -- Output drive OutDri : Boolean := False; -- unspecified Reserved_14_15 : HAL.UInt2 := 16#0#; -- Audio block B enable SAIBEN : Boolean := False; -- DMA enable DMAEN : Boolean := False; -- unspecified Reserved_18_18 : HAL.Bit := 16#0#; -- No divider NODIV : Boolean := False; -- Master clock divider MCJDIV : BCR1_MCJDIV_Field := 16#0#; -- unspecified Reserved_24_31 : HAL.UInt8 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for BCR1_Register use record MODE at 0 range 0 .. 1; PRTCFG at 0 range 2 .. 3; Reserved_4_4 at 0 range 4 .. 4; DS at 0 range 5 .. 7; LSBFIRST at 0 range 8 .. 8; CKSTR at 0 range 9 .. 9; SYNCEN at 0 range 10 .. 11; MONO at 0 range 12 .. 12; OutDri at 0 range 13 .. 13; Reserved_14_15 at 0 range 14 .. 15; SAIBEN at 0 range 16 .. 16; DMAEN at 0 range 17 .. 17; Reserved_18_18 at 0 range 18 .. 18; NODIV at 0 range 19 .. 19; MCJDIV at 0 range 20 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; subtype BCR2_FTH_Field is HAL.UInt3; subtype BCR2_MUTECN_Field is HAL.UInt6; subtype BCR2_COMP_Field is HAL.UInt2; -- BConfiguration register 2 type BCR2_Register is record -- FIFO threshold FTH : BCR2_FTH_Field := 16#0#; -- FIFO flush FFLUS : Boolean := False; -- Tristate management on data line TRIS : Boolean := False; -- Mute MUTE : Boolean := False; -- Mute value MUTEVAL : Boolean := False; -- Mute counter MUTECN : BCR2_MUTECN_Field := 16#0#; -- Complement bit CPL : Boolean := False; -- Companding mode COMP : BCR2_COMP_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for BCR2_Register use record FTH at 0 range 0 .. 2; FFLUS at 0 range 3 .. 3; TRIS at 0 range 4 .. 4; MUTE at 0 range 5 .. 5; MUTEVAL at 0 range 6 .. 6; MUTECN at 0 range 7 .. 12; CPL at 0 range 13 .. 13; COMP at 0 range 14 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype BFRCR_FRL_Field is HAL.UInt8; subtype BFRCR_FSALL_Field is HAL.UInt7; -- BFRCR type BFRCR_Register is record -- Frame length FRL : BFRCR_FRL_Field := 16#7#; -- Frame synchronization active level length FSALL : BFRCR_FSALL_Field := 16#0#; -- unspecified Reserved_15_15 : HAL.Bit := 16#0#; -- Frame synchronization definition FSDEF : Boolean := False; -- Frame synchronization polarity FSPOL : Boolean := False; -- Frame synchronization offset FSOFF : Boolean := False; -- unspecified Reserved_19_31 : HAL.UInt13 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for BFRCR_Register use record FRL at 0 range 0 .. 7; FSALL at 0 range 8 .. 14; Reserved_15_15 at 0 range 15 .. 15; FSDEF at 0 range 16 .. 16; FSPOL at 0 range 17 .. 17; FSOFF at 0 range 18 .. 18; Reserved_19_31 at 0 range 19 .. 31; end record; subtype BSLOTR_FBOFF_Field is HAL.UInt5; subtype BSLOTR_SLOTSZ_Field is HAL.UInt2; subtype BSLOTR_NBSLOT_Field is HAL.UInt4; subtype BSLOTR_SLOTEN_Field is HAL.UInt16; -- BSlot register type BSLOTR_Register is record -- First bit offset FBOFF : BSLOTR_FBOFF_Field := 16#0#; -- unspecified Reserved_5_5 : HAL.Bit := 16#0#; -- Slot size SLOTSZ : BSLOTR_SLOTSZ_Field := 16#0#; -- Number of slots in an audio frame NBSLOT : BSLOTR_NBSLOT_Field := 16#0#; -- unspecified Reserved_12_15 : HAL.UInt4 := 16#0#; -- Slot enable SLOTEN : BSLOTR_SLOTEN_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for BSLOTR_Register use record FBOFF at 0 range 0 .. 4; Reserved_5_5 at 0 range 5 .. 5; SLOTSZ at 0 range 6 .. 7; NBSLOT at 0 range 8 .. 11; Reserved_12_15 at 0 range 12 .. 15; SLOTEN at 0 range 16 .. 31; end record; -- BInterrupt mask register2 type BIM_Register is record -- Overrun/underrun interrupt enable OVRUDRIE : Boolean := False; -- Mute detection interrupt enable MUTEDET : Boolean := False; -- Wrong clock configuration interrupt enable WCKCFG : Boolean := False; -- FIFO request interrupt enable FREQIE : Boolean := False; -- Codec not ready interrupt enable CNRDYIE : Boolean := False; -- Anticipated frame synchronization detection interrupt enable AFSDETIE : Boolean := False; -- Late frame synchronization detection interrupt enable LFSDETIE : Boolean := False; -- unspecified Reserved_7_31 : HAL.UInt25 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for BIM_Register use record OVRUDRIE at 0 range 0 .. 0; MUTEDET at 0 range 1 .. 1; WCKCFG at 0 range 2 .. 2; FREQIE at 0 range 3 .. 3; CNRDYIE at 0 range 4 .. 4; AFSDETIE at 0 range 5 .. 5; LFSDETIE at 0 range 6 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; subtype BSR_FLVL_Field is HAL.UInt3; -- BStatus register type BSR_Register is record -- Read-only. Overrun / underrun OVRUDR : Boolean; -- Read-only. Mute detection MUTEDET : Boolean; -- Read-only. Wrong clock configuration flag WCKCFG : Boolean; -- Read-only. FIFO request FREQ : Boolean; -- Read-only. Codec not ready CNRDY : Boolean; -- Read-only. Anticipated frame synchronization detection AFSDET : Boolean; -- Read-only. Late frame synchronization detection LFSDET : Boolean; -- unspecified Reserved_7_15 : HAL.UInt9; -- Read-only. FIFO level threshold FLVL : BSR_FLVL_Field; -- unspecified Reserved_19_31 : HAL.UInt13; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for BSR_Register use record OVRUDR at 0 range 0 .. 0; MUTEDET at 0 range 1 .. 1; WCKCFG at 0 range 2 .. 2; FREQ at 0 range 3 .. 3; CNRDY at 0 range 4 .. 4; AFSDET at 0 range 5 .. 5; LFSDET at 0 range 6 .. 6; Reserved_7_15 at 0 range 7 .. 15; FLVL at 0 range 16 .. 18; Reserved_19_31 at 0 range 19 .. 31; end record; -- BClear flag register type BCLRFR_Register is record -- Write-only. Clear overrun / underrun OVRUDR : Boolean := False; -- Write-only. Mute detection flag MUTEDET : Boolean := False; -- Write-only. Clear wrong clock configuration flag WCKCFG : Boolean := False; -- unspecified Reserved_3_3 : HAL.Bit := 16#0#; -- Write-only. Clear codec not ready flag CNRDY : Boolean := False; -- Write-only. Clear anticipated frame synchronization detection flag CAFSDET : Boolean := False; -- Write-only. Clear late frame synchronization detection flag LFSDET : Boolean := False; -- unspecified Reserved_7_31 : HAL.UInt25 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for BCLRFR_Register use record OVRUDR at 0 range 0 .. 0; MUTEDET at 0 range 1 .. 1; WCKCFG at 0 range 2 .. 2; Reserved_3_3 at 0 range 3 .. 3; CNRDY at 0 range 4 .. 4; CAFSDET at 0 range 5 .. 5; LFSDET at 0 range 6 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Serial audio interface type SAI_Peripheral is record -- Global configuration register GCR : aliased GCR_Register; -- AConfiguration register 1 ACR1 : aliased ACR1_Register; -- AConfiguration register 2 ACR2 : aliased ACR2_Register; -- AFRCR AFRCR : aliased AFRCR_Register; -- ASlot register ASLOTR : aliased ASLOTR_Register; -- AInterrupt mask register2 AIM : aliased AIM_Register; -- AStatus register ASR : aliased ASR_Register; -- AClear flag register ACLRFR : aliased ACLRFR_Register; -- AData register ADR : aliased HAL.UInt32; -- BConfiguration register 1 BCR1 : aliased BCR1_Register; -- BConfiguration register 2 BCR2 : aliased BCR2_Register; -- BFRCR BFRCR : aliased BFRCR_Register; -- BSlot register BSLOTR : aliased BSLOTR_Register; -- BInterrupt mask register2 BIM : aliased BIM_Register; -- BStatus register BSR : aliased BSR_Register; -- BClear flag register BCLRFR : aliased BCLRFR_Register; -- BData register BDR : aliased HAL.UInt32; end record with Volatile; for SAI_Peripheral use record GCR at 16#0# range 0 .. 31; ACR1 at 16#4# range 0 .. 31; ACR2 at 16#8# range 0 .. 31; AFRCR at 16#C# range 0 .. 31; ASLOTR at 16#10# range 0 .. 31; AIM at 16#14# range 0 .. 31; ASR at 16#18# range 0 .. 31; ACLRFR at 16#1C# range 0 .. 31; ADR at 16#20# range 0 .. 31; BCR1 at 16#24# range 0 .. 31; BCR2 at 16#28# range 0 .. 31; BFRCR at 16#2C# range 0 .. 31; BSLOTR at 16#30# range 0 .. 31; BIM at 16#34# range 0 .. 31; BSR at 16#38# range 0 .. 31; BCLRFR at 16#3C# range 0 .. 31; BDR at 16#40# range 0 .. 31; end record; -- Serial audio interface SAI1_Periph : aliased SAI_Peripheral with Import, Address => System'To_Address (16#40015800#); -- Serial audio interface SAI2_Periph : aliased SAI_Peripheral with Import, Address => System'To_Address (16#40015C00#); end STM32_SVD.SAI;
AdaCore/training_material
Ada
442
adb
with My_Button; use My_Button; package body Solar_System.Button is task body Button_Monitor is Body_Data : Body_Type; begin loop My_Button.Button.Wait_Press; for PO_Body of Bodies loop Body_Data := PO_Body.Get_Data; Body_Data.Speed := -Body_Data.Speed; PO_Body.Set_Data (Body_Data); end loop; end loop; end Button_Monitor; end Solar_System.Button;
reznikmm/matreshka
Ada
4,720
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Style.Font_Style_Name_Complex_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Font_Style_Name_Complex_Attribute_Node is begin return Self : Style_Font_Style_Name_Complex_Attribute_Node do Matreshka.ODF_Style.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Style_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Style_Font_Style_Name_Complex_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Font_Style_Name_Complex_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Style_URI, Matreshka.ODF_String_Constants.Font_Style_Name_Complex_Attribute, Style_Font_Style_Name_Complex_Attribute_Node'Tag); end Matreshka.ODF_Style.Font_Style_Name_Complex_Attributes;
sungyeon/drake
Ada
4,697
adb
with Ada.Text_IO.Formatting; with System.Formatting.Fixed; with System.Formatting.Float; with System.Formatting.Literals.Float; package body Ada.Text_IO.Fixed_IO is procedure Put_To_Field ( To : out String; Fore_Last, Last : out Natural; Item : Num; Aft : Field; Exp : Field); procedure Put_To_Field ( To : out String; Fore_Last, Last : out Natural; Item : Num; Aft : Field; Exp : Field) is Triming_Sign_Marks : constant System.Formatting.Sign_Marks := ('-', System.Formatting.No_Sign, System.Formatting.No_Sign); Aft_Width : constant Field := Field'Max (1, Aft); begin if Exp /= 0 then System.Formatting.Float.Image ( Long_Long_Float (Item), To, Fore_Last, Last, Signs => Triming_Sign_Marks, Aft_Width => Aft_Width, Exponent_Digits_Width => Exp - 1); -- excluding '.' else System.Formatting.Fixed.Image ( Long_Long_Float (Item), To, Fore_Last, Last, Signs => Triming_Sign_Marks, Aft_Width => Aft_Width); end if; end Put_To_Field; procedure Get_From_Field ( From : String; Item : out Num; Last : out Positive); procedure Get_From_Field ( From : String; Item : out Num; Last : out Positive) is Base_Item : Long_Long_Float; Error : Boolean; begin System.Formatting.Literals.Float.Get_Literal ( From, Last, Base_Item, Error => Error); if Error or else Base_Item not in Long_Long_Float (Num'First) .. Long_Long_Float (Num'Last) then raise Data_Error; end if; Item := Num (Base_Item); end Get_From_Field; -- implementation procedure Get ( File : File_Type; Item : out Num; Width : Field := 0) is begin if Width /= 0 then declare S : String (1 .. Width); Last_1 : Natural; Last_2 : Natural; begin Formatting.Get_Field (File, S, Last_1); -- checking the predicate Get_From_Field (S (1 .. Last_1), Item, Last_2); if Last_2 /= Last_1 then raise Data_Error; end if; end; else declare S : constant String := Formatting.Get_Numeric_Literal ( File, -- checking the predicate Real => True); Last : Natural; begin Get_From_Field (S, Item, Last); if Last /= S'Last then raise Data_Error; end if; end; end if; end Get; procedure Get ( Item : out Num; Width : Field := 0) is begin Get (Current_Input.all, Item, Width); end Get; procedure Get ( File : not null File_Access; Item : out Num; Width : Field := 0) is begin Get (File.all, Item, Width); end Get; procedure Put ( File : File_Type; Item : Num; Fore : Field := Default_Fore; Aft : Field := Default_Aft; Exp : Field := Default_Exp) is S : String ( 1 .. Integer'Max (Num'Width, Long_Long_Float'Width) + Aft + Exp); Fore_Last, Last : Natural; begin Put_To_Field (S, Fore_Last, Last, Item, Aft, Exp); Formatting.Tail ( File, -- checking the predicate S (1 .. Last), Last - Fore_Last + Fore); end Put; procedure Put ( Item : Num; Fore : Field := Default_Fore; Aft : Field := Default_Aft; Exp : Field := Default_Exp) is begin Put (Current_Output.all, Item, Fore, Aft, Exp); end Put; procedure Put ( File : not null File_Access; Item : Num; Fore : Field := Default_Fore; Aft : Field := Default_Aft; Exp : Field := Default_Exp) is begin Put (File.all, Item, Fore, Aft, Exp); end Put; procedure Get ( From : String; Item : out Num; Last : out Positive) is begin Formatting.Get_Tail (From, First => Last); Get_From_Field (From (Last .. From'Last), Item, Last); end Get; procedure Put ( To : out String; Item : Num; Aft : Field := Default_Aft; Exp : Field := Default_Exp) is S : String ( 1 .. Integer'Max (Num'Width, Long_Long_Float'Width) + Aft + Exp); Fore_Last, Last : Natural; begin Put_To_Field (S, Fore_Last, Last, Item, Aft, Exp); Formatting.Tail (To, S (1 .. Last)); end Put; end Ada.Text_IO.Fixed_IO;
Rodeo-McCabe/orka
Ada
801
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2017 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. package Orka.OS is pragma Preelaborate; procedure Set_Task_Name (Name : in String) with Pre => Name'Length <= 15; end Orka.OS;
hergin/ada2fuml
Ada
341
ads
package Gm_Text_Types is -- This type defines the text block name length. subtype Name_Length_Type is Positive range 1 .. 25; -- This type defines a text block name associated with a text block. subtype Name_Type is String (Name_Length_Type); Default_Name : constant Name_Type := Name_Type'(others => 'a'); end Gm_Text_Types;
Fabien-Chouteau/pygamer-bsp
Ada
5,144
adb
with HAL; use HAL; with HAL.GPIO; with SAM.Device; with SAM.Port; with SAM.ADC; with SAM.Clock_Generator; with SAM.Clock_Generator.IDs; with SAM.Main_Clock; with SAM.Functions; package body PyGamer.Controls is type Buttons_State is array (Buttons) of Boolean; Current_Pressed : Buttons_State := (others => False); Previous_Pressed : Buttons_State := (others => False); Clk : SAM.Port.GPIO_Point renames SAM.Device.PB31; Latch : SAM.Port.GPIO_Point renames SAM.Device.PB00; Input : SAM.Port.GPIO_Point renames SAM.Device.PB30; Joy_X : SAM.Port.GPIO_Point renames SAM.Device.PB07; Joy_Y : SAM.Port.GPIO_Point renames SAM.Device.PB06; Joy_X_AIN : constant SAM.ADC.Positive_Selection := SAM.ADC.AIN9; Joy_Y_AIN : constant SAM.ADC.Positive_Selection := SAM.ADC.AIN8; Joy_X_Last : Joystick_Range := 0; Joy_Y_Last : Joystick_Range := 0; Joystick_Threshold : constant := 64; ADC : SAM.ADC.ADC_Device renames SAM.Device.ADC1; procedure Initialize; function Read_ADC (AIN : SAM.ADC.Positive_Selection) return Joystick_Range; ---------------- -- Initialize -- ---------------- procedure Initialize is begin -- Buttons -- Clk.Clear; Clk.Set_Mode (HAL.GPIO.Output); Latch.Clear; Latch.Set_Mode (HAL.GPIO.Output); Input.Set_Mode (HAL.GPIO.Input); -- Joystick -- Joy_X.Set_Mode (HAL.GPIO.Input); Joy_X.Set_Pull_Resistor (HAL.GPIO.Floating); Joy_X.Set_Function (SAM.Functions.PB07_ADC1_AIN9); Joy_Y.Set_Mode (HAL.GPIO.Input); Joy_Y.Set_Pull_Resistor (HAL.GPIO.Floating); Joy_Y.Set_Function (SAM.Functions.PB06_ADC1_AIN8); SAM.Clock_Generator.Configure_Periph_Channel (SAM.Clock_Generator.IDs.ADC1, Clk_48Mhz); SAM.Main_Clock.ADC1_On; ADC.Configure (Resolution => SAM.ADC.Res_8bit, Reference => SAM.ADC.VDDANA, Prescaler => SAM.ADC.Pre_16, Free_Running => False, Differential_Mode => False); end Initialize; -------------- -- Read_ADC -- -------------- function Read_ADC (AIN : SAM.ADC.Positive_Selection) return Joystick_Range is Result : UInt16; begin ADC.Enable; ADC.Set_Inputs (SAM.ADC.GND, AIN); -- Read twice and disacard the first value. -- See AT11481: ADC Configurations with Examples: -- "Discard the first conversion result whenever there is a change in ADC -- configuration like voltage reference / ADC channel change" for X in 1 .. 2 loop ADC.Software_Start; while not ADC.Conversion_Done loop null; end loop; Result := ADC.Result; end loop; ADC.Disable; return Joystick_Range (Integer (Result) - 128); end Read_ADC; ---------- -- Scan -- ---------- procedure Scan is type IO_Count is range 0 .. 7; State : array (IO_Count) of Boolean; begin -- Buttons -- Previous_Pressed := Current_Pressed; -- Set initial clock state Clk.Set; -- Load the inputs Latch.Clear; Latch.Set; for X in IO_Count loop Clk.Clear; State (X) := Input.Set; Clk.Set; end loop; Current_Pressed (B) := State (0); Current_Pressed (A) := State (1); Current_Pressed (Start) := State (2); Current_Pressed (Sel) := State (3); -- Joystick -- Joy_X_Last := Read_ADC (Joy_X_AIN); Joy_Y_Last := Read_ADC (Joy_Y_AIN); if (abs Integer (Joy_X_Last)) < Joystick_Threshold then Current_Pressed (Left) := False; Current_Pressed (Right) := False; elsif Joy_X_Last > 0 then Current_Pressed (Left) := False; Current_Pressed (Right) := True; else Current_Pressed (Left) := True; Current_Pressed (Right) := False; end if; if (abs Integer (Joy_Y_Last)) < Joystick_Threshold then Current_Pressed (Up) := False; Current_Pressed (Down) := False; elsif Joy_Y_Last > 0 then Current_Pressed (Up) := False; Current_Pressed (Down) := True; else Current_Pressed (Up) := True; Current_Pressed (Down) := False; end if; end Scan; ------------- -- Pressed -- ------------- function Pressed (Button : Buttons) return Boolean is (Current_Pressed (Button)); ------------ -- Rising -- ------------ function Rising (Button : Buttons) return Boolean is (Previous_Pressed (Button) and then not Current_Pressed (Button)); ------------- -- Falling -- ------------- function Falling (Button : Buttons) return Boolean is (not Previous_Pressed (Button) and then Current_Pressed (Button)); ---------------- -- Joystick_X -- ---------------- function Joystick_X return Joystick_Range is (Joy_X_Last); ---------------- -- Joystick_Y -- ---------------- function Joystick_Y return Joystick_Range is (Joy_Y_Last); begin Initialize; end PyGamer.Controls;
faelys/natools
Ada
5,128
adb
-- Generated at 2014-06-02 19:12:04 +0000 by Natools.Static_Hash_Maps -- from ../src/natools-s_expressions-printers-pretty-config-commands.sx with Natools.S_Expressions.Printers.Pretty.Config.Main_Cmd; with Natools.S_Expressions.Printers.Pretty.Config.Newline_Cmd; with Natools.S_Expressions.Printers.Pretty.Config.Quoted_Cmd; with Natools.S_Expressions.Printers.Pretty.Config.Commands.SC; with Natools.S_Expressions.Printers.Pretty.Config.Atom_Enc; with Natools.S_Expressions.Printers.Pretty.Config.Commands.CE; with Natools.S_Expressions.Printers.Pretty.Config.Hex_Casing; with Natools.S_Expressions.Printers.Pretty.Config.Newline_Enc; with Natools.S_Expressions.Printers.Pretty.Config.Quoted_Esc; with Natools.S_Expressions.Printers.Pretty.Config.Quoted_Opt; with Natools.S_Expressions.Printers.Pretty.Config.Token_Opt; package body Natools.S_Expressions.Printers.Pretty.Config.Commands is function Main (Key : String) return Main_Command is N : constant Natural := Natools.S_Expressions.Printers.Pretty.Config.Main_Cmd.Hash (Key); begin if Map_1_Keys (N).all = Key then return Map_1_Elements (N); else raise Constraint_Error with "Key """ & Key & """ not in map"; end if; end Main; function Newline (Key : String) return Newline_Command is N : constant Natural := Natools.S_Expressions.Printers.Pretty.Config.Newline_Cmd.Hash (Key); begin if Map_2_Keys (N).all = Key then return Map_2_Elements (N); else raise Constraint_Error with "Key """ & Key & """ not in map"; end if; end Newline; function Quoted_String (Key : String) return Quoted_String_Command is N : constant Natural := Natools.S_Expressions.Printers.Pretty.Config.Quoted_Cmd.Hash (Key); begin if Map_3_Keys (N).all = Key then return Map_3_Elements (N); else raise Constraint_Error with "Key """ & Key & """ not in map"; end if; end Quoted_String; function Separator (Key : String) return Separator_Command is N : constant Natural := Natools.S_Expressions.Printers.Pretty.Config.Commands.SC.Hash (Key); begin if Map_4_Keys (N).all = Key then return Map_4_Elements (N); else raise Constraint_Error with "Key """ & Key & """ not in map"; end if; end Separator; function To_Atom_Encoding (Key : String) return Atom_Encoding is N : constant Natural := Natools.S_Expressions.Printers.Pretty.Config.Atom_Enc.Hash (Key); begin if Map_5_Keys (N).all = Key then return Map_5_Elements (N); else raise Constraint_Error with "Key """ & Key & """ not in map"; end if; end To_Atom_Encoding; function To_Character_Encoding (Key : String) return Character_Encoding is N : constant Natural := Natools.S_Expressions.Printers.Pretty.Config.Commands.CE.Hash (Key); begin if Map_6_Keys (N).all = Key then return Map_6_Elements (N); else raise Constraint_Error with "Key """ & Key & """ not in map"; end if; end To_Character_Encoding; function To_Hex_Casing (Key : String) return Encodings.Hex_Casing is N : constant Natural := Natools.S_Expressions.Printers.Pretty.Config.Hex_Casing.Hash (Key); begin if Map_7_Keys (N).all = Key then return Map_7_Elements (N); else raise Constraint_Error with "Key """ & Key & """ not in map"; end if; end To_Hex_Casing; function To_Newline_Encoding (Key : String) return Newline_Encoding is N : constant Natural := Natools.S_Expressions.Printers.Pretty.Config.Newline_Enc.Hash (Key); begin if Map_8_Keys (N).all = Key then return Map_8_Elements (N); else raise Constraint_Error with "Key """ & Key & """ not in map"; end if; end To_Newline_Encoding; function To_Quoted_Escape (Key : String) return Quoted_Escape_Type is N : constant Natural := Natools.S_Expressions.Printers.Pretty.Config.Quoted_Esc.Hash (Key); begin if Map_9_Keys (N).all = Key then return Map_9_Elements (N); else raise Constraint_Error with "Key """ & Key & """ not in map"; end if; end To_Quoted_Escape; function To_Quoted_Option (Key : String) return Quoted_Option is N : constant Natural := Natools.S_Expressions.Printers.Pretty.Config.Quoted_Opt.Hash (Key); begin if Map_10_Keys (N).all = Key then return Map_10_Elements (N); else raise Constraint_Error with "Key """ & Key & """ not in map"; end if; end To_Quoted_Option; function To_Token_Option (Key : String) return Token_Option is N : constant Natural := Natools.S_Expressions.Printers.Pretty.Config.Token_Opt.Hash (Key); begin if Map_11_Keys (N).all = Key then return Map_11_Elements (N); else raise Constraint_Error with "Key """ & Key & """ not in map"; end if; end To_Token_Option; end Natools.S_Expressions.Printers.Pretty.Config.Commands;
ekoeppen/MSP430_Generic_Ada_Drivers
Ada
2,738
ads
-- This spec has been automatically generated from out.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with System; -- Special Function package MSP430_SVD.SPECIAL_FUNCTION is pragma Preelaborate; --------------- -- Registers -- --------------- -- Interrupt Enable 1 type IE1_Register is record -- Watchdog Interrupt Enable WDTIE : MSP430_SVD.Bit := 16#0#; -- Osc. Fault Interrupt Enable OFIE : MSP430_SVD.Bit := 16#0#; -- unspecified Reserved_2_3 : MSP430_SVD.UInt2 := 16#0#; -- NMI Interrupt Enable NMIIE : MSP430_SVD.Bit := 16#0#; -- Flash Access Violation Interrupt Enable ACCVIE : MSP430_SVD.Bit := 16#0#; -- unspecified Reserved_6_7 : MSP430_SVD.UInt2 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for IE1_Register use record WDTIE at 0 range 0 .. 0; OFIE at 0 range 1 .. 1; Reserved_2_3 at 0 range 2 .. 3; NMIIE at 0 range 4 .. 4; ACCVIE at 0 range 5 .. 5; Reserved_6_7 at 0 range 6 .. 7; end record; -- Interrupt Flag 1 type IFG1_Register is record -- Watchdog Interrupt Flag WDTIFG : MSP430_SVD.Bit := 16#0#; -- Osc. Fault Interrupt Flag OFIFG : MSP430_SVD.Bit := 16#0#; -- Power On Interrupt Flag PORIFG : MSP430_SVD.Bit := 16#0#; -- Reset Interrupt Flag RSTIFG : MSP430_SVD.Bit := 16#0#; -- NMI Interrupt Flag NMIIFG : MSP430_SVD.Bit := 16#0#; -- unspecified Reserved_5_7 : MSP430_SVD.UInt3 := 16#0#; end record with Volatile_Full_Access, Object_Size => 8, Bit_Order => System.Low_Order_First; for IFG1_Register use record WDTIFG at 0 range 0 .. 0; OFIFG at 0 range 1 .. 1; PORIFG at 0 range 2 .. 2; RSTIFG at 0 range 3 .. 3; NMIIFG at 0 range 4 .. 4; Reserved_5_7 at 0 range 5 .. 7; end record; ----------------- -- Peripherals -- ----------------- -- Special Function type SPECIAL_FUNCTION_Peripheral is record -- Interrupt Enable 1 IE1 : aliased IE1_Register; -- Interrupt Flag 1 IFG1 : aliased IFG1_Register; end record with Volatile; for SPECIAL_FUNCTION_Peripheral use record IE1 at 16#0# range 0 .. 7; IFG1 at 16#2# range 0 .. 7; end record; -- Special Function SPECIAL_FUNCTION_Periph : aliased SPECIAL_FUNCTION_Peripheral with Import, Address => SPECIAL_FUNCTION_Base; end MSP430_SVD.SPECIAL_FUNCTION;
ohenley/ada-util
Ada
1,547
ads
----------------------------------------------------------------------- -- Util -- Utilities -- Copyright (C) 2009, 2010, 2011, 2014, 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 Util.Tests; package Util.Properties.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new Util.Tests.Test with null record; procedure Test_Property (T : in out Test); procedure Test_Integer_Property (T : in out Test); procedure Test_Load_Property (T : in out Test); procedure Test_Load_Strip_Property (T : in out Test); procedure Test_Copy_Property (T : in out Test); procedure Test_Set_Preserve_Original (T : in out Test); procedure Test_Remove_Preserve_Original (T : in out Test); procedure Test_Missing_Property (T : in out Test); procedure Test_Load_Ini_Property (T : in out Test); end Util.Properties.Tests;
rveenker/sdlada
Ada
2,052
ads
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2013-2020, Luke A. Guest -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- -- 1. The origin of this software must not be misrepresented; you must not -- claim that you wrote the original software. If you use this software -- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- -- 3. This notice may not be removed or altered from any source -- distribution. -------------------------------------------------------------------------------------------------------------------- -- SDL.Video.Renderers.Makers -- -- Constructor subprograms for Renderers. -------------------------------------------------------------------------------------------------------------------- package SDL.Video.Renderers.Makers is procedure Create (Rend : in out Renderer; Window : in out SDL.Video.Windows.Window; Driver : in Positive; Flags : in Renderer_Flags := Default_Renderer_Flags); -- Specifically create a renderer using the first available driver. procedure Create (Rend : in out Renderer; Window : in out SDL.Video.Windows.Window; Flags : in Renderer_Flags := Default_Renderer_Flags); -- Create a software renderer using a surface. procedure Create (Rend : in out Renderer; Surface : in SDL.Video.Surfaces.Surface); -- SDL_CreateWindowAndRenderer end SDL.Video.Renderers.Makers;
optikos/oasis
Ada
4,836
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Elements.Expressions; with Program.Lexical_Elements; with Program.Elements.Qualified_Expressions; with Program.Element_Visitors; package Program.Nodes.Qualified_Expressions is pragma Preelaborate; type Qualified_Expression is new Program.Nodes.Node and Program.Elements.Qualified_Expressions.Qualified_Expression and Program.Elements.Qualified_Expressions.Qualified_Expression_Text with private; function Create (Subtype_Mark : not null Program.Elements.Expressions .Expression_Access; Apostrophe_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Left_Bracket_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Operand : not null Program.Elements.Expressions .Expression_Access; Right_Bracket_Token : not null Program.Lexical_Elements .Lexical_Element_Access) return Qualified_Expression; type Implicit_Qualified_Expression is new Program.Nodes.Node and Program.Elements.Qualified_Expressions.Qualified_Expression with private; function Create (Subtype_Mark : not null Program.Elements.Expressions .Expression_Access; Operand : not null Program.Elements.Expressions .Expression_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False) return Implicit_Qualified_Expression with Pre => Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance; private type Base_Qualified_Expression is abstract new Program.Nodes.Node and Program.Elements.Qualified_Expressions.Qualified_Expression with record Subtype_Mark : not null Program.Elements.Expressions.Expression_Access; Operand : not null Program.Elements.Expressions.Expression_Access; end record; procedure Initialize (Self : aliased in out Base_Qualified_Expression'Class); overriding procedure Visit (Self : not null access Base_Qualified_Expression; Visitor : in out Program.Element_Visitors.Element_Visitor'Class); overriding function Subtype_Mark (Self : Base_Qualified_Expression) return not null Program.Elements.Expressions.Expression_Access; overriding function Operand (Self : Base_Qualified_Expression) return not null Program.Elements.Expressions.Expression_Access; overriding function Is_Qualified_Expression_Element (Self : Base_Qualified_Expression) return Boolean; overriding function Is_Expression_Element (Self : Base_Qualified_Expression) return Boolean; type Qualified_Expression is new Base_Qualified_Expression and Program.Elements.Qualified_Expressions.Qualified_Expression_Text with record Apostrophe_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Left_Bracket_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Right_Bracket_Token : not null Program.Lexical_Elements .Lexical_Element_Access; end record; overriding function To_Qualified_Expression_Text (Self : aliased in out Qualified_Expression) return Program.Elements.Qualified_Expressions .Qualified_Expression_Text_Access; overriding function Apostrophe_Token (Self : Qualified_Expression) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Left_Bracket_Token (Self : Qualified_Expression) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Right_Bracket_Token (Self : Qualified_Expression) return not null Program.Lexical_Elements.Lexical_Element_Access; type Implicit_Qualified_Expression is new Base_Qualified_Expression with record Is_Part_Of_Implicit : Boolean; Is_Part_Of_Inherited : Boolean; Is_Part_Of_Instance : Boolean; end record; overriding function To_Qualified_Expression_Text (Self : aliased in out Implicit_Qualified_Expression) return Program.Elements.Qualified_Expressions .Qualified_Expression_Text_Access; overriding function Is_Part_Of_Implicit (Self : Implicit_Qualified_Expression) return Boolean; overriding function Is_Part_Of_Inherited (Self : Implicit_Qualified_Expression) return Boolean; overriding function Is_Part_Of_Instance (Self : Implicit_Qualified_Expression) return Boolean; end Program.Nodes.Qualified_Expressions;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
2,315
adb
with STM32GD; with STM32_SVD; use STM32_SVD; with STM32_SVD.Flash; use STM32_SVD.Flash; with STM32_SVD.RCC; use STM32_SVD.RCC; with STM32_SVD.PWR; use STM32_SVD.PWR; with STM32_SVD.SCB; use STM32_SVD.SCB; with STM32_SVD.GPIO; use STM32_SVD.GPIO; with STM32_SVD.RTC; use STM32_SVD.RTC; with Startup; package body Power is procedure Deactivate_Peripherals is begin RCC_Periph.IOPENR := ( IOPAEN => 1, IOPBEN => 1, IOPCEN => 1, IOPDEN => 1, IOPEEN => 1, IOPHEN => 1, Reserved_5_6 => 0, Reserved_8_31 => 0); GPIOA_Periph.MODER.Val := 16#FFFF_FFFF#; GPIOB_Periph.MODER.Val := 16#FFFF_FFFF#; GPIOC_Periph.MODER.Val := 16#FFFF_FFFF#; GPIOD_Periph.MODER.Val := 16#FFFF_FFFF#; GPIOE_Periph.MODER.Val := 16#FFFF_FFFF#; GPIOH_Periph.MODER.Val := 16#FFFF_FFFF#; RCC_Periph.IOPENR := ( Reserved_5_6 => 0, Reserved_8_31 => 0, others => 0); STM32_SVD.RCC.RCC_Periph.IOPENR.IOPAEN := 0; STM32_SVD.RCC.RCC_Periph.IOPENR.IOPBEN := 0; STM32_SVD.RCC.RCC_Periph.APB2ENR.USART1EN := 0; STM32_SVD.RCC.RCC_Periph.APB2ENR.SPI1EN := 0; STM32_SVD.RCC.RCC_Periph.APB2ENR.ADCEN := 0; STM32_SVD.RCC.RCC_Periph.APB1ENR.I2C1EN := 0; end Deactivate_Peripherals; procedure Start_RTC is begin RCC_Periph.CSR.LSION := 1; while RCC_Periph.CSR.LSIRDY = 0 loop null; end loop; RCC_Periph.CSR.RTCSEL := 2#10#; RCC_Periph.CSR.RTCEN := 1; end Start_RTC; procedure Sleep is begin loop STM32GD.WFI; end loop; end Sleep; procedure Low_Power_Sleep is begin Flash_Periph.ACR.SLEEP_PD := 1; loop STM32GD.WFI; end loop; end Low_Power_Sleep; procedure Stop is begin Flash_Periph.ACR.SLEEP_PD := 1; PWR_Periph.CR.LPDS := 1; PWR_Periph.CR.PDDS := 0; PWR_Periph.CR.ULP := 1; SCB_Periph.SCR.SLEEPDEEP := 1; Deactivate_Peripherals; Sleep; end Stop; procedure Standby is begin Flash_Periph.ACR.SLEEP_PD := 1; PWR_Periph.CR.LPDS := 1; PWR_Periph.CR.PDDS := 1; PWR_Periph.CR.ULP := 1; SCB_Periph.SCR.SLEEPDEEP := 1; Deactivate_Peripherals; Sleep; end Standby; end Power;
damaki/libkeccak
Ada
6,655
ads
------------------------------------------------------------------------------- -- Copyright (c) 2019, Daniel King -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- * Redistributions of source code must retain the above copyright -- notice, this list of conditions and the following disclaimer. -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- * The name of the copyright holder may not be used to endorse or promote -- Products derived from this software without specific prior written -- permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY -- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------- with Keccak.Generic_CSHAKE; with Keccak.Types; use Keccak.Types; -- @summary -- Generic implementation of the TupleHash algorithm. -- -- @description -- TupleHash is a SHA-3-derived hash function with variable-length output -- that is designed to simply hash a tuple of input strings, any or all of -- which may be empty strings, in an unambiguous way. -- -- This API is used as follows: -- -- 1 Call Init to initialise a new TupleHash context. -- -- 2 Call Update_Tuple_Item for each item in the tuple. -- -- 3 Call either Finish or Extract to produce the desired type of output -- (TupleHash or TupleHashXOF): -- -- * Finish is used to produce a single output of arbitrary length (TupleHash). -- The requested output length affects the output. For example, requesting -- a 10-byte output will produce an unrelated hash to requesting a 20-byte -- output. -- -- * Extract can be called one or more times to produce an arbitrary number -- of output bytes (TupleHashXOF). In this case, the total output length is -- unknown in advance so the output does not change based on the overall length. -- For example, a 10-byte output is the truncated version of a 20-byte output. -- -- @group TupleHash generic with package CSHAKE is new Generic_CSHAKE (<>); package Keccak.Generic_Tuple_Hash is type Context is private; type States is (Updating, Extracting, Finished); -- @value Updating When in this state additional data can be input into the -- TupleHash context. -- -- @value Extracting When in this state, the TupleHash context can generate -- output bytes by calling the Extract procedure. -- -- @value Finished When in this state the context is finished and no more data -- can be input or output. procedure Init (Ctx : out Context; Customization : in String := "") with Global => null, Depends => (Ctx => Customization), Post => State_Of (Ctx) = Updating; -- Initialise the TupleHash context. -- -- @param Ctx The TupleHash context to initialise. -- -- @param Customization An optional customisation string to provide domain -- separation between different instances of TupleHash. procedure Update_Tuple_Item (Ctx : in out Context; Item : in Byte_Array) with Global => null, Depends => (Ctx =>+ Item), Pre => State_Of (Ctx) = Updating, Post => State_Of (Ctx) = Updating; -- Process the next tuple item. -- -- The entire tuple item must be passed into this procedure. -- -- This may be called multiple times to process an arbitrary number of items. procedure Finish (Ctx : in out Context; Digest : out Byte_Array) with Global => null, Depends => ((Ctx, Digest) => (Ctx, Digest)), Pre => State_Of (Ctx) = Updating, Post => State_Of (Ctx) = Finished; -- Produce a TupleHash digest (TupleHash variant) -- -- After calling this procedure the context can no longer be used. However, -- it can be re-initialized to perform a new TupleHash computation. -- -- The number of output bytes requested is determined from the length of -- the Digest array (i.e. Digest'Length) and has an effect on the value of the -- output digest. For example, two different ParallelHash computations with identical -- inputs (same key and input data) but with different digest lengths will -- produce independent digest values. -- -- Note that this procedure can only be called once for each ParallelHash -- computation. This requires that the required digest length is known before -- calling this procedure, and a Byte_Array with the correct length is -- given to this procedure. For applications where the number of required -- output bytes is not known until after bytes are output, see the Extract -- procedure. procedure Extract (Ctx : in out Context; Digest : out Byte_Array) with Global => null, Depends => ((Ctx, Digest) => (Ctx, Digest)), Pre => State_Of (Ctx) in Updating | Extracting, Post => State_Of (Ctx) = Extracting; -- Produce a TupleHash digest (TupleHashXOF variant) -- -- After calling this procudure no more data can be input into the ParllelHash -- computation. -- -- This function can be called multiple times to produce an arbitrary -- number of output bytes. function State_Of (Ctx : in Context) return States with Global => null; private use type CSHAKE.States; type Context is record Ctx : CSHAKE.Context; Finished : Boolean; end record; function State_Of (Ctx : in Context) return States is (if Ctx.Finished then Finished elsif CSHAKE.State_Of (Ctx.Ctx) = CSHAKE.Updating then Updating else Extracting); end Keccak.Generic_Tuple_Hash;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
31,558
ads
pragma Style_Checks (Off); -- This spec has been automatically generated from STM32L0x1.svd pragma Restrictions (No_Elaboration_Code); with System; package STM32_SVD.RTC is pragma Preelaborate; --------------- -- Registers -- --------------- subtype TR_SU_Field is STM32_SVD.UInt4; subtype TR_ST_Field is STM32_SVD.UInt3; subtype TR_MNU_Field is STM32_SVD.UInt4; subtype TR_MNT_Field is STM32_SVD.UInt3; subtype TR_HU_Field is STM32_SVD.UInt4; subtype TR_HT_Field is STM32_SVD.UInt2; subtype TR_PM_Field is STM32_SVD.Bit; -- RTC time register type TR_Register is record -- Second units in BCD format SU : TR_SU_Field := 16#0#; -- Second tens in BCD format ST : TR_ST_Field := 16#0#; -- unspecified Reserved_7_7 : STM32_SVD.Bit := 16#0#; -- Minute units in BCD format MNU : TR_MNU_Field := 16#0#; -- Minute tens in BCD format MNT : TR_MNT_Field := 16#0#; -- unspecified Reserved_15_15 : STM32_SVD.Bit := 16#0#; -- Hour units in BCD format HU : TR_HU_Field := 16#0#; -- Hour tens in BCD format HT : TR_HT_Field := 16#0#; -- AM/PM notation PM : TR_PM_Field := 16#0#; -- unspecified Reserved_23_31 : STM32_SVD.UInt9 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for TR_Register use record SU at 0 range 0 .. 3; ST at 0 range 4 .. 6; Reserved_7_7 at 0 range 7 .. 7; MNU at 0 range 8 .. 11; MNT at 0 range 12 .. 14; Reserved_15_15 at 0 range 15 .. 15; HU at 0 range 16 .. 19; HT at 0 range 20 .. 21; PM at 0 range 22 .. 22; Reserved_23_31 at 0 range 23 .. 31; end record; subtype DR_DU_Field is STM32_SVD.UInt4; subtype DR_DT_Field is STM32_SVD.UInt2; subtype DR_MU_Field is STM32_SVD.UInt4; subtype DR_MT_Field is STM32_SVD.Bit; subtype DR_WDU_Field is STM32_SVD.UInt3; subtype DR_YU_Field is STM32_SVD.UInt4; subtype DR_YT_Field is STM32_SVD.UInt4; -- RTC date register type DR_Register is record -- Date units in BCD format DU : DR_DU_Field := 16#0#; -- Date tens in BCD format DT : DR_DT_Field := 16#0#; -- unspecified Reserved_6_7 : STM32_SVD.UInt2 := 16#0#; -- Month units in BCD format MU : DR_MU_Field := 16#0#; -- Month tens in BCD format MT : DR_MT_Field := 16#0#; -- Week day units WDU : DR_WDU_Field := 16#0#; -- Year units in BCD format YU : DR_YU_Field := 16#0#; -- Year tens in BCD format YT : DR_YT_Field := 16#0#; -- unspecified Reserved_24_31 : STM32_SVD.Byte := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DR_Register use record DU at 0 range 0 .. 3; DT at 0 range 4 .. 5; Reserved_6_7 at 0 range 6 .. 7; MU at 0 range 8 .. 11; MT at 0 range 12 .. 12; WDU at 0 range 13 .. 15; YU at 0 range 16 .. 19; YT at 0 range 20 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; subtype CR_WUCKSEL_Field is STM32_SVD.UInt3; subtype CR_TSEDGE_Field is STM32_SVD.Bit; subtype CR_REFCKON_Field is STM32_SVD.Bit; subtype CR_BYPSHAD_Field is STM32_SVD.Bit; subtype CR_FMT_Field is STM32_SVD.Bit; subtype CR_ALRAE_Field is STM32_SVD.Bit; subtype CR_ALRBE_Field is STM32_SVD.Bit; subtype CR_WUTE_Field is STM32_SVD.Bit; subtype CR_TSE_Field is STM32_SVD.Bit; subtype CR_ALRAIE_Field is STM32_SVD.Bit; subtype CR_ALRBIE_Field is STM32_SVD.Bit; subtype CR_WUTIE_Field is STM32_SVD.Bit; subtype CR_TSIE_Field is STM32_SVD.Bit; subtype CR_ADD1H_Field is STM32_SVD.Bit; subtype CR_SUB1H_Field is STM32_SVD.Bit; subtype CR_BKP_Field is STM32_SVD.Bit; subtype CR_COSEL_Field is STM32_SVD.Bit; subtype CR_POL_Field is STM32_SVD.Bit; subtype CR_OSEL_Field is STM32_SVD.UInt2; subtype CR_COE_Field is STM32_SVD.Bit; -- RTC control register type CR_Register is record -- Wakeup clock selection WUCKSEL : CR_WUCKSEL_Field := 16#0#; -- Time-stamp event active edge TSEDGE : CR_TSEDGE_Field := 16#0#; -- RTC_REFIN reference clock detection enable (50 or 60 Hz) REFCKON : CR_REFCKON_Field := 16#0#; -- Bypass the shadow registers BYPSHAD : CR_BYPSHAD_Field := 16#0#; -- Hour format FMT : CR_FMT_Field := 16#0#; -- unspecified Reserved_7_7 : STM32_SVD.Bit := 16#0#; -- Alarm A enable ALRAE : CR_ALRAE_Field := 16#0#; -- Alarm B enable ALRBE : CR_ALRBE_Field := 16#0#; -- Wakeup timer enable WUTE : CR_WUTE_Field := 16#0#; -- timestamp enable TSE : CR_TSE_Field := 16#0#; -- Alarm A interrupt enable ALRAIE : CR_ALRAIE_Field := 16#0#; -- Alarm B interrupt enable ALRBIE : CR_ALRBIE_Field := 16#0#; -- Wakeup timer interrupt enable WUTIE : CR_WUTIE_Field := 16#0#; -- Time-stamp interrupt enable TSIE : CR_TSIE_Field := 16#0#; -- Write-only. Add 1 hour (summer time change) ADD1H : CR_ADD1H_Field := 16#0#; -- Write-only. Subtract 1 hour (winter time change) SUB1H : CR_SUB1H_Field := 16#0#; -- Backup BKP : CR_BKP_Field := 16#0#; -- Calibration output selection COSEL : CR_COSEL_Field := 16#0#; -- Output polarity POL : CR_POL_Field := 16#0#; -- Output selection OSEL : CR_OSEL_Field := 16#0#; -- Calibration output enable COE : CR_COE_Field := 16#0#; -- unspecified Reserved_24_31 : STM32_SVD.Byte := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CR_Register use record WUCKSEL at 0 range 0 .. 2; TSEDGE at 0 range 3 .. 3; REFCKON at 0 range 4 .. 4; BYPSHAD at 0 range 5 .. 5; FMT at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; ALRAE at 0 range 8 .. 8; ALRBE at 0 range 9 .. 9; WUTE at 0 range 10 .. 10; TSE at 0 range 11 .. 11; ALRAIE at 0 range 12 .. 12; ALRBIE at 0 range 13 .. 13; WUTIE at 0 range 14 .. 14; TSIE at 0 range 15 .. 15; ADD1H at 0 range 16 .. 16; SUB1H at 0 range 17 .. 17; BKP at 0 range 18 .. 18; COSEL at 0 range 19 .. 19; POL at 0 range 20 .. 20; OSEL at 0 range 21 .. 22; COE at 0 range 23 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; subtype ISR_ALRAWF_Field is STM32_SVD.Bit; subtype ISR_ALRBWF_Field is STM32_SVD.Bit; subtype ISR_WUTWF_Field is STM32_SVD.Bit; subtype ISR_SHPF_Field is STM32_SVD.Bit; subtype ISR_INITS_Field is STM32_SVD.Bit; subtype ISR_RSF_Field is STM32_SVD.Bit; subtype ISR_INITF_Field is STM32_SVD.Bit; subtype ISR_INIT_Field is STM32_SVD.Bit; subtype ISR_ALRAF_Field is STM32_SVD.Bit; subtype ISR_ALRBF_Field is STM32_SVD.Bit; subtype ISR_WUTF_Field is STM32_SVD.Bit; subtype ISR_TSF_Field is STM32_SVD.Bit; subtype ISR_TSOVF_Field is STM32_SVD.Bit; subtype ISR_TAMP1F_Field is STM32_SVD.Bit; subtype ISR_TAMP2F_Field is STM32_SVD.Bit; -- RTC initialization and status register type ISR_Register is record -- Read-only. Alarm A write flag ALRAWF : ISR_ALRAWF_Field := 16#0#; -- Read-only. Alarm B write flag ALRBWF : ISR_ALRBWF_Field := 16#0#; -- Read-only. Wakeup timer write flag WUTWF : ISR_WUTWF_Field := 16#0#; -- Read-only. Shift operation pending SHPF : ISR_SHPF_Field := 16#0#; -- Read-only. Initialization status flag INITS : ISR_INITS_Field := 16#0#; -- Registers synchronization flag RSF : ISR_RSF_Field := 16#0#; -- Read-only. Initialization flag INITF : ISR_INITF_Field := 16#0#; -- Initialization mode INIT : ISR_INIT_Field := 16#0#; -- Alarm A flag ALRAF : ISR_ALRAF_Field := 16#0#; -- Alarm B flag ALRBF : ISR_ALRBF_Field := 16#0#; -- Wakeup timer flag WUTF : ISR_WUTF_Field := 16#0#; -- Time-stamp flag TSF : ISR_TSF_Field := 16#0#; -- Time-stamp overflow flag TSOVF : ISR_TSOVF_Field := 16#0#; -- RTC_TAMP1 detection flag TAMP1F : ISR_TAMP1F_Field := 16#0#; -- RTC_TAMP2 detection flag TAMP2F : ISR_TAMP2F_Field := 16#0#; -- unspecified Reserved_15_31 : STM32_SVD.UInt17 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ISR_Register use record ALRAWF at 0 range 0 .. 0; ALRBWF at 0 range 1 .. 1; WUTWF at 0 range 2 .. 2; SHPF at 0 range 3 .. 3; INITS at 0 range 4 .. 4; RSF at 0 range 5 .. 5; INITF at 0 range 6 .. 6; INIT at 0 range 7 .. 7; ALRAF at 0 range 8 .. 8; ALRBF at 0 range 9 .. 9; WUTF at 0 range 10 .. 10; TSF at 0 range 11 .. 11; TSOVF at 0 range 12 .. 12; TAMP1F at 0 range 13 .. 13; TAMP2F at 0 range 14 .. 14; Reserved_15_31 at 0 range 15 .. 31; end record; subtype PRER_PREDIV_S_Field is STM32_SVD.UInt16; subtype PRER_PREDIV_A_Field is STM32_SVD.UInt7; -- RTC prescaler register type PRER_Register is record -- Synchronous prescaler factor PREDIV_S : PRER_PREDIV_S_Field := 16#0#; -- Asynchronous prescaler factor PREDIV_A : PRER_PREDIV_A_Field := 16#0#; -- unspecified Reserved_23_31 : STM32_SVD.UInt9 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for PRER_Register use record PREDIV_S at 0 range 0 .. 15; PREDIV_A at 0 range 16 .. 22; Reserved_23_31 at 0 range 23 .. 31; end record; subtype WUTR_WUT_Field is STM32_SVD.UInt16; -- RTC wakeup timer register type WUTR_Register is record -- Wakeup auto-reload value bits WUT : WUTR_WUT_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for WUTR_Register use record WUT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype ALRMAR_SU_Field is STM32_SVD.UInt4; subtype ALRMAR_ST_Field is STM32_SVD.UInt3; subtype ALRMAR_MSK1_Field is STM32_SVD.Bit; subtype ALRMAR_MNU_Field is STM32_SVD.UInt4; subtype ALRMAR_MNT_Field is STM32_SVD.UInt3; subtype ALRMAR_MSK2_Field is STM32_SVD.Bit; subtype ALRMAR_HU_Field is STM32_SVD.UInt4; subtype ALRMAR_HT_Field is STM32_SVD.UInt2; subtype ALRMAR_PM_Field is STM32_SVD.Bit; subtype ALRMAR_MSK3_Field is STM32_SVD.Bit; subtype ALRMAR_DU_Field is STM32_SVD.UInt4; subtype ALRMAR_DT_Field is STM32_SVD.UInt2; subtype ALRMAR_WDSEL_Field is STM32_SVD.Bit; subtype ALRMAR_MSK4_Field is STM32_SVD.Bit; -- RTC alarm A register type ALRMAR_Register is record -- Second units in BCD format. SU : ALRMAR_SU_Field := 16#0#; -- Second tens in BCD format. ST : ALRMAR_ST_Field := 16#0#; -- Alarm A seconds mask MSK1 : ALRMAR_MSK1_Field := 16#0#; -- Minute units in BCD format. MNU : ALRMAR_MNU_Field := 16#0#; -- Minute tens in BCD format. MNT : ALRMAR_MNT_Field := 16#0#; -- Alarm A minutes mask MSK2 : ALRMAR_MSK2_Field := 16#0#; -- Hour units in BCD format. HU : ALRMAR_HU_Field := 16#0#; -- Hour tens in BCD format. HT : ALRMAR_HT_Field := 16#0#; -- AM/PM notation PM : ALRMAR_PM_Field := 16#0#; -- Alarm A hours mask MSK3 : ALRMAR_MSK3_Field := 16#0#; -- Date units or day in BCD format. DU : ALRMAR_DU_Field := 16#0#; -- Date tens in BCD format. DT : ALRMAR_DT_Field := 16#0#; -- Week day selection WDSEL : ALRMAR_WDSEL_Field := 16#0#; -- Alarm A date mask MSK4 : ALRMAR_MSK4_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ALRMAR_Register use record SU at 0 range 0 .. 3; ST at 0 range 4 .. 6; MSK1 at 0 range 7 .. 7; MNU at 0 range 8 .. 11; MNT at 0 range 12 .. 14; MSK2 at 0 range 15 .. 15; HU at 0 range 16 .. 19; HT at 0 range 20 .. 21; PM at 0 range 22 .. 22; MSK3 at 0 range 23 .. 23; DU at 0 range 24 .. 27; DT at 0 range 28 .. 29; WDSEL at 0 range 30 .. 30; MSK4 at 0 range 31 .. 31; end record; subtype ALRMBR_SU_Field is STM32_SVD.UInt4; subtype ALRMBR_ST_Field is STM32_SVD.UInt3; subtype ALRMBR_MSK1_Field is STM32_SVD.Bit; subtype ALRMBR_MNU_Field is STM32_SVD.UInt4; subtype ALRMBR_MNT_Field is STM32_SVD.UInt3; subtype ALRMBR_MSK2_Field is STM32_SVD.Bit; subtype ALRMBR_HU_Field is STM32_SVD.UInt4; subtype ALRMBR_HT_Field is STM32_SVD.UInt2; subtype ALRMBR_PM_Field is STM32_SVD.Bit; subtype ALRMBR_MSK3_Field is STM32_SVD.Bit; subtype ALRMBR_DU_Field is STM32_SVD.UInt4; subtype ALRMBR_DT_Field is STM32_SVD.UInt2; subtype ALRMBR_WDSEL_Field is STM32_SVD.Bit; subtype ALRMBR_MSK4_Field is STM32_SVD.Bit; -- RTC alarm B register type ALRMBR_Register is record -- Second units in BCD format SU : ALRMBR_SU_Field := 16#0#; -- Second tens in BCD format ST : ALRMBR_ST_Field := 16#0#; -- Alarm B seconds mask MSK1 : ALRMBR_MSK1_Field := 16#0#; -- Minute units in BCD format MNU : ALRMBR_MNU_Field := 16#0#; -- Minute tens in BCD format MNT : ALRMBR_MNT_Field := 16#0#; -- Alarm B minutes mask MSK2 : ALRMBR_MSK2_Field := 16#0#; -- Hour units in BCD format HU : ALRMBR_HU_Field := 16#0#; -- Hour tens in BCD format HT : ALRMBR_HT_Field := 16#0#; -- AM/PM notation PM : ALRMBR_PM_Field := 16#0#; -- Alarm B hours mask MSK3 : ALRMBR_MSK3_Field := 16#0#; -- Date units or day in BCD format DU : ALRMBR_DU_Field := 16#0#; -- Date tens in BCD format DT : ALRMBR_DT_Field := 16#0#; -- Week day selection WDSEL : ALRMBR_WDSEL_Field := 16#0#; -- Alarm B date mask MSK4 : ALRMBR_MSK4_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ALRMBR_Register use record SU at 0 range 0 .. 3; ST at 0 range 4 .. 6; MSK1 at 0 range 7 .. 7; MNU at 0 range 8 .. 11; MNT at 0 range 12 .. 14; MSK2 at 0 range 15 .. 15; HU at 0 range 16 .. 19; HT at 0 range 20 .. 21; PM at 0 range 22 .. 22; MSK3 at 0 range 23 .. 23; DU at 0 range 24 .. 27; DT at 0 range 28 .. 29; WDSEL at 0 range 30 .. 30; MSK4 at 0 range 31 .. 31; end record; subtype WPR_KEY_Field is STM32_SVD.Byte; -- write protection register type WPR_Register is record -- Write-only. Write protection key KEY : WPR_KEY_Field := 16#0#; -- unspecified Reserved_8_31 : STM32_SVD.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for WPR_Register use record KEY at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype SSR_SS_Field is STM32_SVD.UInt16; -- RTC sub second register type SSR_Register is record -- Read-only. Sub second value SS : SSR_SS_Field; -- unspecified Reserved_16_31 : STM32_SVD.UInt16; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SSR_Register use record SS at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype SHIFTR_SUBFS_Field is STM32_SVD.UInt15; subtype SHIFTR_ADD1S_Field is STM32_SVD.Bit; -- RTC shift control register type SHIFTR_Register is record -- Write-only. Subtract a fraction of a second SUBFS : SHIFTR_SUBFS_Field := 16#0#; -- unspecified Reserved_15_30 : STM32_SVD.UInt16 := 16#0#; -- Write-only. Add one second ADD1S : SHIFTR_ADD1S_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SHIFTR_Register use record SUBFS at 0 range 0 .. 14; Reserved_15_30 at 0 range 15 .. 30; ADD1S at 0 range 31 .. 31; end record; subtype TSTR_SU_Field is STM32_SVD.UInt4; subtype TSTR_ST_Field is STM32_SVD.UInt3; subtype TSTR_MNU_Field is STM32_SVD.UInt4; subtype TSTR_MNT_Field is STM32_SVD.UInt3; subtype TSTR_HU_Field is STM32_SVD.UInt4; subtype TSTR_HT_Field is STM32_SVD.UInt2; subtype TSTR_PM_Field is STM32_SVD.Bit; -- RTC timestamp time register type TSTR_Register is record -- Read-only. Second units in BCD format. SU : TSTR_SU_Field; -- Read-only. Second tens in BCD format. ST : TSTR_ST_Field; -- unspecified Reserved_7_7 : STM32_SVD.Bit; -- Read-only. Minute units in BCD format. MNU : TSTR_MNU_Field; -- Read-only. Minute tens in BCD format. MNT : TSTR_MNT_Field; -- unspecified Reserved_15_15 : STM32_SVD.Bit; -- Read-only. Hour units in BCD format. HU : TSTR_HU_Field; -- Read-only. Hour tens in BCD format. HT : TSTR_HT_Field; -- Read-only. AM/PM notation PM : TSTR_PM_Field; -- unspecified Reserved_23_31 : STM32_SVD.UInt9; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for TSTR_Register use record SU at 0 range 0 .. 3; ST at 0 range 4 .. 6; Reserved_7_7 at 0 range 7 .. 7; MNU at 0 range 8 .. 11; MNT at 0 range 12 .. 14; Reserved_15_15 at 0 range 15 .. 15; HU at 0 range 16 .. 19; HT at 0 range 20 .. 21; PM at 0 range 22 .. 22; Reserved_23_31 at 0 range 23 .. 31; end record; subtype TSDR_DU_Field is STM32_SVD.UInt4; subtype TSDR_DT_Field is STM32_SVD.UInt2; subtype TSDR_MU_Field is STM32_SVD.UInt4; subtype TSDR_MT_Field is STM32_SVD.Bit; subtype TSDR_WDU_Field is STM32_SVD.UInt3; -- RTC timestamp date register type TSDR_Register is record -- Read-only. Date units in BCD format DU : TSDR_DU_Field; -- Read-only. Date tens in BCD format DT : TSDR_DT_Field; -- unspecified Reserved_6_7 : STM32_SVD.UInt2; -- Read-only. Month units in BCD format MU : TSDR_MU_Field; -- Read-only. Month tens in BCD format MT : TSDR_MT_Field; -- Read-only. Week day units WDU : TSDR_WDU_Field; -- unspecified Reserved_16_31 : STM32_SVD.UInt16; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for TSDR_Register use record DU at 0 range 0 .. 3; DT at 0 range 4 .. 5; Reserved_6_7 at 0 range 6 .. 7; MU at 0 range 8 .. 11; MT at 0 range 12 .. 12; WDU at 0 range 13 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype TSSSR_SS_Field is STM32_SVD.UInt16; -- RTC time-stamp sub second register type TSSSR_Register is record -- Read-only. Sub second value SS : TSSSR_SS_Field; -- unspecified Reserved_16_31 : STM32_SVD.UInt16; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for TSSSR_Register use record SS at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype CALR_CALM_Field is STM32_SVD.UInt9; subtype CALR_CALW16_Field is STM32_SVD.Bit; subtype CALR_CALW8_Field is STM32_SVD.Bit; subtype CALR_CALP_Field is STM32_SVD.Bit; -- RTC calibration register type CALR_Register is record -- Calibration minus CALM : CALR_CALM_Field := 16#0#; -- unspecified Reserved_9_12 : STM32_SVD.UInt4 := 16#0#; -- Use a 16-second calibration cycle period CALW16 : CALR_CALW16_Field := 16#0#; -- Use an 8-second calibration cycle period CALW8 : CALR_CALW8_Field := 16#0#; -- Increase frequency of RTC by 488.5 ppm CALP : CALR_CALP_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CALR_Register use record CALM at 0 range 0 .. 8; Reserved_9_12 at 0 range 9 .. 12; CALW16 at 0 range 13 .. 13; CALW8 at 0 range 14 .. 14; CALP at 0 range 15 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype TAMPCR_TAMP1E_Field is STM32_SVD.Bit; subtype TAMPCR_TAMP1TRG_Field is STM32_SVD.Bit; subtype TAMPCR_TAMPIE_Field is STM32_SVD.Bit; subtype TAMPCR_TAMP2E_Field is STM32_SVD.Bit; subtype TAMPCR_TAMP2_TRG_Field is STM32_SVD.Bit; subtype TAMPCR_TAMPTS_Field is STM32_SVD.Bit; subtype TAMPCR_TAMPFREQ_Field is STM32_SVD.UInt3; subtype TAMPCR_TAMPFLT_Field is STM32_SVD.UInt2; subtype TAMPCR_TAMPPRCH_Field is STM32_SVD.UInt2; subtype TAMPCR_TAMPPUDIS_Field is STM32_SVD.Bit; subtype TAMPCR_TAMP1IE_Field is STM32_SVD.Bit; subtype TAMPCR_TAMP1NOERASE_Field is STM32_SVD.Bit; subtype TAMPCR_TAMP1MF_Field is STM32_SVD.Bit; subtype TAMPCR_TAMP2IE_Field is STM32_SVD.Bit; subtype TAMPCR_TAMP2NOERASE_Field is STM32_SVD.Bit; subtype TAMPCR_TAMP2MF_Field is STM32_SVD.Bit; -- RTC tamper configuration register type TAMPCR_Register is record -- RTC_TAMP1 input detection enable TAMP1E : TAMPCR_TAMP1E_Field := 16#0#; -- Active level for RTC_TAMP1 input TAMP1TRG : TAMPCR_TAMP1TRG_Field := 16#0#; -- Tamper interrupt enable TAMPIE : TAMPCR_TAMPIE_Field := 16#0#; -- RTC_TAMP2 input detection enable TAMP2E : TAMPCR_TAMP2E_Field := 16#0#; -- Active level for RTC_TAMP2 input TAMP2_TRG : TAMPCR_TAMP2_TRG_Field := 16#0#; -- unspecified Reserved_5_6 : STM32_SVD.UInt2 := 16#0#; -- Activate timestamp on tamper detection event TAMPTS : TAMPCR_TAMPTS_Field := 16#0#; -- Tamper sampling frequency TAMPFREQ : TAMPCR_TAMPFREQ_Field := 16#0#; -- RTC_TAMPx filter count TAMPFLT : TAMPCR_TAMPFLT_Field := 16#0#; -- RTC_TAMPx precharge duration TAMPPRCH : TAMPCR_TAMPPRCH_Field := 16#0#; -- RTC_TAMPx pull-up disable TAMPPUDIS : TAMPCR_TAMPPUDIS_Field := 16#0#; -- Tamper 1 interrupt enable TAMP1IE : TAMPCR_TAMP1IE_Field := 16#0#; -- Tamper 1 no erase TAMP1NOERASE : TAMPCR_TAMP1NOERASE_Field := 16#0#; -- Tamper 1 mask flag TAMP1MF : TAMPCR_TAMP1MF_Field := 16#0#; -- Tamper 2 interrupt enable TAMP2IE : TAMPCR_TAMP2IE_Field := 16#0#; -- Tamper 2 no erase TAMP2NOERASE : TAMPCR_TAMP2NOERASE_Field := 16#0#; -- Tamper 2 mask flag TAMP2MF : TAMPCR_TAMP2MF_Field := 16#0#; -- unspecified Reserved_22_31 : STM32_SVD.UInt10 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for TAMPCR_Register use record TAMP1E at 0 range 0 .. 0; TAMP1TRG at 0 range 1 .. 1; TAMPIE at 0 range 2 .. 2; TAMP2E at 0 range 3 .. 3; TAMP2_TRG at 0 range 4 .. 4; Reserved_5_6 at 0 range 5 .. 6; TAMPTS at 0 range 7 .. 7; TAMPFREQ at 0 range 8 .. 10; TAMPFLT at 0 range 11 .. 12; TAMPPRCH at 0 range 13 .. 14; TAMPPUDIS at 0 range 15 .. 15; TAMP1IE at 0 range 16 .. 16; TAMP1NOERASE at 0 range 17 .. 17; TAMP1MF at 0 range 18 .. 18; TAMP2IE at 0 range 19 .. 19; TAMP2NOERASE at 0 range 20 .. 20; TAMP2MF at 0 range 21 .. 21; Reserved_22_31 at 0 range 22 .. 31; end record; subtype ALRMASSR_SS_Field is STM32_SVD.UInt15; subtype ALRMASSR_MASKSS_Field is STM32_SVD.UInt4; -- RTC alarm A sub second register type ALRMASSR_Register is record -- Sub seconds value SS : ALRMASSR_SS_Field := 16#0#; -- unspecified Reserved_15_23 : STM32_SVD.UInt9 := 16#0#; -- Mask the most-significant bits starting at this bit MASKSS : ALRMASSR_MASKSS_Field := 16#0#; -- unspecified Reserved_28_31 : STM32_SVD.UInt4 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ALRMASSR_Register use record SS at 0 range 0 .. 14; Reserved_15_23 at 0 range 15 .. 23; MASKSS at 0 range 24 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; subtype ALRMBSSR_SS_Field is STM32_SVD.UInt15; subtype ALRMBSSR_MASKSS_Field is STM32_SVD.UInt4; -- RTC alarm B sub second register type ALRMBSSR_Register is record -- Sub seconds value SS : ALRMBSSR_SS_Field := 16#0#; -- unspecified Reserved_15_23 : STM32_SVD.UInt9 := 16#0#; -- Mask the most-significant bits starting at this bit MASKSS : ALRMBSSR_MASKSS_Field := 16#0#; -- unspecified Reserved_28_31 : STM32_SVD.UInt4 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ALRMBSSR_Register use record SS at 0 range 0 .. 14; Reserved_15_23 at 0 range 15 .. 23; MASKSS at 0 range 24 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; subtype OR_RTC_ALARM_TYPE_Field is STM32_SVD.Bit; subtype OR_RTC_OUT_RMP_Field is STM32_SVD.Bit; -- option register type OR_Register is record -- RTC_ALARM on PC13 output type RTC_ALARM_TYPE : OR_RTC_ALARM_TYPE_Field := 16#0#; -- RTC_ALARM on PC13 output type RTC_OUT_RMP : OR_RTC_OUT_RMP_Field := 16#0#; -- unspecified Reserved_2_31 : STM32_SVD.UInt30 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for OR_Register use record RTC_ALARM_TYPE at 0 range 0 .. 0; RTC_OUT_RMP at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Real-time clock type RTC_Peripheral is record -- RTC time register TR : aliased TR_Register; -- RTC date register DR : aliased DR_Register; -- RTC control register CR : aliased CR_Register; -- RTC initialization and status register ISR : aliased ISR_Register; -- RTC prescaler register PRER : aliased PRER_Register; -- RTC wakeup timer register WUTR : aliased WUTR_Register; -- RTC alarm A register ALRMAR : aliased ALRMAR_Register; -- RTC alarm B register ALRMBR : aliased ALRMBR_Register; -- write protection register WPR : aliased WPR_Register; -- RTC sub second register SSR : aliased SSR_Register; -- RTC shift control register SHIFTR : aliased SHIFTR_Register; -- RTC timestamp time register TSTR : aliased TSTR_Register; -- RTC timestamp date register TSDR : aliased TSDR_Register; -- RTC time-stamp sub second register TSSSR : aliased TSSSR_Register; -- RTC calibration register CALR : aliased CALR_Register; -- RTC tamper configuration register TAMPCR : aliased TAMPCR_Register; -- RTC alarm A sub second register ALRMASSR : aliased ALRMASSR_Register; -- RTC alarm B sub second register ALRMBSSR : aliased ALRMBSSR_Register; -- option register OR_k : aliased OR_Register; -- RTC backup registers BKP0R : aliased STM32_SVD.UInt32; -- RTC backup registers BKP1R : aliased STM32_SVD.UInt32; -- RTC backup registers BKP2R : aliased STM32_SVD.UInt32; -- RTC backup registers BKP3R : aliased STM32_SVD.UInt32; -- RTC backup registers BKP4R : aliased STM32_SVD.UInt32; end record with Volatile; for RTC_Peripheral use record TR at 16#0# range 0 .. 31; DR at 16#4# range 0 .. 31; CR at 16#8# range 0 .. 31; ISR at 16#C# range 0 .. 31; PRER at 16#10# range 0 .. 31; WUTR at 16#14# range 0 .. 31; ALRMAR at 16#1C# range 0 .. 31; ALRMBR at 16#20# range 0 .. 31; WPR at 16#24# range 0 .. 31; SSR at 16#28# range 0 .. 31; SHIFTR at 16#2C# range 0 .. 31; TSTR at 16#30# range 0 .. 31; TSDR at 16#34# range 0 .. 31; TSSSR at 16#38# range 0 .. 31; CALR at 16#3C# range 0 .. 31; TAMPCR at 16#40# range 0 .. 31; ALRMASSR at 16#44# range 0 .. 31; ALRMBSSR at 16#48# range 0 .. 31; OR_k at 16#4C# range 0 .. 31; BKP0R at 16#50# range 0 .. 31; BKP1R at 16#54# range 0 .. 31; BKP2R at 16#58# range 0 .. 31; BKP3R at 16#5C# range 0 .. 31; BKP4R at 16#60# range 0 .. 31; end record; -- Real-time clock RTC_Periph : aliased RTC_Peripheral with Import, Address => RTC_Base; end STM32_SVD.RTC;
damaki/libkeccak
Ada
4,092
ads
------------------------------------------------------------------------------- -- Copyright (c) 2019, Daniel King -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- * Redistributions of source code must retain the above copyright -- notice, this list of conditions and the following disclaimer. -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- * The name of the copyright holder may not be used to endorse or promote -- Products derived from this software without specific prior written -- permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY -- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------- with Keccak.Types; -- @summary -- Subprograms for operating on Keccak-f states with a line size less than 8 bits. -- -- @group Keccak-f generic package Keccak.Generic_KeccakF.Bit_Lanes is pragma Assert (Lane_Size_Bits in 1 | 2 | 4, "Bit_Lanes can only be used with lane sizes that 1, 2, or 4 bits wide"); procedure XOR_Bits_Into_State (A : in out State; Data : in Keccak.Types.Byte_Array; Bit_Len : in Natural) with Global => null, Depends => (A =>+ (Data, Bit_Len)), Pre => (Data'Length <= Natural'Last / 8 and then Bit_Len <= Data'Length * 8 and then Bit_Len <= State_Size_Bits); procedure XOR_Bits_Into_State (A : in out Lane_Complemented_State; Data : in Keccak.Types.Byte_Array; Bit_Len : in Natural) with Inline, Global => null, Depends => (A =>+ (Data, Bit_Len)), Pre => (Data'Length <= Natural'Last / 8 and then Bit_Len <= Data'Length * 8 and then Bit_Len <= State_Size_Bits); procedure Extract_Bytes (A : in State; Data : out Keccak.Types.Byte_Array) with Global => null, Depends => (Data =>+ A), Pre => Data'Length <= ((State_Size_Bits + 7) / 8); procedure Extract_Bytes (A : in Lane_Complemented_State; Data : out Keccak.Types.Byte_Array) with Global => null, Depends => (Data =>+ A), Pre => Data'Length <= ((State_Size_Bits + 7) / 8); procedure Extract_Bits (A : in State; Data : out Keccak.Types.Byte_Array; Bit_Len : in Natural) with Global => null, Depends => (Data =>+ (A, Bit_Len)), Pre => (Bit_Len <= State_Size_Bits and then Data'Length = (Bit_Len + 7) / 8); procedure Extract_Bits (A : in Lane_Complemented_State; Data : out Keccak.Types.Byte_Array; Bit_Len : in Natural) with Global => null, Depends => (Data =>+ (A, Bit_Len)), Pre => (Bit_Len <= State_Size_Bits and then Data'Length = (Bit_Len + 7) / 8); end Keccak.Generic_KeccakF.Bit_Lanes;
AdaCore/training_material
Ada
89
ads
type A_F is access function (I : Integer) return Integer with Post => A_F'Result > I;
AdaCore/libadalang
Ada
50
ads
package Pkg_2.A is procedure Bar; end Pkg_2.A;
gerr135/ada_composition
Ada
2,296
ads
-- -- This implementation encapsulates Ada.Containers.Vectors.Vector as a record entry. -- This is a common way to compose enveloping type, requiring glue code to implement all -- declared methods. SImple to understand, but only explicitly declared methods are available. -- -- Copyright (C) 2018 George SHapovalov <[email protected]> -- -- 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. -- with Ada.Containers.Vectors; generic package Lists.dynamic is type List is new List_Interface with private; overriding function List_Constant_Reference (Container : aliased in List; Position : Cursor) return Constant_Reference_Type; overriding function List_Constant_Reference (Container : aliased in List; Index : Index_Type) return Constant_Reference_Type; overriding function List_Reference (Container : aliased in out List; Position : Cursor) return Reference_Type; overriding function List_Reference (Container : aliased in out List; Index : Index_Type) return Reference_Type; overriding function Iterate (Container : in List) return Iterator_Interface'Class; -- new methods from ACV.Vector pool; should really be part of interface, here is only a demo of tying all together.. function To_Vector (Length : Index_Type) return List; private package ACV is new Ada.Containers.Vectors(Index_Type, Element_Type); type List is new List_Interface with record vec : ACV.Vector; end record; function Has_Element (L : List; Position : Index_Base) return Boolean; -- here we also need to implement Reversible_Iterator interface type Iterator is new Iterator_Interface with record Container : List_Access; Index : Index_Type'Base; end record; overriding function First (Object : Iterator) return Cursor; overriding function Last (Object : Iterator) return Cursor; overriding function Next (Object : Iterator; Position : Cursor) return Cursor; overriding function Previous (Object : Iterator; Position : Cursor) return Cursor; end Lists.dynamic;
reznikmm/matreshka
Ada
4,702
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Svg.Strikethrough_Thickness_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Svg_Strikethrough_Thickness_Attribute_Node is begin return Self : Svg_Strikethrough_Thickness_Attribute_Node do Matreshka.ODF_Svg.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Svg_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Svg_Strikethrough_Thickness_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Strikethrough_Thickness_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Svg_URI, Matreshka.ODF_String_Constants.Strikethrough_Thickness_Attribute, Svg_Strikethrough_Thickness_Attribute_Node'Tag); end Matreshka.ODF_Svg.Strikethrough_Thickness_Attributes;
AdaCore/training_material
Ada
1,317
adb
with ada.text_io; use ada.text_io; with Examples; procedure Main is type test_procedure_t is access procedure (A, B, C : Integer; Z : out Integer); procedure test ( name : string; a, b, c : integer; proc : test_procedure_t ) is Z : Integer; begin put_line ( Name & " => " & a'image & ", " & b'image & ", " & c'image ); begin proc ( a, b, c, z ); begin put_line ( " result: " & z'image ); exception when others => put_line ( " result invalid" ); end; exception when others => put_line ( " call failed" ); end; end test; begin test ( "Test_Statement", 1, 2, integer'last, examples.Test_Statement'access ); test ( "Test_Decision True", 0, 0, 0, examples.Test_Decision'access ); test ( "Test_Decision False", 1, 1, integer'last, examples.Test_Decision'access ); test ( "Test_Mcdc A > 0, B = 0", 1, 0, 0, examples.Test_Mcdc'access ); test ( "Test_Mcdc A = 0, B > 0", 0, 1, 0, examples.Test_Mcdc'access ); test ( "Test_Mcdc A > 0, B > 0", 1, 1, 1, examples.Test_Mcdc'access ); test ( "Test_Mcdc A, B, C = -1", -1, -1, -1, examples.Test_Mcdc'access ); end Main;
BrickBot/Bound-T-H8-300
Ada
6,181
ads
-- Bounds.Stacking (decl) -- -- Bounding the stack usage. -- -- A component of the Bound-T Worst-Case Execution Time Tool. -- ------------------------------------------------------------------------------- -- Copyright (c) 1999 .. 2015 Tidorum Ltd -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- 1. Redistributions of source code must retain the above copyright notice, this -- list of conditions and the following disclaimer. -- 2. Redistributions in binary form must reproduce the above copyright notice, -- this list of conditions and the following disclaimer in the documentation -- and/or other materials provided with the distribution. -- -- This software is provided by the copyright holders and contributors "as is" and -- any express or implied warranties, including, but not limited to, the implied -- warranties of merchantability and fitness for a particular purpose are -- disclaimed. In no event shall the copyright owner or contributors be liable for -- any direct, indirect, incidental, special, exemplary, or consequential damages -- (including, but not limited to, procurement of substitute goods or services; -- loss of use, data, or profits; or business interruption) however caused and -- on any theory of liability, whether in contract, strict liability, or tort -- (including negligence or otherwise) arising in any way out of the use of this -- software, even if advised of the possibility of such damage. -- -- Other modules (files) of this software composition should contain their -- own copyright statements, which may have different copyright and usage -- conditions. The above conditions apply to this file. ------------------------------------------------------------------------------- -- -- $Revision: 1.5 $ -- $Date: 2015/10/24 19:36:47 $ -- -- $Log: bounds-stacking.ads,v $ -- Revision 1.5 2015/10/24 19:36:47 niklas -- Moved to free licence. -- -- Revision 1.4 2007-12-17 13:54:34 niklas -- BT-CH-0098: Assertions on stack usage and final stack height, etc. -- -- Revision 1.3 2005/10/20 11:28:28 niklas -- BT-CH-0015. -- -- Revision 1.2 2005/02/23 09:05:14 niklas -- BT-CH-0005. -- -- Revision 1.1 2005/02/16 21:11:39 niklas -- BT-CH-0002. -- with Assertions; with Calculator; with Flow; with Programs; with Programs.Execution; package Bounds.Stacking is procedure Apply_Assertions ( Asserts : in Assertions.Assertion_Set_T; Exec_Bounds : in Programs.Execution.Bounds_Ref); -- -- Enters asserted bounds from on the stack behaviour from the -- given set of Asserts into the given Execution Bounds. procedure Bound_Local_Stack_Height ( Stack_Steps : in Flow.Step_List_T; Into_Stack_Steps : in Calculator.Pool_List_T; Exec_Bounds : in Programs.Execution.Bounds_Ref); -- -- Bounds the local stack-heights, for all stacks, using the computed -- data-pool into each step that changes a stack-height cell. However, -- the local stack-height for some stack(s) may already be bounded (from -- constant propagation), in which case we do nothing for that stack. -- If the local stack-height is only partly (unsafely) bounded already, -- we try to improve the bounding using arithmetic analysis. -- Moreover, if the final stack-height is not yet known for some stack, -- we assume that all final (return) steps are included in Stack_Steps -- and we try to bound the final stack-height, too. -- -- Stack_Steps -- The steps that change some stack-height cell. Note that a given -- step may not change all stack-height cells. Also includes all -- final (return) steps if some stack is yet without bounds on -- the final stack height. -- Into_Stack_Steps -- Calculcated data-pool into each Stack_Step. -- Exec_Bounds -- Execution bounds derived so far for this subprogram. -- Will be updated with execution bounds for local stack height -- that we compute here. -- -- As a side effect, we may discover that some of the Stack_Steps -- are infeasible under the computation model of Exec_Bounds. If so, -- they are marked as infeasible in the model and the model is pruned. -- -- The index ranges of Stack_Steps and Into_Stack_Steps must be the -- same. It is assumed that Into_Stack_Steps(I) is the into-flux of -- Stack_Steps(I). procedure Bound_Take_Off_Height ( Calls : in Programs.Call_List_T; Into_Calls : in Calculator.Pool_List_T; Exec_Bounds : in Programs.Execution.Bounds_Ref); -- -- Bounds the take-off stack-height of the listed calls, for all -- stacks, using the computed data-pool into the call steps. -- -- Calls -- Calls with unbounded take-off height (for some stacks). -- We plan to bound these. -- Into_Calls -- Data-pool into each of the Calls. -- Exec_Bounds -- The execution bounds derived and under construction for -- the caller subprogram, to be updated with new or better -- take-off-height bounds for the Calls. -- -- As a side effect, we may discover that some of the Calls (call steps) -- are infeasible under the computation model of Exec_Bounds. If so, -- they are marked as infeasible in the model and the model is pruned. -- -- The index ranges of Calls and Into_Calls must be the same. -- It is assumed that Into_Calls(I) is the data-pool into Calls(I). procedure Compute_Stack_Usage (Within : in Programs.Execution.Bounds_Ref); -- -- Computes the maximum stack usage Within the given bounds, for -- all stacks in the processor (model), by joining the maximum local -- stack height inside the subprogram covered by the bounds, the -- take-off heights for all the calls from this subprogram, and the -- maximum stack usage of the callees. -- -- Bounds for maximum local stack height and take-off heights must -- already be available Within the bounds for the whole call-tree. -- The result is used to Bound_Stack_Usage (Within). end Bounds.Stacking;
reznikmm/matreshka
Ada
4,615
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.Report_Type_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Text_Report_Type_Attribute_Node is begin return Self : Text_Report_Type_Attribute_Node do Matreshka.ODF_Text.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Text_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Text_Report_Type_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Report_Type_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Text_URI, Matreshka.ODF_String_Constants.Report_Type_Attribute, Text_Report_Type_Attribute_Node'Tag); end Matreshka.ODF_Text.Report_Type_Attributes;
stcarrez/dynamo
Ada
9,710
adb
------------------------------------------------------------------------------ -- -- -- ASIS-for-GNAT IMPLEMENTATION COMPONENTS -- -- -- -- -- -- A 4 G . A _ O P T -- -- -- -- B o d y -- -- -- -- Copyright (C) 1995-2012, Free Software Foundation, Inc. -- -- -- -- ASIS-for-GNAT is free software; you can redistribute it and/or modify it -- -- under terms of the GNU General Public License as published by the Free -- -- Software Foundation; either version 2, or (at your option) any later -- -- version. ASIS-for-GNAT is distributed in the hope that it will be use- -- -- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- -- -- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -- -- Public License for more details. You should have received a copy of the -- -- GNU General Public License distributed with ASIS-for-GNAT; see file -- -- COPYING. If not, write to the Free Software Foundation, 51 Franklin -- -- Street, Fifth Floor, Boston, MA 02110-1301, USA. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the -- -- Software Engineering Laboratory of the Swiss Federal Institute of -- -- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the -- -- Scientific Research Computer Center of Moscow State University (SRCC -- -- MSU), Russia, with funding partially provided by grants from the Swiss -- -- National Science Foundation and the Swiss Academy of Engineering -- -- Sciences. ASIS-for-GNAT is now maintained by AdaCore -- -- (http://www.adacore.com). -- -- -- ------------------------------------------------------------------------------ with Asis.Errors; use Asis.Errors; with A4G.A_Types; use A4G.A_Types; with A4G.A_Osint; use A4G.A_Osint; with A4G.A_Output; use A4G.A_Output; with A4G.A_Debug; use A4G.A_Debug; with A4G.Vcheck; use A4G.Vcheck; with GNAT.OS_Lib; use GNAT.OS_Lib; package body A4G.A_Opt is ------------------------------------- -- Process_Finalization_Parameters -- ------------------------------------- procedure Process_Finalization_Parameters (Parameters : String) is Final_Parameters : Argument_List_Access; procedure Process_One_Parameter (Param : String); -- incapsulates processing of a separate parameter --------------------------- -- Process_One_Parameter -- --------------------------- procedure Process_One_Parameter (Param : String) is Parameter : constant String (1 .. Param'Length) := Param; begin ASIS_Warning (Message => "Asis.Implementation.Finalize: " & "unknown parameter - " & Parameter, Error => Parameter_Error); end Process_One_Parameter; begin -- Process_Finalization_Parameters Final_Parameters := Parameter_String_To_List (Parameters); for I in Final_Parameters'Range loop Process_One_Parameter (Final_Parameters (I).all); end loop; Free_Argument_List (Final_Parameters); end Process_Finalization_Parameters; --------------------------------------- -- Process_Initialization_Parameters -- --------------------------------------- procedure Process_Initialization_Parameters (Parameters : String) is Init_Parameters : Argument_List_Access; procedure Process_One_Parameter (Param : String); -- incapsulates processing of a separate parameter --------------------------- -- Process_One_Parameter -- --------------------------- procedure Process_One_Parameter (Param : String) is Parameter : constant String (1 .. Param'Length) := Param; Unknown_Parameter : Boolean := False; subtype Dig is Character range '1' .. '9'; subtype Let is Character range 'a' .. 'z'; procedure Process_Parameter; procedure Process_Option; -- Process_Option works if Param starts from '-', and -- Process_Parameter works otherwise procedure Process_Parameter is begin -- no parameter is currently available as an ASIS initialization -- parameter Raise_ASIS_Failed (Diagnosis => "Asis.Implementation.Initialize: " & "unknown parameter - " & Parameter, Stat => Parameter_Error, Internal_Bug => False); end Process_Parameter; procedure Process_Option is begin case Parameter (2) is when 'a' => if Parameter = "-asis05" or else Parameter = "-asis12" or else Parameter = "-asis95" then -- We have to accept these parameters because of -- compatibility reasons null; else Unknown_Parameter := True; end if; when 'd' => if Parameter'Length = 3 and then (Parameter (3) in Dig or else Parameter (3) in Let) then Set_Debug_Flag (Parameter (3)); elsif Parameter = "-dall" then A4G.A_Debug.Set_On; else Unknown_Parameter := True; end if; when 'k' => if Parameter = "-k" then Keep_Going := True; else Unknown_Parameter := True; end if; when 'n' => if Parameter = "-nbb" then Generate_Bug_Box := False; Keep_Going := True; else Unknown_Parameter := True; end if; when 's' => if Parameter = "-sv" then Strong_Version_Check := True; else Unknown_Parameter := True; end if; when 'w' => if Parameter = "-ws" then ASIS_Warning_Mode := Suppress; elsif Parameter = "-we" then ASIS_Warning_Mode := Treat_As_Error; elsif Parameter = "-wv" then Strong_Version_Check := False; else Unknown_Parameter := True; end if; when others => Unknown_Parameter := True; end case; if Unknown_Parameter then Raise_ASIS_Failed (Diagnosis => "Asis.Implementation.Initialize: " & "unknown option - " & Parameter, Stat => Parameter_Error, Internal_Bug => False); end if; end Process_Option; begin -- Process_One_Parameter if Parameter (1) = '-' then if Parameter'Length >= 2 then Process_Option; else Raise_ASIS_Failed (Diagnosis => "Asis.Implementation.Initialize: " & "Option is missing after ""-""", Stat => Parameter_Error, Internal_Bug => False); end if; else Process_Parameter; end if; end Process_One_Parameter; begin -- Process_Initialization_Parameters Init_Parameters := Parameter_String_To_List (Parameters); for I in Init_Parameters'Range loop Process_One_Parameter (Init_Parameters (I).all); end loop; Free_Argument_List (Init_Parameters); end Process_Initialization_Parameters; ------------- -- Set_Off -- ------------- procedure Set_Off is begin Is_Initialized := False; ASIS_Warning_Mode := Normal; Strong_Version_Check := True; Generate_Bug_Box := True; Keep_Going := False; end Set_Off; end A4G.A_Opt;
reznikmm/matreshka
Ada
5,064
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2015, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Asis.Elements; with Asis.Expressions; with Asis.Statements; package body Properties.Expressions.If_Expression is ---------- -- Code -- ---------- function Code (Engine : access Engines.Contexts.Context; Element : Asis.Expression; Name : Engines.Text_Property) return League.Strings.Universal_String is List : constant Asis.Element_List := Asis.Expressions.Expression_Paths (Element); Text : League.Strings.Universal_String; Down : League.Strings.Universal_String; begin for J in List'Range loop case Asis.Elements.Path_Kind (List (J)) is when Asis.An_If_Expression_Path => Text.Append ("("); Down := Engine.Text.Get_Property (Asis.Statements.Condition_Expression (List (J)), Name); Text.Append (Down); Text.Append ("?"); when Asis.An_Elsif_Expression_Path => Text.Append (":"); Down := Engine.Text.Get_Property (Asis.Statements.Condition_Expression (List (J)), Name); Text.Append (Down); Text.Append ("?"); when Asis.An_Else_Expression_Path => Text.Append (":"); when others => raise Program_Error; end case; declare Nested : constant Asis.Expression := Asis.Expressions.Dependent_Expression (List (J)); begin Down := Engine.Text.Get_Property (Nested, Name); Text.Append (Down); end; end loop; Text.Append (")"); return Text; end Code; end Properties.Expressions.If_Expression;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
4,393
ads
-- This spec has been automatically generated from STM32F072x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with System; package STM32_SVD.COMP is pragma Preelaborate; --------------- -- Registers -- --------------- subtype CSR_COMP1EN_Field is STM32_SVD.Bit; subtype CSR_COMP1_INP_DAC_Field is STM32_SVD.Bit; subtype CSR_COMP1MODE_Field is STM32_SVD.UInt2; subtype CSR_COMP1INSEL_Field is STM32_SVD.UInt3; subtype CSR_COMP1OUTSEL_Field is STM32_SVD.UInt3; subtype CSR_COMP1POL_Field is STM32_SVD.Bit; subtype CSR_COMP1HYST_Field is STM32_SVD.UInt2; subtype CSR_COMP1OUT_Field is STM32_SVD.Bit; subtype CSR_COMP1LOCK_Field is STM32_SVD.Bit; subtype CSR_COMP2EN_Field is STM32_SVD.Bit; subtype CSR_COMP2MODE_Field is STM32_SVD.UInt2; subtype CSR_COMP2INSEL_Field is STM32_SVD.UInt3; subtype CSR_WNDWEN_Field is STM32_SVD.Bit; subtype CSR_COMP2OUTSEL_Field is STM32_SVD.UInt3; subtype CSR_COMP2POL_Field is STM32_SVD.Bit; subtype CSR_COMP2HYST_Field is STM32_SVD.UInt2; subtype CSR_COMP2OUT_Field is STM32_SVD.Bit; subtype CSR_COMP2LOCK_Field is STM32_SVD.Bit; -- control and status register type CSR_Register is record -- Comparator 1 enable COMP1EN : CSR_COMP1EN_Field := 16#0#; -- COMP1_INP_DAC COMP1_INP_DAC : CSR_COMP1_INP_DAC_Field := 16#0#; -- Comparator 1 mode COMP1MODE : CSR_COMP1MODE_Field := 16#0#; -- Comparator 1 inverting input selection COMP1INSEL : CSR_COMP1INSEL_Field := 16#0#; -- unspecified Reserved_7_7 : STM32_SVD.Bit := 16#0#; -- Comparator 1 output selection COMP1OUTSEL : CSR_COMP1OUTSEL_Field := 16#0#; -- Comparator 1 output polarity COMP1POL : CSR_COMP1POL_Field := 16#0#; -- Comparator 1 hysteresis COMP1HYST : CSR_COMP1HYST_Field := 16#0#; -- Read-only. Comparator 1 output COMP1OUT : CSR_COMP1OUT_Field := 16#0#; -- Comparator 1 lock COMP1LOCK : CSR_COMP1LOCK_Field := 16#0#; -- Comparator 2 enable COMP2EN : CSR_COMP2EN_Field := 16#0#; -- unspecified Reserved_17_17 : STM32_SVD.Bit := 16#0#; -- Comparator 2 mode COMP2MODE : CSR_COMP2MODE_Field := 16#0#; -- Comparator 2 inverting input selection COMP2INSEL : CSR_COMP2INSEL_Field := 16#0#; -- Window mode enable WNDWEN : CSR_WNDWEN_Field := 16#0#; -- Comparator 2 output selection COMP2OUTSEL : CSR_COMP2OUTSEL_Field := 16#0#; -- Comparator 2 output polarity COMP2POL : CSR_COMP2POL_Field := 16#0#; -- Comparator 2 hysteresis COMP2HYST : CSR_COMP2HYST_Field := 16#0#; -- Read-only. Comparator 2 output COMP2OUT : CSR_COMP2OUT_Field := 16#0#; -- Comparator 2 lock COMP2LOCK : CSR_COMP2LOCK_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CSR_Register use record COMP1EN at 0 range 0 .. 0; COMP1_INP_DAC at 0 range 1 .. 1; COMP1MODE at 0 range 2 .. 3; COMP1INSEL at 0 range 4 .. 6; Reserved_7_7 at 0 range 7 .. 7; COMP1OUTSEL at 0 range 8 .. 10; COMP1POL at 0 range 11 .. 11; COMP1HYST at 0 range 12 .. 13; COMP1OUT at 0 range 14 .. 14; COMP1LOCK at 0 range 15 .. 15; COMP2EN at 0 range 16 .. 16; Reserved_17_17 at 0 range 17 .. 17; COMP2MODE at 0 range 18 .. 19; COMP2INSEL at 0 range 20 .. 22; WNDWEN at 0 range 23 .. 23; COMP2OUTSEL at 0 range 24 .. 26; COMP2POL at 0 range 27 .. 27; COMP2HYST at 0 range 28 .. 29; COMP2OUT at 0 range 30 .. 30; COMP2LOCK at 0 range 31 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Comparator type COMP_Peripheral is record -- control and status register CSR : aliased CSR_Register; end record with Volatile; for COMP_Peripheral use record CSR at 0 range 0 .. 31; end record; -- Comparator COMP_Periph : aliased COMP_Peripheral with Import, Address => System'To_Address (16#4001001C#); end STM32_SVD.COMP;
reznikmm/matreshka
Ada
4,701
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Tools 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: 2359 $ $Date: 2011-12-27 10:20:56 +0200 (Вт, 27 дек 2011) $ ------------------------------------------------------------------------------ -- This test detects parameters to link with PostgreSQL client library. -- -- It sets following substitutions variables: -- - HAS_FIREBIRD -- - FIREBIRD_LIBRARY_OPTIONS ------------------------------------------------------------------------------ with Configure.Abstract_Tests; private with Configure.Component_Switches; package Configure.Tests.Firebird is type Firebird_Test is new Configure.Abstract_Tests.Abstract_Test with private; overriding function Name (Self : Firebird_Test) return String; -- Returns name of the test to be used in reports. overriding function Help (Self : Firebird_Test) return Unbounded_String_Vector; -- Returns help information for test. overriding procedure Execute (Self : in out Firebird_Test; Arguments : in out Unbounded_String_Vector); -- Executes test's actions. All used arguments must be removed from -- Arguments. private type Firebird_Test is new Configure.Abstract_Tests.Abstract_Test with record Switches : Configure.Component_Switches.Component_Switches := Configure.Component_Switches.Create (Name => "firebird", Description => "Firebird support", Libdir_Enabled => True); end record; end Configure.Tests.Firebird;
zenharris/ada-bbs
Ada
1,895
ads
with Ada.Text_IO; with Ada.Directories; use Ada.Text_IO; use Ada.Directories; with Terminal_Interface.Curses; use Terminal_Interface.Curses; with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Strings.Fixed; with Ada.Calendar; use Ada.Calendar; With Ada.Text_IO.Unbounded_IO; with Ada.Containers.Doubly_Linked_Lists; with Ada.Containers; use Ada.Containers; with Display_Warning; with Process_Menu; with Message.Login; package Message.Reader is package SU renames Ada.Strings.Unbounded; package SUIO renames Ada.Text_IO.Unbounded_IO; package SF renames Ada.Strings.Fixed; type Directory_Record is record FileName : Unbounded_String; Prompt : Unbounded_String; -- Func : Function_Access; end record; package Directory_List is new Ada.Containers.Doubly_Linked_Lists(Directory_Record); use Directory_List; Directory_Buffer : Directory_List.List; CurrentLine : Line_Position := 0; CurrentCurs : Cursor; TopLine : Line_Position; TermLnth : Line_Position; TermWdth : Column_Position; BottomLine : Line_Position ; Curr_Dir : string := Current_Directory; procedure Read_Directory (ReplyID : Unbounded_String := To_Unbounded_String("")); procedure Read_Messages; procedure Read_Header (FileName : in String; Sender : out Unbounded_String; Subject : out Unbounded_String; Msgid : out Unbounded_String; ReplyTo : out Unbounded_String); -- function Post_Message (ReplyID : in Unbounded_String := To_Unbounded_String(""); -- ReplySubject : in Unbounded_String := To_Unbounded_String("") ) return Boolean; function CharPad(InStr : Unbounded_String; PadWidth : Integer) return String; end Message.Reader;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
7,468
ads
-- This spec has been automatically generated from STM32F411xx.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with System; package STM32_SVD.DBG is pragma Preelaborate; --------------- -- Registers -- --------------- subtype DBGMCU_IDCODE_DEV_ID_Field is STM32_SVD.UInt12; subtype DBGMCU_IDCODE_REV_ID_Field is STM32_SVD.UInt16; -- IDCODE type DBGMCU_IDCODE_Register is record -- Read-only. DEV_ID DEV_ID : DBGMCU_IDCODE_DEV_ID_Field; -- unspecified Reserved_12_15 : STM32_SVD.UInt4; -- Read-only. REV_ID REV_ID : DBGMCU_IDCODE_REV_ID_Field; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DBGMCU_IDCODE_Register use record DEV_ID at 0 range 0 .. 11; Reserved_12_15 at 0 range 12 .. 15; REV_ID at 0 range 16 .. 31; end record; subtype DBGMCU_CR_DBG_SLEEP_Field is STM32_SVD.Bit; subtype DBGMCU_CR_DBG_STOP_Field is STM32_SVD.Bit; subtype DBGMCU_CR_DBG_STANDBY_Field is STM32_SVD.Bit; subtype DBGMCU_CR_TRACE_IOEN_Field is STM32_SVD.Bit; subtype DBGMCU_CR_TRACE_MODE_Field is STM32_SVD.UInt2; -- Control Register type DBGMCU_CR_Register is record -- DBG_SLEEP DBG_SLEEP : DBGMCU_CR_DBG_SLEEP_Field := 16#0#; -- DBG_STOP DBG_STOP : DBGMCU_CR_DBG_STOP_Field := 16#0#; -- DBG_STANDBY DBG_STANDBY : DBGMCU_CR_DBG_STANDBY_Field := 16#0#; -- unspecified Reserved_3_4 : STM32_SVD.UInt2 := 16#0#; -- TRACE_IOEN TRACE_IOEN : DBGMCU_CR_TRACE_IOEN_Field := 16#0#; -- TRACE_MODE TRACE_MODE : DBGMCU_CR_TRACE_MODE_Field := 16#0#; -- unspecified Reserved_8_31 : STM32_SVD.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DBGMCU_CR_Register use record DBG_SLEEP at 0 range 0 .. 0; DBG_STOP at 0 range 1 .. 1; DBG_STANDBY at 0 range 2 .. 2; Reserved_3_4 at 0 range 3 .. 4; TRACE_IOEN at 0 range 5 .. 5; TRACE_MODE at 0 range 6 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype DBGMCU_APB1_FZ_DBG_TIM2_STOP_Field is STM32_SVD.Bit; subtype DBGMCU_APB1_FZ_DBG_TIM3_STOP_Field is STM32_SVD.Bit; subtype DBGMCU_APB1_FZ_DBG_TIM4_STOP_Field is STM32_SVD.Bit; subtype DBGMCU_APB1_FZ_DBG_TIM5_STOP_Field is STM32_SVD.Bit; subtype DBGMCU_APB1_FZ_DBG_RTC_Stop_Field is STM32_SVD.Bit; subtype DBGMCU_APB1_FZ_DBG_WWDG_STOP_Field is STM32_SVD.Bit; subtype DBGMCU_APB1_FZ_DBG_IWDEG_STOP_Field is STM32_SVD.Bit; subtype DBGMCU_APB1_FZ_DBG_I2C1_SMBUS_TIMEOUT_Field is STM32_SVD.Bit; subtype DBGMCU_APB1_FZ_DBG_I2C2_SMBUS_TIMEOUT_Field is STM32_SVD.Bit; subtype DBGMCU_APB1_FZ_DBG_I2C3SMBUS_TIMEOUT_Field is STM32_SVD.Bit; -- Debug MCU APB1 Freeze registe type DBGMCU_APB1_FZ_Register is record -- DBG_TIM2_STOP DBG_TIM2_STOP : DBGMCU_APB1_FZ_DBG_TIM2_STOP_Field := 16#0#; -- DBG_TIM3 _STOP DBG_TIM3_STOP : DBGMCU_APB1_FZ_DBG_TIM3_STOP_Field := 16#0#; -- DBG_TIM4_STOP DBG_TIM4_STOP : DBGMCU_APB1_FZ_DBG_TIM4_STOP_Field := 16#0#; -- DBG_TIM5_STOP DBG_TIM5_STOP : DBGMCU_APB1_FZ_DBG_TIM5_STOP_Field := 16#0#; -- unspecified Reserved_4_9 : STM32_SVD.UInt6 := 16#0#; -- RTC stopped when Core is halted DBG_RTC_Stop : DBGMCU_APB1_FZ_DBG_RTC_Stop_Field := 16#0#; -- DBG_WWDG_STOP DBG_WWDG_STOP : DBGMCU_APB1_FZ_DBG_WWDG_STOP_Field := 16#0#; -- DBG_IWDEG_STOP DBG_IWDEG_STOP : DBGMCU_APB1_FZ_DBG_IWDEG_STOP_Field := 16#0#; -- unspecified Reserved_13_20 : STM32_SVD.Byte := 16#0#; -- DBG_J2C1_SMBUS_TIMEOUT DBG_I2C1_SMBUS_TIMEOUT : DBGMCU_APB1_FZ_DBG_I2C1_SMBUS_TIMEOUT_Field := 16#0#; -- DBG_J2C2_SMBUS_TIMEOUT DBG_I2C2_SMBUS_TIMEOUT : DBGMCU_APB1_FZ_DBG_I2C2_SMBUS_TIMEOUT_Field := 16#0#; -- DBG_J2C3SMBUS_TIMEOUT DBG_I2C3SMBUS_TIMEOUT : DBGMCU_APB1_FZ_DBG_I2C3SMBUS_TIMEOUT_Field := 16#0#; -- unspecified Reserved_24_31 : STM32_SVD.Byte := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DBGMCU_APB1_FZ_Register use record DBG_TIM2_STOP at 0 range 0 .. 0; DBG_TIM3_STOP at 0 range 1 .. 1; DBG_TIM4_STOP at 0 range 2 .. 2; DBG_TIM5_STOP at 0 range 3 .. 3; Reserved_4_9 at 0 range 4 .. 9; DBG_RTC_Stop at 0 range 10 .. 10; DBG_WWDG_STOP at 0 range 11 .. 11; DBG_IWDEG_STOP at 0 range 12 .. 12; Reserved_13_20 at 0 range 13 .. 20; DBG_I2C1_SMBUS_TIMEOUT at 0 range 21 .. 21; DBG_I2C2_SMBUS_TIMEOUT at 0 range 22 .. 22; DBG_I2C3SMBUS_TIMEOUT at 0 range 23 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; subtype DBGMCU_APB2_FZ_DBG_TIM1_STOP_Field is STM32_SVD.Bit; subtype DBGMCU_APB2_FZ_DBG_TIM9_STOP_Field is STM32_SVD.Bit; subtype DBGMCU_APB2_FZ_DBG_TIM10_STOP_Field is STM32_SVD.Bit; subtype DBGMCU_APB2_FZ_DBG_TIM11_STOP_Field is STM32_SVD.Bit; -- Debug MCU APB2 Freeze registe type DBGMCU_APB2_FZ_Register is record -- TIM1 counter stopped when core is halted DBG_TIM1_STOP : DBGMCU_APB2_FZ_DBG_TIM1_STOP_Field := 16#0#; -- unspecified Reserved_1_15 : STM32_SVD.UInt15 := 16#0#; -- TIM9 counter stopped when core is halted DBG_TIM9_STOP : DBGMCU_APB2_FZ_DBG_TIM9_STOP_Field := 16#0#; -- TIM10 counter stopped when core is halted DBG_TIM10_STOP : DBGMCU_APB2_FZ_DBG_TIM10_STOP_Field := 16#0#; -- TIM11 counter stopped when core is halted DBG_TIM11_STOP : DBGMCU_APB2_FZ_DBG_TIM11_STOP_Field := 16#0#; -- unspecified Reserved_19_31 : STM32_SVD.UInt13 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DBGMCU_APB2_FZ_Register use record DBG_TIM1_STOP at 0 range 0 .. 0; Reserved_1_15 at 0 range 1 .. 15; DBG_TIM9_STOP at 0 range 16 .. 16; DBG_TIM10_STOP at 0 range 17 .. 17; DBG_TIM11_STOP at 0 range 18 .. 18; Reserved_19_31 at 0 range 19 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Debug support type DBG_Peripheral is record -- IDCODE DBGMCU_IDCODE : aliased DBGMCU_IDCODE_Register; -- Control Register DBGMCU_CR : aliased DBGMCU_CR_Register; -- Debug MCU APB1 Freeze registe DBGMCU_APB1_FZ : aliased DBGMCU_APB1_FZ_Register; -- Debug MCU APB2 Freeze registe DBGMCU_APB2_FZ : aliased DBGMCU_APB2_FZ_Register; end record with Volatile; for DBG_Peripheral use record DBGMCU_IDCODE at 16#0# range 0 .. 31; DBGMCU_CR at 16#4# range 0 .. 31; DBGMCU_APB1_FZ at 16#8# range 0 .. 31; DBGMCU_APB2_FZ at 16#C# range 0 .. 31; end record; -- Debug support DBG_Periph : aliased DBG_Peripheral with Import, Address => System'To_Address (16#E0042000#); end STM32_SVD.DBG;
stcarrez/ada-servlet
Ada
1,817
adb
----------------------------------------------------------------------- -- asf-clients-tests - Unit tests for HTTP clients -- Copyright (C) 2011 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Test_Caller; with Util.Log.Loggers; with ASF.Clients.Web; package body ASF.Clients.Tests is use Util.Tests; use Util.Log; -- The logger Log : constant Loggers.Logger := Loggers.Create ("ASF.Clients.Tests"); package Caller is new Util.Test_Caller (Test, "Clients"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test ASF.Clients.Do_Get", Test_Http_Get'Access); ASF.Clients.Web.Register; end Add_Tests; -- ------------------------------ -- Test creation of cookie -- ------------------------------ procedure Test_Http_Get (T : in out Test) is pragma Unreferenced (T); C : ASF.Clients.Client; Reply : ASF.Clients.Response; begin C.Do_Get (URL => "http://www.google.com/", Reply => Reply); Log.Info ("Result: {0}", Reply.Get_Body); end Test_Http_Get; end ASF.Clients.Tests;
strenkml/EE368
Ada
446
adb
with Memory.Transform.Flip; use Memory.Transform.Flip; with Parser.Transform_Parser; separate (Parser) procedure Parse_Flip(parser : in out Parser_Type; result : out Memory_Pointer) is package Flip_Parser is new Transform_Parser( T_Type => Flip_Type, T_Pointer => Flip_Pointer, Create_Transform => Create_Flip ); begin Flip_Parser.Parse(parser, result); end Parse_Flip;
reznikmm/matreshka
Ada
3,689
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.Office_Change_Info_Elements is pragma Preelaborate; type ODF_Office_Change_Info is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Office_Change_Info_Access is access all ODF_Office_Change_Info'Class with Storage_Size => 0; end ODF.DOM.Office_Change_Info_Elements;
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_Automatic_Content_Attributes; package Matreshka.ODF_Chart.Automatic_Content_Attributes is type Chart_Automatic_Content_Attribute_Node is new Matreshka.ODF_Chart.Abstract_Chart_Attribute_Node and ODF.DOM.Chart_Automatic_Content_Attributes.ODF_Chart_Automatic_Content_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Chart_Automatic_Content_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Chart_Automatic_Content_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Chart.Automatic_Content_Attributes;
usainzg/EHU
Ada
2,079
ads
PACKAGE Salas IS TYPE Sala IS PRIVATE; --Constructor para crear la sala e inicializarla FUNCTION Crear_Sala ( Nombre_Sala : String; Numero_Filas : Positive; Numero_Localidades_Fila : Positive) RETURN Sala; --Devuelve el nombre de la sala FUNCTION Nombre_Sala ( S : Sala) RETURN String; --Devuelve el aforo maximo de la sala FUNCTION Aforo_Sala ( S : Sala) RETURN Positive; --Devuelve el numero de plazas libres en la sala FUNCTION Plazas_Libres ( S : Sala) RETURN Natural; --Imprime por pantalla el identificador de la pelicula FUNCTION La_Pelicula ( S : IN Sala) RETURN String; --Modificar el identificador de la sala pasada por parametro PROCEDURE Modificar_Pelicula ( S : IN OUT Sala; Nombre : String); --Procedimiento que vende localidades contiguas PROCEDURE Vender_Localidades_Contiguas ( S : IN OUT Sala; Numero_Entradas : Positive); --Funcion auxiliar para normalizar strings FUNCTION Normalizar_String ( S : Sala; Rango_Maximo : Positive) RETURN String; --Procedimiento para mostrar el mapa de la sala PROCEDURE Mostrar_Sala ( S : Sala); --Sobrecarga del operador ":=" para copiar objetos PROCEDURE Copiar_Sala ( S : IN OUT Sala; S_A_Copiar : IN Sala); PRIVATE RANGO_MATRIZ : CONSTANT := 25; RANGO_LOCALIDADES : CONSTANT := 25; TYPE Matriz IS ARRAY (1 .. RANGO_MATRIZ, 1 .. RANGO_MATRIZ) OF Boolean; TYPE Sala IS RECORD Nombre_Sala : String (1 .. 7); Identificador_Peli : String (1 .. 10); Localidades_Libres : Natural; Numero_Filas, Numero_Localidades_Fila : Positive RANGE 1 .. RANGO_LOCALIDADES; Array_Localidades : Matriz; END RECORD; END Salas;
ecofast/asphyre-cpp
Ada
4,412
adb
---------------------------------------------------------------- -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- -- -- -- Open source license information is in the zlib.ads file. -- ---------------------------------------------------------------- -- $Id: read.adb,v 1.1 2010/08/18 14:11:29 Administrator Exp $ -- Test/demo program for the generic read interface. with Ada.Numerics.Discrete_Random; with Ada.Streams; with Ada.Text_IO; with ZLib; procedure Read is use Ada.Streams; ------------------------------------ -- Test configuration parameters -- ------------------------------------ File_Size : Stream_Element_Offset := 100_000; Continuous : constant Boolean := False; -- If this constant is True, the test would be repeated again and again, -- with increment File_Size for every iteration. Header : constant ZLib.Header_Type := ZLib.Default; -- Do not use Header other than Default in ZLib versions 1.1.4 and older. Init_Random : constant := 8; -- We are using the same random sequence, in case of we catch bug, -- so we would be able to reproduce it. -- End -- Pack_Size : Stream_Element_Offset; Offset : Stream_Element_Offset; Filter : ZLib.Filter_Type; subtype Visible_Symbols is Stream_Element range 16#20# .. 16#7E#; package Random_Elements is new Ada.Numerics.Discrete_Random (Visible_Symbols); Gen : Random_Elements.Generator; Period : constant Stream_Element_Offset := 200; -- Period constant variable for random generator not to be very random. -- Bigger period, harder random. Read_Buffer : Stream_Element_Array (1 .. 2048); Read_First : Stream_Element_Offset; Read_Last : Stream_Element_Offset; procedure Reset; procedure Read (Item : out Stream_Element_Array; Last : out Stream_Element_Offset); -- this procedure is for generic instantiation of -- ZLib.Read -- reading data from the File_In. procedure Read is new ZLib.Read (Read, Read_Buffer, Rest_First => Read_First, Rest_Last => Read_Last); ---------- -- Read -- ---------- procedure Read (Item : out Stream_Element_Array; Last : out Stream_Element_Offset) is begin Last := Stream_Element_Offset'Min (Item'Last, Item'First + File_Size - Offset); for J in Item'First .. Last loop if J < Item'First + Period then Item (J) := Random_Elements.Random (Gen); else Item (J) := Item (J - Period); end if; Offset := Offset + 1; end loop; end Read; ----------- -- Reset -- ----------- procedure Reset is begin Random_Elements.Reset (Gen, Init_Random); Pack_Size := 0; Offset := 1; Read_First := Read_Buffer'Last + 1; Read_Last := Read_Buffer'Last; end Reset; begin Ada.Text_IO.Put_Line ("ZLib " & ZLib.Version); loop for Level in ZLib.Compression_Level'Range loop Ada.Text_IO.Put ("Level =" & ZLib.Compression_Level'Image (Level)); -- Deflate using generic instantiation. ZLib.Deflate_Init (Filter, Level, Header => Header); Reset; Ada.Text_IO.Put (Stream_Element_Offset'Image (File_Size) & " ->"); loop declare Buffer : Stream_Element_Array (1 .. 1024); Last : Stream_Element_Offset; begin Read (Filter, Buffer, Last); Pack_Size := Pack_Size + Last - Buffer'First + 1; exit when Last < Buffer'Last; end; end loop; Ada.Text_IO.Put_Line (Stream_Element_Offset'Image (Pack_Size)); ZLib.Close (Filter); end loop; exit when not Continuous; File_Size := File_Size + 1; end loop; end Read;
stcarrez/ada-wiki
Ada
57,322
adb
----------------------------------------------------------------------- -- wiki-parsers-markdown -- Markdown parser operations -- Copyright (C) 2016 - 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.Vectors; with Wiki.Nodes; with Wiki.Helpers; with Wiki.Parsers.Common; with Wiki.Html_Parser; package body Wiki.Parsers.Markdown is use Wiki.Helpers; use Wiki.Nodes; use Wiki.Strings; use type Wiki.Buffers.Buffer_Access; use type Wiki.Html_Parser.Entity_State_Type; type Marker_Kind is (M_CODE, M_STAR, M_UNDERSCORE, M_LINK, M_LINK_REF, M_IMAGE, M_END, M_ENTITY, M_TEXT); type Delimiter_Type; type Delimiter_Type is record Marker : Marker_Kind := M_END; Pos : Natural := 0; Block : Wiki.Buffers.Buffer_Access; Count : Natural := 0; Can_Open : Boolean := False; Can_Close : Boolean := False; Link_Pos : Natural := 0; Link_End : Natural := 0; end record; package Delimiter_Vectors is new Ada.Containers.Vectors (Positive, Delimiter_Type); subtype Delimiter_Vector is Delimiter_Vectors.Vector; subtype Delimiter_Cursor is Delimiter_Vectors.Cursor; function Get_Header_Level (Text : in Wiki.Buffers.Buffer_Access; From : in Positive) return Natural; function Is_Thematic_Break (Text : in Wiki.Buffers.Buffer_Access; From : in Positive; Token : in Wiki.Strings.WChar) return Boolean; procedure Get_List_Level (Parser : in out Parser_Type; Text : in out Wiki.Buffers.Buffer_Access; From : in out Positive; Level : out Integer; Indent : out Natural); function Is_End_Preformat (Text : in Wiki.Buffers.Buffer_Access; From : in Positive; Expect : in WChar; Length : in Positive) return Boolean; procedure Scan_Link_Title (Text : in out Wiki.Buffers.Buffer_Access; From : in out Positive; Expect : in Wiki.Strings.WChar; Link : in out Wiki.Strings.BString; Title : in out Wiki.Strings.BString); procedure Add_Header (Parser : in out Parser_Type; Text : in Wiki.Buffers.Buffer_Access; From : in Positive; Level : in Positive); procedure Add_Text (Parser : in out Parser_Type; Text : in out Wiki.Buffers.Buffer_Access; From : in out Positive; Limit : in Wiki.Buffers.Buffer_Access; Last_Pos : in Positive); procedure Add_Link (Parser : in out Parser_Type; Text : in out Wiki.Buffers.Buffer_Access; From : in out Positive); procedure Add_Link_Ref (Parser : in out Parser_Type; Text : in out Wiki.Buffers.Buffer_Access; From : in out Positive); procedure Add_Image (Parser : in out Parser_Type; Text : in out Wiki.Buffers.Buffer_Access; From : in out Positive); procedure Parse_Table (Parser : in out Parser_Type; Text : in out Wiki.Buffers.Buffer_Access; From : in out Positive); procedure Parse_Link (Text : in Wiki.Buffers.Buffer_Access; From : in Positive; Delim : in Delimiter_Vectors.Reference_Type); procedure Get_Delimiter (Text : in out Wiki.Buffers.Buffer_Access; From : in out Positive; Before_Char : Strings.WChar; C : in Strings.WChar; Delim : in out Delimiter_Type); procedure Parse_Link_Label (Parser : in out Parser_Type; Text : in out Wiki.Buffers.Buffer_Access; From : in out Positive; Label : in out Wiki.Strings.BString); procedure Parse_Link_Definition (Parser : in out Parser_Type; Text : in out Wiki.Buffers.Buffer_Access; From : in out Positive); procedure Scan_Backtick (Parser : in out Parser_Type; Text : in out Wiki.Buffers.Buffer_Access; From : in out Positive; Start : in out Delimiter_Type; Stop : in out Delimiter_Type); function Is_Escapable (C : in Wiki.Strings.WChar) return Boolean is (C in '!' .. '/' | ':' .. '@' | '{' .. '~' | '[' .. '`'); function Get_Header_Level (Text : in Wiki.Buffers.Buffer_Access; From : in Positive) return Natural is Count : constant Natural := Buffers.Count_Occurence (Text, From, '#'); begin if Count > 6 then return 0; end if; if From + Count > Text.Last then return 0; end if; if not Is_Space (Text.Content (From + Count)) then return 0; end if; return Count; end Get_Header_Level; function Is_Thematic_Break (Text : in Wiki.Buffers.Buffer_Access; From : in Positive; Token : in Wiki.Strings.WChar) return Boolean is Block : Wiki.Buffers.Buffer_Access := Text; Pos : Positive := From; Count : Natural := 0; begin while Block /= null loop declare Last : constant Natural := Block.Last; C : Wiki.Strings.WChar; begin while Pos <= Last loop C := Block.Content (Pos); if C = Token then Count := Count + 1; elsif not Is_Space_Or_Newline (C) then return False; end if; Pos := Pos + 1; end loop; end; Block := Block.Next_Block; Pos := 1; end loop; return Count >= 3; end Is_Thematic_Break; procedure Get_List_Level (Parser : in out Parser_Type; Text : in out Wiki.Buffers.Buffer_Access; From : in out Positive; Level : out Integer; Indent : out Natural) is Block : Wiki.Buffers.Buffer_Access := Text; Pos : Positive := From; C : Strings.WChar; Limit : Natural := 9; begin Level := 0; Indent := 0; Main : while Block /= null loop declare Last : constant Natural := Block.Last; Count : Natural; begin while Pos <= Last loop C := Block.Content (Pos); if C in '0' .. '9' then -- Must not exceed 9 digits exit Main when Limit = 0; Level := Level * 10; Level := Level + WChar'Pos (C) - WChar'Pos ('0'); Indent := Indent + 1; Limit := Limit - 1; elsif C in '.' | ')' then Indent := Indent + 1; Buffers.Next (Block, Pos); exit Main when Block = null; Buffers.Skip_Spaces (Block, Pos, Count); exit Main when Count = 0; -- A list that interrupts a paragraph must start with 1. exit Main when Level /= 1 and then not (Parser.Current_Node in Nodes.N_LIST_ITEM) and then Parser.Text_Buffer.Length > 0; Indent := Indent + Count; Text := Block; From := Pos; return; else Level := -1; return; end if; Pos := Pos + 1; end loop; end; Block := Block.Next_Block; Pos := 1; end loop Main; Level := -1; end Get_List_Level; procedure Add_Header (Parser : in out Parser_Type; Text : in Wiki.Buffers.Buffer_Access; From : in Positive; Level : in Positive) is procedure Add_Header (Content : in Wiki.Strings.WString); procedure Add_Header (Content : in Wiki.Strings.WString) is Last : Natural := Content'Last; begin -- Remove trailing spaces. while Last > Content'First and then Is_Space (Content (Last)) loop Last := Last - 1; end loop; -- If there are ending '#', remove all of them and remove trailing spaces again. if Last > Content'First and then Content (Last) = '#' then while Last > Content'First and then Content (Last) = '#' loop Last := Last - 1; end loop; while Last > Content'First and then Is_Space (Content (Last)) loop Last := Last - 1; end loop; end if; Parser.Context.Filters.Start_Block (Parser.Document, Nodes.N_HEADER, Level); Strings.Clear (Parser.Text); Buffers.Append (Parser.Text_Buffer, Content (Content'First .. Last)); Parse_Inline_Text (Parser, Parser.Text_Buffer.First'Unchecked_Access); Buffers.Clear (Parser.Text_Buffer); Parser.Document.Pop_Node (Wiki.H1_TAG); end Add_Header; procedure Add_Header is new Wiki.Strings.Wide_Wide_Builders.Get (Add_Header); Block : Wiki.Buffers.Buffer_Access := Text; Pos : Positive := From; C : Wiki.Strings.WChar; Space_Count : Natural; begin Flush_Text (Parser); Flush_List (Parser); if not Parser.Context.Is_Hidden then Buffers.Skip_Spaces (Block, Pos, Space_Count); while Block /= null loop declare Last : constant Natural := Block.Last; begin while Pos <= Last loop C := Block.Content (Pos); exit when Is_Newline (C); Append (Parser.Text, C); Pos := Pos + 1; end loop; end; Block := Block.Next_Block; end loop; Add_Header (Parser.Text); Wiki.Strings.Clear (Parser.Text); Parser.Format := (others => False); end if; Parser.Empty_Line := True; Parser.In_Paragraph := False; end Add_Header; function Is_End_Preformat (Text : in Wiki.Buffers.Buffer_Access; From : in Positive; Expect : in WChar; Length : in Positive) return Boolean is Block : Wiki.Buffers.Buffer_Access := Text; Pos : Positive := From; C : WChar; Count : Natural := 0; begin while Block /= null loop declare Last : constant Natural := Block.Last; begin while Pos <= Last loop C := Block.Content (Pos); if Is_Newline (C) then return Count >= Length; end if; if C /= Expect then return False; end if; Pos := Pos + 1; Count := Count + 1; end loop; end; Block := Block.Next_Block; Pos := 1; end loop; return False; end Is_End_Preformat; -- Parse a markdown table/column. -- Example: -- | col1 | col2 | ... | colN | procedure Parse_Table (Parser : in out Parser_Type; Text : in out Wiki.Buffers.Buffer_Access; From : in out Positive) is Block : Wiki.Buffers.Buffer_Access := Text; Pos : Positive := From + 1; C : Wiki.Strings.WChar; Skip_Spaces : Boolean := True; begin if Parser.Current_Node /= Nodes.N_TABLE then Flush_List (Parser); Push_Block (Parser, Nodes.N_TABLE); end if; Parser.Context.Filters.Add_Row (Parser.Document); Wiki.Attributes.Clear (Parser.Attributes); Main : while Block /= null loop declare Last : Natural := Block.Last; begin while Pos <= Last loop C := Block.Content (Pos); if Skip_Spaces and then Is_Space_Or_Newline (C) then Pos := Pos + 1; else if Skip_Spaces then Skip_Spaces := False; Parser.Context.Filters.Add_Column (Parser.Document, Parser.Attributes); end if; if C = '\' then Buffers.Next (Block, Pos); exit Main when Block = null; Last := Block.Last; C := Block.Content (Pos); Buffers.Append (Parser.Text_Buffer, C); elsif C = '|' then Skip_Spaces := True; Flush_Block (Parser); else Buffers.Append (Parser.Text_Buffer, C); end if; Pos := Pos + 1; end if; end loop; end; Block := Block.Next_Block; Pos := 1; end loop Main; if not Skip_Spaces then Flush_Block (Parser); end if; Text := Block; From := Pos; end Parse_Table; -- Parse a markdown link definition. -- Example: -- [label]: url -- [label]: url "title" procedure Parse_Link_Label (Parser : in out Parser_Type; Text : in out Wiki.Buffers.Buffer_Access; From : in out Positive; Label : in out Wiki.Strings.BString) is pragma Unreferenced (Parser); Block : Wiki.Buffers.Buffer_Access := Text; Pos : Positive := From; C : Wiki.Strings.WChar; begin Main : while Block /= null loop while Pos <= Block.Last loop C := Block.Content (Pos); if C = '\' then Buffers.Next (Block, Pos); exit Main when Block = null; C := Block.Content (Pos); if Is_Escapable (C) then Buffers.Next (Block, Pos); exit Main when Block = null; Append (Label, C); else Append (Label, '\'); Append (Label, C); end if; elsif C = ']' then Text := Block; From := Pos; return; else Append (Label, C); Pos := Pos + 1; end if; end loop; Block := Block.Next_Block; Pos := 1; end loop Main; Text := null; end Parse_Link_Label; -- Parse a markdown link definition. -- Example: -- [label]: url -- [label]: url "title" -- [label]: <url> procedure Parse_Link_Definition (Parser : in out Parser_Type; Text : in out Wiki.Buffers.Buffer_Access; From : in out Positive) is Block : Wiki.Buffers.Buffer_Access := Text; Pos : Positive := From + 1; Label : Wiki.Strings.BString (128); Link : Wiki.Strings.BString (128); Title : Wiki.Strings.BString (128); Space_Count : Natural; begin Parse_Link_Label (Parser, Block, Pos, Label); if Block = null or else Block.Content (Pos) /= ']' then return; end if; Buffers.Next (Block, Pos); if Block = null then return; end if; if Block.Content (Pos) /= ':' then return; end if; Buffers.Next (Block, Pos); Buffers.Skip_Spaces (Block, Pos, Space_Count); Scan_Link_Title (Block, Pos, ' ', Link, Title); if Block = null then if Wiki.Strings.Length (Link) = 0 then return; end if; Parser.Document.Set_Link (Strings.To_WString (Label), Strings.To_WString (Link), Strings.To_WString (Title)); Text := null; From := 1; return; end if; end Parse_Link_Definition; -- Current paragraph -- N_BLOCKQUOTE -- N_LIST -- N_LIST_ITEM -- N_PARAGRAPH *Never nested* -- N_PREFORMAT, Fence, Indent level *Never nested* procedure Parse_Line (Parser : in out Parser_Type; Text : in Wiki.Buffers.Buffer_Access) is Block : Wiki.Buffers.Buffer_Access := Text; Pos : Positive := 1; C : WChar; Count : Natural := 0; Level : Integer; begin -- Feed the HTML parser if there are some pending state. if not Wiki.Html_Parser.Is_Empty (Parser.Html) then Common.Parse_Html_Element (Parser, Block, Pos, Start => False); if Block = null then return; end if; end if; if Parser.In_Html and then not Wiki.Helpers.Is_Newline (Block.Content (1)) then Common.Parse_Html_Preformatted (Parser, Block, Pos); return; end if; Spaces : while Block /= null loop declare Last : constant Natural := Block.Last; begin while Pos <= Last loop C := Block.Content (Pos); if C = ' ' then Count := Count + 1; elsif C = Wiki.Helpers.HT then Count := Count + 4; else exit Spaces; end if; Pos := Pos + 1; end loop; end; Block := Block.Next_Block; Pos := 1; end loop Spaces; -- Handle blockquote first because it can contain its specific -- formatting (lists, headers, pre-formatted, ...). if Parser.In_Blockquote and then Count <= 3 then Level := Buffers.Count_Occurence (Block, Pos, '>'); if Level = 0 then loop Pop_Block (Parser); exit when Parser.Current_Node = Nodes.N_NONE; end loop; else Buffers.Next (Block, Pos, Level); Buffers.Skip_Spaces (Block, Pos, Count); if Block = null then return; end if; Push_Block (Parser, Nodes.N_BLOCKQUOTE, Level); C := Block.Content (Pos); end if; end if; -- Continue a pre-formatted block. if Parser.Current_Node = N_PREFORMAT then if Parser.Preformat_Fence = ' ' and then Count = 0 and then C in Wiki.Helpers.LF | Wiki.Helpers.CR and then not Parser.Previous_Line_Empty then Parser.Previous_Line_Empty := True; return; end if; if Parser.Preformat_Fence = ' ' and then Count < Parser.Preformat_Indent - 3 then Pop_Block (Parser); else if C = Parser.Preformat_Fence then if Is_End_Preformat (Block, Pos, C, Parser.Preformat_Fcount) then Parser.Previous_Line_Empty := False; Pop_Block (Parser); return; end if; end if; if Count > Parser.Preformat_Indent then Block := Text; Pos := 1; Buffers.Next (Block, Pos, Parser.Preformat_Indent); end if; if Parser.Previous_Line_Empty then Strings.Append_Char (Parser.Text, Wiki.Helpers.LF); end if; Common.Append (Parser.Text, Block, Pos); Parser.Previous_Line_Empty := False; return; end if; end if; if Parser.Current_Node = Nodes.N_LIST_ITEM then declare Level : constant Natural := Get_Current_Level (Parser); begin if Count >= Level + 3 then Parser.Preformat_Indent := Count; Parser.Preformat_Fence := ' '; Parser.Preformat_Fcount := 0; Parser.Context.Filters.Add_Node (Parser.Document, Nodes.N_PARAGRAPH); Push_Block (Parser, N_PREFORMAT); Common.Append (Parser.Text, Block, Pos); return; end if; if Count = Level and then Parser.Previous_Line_Empty then Parser.Context.Filters.Add_Node (Parser.Document, Nodes.N_PARAGRAPH); Flush_Block (Parser); Parser.Context.Filters.Add_Node (Parser.Document, Nodes.N_PARAGRAPH); elsif Count < Level and then Parser.Previous_Line_Empty and then C not in Wiki.Helpers.LF | Wiki.Helpers.CR then Pop_Block (Parser); end if; end; end if; if C in Wiki.Helpers.LF | Wiki.Helpers.CR then Parser.In_Html := False; if Parser.Current_Node = Nodes.N_PARAGRAPH then Pop_Block (Parser); return; end if; if Count = 0 and then Parser.Current_Node = N_LIST_ITEM then Parser.Previous_Line_Empty := True; return; end if; else if Parser.Previous_Line_Empty and then Parser.Current_Node = Nodes.N_LIST_ITEM then Flush_Block (Parser); Parser.Context.Filters.Add_Node (Parser.Document, Nodes.N_PARAGRAPH); Parser.Is_Empty_Paragraph := True; elsif Parser.Previous_Line_Empty and then Parser.Current_Node = Nodes.N_PARAGRAPH then Flush_Block (Parser); Parser.Context.Filters.Add_Node (Parser.Document, Nodes.N_PARAGRAPH); Parser.Is_Empty_Paragraph := True; end if; Parser.Previous_Line_Empty := False; end if; -- if C = '>' and then Count <= 3 then Count := Buffers.Count_Occurence (Block, Pos, '>'); Push_Block (Parser, Nodes.N_BLOCKQUOTE, Count); Buffers.Next (Block, Pos, Count); Buffers.Skip_Spaces (Block, Pos, Count); if Block = null then return; end if; if Count > 0 then Count := Count - 1; end if; C := Block.Content (Pos); end if; if Count > 3 and then Parser.Current_Node not in Nodes.N_LIST_ITEM | Nodes.N_LIST_START then if Parser.Current_Node in Nodes.N_LIST_START | Nodes.N_NUM_LIST_START then Pop_Block (Parser); end if; Parser.Preformat_Indent := Count; Parser.Preformat_Fence := ' '; Parser.Preformat_Fcount := 0; Push_Block (Parser, N_PREFORMAT); Common.Append (Parser.Text, Block, Pos); return; end if; case C is when '#' => if Count < 4 then Level := Get_Header_Level (Block, Pos); if Level > 0 then if Parser.Current_Node /= N_BLOCKQUOTE then Pop_Block (Parser); end if; Pos := Pos + Level + 1; Add_Header (Parser, Block, Pos, Level); Parser.Previous_Line_Empty := False; return; end if; end if; when '_' => if Count <= 3 and then Is_Thematic_Break (Block, Pos, C) then Add_Horizontal_Rule (Parser); return; end if; when '*' | '-' | '+' => if Count <= 3 and then C in '*' | '-' and then Is_Thematic_Break (Block, Pos, C) then Add_Horizontal_Rule (Parser); return; end if; if (Pos + 1 <= Block.Last and then Helpers.Is_Space (Block.Content (Pos + 1))) or else (Parser.Current_Node = Nodes.N_LIST_ITEM) then Level := Count + 1; Buffers.Next (Block, Pos); Buffers.Skip_Spaces (Block, Pos, Count); Level := Level + Count; if Level <= Get_Current_Level (Parser) then Pop_List (Parser, Level, C, 0); end if; if not Is_List_Item (Parser, Level) then if Parser.Current_Node /= Nodes.N_BLOCKQUOTE then Pop_Block (Parser); end if; Push_Block (Parser, Nodes.N_LIST_START, Level, C); end if; if Count >= 4 then Push_Block (Parser, Nodes.N_LIST_ITEM, Level - 4, C); Parser.Preformat_Indent := Level - 1; Parser.Preformat_Fence := ' '; Parser.Preformat_Fcount := 0; Push_Block (Parser, N_PREFORMAT); Common.Append (Parser.Text, Block, Pos); else Push_Block (Parser, Nodes.N_LIST_ITEM, Level, C); Buffers.Append (Parser.Text_Buffer, Block, Pos); Parser.Previous_Line_Empty := False; end if; return; end if; when '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' => Parser.Previous_Line_Empty := False; declare Indent : Natural; begin Get_List_Level (Parser, Block, Pos, Level, Indent); if Level >= 0 then Indent := Indent + Count; Pop_List (Parser, Indent, '0', Level); if not Is_List_Item (Parser, Indent) then Push_Block (Parser, Nodes.N_NUM_LIST_START, Level => Indent, Marker => '0', Number => Level); end if; Push_Block (Parser, Nodes.N_LIST_ITEM, Level => Indent, Marker => '0', Number => Level); Parser.List_Level := Level; Buffers.Append (Parser.Text_Buffer, Block, Pos); return; end if; end; when '~' | '`' => if Count > 0 and then Parser.Current_Node in Nodes.N_LIST_ITEM then Common.Parse_Preformatted (Parser, Block, Pos, C, True); else Common.Parse_Preformatted (Parser, Block, Pos, C, False); end if; if Parser.Current_Node = Nodes.N_PREFORMAT then Parser.Preformat_Indent := Count; -- Parser.Preformat_Fence := C; -- Parser.Preformat_Fcount := Level; -- Push_Block (Parser, N_PREFORMAT); return; end if; when '>' => if Count < 4 then -- Enter block quote return; end if; -- Parse_Blockquote (Parser, C); when '|' => if Count = 0 then Parse_Table (Parser, Block, Pos); if Block = null then return; end if; end if; when '<' => if Count <= 3 then Common.Parse_Html_Element (Parser, Block, Pos, True); if Block = null then return; end if; if Parser.In_Html then Common.Parse_Html_Preformatted (Parser, Block, Pos); return; end if; end if; when '[' => Parse_Link_Definition (Parser, Block, Pos); if Block = null then return; end if; if Parser.Previous_Line_Empty and then Parser.Current_Node /= N_PARAGRAPH then Pop_List (Parser); Push_Block (Parser, N_PARAGRAPH); end if; when others => if Parser.Previous_Line_Empty and then Parser.Current_Node /= N_PARAGRAPH then Pop_List (Parser); Push_Block (Parser, N_PARAGRAPH); end if; end case; while not (Parser.Current_Node in N_PARAGRAPH | N_NONE | N_LIST_ITEM | N_BLOCKQUOTE) loop Pop_Block (Parser); end loop; if not (Parser.Current_Node in N_PARAGRAPH | N_LIST_ITEM) then Push_Block (Parser, N_PARAGRAPH); end if; Parser.Previous_Line_Empty := False; Buffers.Append (Parser.Text_Buffer, Block, Pos); end Parse_Line; procedure Scan_Link_Title (Text : in out Wiki.Buffers.Buffer_Access; From : in out Positive; Expect : in Wiki.Strings.WChar; Link : in out Wiki.Strings.BString; Title : in out Wiki.Strings.BString) is Block : Wiki.Buffers.Buffer_Access := Text; Pos : Positive := From; C : Wiki.Strings.WChar; Space_Count : Natural; begin Wiki.Strings.Clear (Link); Wiki.Strings.Clear (Title); if Block /= null and then Block.Content (Pos) = '<' then Buffers.Next (Block, Pos); Scan_Bracket_Link : while Block /= null loop declare Last : constant Natural := Block.Last; begin while Pos <= Last loop C := Block.Content (Pos); exit Scan_Bracket_Link when C = '>'; Pos := Pos + 1; Append (Link, C); end loop; end; Block := Block.Next_Block; Pos := 1; end loop Scan_Bracket_Link; if Block /= null and then C = '>' then Buffers.Next (Block, Pos); end if; else Scan_Link : while Block /= null loop while Pos <= Block.Last loop C := Block.Content (Pos); exit Scan_Link when C = Expect or else Wiki.Helpers.Is_Space_Or_Newline (C); if C = '\' then Buffers.Next (Block, Pos); exit Scan_Link when Block = null; C := Block.Content (Pos); if Is_Escapable (C) then Buffers.Next (Block, Pos); exit Scan_Link when Block = null; Append (Link, C); else Append (Link, '\'); Append (Link, C); Buffers.Next (Block, Pos); exit Scan_Link when Block = null; end if; else Pos := Pos + 1; Append (Link, C); end if; end loop; Block := Block.Next_Block; Pos := 1; end loop Scan_Link; end if; Buffers.Skip_Spaces (Block, Pos, Space_Count); if Block /= null and then Block.Content (Pos) in '"' | ''' then Buffers.Next (Block, Pos); Scan_Title : while Block /= null loop while Pos <= Block.Last loop C := Block.Content (Pos); exit Scan_Title when C in '"' | '''; if C = '\' then Buffers.Next (Block, Pos); exit Scan_Title when Block = null; C := Block.Content (Pos); if Is_Escapable (C) then Append (Title, C); Buffers.Next (Block, Pos); exit Scan_Title when Block = null; else Append (Title, '\'); Append (Title, C); Buffers.Next (Block, Pos); exit Scan_Title when Block = null; end if; else Pos := Pos + 1; Append (Title, C); end if; end loop; Block := Block.Next_Block; Pos := 1; end loop Scan_Title; if Block /= null then Buffers.Next (Block, Pos); end if; Buffers.Skip_Spaces (Block, Pos, Space_Count); end if; Text := Block; From := Pos; end Scan_Link_Title; procedure Get_Delimiter (Text : in out Wiki.Buffers.Buffer_Access; From : in out Positive; Before_Char : Strings.WChar; C : in Strings.WChar; Delim : in out Delimiter_Type) is Block : Wiki.Buffers.Buffer_Access := Text; Pos : Positive := From; After_Char : Strings.WChar; Numdelims : Natural := 1; begin Buffers.Next (Block, Pos); if C not in ''' | '"' then Count_Delimiters : while Block /= null loop while Pos <= Block.Last loop exit Count_Delimiters when Block.Content (Pos) /= C; Pos := Pos + 1; Numdelims := Numdelims + 1; end loop; Block := Block.Next_Block; Pos := Pos + 1; end loop Count_Delimiters; end if; if Block = null then After_Char := LF; else After_Char := Block.Content (Pos); end if; declare Before_Space : constant Boolean := Helpers.Is_Space (Before_Char); Before_Punct : constant Boolean := Helpers.Is_Punctuation (Before_Char); After_Space : constant Boolean := Helpers.Is_Space_Or_Newline (After_Char); After_Punct : constant Boolean := Helpers.Is_Punctuation (After_Char); Left_Flanking : constant Boolean := Numdelims > 0 and then not After_Space and then (not After_Punct or else Before_Space or else Before_Punct); Right_Flanking : constant Boolean := Numdelims > 0 and then not Before_Space and then (not Before_Punct or else After_Space or else After_Punct); begin if C = '_' then Delim.Can_Open := Left_Flanking and then (not Right_Flanking or else Before_Punct); Delim.Can_Close := Right_Flanking and then (not Left_Flanking or else After_Punct); elsif C in ''' | '"' then Delim.Can_Open := Left_Flanking and then (not Right_Flanking or else Before_Char in '(' | '[') and then Before_Char not in ']' | ')'; Delim.Can_Close := Right_Flanking; else Delim.Can_Open := Left_Flanking; Delim.Can_Close := Right_Flanking; end if; Delim.Count := Numdelims; Delim.Pos := From; Delim.Block := Text; Text := Block; From := Pos; end; end Get_Delimiter; -- Parse a link at the ']' position: -- -- Link (M_LINK): -- [link-label] -- [link](url) -- Link (M_IMAGE): -- ![label](url) procedure Parse_Link (Text : in Wiki.Buffers.Buffer_Access; From : in Positive; Delim : in Delimiter_Vectors.Reference_Type) is Block : Wiki.Buffers.Buffer_Access := Text; Pos : Positive := From; begin Buffers.Next (Block, Pos); if Block = null then Delim.Marker := M_TEXT; return; end if; if Block.Content (Pos) = '(' then Buffers.Next (Block, Pos); declare Link : Wiki.Strings.BString (128); Title : Wiki.Strings.BString (128); begin Scan_Link_Title (Block, Pos, ')', Link, Title); end; if Block /= null and then Block.Content (Pos) = ')' then Buffers.Next (Block, Pos); Delim.Link_Pos := Pos; else Delim.Marker := M_TEXT; end if; elsif Delim.Marker = M_LINK then Delim.Marker := M_LINK_REF; else Delim.Marker := M_TEXT; end if; end Parse_Link; procedure Add_Image (Parser : in out Parser_Type; Text : in out Wiki.Buffers.Buffer_Access; From : in out Positive) is Block : Wiki.Buffers.Buffer_Access := Text; Pos : Positive := From; Alt : Wiki.Strings.BString (128); Link : Wiki.Strings.BString (128); Title : Wiki.Strings.BString (128); C : Wiki.Strings.WChar := ' '; begin Scan_Alt : while Block /= null loop declare Last : constant Natural := Block.Last; begin while Pos <= Last loop C := Block.Content (Pos); exit Scan_Alt when C = ']'; Append (Alt, C); Pos := Pos + 1; end loop; end; Block := Block.Next_Block; Pos := 1; end loop Scan_Alt; if Block /= null and then C = ']' then Buffers.Next (Block, Pos); end if; if Block /= null and then Block.Content (Pos) = '(' then Buffers.Next (Block, Pos); Scan_Link_Title (Block, Pos, ')', Link, Title); if Block /= null and then Block.Content (Pos) = ')' then Buffers.Next (Block, Pos); end if; end if; Flush_Text (Parser); if not Parser.Context.Is_Hidden then Wiki.Attributes.Clear (Parser.Attributes); Wiki.Attributes.Append (Parser.Attributes, "src", Link); Wiki.Attributes.Append (Parser.Attributes, "title", Title); Parser.Context.Filters.Add_Image (Parser.Document, Strings.To_WString (Alt), Parser.Attributes); end if; Text := Block; From := Pos; end Add_Image; procedure Add_Link (Parser : in out Parser_Type; Text : in out Wiki.Buffers.Buffer_Access; From : in out Positive) is Block : Wiki.Buffers.Buffer_Access := Text; Pos : Positive := From; Alt : Wiki.Strings.BString (128); Title : Wiki.Strings.BString (128); Link : Wiki.Strings.BString (128); C : Wiki.Strings.WChar; begin Scan_Alt : while Block /= null loop declare Last : Natural := Block.Last; begin while Pos <= Last loop C := Block.Content (Pos); exit Scan_Alt when C = ']'; if C = '\' then Pos := Pos + 1; if Pos > Last then Block := Block.Next_Block; exit Scan_Alt when Block = null; Last := Block.Last; Pos := 1; end if; C := Block.Content (Pos); if not Is_Escapable (C) then Append (Alt, '\'); end if; end if; Append (Alt, C); Pos := Pos + 1; end loop; end; Block := Block.Next_Block; Pos := 1; end loop Scan_Alt; if Block /= null and then C = ']' then Buffers.Next (Block, Pos); end if; if Block /= null and then Block.Content (Pos) = '(' then Buffers.Next (Block, Pos); Scan_Link_Title (Block, Pos, ')', Link, Title); if Block /= null and then Block.Content (Pos) = ')' then Buffers.Next (Block, Pos); end if; end if; Flush_Text (Parser); if not Parser.Context.Is_Hidden then Wiki.Attributes.Clear (Parser.Attributes); Wiki.Attributes.Append (Parser.Attributes, HREF_ATTR, Link); Wiki.Attributes.Append (Parser.Attributes, "title", Title); Parser.Context.Filters.Add_Link (Parser.Document, Strings.To_WString (Alt), Parser.Attributes); end if; Text := Block; From := Pos; end Add_Link; procedure Add_Link_Ref (Parser : in out Parser_Type; Text : in out Wiki.Buffers.Buffer_Access; From : in out Positive) is Block : Wiki.Buffers.Buffer_Access := Text; Pos : Positive := From; Label : Wiki.Strings.BString (128); C : Wiki.Strings.WChar; begin Scan_Label : while Block /= null loop declare Last : Natural := Block.Last; begin while Pos <= Last loop C := Block.Content (Pos); exit Scan_Label when C = ']'; if C = '\' then Pos := Pos + 1; if Pos > Last then Block := Block.Next_Block; exit Scan_Label when Block = null; Last := Block.Last; Pos := 1; end if; C := Block.Content (Pos); if not Is_Escapable (C) then Append (Label, '\'); end if; end if; Append (Label, C); Pos := Pos + 1; end loop; end; Block := Block.Next_Block; Pos := 1; end loop Scan_Label; if Block /= null and then C = ']' then Buffers.Next (Block, Pos); end if; Flush_Text (Parser); if not Parser.Context.Is_Hidden then Parser.Context.Filters.Add_Link_Ref (Parser.Document, Strings.To_WString (Label)); end if; Text := Block; From := Pos; end Add_Link_Ref; procedure Add_Text (Parser : in out Parser_Type; Text : in out Wiki.Buffers.Buffer_Access; From : in out Positive; Limit : in Wiki.Buffers.Buffer_Access; Last_Pos : in Positive) is Block : Wiki.Buffers.Buffer_Access := Text; Pos : Positive := From; begin while Block /= null loop declare Last : constant Natural := Block.Last; C : Wiki.Strings.WChar; begin while Pos <= Last loop if Block = Limit and then Pos = Last_Pos then return; end if; C := Block.Content (Pos); if C = Wiki.Helpers.CR or else C = Wiki.Helpers.LF then if Parser.Format (STRONG) or else Parser.Format (EMPHASIS) then Flush_Text (Parser); Parser.Context.Filters.Add_Node (Parser.Document, Nodes.N_LINE_BREAK); else Append (Parser.Text, ' '); end if; elsif C = '\' then Buffers.Next (Block, Pos); if Block = Limit and then Pos = Last_Pos then return; end if; C := Block.Content (Pos); if Wiki.Helpers.Is_Newline (C) and then not Parser.Format (CODE) and then (Limit /= null or else Pos < Last) then Flush_Text (Parser); if not Parser.Context.Is_Hidden then Parser.Context.Filters.Add_Node (Parser.Document, Nodes.N_LINE_BREAK); end if; elsif Parser.Format (CODE) or else not Is_Escapable (C) then Append (Parser.Text, '\'); Append (Parser.Text, C); else Append (Parser.Text, C); end if; else Append (Parser.Text, C); end if; Pos := Pos + 1; end loop; end; Block := Block.Next_Block; Pos := 1; end loop; Text := Block; From := Pos; end Add_Text; procedure Scan_Backtick (Parser : in out Parser_Type; Text : in out Wiki.Buffers.Buffer_Access; From : in out Positive; Start : in out Delimiter_Type; Stop : in out Delimiter_Type) is pragma Unreferenced (Parser); Block : Wiki.Buffers.Buffer_Access := Text; Pos : Positive := From; Count : Natural; C : Wiki.Strings.WChar; begin Start.Pos := Pos; Start.Block := Block; Buffers.Count_Occurence (Block, Pos, '`', Count); Start.Count := Count; while Block /= null loop while Pos <= Block.Last loop C := Block.Content (Pos); if C = '`' then Stop.Block := Block; Stop.Pos := Pos; Buffers.Count_Occurence (Block, Pos, '`', Count); -- Found a matching occurence, we are done. if Count = Start.Count then Start.Marker := M_CODE; Start.Can_Open := True; Start.Can_Close := False; Stop.Can_Open := False; Stop.Can_Close := True; Stop.Count := Count; Stop.Marker := M_CODE; Text := Block; From := Pos; return; end if; elsif C = '\' then Buffers.Next (Block, Pos); end if; Pos := Pos + 1; end loop; Block := Block.Next_Block; Pos := 1; end loop; -- End of buffer reached: we have not found the end marker. Start.Count := 0; From := From + 1; end Scan_Backtick; procedure Parse_Inline_Text (Parser : in out Parser_Type; Text : in Wiki.Buffers.Buffer_Access) is use Delimiter_Vectors; function Has_Closing (Starting : in Delimiter_Cursor; Opening : in Delimiter_Type) return Boolean; Block : Wiki.Buffers.Buffer_Access := Text; Pos : Positive := 1; C : Wiki.Strings.WChar; Prev : Wiki.Strings.WChar := ' '; Delimiters : Delimiter_Vector; function Has_Closing (Starting : in Delimiter_Cursor; Opening : in Delimiter_Type) return Boolean is Iter : Delimiter_Cursor := Starting; begin Delimiter_Vectors.Next (Iter); while Delimiter_Vectors.Has_Element (Iter) loop declare Delim : constant Delimiter_Vectors.Reference_Type := Delimiters.Reference (Iter); begin if Opening.Marker = Delim.Marker then return True; end if; end; Delimiter_Vectors.Next (Iter); end loop; return False; end Has_Closing; Delim : Delimiter_Type; begin Main : while Block /= null loop while Pos <= Block.Last loop C := Block.Content (Pos); case C is when '\' => Pos := Pos + 1; Buffers.Next (Block, Pos); exit Main when Block = null; Prev := C; when '`' => declare End_Marker : Delimiter_Type; begin Scan_Backtick (Parser, Block, Pos, Delim, End_Marker); if Delim.Count > 0 then Delimiters.Append (Delim); Delimiters.Append (End_Marker); end if; exit Main when Block = null; end; Prev := C; when '*' => Get_Delimiter (Block, Pos, Prev, C, Delim); if Delim.Can_Open or else Delim.Can_Close then Delim.Marker := M_STAR; Delimiters.Append (Delim); end if; Prev := C; exit Main when Block = null; when '_' => Get_Delimiter (Block, Pos, Prev, C, Delim); if Delim.Can_Open or else Delim.Can_Close then Delim.Marker := M_UNDERSCORE; Delimiters.Append (Delim); end if; Prev := C; exit Main when Block = null; when '[' => Get_Delimiter (Block, Pos, Prev, C, Delim); if Delim.Can_Open or else Delim.Can_Close then Delim.Marker := M_LINK; Delimiters.Append (Delim); end if; Prev := C; exit Main when Block = null; when ']' => for Iter in reverse Delimiters.Iterate loop declare Delim : constant Delimiter_Vectors.Reference_Type := Delimiters.Reference (Iter); begin if Delim.Marker in M_LINK | M_IMAGE and then Delim.Link_Pos = 0 then Parse_Link (Block, Pos, Delim); exit; end if; end; end loop; Pos := Pos + 1; Prev := C; when '!' => Delim.Block := Block; Delim.Pos := Pos; Buffers.Next (Block, Pos); Prev := C; exit Main when Block = null; if Block.Content (Pos) = '[' then Delim.Marker := M_IMAGE; Delim.Count := 1; Delim.Can_Close := False; Delim.Can_Open := False; Delimiters.Append (Delim); Pos := Pos + 1; Prev := '['; end if; when '&' => declare Status : Wiki.Html_Parser.Entity_State_Type; begin Delim.Block := Block; Delim.Pos := Pos; Common.Parse_Entity (Parser, Block, Pos, Status, C); if Status = Wiki.Html_Parser.ENTITY_VALID then Delim.Block.Content (Delim.Pos) := C; Buffers.Next (Delim.Block, Delim.Pos); Delim.Marker := M_ENTITY; Delim.Count := 1; Delim.Can_Close := False; Delim.Can_Open := False; Delimiters.Append (Delim); else Pos := Pos + 1; end if; exit Main when Block = null; end; when others => Pos := Pos + 1; Prev := C; end case; end loop; Block := Block.Next_Block; Pos := 1; end loop Main; Block := Text; Pos := 1; for Iter in Delimiters.Iterate loop declare Delim : constant Delimiter_Vectors.Reference_Type := Delimiters.Reference (Iter); begin if Delim.Block.Offset > Block.Offset or else (Delim.Block.Offset = Block.Offset and then Delim.Pos >= Pos) then if Delim.Marker = M_ENTITY then Add_Text (Parser, Block, Pos, Delim.Block, Delim.Pos); Pos := Delim.Pos; Block := Delim.Block; while Block /= null and then Block.Content (Pos) /= ';' loop Buffers.Next (Block, Pos); end loop; if Block /= null then Buffers.Next (Block, Pos); end if; elsif Delim.Marker = M_LINK and then Delim.Link_Pos > 0 then Add_Text (Parser, Block, Pos, Delim.Block, Delim.Pos); Block := Delim.Block; Pos := Delim.Pos; Buffers.Next (Block, Pos); Add_Link (Parser, Block, Pos); elsif Delim.Marker = M_LINK_REF then Add_Text (Parser, Block, Pos, Delim.Block, Delim.Pos); Block := Delim.Block; Pos := Delim.Pos; Buffers.Next (Block, Pos); Add_Link_Ref (Parser, Block, Pos); elsif Delim.Marker = M_IMAGE then Add_Text (Parser, Block, Pos, Delim.Block, Delim.Pos); Block := Delim.Block; Pos := Delim.Pos; Buffers.Next (Block, Pos); Buffers.Next (Block, Pos); Add_Image (Parser, Block, Pos); elsif Delim.Marker = M_LINK_REF then Add_Text (Parser, Block, Pos, Delim.Block, Delim.Pos); -- if Pos <= Delim.Pos - 1 then -- Parser.Context.Filters.Add_Text (Parser.Document, -- Text (Pos .. Delim.Pos - 1), Parser.Format); -- end if; Block := Delim.Block; Pos := Delim.Pos; Add_Link (Parser, Block, Pos); elsif Delim.Count > 0 and then Delim.Can_Open and then (Has_Closing (Iter, Delim) or else Delim.Marker = M_CODE) then Add_Text (Parser, Block, Pos, Delim.Block, Delim.Pos); Flush_Text (Parser); -- if Pos < Delim.Pos then -- Parser.Context.Filters.Add_Text (Parser.Document, -- Text (Pos .. Delim.Pos - 1), Parser.Format); -- end if; if Delim.Marker in M_STAR | M_UNDERSCORE and then Delim.Count = 2 then Parser.Format (STRONG) := True; -- not Parser.Format (STRONG); elsif Delim.Marker in M_STAR | M_UNDERSCORE then Parser.Format (EMPHASIS) := True; -- not Parser.Format (EMPHASIS); elsif Delim.Marker = M_CODE then Parser.Format (CODE) := not Parser.Format (CODE); end if; Block := Delim.Block; Pos := Delim.Pos; for I in 1 .. Delim.Count loop Buffers.Next (Block, Pos); end loop; elsif Delim.Count > 0 and then Delim.Can_Close then Add_Text (Parser, Block, Pos, Delim.Block, Delim.Pos); if Delim.Marker in M_STAR | M_UNDERSCORE and then Delim.Count = 2 and then Parser.Format (STRONG) then Flush_Text (Parser); Parser.Format (STRONG) := False; elsif Delim.Marker in M_STAR | M_UNDERSCORE and then Parser.Format (EMPHASIS) then Flush_Text (Parser); Parser.Format (EMPHASIS) := False; elsif Delim.Marker = M_CODE and then Parser.Format (CODE) then Flush_Text (Parser); Parser.Format (CODE) := False; else Block := Delim.Block; Pos := Delim.Pos; for I in 1 .. Delim.Count loop Append (Parser.Text, Block.Content (Pos)); Buffers.Next (Block, Pos); end loop; end if; Block := Delim.Block; Pos := Delim.Pos; for I in 1 .. Delim.Count loop Buffers.Next (Block, Pos); end loop; end if; end if; end; end loop; Add_Text (Parser, Block, Pos, null, 1); Flush_Text (Parser, Trim => Wiki.Parsers.Right); end Parse_Inline_Text; end Wiki.Parsers.Markdown;
sungyeon/drake
Ada
11,616
adb
with Ada.Exception_Identification.From_Here; with Ada.Exceptions.Finally; with System.Address_To_Named_Access_Conversions; with System.Growth; with System.Standard_Allocators; with System.Storage_Elements; with System.Zero_Terminated_Strings; with C.errno; with C.fcntl; with C.unistd; package body System.Native_Directories.Volumes is use Ada.Exception_Identification.From_Here; use type Storage_Elements.Storage_Offset; use type File_Size; use type C.char; use type C.char_array; use type C.char_ptr; use type C.ptrdiff_t; use type C.signed_int; use type C.signed_long; -- f_type in 64bit use type C.signed_long_long; -- f_type in x32 use type C.size_t; use type C.sys.types.fsid_t; procedure memcpy (dst, src : not null C.char_ptr; n : C.size_t) with Import, Convention => Intrinsic, External_Name => "__builtin_memcpy"; package char_ptr_Conv is new Address_To_Named_Access_Conversions (C.char, C.char_ptr); function "+" (Left : C.char_ptr; Right : C.ptrdiff_t) return C.char_ptr with Convention => Intrinsic; function "-" (Left : C.char_ptr; Right : C.char_ptr) return C.ptrdiff_t with Convention => Intrinsic; function "<" (Left, Right : C.char_ptr) return Boolean with Import, Convention => Intrinsic; pragma Inline_Always ("+"); pragma Inline_Always ("-"); function "+" (Left : C.char_ptr; Right : C.ptrdiff_t) return C.char_ptr is begin return char_ptr_Conv.To_Pointer ( char_ptr_Conv.To_Address (Left) + Storage_Elements.Storage_Offset (Right)); end "+"; function "-" (Left : C.char_ptr; Right : C.char_ptr) return C.ptrdiff_t is begin return C.ptrdiff_t ( char_ptr_Conv.To_Address (Left) - char_ptr_Conv.To_Address (Right)); end "-"; proc_self_mountinfo : aliased constant C.char_array (0 .. 20) := "/proc/self/mountinfo" & C.char'Val (0); -- 36 35 98:0 /mnt1 /mnt2 rw,noatime master:1 - ext3 /dev/root rw,... -- (1)(2)(3) (4) (5) (6) (7) (8) (9) (10) (11) -- (1) mount ID -- (2) parent ID -- (3) major:minor, st_dev -- (4) root, '/' -- (5) mount point (for Directory) -- (6) mount options -- (7) optional fields -- (8) separator, '-' -- (9) filesystem type (for Format_Name) -- (10) mount source (for Device) -- (11) super options procedure Close (fd : in out C.signed_int); procedure Close (fd : in out C.signed_int) is begin if C.unistd.close (fd) < 0 then null; -- raise Use_Error end if; end Close; procedure Skip (P : in out C.char_ptr; To : C.char); procedure Skip (P : in out C.char_ptr; To : C.char) is begin while P.all /= C.char'Val (10) loop if P.all = To then P := P + 1; exit; end if; P := P + 1; end loop; end Skip; procedure Skip_Escaped (P : in out C.char_ptr; Length : out C.size_t); procedure Skip_Escaped (P : in out C.char_ptr; Length : out C.size_t) is Z : constant := C.char'Pos ('0'); D : C.char_ptr := P; begin Length := 0; while P.all /= C.char'Val (10) loop if P.all = ' ' then P := P + 1; exit; elsif P.all = '\' and then C.char_ptr'(P + 1).all in '0' .. '3' and then C.char_ptr'(P + 2).all in '0' .. '7' and then C.char_ptr'(P + 3).all in '0' .. '7' then D.all := C.char'Val ( 64 * (C.char'Pos (C.char_ptr'(P + 1).all) - Z) + 8 * (C.char'Pos (C.char_ptr'(P + 2).all) - Z) + (C.char'Pos (C.char_ptr'(P + 3).all) - Z)); P := P + 4; else if D /= P then D.all := P.all; end if; P := P + 1; end if; D := D + 1; Length := Length + 1; end loop; end Skip_Escaped; procedure Skip_Line (P : in out C.char_ptr); procedure Skip_Line (P : in out C.char_ptr) is begin while P.all /= C.char'Val (10) loop P := P + 1; end loop; P := P + 1; -- skip '\n' end Skip_Line; procedure Read_Info (FS : in out File_System); procedure Read_Info (FS : in out File_System) is package Buffer_Holder is new Growth.Scoped_Holder ( C.sys.types.ssize_t, Component_Size => C.char_array'Component_Size); Size : C.size_t := 0; begin Buffer_Holder.Reserve_Capacity (4096); -- read /proc/self/mountinfo declare package File_Holder is new Ada.Exceptions.Finally.Scoped_Holder (C.signed_int, Close); File : aliased C.signed_int; begin File := C.fcntl.open (proc_self_mountinfo (0)'Access, C.fcntl.O_RDONLY); if File < 0 then Raise_Exception (Named_IO_Exception_Id (C.errno.errno)); end if; File_Holder.Assign (File); Reading : loop loop declare Read_Size : C.sys.types.ssize_t; begin Read_Size := C.unistd.read ( File, C.void_ptr ( char_ptr_Conv.To_Address ( char_ptr_Conv.To_Pointer ( Buffer_Holder.Storage_Address) + C.ptrdiff_t (Size))), C.size_t (Buffer_Holder.Capacity) - Size); if Read_Size < 0 then Raise_Exception (IO_Exception_Id (C.errno.errno)); end if; exit Reading when Read_Size = 0; Size := Size + C.size_t (Read_Size); end; exit when Size >= C.size_t (Buffer_Holder.Capacity); end loop; -- growth declare function Grow is new Growth.Fast_Grow (C.sys.types.ssize_t); begin Buffer_Holder.Reserve_Capacity (Grow (Buffer_Holder.Capacity)); end; end loop Reading; end; -- parsing declare End_Of_Buffer : constant C.char_ptr := char_ptr_Conv.To_Pointer (Buffer_Holder.Storage_Address) + C.ptrdiff_t (Size); Line : C.char_ptr := char_ptr_Conv.To_Pointer (Buffer_Holder.Storage_Address); begin while Line < End_Of_Buffer loop declare Directory_Offset : C.ptrdiff_t; Directory_Length : C.size_t; Format_Name_Offset : C.ptrdiff_t; Format_Name_Length : C.size_t; Device_Offset : C.ptrdiff_t; Device_Length : C.size_t; statfs : aliased C.sys.statfs.struct_statfs; P : C.char_ptr := Line; begin Skip (P, To => ' '); -- mount ID Skip (P, To => ' '); -- parent ID Skip (P, To => ' '); -- major:minor Skip (P, To => ' '); -- root Directory_Offset := P - Line; -- mount point Skip_Escaped (P, Directory_Length); Skip (P, To => ' '); -- mount options loop -- optional fields Skip (P, To => ' '); exit when P.all = '-' or else P.all = C.char'Val (10); end loop; Skip (P, To => ' '); -- separator Format_Name_Offset := P - Line; -- filesystem type Skip_Escaped (P, Format_Name_Length); Device_Offset := P - Line; -- mount source Skip_Escaped (P, Device_Length); Skip_Line (P); -- super options -- matching declare End_Of_Directory : constant C.char_ptr := Line + Directory_Offset + C.ptrdiff_t (Directory_Length); Orig : constant C.char := End_Of_Directory.all; begin End_Of_Directory.all := C.char'Val (0); if C.sys.statfs.statfs ( Line + Directory_Offset, statfs'Access) < 0 then Raise_Exception (Named_IO_Exception_Id (C.errno.errno)); end if; End_Of_Directory.all := Orig; end; if statfs.f_fsid /= (val => (others => 0)) and then statfs.f_fsid = FS.Statistics.f_fsid then FS.Format_Name_Offset := Format_Name_Offset; FS.Format_Name_Length := Format_Name_Length; FS.Directory_Offset := Directory_Offset; FS.Directory_Length := Directory_Length; FS.Device_Offset := Device_Offset; FS.Device_Length := Device_Length; FS.Info := char_ptr_Conv.To_Pointer ( Standard_Allocators.Allocate ( Storage_Elements.Storage_Count (P - Line))); memcpy (FS.Info, Line, C.size_t (P - Line)); return; -- found end if; -- continue Line := P; end; end loop; end; Raise_Exception (Use_Error'Identity); -- not found end Read_Info; -- implementation function Is_Assigned (FS : File_System) return Boolean is begin return FS.Statistics.f_type /= 0; end Is_Assigned; procedure Get (Name : String; FS : aliased out File_System) is C_Name : C.char_array ( 0 .. Name'Length * Zero_Terminated_Strings.Expanding); begin Zero_Terminated_Strings.To_C (Name, C_Name (0)'Access); FS.Info := null; if C.sys.statfs.statfs (C_Name (0)'Access, FS.Statistics'Access) < 0 then Raise_Exception (Named_IO_Exception_Id (C.errno.errno)); end if; end Get; procedure Finalize (FS : in out File_System) is begin Standard_Allocators.Free (char_ptr_Conv.To_Address (FS.Info)); end Finalize; function Size (FS : File_System) return File_Size is begin return File_Size (FS.Statistics.f_blocks) * File_Size (FS.Statistics.f_bsize); end Size; function Free_Space (FS : File_System) return File_Size is begin return File_Size (FS.Statistics.f_bfree) * File_Size (FS.Statistics.f_bsize); end Free_Space; function Format_Name (FS : aliased in out File_System) return String is begin if FS.Info = null then Read_Info (FS); end if; return Zero_Terminated_Strings.Value ( FS.Info + FS.Format_Name_Offset, FS.Format_Name_Length); end Format_Name; function Directory (FS : aliased in out File_System) return String is begin if FS.Info = null then Read_Info (FS); end if; return Zero_Terminated_Strings.Value ( FS.Info + FS.Directory_Offset, FS.Directory_Length); end Directory; function Device (FS : aliased in out File_System) return String is begin if FS.Info = null then Read_Info (FS); end if; return Zero_Terminated_Strings.Value ( FS.Info + FS.Device_Offset, FS.Device_Length); end Device; function Identity (FS : File_System) return File_System_Id is begin return FS.Statistics.f_fsid; end Identity; end System.Native_Directories.Volumes;
stcarrez/ada-awa
Ada
3,907
ads
----------------------------------------------------------------------- -- awa-storages-modules -- Storage management module -- Copyright (C) 2012, 2018, 2020 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with ASF.Applications; with AWA.Modules; with AWA.Storages.Services; with AWA.Storages.Servlets; -- == Integration == -- To be able to use the `storages` module, you will need to add the following -- line in your GNAT project file: -- -- with "awa_storages"; -- -- The `Storage_Module` type represents the storage module. An instance -- of the storage module must be declared and registered when the application -- is created and initialized. The storage module is associated with -- the storage service which provides and implements the storage management -- operations. An instance of the `Storage_Module` must be declared and -- registered in the AWA application. The module instance can be defined -- as follows: -- -- with AWA.Storages.Modules; -- ... -- type Application is new AWA.Applications.Application with record -- Storage_Module : aliased AWA.Storages.Modules.Storage_Module; -- end record; -- -- And registered in the `Initialize_Modules` procedure by using: -- -- Register (App => App.Self.all'Access, -- Name => AWA.Storages.Modules.NAME, -- Module => App.Storage_Module'Access); -- -- == Permissions == -- @include-permission storages.xml -- -- == Configuration == -- The `storages` module defines the following configuration parameters: -- -- @include-config storages.xml package AWA.Storages.Modules is NAME : constant String := "storages"; type Storage_Module is new AWA.Modules.Module with private; type Storage_Module_Access is access all Storage_Module'Class; -- Initialize the storage module. overriding procedure Initialize (Plugin : in out Storage_Module; App : in AWA.Modules.Application_Access; Props : in ASF.Applications.Config); -- Configures the module after its initialization and after having -- read its XML configuration. overriding procedure Configure (Plugin : in out Storage_Module; Props : in ASF.Applications.Config); -- Get the storage manager. function Get_Storage_Manager (Plugin : in Storage_Module) return Services.Storage_Service_Access; -- Create a storage manager. This operation can be overridden to provide -- another storage service implementation. function Create_Storage_Manager (Plugin : in Storage_Module) return Services.Storage_Service_Access; -- Get the storage module instance associated with the current application. function Get_Storage_Module return Storage_Module_Access; -- Get the storage manager instance associated with the current application. function Get_Storage_Manager return Services.Storage_Service_Access; private type Storage_Module is new AWA.Modules.Module with record Manager : Services.Storage_Service_Access := null; Storage_Servlet : aliased AWA.Storages.Servlets.Storage_Servlet; end record; end AWA.Storages.Modules;
sf17k/sdlada
Ada
2,015
adb
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2014-2015 Luke A. Guest -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- -- 1. The origin of this software must not be misrepresented; you must not -- claim that you wrote the original software. If you use this software -- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- -- 3. This notice may not be removed or altered from any source -- distribution. -------------------------------------------------------------------------------------------------------------------- with Interfaces.C; package body SDL.Power is package C renames Interfaces.C; use type C.int; procedure Info (Data : in out Battery_Info) is function SDL_GetPowerInfo (Seconds, Percent : out C.int) return State with Import => True, Convention => C, External_Name => "SDL_GetPowerInfo"; Seconds, Percent : C.int; begin Data.Power_State := SDL_GetPowerInfo (Seconds, Percent); if Seconds = -1 then Data.Time_Valid := False; else Data.Time_Valid := True; Data.Time := SDL.Power.Seconds (Seconds); end if; if Percent = -1 then Data.Percentage_Valid := False; else Data.Percentage_Valid := True; Data.Percent := Percentage (Percent); end if; end Info; end SDL.Power;
AdaCore/Ada-IntelliJ
Ada
469
adb
-- Ada Keywords abort abs abstract accept access aliased all and array at begin body case constant declare delay delta digits do else elsif end entry exception exit for function generic goto if in interface is limited loop mod new not null of or others out overriding package pragma private procedure protected raise range record rem renames requeue return reverse select separate some subtype synchronized tagged task terminate then type until use when while with xor
0siris/carve
Ada
5,446
adb
-- -- (c) Copyright 1993,1994,1995,1996 Silicon Graphics, Inc. -- ALL RIGHTS RESERVED -- Permission to use, copy, modify, and distribute this software for -- any purpose and without fee is hereby granted, provided that the above -- copyright notice appear in all copies and that both the copyright notice -- and this permission notice appear in supporting documentation, and that -- the name of Silicon Graphics, Inc. not be used in advertising -- or publicity pertaining to distribution of the software without specific, -- written prior permission. -- -- THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" -- AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, -- INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR -- FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON -- GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, -- SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY -- KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, -- LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF -- THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN -- ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON -- ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE -- POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. -- -- US Government Users Restricted Rights -- Use, duplication, or disclosure by the Government is subject to -- restrictions set forth in FAR 52.227.19(c)(2) or subparagraph -- (c)(1)(ii) of the Rights in Technical Data and Computer Software -- clause at DFARS 252.227-7013 and/or in similar or successor -- clauses in the FAR or the DOD or NASA FAR Supplement. -- Unpublished-- rights reserved under the copyright laws of the -- United States. Contractor/manufacturer is Silicon Graphics, -- Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. -- -- OpenGL(TM) is a trademark of Silicon Graphics, Inc. -- with System; use System; with GL; use GL; with Ada.Numerics; use Ada.Numerics; with Ada.Numerics.Generic_Elementary_Functions; package body Texturesurf_Procs is package GLdouble_GEF is new Generic_Elementary_Functions (GLfloat); use GLdouble_GEF; ctrlpoints : array (0 .. 3, 0 .. 3, 0 .. 2) of aliased GLfloat := (((-1.5, -1.5, 4.0), (-0.5, -1.5, 2.0), (0.5, -1.5, -1.0), (1.5, -1.5, 2.0)), ((-1.5, -0.5, 1.0), (-0.5, -0.5, 3.0), (0.5, -0.5, 0.0), (1.5, -0.5, -1.0)), ((-1.5, 0.5, 4.0), (-0.5, 0.5, 0.0), (0.5, 0.5, 3.0), (1.5, 0.5, 4.0)), ((-1.5, 1.5, -2.0), (-0.5, 1.5, -2.0), (0.5, 1.5, 0.0), (1.5, 1.5, -1.0))); texpts : array (0 .. 1, 0 .. 1, 0 .. 1) of aliased GLfloat := (((0.0, 0.0), (0.0, 1.0)), ((1.0, 0.0), (1.0, 1.0))); imageWidth : constant := 64; imageHeight : constant := 64; image : array (Integer range 0 .. (3*imageWidth*imageHeight)) of aliased GLubyte; procedure makeImage is ti, tj : GLfloat; begin for i in 0 .. (imageWidth - 1) loop ti := 2.0*Pi*GLfloat (i)/GLfloat (imageWidth); for j in 0 .. (imageHeight - 1) loop tj := 2.0*Pi*GLfloat (j)/GLfloat (imageHeight); image (3 * (imageHeight * i + j)) := GLubyte (127.0 * (1.0 + Sin (ti))); image (3 * (imageHeight * i + j) + 1) := GLubyte (127.0 * (1.0 + Cos (2.0 * tj))); image (3 * (imageHeight * i + j) + 2) := GLubyte (127.0 * (1.0 + Cos (ti + tj))); end loop; end loop; end makeImage; procedure DoInit is begin glMap2f (GL_MAP2_VERTEX_3, 0.0, 1.0, 3, 4, 0.0, 1.0, 12, 4, ctrlpoints (0, 0, 0)'Access); glMap2f (GL_MAP2_TEXTURE_COORD_2, 0.0, 1.0, 2, 2, 0.0, 1.0, 4, 2, texpts (0, 0, 0)'Access); glEnable (GL_MAP2_TEXTURE_COORD_2); glEnable (GL_MAP2_VERTEX_3); glMapGrid2f (20, 0.0, 1.0, 20, 0.0, 1.0); makeImage; glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexImage2D (GL_TEXTURE_2D, 0, 3, imageWidth, imageHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, image(0)'Access); glEnable (GL_TEXTURE_2D); glEnable (GL_DEPTH_TEST); glEnable (GL_NORMALIZE); glShadeModel (GL_FLAT); end DoInit; procedure DoDisplay is begin glClear (GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); glColor3f (1.0, 1.0, 1.0); glEvalMesh2 (GL_FILL, 0, 20, 0, 20); glFlush; end DoDisplay; procedure ReshapeCallback (w : Integer; h : Integer) is begin glViewport (0, 0, GLsizei(w), GLsizei(h)); glMatrixMode (GL_PROJECTION); glLoadIdentity; if w <= h then glOrtho (-4.0, 4.0, GLdouble (-4.0*GLdouble (h)/GLdouble (w)), GLdouble (4.0*GLdouble (h)/GLdouble (w)), -4.0, 4.0); else glOrtho ((-4.0*GLdouble (w)/GLdouble (h)), GLdouble (4.0*GLdouble (w)/GLdouble (h)), -4.0, 4.0, -4.0, 4.0); end if; glMatrixMode (GL_MODELVIEW); glLoadIdentity; glRotatef (85.0, 1.0, 1.0, 1.0); end ReshapeCallback; end Texturesurf_Procs;
reznikmm/matreshka
Ada
4,934
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with AMF.Internals.UML_Elements; with AMF.Standard_Profile_L2.Processes; with AMF.UML.Components; with AMF.Visitors; package AMF.Internals.Standard_Profile_L2_Processes is type Standard_Profile_L2_Process_Proxy is limited new AMF.Internals.UML_Elements.UML_Element_Base and AMF.Standard_Profile_L2.Processes.Standard_Profile_L2_Process with null record; overriding function Get_Base_Component (Self : not null access constant Standard_Profile_L2_Process_Proxy) return AMF.UML.Components.UML_Component_Access; -- Getter of Process::base_Component. -- overriding procedure Set_Base_Component (Self : not null access Standard_Profile_L2_Process_Proxy; To : AMF.UML.Components.UML_Component_Access); -- Setter of Process::base_Component. -- overriding procedure Enter_Element (Self : not null access constant Standard_Profile_L2_Process_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); overriding procedure Leave_Element (Self : not null access constant Standard_Profile_L2_Process_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); overriding procedure Visit_Element (Self : not null access constant Standard_Profile_L2_Process_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); end AMF.Internals.Standard_Profile_L2_Processes;
MinimSecure/unum-sdk
Ada
1,126
adb
-- Copyright 2008-2019 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. with Pck; use Pck; procedure Foo is type Table is array (Integer range <>) of Integer; type Matrix is array (1 .. 10, 1 .. 0) of Character; type Wrapper is record M : Matrix; end record; My_Table : Table (Ident (10) .. Ident (1)); My_Matrix : Wrapper := (M => (others => (others => 'a'))); begin Do_Nothing (My_Table'Address); -- START Do_Nothing (My_Matrix'Address); end Foo;
zhmu/ananas
Ada
171
adb
-- { dg-do compile } procedure Enum5 is package Pack1 is type Enum is (A, B, C); end; E1 : Pack1.Enum; use all type Pack1.Enum; begin E1 := A; end;
riccardo-bernardini/eugen
Ada
533
ads
with EU_Projects.Projects; package Project_Processor.Processors.Dumping is type Processor_Type is new Abstract_Processor with private; overriding function Create (Params : not null access Processor_Parameter) return Processor_Type; overriding procedure Process (Processor : Processor_Type; Input : EU_Projects.Projects.Project_Descriptor); private type Processor_Type is new Abstract_Processor with null record; end Project_Processor.Processors.Dumping;
reznikmm/matreshka
Ada
20,628
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with AMF.Internals.UML_Named_Elements; with AMF.String_Collections; with AMF.UML.Classifiers.Collections; with AMF.UML.Constraints.Collections; with AMF.UML.Dependencies.Collections; with AMF.UML.Element_Imports.Collections; with AMF.UML.Named_Elements.Collections; with AMF.UML.Namespaces; with AMF.UML.Package_Imports.Collections; with AMF.UML.Packageable_Elements.Collections; with AMF.UML.Packages.Collections; with AMF.UML.Redefinable_Elements.Collections; with AMF.UML.Regions; with AMF.UML.State_Machines; with AMF.UML.States; with AMF.UML.String_Expressions; with AMF.UML.Transitions.Collections; with AMF.UML.Vertexs.Collections; with AMF.Visitors; package AMF.Internals.UML_Regions is type UML_Region_Proxy is limited new AMF.Internals.UML_Named_Elements.UML_Named_Element_Proxy and AMF.UML.Regions.UML_Region with null record; overriding function Get_Extended_Region (Self : not null access constant UML_Region_Proxy) return AMF.UML.Regions.UML_Region_Access; -- Getter of Region::extendedRegion. -- -- The region of which this region is an extension. overriding procedure Set_Extended_Region (Self : not null access UML_Region_Proxy; To : AMF.UML.Regions.UML_Region_Access); -- Setter of Region::extendedRegion. -- -- The region of which this region is an extension. overriding function Get_Redefinition_Context (Self : not null access constant UML_Region_Proxy) return AMF.UML.Classifiers.UML_Classifier_Access; -- Getter of Region::redefinitionContext. -- -- References the classifier in which context this element may be -- redefined. overriding function Get_State (Self : not null access constant UML_Region_Proxy) return AMF.UML.States.UML_State_Access; -- Getter of Region::state. -- -- The State that owns the Region. If a Region is owned by a State, then -- it cannot also be owned by a StateMachine. overriding procedure Set_State (Self : not null access UML_Region_Proxy; To : AMF.UML.States.UML_State_Access); -- Setter of Region::state. -- -- The State that owns the Region. If a Region is owned by a State, then -- it cannot also be owned by a StateMachine. overriding function Get_State_Machine (Self : not null access constant UML_Region_Proxy) return AMF.UML.State_Machines.UML_State_Machine_Access; -- Getter of Region::stateMachine. -- -- The StateMachine that owns the Region. If a Region is owned by a -- StateMachine, then it cannot also be owned by a State. overriding procedure Set_State_Machine (Self : not null access UML_Region_Proxy; To : AMF.UML.State_Machines.UML_State_Machine_Access); -- Setter of Region::stateMachine. -- -- The StateMachine that owns the Region. If a Region is owned by a -- StateMachine, then it cannot also be owned by a State. overriding function Get_Subvertex (Self : not null access constant UML_Region_Proxy) return AMF.UML.Vertexs.Collections.Set_Of_UML_Vertex; -- Getter of Region::subvertex. -- -- The set of vertices that are owned by this region. overriding function Get_Transition (Self : not null access constant UML_Region_Proxy) return AMF.UML.Transitions.Collections.Set_Of_UML_Transition; -- Getter of Region::transition. -- -- The set of transitions owned by the region. overriding function Get_Element_Import (Self : not null access constant UML_Region_Proxy) return AMF.UML.Element_Imports.Collections.Set_Of_UML_Element_Import; -- Getter of Namespace::elementImport. -- -- References the ElementImports owned by the Namespace. overriding function Get_Imported_Member (Self : not null access constant UML_Region_Proxy) return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element; -- Getter of Namespace::importedMember. -- -- References the PackageableElements that are members of this Namespace -- as a result of either PackageImports or ElementImports. overriding function Get_Member (Self : not null access constant UML_Region_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element; -- Getter of Namespace::member. -- -- A collection of NamedElements identifiable within the Namespace, either -- by being owned or by being introduced by importing or inheritance. overriding function Get_Owned_Member (Self : not null access constant UML_Region_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element; -- Getter of Namespace::ownedMember. -- -- A collection of NamedElements owned by the Namespace. overriding function Get_Owned_Rule (Self : not null access constant UML_Region_Proxy) return AMF.UML.Constraints.Collections.Set_Of_UML_Constraint; -- Getter of Namespace::ownedRule. -- -- Specifies a set of Constraints owned by this Namespace. overriding function Get_Package_Import (Self : not null access constant UML_Region_Proxy) return AMF.UML.Package_Imports.Collections.Set_Of_UML_Package_Import; -- Getter of Namespace::packageImport. -- -- References the PackageImports owned by the Namespace. overriding function Get_Client_Dependency (Self : not null access constant UML_Region_Proxy) return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency; -- Getter of NamedElement::clientDependency. -- -- Indicates the dependencies that reference the client. overriding function Get_Name_Expression (Self : not null access constant UML_Region_Proxy) return AMF.UML.String_Expressions.UML_String_Expression_Access; -- Getter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding procedure Set_Name_Expression (Self : not null access UML_Region_Proxy; To : AMF.UML.String_Expressions.UML_String_Expression_Access); -- Setter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding function Get_Namespace (Self : not null access constant UML_Region_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Getter of NamedElement::namespace. -- -- Specifies the namespace that owns the NamedElement. overriding function Get_Qualified_Name (Self : not null access constant UML_Region_Proxy) return AMF.Optional_String; -- Getter of NamedElement::qualifiedName. -- -- A name which allows the NamedElement to be identified within a -- hierarchy of nested Namespaces. It is constructed from the names of the -- containing namespaces starting at the root of the hierarchy and ending -- with the name of the NamedElement itself. overriding function Get_Is_Leaf (Self : not null access constant UML_Region_Proxy) return Boolean; -- Getter of RedefinableElement::isLeaf. -- -- Indicates whether it is possible to further redefine a -- RedefinableElement. If the value is true, then it is not possible to -- further redefine the RedefinableElement. Note that this property is -- preserved through package merge operations; that is, the capability to -- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in -- the resulting RedefinableElement of a package merge operation where a -- RedefinableElement with isLeaf=false is merged with a matching -- RedefinableElement with isLeaf=true: the resulting RedefinableElement -- will have isLeaf=false. Default value is false. overriding procedure Set_Is_Leaf (Self : not null access UML_Region_Proxy; To : Boolean); -- Setter of RedefinableElement::isLeaf. -- -- Indicates whether it is possible to further redefine a -- RedefinableElement. If the value is true, then it is not possible to -- further redefine the RedefinableElement. Note that this property is -- preserved through package merge operations; that is, the capability to -- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in -- the resulting RedefinableElement of a package merge operation where a -- RedefinableElement with isLeaf=false is merged with a matching -- RedefinableElement with isLeaf=true: the resulting RedefinableElement -- will have isLeaf=false. Default value is false. overriding function Get_Redefined_Element (Self : not null access constant UML_Region_Proxy) return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element; -- Getter of RedefinableElement::redefinedElement. -- -- The redefinable element that is being redefined by this element. overriding function Get_Redefinition_Context (Self : not null access constant UML_Region_Proxy) return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier; -- Getter of RedefinableElement::redefinitionContext. -- -- References the contexts that this element may be redefined from. overriding function Belongs_To_PSM (Self : not null access constant UML_Region_Proxy) return Boolean; -- Operation Region::belongsToPSM. -- -- The operation belongsToPSM () checks if the region belongs to a -- protocol state machine overriding function Containing_State_Machine (Self : not null access constant UML_Region_Proxy) return AMF.UML.State_Machines.UML_State_Machine_Access; -- Operation Region::containingStateMachine. -- -- The operation containingStateMachine() returns the sate machine in -- which this Region is defined overriding function Is_Consistent_With (Self : not null access constant UML_Region_Proxy; Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access) return Boolean; -- Operation Region::isConsistentWith. -- -- The query isConsistentWith() specifies that a redefining region is -- consistent with a redefined region provided that the redefining region -- is an extension of the redefined region, i.e. it adds vertices and -- transitions and it redefines states and transitions of the redefined -- region. overriding function Is_Redefinition_Context_Valid (Self : not null access constant UML_Region_Proxy; Redefined : AMF.UML.Regions.UML_Region_Access) return Boolean; -- Operation Region::isRedefinitionContextValid. -- -- The query isRedefinitionContextValid() specifies whether the -- redefinition contexts of a region are properly related to the -- redefinition contexts of the specified region to allow this element to -- redefine the other. The containing statemachine/state of a redefining -- region must redefine the containing statemachine/state of the redefined -- region. overriding function Redefinition_Context (Self : not null access constant UML_Region_Proxy) return AMF.UML.Classifiers.UML_Classifier_Access; -- Operation Region::redefinitionContext. -- -- The redefinition context of a region is the nearest containing -- statemachine overriding function Exclude_Collisions (Self : not null access constant UML_Region_Proxy; Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element) return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element; -- Operation Namespace::excludeCollisions. -- -- The query excludeCollisions() excludes from a set of -- PackageableElements any that would not be distinguishable from each -- other in this namespace. overriding function Get_Names_Of_Member (Self : not null access constant UML_Region_Proxy; Element : AMF.UML.Named_Elements.UML_Named_Element_Access) return AMF.String_Collections.Set_Of_String; -- Operation Namespace::getNamesOfMember. -- -- The query getNamesOfMember() takes importing into account. It gives -- back the set of names that an element would have in an importing -- namespace, either because it is owned, or if not owned then imported -- individually, or if not individually then from a package. -- The query getNamesOfMember() gives a set of all of the names that a -- member would have in a Namespace. In general a member can have multiple -- names in a Namespace if it is imported more than once with different -- aliases. The query takes account of importing. It gives back the set of -- names that an element would have in an importing namespace, either -- because it is owned, or if not owned then imported individually, or if -- not individually then from a package. overriding function Import_Members (Self : not null access constant UML_Region_Proxy; Imps : AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element) return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element; -- Operation Namespace::importMembers. -- -- The query importMembers() defines which of a set of PackageableElements -- are actually imported into the namespace. This excludes hidden ones, -- i.e., those which have names that conflict with names of owned members, -- and also excludes elements which would have the same name when imported. overriding function Imported_Member (Self : not null access constant UML_Region_Proxy) return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element; -- Operation Namespace::importedMember. -- -- The importedMember property is derived from the ElementImports and the -- PackageImports. References the PackageableElements that are members of -- this Namespace as a result of either PackageImports or ElementImports. overriding function Members_Are_Distinguishable (Self : not null access constant UML_Region_Proxy) return Boolean; -- Operation Namespace::membersAreDistinguishable. -- -- The Boolean query membersAreDistinguishable() determines whether all of -- the namespace's members are distinguishable within it. overriding function Owned_Member (Self : not null access constant UML_Region_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element; -- Operation Namespace::ownedMember. -- -- Missing derivation for Namespace::/ownedMember : NamedElement overriding function All_Owning_Packages (Self : not null access constant UML_Region_Proxy) return AMF.UML.Packages.Collections.Set_Of_UML_Package; -- Operation NamedElement::allOwningPackages. -- -- The query allOwningPackages() returns all the directly or indirectly -- owning packages. overriding function Is_Distinguishable_From (Self : not null access constant UML_Region_Proxy; N : AMF.UML.Named_Elements.UML_Named_Element_Access; Ns : AMF.UML.Namespaces.UML_Namespace_Access) return Boolean; -- Operation NamedElement::isDistinguishableFrom. -- -- The query isDistinguishableFrom() determines whether two NamedElements -- may logically co-exist within a Namespace. By default, two named -- elements are distinguishable if (a) they have unrelated types or (b) -- they have related types but different names. overriding function Namespace (Self : not null access constant UML_Region_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Operation NamedElement::namespace. -- -- Missing derivation for NamedElement::/namespace : Namespace overriding function Is_Redefinition_Context_Valid (Self : not null access constant UML_Region_Proxy; Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access) return Boolean; -- Operation RedefinableElement::isRedefinitionContextValid. -- -- The query isRedefinitionContextValid() specifies whether the -- redefinition contexts of this RedefinableElement are properly related -- to the redefinition contexts of the specified RedefinableElement to -- allow this element to redefine the other. By default at least one of -- the redefinition contexts of this element must be a specialization of -- at least one of the redefinition contexts of the specified element. overriding procedure Enter_Element (Self : not null access constant UML_Region_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Leave_Element (Self : not null access constant UML_Region_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Visit_Element (Self : not null access constant UML_Region_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of iterator interface. end AMF.Internals.UML_Regions;
zhmu/ananas
Ada
1,228
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . F L O A T _ T E X T _ I O -- -- -- -- S p e c -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- -- copy and modify this specification, provided that if you redistribute a -- -- modified version, any changes that you have made are clearly indicated. -- -- -- ------------------------------------------------------------------------------ with Ada.Text_IO; pragma Elaborate_All (Ada.Text_IO); package Ada.Float_Text_IO is new Ada.Text_IO.Float_IO (Float);
fnarenji/BoiteMaker
Ada
802
ads
package point is -- exception en cas de coordonnées invalides invalid_pos : exception; type point_t is record x, y : float := 0.0; end record; -- Bouge le point sur l'axe x procedure mv_x(point : in out point_t; delta_x : float); -- Bouge le point sur l'axe y procedure mv_y(point : in out point_t; delta_y : float); -- Pointeur de fonction vers une fonction de mv_* type mv_point_ptr is access procedure (point : in out point_t; delta_axis : float); -- Constantes pour les pointeurs de fonctions mv_x_ptr : constant mv_point_ptr := mv_x'access; mv_y_ptr : constant mv_point_ptr := mv_y'access; -- Représentation en texte du point function to_string(point : point_t) return string; private end point;
reznikmm/matreshka
Ada
4,865
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Visitors; with ODF.DOM.Presentation_Event_Listener_Elements; package Matreshka.ODF_Presentation.Event_Listener_Elements is type Presentation_Event_Listener_Element_Node is new Matreshka.ODF_Presentation.Abstract_Presentation_Element_Node and ODF.DOM.Presentation_Event_Listener_Elements.ODF_Presentation_Event_Listener with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Presentation_Event_Listener_Element_Node; overriding function Get_Local_Name (Self : not null access constant Presentation_Event_Listener_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Presentation_Event_Listener_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Leave_Node (Self : not null access Presentation_Event_Listener_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Visit_Node (Self : not null access Presentation_Event_Listener_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); end Matreshka.ODF_Presentation.Event_Listener_Elements;
AdaCore/libadalang
Ada
581
ads
package Pkg is type Enum_1 is (A, B, C); --% [l.p_enum_rep for l in node.findall(lal.EnumLiteralDecl)] type Enum_2 is (A, B, C); --% [l.p_enum_rep for l in node.findall(lal.EnumLiteralDecl)] for Enum_2 use (10, 20, 30); type Enum_3 is (A, B, C); --% [l.p_enum_rep for l in node.findall(lal.EnumLiteralDecl)] for Enum_3 use (A => -30, B => -20, C => -10); type Enum_4 is (A, B, C); --% [l.p_enum_rep for l in node.findall(lal.EnumLiteralDecl)] for Enum_4 use (10 ** 40, 10 ** 40 + 1, 10 ** 40 + 2); end Pkg;
reznikmm/matreshka
Ada
3,979
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Style_Family_Attributes; package Matreshka.ODF_Style.Family_Attributes is type Style_Family_Attribute_Node is new Matreshka.ODF_Style.Abstract_Style_Attribute_Node and ODF.DOM.Style_Family_Attributes.ODF_Style_Family_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Family_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Style_Family_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Style.Family_Attributes;
stcarrez/ada-el
Ada
3,544
adb
----------------------------------------------------------------------- -- Action_Bean - Simple bean with methods that can be called from EL -- Copyright (C) 2010, 2011, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body Action_Bean is -- ------------------------------ -- Get the value identified by the name. -- ------------------------------ overriding function Get_Value (From : Action; Name : String) return EL.Objects.Object is begin if Name = "count" then return EL.Objects.To_Object (From.Count); end if; return From.Person.Get_Value (Name); end Get_Value; -- ------------------------------ -- Set the value identified by the name. -- ------------------------------ overriding procedure Set_Value (From : in out Action; Name : in String; Value : in EL.Objects.Object) is begin From.Person.Set_Value (Name, Value); end Set_Value; -- ------------------------------ -- Action with one parameter. -- Sets the person. -- ------------------------------ procedure Notify (Target : in out Action; Param : in out Test_Bean.Person) is begin Target.Person := Param; end Notify; -- ------------------------------ -- Action with two parameters. -- Sets the person object and the counter. -- ------------------------------ procedure Notify (Target : in out Action; Param : in Test_Bean.Person; Count : in Natural) is begin Target.Person := Param; Target.Count := Count; end Notify; -- ------------------------------ -- Action with one parameter -- ------------------------------ procedure Print (Target : in out Action; Param : in out Test_Bean.Person) is begin Target.Person := Param; end Print; package Notify_Binding is new Proc_Action.Bind (Bean => Action, Method => Notify, Name => "notify"); package Notify_Count_Binding is new Proc2_Action.Bind (Bean => Action, Method => Notify, Name => "notify2"); package Print_Binding is new Proc_Action.Bind (Bean => Action, Method => Print, Name => "print"); Binding_Array : aliased constant Util.Beans.Methods.Method_Binding_Array := (Notify_Binding.Proxy'Access, Print_Binding.Proxy'Access, Notify_Count_Binding.Proxy'Access); -- ------------------------------ -- Get the EL method bindings exposed by the Action type. -- ------------------------------ overriding function Get_Method_Bindings (From : in Action) return Util.Beans.Methods.Method_Binding_Array_Access is pragma Unreferenced (From); begin return Binding_Array'Access; end Get_Method_Bindings; end Action_Bean;
bracke/Ext2Dir
Ada
117
adb
-- StrongEd$WrapWidth=256 -- StrongEd$Mode=Ada -- with Main; procedure Ext2Dir is begin Main.Main; end Ext2Dir;
reznikmm/matreshka
Ada
3,733
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.UMLDI.Holders.UML_Interaction_Diagram_Kinds is new League.Holders.Generic_Enumerations (AMF.UMLDI.UMLDI_UML_Interaction_Diagram_Kind); pragma Preelaborate (AMF.UMLDI.Holders.UML_Interaction_Diagram_Kinds);
nerilex/ada-util
Ada
3,447
ads
----------------------------------------------------------------------- -- Util.Beans.Basic.Lists -- List bean given access to a vector -- Copyright (C) 2011, 2012 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Finalization; with Ada.Containers; with Ada.Containers.Vectors; with Util.Beans.Objects; -- The <b>Util.Beans.Basic.Lists</b> generic package implements a list of -- elements that can be accessed through the <b>List_Bean</b> interface. generic type Element_Type is new Util.Beans.Basic.Readonly_Bean with private; package Util.Beans.Basic.Lists is -- Package that represents the vectors of elements. -- (gcc 4.4 crashes if this package is defined as generic parameter. package Vectors is new Ada.Containers.Vectors (Element_Type => Element_Type, Index_Type => Natural); -- The list of elements is defined in a public part so that applications -- can easily add or remove elements in the target list. The <b>List_Bean</b> -- type holds the real implementation with the private parts. type Abstract_List_Bean is abstract new Ada.Finalization.Controlled and Util.Beans.Basic.List_Bean with record List : aliased Vectors.Vector; end record; -- ------------------------------ -- List of objects -- ------------------------------ -- The <b>List_Bean</b> type gives access to a list of objects. type List_Bean is new Abstract_List_Bean with private; type List_Bean_Access is access all List_Bean'Class; -- Get the number of elements in the list. overriding function Get_Count (From : in List_Bean) return Natural; -- Set the current row index. Valid row indexes start at 1. overriding procedure Set_Row_Index (From : in out List_Bean; Index : in Natural); -- Returns the current row index. function Get_Row_Index (From : in List_Bean) return Natural; -- Get the element at the current row index. overriding function Get_Row (From : in List_Bean) return Util.Beans.Objects.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_Bean; Name : in String) return Util.Beans.Objects.Object; -- Initialize the list bean. overriding procedure Initialize (Object : in out List_Bean); -- Deletes the list bean procedure Free (List : in out Util.Beans.Basic.Readonly_Bean_Access); private type List_Bean is new Abstract_List_Bean with record Current : aliased Element_Type; Current_Index : Natural := 0; Row : Util.Beans.Objects.Object; end record; end Util.Beans.Basic.Lists;
stcarrez/ada-ado
Ada
9,567
ads
----------------------------------------------------------------------- -- ADO Postgresql statements -- Postgresql query statements -- Copyright (C) 2018, 2019, 2021, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with ADO.SQL; with ADO.Schemas; with PQ; package ADO.Statements.Postgresql is -- ------------------------------ -- Delete statement -- ------------------------------ type Postgresql_Delete_Statement is new Delete_Statement with private; type Postgresql_Delete_Statement_Access is access all Postgresql_Delete_Statement'Class; -- Execute the query overriding procedure Execute (Stmt : in out Postgresql_Delete_Statement; Result : out Natural); -- Create the delete statement function Create_Statement (Database : in PQ.PGconn_Access; Table : in ADO.Schemas.Class_Mapping_Access) return Delete_Statement_Access; -- ------------------------------ -- Update statement -- ------------------------------ type Postgresql_Update_Statement is new Update_Statement with private; type Postgresql_Update_Statement_Access is access all Postgresql_Update_Statement'Class; -- Execute the query overriding procedure Execute (Stmt : in out Postgresql_Update_Statement); -- Execute the query overriding procedure Execute (Stmt : in out Postgresql_Update_Statement; Result : out Integer); -- Create an update statement. function Create_Statement (Database : in PQ.PGconn_Access; Table : in ADO.Schemas.Class_Mapping_Access) return Update_Statement_Access; -- ------------------------------ -- Insert statement -- ------------------------------ type Postgresql_Insert_Statement is new Insert_Statement with private; type Postgresql_Insert_Statement_Access is access all Postgresql_Insert_Statement'Class; -- Execute the query overriding procedure Execute (Stmt : in out Postgresql_Insert_Statement; Result : out Integer); -- Create an insert statement. function Create_Statement (Database : in PQ.PGconn_Access; Table : in ADO.Schemas.Class_Mapping_Access) return Insert_Statement_Access; -- ------------------------------ -- Query statement for Postgresql -- ------------------------------ type Postgresql_Query_Statement is new Query_Statement with private; type Postgresql_Query_Statement_Access is access all Postgresql_Query_Statement'Class; -- Execute the query overriding procedure Execute (Stmt : in out Postgresql_Query_Statement); -- Get the number of rows returned by the query overriding function Get_Row_Count (Query : in Postgresql_Query_Statement) return Natural; -- Returns True if there is more data (row) to fetch overriding function Has_Elements (Query : in Postgresql_Query_Statement) return Boolean; -- Fetch the next row overriding procedure Next (Query : in out Postgresql_Query_Statement); -- Returns true if the column <b>Column</b> is null. overriding function Is_Null (Query : in Postgresql_Query_Statement; Column : in Natural) return Boolean; -- Get the column value at position <b>Column</b> and -- return it as an <b>Int64</b>. -- Raises <b>Invalid_Type</b> if the value cannot be converted. -- Raises <b>Invalid_Column</b> if the column does not exist. overriding function Get_Int64 (Query : Postgresql_Query_Statement; Column : Natural) return Int64; -- Get the column value at position <b>Column</b> and -- return it as an <b>Long_Float</b>. -- Raises <b>Invalid_Type</b> if the value cannot be converted. -- Raises <b>Invalid_Column</b> if the column does not exist. overriding function Get_Long_Float (Query : Postgresql_Query_Statement; Column : Natural) return Long_Float; -- Get the column value at position <b>Column</b> and -- return it as an <b>Boolean</b>. -- Raises <b>Invalid_Type</b> if the value cannot be converted. -- Raises <b>Invalid_Column</b> if the column does not exist. overriding function Get_Boolean (Query : Postgresql_Query_Statement; Column : Natural) return Boolean; -- Get the column value at position <b>Column</b> and -- return it as an <b>Unbounded_String</b>. -- Raises <b>Invalid_Type</b> if the value cannot be converted. -- Raises <b>Invalid_Column</b> if the column does not exist. overriding function Get_Unbounded_String (Query : Postgresql_Query_Statement; Column : Natural) return Unbounded_String; -- Get the column value at position <b>Column</b> and -- return it as an <b>Unbounded_String</b>. -- Raises <b>Invalid_Type</b> if the value cannot be converted. -- Raises <b>Invalid_Column</b> if the column does not exist. overriding function Get_String (Query : Postgresql_Query_Statement; Column : Natural) return String; -- Get the column value at position <b>Column</b> and -- return it as a <b>Blob</b> reference. overriding function Get_Blob (Query : in Postgresql_Query_Statement; Column : in Natural) return ADO.Blob_Ref; -- Get the column value at position <b>Column</b> and -- return it as an <b>Time</b>. -- Raises <b>Invalid_Type</b> if the value cannot be converted. -- Raises <b>Invalid_Column</b> if the column does not exist. overriding function Get_Time (Query : Postgresql_Query_Statement; Column : Natural) return Ada.Calendar.Time; -- Get the column type -- Raises <b>Invalid_Column</b> if the column does not exist. overriding function Get_Column_Type (Query : Postgresql_Query_Statement; Column : Natural) return ADO.Schemas.Column_Type; -- Get the column name. -- Raises <b>Invalid_Column</b> if the column does not exist. overriding function Get_Column_Name (Query : in Postgresql_Query_Statement; Column : in Natural) return String; -- Get the number of columns in the result. overriding function Get_Column_Count (Query : in Postgresql_Query_Statement) return Natural; overriding procedure Finalize (Query : in out Postgresql_Query_Statement); -- Create the query statement. function Create_Statement (Database : in PQ.PGconn_Access; Table : in ADO.Schemas.Class_Mapping_Access) return Query_Statement_Access; function Create_Statement (Database : in PQ.PGconn_Access; Query : in String) return Query_Statement_Access; private type State is (HAS_ROW, HAS_MORE, DONE, ERROR); type Postgresql_Query_Statement is new Query_Statement with record This_Query : aliased ADO.SQL.Query; Connection : PQ.PGconn_Access := PQ.Null_PGconn; Result : PQ.PGresult_Access := PQ.Null_PGresult; Row : Interfaces.C.int := 0; Row_Count : Interfaces.C.int := 0; Counter : Natural := 1; Status : State := DONE; Max_Column : Natural; end record; -- Get a column field address. -- If the query was not executed, raises Invalid_Statement -- If the column is out of bound, raises Constraint_Error function Get_Field (Query : Postgresql_Query_Statement'Class; Column : Natural) return chars_ptr; -- Get a column field length. -- If the query was not executed, raises Invalid_Statement -- If the column is out of bound, raises Constraint_Error -- ------------------------------ function Get_Field_Length (Query : in Postgresql_Query_Statement'Class; Column : in Natural) return Natural; type Postgresql_Delete_Statement is new Delete_Statement with record Connection : PQ.PGconn_Access; Table : ADO.Schemas.Class_Mapping_Access; Delete_Query : aliased ADO.SQL.Query; end record; type Postgresql_Update_Statement is new Update_Statement with record Connection : PQ.PGconn_Access; This_Query : aliased ADO.SQL.Update_Query; Table : ADO.Schemas.Class_Mapping_Access; end record; type Postgresql_Insert_Statement is new Insert_Statement with record Connection : PQ.PGconn_Access; This_Query : aliased ADO.SQL.Update_Query; Table : ADO.Schemas.Class_Mapping_Access; end record; end ADO.Statements.Postgresql;
AdaCore/gpr
Ada
76
adb
package body My_Package_Body is Hello_� : Integer; end My_Package_Body;
sungyeon/drake
Ada
416
ads
pragma License (Unrestricted); -- extended unit package System.Storage_Elements.Formatting is -- The formatting functions Image and Value for System.Address. pragma Pure; subtype Address_String is String (1 .. (Standard'Address_Size + 3) / 4); function Image (Value : Address) return Address_String; function Value (Value : Address_String) return Address; end System.Storage_Elements.Formatting;
reznikmm/matreshka
Ada
3,789
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_Alphabetical_Index_Entry_Template_Elements is pragma Preelaborate; type ODF_Text_Alphabetical_Index_Entry_Template is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Text_Alphabetical_Index_Entry_Template_Access is access all ODF_Text_Alphabetical_Index_Entry_Template'Class with Storage_Size => 0; end ODF.DOM.Text_Alphabetical_Index_Entry_Template_Elements;
ekoeppen/MSP430_Generic_Ada_Drivers
Ada
4,060
adb
with System.Machine_Code; use System.Machine_Code; with System; use System; with Interfaces; use Interfaces; with MSP430_SVD; use MSP430_SVD; with Flash; with Board; package body Bootloader is Line : array (Unsigned_16 range 0 .. 47) of Unsigned_8; Write_Addr : Unsigned_16; Count : Unsigned_8; User_Vector_Address : constant Unsigned_16 := 16#FFBE#; Reset_Vector_Address : constant Unsigned_16 := 16#FFFE#; Bootloader_Address : constant Unsigned_16 := 16#FC00#; Vector_Segment_Address : constant Unsigned_16 := 16#FE00#; Flash_Segment_Size : constant Unsigned_16 := 512; package UART renames Board.UART; procedure Erase is Addr : Unsigned_16 := 16#C000#; Saved_Vector : Unsigned_16; Saved_Code : array (Unsigned_16 range 0 .. 127) of Unsigned_16; begin for I in Saved_Code'Range loop Saved_Code (I) := Flash.Read (I * 2 + Vector_Segment_Address); end loop; Saved_Vector := Flash.Read (Reset_Vector_Address); Flash.Unlock; Flash.Erase (Vector_Segment_Address); while Addr < Bootloader_Address loop Flash.Erase (Addr); Addr := Addr + Flash_Segment_Size; end loop; Flash.Enable_Write; Flash.Write (Reset_Vector_Address, Saved_Vector); for I in Saved_Code'Range loop Flash.Write (I * 2 + Vector_Segment_Address, Saved_Code (I)); end loop; Flash.Lock; end Erase; pragma Linker_Section (Erase, ".text.lower"); function Nibble (N : Unsigned_8) return Unsigned_8 is begin return (if N >= 65 then N - 65 + 10 else N - 48); end Nibble; function From_Hex (I : Unsigned_16) return Unsigned_8 is begin return 16 * Nibble (Line (I)) + Nibble (Line (I + 1)); end From_Hex; procedure Write is Value : Unsigned_16; J : Unsigned_16; begin Flash.Unlock; Flash.Enable_Write; J := 9; for I in Unsigned_16 range 1 .. Unsigned_16 (Count) / 2 loop Value := Unsigned_16 (From_Hex (J)) + 256 * Unsigned_16 (From_Hex (J + 2)); if Write_Addr = Reset_Vector_Address then Flash.Write (User_Vector_Address, Value); else Flash.Write (Write_Addr, Value); end if; J := J + 4; Write_Addr := Write_Addr + Unsigned_16 (2); end loop; Flash.Lock; end Write; procedure Read_Lines is Record_Type : Unsigned_8; XON : constant Byte := 17; XOFF : constant Byte := 19; begin loop UART.Transmit (XON); for I in Line'Range loop Line (I) := Unsigned_8 (UART.Receive); exit when Line (I) = 10; end loop; UART.Transmit (XOFF); Count := From_Hex (1); Write_Addr := Unsigned_16 (From_Hex (3)) * 256 + Unsigned_16 (From_Hex (5)); Record_Type := From_Hex (7); case Record_Type is when 16#00# => Write; when 16#80# => Flash.Erase (Write_Addr); when others => null; end case; end loop; end Read_Lines; procedure Start is begin Board.Init; UART.Transmit (Character'Pos ('?')); for J in 1 .. 12 loop for I in 0 .. Unsigned_16'Last loop if UART.Data_Available and then UART.Receive = Character'Pos ('f') then while UART.Data_Available loop UART.Transmit (UART.Receive); end loop; Flash.Init; Erase; Read_Lines; end if; end loop; end loop; if Flash.Read (User_Vector_Address) /= 16#FFFF# then Asm ("mov #0xffbe, r8", Volatile => True); Asm ("mov.b #0x60, &0x56", Volatile => True); Asm ("mov.b #0x87, &0x57", Volatile => True); Asm ("mov #0x5a00, &0x120", Volatile => True); Asm ("br 0(r8)", Volatile => True); end if; end Start; procedure Start_1 is begin Board.Init; Flash.Init; Erase; Read_Lines; loop null; end loop; end Start_1; end Bootloader;
persan/a-vulkan
Ada
5,860
ads
pragma Ada_2012; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; with Vulkan.Low_Level.vulkan_core_h; with Interfaces.C.Strings; with System; with Interfaces.C.Extensions; package Vulkan.Low_Level.vk_icd_h is CURRENT_LOADER_ICD_INTERFACE_VERSION : constant := 5; -- vk_icd.h:44 MIN_SUPPORTED_LOADER_ICD_INTERFACE_VERSION : constant := 0; -- vk_icd.h:45 MIN_PHYS_DEV_EXTENSION_ICD_INTERFACE_VERSION : constant := 4; -- vk_icd.h:46 ICD_LOADER_MAGIC : constant := 16#01CDC0DE#; -- vk_icd.h:61 -- File: vk_icd.h -- * Copyright (c) 2015-2016 The Khronos Group Inc. -- * Copyright (c) 2015-2016 Valve Corporation -- * Copyright (c) 2015-2016 LunarG, Inc. -- * -- * 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. -- * -- -- Loader-ICD version negotiation API. Versions add the following features: -- Version 0 - Initial. Doesn't support vk_icdGetInstanceProcAddr -- or vk_icdNegotiateLoaderICDInterfaceVersion. -- Version 1 - Add support for vk_icdGetInstanceProcAddr. -- Version 2 - Add Loader/ICD Interface version negotiation -- via vk_icdNegotiateLoaderICDInterfaceVersion. -- Version 3 - Add ICD creation/destruction of KHR_surface objects. -- Version 4 - Add unknown physical device extension qyering via -- vk_icdGetPhysicalDeviceProcAddr. -- Version 5 - Tells ICDs that the loader is now paying attention to the -- application version of Vulkan passed into the ApplicationInfo -- structure during vkCreateInstance. This will tell the ICD -- that if the loader is older, it should automatically fail a -- call for any API version > 1.0. Otherwise, the loader will -- manually determine if it can support the expected version. type PFN_vkNegotiateLoaderICDInterfaceVersion is access function (arg1 : access Interfaces.C.unsigned_short) return Vulkan.Low_Level.vulkan_core_h.VkResult with Convention => C; -- vk_icd.h:47 -- This is defined in vk_layer.h which will be found by the loader, but if an ICD is building against this -- file directly, it won't be found. type PFN_GetPhysicalDeviceProcAddr is access function (arg1 : Vulkan.Low_Level.vulkan_core_h.VkInstance; arg2 : Interfaces.C.Strings.chars_ptr) return Vulkan.Low_Level.vulkan_core_h.PFN_vkVoidFunction with Convention => C; -- vk_icd.h:52 -- * The ICD must reserve space for a pointer for the loader's dispatch -- * table, at the start of <each object>. -- * The ICD must initialize this variable using the SET_LOADER_MAGIC_VALUE macro. -- -- skipped anonymous struct anon_2 type VK_LOADER_DATA (discr : unsigned := 0) is record case discr is when 0 => loaderMagic : aliased access Interfaces.C.unsigned; -- vk_icd.h:64 when others => loaderData : System.Address; -- vk_icd.h:65 end case; end record with Convention => C_Pass_By_Copy, Unchecked_Union => True; -- vk_icd.h:66 procedure set_loader_magic_value (pNewObject : System.Address) -- vk_icd.h:68 with Import => True, Convention => CPP, External_Name => "_ZL22set_loader_magic_valuePv"; function valid_loader_magic_value (pNewObject : System.Address) return Extensions.bool -- vk_icd.h:73 with Import => True, Convention => CPP, External_Name => "_ZL24valid_loader_magic_valuePv"; -- * Windows and Linux ICDs will treat VkSurfaceKHR as a pointer to a struct that -- * contains the platform-specific connection and surface information. -- type VkIcdWsiPlatform is (VK_ICD_WSI_PLATFORM_MIR, VK_ICD_WSI_PLATFORM_WAYLAND, VK_ICD_WSI_PLATFORM_WIN32, VK_ICD_WSI_PLATFORM_XCB, VK_ICD_WSI_PLATFORM_XLIB, VK_ICD_WSI_PLATFORM_ANDROID, VK_ICD_WSI_PLATFORM_MACOS, VK_ICD_WSI_PLATFORM_IOS, VK_ICD_WSI_PLATFORM_DISPLAY, VK_ICD_WSI_PLATFORM_HEADLESS, VK_ICD_WSI_PLATFORM_METAL) with Convention => C; -- vk_icd.h:94 -- skipped anonymous struct anon_4 type VkIcdSurfaceBase is record platform : aliased VkIcdWsiPlatform; -- vk_icd.h:97 end record with Convention => C_Pass_By_Copy; -- vk_icd.h:98 -- skipped anonymous struct anon_5 type VkIcdSurfaceDisplay is record base : aliased VkIcdSurfaceBase; -- vk_icd.h:162 displayMode : Vulkan.Low_Level.vulkan_core_h.VkDisplayModeKHR; -- vk_icd.h:163 planeIndex : aliased Interfaces.C.unsigned_short; -- vk_icd.h:164 planeStackIndex : aliased Interfaces.C.unsigned_short; -- vk_icd.h:165 transform : aliased Vulkan.Low_Level.vulkan_core_h.VkSurfaceTransformFlagBitsKHR; -- vk_icd.h:166 globalAlpha : aliased float; -- vk_icd.h:167 alphaMode : aliased Vulkan.Low_Level.vulkan_core_h.VkDisplayPlaneAlphaFlagBitsKHR; -- vk_icd.h:168 imageExtent : aliased Vulkan.Low_Level.vulkan_core_h.VkExtent2D; -- vk_icd.h:169 end record with Convention => C_Pass_By_Copy; -- vk_icd.h:170 -- skipped anonymous struct anon_6 type VkIcdSurfaceHeadless is record base : aliased VkIcdSurfaceBase; -- vk_icd.h:173 end record with Convention => C_Pass_By_Copy; -- vk_icd.h:174 end Vulkan.Low_Level.vk_icd_h;
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.Realizations.Hash is new AMF.Elements.Generic_Hash (UML_Realization, UML_Realization_Access);
reznikmm/matreshka
Ada
6,153
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- 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$ ------------------------------------------------------------------------------ package body Matreshka.DOM_Processing_Instructions is ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Processing_Instruction_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin Visitor.Enter_Processing_Instruction (XML.DOM.Processing_Instructions.DOM_Processing_Instruction_Access (Self), Control); end Enter_Node; -------------- -- Get_Data -- -------------- overriding function Get_Data (Self : not null access constant Processing_Instruction_Node) return League.Strings.Universal_String is begin raise Program_Error; return League.Strings.Empty_Universal_String; end Get_Data; ------------------- -- Get_Node_Type -- ------------------- overriding function Get_Node_Type (Self : not null access constant Processing_Instruction_Node) return XML.DOM.Node_Type is pragma Unreferenced (Self); begin return XML.DOM.Processing_Instruction_Node; end Get_Node_Type; ---------------- -- Get_Target -- ---------------- overriding function Get_Target (Self : not null access constant Processing_Instruction_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin raise Program_Error; return League.Strings.Empty_Universal_String; end Get_Target; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Processing_Instruction_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin Visitor.Leave_Processing_Instruction (XML.DOM.Processing_Instructions.DOM_Processing_Instruction_Access (Self), Control); end Leave_Node; -------------- -- Set_Data -- -------------- overriding procedure Set_Data (Self : not null access Processing_Instruction_Node; New_Data : League.Strings.Universal_String) is begin raise Program_Error; end Set_Data; ---------------- -- Visit_Node -- ---------------- overriding procedure Visit_Node (Self : not null access Processing_Instruction_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 Iterator.Visit_Processing_Instruction (Visitor, XML.DOM.Processing_Instructions.DOM_Processing_Instruction_Access (Self), Control); end Visit_Node; end Matreshka.DOM_Processing_Instructions;
AaronC98/PlaneSystem
Ada
7,902
adb
------------------------------------------------------------------------------ -- Ada Web Server -- -- -- -- Copyright (C) 2000-2014, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 3, or (at your option) any -- -- later version. This library is distributed in the hope that it will be -- -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ------------------------------------------------------------------------------ pragma Ada_2012; with Ada.Real_Time; with Ada.Streams; with Ada.Strings.Maps.Constants; with Ada.Unchecked_Conversion; with AWS.Translator; with AWS.Utils; package body AWS.Digest is use Ada; use Ada.Streams; use GNAT; Private_Key : MD5.Context; type Modular24_Bits is mod 2 ** 24; for Modular24_Bits'Size use 24; Nonce_Idx : Modular24_Bits := Modular24_Bits'Mod (Utils.Random) with Atomic; subtype Timestamp_String is String (1 .. 4); -- The timestamp string is a 24 bits Base64 encoded value subtype Index_String is String (1 .. 4); -- The Nonce string is a 24 bits Base64 encoded value Nonce_Expiration : constant := 300; -- Expiration expressed in seconds subtype Byte_Array_Of_Modular24 is Stream_Element_Array (1 .. Modular24_Bits'Size / Stream_Element_Array'Component_Size); subtype Byte_Array_Of_Seconds is Stream_Element_Array (1 .. Real_Time.Seconds_Count'Size / Stream_Element_Array'Component_Size); function To_Byte_Array is new Ada.Unchecked_Conversion (Real_Time.Seconds_Count, Byte_Array_Of_Seconds); function To_Byte_Array is new Ada.Unchecked_Conversion (Modular24_Bits, Byte_Array_Of_Modular24); function To_Modular24 is new Ada.Unchecked_Conversion (Byte_Array_Of_Modular24, Modular24_Bits); ----------------- -- Check_Nonce -- ----------------- function Check_Nonce (Value : String) return Boolean is use Real_Time; subtype Timestamp_Range is Positive range Value'First .. Value'First + Timestamp_String'Length - 1; subtype Index_Range is Positive range Timestamp_Range'Last + 1 .. Timestamp_Range'Last + Index_String'Length; subtype Digest_Range is Positive range Index_Range'Last + 1 .. Index_Range'Last + MD5.Message_Digest'Length; Time_Dif : Modular24_Bits; Seconds_Now : Seconds_Count; TS : Time_Span; Index_Nonce : Index_String; Seconds_Array : Byte_Array_Of_Modular24; Seconds_Nonce : Modular24_Bits; Ctx : MD5.Context; Sample : Digest_String; begin if Value'Length /= Nonce'Length then return False; end if; -- Check that we have only base64 digits in the timestamp and index -- and hex in the digest. declare use Ada.Strings.Maps; Base64_Set : constant Character_Set := To_Set (Character_Range'(Low => 'a', High => 'z')) or To_Set (Character_Range'(Low => 'A', High => 'Z')) or To_Set (Character_Range'(Low => '0', High => '9')) or To_Set ("+/"); begin if not Is_Subset (To_Set (Value (Timestamp_Range'First .. Index_Range'Last)), Base64_Set) or else not Is_Subset (To_Set (Value (Digest_Range)), Constants.Hexadecimal_Digit_Set) then return False; end if; end; Split (Clock, Seconds_Now, TS); Seconds_Array := Translator.Base64_Decode (Value (Timestamp_Range)); Seconds_Nonce := To_Modular24 (Seconds_Array); Index_Nonce := Value (Index_Range); Time_Dif := Modular24_Bits'Mod (Seconds_Now) - Seconds_Nonce; if Time_Dif > Nonce_Expiration then return False; end if; Ctx := Private_Key; MD5.Update (Ctx, To_Byte_Array (Seconds_Now - Seconds_Count (Time_Dif))); MD5.Update (Ctx, Index_Nonce); Sample := MD5.Digest (Ctx); return Value (Digest_Range) = Sample; end Check_Nonce; ------------ -- Create -- ------------ function Create (Username, Realm, Password : String; Nonce, NC, CNonce, QOP : String; Method, URI : String) return Digest_String is begin return MD5.Digest (MD5.Digest (Username & ':' & Realm & ':' & Password) & Tail (Nonce, NC, CNonce, QOP, Method, URI)); end Create; function Create (Username, Realm, Password : String; Nonce : String; Method, URI : String) return Digest_String is begin return Create (Username, Realm, Password, Nonce, "", "", "", Method, URI); end Create; ------------------ -- Create_Nonce -- ------------------ function Create_Nonce return Nonce is use Real_Time; Seconds_Now : Seconds_Count; TS : Time_Span; Timestamp_Str : Timestamp_String; Index_Str : Index_String; Ctx : MD5.Context; begin Split (Clock, Seconds_Now, TS); Ctx := Private_Key; Nonce_Idx := Nonce_Idx + 1; Index_Str := Translator.Base64_Encode (To_Byte_Array (Nonce_Idx)); Timestamp_Str := Translator.Base64_Encode (To_Byte_Array (Modular24_Bits'Mod (Seconds_Now))); MD5.Update (Ctx, To_Byte_Array (Seconds_Now)); MD5.Update (Ctx, Index_Str); -- The Nonce result is composed of three parts: -- Five Hex Digits : timestamp to check Nonce expiration -- Uniq index : to avoid generating the same Nonce twice -- MD5 digest : the Nonce main MD5 data return Nonce (Timestamp_Str & Index_Str & MD5.Digest (Ctx)); end Create_Nonce; ---------- -- Tail -- ---------- function Tail (Nonce, NC, CNonce, QOP, Method, URI : String) return String is begin return ':' & Nonce & (if QOP = "" then "" else ':' & NC & ':' & CNonce & ':' & QOP & ':') & MD5.Digest (Method & ':' & URI); end Tail; begin MD5.Update (Private_Key, Utils.Random_String (32)); end AWS.Digest;
sungyeon/drake
Ada
6,332
adb
pragma Check_Policy (Trace => Ignore); with Ada.Unchecked_Conversion; with System.Address_To_Named_Access_Conversions; with System.Shared_Locking; package body Ada.Tags.Delegating is pragma Suppress (All_Checks); use type System.Address; package Tag_Conv is new System.Address_To_Named_Access_Conversions (Dispatch_Table, Tag); package Tag_Ptr_Conv is new System.Address_To_Named_Access_Conversions (Tag, Tag_Ptr); type Delegate is access function (Object : System.Address) return System.Address; type I_Node; type I_Node_Access is access I_Node; type I_Node is record Left, Right : aliased I_Node_Access; Interface_Tag : Tag; Get : not null Delegate; end record; pragma Suppress_Initialization (I_Node); procedure I_Insert ( Node : aliased in out I_Node_Access; Interface_Tag : Tag; Get : not null Delegate); procedure I_Insert ( Node : aliased in out I_Node_Access; Interface_Tag : Tag; Get : not null Delegate) is function "+" (X : Tag) return System.Address renames Tag_Conv.To_Address; type I_Node_Access_Access is access all I_Node_Access; for I_Node_Access_Access'Storage_Size use 0; Current : not null I_Node_Access_Access := Node'Access; begin loop if Current.all = null then pragma Check (Trace, Debug.Put ("add")); Current.all := new I_Node'( Left => null, Right => null, Interface_Tag => Interface_Tag, Get => Get); exit; elsif +Current.all.Interface_Tag > +Interface_Tag then Current := Current.all.Left'Access; elsif +Current.all.Interface_Tag < +Interface_Tag then Current := Current.all.Right'Access; else exit; -- already added end if; end loop; end I_Insert; function I_Find (Node : I_Node_Access; Interface_Tag : Tag) return I_Node_Access; function I_Find (Node : I_Node_Access; Interface_Tag : Tag) return I_Node_Access is function "+" (X : Tag) return System.Address renames Tag_Conv.To_Address; Current : I_Node_Access := Node; begin while Current /= null loop if +Current.Interface_Tag > +Interface_Tag then Current := Current.Left; elsif +Current.Interface_Tag < +Interface_Tag then Current := Current.Right; else return Current; -- found end if; end loop; return null; -- not found end I_Find; type D_Node; type D_Node_Access is access D_Node; type D_Node is record Left, Right : aliased D_Node_Access; Object_Tag : Tag; Map : aliased I_Node_Access; end record; pragma Suppress_Initialization (D_Node); procedure D_Insert ( Node : aliased in out D_Node_Access; T : Tag; Result : out D_Node_Access); procedure D_Insert ( Node : aliased in out D_Node_Access; T : Tag; Result : out D_Node_Access) is function "+" (X : Tag) return System.Address renames Tag_Conv.To_Address; type D_Node_Access_Access is access all D_Node_Access; for D_Node_Access_Access'Storage_Size use 0; Current : not null D_Node_Access_Access := Node'Access; begin loop if Current.all = null then Current.all := new D_Node'( Left => null, Right => null, Object_Tag => T, Map => null); Result := Current.all; exit; elsif +Current.all.Object_Tag > +T then Current := Current.all.Left'Access; elsif +Current.all.Object_Tag < +T then Current := Current.all.Right'Access; else Result := Current.all; exit; -- already added end if; end loop; end D_Insert; function D_Find (Node : D_Node_Access; T : Tag) return D_Node_Access; function D_Find (Node : D_Node_Access; T : Tag) return D_Node_Access is function "+" (X : Tag) return System.Address renames Tag_Conv.To_Address; Current : D_Node_Access := Node; begin while Current /= null loop if +Current.Object_Tag > +T then Current := Current.Left; elsif +Current.Object_Tag < +T then Current := Current.Right; else return Current; -- found end if; end loop; return null; -- not found end D_Find; Delegating_Map : aliased D_Node_Access := null; function Get_Delegation (Object : System.Address; Interface_Tag : Tag) return System.Address; function Get_Delegation (Object : System.Address; Interface_Tag : Tag) return System.Address is Result : System.Address := System.Null_Address; T : Tag := Tag_Ptr_Conv.To_Pointer (Object).all; begin System.Shared_Locking.Enter; Search : loop declare D : constant D_Node_Access := D_Find (Delegating_Map, T); begin if D /= null then declare I : constant I_Node_Access := I_Find (D.Map, Interface_Tag); begin exit Search when I = null; Result := I.Get (Object); exit Search; end; end if; end; T := Parent_Tag (T); exit Search when T = No_Tag; end loop Search; System.Shared_Locking.Leave; return Result; end Get_Delegation; procedure Register_Delegation ( T : Tag; Interface_Tag : Tag; Get : not null Delegate); procedure Register_Delegation ( T : Tag; Interface_Tag : Tag; Get : not null Delegate) is D : D_Node_Access; begin System.Shared_Locking.Enter; D_Insert (Delegating_Map, T, D); I_Insert (D.Map, Interface_Tag, Get); System.Shared_Locking.Leave; end Register_Delegation; -- implementation procedure Implements is function Cast is new Unchecked_Conversion (System.Address, Delegate); begin Tags.Get_Delegation := Get_Delegation'Access; Register_Delegation (T'Tag, I'Tag, Cast (Get'Code_Address)); end Implements; end Ada.Tags.Delegating;
reznikmm/matreshka
Ada
3,467
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.Schema.Objects.Terms.Model_Groups; package XML.Schema.Model_Groups renames XML.Schema.Objects.Terms.Model_Groups;
sungyeon/drake
Ada
14,099
adb
with Ada.Unchecked_Conversion; with System.Long_Long_Complex_Elementary_Functions; with System.Long_Long_Complex_Types; package body Ada.Numerics.Generic_Complex_Elementary_Functions is pragma Warnings (Off); function To_Complex is new Unchecked_Conversion ( Complex, System.Long_Long_Complex_Types.Complex); function To_Long_Complex is new Unchecked_Conversion ( Complex, System.Long_Long_Complex_Types.Long_Complex); function To_Long_Long_Complex is new Unchecked_Conversion ( Complex, System.Long_Long_Complex_Types.Long_Long_Complex); function From_Complex is new Unchecked_Conversion ( System.Long_Long_Complex_Types.Complex, Complex); function From_Long_Complex is new Unchecked_Conversion ( System.Long_Long_Complex_Types.Long_Complex, Complex); function From_Long_Long_Complex is new Unchecked_Conversion ( System.Long_Long_Complex_Types.Long_Long_Complex, Complex); pragma Warnings (On); -- implementation function Sqrt (X : Complex) return Complex is begin if Real'Digits <= Float'Digits then declare function csqrtf (x : Complex) return Complex with Import, Convention => Intrinsic, External_Name => "__builtin_csqrtf"; begin return csqrtf (X); end; elsif Real'Digits <= Long_Float'Digits and then Real'Size <= Long_Float'Size -- for 32bit FreeBSD then declare function csqrt (x : Complex) return Complex with Import, Convention => Intrinsic, External_Name => "__builtin_csqrt"; begin return csqrt (X); end; else declare function csqrtl (x : Complex) return Complex with Import, Convention => Intrinsic, External_Name => "__builtin_csqrtl"; begin return csqrtl (X); end; end if; end Sqrt; function Log (X : Complex) return Complex is begin -- RM G.1.2(29), raise Constraint_Error when X = 0.0 if Real'Digits <= Float'Digits then return From_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Log ( To_Complex (X))); elsif Real'Digits <= Long_Float'Digits then return From_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Log ( To_Long_Complex (X))); else return From_Long_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Log ( To_Long_Long_Complex (X))); end if; end Log; function Exp (X : Complex) return Complex is begin if Real'Digits <= Float'Digits then return From_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Exp ( To_Complex (X))); elsif Real'Digits <= Long_Float'Digits then return From_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Exp ( To_Long_Complex (X))); else return From_Long_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Exp ( To_Long_Long_Complex (X))); end if; end Exp; function Exp (X : Imaginary) return Complex is begin if Real'Digits <= Float'Digits then return From_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Exp ( System.Long_Long_Complex_Types.Imaginary (Im (X)))); elsif Real'Digits <= Long_Float'Digits then return From_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Exp ( System.Long_Long_Complex_Types.Long_Imaginary (Im (X)))); else return From_Long_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Exp ( System.Long_Long_Complex_Types.Long_Long_Imaginary (Im (X)))); end if; end Exp; function "**" (Left : Complex; Right : Complex) return Complex is begin if not Standard'Fast_Math then if not (Left.Re /= 0.0) and then not (Left.Im /= 0.0) and then not (Right.Re /= 0.0) then raise Argument_Error; -- RM G.1.2(27), CXG1004 end if; -- RM G.1.2(30), raise Constraint_Error -- when Left = 0.0 and Right.Re < 0.0 if Right.Re = 1.0 and then Right.Im = 0.0 then return Left; -- CXG1005 end if; end if; if Real'Digits <= Float'Digits then return From_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Pow ( To_Complex (Left), To_Complex (Right))); elsif Real'Digits <= Long_Float'Digits then return From_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Pow ( To_Long_Complex (Left), To_Long_Complex (Right))); else return From_Long_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Pow ( To_Long_Long_Complex (Left), To_Long_Long_Complex (Right))); end if; end "**"; function "**" (Left : Complex; Right : Real'Base) return Complex is begin return Left ** (Re => Right, Im => 0.0); end "**"; function "**" (Left : Real'Base; Right : Complex) return Complex is begin return (Re => Left, Im => 0.0) ** Right; end "**"; function Sin (X : Complex) return Complex is begin if Real'Digits <= Float'Digits then return From_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Sin ( To_Complex (X))); elsif Real'Digits <= Long_Float'Digits then return From_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Sin ( To_Long_Complex (X))); else return From_Long_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Sin ( To_Long_Long_Complex (X))); end if; end Sin; function Cos (X : Complex) return Complex is begin if Real'Digits <= Float'Digits then return From_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Cos ( To_Complex (X))); elsif Real'Digits <= Long_Float'Digits then return From_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Cos ( To_Long_Complex (X))); else return From_Long_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Cos ( To_Long_Long_Complex (X))); end if; end Cos; function Tan (X : Complex) return Complex is begin if Real'Digits <= Float'Digits then return From_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Tan ( To_Complex (X))); elsif Real'Digits <= Long_Float'Digits then return From_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Tan ( To_Long_Complex (X))); else return From_Long_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Tan ( To_Long_Long_Complex (X))); end if; end Tan; function Cot (X : Complex) return Complex is begin -- RM G.1.2(29), raise Constraint_Error when X = 0.0 return Cos (X) / Sin (X); end Cot; function Arcsin (X : Complex) return Complex is begin if Real'Digits <= Float'Digits then return From_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Arcsin ( To_Complex (X))); elsif Real'Digits <= Long_Float'Digits then return From_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Arcsin ( To_Long_Complex (X))); else return From_Long_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Arcsin ( To_Long_Long_Complex (X))); end if; end Arcsin; function Arccos (X : Complex) return Complex is begin if Real'Digits <= Float'Digits then return From_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Arccos ( To_Complex (X))); elsif Real'Digits <= Long_Float'Digits then return From_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Arccos ( To_Long_Complex (X))); else return From_Long_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Arccos ( To_Long_Long_Complex (X))); end if; end Arccos; function Arctan (X : Complex) return Complex is begin -- RM G.1.2(31), raise Constraint_Error when X = I or X = -I if Real'Digits <= Float'Digits then return From_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Arctan ( To_Complex (X))); elsif Real'Digits <= Long_Float'Digits then return From_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Arctan ( To_Long_Complex (X))); else return From_Long_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Arctan ( To_Long_Long_Complex (X))); end if; end Arctan; function Arccot (X : Complex) return Complex is begin -- RM G.1.2(31), raise Constraint_Error when X = I or X = -I return Pi / 2.0 - Arctan (X); end Arccot; function Sinh (X : Complex) return Complex is begin if Real'Digits <= Float'Digits then return From_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Sinh ( To_Complex (X))); elsif Real'Digits <= Long_Float'Digits then return From_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Sinh ( To_Long_Complex (X))); else return From_Long_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Sinh ( To_Long_Long_Complex (X))); end if; end Sinh; function Cosh (X : Complex) return Complex is begin if Real'Digits <= Float'Digits then return From_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Cosh ( To_Complex (X))); elsif Real'Digits <= Long_Float'Digits then return From_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Cosh ( To_Long_Complex (X))); else return From_Long_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Cosh ( To_Long_Long_Complex (X))); end if; end Cosh; function Tanh (X : Complex) return Complex is begin if Real'Digits <= Float'Digits then return From_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Tanh ( To_Complex (X))); elsif Real'Digits <= Long_Float'Digits then return From_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Tanh ( To_Long_Complex (X))); else return From_Long_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Tanh ( To_Long_Long_Complex (X))); end if; end Tanh; function Coth (X : Complex) return Complex is begin -- RM G.1.2(29), raise Constraint_Error when X = 0.0 return Cosh (X) / Sinh (X); end Coth; function Arcsinh (X : Complex) return Complex is begin if Real'Digits <= Float'Digits then return From_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Arcsinh ( To_Complex (X))); elsif Real'Digits <= Long_Float'Digits then return From_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Arcsinh ( To_Long_Complex (X))); else return From_Long_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Arcsinh ( To_Long_Long_Complex (X))); end if; end Arcsinh; function Arccosh (X : Complex) return Complex is begin if Real'Digits <= Float'Digits then return From_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Arccosh ( To_Complex (X))); elsif Real'Digits <= Long_Float'Digits then return From_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Arccosh ( To_Long_Complex (X))); else return From_Long_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Arccosh ( To_Long_Long_Complex (X))); end if; end Arccosh; function Arctanh (X : Complex) return Complex is begin -- RM G.1.2(32), raise Constraint_Error when X = 1.0 or X = -1.0 if Real'Digits <= Float'Digits then return From_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Arctanh ( To_Complex (X))); elsif Real'Digits <= Long_Float'Digits then return From_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Arctanh ( To_Long_Complex (X))); else return From_Long_Long_Complex ( System.Long_Long_Complex_Elementary_Functions.Fast_Arctanh ( To_Long_Long_Complex (X))); end if; end Arctanh; function Arccoth (X : Complex) return Complex is begin -- RM G.1.2(32), raise Constraint_Error when X = 1.0 or X = -1.0 if X.Re = 0.0 and then X.Im = 0.0 then return (0.0, Pi / 2.0); else return Arctanh (1.0 / X); end if; end Arccoth; end Ada.Numerics.Generic_Complex_Elementary_Functions;
apple-oss-distributions/old_ncurses
Ada
4,546
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- Sample.Form_Demo.Handler -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Juergen Pfeifer <[email protected]> 1996 -- Version Control -- $Revision: 1.1.1.1 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ with Sample.Form_Demo.Aux; package body Sample.Form_Demo.Handler is package Aux renames Sample.Form_Demo.Aux; procedure Drive_Me (F : in Form; Title : in String := "") is L : Line_Count; C : Column_Count; Y : Line_Position; X : Column_Position; begin Aux.Geometry (F, L, C, Y, X); Drive_Me (F, Y, X, Title); end Drive_Me; procedure Drive_Me (F : in Form; Lin : in Line_Position; Col : in Column_Position; Title : in String := "") is Pan : Panel := Aux.Create (F, Title, Lin, Col); V : Cursor_Visibility := Normal; Handle_CRLF : Boolean := True; begin Set_Cursor_Visibility (V); if Aux.Count_Active (F) = 1 then Handle_CRLF := False; end if; loop declare K : Key_Code := Aux.Get_Request (F, Pan, Handle_CRLF); R : Driver_Result; begin if (K = 13 or else K = 10) and then not Handle_CRLF then R := Unknown_Request; else R := Driver (F, K); end if; case R is when Form_Ok => null; when Unknown_Request => if My_Driver (F, K, Pan) then exit; end if; when others => Beep; end case; end; end loop; Set_Cursor_Visibility (V); Aux.Destroy (F, Pan); end Drive_Me; end Sample.Form_Demo.Handler;
libos-nuse/frankenlibc
Ada
4,465
adb
---------------------------------------------------------------- -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- -- -- -- Open source license information is in the zlib.ads file. -- ---------------------------------------------------------------- -- Continuous test for ZLib multithreading. If the test would fail -- we should provide thread safe allocation routines for the Z_Stream. -- -- Id: mtest.adb,v 1.4 2004/07/23 07:49:54 vagul Exp with ZLib; with Ada.Streams; with Ada.Numerics.Discrete_Random; with Ada.Text_IO; with Ada.Exceptions; with Ada.Task_Identification; procedure MTest is use Ada.Streams; use ZLib; Stop : Boolean := False; pragma Atomic (Stop); subtype Visible_Symbols is Stream_Element range 16#20# .. 16#7E#; package Random_Elements is new Ada.Numerics.Discrete_Random (Visible_Symbols); task type Test_Task; task body Test_Task is Buffer : Stream_Element_Array (1 .. 100_000); Gen : Random_Elements.Generator; Buffer_First : Stream_Element_Offset; Compare_First : Stream_Element_Offset; Deflate : Filter_Type; Inflate : Filter_Type; procedure Further (Item : in Stream_Element_Array); procedure Read_Buffer (Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); ------------- -- Further -- ------------- procedure Further (Item : in Stream_Element_Array) is procedure Compare (Item : in Stream_Element_Array); ------------- -- Compare -- ------------- procedure Compare (Item : in Stream_Element_Array) is Next_First : Stream_Element_Offset := Compare_First + Item'Length; begin if Buffer (Compare_First .. Next_First - 1) /= Item then raise Program_Error; end if; Compare_First := Next_First; end Compare; procedure Compare_Write is new ZLib.Write (Write => Compare); begin Compare_Write (Inflate, Item, No_Flush); end Further; ----------------- -- Read_Buffer -- ----------------- procedure Read_Buffer (Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset) is Buff_Diff : Stream_Element_Offset := Buffer'Last - Buffer_First; Next_First : Stream_Element_Offset; begin if Item'Length <= Buff_Diff then Last := Item'Last; Next_First := Buffer_First + Item'Length; Item := Buffer (Buffer_First .. Next_First - 1); Buffer_First := Next_First; else Last := Item'First + Buff_Diff; Item (Item'First .. Last) := Buffer (Buffer_First .. Buffer'Last); Buffer_First := Buffer'Last + 1; end if; end Read_Buffer; procedure Translate is new Generic_Translate (Data_In => Read_Buffer, Data_Out => Further); begin Random_Elements.Reset (Gen); Buffer := (others => 20); Main : loop for J in Buffer'Range loop Buffer (J) := Random_Elements.Random (Gen); Deflate_Init (Deflate); Inflate_Init (Inflate); Buffer_First := Buffer'First; Compare_First := Buffer'First; Translate (Deflate); if Compare_First /= Buffer'Last + 1 then raise Program_Error; end if; Ada.Text_IO.Put_Line (Ada.Task_Identification.Image (Ada.Task_Identification.Current_Task) & Stream_Element_Offset'Image (J) & ZLib.Count'Image (Total_Out (Deflate))); Close (Deflate); Close (Inflate); exit Main when Stop; end loop; end loop Main; exception when E : others => Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Information (E)); Stop := True; end Test_Task; Test : array (1 .. 4) of Test_Task; pragma Unreferenced (Test); Dummy : Character; begin Ada.Text_IO.Get_Immediate (Dummy); Stop := True; end MTest;
reznikmm/matreshka
Ada
4,871
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Visitors; with ODF.DOM.Text_Index_Entry_Bibliography_Elements; package Matreshka.ODF_Text.Index_Entry_Bibliography_Elements is type Text_Index_Entry_Bibliography_Element_Node is new Matreshka.ODF_Text.Abstract_Text_Element_Node and ODF.DOM.Text_Index_Entry_Bibliography_Elements.ODF_Text_Index_Entry_Bibliography with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_Index_Entry_Bibliography_Element_Node; overriding function Get_Local_Name (Self : not null access constant Text_Index_Entry_Bibliography_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Text_Index_Entry_Bibliography_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Leave_Node (Self : not null access Text_Index_Entry_Bibliography_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Visit_Node (Self : not null access Text_Index_Entry_Bibliography_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); end Matreshka.ODF_Text.Index_Entry_Bibliography_Elements;
Letractively/ada-el
Ada
8,180
ads
----------------------------------------------------------------------- -- EL.Expressions -- Expression Language -- Copyright (C) 2009, 2010, 2011 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- -- -- First, create the expression object: -- -- E : constant Expression := EL.Expressions.Create_Expression ("obj.count + 3"); -- -- The expression must be evaluated against an expression context. -- The expression context will resolve variables whose values can change depending -- on the evaluation context. In the example, ''obj'' is the variable name -- and ''count'' is the property associated with that variable. -- -- Value : constant Object := E.Get_Value (Context); -- -- The ''Value'' holds the result which can be a boolean, an integer, a date, -- a float number or a string. The value can be converted as follows: -- -- N : Integer := To_Integer (Value); -- with EL.Objects; with Ada.Finalization; with Ada.Strings.Unbounded; limited private with EL.Expressions.Nodes; with EL.Contexts; with Util.Beans.Methods; with Util.Beans.Basic; package EL.Expressions is pragma Preelaborate; use EL.Objects; use EL.Contexts; -- Exception raised when parsing an invalid expression. Invalid_Expression : exception; -- Exception raised when a variable cannot be resolved. Invalid_Variable : exception; -- Exception raised when a method cannot be found. Invalid_Method : exception; -- A parameter is missing in a function call. Missing_Argument : exception; -- ------------------------------ -- Expression -- ------------------------------ type Expression is new Ada.Finalization.Controlled with private; type Expression_Access is access all Expression'Class; -- Check whether the expression is a holds a constant value. function Is_Constant (Expr : Expression'Class) return Boolean; -- Returns True if the expression is empty (no constant value and no expression). function Is_Null (Expr : in Expression'Class) return Boolean; -- Get the value of the expression using the given expression context. -- Returns an object that holds a typed result. function Get_Value (Expr : Expression; Context : ELContext'Class) return Object; -- Get the expression string that was parsed. function Get_Expression (Expr : in Expression) return String; -- Parse an expression and return its representation ready for evaluation. -- The context is used to resolve the functions. Variables will be -- resolved during evaluation of the expression. -- Raises <b>Invalid_Expression</b> if the expression is invalid. function Create_Expression (Expr : String; Context : ELContext'Class) return Expression; -- Reduce the expression by eliminating known variables and computing -- constant expressions. The result expression is either another -- expression or a computed constant value. function Reduce_Expression (Expr : Expression; Context : ELContext'Class) return Expression; -- ------------------------------ -- ValueExpression -- ------------------------------ -- type Value_Expression is new Expression with private; type Value_Expression_Access is access all Value_Expression'Class; -- Set the value of the expression to the given object value. procedure Set_Value (Expr : in Value_Expression; Context : in ELContext'Class; Value : in Object); -- Returns true if the expression is read-only. function Is_Readonly (Expr : in Value_Expression; Context : in ELContext'Class) return Boolean; overriding function Reduce_Expression (Expr : Value_Expression; Context : ELContext'Class) return Value_Expression; -- Parse an expression and return its representation ready for evaluation. function Create_Expression (Expr : String; Context : ELContext'Class) return Value_Expression; function Create_ValueExpression (Bean : EL.Objects.Object) return Value_Expression; -- Create a Value_Expression from an expression. -- Raises Invalid_Expression if the expression in not an lvalue. function Create_Expression (Expr : Expression'Class) return Value_Expression; -- Create an EL expression from an object. function Create_Expression (Bean : in EL.Objects.Object) return Expression; -- ------------------------------ -- Method Expression -- ------------------------------ -- A <b>Method_Expression</b> is an expression that refers to a method. -- Information about the object and method is retrieved by using -- the <b>Get_Method_Info</b> operation. type Method_Expression is new EL.Expressions.Expression with private; type Method_Info is record Object : access Util.Beans.Basic.Readonly_Bean'Class; Binding : Util.Beans.Methods.Method_Binding_Access; end record; -- Evaluate the method expression and return the object and method -- binding to execute the method. The result contains a pointer -- to the bean object and a method binding. The method binding -- contains the information to invoke the method -- (such as an access to the function or procedure). -- Raises the <b>Invalid_Method</b> exception if the method -- cannot be resolved. function Get_Method_Info (Expr : Method_Expression; Context : ELContext'Class) return Method_Info; -- Parse an expression and return its representation ready for evaluation. -- The context is used to resolve the functions. Variables will be -- resolved during evaluation of the expression. -- Raises <b>Invalid_Expression</b> if the expression is invalid. overriding function Create_Expression (Expr : String; Context : EL.Contexts.ELContext'Class) return Method_Expression; -- Reduce the expression by eliminating known variables and computing -- constant expressions. The result expression is either another -- expression or a computed constant value. overriding function Reduce_Expression (Expr : Method_Expression; Context : EL.Contexts.ELContext'Class) return Method_Expression; -- Create a Method_Expression from an expression. -- Raises Invalid_Expression if the expression in not an lvalue. function Create_Expression (Expr : Expression'Class) return Method_Expression; private overriding procedure Adjust (Object : in out Expression); overriding procedure Finalize (Object : in out Expression); type Expression is new Ada.Finalization.Controlled with record Node : access EL.Expressions.Nodes.ELNode'Class := null; Value : EL.Objects.Object := EL.Objects.Null_Object; Expr : Ada.Strings.Unbounded.Unbounded_String; end record; type Value_Expression is new Expression with null record; type Method_Expression is new EL.Expressions.Expression with null record; end EL.Expressions;
persan/AdaYaml
Ada
976
ads
-- part of AdaYaml, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "copying.txt" package Yaml.Events is -- parent of several event-holding collection types -- raised when trying to manipulate an event holder object while a -- Stream_Instance based on that object exists. State_Error : exception; private type Event_Array is array (Positive range <>) of aliased Event; type Event_Array_Access is access Event_Array; type Event_Holder is abstract limited new Refcount_Base with record Length : Natural := 0; Data : not null Event_Array_Access := new Event_Array (1 .. 256); end record; overriding procedure Finalize (Object : in out Event_Holder); procedure Copy_Data (Source : Event_Holder; Target : not null Event_Array_Access) with Pre => Target.all'Length >= Source.Data.all'Length; procedure Grow (Object : in out Event_Holder'Class); end Yaml.Events;
reznikmm/matreshka
Ada
3,674
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.Draw_Cx_Attributes is pragma Preelaborate; type ODF_Draw_Cx_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Draw_Cx_Attribute_Access is access all ODF_Draw_Cx_Attribute'Class with Storage_Size => 0; end ODF.DOM.Draw_Cx_Attributes;
reznikmm/matreshka
Ada
2,704
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2010 Vadim Godunko <[email protected]> -- -- -- -- Matreshka is free software; you can redistribute it and/or modify it -- -- under terms of the GNU General Public License as published by the Free -- -- Software Foundation; either version 2, or (at your option) any later -- -- version. Matreshka 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 distributed with Matreshka; see file COPYING. -- -- If not, write to the Free Software Foundation, 51 Franklin Street, -- -- Fifth Floor, Boston, MA 02110-1301, USA. -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ package Matreshka.Internals.Host_Parameters is Vector_Alignment : constant := Standard'Maximum_Alignment; end Matreshka.Internals.Host_Parameters;
zhmu/ananas
Ada
3,895
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . P A C K _ 5 4 -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ -- Handling of packed arrays with Component_Size = 54 package System.Pack_54 is pragma Preelaborate; Bits : constant := 54; type Bits_54 is mod 2 ** Bits; for Bits_54'Size use Bits; -- In all subprograms below, Rev_SSO is set True if the array has the -- non-default scalar storage order. function Get_54 (Arr : System.Address; N : Natural; Rev_SSO : Boolean) return Bits_54 with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is extracted and returned. procedure Set_54 (Arr : System.Address; N : Natural; E : Bits_54; Rev_SSO : Boolean) with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is set to the given value. function GetU_54 (Arr : System.Address; N : Natural; Rev_SSO : Boolean) return Bits_54 with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is extracted and returned. This version -- is used when Arr may represent an unaligned address. procedure SetU_54 (Arr : System.Address; N : Natural; E : Bits_54; Rev_SSO : Boolean) with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is set to the given value. This version -- is used when Arr may represent an unaligned address end System.Pack_54;
reznikmm/matreshka
Ada
6,860
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_Draw.Fill_Image_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Draw_Fill_Image_Element_Node is begin return Self : Draw_Fill_Image_Element_Node do Matreshka.ODF_Draw.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Draw_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Draw_Fill_Image_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_Draw_Fill_Image (ODF.DOM.Draw_Fill_Image_Elements.ODF_Draw_Fill_Image_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 Draw_Fill_Image_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Fill_Image_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Draw_Fill_Image_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_Draw_Fill_Image (ODF.DOM.Draw_Fill_Image_Elements.ODF_Draw_Fill_Image_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 Draw_Fill_Image_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_Draw_Fill_Image (Visitor, ODF.DOM.Draw_Fill_Image_Elements.ODF_Draw_Fill_Image_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.Draw_URI, Matreshka.ODF_String_Constants.Fill_Image_Element, Draw_Fill_Image_Element_Node'Tag); end Matreshka.ODF_Draw.Fill_Image_Elements;
optikos/oasis
Ada
8,285
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Elements.Defining_Identifiers; with Program.Lexical_Elements; with Program.Elements.Loop_Parameter_Specifications; with Program.Elements.Generalized_Iterator_Specifications; with Program.Elements.Element_Iterator_Specifications; with Program.Element_Vectors; with Program.Elements.Identifiers; with Program.Elements.For_Loop_Statements; with Program.Element_Visitors; package Program.Nodes.For_Loop_Statements is pragma Preelaborate; type For_Loop_Statement is new Program.Nodes.Node and Program.Elements.For_Loop_Statements.For_Loop_Statement and Program.Elements.For_Loop_Statements.For_Loop_Statement_Text with private; function Create (Statement_Identifier : Program.Elements.Defining_Identifiers .Defining_Identifier_Access; Colon_Token : Program.Lexical_Elements .Lexical_Element_Access; For_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Loop_Parameter : Program.Elements.Loop_Parameter_Specifications .Loop_Parameter_Specification_Access; Generalized_Iterator : Program.Elements .Generalized_Iterator_Specifications .Generalized_Iterator_Specification_Access; Element_Iterator : Program.Elements .Element_Iterator_Specifications .Element_Iterator_Specification_Access; Loop_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Statements : not null Program.Element_Vectors .Element_Vector_Access; End_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Loop_Token_2 : not null Program.Lexical_Elements .Lexical_Element_Access; End_Statement_Identifier : Program.Elements.Identifiers.Identifier_Access; Semicolon_Token : not null Program.Lexical_Elements .Lexical_Element_Access) return For_Loop_Statement; type Implicit_For_Loop_Statement is new Program.Nodes.Node and Program.Elements.For_Loop_Statements.For_Loop_Statement with private; function Create (Statement_Identifier : Program.Elements.Defining_Identifiers .Defining_Identifier_Access; Loop_Parameter : Program.Elements.Loop_Parameter_Specifications .Loop_Parameter_Specification_Access; Generalized_Iterator : Program.Elements .Generalized_Iterator_Specifications .Generalized_Iterator_Specification_Access; Element_Iterator : Program.Elements .Element_Iterator_Specifications .Element_Iterator_Specification_Access; Statements : not null Program.Element_Vectors .Element_Vector_Access; End_Statement_Identifier : Program.Elements.Identifiers.Identifier_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False) return Implicit_For_Loop_Statement with Pre => Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance; private type Base_For_Loop_Statement is abstract new Program.Nodes.Node and Program.Elements.For_Loop_Statements.For_Loop_Statement with record Statement_Identifier : Program.Elements.Defining_Identifiers .Defining_Identifier_Access; Loop_Parameter : Program.Elements .Loop_Parameter_Specifications.Loop_Parameter_Specification_Access; Generalized_Iterator : Program.Elements .Generalized_Iterator_Specifications .Generalized_Iterator_Specification_Access; Element_Iterator : Program.Elements .Element_Iterator_Specifications .Element_Iterator_Specification_Access; Statements : not null Program.Element_Vectors .Element_Vector_Access; End_Statement_Identifier : Program.Elements.Identifiers .Identifier_Access; end record; procedure Initialize (Self : aliased in out Base_For_Loop_Statement'Class); overriding procedure Visit (Self : not null access Base_For_Loop_Statement; Visitor : in out Program.Element_Visitors.Element_Visitor'Class); overriding function Statement_Identifier (Self : Base_For_Loop_Statement) return Program.Elements.Defining_Identifiers.Defining_Identifier_Access; overriding function Loop_Parameter (Self : Base_For_Loop_Statement) return Program.Elements.Loop_Parameter_Specifications .Loop_Parameter_Specification_Access; overriding function Generalized_Iterator (Self : Base_For_Loop_Statement) return Program.Elements.Generalized_Iterator_Specifications .Generalized_Iterator_Specification_Access; overriding function Element_Iterator (Self : Base_For_Loop_Statement) return Program.Elements.Element_Iterator_Specifications .Element_Iterator_Specification_Access; overriding function Statements (Self : Base_For_Loop_Statement) return not null Program.Element_Vectors.Element_Vector_Access; overriding function End_Statement_Identifier (Self : Base_For_Loop_Statement) return Program.Elements.Identifiers.Identifier_Access; overriding function Is_For_Loop_Statement_Element (Self : Base_For_Loop_Statement) return Boolean; overriding function Is_Statement_Element (Self : Base_For_Loop_Statement) return Boolean; type For_Loop_Statement is new Base_For_Loop_Statement and Program.Elements.For_Loop_Statements.For_Loop_Statement_Text with record Colon_Token : Program.Lexical_Elements.Lexical_Element_Access; For_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Loop_Token : not null Program.Lexical_Elements .Lexical_Element_Access; End_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Loop_Token_2 : not null Program.Lexical_Elements .Lexical_Element_Access; Semicolon_Token : not null Program.Lexical_Elements .Lexical_Element_Access; end record; overriding function To_For_Loop_Statement_Text (Self : aliased in out For_Loop_Statement) return Program.Elements.For_Loop_Statements .For_Loop_Statement_Text_Access; overriding function Colon_Token (Self : For_Loop_Statement) return Program.Lexical_Elements.Lexical_Element_Access; overriding function For_Token (Self : For_Loop_Statement) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Loop_Token (Self : For_Loop_Statement) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function End_Token (Self : For_Loop_Statement) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Loop_Token_2 (Self : For_Loop_Statement) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Semicolon_Token (Self : For_Loop_Statement) return not null Program.Lexical_Elements.Lexical_Element_Access; type Implicit_For_Loop_Statement is new Base_For_Loop_Statement with record Is_Part_Of_Implicit : Boolean; Is_Part_Of_Inherited : Boolean; Is_Part_Of_Instance : Boolean; end record; overriding function To_For_Loop_Statement_Text (Self : aliased in out Implicit_For_Loop_Statement) return Program.Elements.For_Loop_Statements .For_Loop_Statement_Text_Access; overriding function Is_Part_Of_Implicit (Self : Implicit_For_Loop_Statement) return Boolean; overriding function Is_Part_Of_Inherited (Self : Implicit_For_Loop_Statement) return Boolean; overriding function Is_Part_Of_Instance (Self : Implicit_For_Loop_Statement) return Boolean; end Program.Nodes.For_Loop_Statements;
google-code/ada-util
Ada
2,522
adb
----------------------------------------------------------------------- -- util-beans-objects-datasets-tests -- Unit tests for dataset beans -- Copyright (C) 2013 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; with Util.Test_Caller; package body Util.Beans.Objects.Datasets.Tests is package Caller is new Util.Test_Caller (Test, "Objects.Datasets"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Util.Beans.Objects.Datasets", Test_Fill_Dataset'Access); end Add_Tests; -- Test the creation, initialization and retrieval of dataset content. procedure Test_Fill_Dataset (T : in out Test) is Set : Dataset; procedure Fill (Row : in out Object_Array) is begin Row (Row'First) := To_Object (String '("john")); Row (Row'First + 1) := To_Object (String '("[email protected]")); Row (Row'First + 2) := To_Object (Set.Get_Count); end Fill; begin Set.Add_Column ("name"); Set.Add_Column ("email"); Set.Add_Column ("age"); for I in 1 .. 100 loop Set.Append (Fill'Access); end loop; Util.Tests.Assert_Equals (T, 100, Set.Get_Count, "Invalid number of rows"); for I in 1 .. 100 loop Set.Set_Row_Index (I); declare R : Object := Set.Get_Row; begin T.Assert (not Is_Null (R), "Row is null"); Util.Tests.Assert_Equals (T, "john", To_String (Get_Value (R, "name")), "Invalid 'name' attribute"); Util.Tests.Assert_Equals (T, I, To_Integer (Get_Value (R, "age")), "Invalid 'age' attribute"); end; end loop; end Test_Fill_Dataset; end Util.Beans.Objects.Datasets.Tests;
DrenfongWong/tkm-rpc
Ada
1,442
ads
with Tkmrpc.Types; with Tkmrpc.Operations.Ike; package Tkmrpc.Request.Ike.Cc_Check_Ca is Data_Size : constant := 16; type Data_Type is record Cc_Id : Types.Cc_Id_Type; Ca_Id : Types.Ca_Id_Type; end record; for Data_Type use record Cc_Id at 0 range 0 .. (8 * 8) - 1; Ca_Id at 8 range 0 .. (8 * 8) - 1; end record; for Data_Type'Size use Data_Size * 8; Padding_Size : constant := Request.Body_Size - Data_Size; subtype Padding_Range is Natural range 1 .. Padding_Size; subtype Padding_Type is Types.Byte_Sequence (Padding_Range); type Request_Type is record Header : Request.Header_Type; Data : Data_Type; Padding : Padding_Type; end record; for Request_Type use record Header at 0 range 0 .. (Request.Header_Size * 8) - 1; Data at Request.Header_Size range 0 .. (Data_Size * 8) - 1; Padding at Request.Header_Size + Data_Size range 0 .. (Padding_Size * 8) - 1; end record; for Request_Type'Size use Request.Request_Size * 8; Null_Request : constant Request_Type := Request_Type' (Header => Request.Header_Type'(Operation => Operations.Ike.Cc_Check_Ca, Request_Id => 0), Data => Data_Type'(Cc_Id => Types.Cc_Id_Type'First, Ca_Id => Types.Ca_Id_Type'First), Padding => Padding_Type'(others => 0)); end Tkmrpc.Request.Ike.Cc_Check_Ca;
sungyeon/drake
Ada
3,426
ads
pragma License (Unrestricted); -- implementation unit with System; package Ada.Containers.Naked_Singly_Linked_Lists is pragma Preelaborate; Node_Size : constant := Standard'Address_Size; type Node is limited private; type Node_Access is access Node; function Previous (Position : not null Node_Access) return Node_Access with Convention => Intrinsic; pragma Inline_Always (Previous); -- traversing procedure Reverse_Iterate ( Last : Node_Access; Process : not null access procedure (Position : not null Node_Access)); -- liner search function Reverse_Find ( Last : Node_Access; Params : System.Address; Equivalent : not null access function ( Right : not null Node_Access; Params : System.Address) return Boolean) return Node_Access; function Is_Before (Before, After : Node_Access) return Boolean; -- comparison function Equivalent ( Left_Last, Right_Last : Node_Access; Equivalent : not null access function ( Left, Right : not null Node_Access) return Boolean) return Boolean; -- management procedure Free ( First : in out Node_Access; Last : in out Node_Access; Length : in out Count_Type; Free : not null access procedure (Object : in out Node_Access)); procedure Insert ( First : in out Node_Access; Last : in out Node_Access; Length : in out Count_Type; Before : Node_Access; New_Item : not null Node_Access); procedure Remove ( First : in out Node_Access; Last : in out Node_Access; Length : in out Count_Type; Position : not null Node_Access; Next : Node_Access); procedure Split ( Target_First : out Node_Access; Target_Last : out Node_Access; Length : out Count_Type; Source_First : in out Node_Access; Source_Last : in out Node_Access; Source_Length : in out Count_Type; Count : Count_Type); procedure Copy ( Target_First : out Node_Access; Target_Last : out Node_Access; Length : out Count_Type; Source_Last : Node_Access; Copy : not null access procedure ( Target : out Node_Access; Source : not null Node_Access)); procedure Reverse_Elements ( Target_First : in out Node_Access; Target_Last : in out Node_Access; Length : in out Count_Type); -- sorting function Is_Sorted ( Last : Node_Access; LT : not null access function ( Left, Right : not null Node_Access) return Boolean) return Boolean; procedure Merge ( Target_First : in out Node_Access; Target_Last : in out Node_Access; Length : in out Count_Type; Source_First : in out Node_Access; Source_Last : in out Node_Access; Source_Length : in out Count_Type; LT : not null access function ( Left, Right : not null Node_Access) return Boolean); procedure Merge_Sort ( Target_First : in out Node_Access; Target_Last : in out Node_Access; Length : in out Count_Type; LT : not null access function ( Left, Right : not null Node_Access) return Boolean); private type Node is limited record Previous : Node_Access := null; end record; for Node'Size use Node_Size; end Ada.Containers.Naked_Singly_Linked_Lists;
kevans91/synth
Ada
21,067
adb
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../License.txt with JohnnyText; with Signals; package body Display is package JT renames JohnnyText; package SIG renames Signals; ---------------------- -- launch_monitor -- ---------------------- function launch_monitor (num_builders : builders) return Boolean is begin TIC.Init_Screen; if not TIC.Has_Colors then TIC.End_Windows; return False; end if; TIC.Set_Echo_Mode (False); TIC.Set_Raw_Mode (True); TIC.Set_Cbreak_Mode (True); TIC.Set_Cursor_Visibility (Visibility => cursor_vis); establish_colors; builders_used := Integer (num_builders); launch_summary_zone; launch_builders_zone; launch_actions_zone; draw_static_summary_zone; draw_static_builders_zone; TIC.Refresh (Win => zone_summary); TIC.Refresh (Win => zone_builders); return True; end launch_monitor; ------------------------- -- terminate_monitor -- ------------------------- procedure terminate_monitor is begin TIC.Delete (Win => zone_actions); TIC.Delete (Win => zone_builders); TIC.Delete (Win => zone_summary); TIC.End_Windows; end terminate_monitor; ----------------------------------- -- set_full_redraw_next_update -- ----------------------------------- procedure set_full_redraw_next_update is begin TIC.Redraw (Win => zone_actions); TIC.Redraw (Win => zone_builders); TIC.Redraw (Win => zone_summary); end set_full_redraw_next_update; --------------------------- -- launch_summary_zone -- --------------------------- procedure launch_summary_zone is begin zone_summary := TIC.Create (Number_Of_Lines => 2, Number_Of_Columns => app_width, First_Line_Position => 0, First_Column_Position => 0); end launch_summary_zone; -------------------------------- -- draw_static_summary_zone -- -------------------------------- procedure draw_static_summary_zone is line1 : constant appline := " Total Built Ignored Load 0.00 Pkg/hour" & " "; line2 : constant appline := " Left Failed skipped swap 0.0% Impulse" & " 00:00:00 "; begin TIC.Set_Character_Attributes (Win => zone_summary, Attr => bright, Color => TIC.Color_Pair (c_sumlabel)); TIC.Move_Cursor (Win => zone_summary, Line => 0, Column => 0); TIC.Add (Win => zone_summary, Str => line1); TIC.Move_Cursor (Win => zone_summary, Line => 1, Column => 0); TIC.Add (Win => zone_summary, Str => line2); end draw_static_summary_zone; ---------------------------- -- launch_builders_zone -- ---------------------------- procedure launch_builders_zone is hghtint : constant Integer := 4 + builders_used; height : constant TIC.Line_Position := TIC.Line_Position (hghtint); begin zone_builders := TIC.Create (Number_Of_Lines => height, Number_Of_Columns => app_width, First_Line_Position => 2, First_Column_Position => 0); end launch_builders_zone; --------------------------------- -- draw_static_builders_zone -- --------------------------------- procedure draw_static_builders_zone is hghtint : constant Integer := 4 + builders_used; height : constant TIC.Line_Position := TIC.Line_Position (hghtint); lastrow : constant TIC.Line_Position := inc (height, -1); dashes : constant appline := (others => '='); headtxt : constant appline := " ID Elapsed Build Phase " & "Origin Lines "; begin TIC.Set_Character_Attributes (Win => zone_builders, Attr => bright, Color => TIC.Color_Pair (c_dashes)); TIC.Move_Cursor (Win => zone_builders, Line => 0, Column => 0); TIC.Add (Win => zone_builders, Str => dashes); TIC.Move_Cursor (Win => zone_builders, Line => 2, Column => 0); TIC.Add (Win => zone_builders, Str => dashes); TIC.Move_Cursor (Win => zone_builders, Line => lastrow, Column => 0); TIC.Add (Win => zone_builders, Str => dashes); TIC.Move_Cursor (Win => zone_builders, Line => 1, Column => 0); if SIG.graceful_shutdown_requested then TIC.Set_Character_Attributes (Win => zone_builders, Attr => bright, Color => c_advisory); TIC.Add (Win => zone_builders, Str => shutdown_msg); else TIC.Set_Character_Attributes (Win => zone_builders, Attr => normal, Color => c_tableheader); TIC.Add (Win => zone_builders, Str => headtxt); end if; for z in 3 .. inc (lastrow, -1) loop TIC.Move_Cursor (Win => zone_builders, Line => z, Column => 0); TIC.Add (Win => zone_builders, Str => blank); end loop; end draw_static_builders_zone; --------------------------- -- launch_actions_zone -- --------------------------- procedure launch_actions_zone is consumed : constant Integer := builders_used + 4 + 2; viewpos : constant TIC.Line_Position := TIC.Line_Position (consumed); difference : Integer := 0 - consumed; begin -- Guarantee at least 10 lines for history and let ncurses handle any overflow if difference < 10 then difference := 10; end if; historyheight := inc (TIC.Lines, difference); zone_actions := TIC.Create (Number_Of_Lines => historyheight, Number_Of_Columns => app_width, First_Line_Position => viewpos, First_Column_Position => 0); end launch_actions_zone; ----------- -- inc -- ----------- function inc (X : TIC.Line_Position; by : Integer) return TIC.Line_Position is use type TIC.Line_Position; begin return X + TIC.Line_Position (by); end inc; ----------------- -- summarize -- ----------------- procedure summarize (data : summary_rec) is subtype fivelong is String (1 .. 5); function pad (S : String; amount : Positive := 5) return String; function fmtpc (f : Float; percent : Boolean) return fivelong; procedure colorado (S : String; color : TIC.Color_Pair; col : TIC.Column_Position; row : TIC.Line_Position; dim : Boolean := False); remaining : constant Integer := data.Initially - data.Built - data.Failed - data.Ignored - data.Skipped; function pad (S : String; amount : Positive := 5) return String is result : String (1 .. amount) := (others => ' '); slen : constant Natural := S'Length; begin if slen <= amount then result (1 .. slen) := S; else result := S (S'First .. S'First + amount - 1); end if; return result; end pad; function fmtpc (f : Float; percent : Boolean) return fivelong is type loadtype is delta 0.01 digits 4; result : fivelong := (others => ' '); raw1 : constant loadtype := loadtype (f); raw2 : constant String := raw1'Img; raw3 : constant String := raw2 (2 .. raw2'Last); rlen : constant Natural := raw3'Length; start : constant Natural := 6 - rlen; begin result (start .. 5) := raw3; if percent then result (5) := '%'; end if; return result; end fmtpc; procedure colorado (S : String; color : TIC.Color_Pair; col : TIC.Column_Position; row : TIC.Line_Position; dim : Boolean := False) is attribute : TIC.Character_Attribute_Set := bright; begin if dim then attribute := normal; end if; TIC.Set_Character_Attributes (Win => zone_summary, Attr => attribute, Color => color); TIC.Move_Cursor (Win => zone_summary, Line => row, Column => col); TIC.Add (Win => zone_summary, Str => S); exception when others => null; end colorado; L1F1 : constant String := pad (JT.int2str (data.Initially)); L1F2 : constant String := pad (JT.int2str (data.Built)); L1F3 : constant String := pad (JT.int2str (data.Ignored)); L1F4 : fivelong; L1F5 : constant String := pad (JT.int2str (data.pkg_hour), 4); L2F1 : constant String := pad (JT.int2str (remaining)); L2F2 : constant String := pad (JT.int2str (data.Failed)); L2F3 : constant String := pad (JT.int2str (data.Skipped)); L2F4 : fivelong; L2F5 : constant String := pad (JT.int2str (data.impulse), 4); begin if data.swap = 100.0 then L2F4 := " 100%"; elsif data.swap > 100.0 then L2F4 := " n/a"; else L2F4 := fmtpc (data.swap, True); end if; if data.load >= 100.0 then L1F4 := pad (JT.int2str (Integer (data.load))); else L1F4 := fmtpc (data.load, False); end if; colorado (L1F1, c_standard, 7, 0); colorado (L1F2, c_success, 21, 0); colorado (L1F3, c_ignored, 36, 0); colorado (L1F4, c_standard, 48, 0, True); colorado (L1F5, c_standard, 64, 0, True); colorado (L2F1, c_standard, 7, 1); colorado (L2F2, c_failure, 21, 1); colorado (L2F3, c_skipped, 36, 1); colorado (L2F4, c_standard, 48, 1, True); colorado (L2F5, c_standard, 64, 1, True); colorado (data.elapsed, c_elapsed, 70, 1); TIC.Refresh (Win => zone_summary); end summarize; ----------------------- -- update_builder -- ----------------------- procedure update_builder (BR : builder_rec) is procedure colorado (S : String; color : TIC.Color_Pair; col : TIC.Column_Position; row : TIC.Line_Position; dim : Boolean := False); procedure print_id; row : TIC.Line_Position := inc (TIC.Line_Position (BR.id), 2); procedure print_id is begin TIC.Set_Character_Attributes (Win => zone_builders, Attr => c_slave (BR.id).attribute, Color => c_slave (BR.id).palette); TIC.Move_Cursor (Win => zone_builders, Line => row, Column => 1); TIC.Add (Win => zone_builders, Str => BR.slavid); end print_id; procedure colorado (S : String; color : TIC.Color_Pair; col : TIC.Column_Position; row : TIC.Line_Position; dim : Boolean := False) is attribute : TIC.Character_Attribute_Set := bright; begin if dim then attribute := normal; end if; TIC.Set_Character_Attributes (Win => zone_builders, Attr => attribute, Color => color); TIC.Move_Cursor (Win => zone_builders, Line => row, Column => col); TIC.Add (Win => zone_builders, Str => S); end colorado; begin if SIG.graceful_shutdown_requested then TIC.Set_Character_Attributes (Win => zone_builders, Attr => bright, Color => c_advisory); TIC.Move_Cursor (Win => zone_builders, Line => 1, Column => 0); TIC.Add (Win => zone_builders, Str => shutdown_msg); end if; print_id; colorado (BR.Elapsed, c_standard, 5, row, True); colorado (BR.phase, c_bldphase, 15, row, True); colorado (BR.origin, c_origin, 32, row, False); colorado (BR.LLines, c_standard, 71, row, True); end update_builder; ------------------------------ -- refresh_builder_window -- ------------------------------ procedure refresh_builder_window is begin TIC.Refresh (Win => zone_builders); end refresh_builder_window; ---------------------- -- insert_history -- ---------------------- procedure insert_history (HR : history_rec) is begin if history_arrow = cyclic_range'Last then history_arrow := cyclic_range'First; else history_arrow := history_arrow + 1; end if; history (history_arrow) := HR; end insert_history; ------------------------------ -- refresh_history_window -- ------------------------------ procedure refresh_history_window is procedure clear_row (row : TIC.Line_Position); procedure colorado (S : String; color : TIC.Color_Pair; col : TIC.Column_Position; row : TIC.Line_Position; dim : Boolean := False); function col_action (action : String) return TIC.Color_Pair; procedure print_id (id : builders; sid : String; row : TIC.Line_Position; action : String); procedure clear_row (row : TIC.Line_Position) is begin TIC.Set_Character_Attributes (Win => zone_actions, Attr => TIC.Normal_Video, Color => c_standard); TIC.Move_Cursor (Win => zone_actions, Line => row, Column => 0); TIC.Add (Win => zone_actions, Str => blank); end clear_row; procedure colorado (S : String; color : TIC.Color_Pair; col : TIC.Column_Position; row : TIC.Line_Position; dim : Boolean := False) is attribute : TIC.Character_Attribute_Set := bright; begin if dim then attribute := normal; end if; TIC.Set_Character_Attributes (Win => zone_actions, Attr => attribute, Color => color); TIC.Move_Cursor (Win => zone_actions, Line => row, Column => col); TIC.Add (Win => zone_actions, Str => S); end colorado; function col_action (action : String) return TIC.Color_Pair is begin if action = "shutdown" then return c_shutdown; elsif action = "success " then return c_success; elsif action = "failure " then return c_failure; elsif action = "skipped " then return c_skipped; elsif action = "ignored " then return c_ignored; else return c_standard; end if; end col_action; procedure print_id (id : builders; sid : String; row : TIC.Line_Position; action : String) is begin TIC.Set_Character_Attributes (Win => zone_actions, Attr => normal, Color => c_standard); TIC.Move_Cursor (Win => zone_actions, Line => row, Column => 10); TIC.Add (Win => zone_actions, Str => "[--]"); if action /= "skipped " and then action /= "ignored " then TIC.Set_Character_Attributes (Win => zone_actions, Attr => c_slave (id).attribute, Color => c_slave (id).palette); TIC.Move_Cursor (Win => zone_actions, Line => row, Column => 11); TIC.Add (Win => zone_actions, Str => sid); end if; end print_id; arrow : cyclic_range := history_arrow; maxrow : TIC.Line_Position; use type TIC.Line_Position; begin if historyheight >= TIC.Line_Position (cyclic_range'Last) then maxrow := TIC.Line_Position (cyclic_range'Last) - 1; else maxrow := historyheight - 1; end if; for row in TIC.Line_Position (0) .. maxrow loop if history (arrow).established then colorado (history (arrow).run_elapsed, c_standard, 1, row, True); print_id (id => history (arrow).id, sid => history (arrow).slavid, row => row, action => history (arrow).action); colorado (history (arrow).action, col_action (history (arrow).action), 15, row); colorado (history (arrow).origin, c_origin, 24, row); colorado (history (arrow).pkg_elapsed, c_standard, 70, row, True); else clear_row (row); end if; if arrow = cyclic_range'First then arrow := cyclic_range'Last; else arrow := arrow - 1; end if; end loop; TIC.Refresh (Win => zone_actions); end refresh_history_window; ------------------------ -- establish_colors -- ------------------------ procedure establish_colors is begin TIC.Start_Color; TIC.Init_Pair (TIC.Color_Pair (1), TIC.White, TIC.Black); TIC.Init_Pair (TIC.Color_Pair (2), TIC.Green, TIC.Black); TIC.Init_Pair (TIC.Color_Pair (3), TIC.Red, TIC.Black); TIC.Init_Pair (TIC.Color_Pair (4), TIC.Yellow, TIC.Black); TIC.Init_Pair (TIC.Color_Pair (5), TIC.Black, TIC.Black); TIC.Init_Pair (TIC.Color_Pair (6), TIC.Cyan, TIC.Black); TIC.Init_Pair (TIC.Color_Pair (7), TIC.Blue, TIC.Black); TIC.Init_Pair (TIC.Color_Pair (8), TIC.Magenta, TIC.Black); TIC.Init_Pair (TIC.Color_Pair (9), TIC.Blue, TIC.White); c_standard := TIC.Color_Pair (1); c_success := TIC.Color_Pair (2); c_failure := TIC.Color_Pair (3); c_ignored := TIC.Color_Pair (4); c_skipped := TIC.Color_Pair (5); c_sumlabel := TIC.Color_Pair (6); c_dashes := TIC.Color_Pair (7); c_elapsed := TIC.Color_Pair (4); c_tableheader := TIC.Color_Pair (1); c_origin := TIC.Color_Pair (6); c_bldphase := TIC.Color_Pair (4); c_shutdown := TIC.Color_Pair (1); c_advisory := TIC.Color_Pair (4); c_slave (1).palette := TIC.Color_Pair (1); -- white / Black c_slave (1).attribute := bright; c_slave (2).palette := TIC.Color_Pair (2); -- light green / Black c_slave (2).attribute := bright; c_slave (3).palette := TIC.Color_Pair (4); -- yellow / Black c_slave (3).attribute := bright; c_slave (4).palette := TIC.Color_Pair (8); -- light magenta / Black c_slave (4).attribute := bright; c_slave (5).palette := TIC.Color_Pair (3); -- light red / Black c_slave (5).attribute := bright; c_slave (6).palette := TIC.Color_Pair (7); -- light blue / Black c_slave (6).attribute := bright; c_slave (7).palette := TIC.Color_Pair (6); -- light cyan / Black c_slave (7).attribute := bright; c_slave (8).palette := TIC.Color_Pair (5); -- dark grey / Black c_slave (8).attribute := bright; c_slave (9).palette := TIC.Color_Pair (1); -- light grey / Black c_slave (9).attribute := normal; c_slave (10).palette := TIC.Color_Pair (2); -- light green / Black c_slave (10).attribute := normal; c_slave (11).palette := TIC.Color_Pair (4); -- brown / Black c_slave (11).attribute := normal; c_slave (12).palette := TIC.Color_Pair (8); -- dark magenta / Black c_slave (12).attribute := normal; c_slave (13).palette := TIC.Color_Pair (3); -- dark red / Black c_slave (13).attribute := normal; c_slave (14).palette := TIC.Color_Pair (7); -- dark blue / Black c_slave (14).attribute := normal; c_slave (15).palette := TIC.Color_Pair (6); -- dark cyan / Black c_slave (15).attribute := normal; c_slave (16).palette := TIC.Color_Pair (9); -- white / dark blue c_slave (16).attribute := normal; for bld in builders (17) .. builders (32) loop c_slave (bld) := c_slave (bld - 16); c_slave (bld).attribute.Under_Line := True; end loop; for bld in builders (33) .. builders (64) loop c_slave (bld) := c_slave (bld - 32); end loop; end establish_colors; end Display;
charlie5/lace
Ada
1,706
adb
with openGL.Tasks, GL.Binding, ada.unchecked_Deallocation; package body openGL.Primitive is --------- -- Forge -- procedure define (Self : in out Item; Kind : in facet_Kind) is begin Self.facet_Kind := Kind; end define; procedure free (Self : in out View) is procedure deallocate is new ada.Unchecked_Deallocation (Primitive.item'Class, Primitive.view); begin Self.destroy; deallocate (Self); end free; -------------- -- Attributes -- function Texture (Self : in Item) return openGL.Texture.Object is begin return Self.Texture; end Texture; procedure Texture_is (Self : in out Item; Now : in openGL.Texture.Object) is begin Self.Texture := Now; end Texture_is; function Bounds (self : in Item) return openGL.Bounds is begin return Self.Bounds; end Bounds; procedure Bounds_are (Self : in out Item; Now : in openGL.Bounds) is begin Self.Bounds := Now; end Bounds_are; function is_Transparent (self : in Item) return Boolean is begin return Self.is_Transparent; end is_Transparent; procedure is_Transparent (Self : in out Item; Now : in Boolean := True) is begin Self.is_Transparent := Now; end is_Transparent; -------------- --- Operations -- procedure render (Self : in out Item) is use GL, GL.Binding; begin Tasks.check; if Self.line_Width /= unused_line_Width then glLineWidth (glFloat (Self.line_Width)); end if; end render; end openGL.Primitive;
reznikmm/matreshka
Ada
4,717
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Visitors; with ODF.DOM.Text_Print_Time_Elements; package Matreshka.ODF_Text.Print_Time_Elements is type Text_Print_Time_Element_Node is new Matreshka.ODF_Text.Abstract_Text_Element_Node and ODF.DOM.Text_Print_Time_Elements.ODF_Text_Print_Time with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_Print_Time_Element_Node; overriding function Get_Local_Name (Self : not null access constant Text_Print_Time_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Text_Print_Time_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Leave_Node (Self : not null access Text_Print_Time_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Visit_Node (Self : not null access Text_Print_Time_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); end Matreshka.ODF_Text.Print_Time_Elements;
RREE/ada-util
Ada
4,259
ads
----------------------------------------------------------------------- -- util-encoders-base16 -- Encode/Decode a stream in hexadecimal -- Copyright (C) 2009, 2010, 2011, 2017 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Streams; -- The <b>Util.Encodes.Base16</b> packages encodes and decodes streams -- in hexadecimal. package Util.Encoders.Base16 is pragma Preelaborate; -- ------------------------------ -- Base16 encoder -- ------------------------------ -- This <b>Encoder</b> translates the (binary) input stream into -- an ascii hexadecimal stream. The encoding alphabet is: 0123456789ABCDEF. type Encoder is new Util.Encoders.Transformer with private; -- Encodes the binary input stream represented by <b>Data</b> into -- the a base16 (hexadecimal) output stream <b>Into</b>. -- -- If the transformer does not have enough room to write the result, -- it must return in <b>Encoded</b> the index of the last encoded -- position in the <b>Data</b> stream. -- -- The transformer returns in <b>Last</b> the last valid position -- in the output stream <b>Into</b>. -- -- The <b>Encoding_Error</b> exception is raised if the input -- stream cannot be transformed. overriding procedure Transform (E : in out Encoder; Data : in Ada.Streams.Stream_Element_Array; Into : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset; Encoded : out Ada.Streams.Stream_Element_Offset); -- ------------------------------ -- Base16 decoder -- ------------------------------ -- The <b>Decoder</b> decodes an hexadecimal stream into a binary stream. type Decoder is new Util.Encoders.Transformer with private; -- Decodes the base16 input stream represented by <b>Data</b> into -- the binary output stream <b>Into</b>. -- -- If the transformer does not have enough room to write the result, -- it must return in <b>Encoded</b> the index of the last encoded -- position in the <b>Data</b> stream. -- -- The transformer returns in <b>Last</b> the last valid position -- in the output stream <b>Into</b>. -- -- The <b>Encoding_Error</b> exception is raised if the input -- stream cannot be transformed. overriding procedure Transform (E : in out Decoder; Data : in Ada.Streams.Stream_Element_Array; Into : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset; Encoded : out Ada.Streams.Stream_Element_Offset); private type Encoder is new Util.Encoders.Transformer with null record; type Decoder is new Util.Encoders.Transformer with null record; generic type Input_Char is (<>); type Output_Char is (<>); type Index is range <>; type Output_Index is range <>; type Input is array (Index range <>) of Input_Char; type Output is array (Output_Index range <>) of Output_Char; package Encoding is procedure Encode (From : in Input; Into : in out Output; Last : out Output_Index; Encoded : out Index); procedure Decode (From : in Input; Into : in out Output; Last : out Output_Index; Encoded : out Index); end Encoding; end Util.Encoders.Base16;
reznikmm/matreshka
Ada
5,553
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2015, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Asis.Elements; with Asis.Expressions; with Asis.Statements; package body Properties.Expressions.Case_Expression is ---------- -- Code -- ---------- function Code (Engine : access Engines.Contexts.Context; Element : Asis.Expression; Name : Engines.Text_Property) return League.Strings.Universal_String is use type Asis.Path_Kinds; use type Asis.Definition_Kinds; use type Asis.Element_Kinds; List : constant Asis.Path_List := Asis.Expressions.Expression_Paths (Element); Text : League.Strings.Universal_String; Down : League.Strings.Universal_String; begin Text.Append ("(function (_case){"); Text.Append ("switch (_case){"); for J in List'Range loop pragma Assert (Asis.Elements.Path_Kind (List (J)) = Asis.A_Case_Expression_Path); declare Nested : constant Asis.Expression := Asis.Expressions.Dependent_Expression (List (J)); Alt : constant Asis.Element_List := Asis.Statements.Case_Path_Alternative_Choices (List (J)); begin for K in Alt'Range loop if Asis.Elements.Element_Kind (Alt (K)) = Asis.An_Expression then Down := Engine.Text.Get_Property (Alt (K), Name); Text.Append ("case "); Text.Append (Down); Text.Append (" : "); elsif Asis.Elements.Definition_Kind (Alt (K)) = Asis.An_Others_Choice then Text.Append ("default: "); else raise Constraint_Error; end if; Text.Append ("return "); Down := Engine.Text.Get_Property (Nested, Name); Text.Append (Down); Text.Append (";"); end loop; end; end loop; Text.Append ("}})("); Down := Engine.Text.Get_Property (Asis.Statements.Case_Expression (Element), Name); Text.Append (Down); Text.Append (")"); return Text; end Code; end Properties.Expressions.Case_Expression;
AdaCore/libadalang
Ada
228
adb
procedure Test (D : Float) is A, B : Integer; --% node.p_unique_identifying_name --% node.p_defining_names[0].p_unique_identifying_name --% node.p_defining_names[1].p_unique_identifying_name begin null; end Test;
optikos/ada-lsp
Ada
1,173
adb
-- Copyright (c) 2017 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package body LSP.Request_Dispatchers is -------------- -- Dispatch -- -------------- not overriding function Dispatch (Self : in out Request_Dispatcher; Method : LSP.Types.LSP_String; Stream : access Ada.Streams.Root_Stream_Type'Class; Handler : not null LSP.Message_Handlers.Request_Handler_Access) return LSP.Messages.ResponseMessage'Class is Cursor : Maps.Cursor := Self.Map.Find (Method); begin if not Maps.Has_Element (Cursor) then Cursor := Self.Map.Find (League.Strings.Empty_Universal_String); end if; return Maps.Element (Cursor) (Stream, Handler); end Dispatch; -------------- -- Register -- -------------- not overriding procedure Register (Self : in out Request_Dispatcher; Method : League.Strings.Universal_String; Value : Parameter_Handler_Access) is begin Self.Map.Insert (Method, Value); end Register; end LSP.Request_Dispatchers;
reznikmm/matreshka
Ada
5,049
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-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.SAX.Simple_Readers.Callbacks; package body XML.SAX.Simple_Readers.Validator is use Matreshka.Internals.XML; use Matreshka.Internals.XML.Element_Tables; ---------------------- -- Validate_Element -- ---------------------- procedure Validate_Element (Self : in out Simple_Reader'Class) is use type Ada.Containers.Count_Type; begin if Self.Validation.Enabled and Self.Validation.Has_DTD then if Self.Element_Names.Length = 1 then -- Check whether root element match declared element type. if Self.Root_Symbol /= Self.Current_Element_Name then -- [2.8 VC: Root Element Type] -- -- "The Name in the document type declaration MUST match the -- element type of the root element." Callbacks.Call_Error (Self, League.Strings.To_Universal_String ("[2.8 VC: Root Element Type] Root element has wrong name")); end if; end if; -- [XML 3 VC: Element Valid] -- -- "An element is valid if there is a declaration matching -- elementdecl where the Name matches the element type, ..." -- -- Check whether element was declared. if Self.Current_Element = No_Element or else not Is_Declared (Self.Elements, Self.Current_Element) then Callbacks.Call_Error (Self, League.Strings.To_Universal_String ("[XML 3 VC: Element Valid] no declaration for element")); end if; end if; end Validate_Element; end XML.SAX.Simple_Readers.Validator;
afrl-rq/OpenUxAS
Ada
301
ads
package UxAS.Comms.Transport.Network_Name is ZmqExternalLmcpTcpNetwork : constant String := "zmqExternalLmcpTcpNetwork"; ZmqLmcpNetwork : constant String := "zmqLmcpNetwork"; ZmqStringNetwork : constant String := "zmqStringNetwork"; end UxAS.Comms.Transport.Network_Name;
stcarrez/dynamo
Ada
27,191
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- A S P E C T S -- -- -- -- B o d y -- -- -- -- Copyright (C) 2010-2015, 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 Atree; use Atree; with Einfo; use Einfo; with Nlists; use Nlists; with Sinfo; use Sinfo; with Tree_IO; use Tree_IO; with GNAT.HTable; package body Aspects is -- The following array indicates aspects that a subtype inherits from its -- base type. True means that the subtype inherits the aspect from its base -- type. False means it is not inherited. Base_Aspect : constant array (Aspect_Id) of Boolean := (Aspect_Atomic => True, Aspect_Atomic_Components => True, Aspect_Constant_Indexing => True, Aspect_Default_Iterator => True, Aspect_Discard_Names => True, Aspect_Independent_Components => True, Aspect_Iterator_Element => True, Aspect_Type_Invariant => True, Aspect_Unchecked_Union => True, Aspect_Variable_Indexing => True, Aspect_Volatile => True, others => False); -- The following array indicates type aspects that are inherited and apply -- to the class-wide type as well. Inherited_Aspect : constant array (Aspect_Id) of Boolean := (Aspect_Constant_Indexing => True, Aspect_Default_Iterator => True, Aspect_Implicit_Dereference => True, Aspect_Iterator_Element => True, Aspect_Remote_Types => True, Aspect_Variable_Indexing => True, others => False); procedure Set_Aspect_Specifications_No_Check (N : Node_Id; L : List_Id); -- Same as Set_Aspect_Specifications, but does not contain the assertion -- that checks that N does not already have aspect specifications. This -- subprogram is supposed to be used as a part of Tree_Read. When reading -- tree, first read nodes with their basic properties (as Atree.Tree_Read), -- this includes reading the Has_Aspects flag for each node, then we reed -- all the list tables and only after that we call Tree_Read for Aspects. -- That is, when reading the tree, the list of aspects is attached to the -- node that already has Has_Aspects flag set ON. ------------------------------------------ -- Hash Table for Aspect Specifications -- ------------------------------------------ type AS_Hash_Range is range 0 .. 510; -- Size of hash table headers function AS_Hash (F : Node_Id) return AS_Hash_Range; -- Hash function for hash table function AS_Hash (F : Node_Id) return AS_Hash_Range is begin return AS_Hash_Range (F mod 511); end AS_Hash; package Aspect_Specifications_Hash_Table is new GNAT.HTable.Simple_HTable (Header_Num => AS_Hash_Range, Element => List_Id, No_Element => No_List, Key => Node_Id, Hash => AS_Hash, Equal => "="); ------------------------------------- -- Hash Table for Aspect Id Values -- ------------------------------------- type AI_Hash_Range is range 0 .. 112; -- Size of hash table headers function AI_Hash (F : Name_Id) return AI_Hash_Range; -- Hash function for hash table function AI_Hash (F : Name_Id) return AI_Hash_Range is begin return AI_Hash_Range (F mod 113); end AI_Hash; package Aspect_Id_Hash_Table is new GNAT.HTable.Simple_HTable (Header_Num => AI_Hash_Range, Element => Aspect_Id, No_Element => No_Aspect, Key => Name_Id, Hash => AI_Hash, Equal => "="); --------------------------- -- Aspect_Specifications -- --------------------------- function Aspect_Specifications (N : Node_Id) return List_Id is begin if Has_Aspects (N) then return Aspect_Specifications_Hash_Table.Get (N); else return No_List; end if; end Aspect_Specifications; -------------------------------- -- Aspects_On_Body_Or_Stub_OK -- -------------------------------- function Aspects_On_Body_Or_Stub_OK (N : Node_Id) return Boolean is Aspect : Node_Id; Aspects : List_Id; begin -- The routine should be invoked on a body [stub] with aspects pragma Assert (Has_Aspects (N)); pragma Assert (Nkind (N) in N_Body_Stub or else Nkind_In (N, N_Package_Body, N_Protected_Body, N_Subprogram_Body, N_Task_Body)); -- Look through all aspects and see whether they can be applied to a -- body [stub]. Aspects := Aspect_Specifications (N); Aspect := First (Aspects); while Present (Aspect) loop if not Aspect_On_Body_Or_Stub_OK (Get_Aspect_Id (Aspect)) then return False; end if; Next (Aspect); end loop; return True; end Aspects_On_Body_Or_Stub_OK; ---------------------- -- Exchange_Aspects -- ---------------------- procedure Exchange_Aspects (N1 : Node_Id; N2 : Node_Id) is begin pragma Assert (Permits_Aspect_Specifications (N1) and then Permits_Aspect_Specifications (N2)); -- Perform the exchange only when both nodes have lists to be swapped if Has_Aspects (N1) and then Has_Aspects (N2) then declare L1 : constant List_Id := Aspect_Specifications (N1); L2 : constant List_Id := Aspect_Specifications (N2); begin Set_Parent (L1, N2); Set_Parent (L2, N1); Aspect_Specifications_Hash_Table.Set (N1, L2); Aspect_Specifications_Hash_Table.Set (N2, L1); end; end if; end Exchange_Aspects; ----------------- -- Find_Aspect -- ----------------- function Find_Aspect (Id : Entity_Id; A : Aspect_Id) return Node_Id is Decl : Node_Id; Item : Node_Id; Owner : Entity_Id; Spec : Node_Id; begin Owner := Id; -- Handle various cases of base or inherited aspects for types if Is_Type (Id) then if Base_Aspect (A) then Owner := Base_Type (Owner); end if; if Is_Class_Wide_Type (Owner) and then Inherited_Aspect (A) then Owner := Root_Type (Owner); end if; if Is_Private_Type (Owner) and then Present (Full_View (Owner)) then Owner := Full_View (Owner); end if; end if; -- Search the representation items for the desired aspect Item := First_Rep_Item (Owner); while Present (Item) loop if Nkind (Item) = N_Aspect_Specification and then Get_Aspect_Id (Item) = A then return Item; end if; Next_Rep_Item (Item); end loop; -- Note that not all aspects are added to the chain of representation -- items. In such cases, search the list of aspect specifications. First -- find the declaration node where the aspects reside. This is usually -- the parent or the parent of the parent. Decl := Parent (Owner); if not Permits_Aspect_Specifications (Decl) then Decl := Parent (Decl); end if; -- Search the list of aspect specifications for the desired aspect if Permits_Aspect_Specifications (Decl) then Spec := First (Aspect_Specifications (Decl)); while Present (Spec) loop if Get_Aspect_Id (Spec) = A then return Spec; end if; Next (Spec); end loop; end if; -- The entity does not carry any aspects or the desired aspect was not -- found. return Empty; end Find_Aspect; -------------------------- -- Find_Value_Of_Aspect -- -------------------------- function Find_Value_Of_Aspect (Id : Entity_Id; A : Aspect_Id) return Node_Id is Spec : constant Node_Id := Find_Aspect (Id, A); begin if Present (Spec) then if A = Aspect_Default_Iterator then return Expression (Aspect_Rep_Item (Spec)); else return Expression (Spec); end if; end if; return Empty; end Find_Value_Of_Aspect; ------------------- -- Get_Aspect_Id -- ------------------- function Get_Aspect_Id (Name : Name_Id) return Aspect_Id is begin return Aspect_Id_Hash_Table.Get (Name); end Get_Aspect_Id; function Get_Aspect_Id (Aspect : Node_Id) return Aspect_Id is begin pragma Assert (Nkind (Aspect) = N_Aspect_Specification); return Aspect_Id_Hash_Table.Get (Chars (Identifier (Aspect))); end Get_Aspect_Id; ---------------- -- Has_Aspect -- ---------------- function Has_Aspect (Id : Entity_Id; A : Aspect_Id) return Boolean is begin return Present (Find_Aspect (Id, A)); end Has_Aspect; ------------------ -- Move_Aspects -- ------------------ procedure Move_Aspects (From : Node_Id; To : Node_Id) is pragma Assert (not Has_Aspects (To)); begin if Has_Aspects (From) then Set_Aspect_Specifications (To, Aspect_Specifications (From)); Aspect_Specifications_Hash_Table.Remove (From); Set_Has_Aspects (From, False); end if; end Move_Aspects; --------------------------- -- Move_Or_Merge_Aspects -- --------------------------- procedure Move_Or_Merge_Aspects (From : Node_Id; To : Node_Id) is procedure Relocate_Aspect (Asp : Node_Id); -- Asp denotes an aspect specification of node From. Relocate the Asp to -- the aspect specifications of node To (if any). --------------------- -- Relocate_Aspect -- --------------------- procedure Relocate_Aspect (Asp : Node_Id) is Asps : List_Id; begin if Has_Aspects (To) then Asps := Aspect_Specifications (To); -- Create a new aspect specification list for node To else Asps := New_List; Set_Aspect_Specifications (To, Asps); Set_Has_Aspects (To); end if; -- Remove the aspect from node From's aspect specifications and -- append it to node To. Remove (Asp); Append (Asp, Asps); end Relocate_Aspect; -- Local variables Asp : Node_Id; Asp_Id : Aspect_Id; Next_Asp : Node_Id; -- Start of processing for Move_Or_Merge_Aspects begin if Has_Aspects (From) then Asp := First (Aspect_Specifications (From)); while Present (Asp) loop -- Store the next aspect now as a potential relocation will alter -- the contents of the list. Next_Asp := Next (Asp); -- When moving or merging aspects from a subprogram body stub that -- also acts as a spec, relocate only those aspects that may apply -- to a body [stub]. Note that a precondition must also be moved -- to the proper body as the pre/post machinery expects it to be -- there. if Nkind (From) = N_Subprogram_Body_Stub and then No (Corresponding_Spec_Of_Stub (From)) then Asp_Id := Get_Aspect_Id (Asp); if Aspect_On_Body_Or_Stub_OK (Asp_Id) or else Asp_Id = Aspect_Pre or else Asp_Id = Aspect_Precondition then Relocate_Aspect (Asp); end if; -- Default case - relocate the aspect to its new owner else Relocate_Aspect (Asp); end if; Asp := Next_Asp; end loop; -- The relocations may have left node From's aspect specifications -- list empty. If this is the case, simply remove the aspects. if Is_Empty_List (Aspect_Specifications (From)) then Remove_Aspects (From); end if; end if; end Move_Or_Merge_Aspects; ----------------------------------- -- Permits_Aspect_Specifications -- ----------------------------------- Has_Aspect_Specifications_Flag : constant array (Node_Kind) of Boolean := (N_Abstract_Subprogram_Declaration => True, N_Component_Declaration => True, N_Entry_Declaration => True, N_Exception_Declaration => True, N_Exception_Renaming_Declaration => True, N_Expression_Function => True, N_Formal_Abstract_Subprogram_Declaration => True, N_Formal_Concrete_Subprogram_Declaration => True, N_Formal_Object_Declaration => True, N_Formal_Package_Declaration => True, N_Formal_Type_Declaration => True, N_Full_Type_Declaration => True, N_Function_Instantiation => True, N_Generic_Package_Declaration => True, N_Generic_Renaming_Declaration => True, N_Generic_Subprogram_Declaration => True, N_Object_Declaration => True, N_Object_Renaming_Declaration => True, N_Package_Body => True, N_Package_Body_Stub => True, N_Package_Declaration => True, N_Package_Instantiation => True, N_Package_Specification => True, N_Package_Renaming_Declaration => True, N_Private_Extension_Declaration => True, N_Private_Type_Declaration => True, N_Procedure_Instantiation => True, N_Protected_Body => True, N_Protected_Body_Stub => True, N_Protected_Type_Declaration => True, N_Single_Protected_Declaration => True, N_Single_Task_Declaration => True, N_Subprogram_Body => True, N_Subprogram_Body_Stub => True, N_Subprogram_Declaration => True, N_Subprogram_Renaming_Declaration => True, N_Subtype_Declaration => True, N_Task_Body => True, N_Task_Body_Stub => True, N_Task_Type_Declaration => True, others => False); function Permits_Aspect_Specifications (N : Node_Id) return Boolean is begin return Has_Aspect_Specifications_Flag (Nkind (N)); end Permits_Aspect_Specifications; -------------------- -- Remove_Aspects -- -------------------- procedure Remove_Aspects (N : Node_Id) is begin if Has_Aspects (N) then Aspect_Specifications_Hash_Table.Remove (N); Set_Has_Aspects (N, False); end if; end Remove_Aspects; ----------------- -- Same_Aspect -- ----------------- -- Table used for Same_Aspect, maps aspect to canonical aspect Canonical_Aspect : constant array (Aspect_Id) of Aspect_Id := (No_Aspect => No_Aspect, Aspect_Abstract_State => Aspect_Abstract_State, Aspect_Address => Aspect_Address, Aspect_Alignment => Aspect_Alignment, Aspect_All_Calls_Remote => Aspect_All_Calls_Remote, Aspect_Annotate => Aspect_Annotate, Aspect_Async_Readers => Aspect_Async_Readers, Aspect_Async_Writers => Aspect_Async_Writers, Aspect_Asynchronous => Aspect_Asynchronous, Aspect_Atomic => Aspect_Atomic, Aspect_Atomic_Components => Aspect_Atomic_Components, Aspect_Attach_Handler => Aspect_Attach_Handler, Aspect_Bit_Order => Aspect_Bit_Order, Aspect_Component_Size => Aspect_Component_Size, Aspect_Constant_Indexing => Aspect_Constant_Indexing, Aspect_Contract_Cases => Aspect_Contract_Cases, Aspect_Convention => Aspect_Convention, Aspect_CPU => Aspect_CPU, Aspect_Default_Component_Value => Aspect_Default_Component_Value, Aspect_Default_Initial_Condition => Aspect_Default_Initial_Condition, Aspect_Default_Iterator => Aspect_Default_Iterator, Aspect_Default_Storage_Pool => Aspect_Default_Storage_Pool, Aspect_Default_Value => Aspect_Default_Value, Aspect_Depends => Aspect_Depends, Aspect_Dimension => Aspect_Dimension, Aspect_Dimension_System => Aspect_Dimension_System, Aspect_Discard_Names => Aspect_Discard_Names, Aspect_Dispatching_Domain => Aspect_Dispatching_Domain, Aspect_Dynamic_Predicate => Aspect_Predicate, Aspect_Effective_Reads => Aspect_Effective_Reads, Aspect_Effective_Writes => Aspect_Effective_Writes, Aspect_Elaborate_Body => Aspect_Elaborate_Body, Aspect_Export => Aspect_Export, Aspect_Extensions_Visible => Aspect_Extensions_Visible, Aspect_External_Name => Aspect_External_Name, Aspect_External_Tag => Aspect_External_Tag, Aspect_Favor_Top_Level => Aspect_Favor_Top_Level, Aspect_Ghost => Aspect_Ghost, Aspect_Global => Aspect_Global, Aspect_Implicit_Dereference => Aspect_Implicit_Dereference, Aspect_Import => Aspect_Import, Aspect_Independent => Aspect_Independent, Aspect_Independent_Components => Aspect_Independent_Components, Aspect_Inline => Aspect_Inline, Aspect_Inline_Always => Aspect_Inline, Aspect_Initial_Condition => Aspect_Initial_Condition, Aspect_Initializes => Aspect_Initializes, Aspect_Input => Aspect_Input, Aspect_Interrupt_Handler => Aspect_Interrupt_Handler, Aspect_Interrupt_Priority => Aspect_Priority, Aspect_Invariant => Aspect_Invariant, Aspect_Iterable => Aspect_Iterable, Aspect_Iterator_Element => Aspect_Iterator_Element, Aspect_Link_Name => Aspect_Link_Name, Aspect_Linker_Section => Aspect_Linker_Section, Aspect_Lock_Free => Aspect_Lock_Free, Aspect_Machine_Radix => Aspect_Machine_Radix, Aspect_No_Elaboration_Code_All => Aspect_No_Elaboration_Code_All, Aspect_No_Return => Aspect_No_Return, Aspect_No_Tagged_Streams => Aspect_No_Tagged_Streams, Aspect_Obsolescent => Aspect_Obsolescent, Aspect_Object_Size => Aspect_Object_Size, Aspect_Output => Aspect_Output, Aspect_Pack => Aspect_Pack, Aspect_Part_Of => Aspect_Part_Of, Aspect_Persistent_BSS => Aspect_Persistent_BSS, Aspect_Post => Aspect_Post, Aspect_Postcondition => Aspect_Post, Aspect_Pre => Aspect_Pre, Aspect_Precondition => Aspect_Pre, Aspect_Predicate => Aspect_Predicate, Aspect_Preelaborate => Aspect_Preelaborate, Aspect_Preelaborable_Initialization => Aspect_Preelaborable_Initialization, Aspect_Priority => Aspect_Priority, Aspect_Pure => Aspect_Pure, Aspect_Pure_Function => Aspect_Pure_Function, Aspect_Refined_Depends => Aspect_Refined_Depends, Aspect_Refined_Global => Aspect_Refined_Global, Aspect_Refined_Post => Aspect_Refined_Post, Aspect_Refined_State => Aspect_Refined_State, Aspect_Remote_Access_Type => Aspect_Remote_Access_Type, Aspect_Remote_Call_Interface => Aspect_Remote_Call_Interface, Aspect_Remote_Types => Aspect_Remote_Types, Aspect_Read => Aspect_Read, Aspect_Relative_Deadline => Aspect_Relative_Deadline, Aspect_Scalar_Storage_Order => Aspect_Scalar_Storage_Order, Aspect_Shared => Aspect_Atomic, Aspect_Shared_Passive => Aspect_Shared_Passive, Aspect_Simple_Storage_Pool => Aspect_Simple_Storage_Pool, Aspect_Simple_Storage_Pool_Type => Aspect_Simple_Storage_Pool_Type, Aspect_Size => Aspect_Size, Aspect_Small => Aspect_Small, Aspect_SPARK_Mode => Aspect_SPARK_Mode, Aspect_Static_Predicate => Aspect_Predicate, Aspect_Storage_Pool => Aspect_Storage_Pool, Aspect_Storage_Size => Aspect_Storage_Size, Aspect_Stream_Size => Aspect_Stream_Size, Aspect_Suppress => Aspect_Suppress, Aspect_Suppress_Debug_Info => Aspect_Suppress_Debug_Info, Aspect_Suppress_Initialization => Aspect_Suppress_Initialization, Aspect_Synchronization => Aspect_Synchronization, Aspect_Test_Case => Aspect_Test_Case, Aspect_Thread_Local_Storage => Aspect_Thread_Local_Storage, Aspect_Type_Invariant => Aspect_Invariant, Aspect_Unchecked_Union => Aspect_Unchecked_Union, Aspect_Unimplemented => Aspect_Unimplemented, Aspect_Universal_Aliasing => Aspect_Universal_Aliasing, Aspect_Universal_Data => Aspect_Universal_Data, Aspect_Unmodified => Aspect_Unmodified, Aspect_Unreferenced => Aspect_Unreferenced, Aspect_Unreferenced_Objects => Aspect_Unreferenced_Objects, Aspect_Unsuppress => Aspect_Unsuppress, Aspect_Variable_Indexing => Aspect_Variable_Indexing, Aspect_Value_Size => Aspect_Value_Size, Aspect_Volatile => Aspect_Volatile, Aspect_Volatile_Components => Aspect_Volatile_Components, Aspect_Warnings => Aspect_Warnings, Aspect_Write => Aspect_Write); function Same_Aspect (A1 : Aspect_Id; A2 : Aspect_Id) return Boolean is begin return Canonical_Aspect (A1) = Canonical_Aspect (A2); end Same_Aspect; ------------------------------- -- Set_Aspect_Specifications -- ------------------------------- procedure Set_Aspect_Specifications (N : Node_Id; L : List_Id) is begin pragma Assert (Permits_Aspect_Specifications (N)); pragma Assert (not Has_Aspects (N)); pragma Assert (L /= No_List); Set_Has_Aspects (N); Set_Parent (L, N); Aspect_Specifications_Hash_Table.Set (N, L); end Set_Aspect_Specifications; ---------------------------------------- -- Set_Aspect_Specifications_No_Check -- ---------------------------------------- procedure Set_Aspect_Specifications_No_Check (N : Node_Id; L : List_Id) is begin pragma Assert (Permits_Aspect_Specifications (N)); pragma Assert (L /= No_List); Set_Has_Aspects (N); Set_Parent (L, N); Aspect_Specifications_Hash_Table.Set (N, L); end Set_Aspect_Specifications_No_Check; --------------- -- Tree_Read -- --------------- procedure Tree_Read is Node : Node_Id; List : List_Id; begin loop Tree_Read_Int (Int (Node)); Tree_Read_Int (Int (List)); exit when List = No_List; Set_Aspect_Specifications_No_Check (Node, List); end loop; end Tree_Read; ---------------- -- Tree_Write -- ---------------- procedure Tree_Write is Node : Node_Id := Empty; List : List_Id; begin Aspect_Specifications_Hash_Table.Get_First (Node, List); loop Tree_Write_Int (Int (Node)); Tree_Write_Int (Int (List)); exit when List = No_List; Aspect_Specifications_Hash_Table.Get_Next (Node, List); end loop; end Tree_Write; -- Package initialization sets up Aspect Id hash table begin for J in Aspect_Id loop Aspect_Id_Hash_Table.Set (Aspect_Names (J), J); end loop; end Aspects;