repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
AdaCore/libadalang
Ada
205
ads
package Test is type A; type A is private; private type A is record C, D : Integer; end record; type B; type C; type C is record X : Integer; end record; end Test;
zhmu/ananas
Ada
37,234
adb
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- ADA.CONTAINERS.INDEFINITE_HASHED_MAPS -- -- -- -- 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.Hash_Tables.Generic_Operations; pragma Elaborate_All (Ada.Containers.Hash_Tables.Generic_Operations); with Ada.Containers.Hash_Tables.Generic_Keys; pragma Elaborate_All (Ada.Containers.Hash_Tables.Generic_Keys); with Ada.Containers.Helpers; use Ada.Containers.Helpers; with Ada.Unchecked_Deallocation; with System; use type System.Address; with System.Put_Images; package body Ada.Containers.Indefinite_Hashed_Maps with SPARK_Mode => Off is pragma Warnings (Off, "variable ""Busy*"" is not referenced"); pragma Warnings (Off, "variable ""Lock*"" is not referenced"); -- See comment in Ada.Containers.Helpers procedure Free_Key is new Ada.Unchecked_Deallocation (Key_Type, Key_Access); procedure Free_Element is new Ada.Unchecked_Deallocation (Element_Type, Element_Access); ----------------------- -- Local Subprograms -- ----------------------- function Copy_Node (Node : Node_Access) return Node_Access; pragma Inline (Copy_Node); function Equivalent_Key_Node (Key : Key_Type; Node : Node_Access) return Boolean; pragma Inline (Equivalent_Key_Node); function Find_Equal_Key (R_HT : Hash_Table_Type; L_Node : Node_Access) return Boolean; procedure Free (X : in out Node_Access); -- pragma Inline (Free); function Hash_Node (Node : Node_Access) return Hash_Type; pragma Inline (Hash_Node); function Next (Node : Node_Access) return Node_Access; pragma Inline (Next); function Read_Node (Stream : not null access Root_Stream_Type'Class) return Node_Access; procedure Set_Next (Node : Node_Access; Next : Node_Access); pragma Inline (Set_Next); function Vet (Position : Cursor) return Boolean; procedure Write_Node (Stream : not null access Root_Stream_Type'Class; Node : Node_Access); -------------------------- -- Local Instantiations -- -------------------------- package HT_Ops is new Ada.Containers.Hash_Tables.Generic_Operations (HT_Types => HT_Types, Hash_Node => Hash_Node, Next => Next, Set_Next => Set_Next, Copy_Node => Copy_Node, Free => Free); package Key_Ops is new Hash_Tables.Generic_Keys (HT_Types => HT_Types, Next => Next, Set_Next => Set_Next, Key_Type => Key_Type, Hash => Hash, Equivalent_Keys => Equivalent_Key_Node); --------- -- "=" -- --------- function Is_Equal is new HT_Ops.Generic_Equal (Find_Equal_Key); overriding function "=" (Left, Right : Map) return Boolean is begin return Is_Equal (Left.HT, Right.HT); end "="; ------------ -- Adjust -- ------------ procedure Adjust (Container : in out Map) is begin HT_Ops.Adjust (Container.HT); end Adjust; ------------ -- Assign -- ------------ procedure Assign (Target : in out Map; Source : Map) is procedure Insert_Item (Node : Node_Access); pragma Inline (Insert_Item); procedure Insert_Items is new HT_Ops.Generic_Iteration (Insert_Item); ----------------- -- Insert_Item -- ----------------- procedure Insert_Item (Node : Node_Access) is begin Target.Insert (Key => Node.Key.all, New_Item => Node.Element.all); end Insert_Item; -- Start of processing for Assign begin if Target'Address = Source'Address then return; end if; Target.Clear; if Target.Capacity < Source.Length then Target.Reserve_Capacity (Source.Length); end if; Insert_Items (Source.HT); end Assign; -------------- -- Capacity -- -------------- function Capacity (Container : Map) return Count_Type is begin return HT_Ops.Capacity (Container.HT); end Capacity; ----------- -- Clear -- ----------- procedure Clear (Container : in out Map) is begin HT_Ops.Clear (Container.HT); end Clear; ------------------------ -- Constant_Reference -- ------------------------ function Constant_Reference (Container : aliased Map; Position : Cursor) return Constant_Reference_Type is begin if Checks and then Position.Container = null then raise Constraint_Error with "Position cursor has no element"; end if; if Checks and then Position.Container /= Container'Unrestricted_Access then raise Program_Error with "Position cursor designates wrong map"; end if; if Checks and then Position.Node.Element = null then raise Program_Error with "Position cursor has no element"; end if; pragma Assert (Vet (Position), "Position cursor in Constant_Reference is bad"); declare M : Map renames Position.Container.all; HT : Hash_Table_Type renames M.HT'Unrestricted_Access.all; TC : constant Tamper_Counts_Access := HT.TC'Unrestricted_Access; begin return R : constant Constant_Reference_Type := (Element => Position.Node.Element.all'Access, Control => (Controlled with TC)) do Busy (TC.all); end return; end; end Constant_Reference; function Constant_Reference (Container : aliased Map; Key : Key_Type) return Constant_Reference_Type is HT : Hash_Table_Type renames Container'Unrestricted_Access.HT; Node : constant Node_Access := Key_Ops.Find (HT, Key); begin if Checks and then Node = null then raise Constraint_Error with "key not in map"; end if; if Checks and then Node.Element = null then raise Program_Error with "key has no element"; end if; declare TC : constant Tamper_Counts_Access := HT.TC'Unrestricted_Access; begin return R : constant Constant_Reference_Type := (Element => Node.Element.all'Access, Control => (Controlled with TC)) do Busy (TC.all); end return; end; end Constant_Reference; -------------- -- Contains -- -------------- function Contains (Container : Map; Key : Key_Type) return Boolean is begin return Find (Container, Key) /= No_Element; end Contains; ---------- -- Copy -- ---------- function Copy (Source : Map; Capacity : Count_Type := 0) return Map is C : Count_Type; begin if Capacity < Source.Length then if Checks and then Capacity /= 0 then raise Capacity_Error with "Requested capacity is less than Source length"; end if; C := Source.Length; else C := Capacity; end if; return Target : Map do Target.Reserve_Capacity (C); Target.Assign (Source); end return; end Copy; --------------- -- Copy_Node -- --------------- function Copy_Node (Node : Node_Access) return Node_Access is K : Key_Access := new Key_Type'(Node.Key.all); E : Element_Access; begin E := new Element_Type'(Node.Element.all); return new Node_Type'(K, E, null); exception when others => Free_Key (K); Free_Element (E); raise; end Copy_Node; ------------ -- Delete -- ------------ procedure Delete (Container : in out Map; Key : Key_Type) is X : Node_Access; begin Key_Ops.Delete_Key_Sans_Free (Container.HT, Key, X); if Checks and then X = null then raise Constraint_Error with "attempt to delete key not in map"; end if; Free (X); end Delete; procedure Delete (Container : in out Map; Position : in out Cursor) is begin TC_Check (Container.HT.TC); if Checks and then Position.Node = null then raise Constraint_Error with "Position cursor of Delete equals No_Element"; end if; if Checks and then Position.Container /= Container'Unrestricted_Access then raise Program_Error with "Position cursor of Delete designates wrong map"; end if; pragma Assert (Vet (Position), "bad cursor in Delete"); HT_Ops.Delete_Node_Sans_Free (Container.HT, Position.Node); Free (Position.Node); Position.Container := null; Position.Position := No_Element.Position; pragma Assert (Position = No_Element); end Delete; ------------- -- Element -- ------------- function Element (Container : Map; Key : Key_Type) return Element_Type is HT : Hash_Table_Type renames Container'Unrestricted_Access.HT; Node : constant Node_Access := Key_Ops.Find (HT, Key); begin if Checks and then Node = null then raise Constraint_Error with "no element available because key not in map"; end if; return Node.Element.all; end Element; function Element (Position : Cursor) return Element_Type is begin if Checks and then Position.Node = null then raise Constraint_Error with "Position cursor of function Element equals No_Element"; end if; if Checks and then Position.Node.Element = null then raise Program_Error with "Position cursor of function Element is bad"; end if; pragma Assert (Vet (Position), "bad cursor in function Element"); return Position.Node.Element.all; end Element; ----------- -- Empty -- ----------- function Empty (Capacity : Count_Type := 1000) return Map is begin return Result : Map do Reserve_Capacity (Result, Capacity); end return; end Empty; ------------------------- -- Equivalent_Key_Node -- ------------------------- function Equivalent_Key_Node (Key : Key_Type; Node : Node_Access) return Boolean is begin return Equivalent_Keys (Key, Node.Key.all); end Equivalent_Key_Node; --------------------- -- Equivalent_Keys -- --------------------- function Equivalent_Keys (Left, Right : Cursor) return Boolean is begin if Checks and then Left.Node = null then raise Constraint_Error with "Left cursor of Equivalent_Keys equals No_Element"; end if; if Checks and then Right.Node = null then raise Constraint_Error with "Right cursor of Equivalent_Keys equals No_Element"; end if; if Checks and then Left.Node.Key = null then raise Program_Error with "Left cursor of Equivalent_Keys is bad"; end if; if Checks and then Right.Node.Key = null then raise Program_Error with "Right cursor of Equivalent_Keys is bad"; end if; pragma Assert (Vet (Left), "bad Left cursor in Equivalent_Keys"); pragma Assert (Vet (Right), "bad Right cursor in Equivalent_Keys"); return Equivalent_Keys (Left.Node.Key.all, Right.Node.Key.all); end Equivalent_Keys; function Equivalent_Keys (Left : Cursor; Right : Key_Type) return Boolean is begin if Checks and then Left.Node = null then raise Constraint_Error with "Left cursor of Equivalent_Keys equals No_Element"; end if; if Checks and then Left.Node.Key = null then raise Program_Error with "Left cursor of Equivalent_Keys is bad"; end if; pragma Assert (Vet (Left), "bad Left cursor in Equivalent_Keys"); return Equivalent_Keys (Left.Node.Key.all, Right); end Equivalent_Keys; function Equivalent_Keys (Left : Key_Type; Right : Cursor) return Boolean is begin if Checks and then Right.Node = null then raise Constraint_Error with "Right cursor of Equivalent_Keys equals No_Element"; end if; if Checks and then Right.Node.Key = null then raise Program_Error with "Right cursor of Equivalent_Keys is bad"; end if; pragma Assert (Vet (Right), "bad Right cursor in Equivalent_Keys"); return Equivalent_Keys (Left, Right.Node.Key.all); end Equivalent_Keys; ------------- -- Exclude -- ------------- procedure Exclude (Container : in out Map; Key : Key_Type) is X : Node_Access; begin Key_Ops.Delete_Key_Sans_Free (Container.HT, Key, X); Free (X); end Exclude; -------------- -- Finalize -- -------------- procedure Finalize (Container : in out Map) is begin HT_Ops.Finalize (Container.HT); end Finalize; procedure Finalize (Object : in out Iterator) is begin if Object.Container /= null then Unbusy (Object.Container.HT.TC); end if; end Finalize; ---------- -- Find -- ---------- function Find (Container : Map; Key : Key_Type) return Cursor is HT : Hash_Table_Type renames Container'Unrestricted_Access.HT; Node : constant Node_Access := Key_Ops.Find (HT, Key); begin if Node = null then return No_Element; end if; return Cursor' (Container'Unrestricted_Access, Node, HT_Ops.Index (HT, Node)); end Find; -------------------- -- Find_Equal_Key -- -------------------- function Find_Equal_Key (R_HT : Hash_Table_Type; L_Node : Node_Access) return Boolean is R_Index : constant Hash_Type := Key_Ops.Index (R_HT, L_Node.Key.all); R_Node : Node_Access := R_HT.Buckets (R_Index); begin while R_Node /= null loop if Equivalent_Keys (L_Node.Key.all, R_Node.Key.all) then return L_Node.Element.all = R_Node.Element.all; end if; R_Node := R_Node.Next; end loop; return False; end Find_Equal_Key; ----------- -- First -- ----------- function First (Container : Map) return Cursor is Pos : Hash_Type; Node : constant Node_Access := HT_Ops.First (Container.HT, Pos); begin if Node = null then return No_Element; else return Cursor'(Container'Unrestricted_Access, Node, Pos); end if; end First; function First (Object : Iterator) return Cursor is begin return Object.Container.First; end First; ---------- -- Free -- ---------- procedure Free (X : in out Node_Access) is procedure Deallocate is new Ada.Unchecked_Deallocation (Node_Type, Node_Access); begin if X = null then return; end if; X.Next := X; -- detect mischief (in Vet) begin Free_Key (X.Key); exception when others => X.Key := null; begin Free_Element (X.Element); exception when others => X.Element := null; end; Deallocate (X); raise; end; begin Free_Element (X.Element); exception when others => X.Element := null; Deallocate (X); raise; end; Deallocate (X); end Free; ------------------------ -- Get_Element_Access -- ------------------------ function Get_Element_Access (Position : Cursor) return not null Element_Access is begin return Position.Node.Element; end Get_Element_Access; ----------------- -- Has_Element -- ----------------- function Has_Element (Position : Cursor) return Boolean is begin pragma Assert (Vet (Position), "bad cursor in Has_Element"); return Position.Node /= null; end Has_Element; --------------- -- Hash_Node -- --------------- function Hash_Node (Node : Node_Access) return Hash_Type is begin return Hash (Node.Key.all); end Hash_Node; ------------- -- Include -- ------------- procedure Include (Container : in out Map; Key : Key_Type; New_Item : Element_Type) is Position : Cursor; Inserted : Boolean; K : Key_Access; E : Element_Access; begin Insert (Container, Key, New_Item, Position, Inserted); if not Inserted then TE_Check (Container.HT.TC); K := Position.Node.Key; E := Position.Node.Element; Position.Node.Key := new Key_Type'(Key); declare -- The element allocator may need an accessibility check in the -- case the actual type is class-wide or has access discriminants -- (see RM 4.8(10.1) and AI12-0035). pragma Unsuppress (Accessibility_Check); begin Position.Node.Element := new Element_Type'(New_Item); exception when others => Free_Key (K); raise; end; Free_Key (K); Free_Element (E); end if; end Include; ------------ -- Insert -- ------------ procedure Insert (Container : in out Map; Key : Key_Type; New_Item : Element_Type; Position : out Cursor; Inserted : out Boolean) is function New_Node (Next : Node_Access) return Node_Access; procedure Local_Insert is new Key_Ops.Generic_Conditional_Insert (New_Node); -------------- -- New_Node -- -------------- function New_Node (Next : Node_Access) return Node_Access is K : Key_Access := new Key_Type'(Key); E : Element_Access; -- The element allocator may need an accessibility check in the case -- the actual type is class-wide or has access discriminants (see -- RM 4.8(10.1) and AI12-0035). pragma Unsuppress (Accessibility_Check); begin E := new Element_Type'(New_Item); return new Node_Type'(K, E, Next); exception when others => Free_Key (K); Free_Element (E); raise; end New_Node; HT : Hash_Table_Type renames Container.HT; -- Start of processing for Insert begin if HT_Ops.Capacity (HT) = 0 then HT_Ops.Reserve_Capacity (HT, 1); end if; Local_Insert (HT, Key, Position.Node, Inserted); if Inserted and then HT.Length > HT_Ops.Capacity (HT) then HT_Ops.Reserve_Capacity (HT, HT.Length); end if; Position.Container := Container'Unchecked_Access; Position.Position := HT_Ops.Index (HT, Position.Node); end Insert; procedure Insert (Container : in out Map; Key : Key_Type; New_Item : Element_Type) is Position : Cursor; Inserted : Boolean; begin Insert (Container, Key, New_Item, Position, Inserted); if Checks and then not Inserted then raise Constraint_Error with "attempt to insert key already in map"; end if; end Insert; -------------- -- Is_Empty -- -------------- function Is_Empty (Container : Map) return Boolean is begin return Container.HT.Length = 0; end Is_Empty; ------------- -- Iterate -- ------------- procedure Iterate (Container : Map; Process : not null access procedure (Position : Cursor)) is procedure Process_Node (Node : Node_Access; Position : Hash_Type); pragma Inline (Process_Node); procedure Local_Iterate is new HT_Ops.Generic_Iteration_With_Position (Process_Node); ------------------ -- Process_Node -- ------------------ procedure Process_Node (Node : Node_Access; Position : Hash_Type) is begin Process (Cursor'(Container'Unrestricted_Access, Node, Position)); end Process_Node; Busy : With_Busy (Container.HT.TC'Unrestricted_Access); -- Start of processing for Iterate begin Local_Iterate (Container.HT); end Iterate; function Iterate (Container : Map) return Map_Iterator_Interfaces.Forward_Iterator'Class is begin return It : constant Iterator := (Limited_Controlled with Container => Container'Unrestricted_Access) do Busy (Container.HT.TC'Unrestricted_Access.all); end return; end Iterate; --------- -- Key -- --------- function Key (Position : Cursor) return Key_Type is begin if Checks and then Position.Node = null then raise Constraint_Error with "Position cursor of function Key equals No_Element"; end if; if Checks and then Position.Node.Key = null then raise Program_Error with "Position cursor of function Key is bad"; end if; pragma Assert (Vet (Position), "bad cursor in function Key"); return Position.Node.Key.all; end Key; ------------ -- Length -- ------------ function Length (Container : Map) return Count_Type is begin return Container.HT.Length; end Length; ---------- -- Move -- ---------- procedure Move (Target : in out Map; Source : in out Map) is begin HT_Ops.Move (Target => Target.HT, Source => Source.HT); end Move; ---------- -- Next -- ---------- function Next (Node : Node_Access) return Node_Access is begin return Node.Next; end Next; procedure Next (Position : in out Cursor) is begin Position := Next (Position); end Next; function Next (Position : Cursor) return Cursor is Node : Node_Access; Pos : Hash_Type; begin if Position.Node = null then return No_Element; end if; if Checks and then (Position.Node.Key = null or else Position.Node.Element = null) then raise Program_Error with "Position cursor of Next is bad"; end if; pragma Assert (Vet (Position), "Position cursor of Next is bad"); Pos := Position.Position; Node := HT_Ops.Next (Position.Container.HT, Position.Node, Pos); if Node = null then return No_Element; else return Cursor'(Position.Container, Node, Pos); end if; end Next; function Next (Object : Iterator; Position : Cursor) return Cursor is begin if Position.Container = null then return No_Element; end if; if Checks and then Position.Container /= Object.Container then raise Program_Error with "Position cursor of Next designates wrong map"; end if; return Next (Position); end Next; ---------------------- -- Pseudo_Reference -- ---------------------- function Pseudo_Reference (Container : aliased Map'Class) return Reference_Control_Type is TC : constant Tamper_Counts_Access := Container.HT.TC'Unrestricted_Access; begin return R : constant Reference_Control_Type := (Controlled with TC) do Busy (TC.all); end return; end Pseudo_Reference; ------------------- -- Query_Element -- ------------------- procedure Query_Element (Position : Cursor; Process : not null access procedure (Key : Key_Type; Element : Element_Type)) is begin if Checks and then Position.Node = null then raise Constraint_Error with "Position cursor of Query_Element equals No_Element"; end if; if Checks and then (Position.Node.Key = null or else Position.Node.Element = null) then raise Program_Error with "Position cursor of Query_Element is bad"; end if; pragma Assert (Vet (Position), "bad cursor in Query_Element"); declare M : Map renames Position.Container.all; HT : Hash_Table_Type renames M.HT'Unrestricted_Access.all; Lock : With_Lock (HT.TC'Unrestricted_Access); K : Key_Type renames Position.Node.Key.all; E : Element_Type renames Position.Node.Element.all; begin Process (K, E); end; end Query_Element; --------------- -- Put_Image -- --------------- procedure Put_Image (S : in out Ada.Strings.Text_Buffers.Root_Buffer_Type'Class; V : Map) is First_Time : Boolean := True; use System.Put_Images; procedure Put_Key_Value (Position : Cursor); procedure Put_Key_Value (Position : Cursor) is begin if First_Time then First_Time := False; else Simple_Array_Between (S); end if; Key_Type'Put_Image (S, Key (Position)); Put_Arrow (S); Element_Type'Put_Image (S, Element (Position)); end Put_Key_Value; begin Array_Before (S); Iterate (V, Put_Key_Value'Access); Array_After (S); end Put_Image; ---------- -- Read -- ---------- procedure Read_Nodes is new HT_Ops.Generic_Read (Read_Node); procedure Read (Stream : not null access Root_Stream_Type'Class; Container : out Map) is begin Read_Nodes (Stream, Container.HT); end Read; procedure Read (Stream : not null access Root_Stream_Type'Class; Item : out Cursor) is begin raise Program_Error with "attempt to stream map cursor"; end Read; procedure Read (Stream : not null access Root_Stream_Type'Class; Item : out Reference_Type) is begin raise Program_Error with "attempt to stream reference"; end Read; procedure Read (Stream : not null access Root_Stream_Type'Class; Item : out Constant_Reference_Type) is begin raise Program_Error with "attempt to stream reference"; end Read; --------------- -- Read_Node -- --------------- function Read_Node (Stream : not null access Root_Stream_Type'Class) return Node_Access is Node : Node_Access := new Node_Type; begin begin Node.Key := new Key_Type'(Key_Type'Input (Stream)); exception when others => Free (Node); raise; end; begin Node.Element := new Element_Type'(Element_Type'Input (Stream)); exception when others => Free_Key (Node.Key); Free (Node); raise; end; return Node; end Read_Node; --------------- -- Reference -- --------------- function Reference (Container : aliased in out Map; Position : Cursor) return Reference_Type is begin if Checks and then Position.Container = null then raise Constraint_Error with "Position cursor has no element"; end if; if Checks and then Position.Container /= Container'Unrestricted_Access then raise Program_Error with "Position cursor designates wrong map"; end if; if Checks and then Position.Node.Element = null then raise Program_Error with "Position cursor has no element"; end if; pragma Assert (Vet (Position), "Position cursor in function Reference is bad"); declare M : Map renames Position.Container.all; HT : Hash_Table_Type renames M.HT'Unrestricted_Access.all; TC : constant Tamper_Counts_Access := HT.TC'Unrestricted_Access; begin return R : constant Reference_Type := (Element => Position.Node.Element.all'Access, Control => (Controlled with TC)) do Busy (TC.all); end return; end; end Reference; function Reference (Container : aliased in out Map; Key : Key_Type) return Reference_Type is HT : Hash_Table_Type renames Container.HT; Node : constant Node_Access := Key_Ops.Find (HT, Key); begin if Checks and then Node = null then raise Constraint_Error with "key not in map"; end if; if Checks and then Node.Element = null then raise Program_Error with "key has no element"; end if; declare TC : constant Tamper_Counts_Access := HT.TC'Unrestricted_Access; begin return R : constant Reference_Type := (Element => Node.Element.all'Access, Control => (Controlled with TC)) do Busy (TC.all); end return; end; end Reference; ------------- -- Replace -- ------------- procedure Replace (Container : in out Map; Key : Key_Type; New_Item : Element_Type) is Node : constant Node_Access := Key_Ops.Find (Container.HT, Key); K : Key_Access; E : Element_Access; begin TE_Check (Container.HT.TC); if Checks and then Node = null then raise Constraint_Error with "attempt to replace key not in map"; end if; K := Node.Key; E := Node.Element; Node.Key := new Key_Type'(Key); declare -- The element allocator may need an accessibility check in the case -- the actual type is class-wide or has access discriminants (see -- RM 4.8(10.1) and AI12-0035). pragma Unsuppress (Accessibility_Check); begin Node.Element := new Element_Type'(New_Item); exception when others => Free_Key (K); raise; end; Free_Key (K); Free_Element (E); end Replace; --------------------- -- Replace_Element -- --------------------- procedure Replace_Element (Container : in out Map; Position : Cursor; New_Item : Element_Type) is begin TE_Check (Position.Container.HT.TC); if Checks and then Position.Node = null then raise Constraint_Error with "Position cursor of Replace_Element equals No_Element"; end if; if Checks and then (Position.Node.Key = null or else Position.Node.Element = null) then raise Program_Error with "Position cursor of Replace_Element is bad"; end if; if Checks and then Position.Container /= Container'Unrestricted_Access then raise Program_Error with "Position cursor of Replace_Element designates wrong map"; end if; pragma Assert (Vet (Position), "bad cursor in Replace_Element"); declare X : Element_Access := Position.Node.Element; -- The element allocator may need an accessibility check in the case -- the actual type is class-wide or has access discriminants (see -- RM 4.8(10.1) and AI12-0035). pragma Unsuppress (Accessibility_Check); begin Position.Node.Element := new Element_Type'(New_Item); Free_Element (X); end; end Replace_Element; ---------------------- -- Reserve_Capacity -- ---------------------- procedure Reserve_Capacity (Container : in out Map; Capacity : Count_Type) is begin HT_Ops.Reserve_Capacity (Container.HT, Capacity); end Reserve_Capacity; -------------- -- Set_Next -- -------------- procedure Set_Next (Node : Node_Access; Next : Node_Access) is begin Node.Next := Next; end Set_Next; -------------------- -- Update_Element -- -------------------- procedure Update_Element (Container : in out Map; Position : Cursor; Process : not null access procedure (Key : Key_Type; Element : in out Element_Type)) is begin if Checks and then Position.Node = null then raise Constraint_Error with "Position cursor of Update_Element equals No_Element"; end if; if Checks and then (Position.Node.Key = null or else Position.Node.Element = null) then raise Program_Error with "Position cursor of Update_Element is bad"; end if; if Checks and then Position.Container /= Container'Unrestricted_Access then raise Program_Error with "Position cursor of Update_Element designates wrong map"; end if; pragma Assert (Vet (Position), "bad cursor in Update_Element"); declare HT : Hash_Table_Type renames Container.HT; Lock : With_Lock (HT.TC'Unrestricted_Access); K : Key_Type renames Position.Node.Key.all; E : Element_Type renames Position.Node.Element.all; begin Process (K, E); end; end Update_Element; --------- -- Vet -- --------- function Vet (Position : Cursor) return Boolean is begin if Position.Node = null then return Position.Container = null; end if; if Position.Container = null then return False; end if; if Position.Node.Next = Position.Node then return False; end if; if Position.Node.Key = null then return False; end if; if Position.Node.Element = null then return False; end if; declare HT : Hash_Table_Type renames Position.Container.HT; X : Node_Access; begin if HT.Length = 0 then return False; end if; if HT.Buckets = null or else HT.Buckets'Length = 0 then return False; end if; X := HT.Buckets (Key_Ops.Checked_Index (HT, Position.Node.Key.all)); for J in 1 .. HT.Length loop if X = Position.Node then return True; end if; if X = null then return False; end if; if X = X.Next then -- to prevent unnecessary looping return False; end if; X := X.Next; end loop; return False; end; end Vet; ----------- -- Write -- ----------- procedure Write_Nodes is new HT_Ops.Generic_Write (Write_Node); procedure Write (Stream : not null access Root_Stream_Type'Class; Container : Map) is begin Write_Nodes (Stream, Container.HT); end Write; procedure Write (Stream : not null access Root_Stream_Type'Class; Item : Cursor) is begin raise Program_Error with "attempt to stream map cursor"; end Write; procedure Write (Stream : not null access Root_Stream_Type'Class; Item : Reference_Type) is begin raise Program_Error with "attempt to stream reference"; end Write; procedure Write (Stream : not null access Root_Stream_Type'Class; Item : Constant_Reference_Type) is begin raise Program_Error with "attempt to stream reference"; end Write; ---------------- -- Write_Node -- ---------------- procedure Write_Node (Stream : not null access Root_Stream_Type'Class; Node : Node_Access) is begin Key_Type'Output (Stream, Node.Key.all); Element_Type'Output (Stream, Node.Element.all); end Write_Node; end Ada.Containers.Indefinite_Hashed_Maps;
AdaCore/gpr
Ada
182
ads
package p2_2 is function p2_2_0 (Item : Integer) return Integer; function p2_2_1 (Item : Integer) return Integer; function p2_2_2 (Item : Integer) return Integer; end p2_2;
AdaCore/gpr
Ada
52
ads
package Code is Dummy : constant := 4; end Code;
reznikmm/matreshka
Ada
3,684
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.Table_Sort_Groups_Elements is pragma Preelaborate; type ODF_Table_Sort_Groups is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Table_Sort_Groups_Access is access all ODF_Table_Sort_Groups'Class with Storage_Size => 0; end ODF.DOM.Table_Sort_Groups_Elements;
reznikmm/matreshka
Ada
4,065
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Text_Anchor_Page_Number_Attributes; package Matreshka.ODF_Text.Anchor_Page_Number_Attributes is type Text_Anchor_Page_Number_Attribute_Node is new Matreshka.ODF_Text.Abstract_Text_Attribute_Node and ODF.DOM.Text_Anchor_Page_Number_Attributes.ODF_Text_Anchor_Page_Number_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Text_Anchor_Page_Number_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Text_Anchor_Page_Number_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Text.Anchor_Page_Number_Attributes;
pdaxrom/Kino2
Ada
4,374
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding -- -- -- -- Terminal_Interface.Curses.Forms.Field_Types.Enumeration.Ada -- -- -- -- 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, 1996 -- Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en -- Version Control: -- $Revision: 1.6 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ with Ada.Characters.Handling; use Ada.Characters.Handling; package body Terminal_Interface.Curses.Forms.Field_Types.Enumeration.Ada is function Create (Set : Type_Set := Mixed_Case; Case_Sensitive : Boolean := False; Must_Be_Unique : Boolean := False) return Enumeration_Field is I : Enumeration_Info (T'Pos (T'Last) - T'Pos (T'First) + 1); J : Positive := 1; begin I.Case_Sensitive := Case_Sensitive; I.Match_Must_Be_Unique := Must_Be_Unique; for E in T'Range loop I.Names (J) := new String'(T'Image (T (E))); -- The Image attribute defaults to upper case, so we have to handle -- only the other ones... if Set /= Upper_Case then I.Names (J).all := To_Lower (I.Names (J).all); if Set = Mixed_Case then I.Names (J)(I.Names (J).all'First) := To_Upper (I.Names (J)(I.Names (J).all'First)); end if; end if; J := J + 1; end loop; return Create (I, True); end Create; function Value (Fld : Field; Buf : Buffer_Number := Buffer_Number'First) return T is begin return T'Value (Get_Buffer (Fld, Buf)); end Value; end Terminal_Interface.Curses.Forms.Field_Types.Enumeration.Ada;
caqg/linux-home
Ada
5,870
ads
-- Abstract : -- -- Ada implementation of: -- -- [1] ada-wisi-elisp-parse.el -- [2] ada-indent-user-options.el -- -- Copyright (C) 2017 - 2019 Free Software Foundation, Inc. -- -- This library is free software; you can redistribute it and/or modify it -- under terms of the GNU General Public License as published by the Free -- Software Foundation; either version 3, or (at your option) any later -- version. This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- As a special exception under Section 7 of GPL version 3, you are granted -- additional permissions described in the GCC Runtime Library Exception, -- version 3.1, as published by the Free Software Foundation. pragma License (Modified_GPL); package Wisi.Ada is Language_Protocol_Version : constant String := "1"; -- Defines the data passed to Initialize in Params. -- -- This value must match ada-wisi.el -- ada-wisi-language-protocol-version. -- -- Only changes once per ada-mode release. Increment as soon as -- required, record new version in NEWS-ada-mode.text. -- Indent parameters from [2] Ada_Indent : Integer := 3; Ada_Indent_Broken : Integer := 2; Ada_Indent_Comment_Col_0 : Boolean := False; Ada_Indent_Comment_GNAT : Boolean := False; Ada_Indent_Label : Integer := -3; Ada_Indent_Record_Rel_Type : Integer := 3; Ada_Indent_Renames : Integer := 2; Ada_Indent_Return : Integer := 0; Ada_Indent_Use : Integer := 2; Ada_Indent_When : Integer := 3; Ada_Indent_With : Integer := 2; Ada_Indent_Hanging_Rel_Exp : Boolean := False; -- Other parameters End_Names_Optional : Boolean := False; type Parse_Data_Type is new Wisi.Parse_Data_Type with null record; overriding procedure Initialize (Data : in out Parse_Data_Type; Descriptor : access constant WisiToken.Descriptor; Source_File_Name : in String; Post_Parse_Action : in Post_Parse_Action_Type; Begin_Line : in WisiToken.Line_Number_Type; End_Line : in WisiToken.Line_Number_Type; Begin_Indent : in Integer; Params : in String); -- Call Wisi_Runtime.Initialize, then: -- -- If Params /= "", set all language-specific parameters from Params, -- in declaration order; otherwise keep default values. Boolean is -- represented by 0 | 1. Parameter values are space delimited. -- -- Also do any other initialization that Data needs. overriding function Indent_Hanging_1 (Data : in out Parse_Data_Type; Tree : in WisiToken.Syntax_Trees.Tree; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array; Tree_Indenting : in WisiToken.Syntax_Trees.Valid_Node_Index; Indenting_Comment : in Boolean; Delta_1 : in Simple_Indent_Param; Delta_2 : in Simple_Indent_Param; Option : in Boolean; Accumulate : in Boolean) return Delta_Type; -- [1] ada-wisi-elisp-parse--indent-hanging ---------- -- The following are declared in ada.wy %elisp_indent, and must match -- Language_Indent_Function. function Ada_Indent_Aggregate (Data : in out Wisi.Parse_Data_Type'Class; Tree : in WisiToken.Syntax_Trees.Tree; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array; Tree_Indenting : in WisiToken.Syntax_Trees.Valid_Node_Index; Indenting_Comment : in Boolean; Args : in Wisi.Indent_Arg_Arrays.Vector) return Wisi.Delta_Type; -- [1] ada-indent-aggregate function Ada_Indent_Renames_0 (Data : in out Wisi.Parse_Data_Type'Class; Tree : in WisiToken.Syntax_Trees.Tree; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array; Tree_Indenting : in WisiToken.Syntax_Trees.Valid_Node_Index; Indenting_Comment : in Boolean; Args : in Wisi.Indent_Arg_Arrays.Vector) return Wisi.Delta_Type; -- [1] ada-indent-renames function Ada_Indent_Return_0 (Data : in out Wisi.Parse_Data_Type'Class; Tree : in WisiToken.Syntax_Trees.Tree; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array; Tree_Indenting : in WisiToken.Syntax_Trees.Valid_Node_Index; Indenting_Comment : in Boolean; Args : in Wisi.Indent_Arg_Arrays.Vector) return Wisi.Delta_Type; -- [1] ada-indent-return function Ada_Indent_Record_0 (Data : in out Wisi.Parse_Data_Type'Class; Tree : in WisiToken.Syntax_Trees.Tree; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array; Tree_Indenting : in WisiToken.Syntax_Trees.Valid_Node_Index; Indenting_Comment : in Boolean; Args : in Wisi.Indent_Arg_Arrays.Vector) return Wisi.Delta_Type; -- [1] ada-indent-record function Ada_Indent_Record_1 (Data : in out Wisi.Parse_Data_Type'Class; Tree : in WisiToken.Syntax_Trees.Tree; Tokens : in WisiToken.Syntax_Trees.Valid_Node_Index_Array; Tree_Indenting : in WisiToken.Syntax_Trees.Valid_Node_Index; Indenting_Comment : in Boolean; Args : in Wisi.Indent_Arg_Arrays.Vector) return Wisi.Delta_Type; -- [1] ada-indent-record* end Wisi.Ada;
reznikmm/matreshka
Ada
4,288
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- OpenGL Framework -- -- -- -- Runtime Library 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$ ------------------------------------------------------------------------------ private with Ada.Finalization; with League.Strings; package OpenGL.Shaders is pragma Preelaborate; type OpenGL_Shader is tagged private; procedure Create (Self : in out OpenGL_Shader'Class; Shader_Type : OpenGL.Shader_Type); -- Creates shader of specified type. procedure Compile_Source_Code (Self : in out OpenGL_Shader'Class; Code : League.Strings.Universal_String); -- Sets the source code for this shader and compiles it. Returns True if -- the source was successfully compiled, False otherwise. function Shader_Id (Self : OpenGL_Shader'Class) return OpenGL.GLuint; -- Returns the OpenGL identifier associated with this shader. private type Shader_Shared_Data; type Shader_Shared_Data_Access is access all Shader_Shared_Data; type OpenGL_Shader is new Ada.Finalization.Controlled with record Data : Shader_Shared_Data_Access; end record; end OpenGL.Shaders;
reznikmm/matreshka
Ada
3,709
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Table_Filter_Condition_Elements is pragma Preelaborate; type ODF_Table_Filter_Condition is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Table_Filter_Condition_Access is access all ODF_Table_Filter_Condition'Class with Storage_Size => 0; end ODF.DOM.Table_Filter_Condition_Elements;
zhmu/ananas
Ada
43,554
adb
------------------------------------------------------------------------------ -- -- -- GNAT LIBRARY COMPONENTS -- -- -- -- ADA.CONTAINERS.FORMAL_INDEFINITE_VECTORS -- -- -- -- B o d y -- -- -- -- Copyright (C) 2010-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/>. -- ------------------------------------------------------------------------------ with Ada.Containers.Generic_Array_Sort; with Ada.Unchecked_Deallocation; with System; use type System.Address; package body Ada.Containers.Formal_Indefinite_Vectors with SPARK_Mode => Off is function H (New_Item : Element_Type) return Holder renames To_Holder; function E (Container : Holder) return Element_Type renames Get; Growth_Factor : constant := 2; -- When growing a container, multiply current capacity by this. Doubling -- leads to amortized linear-time copying. subtype Int is Long_Long_Integer; procedure Free is new Ada.Unchecked_Deallocation (Elements_Array, Elements_Array_Ptr); type Maximal_Array_Ptr is access all Elements_Array (Array_Index) with Storage_Size => 0; type Maximal_Array_Ptr_Const is access constant Elements_Array (Array_Index) with Storage_Size => 0; function Elems (Container : in out Vector) return Maximal_Array_Ptr; function Elemsc (Container : Vector) return Maximal_Array_Ptr_Const; -- Returns a pointer to the Elements array currently in use -- either -- Container.Elements_Ptr or a pointer to Container.Elements. We work with -- pointers to a bogus array subtype that is constrained with the maximum -- possible bounds. This means that the pointer is a thin pointer. This is -- necessary because 'Unrestricted_Access doesn't work when it produces -- access-to-unconstrained and is returned from a function. -- -- Note that this is dangerous: make sure calls to this use an indexed -- component or slice that is within the bounds 1 .. Length (Container). function Get_Element (Container : Vector; Position : Capacity_Range) return Element_Type; function To_Array_Index (Index : Index_Type'Base) return Count_Type'Base; function Current_Capacity (Container : Vector) return Capacity_Range; procedure Insert_Space (Container : in out Vector; Before : Extended_Index; Count : Count_Type := 1); --------- -- "=" -- --------- function "=" (Left : Vector; Right : Vector) return Boolean is begin if Left'Address = Right'Address then return True; end if; if Length (Left) /= Length (Right) then return False; end if; for J in 1 .. Length (Left) loop if Get_Element (Left, J) /= Get_Element (Right, J) then return False; end if; end loop; return True; end "="; ------------ -- Append -- ------------ procedure Append (Container : in out Vector; New_Item : Vector) is begin if Is_Empty (New_Item) then return; end if; if Container.Last >= Index_Type'Last then raise Constraint_Error with "vector is already at its maximum length"; end if; Insert (Container, Container.Last + 1, New_Item); end Append; procedure Append (Container : in out Vector; New_Item : Element_Type) is begin Append (Container, New_Item, 1); end Append; procedure Append (Container : in out Vector; New_Item : Element_Type; Count : Count_Type) is begin if Count = 0 then return; end if; if Container.Last >= Index_Type'Last then raise Constraint_Error with "vector is already at its maximum length"; end if; Insert (Container, Container.Last + 1, New_Item, Count); end Append; ------------ -- Assign -- ------------ procedure Assign (Target : in out Vector; Source : Vector) is LS : constant Capacity_Range := Length (Source); begin if Target'Address = Source'Address then return; end if; if Bounded and then Target.Capacity < LS then raise Constraint_Error; end if; Clear (Target); Append (Target, Source); end Assign; -------------- -- Capacity -- -------------- function Capacity (Container : Vector) return Capacity_Range is begin return (if Bounded then Container.Capacity else Capacity_Range'Last); end Capacity; ----------- -- Clear -- ----------- procedure Clear (Container : in out Vector) is begin Container.Last := No_Index; -- Free element, note that this is OK if Elements_Ptr is null Free (Container.Elements_Ptr); end Clear; ------------------------ -- Constant_Reference -- ------------------------ function Constant_Reference (Container : aliased Vector; Index : Index_Type) return not null access constant Element_Type is begin if Index > Container.Last then raise Constraint_Error with "Index is out of range"; end if; declare II : constant Int'Base := Int (Index) - Int (No_Index); I : constant Capacity_Range := Capacity_Range (II); begin return Constant_Reference (Elemsc (Container) (I)); end; end Constant_Reference; -------------- -- Contains -- -------------- function Contains (Container : Vector; Item : Element_Type) return Boolean is begin return Find_Index (Container, Item) /= No_Index; end Contains; ---------- -- Copy -- ---------- function Copy (Source : Vector; Capacity : Capacity_Range := 0) return Vector is LS : constant Capacity_Range := Length (Source); C : Capacity_Range; begin if Capacity = 0 then C := LS; elsif Capacity >= LS then C := Capacity; else raise Capacity_Error; end if; return Target : Vector (C) do Elems (Target) (1 .. LS) := Elemsc (Source) (1 .. LS); Target.Last := Source.Last; end return; end Copy; ---------------------- -- Current_Capacity -- ---------------------- function Current_Capacity (Container : Vector) return Capacity_Range is begin return (if Container.Elements_Ptr = null then Container.Elements'Length else Container.Elements_Ptr.all'Length); end Current_Capacity; ------------ -- Delete -- ------------ procedure Delete (Container : in out Vector; Index : Extended_Index) is begin Delete (Container, Index, 1); end Delete; procedure Delete (Container : in out Vector; Index : Extended_Index; Count : Count_Type) is Old_Last : constant Index_Type'Base := Container.Last; Old_Len : constant Count_Type := Length (Container); New_Last : Index_Type'Base; Count2 : Count_Type'Base; -- count of items from Index to Old_Last Off : Count_Type'Base; -- Index expressed as offset from IT'First begin -- Delete removes items from the vector, the number of which is the -- minimum of the specified Count and the items (if any) that exist from -- Index to Container.Last. There are no constraints on the specified -- value of Count (it can be larger than what's available at this -- position in the vector, for example), but there are constraints on -- the allowed values of the Index. -- As a precondition on the generic actual Index_Type, the base type -- must include Index_Type'Pred (Index_Type'First); this is the value -- that Container.Last assumes when the vector is empty. However, we do -- not allow that as the value for Index when specifying which items -- should be deleted, so we must manually check. (That the user is -- allowed to specify the value at all here is a consequence of the -- declaration of the Extended_Index subtype, which includes the values -- in the base range that immediately precede and immediately follow the -- values in the Index_Type.) if Index < Index_Type'First then raise Constraint_Error with "Index is out of range (too small)"; end if; -- We do allow a value greater than Container.Last to be specified as -- the Index, but only if it's immediately greater. This allows the -- corner case of deleting no items from the back end of the vector to -- be treated as a no-op. (It is assumed that specifying an index value -- greater than Last + 1 indicates some deeper flaw in the caller's -- algorithm, so that case is treated as a proper error.) if Index > Old_Last then if Index > Old_Last + 1 then raise Constraint_Error with "Index is out of range (too large)"; end if; return; end if; if Count = 0 then return; end if; -- We first calculate what's available for deletion starting at -- Index. Here and elsewhere we use the wider of Index_Type'Base and -- Count_Type'Base as the type for intermediate values. (See function -- Length for more information.) if Count_Type'Base'Last >= Index_Type'Pos (Index_Type'Base'Last) then Count2 := Count_Type'Base (Old_Last) - Count_Type'Base (Index) + 1; else Count2 := Count_Type'Base (Old_Last - Index + 1); end if; -- If more elements are requested (Count) for deletion than are -- available (Count2) for deletion beginning at Index, then everything -- from Index is deleted. There are no elements to slide down, and so -- all we need to do is set the value of Container.Last. if Count >= Count2 then Container.Last := Index - 1; return; end if; -- There are some elements that aren't being deleted (the requested -- count was less than the available count), so we must slide them down -- to Index. We first calculate the index values of the respective array -- slices, using the wider of Index_Type'Base and Count_Type'Base as the -- type for intermediate calculations. if Index_Type'Base'Last >= Count_Type'Pos (Count_Type'Last) then Off := Count_Type'Base (Index - Index_Type'First); New_Last := Old_Last - Index_Type'Base (Count); else Off := Count_Type'Base (Index) - Count_Type'Base (Index_Type'First); New_Last := Index_Type'Base (Count_Type'Base (Old_Last) - Count); end if; -- The array index values for each slice have already been determined, -- so we just slide down to Index the elements that weren't deleted. declare EA : Maximal_Array_Ptr renames Elems (Container); Idx : constant Count_Type := EA'First + Off; begin EA (Idx .. Old_Len - Count) := EA (Idx + Count .. Old_Len); Container.Last := New_Last; end; end Delete; ------------------ -- Delete_First -- ------------------ procedure Delete_First (Container : in out Vector) is begin Delete_First (Container, 1); end Delete_First; procedure Delete_First (Container : in out Vector; Count : Count_Type) is begin if Count = 0 then return; elsif Count >= Length (Container) then Clear (Container); return; else Delete (Container, Index_Type'First, Count); end if; end Delete_First; ----------------- -- Delete_Last -- ----------------- procedure Delete_Last (Container : in out Vector) is begin Delete_Last (Container, 1); end Delete_Last; procedure Delete_Last (Container : in out Vector; Count : Count_Type) is begin if Count = 0 then return; end if; -- There is no restriction on how large Count can be when deleting -- items. If it is equal or greater than the current length, then this -- is equivalent to clearing the vector. (In particular, there's no need -- for us to actually calculate the new value for Last.) -- If the requested count is less than the current length, then we must -- calculate the new value for Last. For the type we use the widest of -- Index_Type'Base and Count_Type'Base for the intermediate values of -- our calculation. (See the comments in Length for more information.) if Count >= Length (Container) then Container.Last := No_Index; elsif Index_Type'Base'Last >= Count_Type'Pos (Count_Type'Last) then Container.Last := Container.Last - Index_Type'Base (Count); else Container.Last := Index_Type'Base (Count_Type'Base (Container.Last) - Count); end if; end Delete_Last; ------------- -- Element -- ------------- function Element (Container : Vector; Index : Index_Type) return Element_Type is begin if Index > Container.Last then raise Constraint_Error with "Index is out of range"; end if; declare II : constant Int'Base := Int (Index) - Int (No_Index); I : constant Capacity_Range := Capacity_Range (II); begin return Get_Element (Container, I); end; end Element; ----------- -- Elems -- ----------- function Elems (Container : in out Vector) return Maximal_Array_Ptr is begin return (if Container.Elements_Ptr = null then Container.Elements'Unrestricted_Access else Container.Elements_Ptr.all'Unrestricted_Access); end Elems; function Elemsc (Container : Vector) return Maximal_Array_Ptr_Const is begin return (if Container.Elements_Ptr = null then Container.Elements'Unrestricted_Access else Container.Elements_Ptr.all'Unrestricted_Access); end Elemsc; ---------------- -- Find_Index -- ---------------- function Find_Index (Container : Vector; Item : Element_Type; Index : Index_Type := Index_Type'First) return Extended_Index is K : Count_Type; Last : constant Extended_Index := Last_Index (Container); begin K := Capacity_Range (Int (Index) - Int (No_Index)); for Indx in Index .. Last loop if Get_Element (Container, K) = Item then return Indx; end if; K := K + 1; end loop; return No_Index; end Find_Index; ------------------- -- First_Element -- ------------------- function First_Element (Container : Vector) return Element_Type is begin if Is_Empty (Container) then raise Constraint_Error with "Container is empty"; else return Get_Element (Container, 1); end if; end First_Element; ----------------- -- First_Index -- ----------------- function First_Index (Container : Vector) return Index_Type is pragma Unreferenced (Container); begin return Index_Type'First; end First_Index; ------------------ -- Formal_Model -- ------------------ package body Formal_Model is ------------------------- -- M_Elements_In_Union -- ------------------------- function M_Elements_In_Union (Container : M.Sequence; Left : M.Sequence; Right : M.Sequence) return Boolean is begin for Index in Index_Type'First .. M.Last (Container) loop declare Elem : constant Element_Type := Element (Container, Index); begin if not M.Contains (Left, Index_Type'First, M.Last (Left), Elem) and then not M.Contains (Right, Index_Type'First, M.Last (Right), Elem) then return False; end if; end; end loop; return True; end M_Elements_In_Union; ------------------------- -- M_Elements_Included -- ------------------------- function M_Elements_Included (Left : M.Sequence; L_Fst : Index_Type := Index_Type'First; L_Lst : Extended_Index; Right : M.Sequence; R_Fst : Index_Type := Index_Type'First; R_Lst : Extended_Index) return Boolean is begin for I in L_Fst .. L_Lst loop declare Found : Boolean := False; J : Extended_Index := R_Fst - 1; begin while not Found and J < R_Lst loop J := J + 1; if Element (Left, I) = Element (Right, J) then Found := True; end if; end loop; if not Found then return False; end if; end; end loop; return True; end M_Elements_Included; ------------------------- -- M_Elements_Reversed -- ------------------------- function M_Elements_Reversed (Left : M.Sequence; Right : M.Sequence) return Boolean is L : constant Index_Type := M.Last (Left); begin if L /= M.Last (Right) then return False; end if; for I in Index_Type'First .. L loop if Element (Left, I) /= Element (Right, L - I + 1) then return False; end if; end loop; return True; end M_Elements_Reversed; ------------------------ -- M_Elements_Swapped -- ------------------------ function M_Elements_Swapped (Left : M.Sequence; Right : M.Sequence; X : Index_Type; Y : Index_Type) return Boolean is begin if M.Length (Left) /= M.Length (Right) or else Element (Left, X) /= Element (Right, Y) or else Element (Left, Y) /= Element (Right, X) then return False; end if; for I in Index_Type'First .. M.Last (Left) loop if I /= X and then I /= Y and then Element (Left, I) /= Element (Right, I) then return False; end if; end loop; return True; end M_Elements_Swapped; ----------- -- Model -- ----------- function Model (Container : Vector) return M.Sequence is R : M.Sequence; begin for Position in 1 .. Length (Container) loop R := M.Add (R, E (Elemsc (Container) (Position))); end loop; return R; end Model; end Formal_Model; --------------------- -- Generic_Sorting -- --------------------- package body Generic_Sorting with SPARK_Mode => Off is ------------------ -- Formal_Model -- ------------------ package body Formal_Model is ----------------------- -- M_Elements_Sorted -- ----------------------- function M_Elements_Sorted (Container : M.Sequence) return Boolean is begin if M.Length (Container) = 0 then return True; end if; declare E1 : Element_Type := Element (Container, Index_Type'First); begin for I in Index_Type'First + 1 .. M.Last (Container) loop declare E2 : constant Element_Type := Element (Container, I); begin if E2 < E1 then return False; end if; E1 := E2; end; end loop; end; return True; end M_Elements_Sorted; end Formal_Model; --------------- -- Is_Sorted -- --------------- function Is_Sorted (Container : Vector) return Boolean is L : constant Capacity_Range := Length (Container); begin for J in 1 .. L - 1 loop if Get_Element (Container, J + 1) < Get_Element (Container, J) then return False; end if; end loop; return True; end Is_Sorted; ---------- -- Sort -- ---------- procedure Sort (Container : in out Vector) is function "<" (Left : Holder; Right : Holder) return Boolean is (E (Left) < E (Right)); procedure Sort is new Generic_Array_Sort (Index_Type => Array_Index, Element_Type => Holder, Array_Type => Elements_Array, "<" => "<"); Len : constant Capacity_Range := Length (Container); begin if Container.Last <= Index_Type'First then return; else Sort (Elems (Container) (1 .. Len)); end if; end Sort; ----------- -- Merge -- ----------- procedure Merge (Target : in out Vector; Source : in out Vector) is I : Count_Type; J : Count_Type; begin if Target'Address = Source'Address then raise Program_Error with "Target and Source denote same container"; end if; if Length (Source) = 0 then return; end if; if Length (Target) = 0 then Move (Target => Target, Source => Source); return; end if; I := Length (Target); declare New_Length : constant Count_Type := I + Length (Source); begin if not Bounded and then Current_Capacity (Target) < Capacity_Range (New_Length) then Reserve_Capacity (Target, Capacity_Range'Max (Current_Capacity (Target) * Growth_Factor, Capacity_Range (New_Length))); end if; if Index_Type'Base'Last >= Count_Type'Pos (Count_Type'Last) then Target.Last := No_Index + Index_Type'Base (New_Length); else Target.Last := Index_Type'Base (Count_Type'Base (No_Index) + New_Length); end if; end; declare TA : Maximal_Array_Ptr renames Elems (Target); SA : Maximal_Array_Ptr renames Elems (Source); begin J := Length (Target); while Length (Source) /= 0 loop if I = 0 then TA (1 .. J) := SA (1 .. Length (Source)); Source.Last := No_Index; exit; end if; if E (SA (Length (Source))) < E (TA (I)) then TA (J) := TA (I); I := I - 1; else TA (J) := SA (Length (Source)); Source.Last := Source.Last - 1; end if; J := J - 1; end loop; end; end Merge; end Generic_Sorting; ----------------- -- Get_Element -- ----------------- function Get_Element (Container : Vector; Position : Capacity_Range) return Element_Type is begin return E (Elemsc (Container) (Position)); end Get_Element; ----------------- -- Has_Element -- ----------------- function Has_Element (Container : Vector; Position : Extended_Index) return Boolean is begin return Position in First_Index (Container) .. Last_Index (Container); end Has_Element; ------------ -- Insert -- ------------ procedure Insert (Container : in out Vector; Before : Extended_Index; New_Item : Element_Type) is begin Insert (Container, Before, New_Item, 1); end Insert; procedure Insert (Container : in out Vector; Before : Extended_Index; New_Item : Element_Type; Count : Count_Type) is J : Count_Type'Base; -- scratch begin -- Use Insert_Space to create the "hole" (the destination slice) Insert_Space (Container, Before, Count); J := To_Array_Index (Before); Elems (Container) (J .. J - 1 + Count) := [others => H (New_Item)]; end Insert; procedure Insert (Container : in out Vector; Before : Extended_Index; New_Item : Vector) is N : constant Count_Type := Length (New_Item); B : Count_Type; -- index Before converted to Count_Type begin if Container'Address = New_Item'Address then raise Program_Error with "Container and New_Item denote same container"; end if; -- Use Insert_Space to create the "hole" (the destination slice) into -- which we copy the source items. Insert_Space (Container, Before, Count => N); if N = 0 then -- There's nothing else to do here (vetting of parameters was -- performed already in Insert_Space), so we simply return. return; end if; B := To_Array_Index (Before); Elems (Container) (B .. B + N - 1) := Elemsc (New_Item) (1 .. N); end Insert; ------------------ -- Insert_Space -- ------------------ procedure Insert_Space (Container : in out Vector; Before : Extended_Index; Count : Count_Type := 1) is Old_Length : constant Count_Type := Length (Container); Max_Length : Count_Type'Base; -- determined from range of Index_Type New_Length : Count_Type'Base; -- sum of current length and Count Index : Index_Type'Base; -- scratch for intermediate values J : Count_Type'Base; -- scratch begin -- As a precondition on the generic actual Index_Type, the base type -- must include Index_Type'Pred (Index_Type'First); this is the value -- that Container.Last assumes when the vector is empty. However, we do -- not allow that as the value for Index when specifying where the new -- items should be inserted, so we must manually check. (That the user -- is allowed to specify the value at all here is a consequence of the -- declaration of the Extended_Index subtype, which includes the values -- in the base range that immediately precede and immediately follow the -- values in the Index_Type.) if Before < Index_Type'First then raise Constraint_Error with "Before index is out of range (too small)"; end if; -- We do allow a value greater than Container.Last to be specified as -- the Index, but only if it's immediately greater. This allows for the -- case of appending items to the back end of the vector. (It is assumed -- that specifying an index value greater than Last + 1 indicates some -- deeper flaw in the caller's algorithm, so that case is treated as a -- proper error.) if Before > Container.Last and then Before - 1 > Container.Last then raise Constraint_Error with "Before index is out of range (too large)"; end if; -- We treat inserting 0 items into the container as a no-op, so we -- simply return. if Count = 0 then return; end if; -- There are two constraints we need to satisfy. The first constraint is -- that a container cannot have more than Count_Type'Last elements, so -- we must check the sum of the current length and the insertion -- count. Note that we cannot simply add these values, because of the -- possibility of overflow. if Old_Length > Count_Type'Last - Count then raise Constraint_Error with "Count is out of range"; end if; -- It is now safe compute the length of the new vector, without fear of -- overflow. New_Length := Old_Length + Count; -- The second constraint is that the new Last index value cannot exceed -- Index_Type'Last. In each branch below, we calculate the maximum -- length (computed from the range of values in Index_Type), and then -- compare the new length to the maximum length. If the new length is -- acceptable, then we compute the new last index from that. if Index_Type'Base'Last >= Count_Type'Pos (Count_Type'Last) then -- We have to handle the case when there might be more values in the -- range of Index_Type than in the range of Count_Type. if Index_Type'First <= 0 then -- We know that No_Index (the same as Index_Type'First - 1) is -- less than 0, so it is safe to compute the following sum without -- fear of overflow. Index := No_Index + Index_Type'Base (Count_Type'Last); if Index <= Index_Type'Last then -- We have determined that range of Index_Type has at least as -- many values as in Count_Type, so Count_Type'Last is the -- maximum number of items that are allowed. Max_Length := Count_Type'Last; else -- The range of Index_Type has fewer values than in Count_Type, -- so the maximum number of items is computed from the range of -- the Index_Type. Max_Length := Count_Type'Base (Index_Type'Last - No_Index); end if; else -- No_Index is equal or greater than 0, so we can safely compute -- the difference without fear of overflow (which we would have to -- worry about if No_Index were less than 0, but that case is -- handled above). if Index_Type'Last - No_Index >= Count_Type'Pos (Count_Type'Last) then -- We have determined that range of Index_Type has at least as -- many values as in Count_Type, so Count_Type'Last is the -- maximum number of items that are allowed. Max_Length := Count_Type'Last; else -- The range of Index_Type has fewer values than in Count_Type, -- so the maximum number of items is computed from the range of -- the Index_Type. Max_Length := Count_Type'Base (Index_Type'Last - No_Index); end if; end if; elsif Index_Type'First <= 0 then -- We know that No_Index (the same as Index_Type'First - 1) is less -- than 0, so it is safe to compute the following sum without fear of -- overflow. J := Count_Type'Base (No_Index) + Count_Type'Last; if J <= Count_Type'Base (Index_Type'Last) then -- We have determined that range of Index_Type has at least as -- many values as in Count_Type, so Count_Type'Last is the maximum -- number of items that are allowed. Max_Length := Count_Type'Last; else -- The range of Index_Type has fewer values than Count_Type does, -- so the maximum number of items is computed from the range of -- the Index_Type. Max_Length := Count_Type'Base (Index_Type'Last) - Count_Type'Base (No_Index); end if; else -- No_Index is equal or greater than 0, so we can safely compute the -- difference without fear of overflow (which we would have to worry -- about if No_Index were less than 0, but that case is handled -- above). Max_Length := Count_Type'Base (Index_Type'Last) - Count_Type'Base (No_Index); end if; -- We have just computed the maximum length (number of items). We must -- now compare the requested length to the maximum length, as we do not -- allow a vector expand beyond the maximum (because that would create -- an internal array with a last index value greater than -- Index_Type'Last, with no way to index those elements). if New_Length > Max_Length then raise Constraint_Error with "Count is out of range"; end if; J := To_Array_Index (Before); -- Increase the capacity of container if needed if not Bounded and then Current_Capacity (Container) < Capacity_Range (New_Length) then Reserve_Capacity (Container, Capacity_Range'Max (Current_Capacity (Container) * Growth_Factor, Capacity_Range (New_Length))); end if; declare EA : Maximal_Array_Ptr renames Elems (Container); begin if Before <= Container.Last then -- The new items are being inserted before some existing -- elements, so we must slide the existing elements up to their -- new home. EA (J + Count .. New_Length) := EA (J .. Old_Length); end if; end; if Index_Type'Base'Last >= Count_Type'Pos (Count_Type'Last) then Container.Last := No_Index + Index_Type'Base (New_Length); else Container.Last := Index_Type'Base (Count_Type'Base (No_Index) + New_Length); end if; end Insert_Space; -------------- -- Is_Empty -- -------------- function Is_Empty (Container : Vector) return Boolean is begin return Last_Index (Container) < Index_Type'First; end Is_Empty; ------------------ -- Last_Element -- ------------------ function Last_Element (Container : Vector) return Element_Type is begin if Is_Empty (Container) then raise Constraint_Error with "Container is empty"; else return Get_Element (Container, Length (Container)); end if; end Last_Element; ---------------- -- Last_Index -- ---------------- function Last_Index (Container : Vector) return Extended_Index is begin return Container.Last; end Last_Index; ------------ -- Length -- ------------ function Length (Container : Vector) return Capacity_Range is L : constant Int := Int (Container.Last); F : constant Int := Int (Index_Type'First); N : constant Int'Base := L - F + 1; begin return Capacity_Range (N); end Length; ---------- -- Move -- ---------- procedure Move (Target : in out Vector; Source : in out Vector) is LS : constant Capacity_Range := Length (Source); begin if Target'Address = Source'Address then return; end if; if Bounded and then Target.Capacity < LS then raise Constraint_Error; end if; Clear (Target); Append (Target, Source); Clear (Source); end Move; ------------ -- Prepend -- ------------ procedure Prepend (Container : in out Vector; New_Item : Vector) is begin Insert (Container, Index_Type'First, New_Item); end Prepend; procedure Prepend (Container : in out Vector; New_Item : Element_Type) is begin Prepend (Container, New_Item, 1); end Prepend; procedure Prepend (Container : in out Vector; New_Item : Element_Type; Count : Count_Type) is begin Insert (Container, Index_Type'First, New_Item, Count); end Prepend; --------------- -- Reference -- --------------- function Reference (Container : not null access Vector; Index : Index_Type) return not null access Element_Type is begin if Index > Container.Last then raise Constraint_Error with "Index is out of range"; end if; declare II : constant Int'Base := Int (Index) - Int (No_Index); I : constant Capacity_Range := Capacity_Range (II); begin if Container.Elements_Ptr = null then return Reference (Container.Elements (I)'Access); else return Reference (Container.Elements_Ptr (I)'Access); end if; end; end Reference; --------------------- -- Replace_Element -- --------------------- procedure Replace_Element (Container : in out Vector; Index : Index_Type; New_Item : Element_Type) is begin if Index > Container.Last then raise Constraint_Error with "Index is out of range"; end if; declare II : constant Int'Base := Int (Index) - Int (No_Index); I : constant Capacity_Range := Capacity_Range (II); begin Elems (Container) (I) := H (New_Item); end; end Replace_Element; ---------------------- -- Reserve_Capacity -- ---------------------- procedure Reserve_Capacity (Container : in out Vector; Capacity : Capacity_Range) is begin if Bounded then if Capacity > Container.Capacity then raise Constraint_Error with "Capacity is out of range"; end if; else if Capacity > Current_Capacity (Container) then declare New_Elements : constant Elements_Array_Ptr := new Elements_Array (1 .. Capacity); L : constant Capacity_Range := Length (Container); begin New_Elements (1 .. L) := Elemsc (Container) (1 .. L); Free (Container.Elements_Ptr); Container.Elements_Ptr := New_Elements; end; end if; end if; end Reserve_Capacity; ---------------------- -- Reverse_Elements -- ---------------------- procedure Reverse_Elements (Container : in out Vector) is begin if Length (Container) <= 1 then return; end if; declare I : Capacity_Range; J : Capacity_Range; E : Elements_Array renames Elems (Container) (1 .. Length (Container)); begin I := 1; J := Length (Container); while I < J loop declare EI : constant Holder := E (I); begin E (I) := E (J); E (J) := EI; end; I := I + 1; J := J - 1; end loop; end; end Reverse_Elements; ------------------------ -- Reverse_Find_Index -- ------------------------ function Reverse_Find_Index (Container : Vector; Item : Element_Type; Index : Index_Type := Index_Type'Last) return Extended_Index is Last : Index_Type'Base; K : Count_Type'Base; begin if Index > Last_Index (Container) then Last := Last_Index (Container); else Last := Index; end if; K := Capacity_Range (Int (Last) - Int (No_Index)); for Indx in reverse Index_Type'First .. Last loop if Get_Element (Container, K) = Item then return Indx; end if; K := K - 1; end loop; return No_Index; end Reverse_Find_Index; ---------- -- Swap -- ---------- procedure Swap (Container : in out Vector; I : Index_Type; J : Index_Type) is begin if I > Container.Last then raise Constraint_Error with "I index is out of range"; end if; if J > Container.Last then raise Constraint_Error with "J index is out of range"; end if; if I = J then return; end if; declare II : constant Int'Base := Int (I) - Int (No_Index); JJ : constant Int'Base := Int (J) - Int (No_Index); EI : Holder renames Elems (Container) (Capacity_Range (II)); EJ : Holder renames Elems (Container) (Capacity_Range (JJ)); EI_Copy : constant Holder := EI; begin EI := EJ; EJ := EI_Copy; end; end Swap; -------------------- -- To_Array_Index -- -------------------- function To_Array_Index (Index : Index_Type'Base) return Count_Type'Base is Offset : Count_Type'Base; begin -- We know that -- Index >= Index_Type'First -- hence we also know that -- Index - Index_Type'First >= 0 -- The issue is that even though 0 is guaranteed to be a value in the -- type Index_Type'Base, there's no guarantee that the difference is a -- value in that type. To prevent overflow we use the wider of -- Count_Type'Base and Index_Type'Base to perform intermediate -- calculations. if Index_Type'Base'Last >= Count_Type'Pos (Count_Type'Last) then Offset := Count_Type'Base (Index - Index_Type'First); else Offset := Count_Type'Base (Index) - Count_Type'Base (Index_Type'First); end if; -- The array index subtype for all container element arrays always -- starts with 1. return 1 + Offset; end To_Array_Index; --------------- -- To_Vector -- --------------- function To_Vector (New_Item : Element_Type; Length : Capacity_Range) return Vector is begin if Length = 0 then return Empty_Vector; end if; declare First : constant Int := Int (Index_Type'First); Last_As_Int : constant Int'Base := First + Int (Length) - 1; Last : Index_Type; begin if Last_As_Int > Index_Type'Pos (Index_Type'Last) then raise Constraint_Error with "Length is out of range"; -- ??? end if; Last := Index_Type (Last_As_Int); return (Capacity => Length, Last => Last, Elements_Ptr => <>, Elements => [others => H (New_Item)]); end; end To_Vector; end Ada.Containers.Formal_Indefinite_Vectors;
Heziode/lsystem-editor
Ada
1,958
ads
------------------------------------------------------------------------------- -- LSE -- L-System Editor -- Author: Heziode -- -- License: -- MIT License -- -- Copyright (c) 2018 Quentin Dauprat (Heziode) <[email protected]> -- -- Permission is hereby granted, free of charge, to any person obtaining a -- copy of this software and associated documentation files (the "Software"), -- to deal in the Software without restriction, including without limitation -- the rights to use, copy, modify, merge, publish, distribute, sublicense, -- and/or sell copies of the Software, and to permit persons to whom the -- Software is furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in -- all copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -- DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------- with LSE.Model.IO.Turtle_Utils; with LSE.Model.Grammar.Symbol; use LSE.Model.IO.Turtle_Utils; use LSE.Model.Grammar.Symbol; -- @description -- This package provides right rotation LOGO Turtle Symbol. -- package LSE.Model.Grammar.Symbol.LogoAnglePlus is type Instance is new LSE.Model.Grammar.Symbol.Instance with null record; overriding procedure Initialize (This : out Instance); overriding procedure Interpret (This : in out Instance; T : in out Holder); end LSE.Model.Grammar.Symbol.LogoAnglePlus;
reznikmm/matreshka
Ada
4,688
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Table.Structure_Protected_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Table_Structure_Protected_Attribute_Node is begin return Self : Table_Structure_Protected_Attribute_Node do Matreshka.ODF_Table.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Table_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Table_Structure_Protected_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Structure_Protected_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Table_URI, Matreshka.ODF_String_Constants.Structure_Protected_Attribute, Table_Structure_Protected_Attribute_Node'Tag); end Matreshka.ODF_Table.Structure_Protected_Attributes;
stcarrez/helios
Ada
953
ads
----------------------------------------------------------------------- -- helios -- Helios Fast Reliable Monitoring Agent -- Copyright (C) 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 Interfaces; package Helios is subtype Uint64 is Interfaces.Unsigned_64; end Helios;
AdaCore/Ada_Drivers_Library
Ada
13,128
ads
-- This spec has been automatically generated from STM32F429x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.GPIO is pragma Preelaborate; --------------- -- Registers -- --------------- -- MODER array element subtype MODER_Element is HAL.UInt2; -- MODER array type MODER_Field_Array is array (0 .. 15) of MODER_Element with Component_Size => 2, Size => 32; -- GPIO port mode register type MODER_Register (As_Array : Boolean := False) is record case As_Array is when False => -- MODER as a value Val : HAL.UInt32; when True => -- MODER as an array Arr : MODER_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for MODER_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- OTYPER_OT array type OTYPER_OT_Field_Array is array (0 .. 15) of Boolean with Component_Size => 1, Size => 16; -- Type definition for OTYPER_OT type OTYPER_OT_Field (As_Array : Boolean := False) is record case As_Array is when False => -- OT as a value Val : HAL.UInt16; when True => -- OT as an array Arr : OTYPER_OT_Field_Array; end case; end record with Unchecked_Union, Size => 16; for OTYPER_OT_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- GPIO port output type register type OTYPER_Register is record -- Port x configuration bits (y = 0..15) OT : OTYPER_OT_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTYPER_Register use record OT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -- OSPEEDR array element subtype OSPEEDR_Element is HAL.UInt2; -- OSPEEDR array type OSPEEDR_Field_Array is array (0 .. 15) of OSPEEDR_Element with Component_Size => 2, Size => 32; -- GPIO port output speed register type OSPEEDR_Register (As_Array : Boolean := False) is record case As_Array is when False => -- OSPEEDR as a value Val : HAL.UInt32; when True => -- OSPEEDR as an array Arr : OSPEEDR_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for OSPEEDR_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- PUPDR array element subtype PUPDR_Element is HAL.UInt2; -- PUPDR array type PUPDR_Field_Array is array (0 .. 15) of PUPDR_Element with Component_Size => 2, Size => 32; -- GPIO port pull-up/pull-down register type PUPDR_Register (As_Array : Boolean := False) is record case As_Array is when False => -- PUPDR as a value Val : HAL.UInt32; when True => -- PUPDR as an array Arr : PUPDR_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for PUPDR_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- IDR array type IDR_Field_Array is array (0 .. 15) of Boolean with Component_Size => 1, Size => 16; -- Type definition for IDR type IDR_Field (As_Array : Boolean := False) is record case As_Array is when False => -- IDR as a value Val : HAL.UInt16; when True => -- IDR as an array Arr : IDR_Field_Array; end case; end record with Unchecked_Union, Size => 16; for IDR_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- GPIO port input data register type IDR_Register is record -- Read-only. Port input data (y = 0..15) IDR : IDR_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for IDR_Register use record IDR at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -- ODR array type ODR_Field_Array is array (0 .. 15) of Boolean with Component_Size => 1, Size => 16; -- Type definition for ODR type ODR_Field (As_Array : Boolean := False) is record case As_Array is when False => -- ODR as a value Val : HAL.UInt16; when True => -- ODR as an array Arr : ODR_Field_Array; end case; end record with Unchecked_Union, Size => 16; for ODR_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- GPIO port output data register type ODR_Register is record -- Port output data (y = 0..15) ODR : ODR_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ODR_Register use record ODR at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -- BSRR_BS array type BSRR_BS_Field_Array is array (0 .. 15) of Boolean with Component_Size => 1, Size => 16; -- Type definition for BSRR_BS type BSRR_BS_Field (As_Array : Boolean := False) is record case As_Array is when False => -- BS as a value Val : HAL.UInt16; when True => -- BS as an array Arr : BSRR_BS_Field_Array; end case; end record with Unchecked_Union, Size => 16; for BSRR_BS_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- BSRR_BR array type BSRR_BR_Field_Array is array (0 .. 15) of Boolean with Component_Size => 1, Size => 16; -- Type definition for BSRR_BR type BSRR_BR_Field (As_Array : Boolean := False) is record case As_Array is when False => -- BR as a value Val : HAL.UInt16; when True => -- BR as an array Arr : BSRR_BR_Field_Array; end case; end record with Unchecked_Union, Size => 16; for BSRR_BR_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- GPIO port bit set/reset register type BSRR_Register is record -- Write-only. Port x set bit y (y= 0..15) BS : BSRR_BS_Field := (As_Array => False, Val => 16#0#); -- Write-only. Port x set bit y (y= 0..15) BR : BSRR_BR_Field := (As_Array => False, Val => 16#0#); end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for BSRR_Register use record BS at 0 range 0 .. 15; BR at 0 range 16 .. 31; end record; -- LCKR_LCK array type LCKR_LCK_Field_Array is array (0 .. 15) of Boolean with Component_Size => 1, Size => 16; -- Type definition for LCKR_LCK type LCKR_LCK_Field (As_Array : Boolean := False) is record case As_Array is when False => -- LCK as a value Val : HAL.UInt16; when True => -- LCK as an array Arr : LCKR_LCK_Field_Array; end case; end record with Unchecked_Union, Size => 16; for LCKR_LCK_Field use record Val at 0 range 0 .. 15; Arr at 0 range 0 .. 15; end record; -- GPIO port configuration lock register type LCKR_Register is record -- Port x lock bit y (y= 0..15) LCK : LCKR_LCK_Field := (As_Array => False, Val => 16#0#); -- Port x lock bit y (y= 0..15) LCKK : Boolean := False; -- unspecified Reserved_17_31 : HAL.UInt15 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for LCKR_Register use record LCK at 0 range 0 .. 15; LCKK at 0 range 16 .. 16; Reserved_17_31 at 0 range 17 .. 31; end record; -- AFRL array element subtype AFRL_Element is HAL.UInt4; -- AFRL array type AFRL_Field_Array is array (0 .. 7) of AFRL_Element with Component_Size => 4, Size => 32; -- GPIO alternate function low register type AFRL_Register (As_Array : Boolean := False) is record case As_Array is when False => -- AFRL as a value Val : HAL.UInt32; when True => -- AFRL as an array Arr : AFRL_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for AFRL_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; -- AFRH array element subtype AFRH_Element is HAL.UInt4; -- AFRH array type AFRH_Field_Array is array (8 .. 15) of AFRH_Element with Component_Size => 4, Size => 32; -- GPIO alternate function high register type AFRH_Register (As_Array : Boolean := False) is record case As_Array is when False => -- AFRH as a value Val : HAL.UInt32; when True => -- AFRH as an array Arr : AFRH_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for AFRH_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- General-purpose I/Os type GPIO_Peripheral is record -- GPIO port mode register MODER : aliased MODER_Register; -- GPIO port output type register OTYPER : aliased OTYPER_Register; -- GPIO port output speed register OSPEEDR : aliased OSPEEDR_Register; -- GPIO port pull-up/pull-down register PUPDR : aliased PUPDR_Register; -- GPIO port input data register IDR : aliased IDR_Register; -- GPIO port output data register ODR : aliased ODR_Register; -- GPIO port bit set/reset register BSRR : aliased BSRR_Register; -- GPIO port configuration lock register LCKR : aliased LCKR_Register; -- GPIO alternate function low register AFRL : aliased AFRL_Register; -- GPIO alternate function high register AFRH : aliased AFRH_Register; end record with Volatile; for GPIO_Peripheral use record MODER at 16#0# range 0 .. 31; OTYPER at 16#4# range 0 .. 31; OSPEEDR at 16#8# range 0 .. 31; PUPDR at 16#C# range 0 .. 31; IDR at 16#10# range 0 .. 31; ODR at 16#14# range 0 .. 31; BSRR at 16#18# range 0 .. 31; LCKR at 16#1C# range 0 .. 31; AFRL at 16#20# range 0 .. 31; AFRH at 16#24# range 0 .. 31; end record; -- General-purpose I/Os GPIOA_Periph : aliased GPIO_Peripheral with Import, Address => System'To_Address (16#40020000#); -- General-purpose I/Os GPIOB_Periph : aliased GPIO_Peripheral with Import, Address => System'To_Address (16#40020400#); -- General-purpose I/Os GPIOC_Periph : aliased GPIO_Peripheral with Import, Address => System'To_Address (16#40020800#); -- General-purpose I/Os GPIOD_Periph : aliased GPIO_Peripheral with Import, Address => System'To_Address (16#40020C00#); -- General-purpose I/Os GPIOE_Periph : aliased GPIO_Peripheral with Import, Address => System'To_Address (16#40021000#); -- General-purpose I/Os GPIOF_Periph : aliased GPIO_Peripheral with Import, Address => System'To_Address (16#40021400#); -- General-purpose I/Os GPIOG_Periph : aliased GPIO_Peripheral with Import, Address => System'To_Address (16#40021800#); -- General-purpose I/Os GPIOH_Periph : aliased GPIO_Peripheral with Import, Address => System'To_Address (16#40021C00#); -- General-purpose I/Os GPIOI_Periph : aliased GPIO_Peripheral with Import, Address => System'To_Address (16#40022000#); -- General-purpose I/Os GPIOJ_Periph : aliased GPIO_Peripheral with Import, Address => System'To_Address (16#40022400#); -- General-purpose I/Os GPIOK_Periph : aliased GPIO_Peripheral with Import, Address => System'To_Address (16#40022800#); end STM32_SVD.GPIO;
charlie5/lace
Ada
84
ads
generic package any_Math.any_Algebra is pragma Pure; end any_Math.any_Algebra;
godunko/cga
Ada
195
ads
-- -- Copyright (C) 2023, Vadim Godunko <[email protected]> -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- package CGK.Mathematics is pragma Pure; end CGK.Mathematics;
AdaCore/Ada_Drivers_Library
Ada
5,548
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2016-2017, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with STM32_SVD.PWR; use STM32_SVD.PWR; with STM32_SVD.RCC; use STM32_SVD.RCC; with Cortex_M_SVD.SCB; use Cortex_M_SVD.SCB; with System.Machine_Code; use System.Machine_Code; package body STM32.Power_Control is ------------ -- Enable -- ------------ procedure Enable is begin RCC_Periph.APB1ENR.PWREN := True; end Enable; -------------------------------------- -- Disable_Backup_Domain_Protection -- -------------------------------------- procedure Disable_Backup_Domain_Protection is begin PWR_Periph.CR1.DBP := True; end Disable_Backup_Domain_Protection; ------------------------------------- -- Enable_Backup_Domain_Protection -- ------------------------------------- procedure Enable_Backup_Domain_Protection is begin PWR_Periph.CR1.DBP := False; end Enable_Backup_Domain_Protection; ----------------- -- Wakeup_Flag -- ----------------- function Wakeup_Flag (Pin : Wakeup_Pin) return Boolean is (PWR_Periph.CSR2.WUPF.Arr (Integer (Pin))); ----------------------- -- Clear_Wakeup_Flag -- ----------------------- procedure Clear_Wakeup_Flag (Pin : Wakeup_Pin) is begin PWR_Periph.CR2.CWUPF.Arr (Integer (Pin)) := True; end Clear_Wakeup_Flag; ------------------ -- Standby_Flag -- ------------------ function Standby_Flag return Boolean is (PWR_Periph.CSR1.SBF); ------------------------ -- Clear_Standby_Flag -- ------------------------ procedure Clear_Standby_Flag is begin PWR_Periph.CR1.CSBF := True; end Clear_Standby_Flag; ------------------------------ -- Set_Power_Down_Deepsleep -- ------------------------------ procedure Set_Power_Down_Deepsleep (Enabled : Boolean := True) is begin PWR_Periph.CR1.PDDS := Enabled; end Set_Power_Down_Deepsleep; ----------------------------- -- Set_Low_Power_Deepsleep -- ----------------------------- procedure Set_Low_Power_Deepsleep (Enabled : Boolean := True) is begin PWR_Periph.CR1.LPDS := Enabled; end Set_Low_Power_Deepsleep; ----------------------- -- Enable_Wakeup_Pin -- ----------------------- procedure Enable_Wakeup_Pin (Pin : Wakeup_Pin; Enabled : Boolean := True) is begin PWR_Periph.CSR2.EWUP.Arr (Integer (Pin)) := Enabled; end Enable_Wakeup_Pin; ----------------------------- -- Set_Wakeup_Pin_Polarity -- ----------------------------- procedure Set_Wakeup_Pin_Polarity (Pin : Wakeup_Pin; Pol : Wakeup_Pin_Polarity) is begin PWR_Periph.CR2.WUPP.Arr (Integer (Pin)) := Pol = Falling_Edge; end Set_Wakeup_Pin_Polarity; ------------------------ -- Enter_Standby_Mode -- ------------------------ procedure Enter_Standby_Mode is begin for Pin in Wakeup_Pin loop Clear_Wakeup_Flag (Pin); end loop; Clear_Standby_Flag; Set_Power_Down_Deepsleep; SCB_Periph.SCR.SLEEPDEEP := True; loop Asm ("wfi", Volatile => True); end loop; end Enter_Standby_Mode; end STM32.Power_Control;
stcarrez/ada-keystore
Ada
15,110
adb
----------------------------------------------------------------------- -- keystore-io-headers -- Keystore file header operations -- Copyright (C) 2019, 2020, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Log.Loggers; with Util.Encoders.HMAC.SHA256; with Keystore.Marshallers; -- === Header block === -- The first block of the file is the keystore header block which contains clear -- information signed by an HMAC header. The header block contains the keystore -- UUID as well as a short description of each storage data file. It also contains -- some optional header data. -- -- ``` -- +------------------+ -- | 41 64 61 00 | 4b = Ada -- | 00 9A 72 57 | 4b = 10/12/1815 -- | 01 9D B1 AC | 4b = 27/11/1852 -- | 00 01 | 2b = Version 1 -- | 00 01 | 2b = File header length in blocks -- +------------------+ -- | Keystore UUID | 16b -- | Storage ID | 4b -- | Block size | 4b -- | Storage count | 4b -- | Header Data count| 2b -- +------------------+----- -- | Header Data size | 2b -- | Header Data type | 2b = 0 (NONE), 1 (GPG1) 2, (GPG2) -- +------------------+ -- | Header Data | Nb -- +------------------+----- -- | ... | -- +------------------+----- -- | 0 | -- +------------------+----- -- | ... | -- +------------------+----- -- | Storage ID | 4b -- | Storage type | 2b -- | Storage status | 2b 00 = open, Ada = sealed -- | Storage max bloc | 4b -- | Storage HMAC | 32b = 44b -- +------------------+---- -- | Header HMAC-256 | 32b -- +------------------+---- -- ``` package body Keystore.IO.Headers is use type Interfaces.Unsigned_16; use type Interfaces.Unsigned_32; use type Keystore.Buffers.Storage_Identifier; -- Header magic numbers. MAGIC_1 : constant := 16#41646100#; MAGIC_2 : constant := 16#009A7257#; MAGIC_3 : constant := 16#019DB1AC#; VERSION_1 : constant := 1; -- Header positions and length. STORAGE_COUNT_POS : constant := 1 + 16 + 16 + 4 + 4; HEADER_DATA_POS : constant := STORAGE_COUNT_POS + 4; STORAGE_SLOT_LENGTH : constant := 4 + 2 + 2 + 4 + 32; Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Keystore.IO.Headers"); function Get_Storage_Offset (Index : in Natural) return Block_Index is (Block_Index'Last - STORAGE_SLOT_LENGTH * Stream_Element_Offset (Index) - 1); function Get_Header_Data_Size (Header : in Wallet_Header) return Buffer_Size; procedure Seek_Header_Data (Buffer : in out Keystore.Marshallers.Marshaller; Index : in Header_Slot_Index_Type); -- ------------------------------ -- Build a new header with the given UUID and for the storage. -- The header buffer is allocated and filled so that it can be written by Write_Header. -- ------------------------------ procedure Build_Header (UUID : in UUID_Type; Storage : in Storage_Identifier; Header : in out Wallet_Header) is Buffer : Keystore.Marshallers.Marshaller; begin Header.Buffer := Buffers.Allocate ((Storage, HEADER_BLOCK_NUM)); Buffer.Buffer := Header.Buffer; Marshallers.Set_Header (Buffer, MAGIC_1); Marshallers.Put_Unsigned_32 (Buffer, MAGIC_2); Marshallers.Put_Unsigned_32 (Buffer, MAGIC_3); Marshallers.Put_Unsigned_16 (Buffer, VERSION_1); Marshallers.Put_Unsigned_16 (Buffer, 1); Marshallers.Put_UUID (Buffer, UUID); Marshallers.Put_Unsigned_32 (Buffer, Interfaces.Unsigned_32 (Storage)); Marshallers.Put_Unsigned_32 (Buffer, Buffers.Block_Size); Marshallers.Put_Unsigned_32 (Buffer, 0); Buffer.Buffer.Data.Value.Data (Buffer.Pos .. Buffers.Block_Type'Last) := (others => 0); end Build_Header; -- ------------------------------ -- Read the header block and verify its integrity. -- ------------------------------ procedure Read_Header (Header : in out Wallet_Header) is Buffer : Keystore.Marshallers.Marshaller; Value : Interfaces.Unsigned_32; Value16 : Interfaces.Unsigned_16; Storage_Count : Interfaces.Unsigned_32; begin Buffer.Buffer := Header.Buffer; -- Verify values found in header block. Value := Marshallers.Get_Header (Buffer); if Value /= MAGIC_1 then Log.Warn ("Header magic 1 is invalid:{0}", Interfaces.Unsigned_32'Image (Value)); raise Invalid_Keystore; end if; Value := Marshallers.Get_Unsigned_32 (Buffer); if Value /= MAGIC_2 then Log.Warn ("Header magic 2 is invalid:{0}", Interfaces.Unsigned_32'Image (Value)); raise Invalid_Keystore; end if; Value := Marshallers.Get_Unsigned_32 (Buffer); if Value /= MAGIC_3 then Log.Warn ("Header magic 3 is invalid:{0}", Interfaces.Unsigned_32'Image (Value)); raise Invalid_Keystore; end if; Header.Version := Natural (Marshallers.Get_Unsigned_16 (Buffer)); if Header.Version /= 1 then Log.Warn ("Header version is not supported:{0}", Natural'Image (Header.Version)); raise Invalid_Keystore; end if; Value := Interfaces.Unsigned_32 (Marshallers.Get_Unsigned_16 (Buffer)); if Value /= 1 then Log.Warn ("Header block size bloc{0} is invalid:{0}", Interfaces.Unsigned_32'Image (Value)); raise Invalid_Keystore; end if; -- Get keystore UUID Marshallers.Get_UUID (Buffer, Header.UUID); Header.Identifier := Storage_Identifier (Marshallers.Get_Unsigned_32 (Buffer)); if Header.Identifier /= Header.Buffer.Block.Storage then Log.Warn ("Header storage identifier does not match:{0}", Storage_Identifier'Image (Header.Identifier)); raise Invalid_Keystore; end if; Value := Marshallers.Get_Unsigned_32 (Buffer); if Value /= Buffers.Block_Size then Log.Warn ("Header block size is not supported:{0}", Interfaces.Unsigned_32'Image (Value)); raise Invalid_Keystore; end if; Header.Block_Size := Natural (Value); Storage_Count := Marshallers.Get_Unsigned_32 (Buffer); Header.Storage_Count := Natural (Storage_Count); Value16 := Marshallers.Get_Unsigned_16 (Buffer); if Value16 > Interfaces.Unsigned_16 (Header_Slot_Count_Type'Last) then Log.Warn ("Header data count is out of range:{0}", Interfaces.Unsigned_16 'Image (Value16)); raise Invalid_Keystore; end if; Header.Data_Count := Header_Slot_Count_Type (Value16); end Read_Header; -- ------------------------------ -- Scan the header block for the storage and call the Process procedure for each -- storage information found in the header block. -- ------------------------------ procedure Scan_Storage (Header : in out Wallet_Header; Process : not null access procedure (Storage : in Wallet_Storage)) is Buf : constant Buffers.Buffer_Accessor := Header.Buffer.Data.Value; Buffer : Keystore.Marshallers.Marshaller; begin Buffer.Buffer := Header.Buffer; for I in 1 .. Header.Storage_Count loop declare S : Wallet_Storage; Status : Interfaces.Unsigned_16; begin Buffer.Pos := Get_Storage_Offset (I); S.Pos := Buffer.Pos + 1; S.Identifier := Storage_Identifier (Marshallers.Get_Unsigned_32 (Buffer)); S.Kind := Marshallers.Get_Unsigned_16 (Buffer); Status := Marshallers.Get_Unsigned_16 (Buffer); S.Readonly := Status > 0; S.Sealed := Status > 0; S.Max_Block := Natural (Marshallers.Get_Unsigned_32 (Buffer)); S.HMAC := Buf.Data (Buffer.Pos + 1 .. Buffer.Pos + 32); Process (S); end; end loop; end Scan_Storage; -- ------------------------------ -- Sign the header block for the storage. -- ------------------------------ procedure Sign_Header (Header : in out Wallet_Header; Sign : in Secret_Key) is Buf : constant Buffers.Buffer_Accessor := Header.Buffer.Data.Value; Context : Util.Encoders.HMAC.SHA256.Context; begin Util.Encoders.HMAC.SHA256.Set_Key (Context, Sign); Util.Encoders.HMAC.SHA256.Update (Context, Buf.Data); Util.Encoders.HMAC.SHA256.Finish (Context, Header.HMAC); end Sign_Header; procedure Seek_Header_Data (Buffer : in out Keystore.Marshallers.Marshaller; Index : in Header_Slot_Index_Type) is Size : Buffer_Size; begin Buffer.Pos := HEADER_DATA_POS + 2 - 1; -- Skip entries until we reach the correct slot. for I in 1 .. Index - 1 loop Size := Marshallers.Get_Buffer_Size (Buffer); Marshallers.Skip (Buffer, Size + 2); end loop; end Seek_Header_Data; function Get_Header_Data_Size (Header : in Wallet_Header) return Buffer_Size is Buffer : Keystore.Marshallers.Marshaller; Total : Buffer_Size := 0; Size : Buffer_Size; begin Buffer.Buffer := Header.Buffer; Buffer.Pos := HEADER_DATA_POS + 2 - 1; for I in 1 .. Header.Data_Count loop Size := Marshallers.Get_Buffer_Size (Buffer); Marshallers.Skip (Buffer, Size + 2); Total := Total + Size + 4; end loop; return Total; end Get_Header_Data_Size; -- ------------------------------ -- Set some header data in the keystore file. -- ------------------------------ procedure Set_Header_Data (Header : in out Wallet_Header; Index : in Header_Slot_Index_Type; Kind : in Header_Slot_Type; Data : in Ada.Streams.Stream_Element_Array) is Buf : constant Buffers.Buffer_Accessor := Header.Buffer.Data.Value; Buffer : Keystore.Marshallers.Marshaller; Size : Buffer_Size; Last : Block_Index; Space : Stream_Element_Offset; Start : Stream_Element_Offset; Limit : constant Stream_Element_Offset := Get_Storage_Offset (Header.Storage_Count); begin if Index > Header.Data_Count + 1 then Log.Warn ("Not enough header slots to add a header data"); raise No_Header_Slot; end if; Buffer.Buffer := Header.Buffer; Seek_Header_Data (Buffer, Index); if Index <= Header.Data_Count then Size := Marshallers.Get_Buffer_Size (Buffer); Space := Data'Length - Size; Buffer.Pos := Buffer.Pos - 2; else Space := Data'Length; end if; Last := Get_Header_Data_Size (Header) + HEADER_DATA_POS; -- Verify there is enough room. if Last + Space + 8 >= Limit then Log.Warn ("Not enough header space to add a header data"); raise No_Header_Slot; end if; -- Shift if Index < Header.Data_Count and then Space /= 0 then Start := Buffer.Pos + 4 + Size; Buf.Data (Start + Space .. Last + Space) := Buf.Data (Start .. Last); end if; -- Update the header data slot. Marshallers.Put_Buffer_Size (Buffer, Data'Length); Marshallers.Put_Unsigned_16 (Buffer, Interfaces.Unsigned_16 (Kind)); Buf.Data (Buffer.Pos + 1 .. Buffer.Pos + Data'Length) := Data; -- Update the header data count. if Index > Header.Data_Count then Header.Data_Count := Index; end if; Buffer.Pos := HEADER_DATA_POS - 1; Marshallers.Put_Unsigned_16 (Buffer, Interfaces.Unsigned_16 (Header.Data_Count)); end Set_Header_Data; -- ------------------------------ -- Get the header data information from the keystore file. -- ------------------------------ procedure Get_Header_Data (Header : in out Wallet_Header; Index : in Header_Slot_Index_Type; Kind : out Header_Slot_Type; Data : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset) is Buffer : Keystore.Marshallers.Marshaller; Size : Buffer_Size; begin if Index > Header.Data_Count then Kind := SLOT_EMPTY; Last := Data'First - 1; return; end if; Buffer.Buffer := Header.Buffer; Seek_Header_Data (Buffer, Index); -- Extract data slot and truncate if the buffer is too small. Size := Marshallers.Get_Buffer_Size (Buffer); Kind := Header_Slot_Type (Marshallers.Get_Unsigned_16 (Buffer)); if Size > Data'Length then Size := Data'Length; end if; Marshallers.Get_Data (Buffer, Size, Data, Last); end Get_Header_Data; -- ------------------------------ -- Add a new storage reference in the header and return its position in the header. -- Raises the No_Header_Slot if there is no room in the header. -- ------------------------------ procedure Add_Storage (Header : in out Wallet_Header; Identifier : in Storage_Identifier; Max_Block : in Positive; Pos : out Block_Index) is Buffer : Keystore.Marshallers.Marshaller; Last : constant Block_Index := Get_Header_Data_Size (Header) + HEADER_DATA_POS; begin Pos := Get_Storage_Offset (Header.Storage_Count + 1); if Pos <= Last + 4 then Log.Warn ("Not enough header space to add a new storage file"); raise No_Header_Slot; end if; Buffer.Pos := Pos; Header.Storage_Count := Header.Storage_Count + 1; Buffer.Buffer := Header.Buffer; Marshallers.Put_Unsigned_32 (Buffer, Interfaces.Unsigned_32 (Identifier)); Marshallers.Put_Unsigned_16 (Buffer, 0); Marshallers.Put_Unsigned_16 (Buffer, 0); Marshallers.Put_Unsigned_32 (Buffer, Interfaces.Unsigned_32 (Max_Block)); Buffer.Pos := STORAGE_COUNT_POS - 1; Marshallers.Put_Unsigned_32 (Buffer, Interfaces.Unsigned_32 (Header.Storage_Count)); end Add_Storage; end Keystore.IO.Headers;
alvaromb/Compilemon
Ada
3,396
adb
-- Copyright (c) 1990 Regents of the University of California. -- All rights reserved. -- -- This software was developed by John Self of the Arcadia project -- at the University of California, Irvine. -- -- Redistribution and use in source and binary forms are permitted -- provided that the above copyright notice and this paragraph are -- duplicated in all such forms and that any documentation, -- advertising materials, and other materials related to such -- distribution and use acknowledge that the software was developed -- by the University of California, Irvine. The name of the -- University may not be used to endorse or promote products derived -- from this software without specific prior written permission. -- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR -- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. -- TITLE external_file_manager -- AUTHOR: John Self (UCI) -- DESCRIPTION opens external files for other functions -- NOTES This package opens external files, and thus may be system dependent -- because of limitations on file names. -- This version is for the VADS 5.5 Ada development system. -- $Header: /co/ua/self/arcadia/aflex/ada/src/RCS/file_managerB.a,v 1.5 90/01/12 15:19:58 self Exp Locker: self $ with misc_defs, tstring, text_io, misc; use misc_defs, tstring, text_io, misc; package body external_file_manager is -- FIX comment about compiler dependent subtype SUFFIX_TYPE is STRING(1 .. 1); function ADA_SUFFIX return SUFFIX_TYPE is begin return "a"; end ADA_SUFFIX; procedure GET_IO_FILE(F : in out FILE_TYPE) is begin if (LEN(INFILENAME) /= 0) then CREATE(F, OUT_FILE, STR(MISC.BASENAME) & "_io." & ADA_SUFFIX); else CREATE(F, OUT_FILE, "aflex_yy_io." & ADA_SUFFIX); end if; exception when USE_ERROR | NAME_ERROR => MISC.AFLEXFATAL("could not create IO package file"); end GET_IO_FILE; procedure GET_DFA_FILE(F : in out FILE_TYPE) is begin if (LEN(INFILENAME) /= 0) then CREATE(F, OUT_FILE, STR(MISC.BASENAME) & "_dfa." & ADA_SUFFIX); else CREATE(F, OUT_FILE, "aflex_yy_dfa." & ADA_SUFFIX); end if; exception when USE_ERROR | NAME_ERROR => MISC.AFLEXFATAL("could not create DFA package file"); end GET_DFA_FILE; procedure GET_SCANNER_FILE(F : in out FILE_TYPE) is OUTFILE_NAME : VSTRING; begin if (LEN(INFILENAME) /= 0) then -- give out infile + ada_suffix OUTFILE_NAME := MISC.BASENAME & "." & ADA_SUFFIX; else OUTFILE_NAME := VSTR("aflex_yy." & ADA_SUFFIX); end if; CREATE(F, OUT_FILE, STR(OUTFILE_NAME)); SET_OUTPUT(F); exception when NAME_ERROR | USE_ERROR => MISC.AFLEXFATAL("can't create scanner file " & OUTFILE_NAME); end GET_SCANNER_FILE; procedure GET_BACKTRACK_FILE(F : in out FILE_TYPE) is begin CREATE(F, OUT_FILE, "aflex.backtrack"); exception when USE_ERROR | NAME_ERROR => MISC.AFLEXFATAL("could not create backtrack file"); end GET_BACKTRACK_FILE; procedure INITIALIZE_FILES is begin null; -- doesn't need to do anything on Verdix end INITIALIZE_FILES; end external_file_manager;
sparre/Command-Line-Parser-Generator
Ada
271
ads
with Ada.Text_IO; package Good_Optional_Help_With_Private_Part is procedure Run (Help : in Boolean := False); private procedure Debug (To : Ada.Text_IO.File_Type); procedure Reset (File : in out Ada.Text_IO.File_Type); end Good_Optional_Help_With_Private_Part;
AdaCore/libadalang
Ada
543
adb
-- Check that p_fully_qualified_name returns correct results on synthetic -- types. with Ada.Unchecked_Deallocation; procedure Test is type T is tagged null record; function Foo return T'Class with Import; --% node[1][3].p_designated_type_decl.p_fully_qualified_name function Bar return Integer'Base with Import; --% node[1][3].p_designated_type_decl.p_fully_qualified_name A : aliased Integer; begin A := A'Unrestricted_Access.all; --% node[1][0].p_expression_type.p_fully_qualified_name end Test;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
40,071
ads
pragma Style_Checks (Off); -- This spec has been automatically generated from STM32L0x3.svd pragma Restrictions (No_Elaboration_Code); with System; package STM32_SVD.USART is pragma Preelaborate; --------------- -- Registers -- --------------- subtype CR1_UE_Field is STM32_SVD.Bit; subtype CR1_UESM_Field is STM32_SVD.Bit; subtype CR1_RE_Field is STM32_SVD.Bit; subtype CR1_TE_Field is STM32_SVD.Bit; subtype CR1_IDLEIE_Field is STM32_SVD.Bit; subtype CR1_RXNEIE_Field is STM32_SVD.Bit; subtype CR1_TCIE_Field is STM32_SVD.Bit; subtype CR1_TXEIE_Field is STM32_SVD.Bit; subtype CR1_PEIE_Field is STM32_SVD.Bit; subtype CR1_PS_Field is STM32_SVD.Bit; subtype CR1_PCE_Field is STM32_SVD.Bit; subtype CR1_WAKE_Field is STM32_SVD.Bit; subtype CR1_M0_Field is STM32_SVD.Bit; subtype CR1_MME_Field is STM32_SVD.Bit; subtype CR1_CMIE_Field is STM32_SVD.Bit; -- CR1_DEDT array element subtype CR1_DEDT_Element is STM32_SVD.Bit; -- CR1_DEDT array type CR1_DEDT_Field_Array is array (0 .. 4) of CR1_DEDT_Element with Component_Size => 1, Size => 5; -- Type definition for CR1_DEDT type CR1_DEDT_Field (As_Array : Boolean := False) is record case As_Array is when False => -- DEDT as a value Val : STM32_SVD.UInt5; when True => -- DEDT as an array Arr : CR1_DEDT_Field_Array; end case; end record with Unchecked_Union, Size => 5; for CR1_DEDT_Field use record Val at 0 range 0 .. 4; Arr at 0 range 0 .. 4; end record; -- CR1_DEAT array element subtype CR1_DEAT_Element is STM32_SVD.Bit; -- CR1_DEAT array type CR1_DEAT_Field_Array is array (0 .. 4) of CR1_DEAT_Element with Component_Size => 1, Size => 5; -- Type definition for CR1_DEAT type CR1_DEAT_Field (As_Array : Boolean := False) is record case As_Array is when False => -- DEAT as a value Val : STM32_SVD.UInt5; when True => -- DEAT as an array Arr : CR1_DEAT_Field_Array; end case; end record with Unchecked_Union, Size => 5; for CR1_DEAT_Field use record Val at 0 range 0 .. 4; Arr at 0 range 0 .. 4; end record; subtype CR1_M1_Field is STM32_SVD.Bit; -- Control register 1 type CR1_Register is record -- USART enable UE : CR1_UE_Field := 16#0#; -- USART enable in Stop mode UESM : CR1_UESM_Field := 16#0#; -- Receiver enable RE : CR1_RE_Field := 16#0#; -- Transmitter enable TE : CR1_TE_Field := 16#0#; -- IDLE interrupt enable IDLEIE : CR1_IDLEIE_Field := 16#0#; -- RXNE interrupt enable RXNEIE : CR1_RXNEIE_Field := 16#0#; -- Transmission complete interrupt enable TCIE : CR1_TCIE_Field := 16#0#; -- interrupt enable TXEIE : CR1_TXEIE_Field := 16#0#; -- PE interrupt enable PEIE : CR1_PEIE_Field := 16#0#; -- Parity selection PS : CR1_PS_Field := 16#0#; -- Parity control enable PCE : CR1_PCE_Field := 16#0#; -- Receiver wakeup method WAKE : CR1_WAKE_Field := 16#0#; -- Word length M0 : CR1_M0_Field := 16#0#; -- Mute mode enable MME : CR1_MME_Field := 16#0#; -- Character match interrupt enable CMIE : CR1_CMIE_Field := 16#0#; -- unspecified Reserved_15_15 : STM32_SVD.Bit := 16#0#; -- DEDT0 DEDT : CR1_DEDT_Field := (As_Array => False, Val => 16#0#); -- DEAT0 DEAT : CR1_DEAT_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_26_27 : STM32_SVD.UInt2 := 16#0#; -- Word length M1 : CR1_M1_Field := 16#0#; -- unspecified Reserved_29_31 : STM32_SVD.UInt3 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CR1_Register use record UE at 0 range 0 .. 0; UESM at 0 range 1 .. 1; RE at 0 range 2 .. 2; TE at 0 range 3 .. 3; IDLEIE at 0 range 4 .. 4; RXNEIE at 0 range 5 .. 5; TCIE at 0 range 6 .. 6; TXEIE at 0 range 7 .. 7; PEIE at 0 range 8 .. 8; PS at 0 range 9 .. 9; PCE at 0 range 10 .. 10; WAKE at 0 range 11 .. 11; M0 at 0 range 12 .. 12; MME at 0 range 13 .. 13; CMIE at 0 range 14 .. 14; Reserved_15_15 at 0 range 15 .. 15; DEDT at 0 range 16 .. 20; DEAT at 0 range 21 .. 25; Reserved_26_27 at 0 range 26 .. 27; M1 at 0 range 28 .. 28; Reserved_29_31 at 0 range 29 .. 31; end record; subtype CR2_ADDM7_Field is STM32_SVD.Bit; subtype CR2_CLKEN_Field is STM32_SVD.Bit; subtype CR2_STOP_Field is STM32_SVD.UInt2; subtype CR2_SWAP_Field is STM32_SVD.Bit; subtype CR2_RXINV_Field is STM32_SVD.Bit; subtype CR2_TXINV_Field is STM32_SVD.Bit; subtype CR2_TAINV_Field is STM32_SVD.Bit; subtype CR2_MSBFIRST_Field is STM32_SVD.Bit; subtype CR2_ADD0_3_Field is STM32_SVD.UInt4; subtype CR2_ADD4_7_Field is STM32_SVD.UInt4; -- Control register 2 type CR2_Register is record -- unspecified Reserved_0_3 : STM32_SVD.UInt4 := 16#0#; -- 7-bit Address Detection/4-bit Address Detection ADDM7 : CR2_ADDM7_Field := 16#0#; -- unspecified Reserved_5_10 : STM32_SVD.UInt6 := 16#0#; -- Clock enable CLKEN : CR2_CLKEN_Field := 16#0#; -- STOP bits STOP : CR2_STOP_Field := 16#0#; -- unspecified Reserved_14_14 : STM32_SVD.Bit := 16#0#; -- Swap TX/RX pins SWAP : CR2_SWAP_Field := 16#0#; -- RX pin active level inversion RXINV : CR2_RXINV_Field := 16#0#; -- TX pin active level inversion TXINV : CR2_TXINV_Field := 16#0#; -- Binary data inversion TAINV : CR2_TAINV_Field := 16#0#; -- Most significant bit first MSBFIRST : CR2_MSBFIRST_Field := 16#0#; -- unspecified Reserved_20_23 : STM32_SVD.UInt4 := 16#0#; -- Address of the USART node ADD0_3 : CR2_ADD0_3_Field := 16#0#; -- Address of the USART node ADD4_7 : CR2_ADD4_7_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CR2_Register use record Reserved_0_3 at 0 range 0 .. 3; ADDM7 at 0 range 4 .. 4; Reserved_5_10 at 0 range 5 .. 10; CLKEN at 0 range 11 .. 11; STOP at 0 range 12 .. 13; Reserved_14_14 at 0 range 14 .. 14; SWAP at 0 range 15 .. 15; RXINV at 0 range 16 .. 16; TXINV at 0 range 17 .. 17; TAINV at 0 range 18 .. 18; MSBFIRST at 0 range 19 .. 19; Reserved_20_23 at 0 range 20 .. 23; ADD0_3 at 0 range 24 .. 27; ADD4_7 at 0 range 28 .. 31; end record; subtype CR3_EIE_Field is STM32_SVD.Bit; subtype CR3_HDSEL_Field is STM32_SVD.Bit; subtype CR3_DMAR_Field is STM32_SVD.Bit; subtype CR3_DMAT_Field is STM32_SVD.Bit; subtype CR3_RTSE_Field is STM32_SVD.Bit; subtype CR3_CTSE_Field is STM32_SVD.Bit; subtype CR3_CTSIE_Field is STM32_SVD.Bit; subtype CR3_OVRDIS_Field is STM32_SVD.Bit; subtype CR3_DDRE_Field is STM32_SVD.Bit; subtype CR3_DEM_Field is STM32_SVD.Bit; subtype CR3_DEP_Field is STM32_SVD.Bit; subtype CR3_WUS_Field is STM32_SVD.UInt2; subtype CR3_WUFIE_Field is STM32_SVD.Bit; -- Control register 3 type CR3_Register is record -- Error interrupt enable EIE : CR3_EIE_Field := 16#0#; -- unspecified Reserved_1_2 : STM32_SVD.UInt2 := 16#0#; -- Half-duplex selection HDSEL : CR3_HDSEL_Field := 16#0#; -- unspecified Reserved_4_5 : STM32_SVD.UInt2 := 16#0#; -- DMA enable receiver DMAR : CR3_DMAR_Field := 16#0#; -- DMA enable transmitter DMAT : CR3_DMAT_Field := 16#0#; -- RTS enable RTSE : CR3_RTSE_Field := 16#0#; -- CTS enable CTSE : CR3_CTSE_Field := 16#0#; -- CTS interrupt enable CTSIE : CR3_CTSIE_Field := 16#0#; -- unspecified Reserved_11_11 : STM32_SVD.Bit := 16#0#; -- Overrun Disable OVRDIS : CR3_OVRDIS_Field := 16#0#; -- DMA Disable on Reception Error DDRE : CR3_DDRE_Field := 16#0#; -- Driver enable mode DEM : CR3_DEM_Field := 16#0#; -- Driver enable polarity selection DEP : CR3_DEP_Field := 16#0#; -- unspecified Reserved_16_19 : STM32_SVD.UInt4 := 16#0#; -- Wakeup from Stop mode interrupt flag selection WUS : CR3_WUS_Field := 16#0#; -- Wakeup from Stop mode interrupt enable WUFIE : CR3_WUFIE_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 CR3_Register use record EIE at 0 range 0 .. 0; Reserved_1_2 at 0 range 1 .. 2; HDSEL at 0 range 3 .. 3; Reserved_4_5 at 0 range 4 .. 5; DMAR at 0 range 6 .. 6; DMAT at 0 range 7 .. 7; RTSE at 0 range 8 .. 8; CTSE at 0 range 9 .. 9; CTSIE at 0 range 10 .. 10; Reserved_11_11 at 0 range 11 .. 11; OVRDIS at 0 range 12 .. 12; DDRE at 0 range 13 .. 13; DEM at 0 range 14 .. 14; DEP at 0 range 15 .. 15; Reserved_16_19 at 0 range 16 .. 19; WUS at 0 range 20 .. 21; WUFIE at 0 range 22 .. 22; Reserved_23_31 at 0 range 23 .. 31; end record; subtype BRR_BRR_Field is STM32_SVD.UInt20; -- Baud rate register type BRR_Register is record -- BRR BRR : BRR_BRR_Field := 16#0#; -- unspecified Reserved_20_31 : STM32_SVD.UInt12 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for BRR_Register use record BRR at 0 range 0 .. 19; Reserved_20_31 at 0 range 20 .. 31; end record; subtype RQR_SBKRQ_Field is STM32_SVD.Bit; subtype RQR_MMRQ_Field is STM32_SVD.Bit; subtype RQR_RXFRQ_Field is STM32_SVD.Bit; -- Request register type RQR_Register is record -- unspecified Reserved_0_0 : STM32_SVD.Bit := 16#0#; -- Write-only. Send break request SBKRQ : RQR_SBKRQ_Field := 16#0#; -- Write-only. Mute mode request MMRQ : RQR_MMRQ_Field := 16#0#; -- Write-only. Receive data flush request RXFRQ : RQR_RXFRQ_Field := 16#0#; -- unspecified Reserved_4_31 : STM32_SVD.UInt28 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for RQR_Register use record Reserved_0_0 at 0 range 0 .. 0; SBKRQ at 0 range 1 .. 1; MMRQ at 0 range 2 .. 2; RXFRQ at 0 range 3 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; subtype ISR_PE_Field is STM32_SVD.Bit; subtype ISR_FE_Field is STM32_SVD.Bit; subtype ISR_NF_Field is STM32_SVD.Bit; subtype ISR_ORE_Field is STM32_SVD.Bit; subtype ISR_IDLE_Field is STM32_SVD.Bit; subtype ISR_RXNE_Field is STM32_SVD.Bit; subtype ISR_TC_Field is STM32_SVD.Bit; subtype ISR_TXE_Field is STM32_SVD.Bit; subtype ISR_CTSIF_Field is STM32_SVD.Bit; subtype ISR_CTS_Field is STM32_SVD.Bit; subtype ISR_BUSY_Field is STM32_SVD.Bit; subtype ISR_CMF_Field is STM32_SVD.Bit; subtype ISR_SBKF_Field is STM32_SVD.Bit; subtype ISR_RWU_Field is STM32_SVD.Bit; subtype ISR_WUF_Field is STM32_SVD.Bit; subtype ISR_TEACK_Field is STM32_SVD.Bit; subtype ISR_REACK_Field is STM32_SVD.Bit; -- Interrupt & status register type ISR_Register is record -- Read-only. PE PE : ISR_PE_Field; -- Read-only. FE FE : ISR_FE_Field; -- Read-only. NF NF : ISR_NF_Field; -- Read-only. ORE ORE : ISR_ORE_Field; -- Read-only. IDLE IDLE : ISR_IDLE_Field; -- Read-only. RXNE RXNE : ISR_RXNE_Field; -- Read-only. TC TC : ISR_TC_Field; -- Read-only. TXE TXE : ISR_TXE_Field; -- unspecified Reserved_8_8 : STM32_SVD.Bit; -- Read-only. CTSIF CTSIF : ISR_CTSIF_Field; -- Read-only. CTS CTS : ISR_CTS_Field; -- unspecified Reserved_11_15 : STM32_SVD.UInt5; -- Read-only. BUSY BUSY : ISR_BUSY_Field; -- Read-only. CMF CMF : ISR_CMF_Field; -- Read-only. SBKF SBKF : ISR_SBKF_Field; -- Read-only. RWU RWU : ISR_RWU_Field; -- Read-only. WUF WUF : ISR_WUF_Field; -- Read-only. TEACK TEACK : ISR_TEACK_Field; -- Read-only. REACK REACK : ISR_REACK_Field; -- unspecified Reserved_23_31 : STM32_SVD.UInt9; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ISR_Register use record PE at 0 range 0 .. 0; FE at 0 range 1 .. 1; NF at 0 range 2 .. 2; ORE at 0 range 3 .. 3; IDLE at 0 range 4 .. 4; RXNE at 0 range 5 .. 5; TC at 0 range 6 .. 6; TXE at 0 range 7 .. 7; Reserved_8_8 at 0 range 8 .. 8; CTSIF at 0 range 9 .. 9; CTS at 0 range 10 .. 10; Reserved_11_15 at 0 range 11 .. 15; BUSY at 0 range 16 .. 16; CMF at 0 range 17 .. 17; SBKF at 0 range 18 .. 18; RWU at 0 range 19 .. 19; WUF at 0 range 20 .. 20; TEACK at 0 range 21 .. 21; REACK at 0 range 22 .. 22; Reserved_23_31 at 0 range 23 .. 31; end record; subtype ICR_PECF_Field is STM32_SVD.Bit; subtype ICR_FECF_Field is STM32_SVD.Bit; subtype ICR_NCF_Field is STM32_SVD.Bit; subtype ICR_ORECF_Field is STM32_SVD.Bit; subtype ICR_IDLECF_Field is STM32_SVD.Bit; subtype ICR_TCCF_Field is STM32_SVD.Bit; subtype ICR_CTSCF_Field is STM32_SVD.Bit; subtype ICR_CMCF_Field is STM32_SVD.Bit; subtype ICR_WUCF_Field is STM32_SVD.Bit; -- Interrupt flag clear register type ICR_Register is record -- Write-only. Parity error clear flag PECF : ICR_PECF_Field := 16#0#; -- Write-only. Framing error clear flag FECF : ICR_FECF_Field := 16#0#; -- Write-only. Noise detected clear flag NCF : ICR_NCF_Field := 16#0#; -- Write-only. Overrun error clear flag ORECF : ICR_ORECF_Field := 16#0#; -- Write-only. Idle line detected clear flag IDLECF : ICR_IDLECF_Field := 16#0#; -- unspecified Reserved_5_5 : STM32_SVD.Bit := 16#0#; -- Write-only. Transmission complete clear flag TCCF : ICR_TCCF_Field := 16#0#; -- unspecified Reserved_7_8 : STM32_SVD.UInt2 := 16#0#; -- Write-only. CTS clear flag CTSCF : ICR_CTSCF_Field := 16#0#; -- unspecified Reserved_10_16 : STM32_SVD.UInt7 := 16#0#; -- Write-only. Character match clear flag CMCF : ICR_CMCF_Field := 16#0#; -- unspecified Reserved_18_19 : STM32_SVD.UInt2 := 16#0#; -- Write-only. Wakeup from Stop mode clear flag WUCF : ICR_WUCF_Field := 16#0#; -- unspecified Reserved_21_31 : STM32_SVD.UInt11 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ICR_Register use record PECF at 0 range 0 .. 0; FECF at 0 range 1 .. 1; NCF at 0 range 2 .. 2; ORECF at 0 range 3 .. 3; IDLECF at 0 range 4 .. 4; Reserved_5_5 at 0 range 5 .. 5; TCCF at 0 range 6 .. 6; Reserved_7_8 at 0 range 7 .. 8; CTSCF at 0 range 9 .. 9; Reserved_10_16 at 0 range 10 .. 16; CMCF at 0 range 17 .. 17; Reserved_18_19 at 0 range 18 .. 19; WUCF at 0 range 20 .. 20; Reserved_21_31 at 0 range 21 .. 31; end record; subtype RDR_RDR_Field is STM32_SVD.UInt9; -- Receive data register type RDR_Register is record -- Read-only. Receive data value RDR : RDR_RDR_Field; -- unspecified Reserved_9_31 : STM32_SVD.UInt23; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for RDR_Register use record RDR at 0 range 0 .. 8; Reserved_9_31 at 0 range 9 .. 31; end record; subtype TDR_TDR_Field is STM32_SVD.UInt9; -- Transmit data register type TDR_Register is record -- Transmit data value TDR : TDR_TDR_Field := 16#0#; -- unspecified Reserved_9_31 : STM32_SVD.UInt23 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for TDR_Register use record TDR at 0 range 0 .. 8; Reserved_9_31 at 0 range 9 .. 31; end record; subtype CR1_OVER8_Field is STM32_SVD.Bit; subtype CR1_RTOIE_Field is STM32_SVD.Bit; subtype CR1_EOBIE_Field is STM32_SVD.Bit; -- Control register 1 type CR1_Register_1 is record -- USART enable UE : CR1_UE_Field := 16#0#; -- USART enable in Stop mode UESM : CR1_UESM_Field := 16#0#; -- Receiver enable RE : CR1_RE_Field := 16#0#; -- Transmitter enable TE : CR1_TE_Field := 16#0#; -- IDLE interrupt enable IDLEIE : CR1_IDLEIE_Field := 16#0#; -- RXNE interrupt enable RXNEIE : CR1_RXNEIE_Field := 16#0#; -- Transmission complete interrupt enable TCIE : CR1_TCIE_Field := 16#0#; -- interrupt enable TXEIE : CR1_TXEIE_Field := 16#0#; -- PE interrupt enable PEIE : CR1_PEIE_Field := 16#0#; -- Parity selection PS : CR1_PS_Field := 16#0#; -- Parity control enable PCE : CR1_PCE_Field := 16#0#; -- Receiver wakeup method WAKE : CR1_WAKE_Field := 16#0#; -- Word length M0 : CR1_M0_Field := 16#0#; -- Mute mode enable MME : CR1_MME_Field := 16#0#; -- Character match interrupt enable CMIE : CR1_CMIE_Field := 16#0#; -- Oversampling mode OVER8 : CR1_OVER8_Field := 16#0#; -- DEDT0 DEDT : CR1_DEDT_Field := (As_Array => False, Val => 16#0#); -- DEAT0 DEAT : CR1_DEAT_Field := (As_Array => False, Val => 16#0#); -- Receiver timeout interrupt enable RTOIE : CR1_RTOIE_Field := 16#0#; -- End of Block interrupt enable EOBIE : CR1_EOBIE_Field := 16#0#; -- Word length M1 : CR1_M1_Field := 16#0#; -- unspecified Reserved_29_31 : STM32_SVD.UInt3 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CR1_Register_1 use record UE at 0 range 0 .. 0; UESM at 0 range 1 .. 1; RE at 0 range 2 .. 2; TE at 0 range 3 .. 3; IDLEIE at 0 range 4 .. 4; RXNEIE at 0 range 5 .. 5; TCIE at 0 range 6 .. 6; TXEIE at 0 range 7 .. 7; PEIE at 0 range 8 .. 8; PS at 0 range 9 .. 9; PCE at 0 range 10 .. 10; WAKE at 0 range 11 .. 11; M0 at 0 range 12 .. 12; MME at 0 range 13 .. 13; CMIE at 0 range 14 .. 14; OVER8 at 0 range 15 .. 15; DEDT at 0 range 16 .. 20; DEAT at 0 range 21 .. 25; RTOIE at 0 range 26 .. 26; EOBIE at 0 range 27 .. 27; M1 at 0 range 28 .. 28; Reserved_29_31 at 0 range 29 .. 31; end record; subtype CR2_LBDL_Field is STM32_SVD.Bit; subtype CR2_LBDIE_Field is STM32_SVD.Bit; subtype CR2_LBCL_Field is STM32_SVD.Bit; subtype CR2_CPHA_Field is STM32_SVD.Bit; subtype CR2_CPOL_Field is STM32_SVD.Bit; subtype CR2_LINEN_Field is STM32_SVD.Bit; subtype CR2_ABREN_Field is STM32_SVD.Bit; -- CR2_ABRMOD array element subtype CR2_ABRMOD_Element is STM32_SVD.Bit; -- CR2_ABRMOD array type CR2_ABRMOD_Field_Array is array (0 .. 1) of CR2_ABRMOD_Element with Component_Size => 1, Size => 2; -- Type definition for CR2_ABRMOD type CR2_ABRMOD_Field (As_Array : Boolean := False) is record case As_Array is when False => -- ABRMOD as a value Val : STM32_SVD.UInt2; when True => -- ABRMOD as an array Arr : CR2_ABRMOD_Field_Array; end case; end record with Unchecked_Union, Size => 2; for CR2_ABRMOD_Field use record Val at 0 range 0 .. 1; Arr at 0 range 0 .. 1; end record; subtype CR2_RTOEN_Field is STM32_SVD.Bit; -- Control register 2 type CR2_Register_1 is record -- unspecified Reserved_0_3 : STM32_SVD.UInt4 := 16#0#; -- 7-bit Address Detection/4-bit Address Detection ADDM7 : CR2_ADDM7_Field := 16#0#; -- LIN break detection length LBDL : CR2_LBDL_Field := 16#0#; -- LIN break detection interrupt enable LBDIE : CR2_LBDIE_Field := 16#0#; -- unspecified Reserved_7_7 : STM32_SVD.Bit := 16#0#; -- Last bit clock pulse LBCL : CR2_LBCL_Field := 16#0#; -- Clock phase CPHA : CR2_CPHA_Field := 16#0#; -- Clock polarity CPOL : CR2_CPOL_Field := 16#0#; -- Clock enable CLKEN : CR2_CLKEN_Field := 16#0#; -- STOP bits STOP : CR2_STOP_Field := 16#0#; -- LIN mode enable LINEN : CR2_LINEN_Field := 16#0#; -- Swap TX/RX pins SWAP : CR2_SWAP_Field := 16#0#; -- RX pin active level inversion RXINV : CR2_RXINV_Field := 16#0#; -- TX pin active level inversion TXINV : CR2_TXINV_Field := 16#0#; -- Binary data inversion TAINV : CR2_TAINV_Field := 16#0#; -- Most significant bit first MSBFIRST : CR2_MSBFIRST_Field := 16#0#; -- Auto baud rate enable ABREN : CR2_ABREN_Field := 16#0#; -- ABRMOD0 ABRMOD : CR2_ABRMOD_Field := (As_Array => False, Val => 16#0#); -- Receiver timeout enable RTOEN : CR2_RTOEN_Field := 16#0#; -- Address of the USART node ADD0_3 : CR2_ADD0_3_Field := 16#0#; -- Address of the USART node ADD4_7 : CR2_ADD4_7_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CR2_Register_1 use record Reserved_0_3 at 0 range 0 .. 3; ADDM7 at 0 range 4 .. 4; LBDL at 0 range 5 .. 5; LBDIE at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; LBCL at 0 range 8 .. 8; CPHA at 0 range 9 .. 9; CPOL at 0 range 10 .. 10; CLKEN at 0 range 11 .. 11; STOP at 0 range 12 .. 13; LINEN at 0 range 14 .. 14; SWAP at 0 range 15 .. 15; RXINV at 0 range 16 .. 16; TXINV at 0 range 17 .. 17; TAINV at 0 range 18 .. 18; MSBFIRST at 0 range 19 .. 19; ABREN at 0 range 20 .. 20; ABRMOD at 0 range 21 .. 22; RTOEN at 0 range 23 .. 23; ADD0_3 at 0 range 24 .. 27; ADD4_7 at 0 range 28 .. 31; end record; subtype CR3_IREN_Field is STM32_SVD.Bit; subtype CR3_IRLP_Field is STM32_SVD.Bit; subtype CR3_NACK_Field is STM32_SVD.Bit; subtype CR3_SCEN_Field is STM32_SVD.Bit; subtype CR3_ONEBIT_Field is STM32_SVD.Bit; subtype CR3_SCARCNT_Field is STM32_SVD.UInt3; -- Control register 3 type CR3_Register_1 is record -- Error interrupt enable EIE : CR3_EIE_Field := 16#0#; -- Ir mode enable IREN : CR3_IREN_Field := 16#0#; -- Ir low-power IRLP : CR3_IRLP_Field := 16#0#; -- Half-duplex selection HDSEL : CR3_HDSEL_Field := 16#0#; -- Smartcard NACK enable NACK : CR3_NACK_Field := 16#0#; -- Smartcard mode enable SCEN : CR3_SCEN_Field := 16#0#; -- DMA enable receiver DMAR : CR3_DMAR_Field := 16#0#; -- DMA enable transmitter DMAT : CR3_DMAT_Field := 16#0#; -- RTS enable RTSE : CR3_RTSE_Field := 16#0#; -- CTS enable CTSE : CR3_CTSE_Field := 16#0#; -- CTS interrupt enable CTSIE : CR3_CTSIE_Field := 16#0#; -- One sample bit method enable ONEBIT : CR3_ONEBIT_Field := 16#0#; -- Overrun Disable OVRDIS : CR3_OVRDIS_Field := 16#0#; -- DMA Disable on Reception Error DDRE : CR3_DDRE_Field := 16#0#; -- Driver enable mode DEM : CR3_DEM_Field := 16#0#; -- Driver enable polarity selection DEP : CR3_DEP_Field := 16#0#; -- unspecified Reserved_16_16 : STM32_SVD.Bit := 16#0#; -- Smartcard auto-retry count SCARCNT : CR3_SCARCNT_Field := 16#0#; -- Wakeup from Stop mode interrupt flag selection WUS : CR3_WUS_Field := 16#0#; -- Wakeup from Stop mode interrupt enable WUFIE : CR3_WUFIE_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 CR3_Register_1 use record EIE at 0 range 0 .. 0; IREN at 0 range 1 .. 1; IRLP at 0 range 2 .. 2; HDSEL at 0 range 3 .. 3; NACK at 0 range 4 .. 4; SCEN at 0 range 5 .. 5; DMAR at 0 range 6 .. 6; DMAT at 0 range 7 .. 7; RTSE at 0 range 8 .. 8; CTSE at 0 range 9 .. 9; CTSIE at 0 range 10 .. 10; ONEBIT at 0 range 11 .. 11; OVRDIS at 0 range 12 .. 12; DDRE at 0 range 13 .. 13; DEM at 0 range 14 .. 14; DEP at 0 range 15 .. 15; Reserved_16_16 at 0 range 16 .. 16; SCARCNT at 0 range 17 .. 19; WUS at 0 range 20 .. 21; WUFIE at 0 range 22 .. 22; Reserved_23_31 at 0 range 23 .. 31; end record; subtype BRR_DIV_Fraction_Field is STM32_SVD.UInt4; subtype BRR_DIV_Mantissa_Field is STM32_SVD.UInt12; -- Baud rate register type BRR_Register_1 is record -- DIV_Fraction DIV_Fraction : BRR_DIV_Fraction_Field := 16#0#; -- DIV_Mantissa DIV_Mantissa : BRR_DIV_Mantissa_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 BRR_Register_1 use record DIV_Fraction at 0 range 0 .. 3; DIV_Mantissa at 0 range 4 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype GTPR_PSC_Field is STM32_SVD.Byte; subtype GTPR_GT_Field is STM32_SVD.Byte; -- Guard time and prescaler register type GTPR_Register is record -- Prescaler value PSC : GTPR_PSC_Field := 16#0#; -- Guard time value GT : GTPR_GT_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 GTPR_Register use record PSC at 0 range 0 .. 7; GT at 0 range 8 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype RTOR_RTO_Field is STM32_SVD.UInt24; subtype RTOR_BLEN_Field is STM32_SVD.Byte; -- Receiver timeout register type RTOR_Register is record -- Receiver timeout value RTO : RTOR_RTO_Field := 16#0#; -- Block Length BLEN : RTOR_BLEN_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for RTOR_Register use record RTO at 0 range 0 .. 23; BLEN at 0 range 24 .. 31; end record; subtype RQR_ABRRQ_Field is STM32_SVD.Bit; subtype RQR_TXFRQ_Field is STM32_SVD.Bit; -- Request register type RQR_Register_1 is record -- Write-only. Auto baud rate request ABRRQ : RQR_ABRRQ_Field := 16#0#; -- Write-only. Send break request SBKRQ : RQR_SBKRQ_Field := 16#0#; -- Write-only. Mute mode request MMRQ : RQR_MMRQ_Field := 16#0#; -- Write-only. Receive data flush request RXFRQ : RQR_RXFRQ_Field := 16#0#; -- Write-only. Transmit data flush request TXFRQ : RQR_TXFRQ_Field := 16#0#; -- unspecified Reserved_5_31 : STM32_SVD.UInt27 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for RQR_Register_1 use record ABRRQ at 0 range 0 .. 0; SBKRQ at 0 range 1 .. 1; MMRQ at 0 range 2 .. 2; RXFRQ at 0 range 3 .. 3; TXFRQ at 0 range 4 .. 4; Reserved_5_31 at 0 range 5 .. 31; end record; subtype ISR_LBDF_Field is STM32_SVD.Bit; subtype ISR_RTOF_Field is STM32_SVD.Bit; subtype ISR_EOBF_Field is STM32_SVD.Bit; subtype ISR_ABRE_Field is STM32_SVD.Bit; subtype ISR_ABRF_Field is STM32_SVD.Bit; -- Interrupt & status register type ISR_Register_1 is record -- Read-only. PE PE : ISR_PE_Field; -- Read-only. FE FE : ISR_FE_Field; -- Read-only. NF NF : ISR_NF_Field; -- Read-only. ORE ORE : ISR_ORE_Field; -- Read-only. IDLE IDLE : ISR_IDLE_Field; -- Read-only. RXNE RXNE : ISR_RXNE_Field; -- Read-only. TC TC : ISR_TC_Field; -- Read-only. TXE TXE : ISR_TXE_Field; -- Read-only. LBDF LBDF : ISR_LBDF_Field; -- Read-only. CTSIF CTSIF : ISR_CTSIF_Field; -- Read-only. CTS CTS : ISR_CTS_Field; -- Read-only. RTOF RTOF : ISR_RTOF_Field; -- Read-only. EOBF EOBF : ISR_EOBF_Field; -- unspecified Reserved_13_13 : STM32_SVD.Bit; -- Read-only. ABRE ABRE : ISR_ABRE_Field; -- Read-only. ABRF ABRF : ISR_ABRF_Field; -- Read-only. BUSY BUSY : ISR_BUSY_Field; -- Read-only. CMF CMF : ISR_CMF_Field; -- Read-only. SBKF SBKF : ISR_SBKF_Field; -- Read-only. RWU RWU : ISR_RWU_Field; -- Read-only. WUF WUF : ISR_WUF_Field; -- Read-only. TEACK TEACK : ISR_TEACK_Field; -- Read-only. REACK REACK : ISR_REACK_Field; -- unspecified Reserved_23_31 : STM32_SVD.UInt9; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ISR_Register_1 use record PE at 0 range 0 .. 0; FE at 0 range 1 .. 1; NF at 0 range 2 .. 2; ORE at 0 range 3 .. 3; IDLE at 0 range 4 .. 4; RXNE at 0 range 5 .. 5; TC at 0 range 6 .. 6; TXE at 0 range 7 .. 7; LBDF at 0 range 8 .. 8; CTSIF at 0 range 9 .. 9; CTS at 0 range 10 .. 10; RTOF at 0 range 11 .. 11; EOBF at 0 range 12 .. 12; Reserved_13_13 at 0 range 13 .. 13; ABRE at 0 range 14 .. 14; ABRF at 0 range 15 .. 15; BUSY at 0 range 16 .. 16; CMF at 0 range 17 .. 17; SBKF at 0 range 18 .. 18; RWU at 0 range 19 .. 19; WUF at 0 range 20 .. 20; TEACK at 0 range 21 .. 21; REACK at 0 range 22 .. 22; Reserved_23_31 at 0 range 23 .. 31; end record; subtype ICR_LBDCF_Field is STM32_SVD.Bit; subtype ICR_RTOCF_Field is STM32_SVD.Bit; subtype ICR_EOBCF_Field is STM32_SVD.Bit; -- Interrupt flag clear register type ICR_Register_1 is record -- Write-only. Parity error clear flag PECF : ICR_PECF_Field := 16#0#; -- Write-only. Framing error clear flag FECF : ICR_FECF_Field := 16#0#; -- Write-only. Noise detected clear flag NCF : ICR_NCF_Field := 16#0#; -- Write-only. Overrun error clear flag ORECF : ICR_ORECF_Field := 16#0#; -- Write-only. Idle line detected clear flag IDLECF : ICR_IDLECF_Field := 16#0#; -- unspecified Reserved_5_5 : STM32_SVD.Bit := 16#0#; -- Write-only. Transmission complete clear flag TCCF : ICR_TCCF_Field := 16#0#; -- unspecified Reserved_7_7 : STM32_SVD.Bit := 16#0#; -- Write-only. LIN break detection clear flag LBDCF : ICR_LBDCF_Field := 16#0#; -- Write-only. CTS clear flag CTSCF : ICR_CTSCF_Field := 16#0#; -- unspecified Reserved_10_10 : STM32_SVD.Bit := 16#0#; -- Write-only. Receiver timeout clear flag RTOCF : ICR_RTOCF_Field := 16#0#; -- Write-only. End of block clear flag EOBCF : ICR_EOBCF_Field := 16#0#; -- unspecified Reserved_13_16 : STM32_SVD.UInt4 := 16#0#; -- Write-only. Character match clear flag CMCF : ICR_CMCF_Field := 16#0#; -- unspecified Reserved_18_19 : STM32_SVD.UInt2 := 16#0#; -- Write-only. Wakeup from Stop mode clear flag WUCF : ICR_WUCF_Field := 16#0#; -- unspecified Reserved_21_31 : STM32_SVD.UInt11 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for ICR_Register_1 use record PECF at 0 range 0 .. 0; FECF at 0 range 1 .. 1; NCF at 0 range 2 .. 2; ORECF at 0 range 3 .. 3; IDLECF at 0 range 4 .. 4; Reserved_5_5 at 0 range 5 .. 5; TCCF at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; LBDCF at 0 range 8 .. 8; CTSCF at 0 range 9 .. 9; Reserved_10_10 at 0 range 10 .. 10; RTOCF at 0 range 11 .. 11; EOBCF at 0 range 12 .. 12; Reserved_13_16 at 0 range 13 .. 16; CMCF at 0 range 17 .. 17; Reserved_18_19 at 0 range 18 .. 19; WUCF at 0 range 20 .. 20; Reserved_21_31 at 0 range 21 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Universal synchronous asynchronous receiver transmitter type LPUSART1_Peripheral is record -- Control register 1 CR1 : aliased CR1_Register; -- Control register 2 CR2 : aliased CR2_Register; -- Control register 3 CR3 : aliased CR3_Register; -- Baud rate register BRR : aliased BRR_Register; -- Request register RQR : aliased RQR_Register; -- Interrupt & status register ISR : aliased ISR_Register; -- Interrupt flag clear register ICR : aliased ICR_Register; -- Receive data register RDR : aliased RDR_Register; -- Transmit data register TDR : aliased TDR_Register; end record with Volatile; for LPUSART1_Peripheral use record CR1 at 16#0# range 0 .. 31; CR2 at 16#4# range 0 .. 31; CR3 at 16#8# range 0 .. 31; BRR at 16#C# range 0 .. 31; RQR at 16#18# range 0 .. 31; ISR at 16#1C# range 0 .. 31; ICR at 16#20# range 0 .. 31; RDR at 16#24# range 0 .. 31; TDR at 16#28# range 0 .. 31; end record; -- Universal synchronous asynchronous receiver transmitter LPUSART1_Periph : aliased LPUSART1_Peripheral with Import, Address => LPUSART1_Base; -- Universal synchronous asynchronous receiver transmitter type USART_Peripheral is record -- Control register 1 CR1 : aliased CR1_Register_1; -- Control register 2 CR2 : aliased CR2_Register_1; -- Control register 3 CR3 : aliased CR3_Register_1; -- Baud rate register BRR : aliased BRR_Register_1; -- Guard time and prescaler register GTPR : aliased GTPR_Register; -- Receiver timeout register RTOR : aliased RTOR_Register; -- Request register RQR : aliased RQR_Register_1; -- Interrupt & status register ISR : aliased ISR_Register_1; -- Interrupt flag clear register ICR : aliased ICR_Register_1; -- Receive data register RDR : aliased RDR_Register; -- Transmit data register TDR : aliased TDR_Register; end record with Volatile; for USART_Peripheral use record CR1 at 16#0# range 0 .. 31; CR2 at 16#4# range 0 .. 31; CR3 at 16#8# range 0 .. 31; BRR at 16#C# range 0 .. 31; GTPR at 16#10# range 0 .. 31; RTOR at 16#14# range 0 .. 31; RQR at 16#18# range 0 .. 31; ISR at 16#1C# range 0 .. 31; ICR at 16#20# range 0 .. 31; RDR at 16#24# range 0 .. 31; TDR at 16#28# range 0 .. 31; end record; -- Universal synchronous asynchronous receiver transmitter USART1_Periph : aliased USART_Peripheral with Import, Address => USART1_Base; -- Universal synchronous asynchronous receiver transmitter USART2_Periph : aliased USART_Peripheral with Import, Address => USART2_Base; -- Universal synchronous asynchronous receiver transmitter USART4_Periph : aliased USART_Peripheral with Import, Address => USART4_Base; -- Universal synchronous asynchronous receiver transmitter USART5_Periph : aliased USART_Peripheral with Import, Address => USART5_Base; end STM32_SVD.USART;
apple-oss-distributions/old_ncurses
Ada
3,514
ads
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding -- -- -- -- Terminal_Interface.Curses.Text_IO.Enumeration_IO -- -- -- -- S P E C -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Juergen Pfeifer <[email protected]> 1996 -- Version Control: -- $Revision: 1.1.1.1 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ generic type Enum is (<>); package Terminal_Interface.Curses.Text_IO.Enumeration_IO is Default_Width : Field := 0; Default_Setting : Type_Set := Mixed_Case; procedure Put (Win : in Window; Item : in Enum; Width : in Field := Default_Width; Set : in Type_Set := Default_Setting); procedure Put (Item : in Enum; Width : in Field := Default_Width; Set : in Type_Set := Default_Setting); private pragma Inline (Put); end Terminal_Interface.Curses.Text_IO.Enumeration_IO;
zhmu/ananas
Ada
6,246
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . P A C K _ 8 9 -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with System.Storage_Elements; with System.Unsigned_Types; package body System.Pack_89 is subtype Bit_Order is System.Bit_Order; Reverse_Bit_Order : constant Bit_Order := Bit_Order'Val (1 - Bit_Order'Pos (System.Default_Bit_Order)); subtype Ofs is System.Storage_Elements.Storage_Offset; subtype Uns is System.Unsigned_Types.Unsigned; subtype N07 is System.Unsigned_Types.Unsigned range 0 .. 7; use type System.Storage_Elements.Storage_Offset; use type System.Unsigned_Types.Unsigned; type Cluster is record E0, E1, E2, E3, E4, E5, E6, E7 : Bits_89; end record; for Cluster use record E0 at 0 range 0 * Bits .. 0 * Bits + Bits - 1; E1 at 0 range 1 * Bits .. 1 * Bits + Bits - 1; E2 at 0 range 2 * Bits .. 2 * Bits + Bits - 1; E3 at 0 range 3 * Bits .. 3 * Bits + Bits - 1; E4 at 0 range 4 * Bits .. 4 * Bits + Bits - 1; E5 at 0 range 5 * Bits .. 5 * Bits + Bits - 1; E6 at 0 range 6 * Bits .. 6 * Bits + Bits - 1; E7 at 0 range 7 * Bits .. 7 * Bits + Bits - 1; end record; for Cluster'Size use Bits * 8; for Cluster'Alignment use Integer'Min (Standard'Maximum_Alignment, 1 + 1 * Boolean'Pos (Bits mod 2 = 0) + 2 * Boolean'Pos (Bits mod 4 = 0)); -- Use maximum possible alignment, given the bit field size, since this -- will result in the most efficient code possible for the field. type Cluster_Ref is access Cluster; type Rev_Cluster is new Cluster with Bit_Order => Reverse_Bit_Order, Scalar_Storage_Order => Reverse_Bit_Order; type Rev_Cluster_Ref is access Rev_Cluster; ------------ -- Get_89 -- ------------ function Get_89 (Arr : System.Address; N : Natural; Rev_SSO : Boolean) return Bits_89 is A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8); C : Cluster_Ref with Address => A'Address, Import; RC : Rev_Cluster_Ref with Address => A'Address, Import; begin if Rev_SSO then case N07 (Uns (N) mod 8) is when 0 => return RC.E0; when 1 => return RC.E1; when 2 => return RC.E2; when 3 => return RC.E3; when 4 => return RC.E4; when 5 => return RC.E5; when 6 => return RC.E6; when 7 => return RC.E7; end case; else case N07 (Uns (N) mod 8) is when 0 => return C.E0; when 1 => return C.E1; when 2 => return C.E2; when 3 => return C.E3; when 4 => return C.E4; when 5 => return C.E5; when 6 => return C.E6; when 7 => return C.E7; end case; end if; end Get_89; ------------ -- Set_89 -- ------------ procedure Set_89 (Arr : System.Address; N : Natural; E : Bits_89; Rev_SSO : Boolean) is A : constant System.Address := Arr + Bits * Ofs (Uns (N) / 8); C : Cluster_Ref with Address => A'Address, Import; RC : Rev_Cluster_Ref with Address => A'Address, Import; begin if Rev_SSO then case N07 (Uns (N) mod 8) is when 0 => RC.E0 := E; when 1 => RC.E1 := E; when 2 => RC.E2 := E; when 3 => RC.E3 := E; when 4 => RC.E4 := E; when 5 => RC.E5 := E; when 6 => RC.E6 := E; when 7 => RC.E7 := E; end case; else case N07 (Uns (N) mod 8) is when 0 => C.E0 := E; when 1 => C.E1 := E; when 2 => C.E2 := E; when 3 => C.E3 := E; when 4 => C.E4 := E; when 5 => C.E5 := E; when 6 => C.E6 := E; when 7 => C.E7 := E; end case; end if; end Set_89; end System.Pack_89;
tum-ei-rcs/StratoX
Ada
4,194
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . S E C O N D A R Y _ S T A C K . S I N G L E _ T A S K -- -- -- -- S p e c -- -- -- -- Copyright (C) 2005-2014, 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. -- -- -- -- -- -- -- -- -- -- -- -- 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 provides a default and simple implementation of a function -- that returns a pointer to a secondary stack. This function is intended -- to be used on single-threaded applications. Multi-threaded applications -- require thread-local data. -- -- The function defined in this package is used when the two following -- conditions are met: -- 1) No user-defined implementation has been provided. That is, the -- symbol __gnat_get_sec_stack is not exported by the user's code. -- 2) No tasking is used. When tasking is used, the __gnat_get_sec_stack -- reference is resolved by libgnarl.a (that contains a thread-safe -- implementation of the secondary stack), so that the single-threaded -- version is not included in the final executable. -- -- Note that the problem of providing different implementations for tasking -- and not tasking applications is usually solved by using the -- System.Soft_Links mechanism. This approach has not been followed because -- this mechanism if it not available for the High Integrity Ravenscar run -- times. -- -- Another possibility would be to always use the tasking (multi-threaded) -- version of this function. However, it forces a dependency on libgnarl in -- libgnat, which is not desirable. pragma Restrictions (No_Elaboration_Code); -- We want to guarantee the absence of elaboration code because the -- binder does not handle references to this package. package System.Secondary_Stack.Single_Task with SPARK_Mode => On is function Get_Sec_Stack return Address; pragma Export (C, Get_Sec_Stack, "__gnat_get_secondary_stack"); -- Return the address of the secondary stack to be used for -- single-threaded applications, as expected by -- System.Secondary_Stack. end System.Secondary_Stack.Single_Task;
zhmu/ananas
Ada
450
adb
-- { dg-do run } with Ada.Tags; procedure tag1 is type T is tagged null record; X : Ada.Tags.Tag; begin begin X := Ada.Tags.Descendant_Tag ("Internal tag at 16#0#", T'Tag); raise Program_Error; exception when Ada.Tags.Tag_Error => null; end; begin X := Ada.Tags.Descendant_Tag ("Internal tag at 16#XXXX#", T'Tag); raise Program_Error; exception when Ada.Tags.Tag_Error => null; end; end;
AdaCore/libadalang
Ada
498
adb
procedure Test is generic type T is private; package Refs is type Reference_Type (Element : access T) is limited null record with Implicit_Dereference => Element; end Refs; package Pkg is type T is tagged null record; package T_Refs is new Refs (T); function Get return T_Refs.Reference_Type is (Element => new T'(null record)); end Pkg; B : Boolean; begin B := Pkg.Get in Pkg.T; pragma Test_Statement; end Test;
nerilex/ada-util
Ada
3,685
adb
----------------------------------------------------------------------- -- Util.Beans.Basic.Lists -- List bean given access to a vector -- Copyright (C) 2011, 2013 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Unchecked_Deallocation; package body Util.Beans.Basic.Lists is -- ------------------------------ -- Initialize the list bean. -- ------------------------------ overriding procedure Initialize (Object : in out List_Bean) is Bean : constant Readonly_Bean_Access := Object.Current'Unchecked_Access; begin Object.Row := Util.Beans.Objects.To_Object (Bean, Util.Beans.Objects.STATIC); end Initialize; -- ------------------------------ -- Get the number of elements in the list. -- ------------------------------ function Get_Count (From : in List_Bean) return Natural is begin return Natural (Vectors.Length (From.List)); end Get_Count; -- ------------------------------ -- Set the current row index. Valid row indexes start at 1. -- ------------------------------ procedure Set_Row_Index (From : in out List_Bean; Index : in Natural) is begin From.Current_Index := Index; From.Current := Vectors.Element (From.List, Index - 1); end Set_Row_Index; -- ------------------------------ -- Returns the current row index. -- ------------------------------ function Get_Row_Index (From : in List_Bean) return Natural is begin return From.Current_Index; end Get_Row_Index; -- ------------------------------ -- Get the element at the current row index. -- ------------------------------ function Get_Row (From : in List_Bean) return Util.Beans.Objects.Object is begin return From.Row; end Get_Row; -- ------------------------------ -- Get the value identified by the name. -- If the name cannot be found, the method should return the Null object. -- ------------------------------ function Get_Value (From : in List_Bean; Name : in String) return Util.Beans.Objects.Object is begin if Name = "count" then return Util.Beans.Objects.To_Object (Integer (From.List.Length)); elsif Name = "rowIndex" then return Util.Beans.Objects.To_Object (From.Current_Index); else return Util.Beans.Objects.Null_Object; end if; end Get_Value; -- ------------------------------ -- Deletes the list bean -- ------------------------------ procedure Free (List : in out Util.Beans.Basic.Readonly_Bean_Access) is procedure Free is new Ada.Unchecked_Deallocation (List_Bean'Class, List_Bean_Access); begin if List.all in List_Bean'Class then declare L : List_Bean_Access := List_Bean (List.all)'Unchecked_Access; begin Free (L); List := null; end; end if; end Free; end Util.Beans.Basic.Lists;
procrastiraptor/euler
Ada
302
adb
with Ada.Integer_Text_IO; procedure Euler2 is A, B: Integer := 1; Sum : Integer := 0; Tmp: Integer; begin while A < 4_000_000 loop if A mod 2 = 0 then Sum := Sum + A; end if; Tmp := A; A := A + B; B := Tmp; end loop; Ada.Integer_Text_IO.Put(Sum); end Euler2;
redparavoz/ada-wiki
Ada
3,192
ads
----------------------------------------------------------------------- -- wiki-streams-html-text_io -- Wiki HTML output stream on Ada Text_IO -- Copyright (C) 2016 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Wiki.Strings; with Wiki.Streams.Text_IO; -- === HTML Output Stream === -- The <tt>Wiki.Writers</tt> package defines the interfaces used by the renderer to write -- their outputs. -- -- The <tt>Input_Stream</tt> interface defines the interface that must be implemented to -- read the source Wiki content. The <tt>Read</tt> procedure is called by the parser -- repeatedly while scanning the Wiki content. package Wiki.Streams.Html.Text_IO is type Html_File_Output_Stream is limited new Wiki.Streams.Text_IO.File_Output_Stream and Html.Html_Output_Stream with private; -- Write an XML attribute within an XML element. -- The attribute value is escaped according to the XML escape rules. overriding procedure Write_Wide_Attribute (Stream : in out Html_File_Output_Stream; Name : in String; Content : in Wiki.Strings.UString); -- Write an XML attribute within an XML element. -- The attribute value is escaped according to the XML escape rules. overriding procedure Write_Wide_Attribute (Stream : in out Html_File_Output_Stream; Name : in String; Content : in Wide_Wide_String); -- Start an XML element with the given name. overriding procedure Start_Element (Stream : in out Html_File_Output_Stream; Name : in String); -- Closes an XML element of the given name. overriding procedure End_Element (Stream : in out Html_File_Output_Stream; Name : in String); -- Write a text escaping any character as necessary. overriding procedure Write_Wide_Text (Stream : in out Html_File_Output_Stream; Content : in Wiki.Strings.WString); -- Write the string to the stream. procedure Write_String (Stream : in out Html_File_Output_Stream'Class; Content : in String); private type Html_File_Output_Stream is limited new Wiki.Streams.Text_IO.File_Output_Stream and Html.Html_Output_Stream with record -- Whether an XML element must be closed (that is a '>' is necessary) Close_Start : Boolean := False; end record; end Wiki.Streams.Html.Text_IO;
godunko/adawebui
Ada
4,313
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2017-2020, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision: 5703 $ $Date: 2017-01-20 22:17:20 +0300 (Fri, 20 Jan 2017) $ ------------------------------------------------------------------------------ -- Generic slot with one parameter. ------------------------------------------------------------------------------ generic type Parameter_2_Type (<>) is limited private; package Web.Core.Connectables.Slots_0.Slots_1.Slots_2 is pragma Preelaborate; type Slot (<>) is abstract tagged limited private; type Signal is limited interface and Slots_1.Signal; not overriding procedure Connect (Self : in out Signal; Slot : Slots_2.Slot'Class) is abstract; private type Slot_End_2 is abstract new Slot_End_Base with null record; not overriding procedure Invoke (Self : in out Slot_End_2; Parameter_1 : Parameter_1_Type; Parameter_2 : Parameter_2_Type) is abstract; type Slot is abstract tagged limited null record; not overriding function Create_Slot_End (Self : Slot) return not null Slot_End_Access; end Web.Core.Connectables.Slots_0.Slots_1.Slots_2;
io7m/coreland-sqlite3-ada
Ada
5,524
adb
with Interfaces.C.Strings; with Interfaces.C; with SQLite3.Constants; with SQLite3.Thin; package body SQLite3.API is package C renames Interfaces.C; package CS renames Interfaces.C.Strings; use type CS.chars_ptr; use type SQLite3.Types.int_t; type CBridge_Context_t is record User_Data : User_Data_Access_Type; Callback : access procedure (Column_Names : in Column_Names_t; Column_Values : in Column_Values_t; User_Data : in User_Data_Access_Type); end record; pragma Convention (C, CBridge_Context_t); function Exec_CBridge (context : access CBridge_Context_t; num_columns : in SQLite3.Types.int_t; Column_Values : in SQLite3.Types.char_2star_t; Column_Names : in SQLite3.Types.char_2star_t) return SQLite3.Types.int_t; pragma Convention (C, Exec_CBridge); -- -- type conversion Callback -- function Exec_CBridge (context : access CBridge_Context_t; num_columns : in SQLite3.Types.int_t; Column_Values : in SQLite3.Types.char_2star_t; Column_Names : in SQLite3.Types.char_2star_t) return SQLite3.Types.int_t is array_size : constant Natural := Natural (num_columns); Ada_Column_Values : constant Column_Values_t := SQLite3.API.Convert (Column_Values, array_size); Ada_Column_Names : constant Column_Names_t := SQLite3.API.Convert (Column_Names, array_size); begin -- call Ada Callback with new arrays context.all.Callback (Column_Names => Ada_Column_Names, Column_Values => Ada_Column_Values, User_Data => context.all.User_Data); return 0; end Exec_CBridge; type CBridge_Callback_t is access function (context : access CBridge_Context_t; num_columns : in SQLite3.Types.int_t; Column_Values : in SQLite3.Types.char_2star_t; Column_Names : in SQLite3.Types.char_2star_t) return SQLite3.Types.int_t; pragma Convention (C, CBridge_Callback_t); -- not using the version from the Thin binding due to needing -- specific User_Data and Callback Types function SQLite3_exec (Database : in Database_t; SQL : in CS.chars_ptr; Callback : in CBridge_Callback_t; context : access CBridge_Context_t; Error_Message : in SQLite3.Types.char_2star_t) return SQLite3.Types.int_t; pragma Import (C, SQLite3_exec, "sqlite3_exec"); procedure SQLite3_free (data : CS.chars_ptr); pragma Import (C, SQLite3_free, "sqlite3_free"); -- -- exec SQL -- procedure Exec (Database : in Database_t; SQL : in String; Error : out Boolean; Error_Message : out US.Unbounded_String; Callback : in Exec_Callback_t := null; User_Data : in User_Data_Access_Type := null) is -- data to pass to C Callback C_Context : aliased CBridge_Context_t := (User_Data, Callback); -- C String Types SQL_C_Array : aliased C.char_array := C.To_C (SQL); Message : aliased CS.chars_ptr; Error_Value : SQLite3.Types.int_t; begin if Callback /= null then -- call SQLite3_exec with type conversion Callback Error_Value := SQLite3_exec (Database => Database, SQL => CS.To_Chars_Ptr (SQL_C_Array'Unchecked_Access), Callback => Exec_CBridge'Access, Context => C_Context'Unchecked_Access, Error_Message => Message'Address); else -- don't bother to go to the trouble of type conversion Error_Value := SQLite3.Thin.exec (DB => Database, SQL => CS.To_Chars_Ptr (SQL_C_Array'Unchecked_Access), Callback => null, Context => SQLite3.Types.Null_Ptr, Error_Message => Message'Address); end if; -- convert Error message if Error_Value /= SQLite3.Constants.SQLITE_OK then Error := True; US.Set_Unbounded_String (Error_Message, CS.Value (Message)); SQLite3_free (Message); else Error := False; end if; end Exec; procedure Close (Database : in Database_t) is Error_Code : constant SQLite3.Types.int_t := SQLite3.Thin.close (Database); begin if Error_Code /= SQLite3.Constants.SQLITE_OK then raise Database_Error with Error_Message (Database); end if; end Close; function SQLite3_open_v2 (file : in CS.chars_ptr; db : access SQLite3.Types.Database_t; mode : in Mode_t; vfs : in CS.chars_ptr := CS.Null_Ptr) return SQLite3.Types.int_t; pragma Import (C, SQLite3_open_v2, "sqlite3_open_v2"); procedure Open (File_Name : in String; Mode : in Mode_t := OPEN_READ_WRITE or OPEN_CREATE; Database : out SQLite3.Types.Database_t) is Func : aliased C.char_array := C.To_C (File_Name); DB : aliased SQLite3.Types.Database_t; Error_Code : constant SQLite3.Types.int_t := SQLite3_open_v2 (File => CS.To_Chars_Ptr (Func'Unchecked_Access), Mode => Mode, DB => DB'Unchecked_Access); begin Database := DB; if Error_Code /= SQLite3.Constants.SQLITE_OK then raise Database_Error with Error_Message (Database); end if; end Open; function Error_Message (Database : in Database_t) return String is begin return CS.Value (SQLite3.Thin.errmsg (Database)); end Error_Message; function Error_Code (Database : in Database_t) return Error_t is begin return Error_t'Val (SQLite3.Thin.errcode (Database)); end Error_Code; end SQLite3.API;
AdaCore/langkit
Ada
458
adb
with Langkit_Support.Adalog.Main_Support; use Langkit_Support.Adalog.Main_Support; -- Test that associations of two domains via the 'or' logic operators is -- exactly similar to having a single domain that is the concatenation of -- both. procedure Main is use T_Solver; use Refs; X : constant Refs.Logic_Var := Create ("X"); R : constant Relation := "or" (Domain (X, (1, 2, 3)), Domain (X, (4, 5, 6))); begin Solve_All (R); end Main;
mfkiwl/ewok-kernel-security-OS
Ada
2,298
ads
-- -- Copyright 2018 The wookey project team <[email protected]> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- package ewok.mpu.allocator with spark_mode => on is type t_region_entry is record used : boolean := false; -- Is region used? addr : system_address; -- Base address end record; ------------------------------- -- Pool of available regions -- ------------------------------- regions_pool : array (m4.mpu.t_region_number range USER_FREE_1_REGION .. USER_FREE_2_REGION) of t_region_entry := (others => (false, 0)); function is_free_region return boolean is (for some R in regions_pool'range => regions_pool(R).used = false) with ghost; function free_region_exist return boolean; function is_power_of_2 (n : unsigned_32) return boolean with post => (if is_power_of_2'result then (n and (n - 1)) = 0); function to_next_power_of_2 (n : unsigned_32) return unsigned_32 with pre => n > 0 and n <= 2*GBYTE, post => to_next_power_of_2'result >= n and is_power_of_2 (to_next_power_of_2'result); procedure map_in_pool (addr : in system_address; size : in unsigned_32; region_type : in ewok.mpu.t_region_type; subregion_mask : in m4.mpu.t_subregion_mask; success : out boolean); procedure unmap_from_pool (addr : in system_address); procedure unmap_all_from_pool; -- SPARK function is_in_pool (addr : system_address) return boolean; end ewok.mpu.allocator;
charlie5/lace
Ada
611
ads
-- This file is generated by SWIG. Please do *not* modify by hand. -- with Interfaces.C; package c_math_c.Pointers is -- Real_Pointer -- type Real_Pointer is access all c_math_c.Real; -- Real_Pointers -- type Real_Pointers is array (Interfaces.C .size_t range <>) of aliased c_math_c.Pointers.Real_Pointer; -- Index_Pointer -- type Index_Pointer is access all c_math_c.Index; -- Index_Pointers -- type Index_Pointers is array (Interfaces.C .size_t range <>) of aliased c_math_c.Pointers.Index_Pointer; end c_math_c.Pointers;
jwarwick/aoc_2020
Ada
1,449
ads
with Ada.Strings.Unbounded; with Ada.Containers.Hashed_Maps; use Ada.Containers; package VM is type Instruction_Index is new Natural; type VM is private; VM_Exception : exception; function load_file(file : in String) return VM; procedure reset(v : in out VM); function acc(v : in VM) return Integer; function pc(v : in VM) return Instruction_Index; function eval(v : in out VM; max_steps : in Positive) return Boolean; function step(v : in out VM) return Boolean; function instructions(v : in VM) return Count_Type; procedure print(v : in VM); procedure swap_nop_jmp(idx : in Instruction_Index; v : in out VM); private type Op is (acc, jmp, nop, halt); type Op_Record (Ins : Op := nop) is record Index : Instruction_Index; case Ins is when acc | jmp | nop => Arg : Integer; when halt => null; end case; end record; function instruction_index_hash(key : in Instruction_Index) return Hash_Type; package Op_Hashed_Maps is new Ada.Containers.Hashed_Maps (Key_Type => Instruction_Index, Element_Type => Op_Record, Hash => instruction_index_hash, Equivalent_Keys => "="); use Op_Hashed_Maps; type VM is record Source : Ada.Strings.Unbounded.Unbounded_String; PC : Instruction_Index := 0; Acc : Integer := 0; Halted : Boolean := false; Instructions : Op_Hashed_Maps.Map := Empty_Map; end record; end VM;
reznikmm/matreshka
Ada
4,179
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2017, 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 test detects presense of AWS library. ------------------------------------------------------------------------------ with Configure.Abstract_Tests; package Configure.Tests.AWS is type AWS_Test is new Configure.Abstract_Tests.Abstract_Test with private; overriding function Name (Self : AWS_Test) return String; -- Returns name of the test to be used in reports. overriding function Help (Self : AWS_Test) return Unbounded_String_Vector; -- Returns help information for test. overriding procedure Execute (Self : in out AWS_Test; Arguments : in out Unbounded_String_Vector); -- Executes test's actions. All used arguments must be removed from -- Arguments. private type AWS_Test is new Configure.Abstract_Tests.Abstract_Test with null record; end Configure.Tests.AWs;
reinertk/cpros
Ada
3,585
adb
-------------------------------------------------------------------------------------- -- -- Copyright (c) 2016 Reinert Korsnes -- Permission is hereby granted, free of charge, to any person obtaining a -- copy of this software and associated documentation files (the "Software"), -- to deal in the Software without restriction, including without limitation -- the rights to use, copy, modify, merge, publish, distribute, sublicense, -- and/or sell copies of the Software, and to permit persons to whom the -- Software is furnished to do so, subject to the following conditions: -- The above copyright notice and this permission notice shall be included in -- all copies or substantial portions of the Software. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -- DEALINGS IN THE SOFTWARE. -- -- NB: this is the MIT License, as found 2016-09-27 on the site -- http://www.opensource.org/licenses/mit-license.php -------------------------------------------------------------------------------------- -- Change log: -- 2020.06.14: Major upgrade (by Reinert Korsnes). -------------------------------------------------------------------------------------- with Text_IO; use Text_IO; with Ada; with Ada.Text_IO; with cpros; with split_string; procedure cpros_test1 is -- list of commands (preceeded by "c_"): type c_t is (c_this, c_that); -- (you are supposed to define your own version of the type "c_t" providing your actual commands. procedure cpros_actual1 (command : in c_t; command_string : in String) is -- command contains actual entered/input command word (converted to type c_t). -- command_string contains the the whole command line. lw : constant String := split_string.last_word (command_string); nw : constant Natural := split_string.number_of_words (command_string); begin Put_Line ("You did enter" & Natural'Image (nw) & " command component(s) (free for use). Last argument is """ & (if nw > 1 then lw else "") & """"); for i in 1 .. nw loop Put_Line (" Word number" & Integer'Image (i) & " " & split_string.word (command_string, i)); end loop; New_Line; -- -- use: -- raise cfe0 with "** message ** "; -- to interrupt erroneous commands (according to below). -- case command is when c_this => Put_Line (" You ended up here (this)"); if nw > 5 then raise cpros.cfe0 with "Wrong number of command words"; end if; when c_that => Put_Line (" You ended up here (that)"); end case; return; end cpros_actual1; procedure cpros1 is new cpros.cpros0 (c_t => c_t, cpros_main => cpros_actual1); begin -- cprosa below calls cpros_actual1 (which substitutes formal procedure in the generic cpros_package1) -- for each input command line (from terminal or file). It passes to the procedure cpros_actual1 a command -- name (stored in the variable "command") and also the whole command stored in "command_string": cpros1 (file1 => Ada.Text_IO.Standard_Input); end cpros_test1;
reznikmm/matreshka
Ada
3,709
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Table_Operator_Attributes is pragma Preelaborate; type ODF_Table_Operator_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Table_Operator_Attribute_Access is access all ODF_Table_Operator_Attribute'Class with Storage_Size => 0; end ODF.DOM.Table_Operator_Attributes;
RREE/ada-util
Ada
5,612
ads
----------------------------------------------------------------------- -- util-encoders-hmac-sha1 -- Compute HMAC-SHA1 authentication code -- Copyright (C) 2011, 2012, 2017, 2019 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; with Ada.Finalization; with Util.Encoders.SHA1; -- The <b>Util.Encodes.HMAC.SHA1</b> package generates HMAC-SHA1 authentication -- (See RFC 2104 - HMAC: Keyed-Hashing for Message Authentication). package Util.Encoders.HMAC.SHA1 is pragma Preelaborate; -- Sign the data string with the key and return the HMAC-SHA1 code in binary. function Sign (Key : in String; Data : in String) return Util.Encoders.SHA1.Hash_Array; -- Sign the data string with the key and return the HMAC-SHA1 code as hexadecimal string. function Sign (Key : in String; Data : in String) return Util.Encoders.SHA1.Digest; -- Sign the data array with the key and return the HMAC-SHA256 code in the result. procedure Sign (Key : in Ada.Streams.Stream_Element_Array; Data : in Ada.Streams.Stream_Element_Array; Result : out Util.Encoders.SHA1.Hash_Array); -- Sign the data string with the key and return the HMAC-SHA1 code as base64 string. -- When <b>URL</b> is True, use the base64 URL alphabet to encode in base64. function Sign_Base64 (Key : in String; Data : in String; URL : in Boolean := False) return Util.Encoders.SHA1.Base64_Digest; -- ------------------------------ -- HMAC-SHA1 Context -- ------------------------------ type Context is limited private; -- Set the hmac private key. The key must be set before calling any <b>Update</b> -- procedure. procedure Set_Key (E : in out Context; Key : in String); -- Set the hmac private key. The key must be set before calling any <b>Update</b> -- procedure. procedure Set_Key (E : in out Context; Key : in Ada.Streams.Stream_Element_Array); -- Update the hash with the string. procedure Update (E : in out Context; S : in String); -- Update the hash with the string. procedure Update (E : in out Context; S : in Ada.Streams.Stream_Element_Array); -- Computes the HMAC-SHA1 with the private key and the data collected by -- the <b>Update</b> procedures. Returns the raw binary hash in <b>Hash</b>. procedure Finish (E : in out Context; Hash : out Util.Encoders.SHA1.Hash_Array); -- Computes the HMAC-SHA1 with the private key and the data collected by -- the <b>Update</b> procedures. Returns the hexadecimal hash in <b>Hash</b>. procedure Finish (E : in out Context; Hash : out Util.Encoders.SHA1.Digest); -- Computes the HMAC-SHA1 with the private key and the data collected by -- the <b>Update</b> procedures. Returns the base64 hash in <b>Hash</b>. -- When <b>URL</b> is True, use the base64 URL alphabet to encode in base64. procedure Finish_Base64 (E : in out Context; Hash : out Util.Encoders.SHA1.Base64_Digest; URL : in Boolean := False); -- ------------------------------ -- HMAC-SHA1 encoder -- ------------------------------ -- This <b>Encoder</b> translates the (binary) input stream into -- an SHA1 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 -- an SHA-1 hash 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); private type Encoder is new Util.Encoders.Transformer with null record; type Context is new Ada.Finalization.Limited_Controlled with record SHA : Util.Encoders.SHA1.Context; Key : Ada.Streams.Stream_Element_Array (0 .. 63); Key_Len : Ada.Streams.Stream_Element_Offset; end record; -- Initialize the SHA-1 context. overriding procedure Initialize (E : in out Context); end Util.Encoders.HMAC.SHA1;
reznikmm/matreshka
Ada
6,900
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.Sender_Title_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_Sender_Title_Element_Node is begin return Self : Text_Sender_Title_Element_Node do Matreshka.ODF_Text.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Text_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Text_Sender_Title_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Enter_Text_Sender_Title (ODF.DOM.Text_Sender_Title_Elements.ODF_Text_Sender_Title_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Enter_Node (Visitor, Control); end if; end Enter_Node; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Text_Sender_Title_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Sender_Title_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Text_Sender_Title_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Leave_Text_Sender_Title (ODF.DOM.Text_Sender_Title_Elements.ODF_Text_Sender_Title_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Leave_Node (Visitor, Control); end if; end Leave_Node; ---------------- -- Visit_Node -- ---------------- overriding procedure Visit_Node (Self : not null access Text_Sender_Title_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then ODF.DOM.Iterators.Abstract_ODF_Iterator'Class (Iterator).Visit_Text_Sender_Title (Visitor, ODF.DOM.Text_Sender_Title_Elements.ODF_Text_Sender_Title_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Visit_Node (Iterator, Visitor, Control); end if; end Visit_Node; begin Matreshka.DOM_Documents.Register_Element (Matreshka.ODF_String_Constants.Text_URI, Matreshka.ODF_String_Constants.Sender_Title_Element, Text_Sender_Title_Element_Node'Tag); end Matreshka.ODF_Text.Sender_Title_Elements;
reznikmm/matreshka
Ada
3,793
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.Constants; package body Matreshka.ODF_Attributes.Style.Tab_Stop_Distance is -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Style_Tab_Stop_Distance_Node) return League.Strings.Universal_String is begin return ODF.Constants.Tab_Stop_Distance_Name; end Get_Local_Name; end Matreshka.ODF_Attributes.Style.Tab_Stop_Distance;
shinesolutions/swagger-aem
Ada
1,531
adb
with Ada.IO_Exceptions; with AWS.Config.Set; with Swagger.Servers.AWS; with Swagger.Servers.Applications; with Util.Strings; with Util.Log.Loggers; with Util.Properties; with Util.Properties.Basic; with .Servers; procedure .Server is procedure Configure (Config : in out AWS.Config.Object); use Util.Properties.Basic; CONFIG_PATH : constant String := ".properties"; Port : Natural := 8080; procedure Configure (Config : in out AWS.Config.Object) is begin AWS.Config.Set.Server_Port (Config, Port); AWS.Config.Set.Max_Connection (Config, 8); AWS.Config.Set.Accept_Queue_Size (Config, 512); end Configure; App : aliased Swagger.Servers.Applications.Application_Type; WS : Swagger.Servers.AWS.AWS_Container; Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create (".Server"); Props : Util.Properties.Manager; begin Props.Load_Properties (CONFIG_PATH); Util.Log.Loggers.Initialize (Props); Port := Integer_Property.Get (Props, "swagger.port", Port); App.Configure (Props); .Servers.Server_Impl.Register (App); WS.Configure (Configure'Access); WS.Register_Application ("", App'Unchecked_Access); App.Dump_Routes (Util.Log.INFO_LEVEL); Log.Info ("Connect you browser to: http://localhost:{0}/ui/index.html", Util.Strings.Image (Port)); WS.Start; delay 6000.0; exception when Ada.IO_Exceptions.Name_Error => Log.Error ("Cannot read application configuration file {0}", CONFIG_PATH); end .Server;
stcarrez/ada-util
Ada
1,087
ads
----------------------------------------------------------------------- -- util-beans-ranges -- Interface Definition with Getter and Setters -- 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.Beans.Objects; with Util.Beans.Basic.Ranges; package Util.Beans.Ranges is package Integer_Ranges is new Util.Beans.Basic.Ranges (Integer, Util.Beans.Objects.To_Object); end Util.Beans.Ranges;
MinimSecure/unum-sdk
Ada
804
adb
-- Copyright 2012-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 begin Do_Something (My_Global_Variable); end Foo;
reznikmm/gela
Ada
3,086
ads
private with Gela.Elements.Defining_Names; with Gela.Elements.Full_Type_Declarations; with Gela.Types.Arrays; with Gela.Types.Simple; with Gela.Types.Visitors; with Gela.Type_Categories; with Gela.Semantic_Types; package Gela.Array_Type_Views is pragma Preelaborate; type Type_View (<>) is new Gela.Type_Categories.Type_View and Gela.Types.Arrays.Array_Type with private; type Type_View_Access is access all Type_View'Class; function Create_Full_Type (Index : Gela.Semantic_Types.Type_View_Index; Category : Gela.Type_Categories.Category_Kinds; Decl : Gela.Elements.Full_Type_Declarations .Full_Type_Declaration_Access; Component : Gela.Types.Type_View_Access; Indexes : Gela.Types.Simple.Discrete_Type_Array) return Gela.Type_Categories.Type_View_Access; private type Type_View (Length : Positive) is new Gela.Type_Categories.Type_View and Gela.Types.Arrays.Array_Type with record Index : Gela.Semantic_Types.Type_View_Index; Category : Gela.Type_Categories.Category_Kinds; Indexes : Gela.Types.Simple.Discrete_Type_Array (1 .. Length); Component : Gela.Types.Type_View_Access; Decl : Gela.Elements.Full_Type_Declarations .Full_Type_Declaration_Access; end record; overriding function Category (Self : Type_View) return Gela.Type_Categories.Category_Kinds; overriding function Is_The_Same_Type (Left : Type_View; Right : Gela.Types.Type_View'Class) return Boolean; overriding function Is_Expected_Type (Self : Type_View; Expected : not null Gela.Types.Type_View_Access) return Boolean; overriding procedure Visit (Self : not null access Type_View; Visiter : in out Gela.Types.Visitors.Type_Visitor'Class); overriding function Is_Array (Self : Type_View) return Boolean; overriding function Is_Character (Self : Type_View) return Boolean; overriding function Is_Enumeration (Self : Type_View) return Boolean; overriding function Is_Floating_Point (Self : Type_View) return Boolean; overriding function Is_Modular_Integer (Self : Type_View) return Boolean; overriding function Is_Object_Access (Self : Type_View) return Boolean; overriding function Is_Record (Self : Type_View) return Boolean; overriding function Is_Signed_Integer (Self : Type_View) return Boolean; overriding function Is_Universal (Self : Type_View) return Boolean; overriding function Is_Root (Self : Type_View) return Boolean; overriding function Index_Types (Self : Type_View) return Gela.Types.Simple.Discrete_Type_Array; overriding function Dimension (Self : Type_View) return Positive; overriding function Component_Type (Self : Type_View) return Gela.Types.Type_View_Access; overriding function Defining_Name (Self : Type_View) return Gela.Elements.Defining_Names.Defining_Name_Access; overriding function Type_View_Index (Self : Type_View) return Gela.Semantic_Types.Type_View_Index; end Gela.Array_Type_Views;
reznikmm/matreshka
Ada
4,543
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ private with Qt4.Graphics_Scene_Drag_Drop_Events; with Qt4.Graphics_Scenes; private with Qt4.Graphics_Scenes.Directors; with Qt4.Objects; package Modeler.Diagram_Scenes is type Diagram_Scene is limited new Qt4.Graphics_Scenes.Q_Graphics_Scene with private; type Diagram_Scene_Access is access all Diagram_Scene'Class; package Constructors is function Create (Parent : access Qt4.Objects.Q_Object'Class := null) return not null Diagram_Scene_Access; end Constructors; private package QGSDDE renames Qt4.Graphics_Scene_Drag_Drop_Events; type Diagram_Scene is limited new Qt4.Graphics_Scenes.Directors.Q_Graphics_Scene_Director with record Accept_Drop : Boolean := False; -- When True scene handle drop event byself, otherwise default handler -- is used. end record; overriding procedure Drag_Move_Event (Self : not null access Diagram_Scene; Event : not null access QGSDDE.Q_Graphics_Scene_Drag_Drop_Event'Class); overriding procedure Drop_Event (Self : not null access Diagram_Scene; Event : not null access QGSDDE.Q_Graphics_Scene_Drag_Drop_Event'Class); end Modeler.Diagram_Scenes;
reznikmm/matreshka
Ada
7,000
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Text.Page_Variable_Set_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_Page_Variable_Set_Element_Node is begin return Self : Text_Page_Variable_Set_Element_Node do Matreshka.ODF_Text.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Text_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Text_Page_Variable_Set_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Enter_Text_Page_Variable_Set (ODF.DOM.Text_Page_Variable_Set_Elements.ODF_Text_Page_Variable_Set_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Enter_Node (Visitor, Control); end if; end Enter_Node; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Text_Page_Variable_Set_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Page_Variable_Set_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Text_Page_Variable_Set_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Leave_Text_Page_Variable_Set (ODF.DOM.Text_Page_Variable_Set_Elements.ODF_Text_Page_Variable_Set_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Leave_Node (Visitor, Control); end if; end Leave_Node; ---------------- -- Visit_Node -- ---------------- overriding procedure Visit_Node (Self : not null access Text_Page_Variable_Set_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then ODF.DOM.Iterators.Abstract_ODF_Iterator'Class (Iterator).Visit_Text_Page_Variable_Set (Visitor, ODF.DOM.Text_Page_Variable_Set_Elements.ODF_Text_Page_Variable_Set_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Visit_Node (Iterator, Visitor, Control); end if; end Visit_Node; begin Matreshka.DOM_Documents.Register_Element (Matreshka.ODF_String_Constants.Text_URI, Matreshka.ODF_String_Constants.Page_Variable_Set_Element, Text_Page_Variable_Set_Element_Node'Tag); end Matreshka.ODF_Text.Page_Variable_Set_Elements;
zhmu/ananas
Ada
5,660
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- G N A T . M B B S _ D I S C R E T E _ R A N D O M -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- -- apply solely to the contents of the part following the private keyword. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- The implementation used in this package was contributed by Robert -- Eachus. It is based on the work of L. Blum, M. Blum, and M. Shub, SIAM -- Journal of Computing, Vol 15. No 2, May 1986. The particular choices for P -- and Q chosen here guarantee a period of 562,085,314,430,582 (about 2**49), -- and the generated sequence has excellent randomness properties. For further -- details, see the paper "Fast Generation of Trustworthy Random Numbers", by -- Robert Eachus, which describes both the algorithm and the efficient -- implementation approach used here. -- Formerly, this package was Ada.Numerics.Discrete_Random. It is retained -- here in part to allow users to reconstruct number sequences generated -- by previous versions. with Interfaces; generic type Result_Subtype is (<>); package GNAT.MBBS_Discrete_Random is -- The algorithm used here is reliable from a required statistical point of -- view only up to 48 bits. We try to behave reasonably in the case of -- larger types, but we can't guarantee the required properties. So -- generate a warning for these (slightly) dubious cases. pragma Compile_Time_Warning (Result_Subtype'Size > 48, "statistical properties not guaranteed for size > 48"); -- Basic facilities type Generator is limited private; function Random (Gen : Generator) return Result_Subtype; procedure Reset (Gen : Generator); procedure Reset (Gen : Generator; Initiator : Integer); -- Advanced facilities type State is private; procedure Save (Gen : Generator; To_State : out State); procedure Reset (Gen : Generator; From_State : State); Max_Image_Width : constant := 80; function Image (Of_State : State) return String; function Value (Coded_State : String) return State; private subtype Int is Interfaces.Integer_32; subtype Rst is Result_Subtype; -- We prefer to use 14 digits for Flt, but some targets are more limited type Flt is digits Positive'Min (14, Long_Long_Float'Digits); RstF : constant Flt := Flt (Rst'Pos (Rst'First)); RstL : constant Flt := Flt (Rst'Pos (Rst'Last)); Offs : constant Flt := RstF - 0.5; K1 : constant := 94_833_359; K1F : constant := 94_833_359.0; K2 : constant := 47_416_679; K2F : constant := 47_416_679.0; Scal : constant Flt := (RstL - RstF + 1.0) / (K1F * K2F); type State is record X1 : Int := Int (2999 ** 2); X2 : Int := Int (1439 ** 2); P : Int := K1; Q : Int := K2; FP : Flt := K1F; Scl : Flt := Scal; end record; type Writable_Access (Self : access Generator) is limited null record; -- Auxiliary type to make Generator a self-referential type type Generator is limited record Writable : Writable_Access (Generator'Access); -- This self reference allows functions to modify Generator arguments Gen_State : State; end record; end GNAT.MBBS_Discrete_Random;
emilybache/GildedRose-Refactoring-Kata
Ada
332
ads
with Ada.Containers.Vectors; with Items; use Items; package Gilded_Rose is package Item_Vecs is new Ada.Containers.Vectors ( Element_Type => Item, Index_Type => Positive ); type Gilded_Rose is record Items : Item_Vecs.Vector; end record; procedure Update_Quality(Self : in out Gilded_Rose); end Gilded_Rose;
reznikmm/matreshka
Ada
4,369
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Nodes; with XML.DOM.Attributes.Internals; package body ODF.DOM.Attributes.Style.Use_Window_Font_Color.Internals is ------------ -- Create -- ------------ function Create (Node : Matreshka.ODF_Attributes.Style.Use_Window_Font_Color.Style_Use_Window_Font_Color_Access) return ODF.DOM.Attributes.Style.Use_Window_Font_Color.ODF_Style_Use_Window_Font_Color is begin return (XML.DOM.Attributes.Internals.Create (Matreshka.DOM_Nodes.Attribute_Access (Node)) with null record); end Create; ---------- -- Wrap -- ---------- function Wrap (Node : Matreshka.ODF_Attributes.Style.Use_Window_Font_Color.Style_Use_Window_Font_Color_Access) return ODF.DOM.Attributes.Style.Use_Window_Font_Color.ODF_Style_Use_Window_Font_Color is begin return (XML.DOM.Attributes.Internals.Wrap (Matreshka.DOM_Nodes.Attribute_Access (Node)) with null record); end Wrap; end ODF.DOM.Attributes.Style.Use_Window_Font_Color.Internals;
zhmu/ananas
Ada
532
ads
package SPARK2 with SPARK_Mode is function Expon (Value, Exp : Natural) return Natural is (if Exp = 0 then 1 else Value * Expon (Value, Exp - 1)) with Ghost, Pre => Value <= Max_Factorial_Number and Exp <= Max_Factorial_Number, Annotate => (GNATprove, Terminating); -- CRASH! Max_Factorial_Number : constant := 6; function Factorial (N : Natural) return Natural with Pre => N < Max_Factorial_Number, Post => Factorial'Result <= Expon (Max_Factorial_Number, N); end SPARK2;
stcarrez/ada-util
Ada
2,942
adb
----------------------------------------------------------------------- -- measures -- Example of Runtime Benchmark -- Copyright (C) 2001, 2002, 2003, 2006, 2008, 2009, 2010 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Text_IO; with Util.Measures; -- -- This example performs several measures and dumps the result. -- The result produced by <b>Util.Measures.Write</b> looks like: -- -- <measures title="Example of measures"> -- <time count="1000" time="406.000000000us" title="Empty"/> -- <time count="2" time="34.000000000us" title="Ada.Text_IO.Put_Line"/> -- <time count="1" time="413.000000000us" -- title="No tracking Empty procedure called 1000 times"/> -- <time count="1" time="1.960000000ms" -- title="Tracking Empty procedure called 1000 times"/> -- </measures> -- -- 'Empty' is called 1000 times for a total time of 406us (or 406ns per call). procedure Measures is procedure Print; procedure Empty; Perf : Util.Measures.Measure_Set; procedure Print is S : Util.Measures.Stamp; begin Ada.Text_IO.Put_Line ("Print test benchmark"); Util.Measures.Report (Perf, S, "Ada.Text_IO.Put_Line"); end Print; procedure Empty is S : Util.Measures.Stamp; begin Util.Measures.Report (Perf, S, "Empty"); end Empty; begin Print; Print; -- Measure time for calling 'Empty' 1000 times declare S : Util.Measures.Stamp; begin for I in 1 .. 1_000 loop Empty; end loop; Util.Measures.Report (Perf, S, "Tracking Empty procedure called 1000 times"); end; -- Disable measures (the next calls will not be counted) Util.Measures.Disable (Perf); Print; Print; -- Measure time for calling 'Empty' 1000 times with performance tracking OFF. declare S : Util.Measures.Stamp; begin for I in 1 .. 1_000 loop Empty; end loop; -- Enable measures again to track Util.Measures.Enable (Perf); Util.Measures.Report (Perf, S, "No tracking Empty procedure called 1000 times"); end; -- Dump the result Util.Measures.Write (Perf, "Example of measures", Ada.Text_IO.Standard_Output); end Measures;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
2,737
adb
with Interfaces; use Interfaces; with STM32GD.Board; use STM32GD.Board; with STM32_SVD; use STM32_SVD; with STM32GD.GPIO; with STM32GD.Startup; with Drivers.RFM69; with Host_Message; package body Modem is package Radio renames STM32GD.Board.Radio; package Modem_Message is new Host_Message (Radio => Radio); Packet: Radio.Packet_Type (1 .. 64); Host_Packet : Modem_Message.Packet_Type (1 .. Unsigned_8 (Packet'Last)); Now : RTC.Date_Time_Type; Wait_Time : RTC.Second_Delta_Type := 30; Sync_Word : constant Radio.Sync_Word_Type (1 .. 3) := (16#F0#, 16#12#, 16#78#); RX_Address : constant Radio.Address_Type := 0; procedure Print_Registers is new Radio.Print_Registers (Put_Line => Text_IO.Put_Line); function Init return Boolean is use Radio; S : Sync_Word_Type (1 .. 3); begin STM32GD.Board.Init; Modem_Message.Send_Hello; Radio.Init; Radio.Get_Sync_Word (S); if S = Sync_Word then IRQ.Configure_Trigger (Rising => True); STM32GD.Clear_Event; return True; else return False; end if; end Init; procedure Run is Length : Byte; Radio_Registers : Radio.Raw_Register_Array; use STM32GD.Board.Radio; begin Radio.Set_RX_Address (RX_Address); Radio.RX_Mode; RTC.Read (Now); RTC.Add_Seconds (Now, Wait_Time); RTC.Set_Alarm (Now); loop STM32GD.Wait_For_Event; if Radio.RX_Available then LED.Set; Radio.Clear_IRQ; Radio.RX (Packet, Length); for I in 1 .. Length loop Host_Packet (Unsigned_8 (I)) := Unsigned_8 (Packet (I)); end loop; Modem_Message.Send_Packet (Host_Packet, Unsigned_8 (Length)); LED.Clear; end if; if RTC.Alarm_Triggered then RTC.Clear_Alarm; Modem_Message.Send_Heartbeat; Radio.Read_Registers (Radio_Registers); Modem_Message.Send_Status (Radio_Registers); if Radio.Get_Mode /= Radio.RX then Modem_Message.Send_Error_Message ("Mode error"); STM32GD.Startup.Reset_Handler; end if; RTC.Read (Now); RTC.Add_Seconds (Now, Wait_Time); RTC.Set_Alarm (Now); end if; end loop; end Run; procedure Error is begin loop RTC.Read (Now); RTC.Add_Seconds (Now, Wait_Time); RTC.Set_Alarm (Now); STM32GD.Wait_For_Event; if RTC.Alarm_Triggered then RTC.Clear_Alarm; Modem_Message.Send_Error_Message ("Modem init failed"); end if; end loop; end Error; end Modem;
AdaCore/libadalang
Ada
166
adb
with Test_Pkg; pragma Test_Statement; separate (Test_Sep) procedure Bar is B : Integer := A + 12; begin Test_Pkg.Pouet (B); pragma Test_Statement; end Bar;
AdaCore/Ada_Drivers_Library
Ada
2,658
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2018, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with MicroBit.IOs; procedure Main is Value : MicroBit.IOs.Analog_Value; begin -- Loop forever loop -- Read analog value of pin Value := MicroBit.IOs.Analog (1); -- Write analog value of pin 0 MicroBit.IOs.Write (0, Value); end loop; end Main;
reznikmm/matreshka
Ada
3,536
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Demos Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with League.Strings; package Paste_Bin.Operations is function Get_Page (Path : League.Strings.Universal_String) return League.Strings.Universal_String; end Paste_Bin.Operations;
reznikmm/spawn
Ada
4,070
adb
-- -- Copyright (C) 2020-2021, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- with Ada.Command_Line; with Ada.Streams; with Ada.Text_IO; with Glib.Application; with Spawn.Processes; with Spawn.String_Vectors; procedure Spawn_Glib_Args_Test is package Listeners is type Listener is new Spawn.Processes.Process_Listener with record App : Glib.Application.Gapplication; Process : access Spawn.Processes.Process'Class; end record; overriding procedure Standard_Output_Available (Self : in out Listener); overriding procedure Standard_Error_Available (Self : in out Listener); overriding procedure Finished (Self : in out Listener; Exit_Status : Spawn.Processes.Process_Exit_Status; Exit_Code : Spawn.Processes.Process_Exit_Code); overriding procedure Error_Occurred (Self : in out Listener; Process_Error : Integer); end Listeners; procedure Activate_Callback (Application : access Glib.Application.Gapplication_Record'Class); package body Listeners is -------------------- -- Error_Occurred -- -------------------- overriding procedure Error_Occurred (Self : in out Listener; Process_Error : Integer) is begin Ada.Text_IO.Put_Line ("Error_Occurred:" & (Process_Error'Img)); Self.App.Release; end Error_Occurred; -------------- -- Finished -- -------------- overriding procedure Finished (Self : in out Listener; Exit_Status : Spawn.Processes.Process_Exit_Status; Exit_Code : Spawn.Processes.Process_Exit_Code) is begin Ada.Text_IO.Put_Line ("Finished" & (Exit_Code'Img)); Self.App.Release; end Finished; ------------------------------ -- Standard_Error_Available -- ------------------------------ overriding procedure Standard_Error_Available (Self : in out Listener) is Data : Ada.Streams.Stream_Element_Array (1 .. 256); Last : Ada.Streams.Stream_Element_Count; begin Self.Process.Read_Standard_Error (Data, Last); for X of Data (1 .. Last) loop Ada.Text_IO.Put (Character'Val (X)); end loop; end Standard_Error_Available; ------------------------------- -- Standard_Output_Available -- ------------------------------- overriding procedure Standard_Output_Available (Self : in out Listener) is Data : Ada.Streams.Stream_Element_Array (1 .. 256); Last : Ada.Streams.Stream_Element_Count; begin Self.Process.Read_Standard_Output (Data, Last); for X of Data (1 .. Last) loop Ada.Text_IO.Put (Character'Val (X)); end loop; end Standard_Output_Available; end Listeners; P : aliased Spawn.Processes.Process; L : aliased Listeners.Listener; ----------------------- -- Activate_Callback -- ----------------------- procedure Activate_Callback (Application : access Glib.Application.Gapplication_Record'Class) is Args : Spawn.String_Vectors.UTF_8_String_Vector; begin L.App := Application.all'Access; L.Process := P'Access; Application.Hold; P.Set_Program ("./spawn_glib_args_test.exe"); Args.Append ("Hello, world with spaces!"); P.Set_Arguments (Args); P.Set_Working_Directory ("/tmp"); P.Set_Listener (L'Unchecked_Access); P.Start; end Activate_Callback; App : constant Glib.Application.Gapplication := Glib.Application.Gapplication_New (Flags => Glib.Application.G_Application_Flags_None); Dummy : Glib.Gint; begin if Ada.Command_Line.Argument_Count = 0 then App.On_Activate (Activate_Callback'Unrestricted_Access); Dummy := App.Run; elsif Ada.Command_Line.Argument_Count /= 1 then raise Program_Error; end if; end Spawn_Glib_Args_Test;
AdaCore/libadalang
Ada
41
ads
with Pkg_A; package Pkg_B is end Pkg_B;
usainzg/EHU
Ada
315
adb
with Es_Divisor; function Suma_Divisores_Propios (N: Integer) return Integer is Cont: Integer; begin Cont := 0; for I in 1..N-1 loop if Es_Divisor(I, N) then Cont := Cont + I; end if; end loop; return Cont; end Suma_Divisores_Propios;
LaplaceKorea/curve25519-spark2014
Ada
311
ads
with Big_Integers; use Big_Integers; with Types; use Types; with Conversion; use Conversion; package Curve25519_Add with SPARK_Mode is function Add (X, Y : Integer_255) return Integer_255 with Pre => All_In_Range (X, Y, Min_Add, Max_Add), Post => +Add'Result = (+X) + (+Y); end Curve25519_Add;
reznikmm/matreshka
Ada
3,803
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.XML_Schema.AST.Types; package body XML.Schema.Objects.Type_Definitions.Internals is ------------ -- Create -- ------------ function Create (Node : Matreshka.XML_Schema.AST.Type_Definition_Access) return XS_Type_Definition is begin return (Ada.Finalization.Controlled with Node => Matreshka.XML_Schema.AST.Object_Access (Node)); end Create; end XML.Schema.Objects.Type_Definitions.Internals;
AdaCore/training_material
Ada
1,943
adb
with Ada.Interrupts.Names; package body STM32.RNG.Interrupts is type Buffer_Content is array (Integer range <>) of UInt32; type Ring_Buffer is record Content : Buffer_Content (0 .. 9); Head : Integer := 0; Tail : Integer := 0; end record; -------------- -- Receiver -- -------------- protected Receiver is -- Implement the Receiver protected object as an interrupt handler for -- the Ada.Interrupts.Names.HASH_RNG_Interrupt. -- -- The Last, Buffer and Data_Available provate variables are used to -- store and control the data present in the RNG_Perpih peripheral. -- -- Pay attention in settting the right priority. entry Get_Random_32 (Value : out UInt32); private Last : UInt32 := 0; Buffer : Ring_Buffer; Data_Available : Boolean := False; procedure Interrupt_Handler; end Receiver; -------------- -- Receiver -- -------------- protected body Receiver is -- TODO: implement the body of the Receiver interrupt handler ------------------- -- Get_Random_32 -- ------------------- entry Get_Random_32 (Value : out UInt32) when Data_Available is begin null; end Get_Random_32; ----------------------- -- Interrupt_Handler -- ----------------------- procedure Interrupt_Handler is null; end Receiver; -------------------- -- Initialize_RNG -- -------------------- procedure Initialize_RNG is begin -- TODO: initialize the RNG module in interrupt modue using the -- subprograms defined in the STM32.RNG package. null; end Initialize_RNG; ------------ -- Random -- ------------ function Random return UInt32 is Result : UInt32; begin Receiver.Get_Random_32 (Result); return Result; end Random; end STM32.RNG.Interrupts;
Gabriel-Degret/adalib
Ada
17,157
ads
-- Standard Ada library specification -- Copyright (c) 2003-2018 Maxim Reznik <[email protected]> -- Copyright (c) 2004-2016 AXE Consultants -- Copyright (c) 2004, 2005, 2006 Ada-Europe -- Copyright (c) 2000 The MITRE Corporation, Inc. -- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc. -- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual --------------------------------------------------------------------------- package Ada.Characters.Latin_1 is pragma Pure (Latin_1); -- Control characters: NUL : constant Character := Character'Val(0); SOH : constant Character := Character'Val(1); STX : constant Character := Character'Val(2); ETX : constant Character := Character'Val(3); EOT : constant Character := Character'Val(4); ENQ : constant Character := Character'Val(5); ACK : constant Character := Character'Val(6); BEL : constant Character := Character'Val(7); BS : constant Character := Character'Val(8); HT : constant Character := Character'Val(9); LF : constant Character := Character'Val(10); VT : constant Character := Character'Val(11); FF : constant Character := Character'Val(12); CR : constant Character := Character'Val(13); SO : constant Character := Character'Val(14); SI : constant Character := Character'Val(15); DLE : constant Character := Character'Val(16); DC1 : constant Character := Character'Val(17); DC2 : constant Character := Character'Val(18); DC3 : constant Character := Character'Val(19); DC4 : constant Character := Character'Val(20); NAK : constant Character := Character'Val(21); SYN : constant Character := Character'Val(22); ETB : constant Character := Character'Val(23); CAN : constant Character := Character'Val(24); EM : constant Character := Character'Val(25); SUB : constant Character := Character'Val(26); ESC : constant Character := Character'Val(27); FS : constant Character := Character'Val(28); GS : constant Character := Character'Val(29); RS : constant Character := Character'Val(30); US : constant Character := Character'Val(31); -- ISO 646 graphic characters: Space : constant Character := ' '; -- Character'Val(32) Exclamation : constant Character := '!'; -- Character'Val(33) Quotation : constant Character := '"'; -- Character'Val(34) Number_Sign : constant Character := '#'; -- Character'Val(35) Dollar_Sign : constant Character := '$'; -- Character'Val(36) Percent_Sign : constant Character := '%'; -- Character'Val(37) Ampersand : constant Character := '&'; -- Character'Val(38) Apostrophe : constant Character := '''; -- Character'Val(39) Left_Parenthesis : constant Character := '('; -- Character'Val(40) Right_Parenthesis : constant Character := ')'; -- Character'Val(41) Asterisk : constant Character := '*'; -- Character'Val(42) Plus_Sign : constant Character := '+'; -- Character'Val(43) Comma : constant Character := ','; -- Character'Val(44) Hyphen : constant Character := '-'; -- Character'Val(45) Minus_Sign : Character renames Hyphen; Full_Stop : constant Character := '.'; -- Character'Val(46) Solidus : constant Character := '/'; -- Character'Val(47) -- Decimal digits '0' though '9' are at positions 48 through 57 Colon : constant Character := ':'; -- Character'Val(58) Semicolon : constant Character := ';'; -- Character'Val(59) Less_Than_Sign : constant Character := '<'; -- Character'Val(60) Equals_Sign : constant Character := '='; -- Character'Val(61) Greater_Than_Sign : constant Character := '>'; -- Character'Val(62) Question : constant Character := '?'; -- Character'Val(63) Commercial_At : constant Character := '@'; -- Character'Val(64) -- Letters 'A' through 'Z' are at positions 65 through 90 Left_Square_Bracket : constant Character := '['; -- Character'Val(91) Reverse_Solidus : constant Character := '\'; -- Character'Val(92) Right_Square_Bracket : constant Character := ']'; -- Character'Val(93) Circumflex : constant Character := '^'; -- Character'Val(94) Low_Line : constant Character := '_'; -- Character'Val(95) Grave : constant Character := '`'; -- Character'Val(96) LC_A : constant Character := 'a'; -- Character'Val(97) LC_B : constant Character := 'b'; -- Character'Val(98) LC_C : constant Character := 'c'; -- Character'Val(99) LC_D : constant Character := 'd'; -- Character'Val(100) LC_E : constant Character := 'e'; -- Character'Val(101) LC_F : constant Character := 'f'; -- Character'Val(102) LC_G : constant Character := 'g'; -- Character'Val(103) LC_H : constant Character := 'h'; -- Character'Val(104) LC_I : constant Character := 'i'; -- Character'Val(105) LC_J : constant Character := 'j'; -- Character'Val(106) LC_K : constant Character := 'k'; -- Character'Val(107) LC_L : constant Character := 'l'; -- Character'Val(108) LC_M : constant Character := 'm'; -- Character'Val(109) LC_N : constant Character := 'n'; -- Character'Val(110) LC_O : constant Character := 'o'; -- Character'Val(111) LC_P : constant Character := 'p'; -- Character'Val(112) LC_Q : constant Character := 'q'; -- Character'Val(113) LC_R : constant Character := 'r'; -- Character'Val(114) LC_S : constant Character := 's'; -- Character'Val(115) LC_T : constant Character := 't'; -- Character'Val(116) LC_U : constant Character := 'u'; -- Character'Val(117) LC_V : constant Character := 'v'; -- Character'Val(118) LC_W : constant Character := 'w'; -- Character'Val(119) LC_X : constant Character := 'x'; -- Character'Val(120) LC_Y : constant Character := 'y'; -- Character'Val(121) LC_Z : constant Character := 'z'; -- Character'Val(122) Left_Curly_Bracket : constant Character := '{'; -- Character'Val(123) Vertical_Line : constant Character := '|'; -- Character'Val(124) Right_Curly_Bracket : constant Character := '}'; -- Character'Val(125) Tilde : constant Character := '~'; -- Character'Val(126) DEL : constant Character := Character'Val(127); -- ISO 6429 control characters: IS4 : Character renames FS; IS3 : Character renames GS; IS2 : Character renames RS; IS1 : Character renames US; Reserved_128 : constant Character := Character'Val(128); Reserved_129 : constant Character := Character'Val(129); BPH : constant Character := Character'Val(130); NBH : constant Character := Character'Val(131); Reserved_132 : constant Character := Character'Val(132); NEL : constant Character := Character'Val(133); SSA : constant Character := Character'Val(134); ESA : constant Character := Character'Val(135); HTS : constant Character := Character'Val(136); HTJ : constant Character := Character'Val(137); VTS : constant Character := Character'Val(138); PLD : constant Character := Character'Val(139); PLU : constant Character := Character'Val(140); RI : constant Character := Character'Val(141); SS2 : constant Character := Character'Val(142); SS3 : constant Character := Character'Val(143); DCS : constant Character := Character'Val(144); PU1 : constant Character := Character'Val(145); PU2 : constant Character := Character'Val(146); STS : constant Character := Character'Val(147); CCH : constant Character := Character'Val(148); MW : constant Character := Character'Val(149); SPA : constant Character := Character'Val(150); EPA : constant Character := Character'Val(151); SOS : constant Character := Character'Val(152); Reserved_153 : constant Character := Character'Val(153); SCI : constant Character := Character'Val(154); CSI : constant Character := Character'Val(155); ST : constant Character := Character'Val(156); OSC : constant Character := Character'Val(157); PM : constant Character := Character'Val(158); APC : constant Character := Character'Val(159); -- Other graphic characters: -- Character positions 160 (16#A0#) .. 175 (16#AF#): No_Break_Space : constant Character := ' '; --Character'Val(160) NBSP : Character renames No_Break_Space; Inverted_Exclamation : constant Character := '¡'; --Character'Val(161) Cent_Sign : constant Character := '¢'; --Character'Val(162) Pound_Sign : constant Character := '£'; --Character'Val(163) Currency_Sign : constant Character := '¤'; --Character'Val(164) Yen_Sign : constant Character := '¥'; --Character'Val(165) Broken_Bar : constant Character := '¦'; --Character'Val(166) Section_Sign : constant Character := '§'; --Character'Val(167) Diaeresis : constant Character := '¨'; --Character'Val(168) Copyright_Sign : constant Character := '©'; --Character'Val(169) Feminine_Ordinal_Indicator : constant Character := 'ª'; --Character'Val(170) Left_Angle_Quotation : constant Character := '«'; --Character'Val(171) Not_Sign : constant Character := '¬'; --Character'Val(172) Soft_Hyphen : constant Character := '­'; --Character'Val(173) Registered_Trade_Mark_Sign : constant Character := '®'; --Character'Val(174) Macron : constant Character := '¯'; --Character'Val(175) -- Character positions 176 (16#B0#) .. 191 (16#BF#): Degree_Sign : constant Character := '°'; --Character'Val(176) Ring_Above : Character renames Degree_Sign; Plus_Minus_Sign : constant Character := '±'; --Character'Val(177) Superscript_Two : constant Character := '²'; --Character'Val(178) Superscript_Three : constant Character := '³'; --Character'Val(179) Acute : constant Character := '´'; --Character'Val(180) Micro_Sign : constant Character := 'µ'; --Character'Val(181) Pilcrow_Sign : constant Character := '¶'; --Character'Val(182) Paragraph_Sign : Character renames Pilcrow_Sign; Middle_Dot : constant Character := '·'; --Character'Val(183) Cedilla : constant Character := '¸'; --Character'Val(184) Superscript_One : constant Character := '¹'; --Character'Val(185) Masculine_Ordinal_Indicator : constant Character := 'º'; --Character'Val(186) Right_Angle_Quotation : constant Character := '»'; --Character'Val(187) Fraction_One_Quarter : constant Character := '¼'; --Character'Val(188) Fraction_One_Half : constant Character := '½'; --Character'Val(189) Fraction_Three_Quarters : constant Character := '¾'; --Character'Val(190) Inverted_Question : constant Character := '¿'; --Character'Val(191) -- Character positions 192 (16#C0#) .. 207 (16#CF#): UC_A_Grave : constant Character := 'À'; --Character'Val(192) UC_A_Acute : constant Character := 'Á'; --Character'Val(193) UC_A_Circumflex : constant Character := 'Â'; --Character'Val(194) UC_A_Tilde : constant Character := 'Ã'; --Character'Val(195) UC_A_Diaeresis : constant Character := 'Ä'; --Character'Val(196) UC_A_Ring : constant Character := 'Å'; --Character'Val(197) UC_AE_Diphthong : constant Character := 'Æ'; --Character'Val(198) UC_C_Cedilla : constant Character := 'Ç'; --Character'Val(199) UC_E_Grave : constant Character := 'È'; --Character'Val(200) UC_E_Acute : constant Character := 'É'; --Character'Val(201) UC_E_Circumflex : constant Character := 'Ê'; --Character'Val(202) UC_E_Diaeresis : constant Character := 'Ë'; --Character'Val(203) UC_I_Grave : constant Character := 'Ì'; --Character'Val(204) UC_I_Acute : constant Character := 'Í'; --Character'Val(205) UC_I_Circumflex : constant Character := 'Î'; --Character'Val(206) UC_I_Diaeresis : constant Character := 'Ï'; --Character'Val(207) -- Character positions 208 (16#D0#) .. 223 (16#DF#): UC_Icelandic_Eth : constant Character := 'Ð'; --Character'Val(208) UC_N_Tilde : constant Character := 'Ñ'; --Character'Val(209) UC_O_Grave : constant Character := 'Ò'; --Character'Val(210) UC_O_Acute : constant Character := 'Ó'; --Character'Val(211) UC_O_Circumflex : constant Character := 'Ô'; --Character'Val(212) UC_O_Tilde : constant Character := 'Õ'; --Character'Val(213) UC_O_Diaeresis : constant Character := 'Ö'; --Character'Val(214) Multiplication_Sign : constant Character := '×'; --Character'Val(215) UC_O_Oblique_Stroke : constant Character := 'Ø'; --Character'Val(216) UC_U_Grave : constant Character := 'Ù'; --Character'Val(217) UC_U_Acute : constant Character := 'Ú'; --Character'Val(218) UC_U_Circumflex : constant Character := 'Û'; --Character'Val(219) UC_U_Diaeresis : constant Character := 'Ü'; --Character'Val(220) UC_Y_Acute : constant Character := 'Ý'; --Character'Val(221) UC_Icelandic_Thorn : constant Character := 'Þ'; --Character'Val(222) LC_German_Sharp_S : constant Character := 'ß'; --Character'Val(223) -- Character positions 224 (16#E0#) .. 239 (16#EF#): LC_A_Grave : constant Character := 'à'; --Character'Val(224) LC_A_Acute : constant Character := 'á'; --Character'Val(225) LC_A_Circumflex : constant Character := 'â'; --Character'Val(226) LC_A_Tilde : constant Character := 'ã'; --Character'Val(227) LC_A_Diaeresis : constant Character := 'ä'; --Character'Val(228) LC_A_Ring : constant Character := 'å'; --Character'Val(229) LC_AE_Diphthong : constant Character := 'æ'; --Character'Val(230) LC_C_Cedilla : constant Character := 'ç'; --Character'Val(231) LC_E_Grave : constant Character := 'è'; --Character'Val(232) LC_E_Acute : constant Character := 'é'; --Character'Val(233) LC_E_Circumflex : constant Character := 'ê'; --Character'Val(234) LC_E_Diaeresis : constant Character := 'ë'; --Character'Val(235) LC_I_Grave : constant Character := 'ì'; --Character'Val(236) LC_I_Acute : constant Character := 'í'; --Character'Val(237) LC_I_Circumflex : constant Character := 'î'; --Character'Val(238) LC_I_Diaeresis : constant Character := 'ï'; --Character'Val(239) -- Character positions 240 (16#F0#) .. 255 (16#FF#): LC_Icelandic_Eth : constant Character := 'ð'; --Character'Val(240) LC_N_Tilde : constant Character := 'ñ'; --Character'Val(241) LC_O_Grave : constant Character := 'ò'; --Character'Val(242) LC_O_Acute : constant Character := 'ó'; --Character'Val(243) LC_O_Circumflex : constant Character := 'ô'; --Character'Val(244) LC_O_Tilde : constant Character := 'õ'; --Character'Val(245) LC_O_Diaeresis : constant Character := 'ö'; --Character'Val(246) Division_Sign : constant Character := '÷'; --Character'Val(247) LC_O_Oblique_Stroke : constant Character := 'ø'; --Character'Val(248) LC_U_Grave : constant Character := 'ù'; --Character'Val(249) LC_U_Acute : constant Character := 'ú'; --Character'Val(250) LC_U_Circumflex : constant Character := 'û'; --Character'Val(251) LC_U_Diaeresis : constant Character := 'ü'; --Character'Val(252) LC_Y_Acute : constant Character := 'ý'; --Character'Val(253) LC_Icelandic_Thorn : constant Character := 'þ'; --Character'Val(254) LC_Y_Diaeresis : constant Character := 'ÿ'; --Character'Val(255) end Ada.Characters.Latin_1;
stcarrez/ada-mail
Ada
1,036
ads
----------------------------------------------------------------------- -- mail-headers -- Operations on mail headers -- Copyright (C) 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. ----------------------------------------------------------------------- package Mail.Headers is -- Decode the mail header value and normalize to an UTF-8 string (RFC2047). function Decode (Content : in String) return String; end Mail.Headers;
reznikmm/matreshka
Ada
4,679
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.Path_Stretchpoint_Y_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Draw_Path_Stretchpoint_Y_Attribute_Node is begin return Self : Draw_Path_Stretchpoint_Y_Attribute_Node do Matreshka.ODF_Draw.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Draw_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Draw_Path_Stretchpoint_Y_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Path_Stretchpoint_Y_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Draw_URI, Matreshka.ODF_String_Constants.Path_Stretchpoint_Y_Attribute, Draw_Path_Stretchpoint_Y_Attribute_Node'Tag); end Matreshka.ODF_Draw.Path_Stretchpoint_Y_Attributes;
charlie5/cBound
Ada
1,739
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces; with swig; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_glx_get_mapiv_reply_t is -- Item -- type Item is record response_type : aliased Interfaces.Unsigned_8; pad0 : aliased Interfaces.Unsigned_8; sequence : aliased Interfaces.Unsigned_16; length : aliased Interfaces.Unsigned_32; pad1 : aliased swig.int8_t_Array (0 .. 3); n : aliased Interfaces.Unsigned_32; datum : aliased Interfaces.Integer_32; pad2 : aliased swig.int8_t_Array (0 .. 11); end record; -- Item_Array -- type Item_Array is array (Interfaces.C.size_t range <>) of aliased xcb.xcb_glx_get_mapiv_reply_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_mapiv_reply_t.Item, Element_Array => xcb.xcb_glx_get_mapiv_reply_t.Item_Array, Default_Terminator => (others => <>)); subtype Pointer is C_Pointers.Pointer; -- Pointer_Array -- type Pointer_Array is array (Interfaces.C.size_t range <>) of aliased xcb.xcb_glx_get_mapiv_reply_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_mapiv_reply_t.Pointer, Element_Array => xcb.xcb_glx_get_mapiv_reply_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_glx_get_mapiv_reply_t;
pombredanne/ravenadm
Ada
51,662
adb
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../License.txt with Ada.Exceptions; with Ada.Directories; with Ada.Containers.Vectors; with Ada.Characters.Latin_1; with Parameters; with Signals; with Unix; package body Replicant is package EX renames Ada.Exceptions; package PM renames Parameters; package CON renames Ada.Containers; package DIR renames Ada.Directories; package LAT renames Ada.Characters.Latin_1; -------------------------------------------------------------------------------------------- -- initialize -------------------------------------------------------------------------------------------- procedure initialize (testmode : Boolean) is raven_sysroot : constant String := HT.USS (PM.configuration.dir_sysroot); mm : constant String := get_master_mount; sretc : constant String := raven_sysroot & "/usr/share"; maspas : constant String := "/master.passwd"; passwd : constant String := "/passwd"; spwd : constant String := "/spwd.db"; pwd : constant String := "/pwd.db"; rcconf : constant String := "/rc.conf"; hints : constant String := "/ld-elf.so.hints"; nhints : constant String := "/ld.so.hints"; trmcap : constant String := "/termcap"; group : constant String := "/group"; ldcnf1 : constant String := "/x86_64-linux-gnu.conf"; ldcnf2 : constant String := "/ld.so.conf"; begin developer_mode := testmode; ravenbase := PM.configuration.dir_localbase; start_abnormal_logging; DIR.Create_Path (mm); case platform_type is when dragonfly | freebsd | macos | netbsd | openbsd => DIR.Copy_File (sretc & passwd, mm & passwd); DIR.Copy_File (sretc & maspas, mm & maspas); DIR.Copy_File (sretc & group, mm & group); when linux => DIR.Copy_File (sretc & passwd, mm & passwd); DIR.Copy_File (sretc & group, mm & group); when sunos => null; -- passwd not used end case; case platform_type is when dragonfly | freebsd | netbsd | openbsd => DIR.Copy_File (sretc & spwd, mm & spwd); DIR.Copy_File (sretc & pwd, mm & pwd); when linux | macos | sunos => null; -- pwd.db not used end case; case platform_type is when dragonfly | freebsd | netbsd | openbsd => DIR.Copy_File (sretc & rcconf, mm & rcconf); when linux | macos | sunos => null; -- rc.conf not used end case; case platform_type is when dragonfly => DIR.Copy_File (sretc & hints, mm & hints); DIR.Copy_File (sretc & trmcap, mm & trmcap); when freebsd => DIR.Copy_File (sretc & hints, mm & hints); when netbsd | openbsd => DIR.Copy_File (sretc & nhints, mm & nhints); DIR.Copy_File (sretc & trmcap, mm & trmcap); when linux => DIR.Copy_File (sretc & ldcnf1, mm & ldcnf1); DIR.Copy_File (sretc & ldcnf2, mm & ldcnf2); when macos | sunos => null; end case; create_mtree_exc_preinst (mm); create_mtree_exc_preconfig (mm); end initialize; -------------------------------------------------------------------------------------------- -- finalize -------------------------------------------------------------------------------------------- procedure finalize is mm : constant String := get_master_mount; begin if DIR.Exists (mm) then annihilate_directory_tree (mm); end if; stop_abnormal_logging; end finalize; -------------------------------------------------------------------------------------------- -- get_master_mount -------------------------------------------------------------------------------------------- function get_master_mount return String is begin return HT.USS (PM.configuration.dir_buildbase) & "/" & reference_base; end get_master_mount; -------------------------------------------------------------------------------------------- -- get_slave_mount -------------------------------------------------------------------------------------------- function get_slave_mount (id : builders) return String is begin return HT.USS (PM.configuration.dir_buildbase) & "/" & slave_name (id); end get_slave_mount; -------------------------------------------------------------------------------------------- -- start_abnormal_logging -------------------------------------------------------------------------------------------- procedure start_abnormal_logging is logpath : constant String := HT.USS (PM.configuration.dir_logs) & "/logs/" & abnormal_cmd_logname; begin if DIR.Exists (logpath) then DIR.Delete_File (logpath); end if; TIO.Create (File => abnormal_log, Mode => TIO.Out_File, Name => logpath); abn_log_ready := True; exception when others => abn_log_ready := False; end start_abnormal_logging; -------------------------------------------------------------------------------------------- -- stop_abnormal_logging -------------------------------------------------------------------------------------------- procedure stop_abnormal_logging is begin if abn_log_ready then TIO.Close (abnormal_log); end if; end stop_abnormal_logging; -------------------------------------------------------------------------------------------- -- annihilate_directory_tree -------------------------------------------------------------------------------------------- procedure annihilate_directory_tree (tree : String) is command : constant String := "/bin/rm -rf " & tree; retry : Boolean := False; begin silent_exec (command); exception when others => -- Only can occur when tmpfs is avoided if DIR.Exists (tree & "/home") then folder_access (tree & "/home", unlock); retry := True; end if; if DIR.Exists (tree & "/root") then folder_access (tree & "/root", unlock); retry := True; end if; if retry then silent_exec (command); else raise scenario_unexpected with "annihilate_directory_tree " & tree & " failed"; end if; end annihilate_directory_tree; -------------------------------------------------------------------------------------------- -- annihilate_directory_tree_contents -------------------------------------------------------------------------------------------- procedure annihilate_directory_tree_contents (tree : String) is command : constant String := "/usr/bin/find -s " & tree & " -depth 1 -maxdepth 1 -exec /bin/rm -rf {} \;"; begin silent_exec (command); end annihilate_directory_tree_contents; -------------------------------------------------------------------------------------------- -- execute -------------------------------------------------------------------------------------------- procedure execute (command : String) is Exit_Status : Integer; output : HT.Text := Unix.piped_command (command, Exit_Status); begin if abn_log_ready and then not HT.IsBlank (output) then TIO.Put_Line (abnormal_log, HT.USS (output)); end if; if Exit_Status /= 0 then raise scenario_unexpected with command & " => failed with code" & Exit_Status'Img; end if; end execute; -------------------------------------------------------------------------------------------- -- silent_exec -------------------------------------------------------------------------------------------- procedure silent_exec (command : String) is cmd_output : HT.Text; success : Boolean := Unix.piped_mute_command (command, cmd_output); begin if not success then if abn_log_ready and then not HT.IsBlank (cmd_output) then TIO.Put_Line (abnormal_log, "piped_mute_command failure:"); TIO.Put_Line (abnormal_log, HT.USS (cmd_output)); end if; raise scenario_unexpected with command & " => failed (exit code not 0)"; end if; end silent_exec; -------------------------------------------------------------------------------------------- -- internal_system_command -------------------------------------------------------------------------------------------- function internal_system_command (command : String) return HT.Text is content : HT.Text; status : Integer; begin content := Unix.piped_command (command, status); if status /= 0 then raise scenario_unexpected with "cmd: " & command & " (return code =" & status'Img & ")"; end if; return content; end internal_system_command; -------------------------------------------------------------------------------------------- -- specific_mount_exists -------------------------------------------------------------------------------------------- function specific_mount_exists (mount_point : String) return Boolean is comres : constant String := HT.USS (internal_system_command (df_command)); markers : HT.Line_Markers; begin HT.initialize_markers (comres, markers); loop exit when not HT.next_line_present (comres, markers); declare line : constant String := HT.extract_line (comres, markers); begin if HT.contains (line, mount_point) then return True; end if; end; end loop; return False; exception when others => return True; end specific_mount_exists; -------------------------------------------------------------------------------------------- -- ravenadm_mounts_exist -------------------------------------------------------------------------------------------- function ravenadm_mounts_exist return Boolean is buildbase : constant String := HT.USS (PM.configuration.dir_buildbase); comres : constant String := HT.USS (internal_system_command (df_command)); markers : HT.Line_Markers; begin HT.initialize_markers (comres, markers); loop exit when not HT.next_line_present (comres, markers); declare line : constant String := HT.extract_line (comres, markers); begin if HT.contains (line, buildbase) then return True; end if; end; end loop; return False; exception when others => return True; end ravenadm_mounts_exist; -------------------------------------------------------------------------------------------- -- clear_existing_mounts -------------------------------------------------------------------------------------------- function clear_existing_mounts return Boolean is package crate is new CON.Vectors (Index_Type => Positive, Element_Type => HT.Text, "=" => HT.SU."="); procedure annihilate (cursor : crate.Cursor); buildbase : constant String := HT.USS (PM.configuration.dir_buildbase); comres : constant String := HT.USS (internal_system_command (df_command)); markers : HT.Line_Markers; mpoints : crate.Vector; procedure annihilate (cursor : crate.Cursor) is mountpoint : constant String := HT.USS (crate.Element (cursor)); begin unmount (mountpoint); if DIR.Exists (mountpoint) then DIR.Delete_Directory (mountpoint); end if; exception when others => null; end annihilate; begin HT.initialize_markers (comres, markers); loop exit when not HT.next_line_present (comres, markers); declare line : constant String := HT.extract_line (comres, markers); mindex : Natural; begin mindex := HT.start_index (line, buildbase); if mindex > 0 then mpoints.Append (HT.SUS (line (mindex .. line'Last))); end if; end; end loop; mpoints.Reverse_Iterate (Process => annihilate'Access); if ravenadm_mounts_exist then return False; end if; -- No need to remove empty dirs, the upcoming run will do that. return True; end clear_existing_mounts; -------------------------------------------------------------------------------------------- -- disk_workareas_exist -------------------------------------------------------------------------------------------- function disk_workareas_exist return Boolean is Search : DIR.Search_Type; buildbase : constant String := HT.USS (PM.configuration.dir_buildbase); result : Boolean := False; begin if not DIR.Exists (buildbase) then return False; end if; if DIR.Exists (buildbase & "/Base") then return True; end if; -- SLXX may be present if tmpfs is avoided DIR.Start_Search (Search => Search, Directory => buildbase, Filter => (DIR.Directory => True, others => False), Pattern => "SL*"); result := DIR.More_Entries (Search => Search); DIR.End_Search (Search); return result; end disk_workareas_exist; -------------------------------------------------------------------------------------------- -- clear_existing_workareas -------------------------------------------------------------------------------------------- function clear_existing_workareas return Boolean is Search : DIR.Search_Type; Dir_Ent : DIR.Directory_Entry_Type; buildbase : constant String := HT.USS (PM.configuration.dir_buildbase); base : constant String := buildbase & "/Base"; begin if DIR.Exists (base) then annihilate_directory_tree (base); end if; -- SLXX may be present if tmpfs is avoided DIR.Start_Search (Search => Search, Directory => buildbase, Filter => (DIR.Directory => True, others => False), Pattern => "SL*"); while DIR.More_Entries (Search => Search) loop DIR.Get_Next_Entry (Search => Search, Directory_Entry => Dir_Ent); declare target : constant String := buildbase & "/" & DIR.Simple_Name (Dir_Ent); begin annihilate_directory_tree (target); end; end loop; DIR.End_Search (Search); return True; exception when others => return False; end clear_existing_workareas; -------------------------------------------------------------------------------------------- -- create_mtree_exc_preinst -------------------------------------------------------------------------------------------- procedure create_mtree_exc_preinst (path_to_mm : String) is mtreefile : TIO.File_Type; filename : constant String := path_to_mm & "/mtree.prestage.exclude"; begin TIO.Create (File => mtreefile, Mode => TIO.Out_File, Name => filename); write_common_mtree_exclude_base (mtreefile); write_preinstall_section (mtreefile); TIO.Close (mtreefile); end create_mtree_exc_preinst; -------------------------------------------------------------------------------------------- -- create_mtree_exc_preconfig -------------------------------------------------------------------------------------------- procedure create_mtree_exc_preconfig (path_to_mm : String) is mtreefile : TIO.File_Type; filename : constant String := path_to_mm & "/mtree.preconfig.exclude"; begin TIO.Create (File => mtreefile, Mode => TIO.Out_File, Name => filename); write_common_mtree_exclude_base (mtreefile); TIO.Close (mtreefile); end create_mtree_exc_preconfig; -------------------------------------------------------------------------------------------- -- write_common_mtree_exclude_base -------------------------------------------------------------------------------------------- procedure write_common_mtree_exclude_base (mtreefile : TIO.File_Type) is function write_usr return String; RB : String := LAT.Full_Stop & HT.USS (ravenbase); function write_usr return String is begin if HT.equivalent (ravenbase, bsd_localbase) then return "./usr/bin" & LAT.LF & "./usr/include" & LAT.LF & "./usr/lib" & LAT.LF & "./usr/lib32" & LAT.LF & "./usr/share" & LAT.LF; else return "./usr" & LAT.LF; end if; end write_usr; begin TIO.Put_Line (mtreefile, "./bin" & LAT.LF & "./ccache" & LAT.LF & "./construction" & LAT.LF & "./dev" & LAT.LF & "./distfiles" & LAT.LF & "./home" & LAT.LF & "./libexec" & LAT.LF & "./packages" & LAT.LF & "./port" & LAT.LF & "./proc" & LAT.LF & "./root" & LAT.LF & "./tmp" & LAT.LF & write_usr & "./var/db/rvnfontconfig" & LAT.LF & "./var/run" & LAT.LF & "./var/tmp" & LAT.LF & "./xports" & LAT.LF & RB & "/toolchain" ); end write_common_mtree_exclude_base; -------------------------------------------------------------------------------------------- -- write_preinstall_section -------------------------------------------------------------------------------------------- procedure write_preinstall_section (mtreefile : TIO.File_Type) is RB : String := LAT.Full_Stop & HT.USS (ravenbase); begin TIO.Put_Line (mtreefile, "./etc/group" & LAT.LF & "./etc/make.conf" & LAT.LF & "./etc/make.conf.bak" & LAT.LF & "./etc/make.nxb.conf" & LAT.LF & "./etc/master.passwd" & LAT.LF & "./etc/passwd" & LAT.LF & "./etc/pwd.db" & LAT.LF & "./etc/shells" & LAT.LF & "./etc/spwd.db" & LAT.LF & "./etc/ld.so.conf.d/x86_64-linux-gnu.conf" & LAT.LF & "./var/db" & LAT.LF & "./var/log" & LAT.LF & "./var/mail" & LAT.LF & "./var/spool" & LAT.LF & "./var/tmp" & LAT.LF & RB & "/etc/gconf/gconf.xml.defaults/%gconf-tree*.xml" & LAT.LF & RB & "/lib/gio/modules/giomodule.cache" & LAT.LF & RB & "/share/info/dir" & LAT.LF & RB & "/share/info" & LAT.LF & RB & "/share/*/info/dir" & LAT.LF & RB & "/share/*/info" & LAT.LF & RB & "/*/ls-R" & LAT.LF & RB & "/share/octave/octave_packages" & LAT.LF & RB & "/share/xml/catalog.ports" ); end write_preinstall_section; -------------------------------------------------------------------------------------------- -- df_command -------------------------------------------------------------------------------------------- function df_command return String is begin case platform_type is when freebsd => return "/bin/df -h"; when dragonfly | macos | netbsd | openbsd => return "/bin/df -h -t null,tmpfs,devfs,procfs"; when sunos => return "/usr/sbin/df -h"; when linux => return "/bin/df -h -a"; end case; end df_command; -------------------------------------------------------------------------------------------- -- unmount -------------------------------------------------------------------------------------------- procedure unmount (device_or_node : String; retry_times : Natural := 0) is bsd_command : constant String := "/sbin/umount " & device_or_node; sol_command : constant String := "/usr/sbin/umount " & device_or_node; lin_command : constant String := "/bin/umount " & device_or_node; counter : Natural := 0; begin -- failure to unmount causes stderr squawks which messes up curses display -- Just log it and ignore for now (Add robustness later) loop begin exit when counter > retry_times; case platform_type is when dragonfly | freebsd | macos | netbsd | openbsd => execute (bsd_command); when linux => execute (lin_command); when sunos => execute (sol_command); end case; exit; exception when others => counter := counter + 1; delay 10.0; end; end loop; end unmount; -------------------------------------------------------------------------------------------- -- mount_nullfs -------------------------------------------------------------------------------------------- procedure mount_nullfs (target, mount_point : String; mode : mount_mode := readonly) is cmd_freebsd : constant String := "/sbin/mount_nullfs"; cmd_dragonfly : constant String := "/sbin/mount_null"; cmd_solaris : constant String := "/usr/sbin/mount -F lofs"; cmd_linux : constant String := "/bin/mount --bind"; command : HT.Text; begin if not DIR.Exists (mount_point) then raise scenario_unexpected with "mount point " & mount_point & " does not exist"; end if; if not DIR.Exists (target) then raise scenario_unexpected with "mount target " & target & " does not exist"; end if; case platform_type is when freebsd => command := HT.SUS (cmd_freebsd); when dragonfly | netbsd => command := HT.SUS (cmd_dragonfly); when sunos => command := HT.SUS (cmd_solaris); when linux => command := HT.SUS (cmd_linux); when openbsd | macos => raise scenario_unexpected with "Null mounting not supported on " & platform_type'Img; end case; case mode is when readonly => HT.SU.Append (command, " -o ro"); when readwrite => null; end case; execute (HT.USS (command) & " " & target & " " & mount_point); end mount_nullfs; -------------------------------------------------------------------------------------------- -- mount_tmpfs -------------------------------------------------------------------------------------------- procedure mount_tmpfs (mount_point : String; max_size_M : Natural := 0) is cmd_freebsd : constant String := "/sbin/mount -t tmpfs"; cmd_dragonfly : constant String := "/sbin/mount_tmpfs"; cmd_solaris : constant String := "/sbin/mount -F tmpfs"; cmd_linux : constant String := "/bin/mount -t tmpfs"; command : HT.Text; begin case platform_type is when freebsd | netbsd | openbsd => command := HT.SUS (cmd_freebsd); when dragonfly => command := HT.SUS (cmd_dragonfly); when sunos => command := HT.SUS (cmd_solaris); when linux => command := HT.SUS (cmd_linux); when macos => raise scenario_unexpected with "Null mounting not supported on " & platform_type'Img; end case; if max_size_M > 0 then HT.SU.Append (command, " -o size=" & HT.trim (max_size_M'Img) & "M"); end if; case platform_type is when sunos => HT.SU.Append (command, " swap " & mount_point); when freebsd | dragonfly | netbsd | openbsd | linux => HT.SU.Append (command, " tmpfs " & mount_point); when macos => null; end case; execute (HT.USS (command)); end mount_tmpfs; -------------------------------------------------------------------------------------------- -- mount_devices -------------------------------------------------------------------------------------------- procedure mount_devices (path_to_dev : String) is bsd_command : constant String := "/sbin/mount -t devfs devfs " & path_to_dev; lin_command : constant String := "/bin/mount --bind /dev " & path_to_dev; begin case platform_type is when dragonfly | freebsd => execute (bsd_command); when linux => execute (lin_command); when netbsd | openbsd | macos | sunos => mount_nullfs (target => "/dev", mount_point => path_to_dev); end case; end mount_devices; -------------------------------------------------------------------------------------------- -- unmount_devices -------------------------------------------------------------------------------------------- procedure unmount_devices (path_to_dev : String) is begin unmount (path_to_dev); end unmount_devices; -------------------------------------------------------------------------------------------- -- mount_procfs -------------------------------------------------------------------------------------------- procedure mount_procfs (path_to_proc : String) is bsd_command : constant String := "/sbin/mount -t procfs proc " & path_to_proc; net_command : constant String := "/sbin/mount_procfs /proc " & path_to_proc; lin_command : constant String := "/bin/mount --bind /proc " & path_to_proc; begin case platform_type is when dragonfly | freebsd => execute (bsd_command); when netbsd | openbsd => execute (net_command); when linux => execute (lin_command); when sunos => mount_nullfs (target => "/proc", mount_point => path_to_proc); when macos => raise scenario_unexpected with "Null mounting not supported on " & platform_type'Img; end case; end mount_procfs; -------------------------------------------------------------------------------------------- -- unmount_procfs -------------------------------------------------------------------------------------------- procedure unmount_procfs (path_to_proc : String) is begin unmount (path_to_proc); end unmount_procfs; -------------------------------------------------------------------------------------------- -- location -------------------------------------------------------------------------------------------- function location (mount_base : String; point : folder) return String is begin case point is when bin => return mount_base & root_bin; when usr => return mount_base & root_usr; when dev => return mount_base & root_dev; when etc => return mount_base & root_etc; when etc_default => return mount_base & root_etc_default; when etc_rcd => return mount_base & root_etc_rcd; when etc_ldsocnf => return mount_base & root_etc_ldsocnf; when tmp => return mount_base & root_tmp; when var => return mount_base & root_var; when home => return mount_base & root_home; when proc => return mount_base & root_proc; when root => return mount_base & root_root; when xports => return mount_base & root_xports; when port => return mount_base & root_port; when lib => return mount_base & root_lib; when lib64 => return mount_base & root_lib64; when libexec => return mount_base & root_libexec; when packages => return mount_base & root_packages; when distfiles => return mount_base & root_distfiles; when wrkdirs => return mount_base & root_wrkdirs; when ccache => return mount_base & root_ccache; when localbase => return mount_base & HT.USS (PM.configuration.dir_localbase); when toolchain => return mount_base & HT.USS (PM.configuration.dir_localbase) & toolchain_dir; end case; end location; -------------------------------------------------------------------------------------------- -- mount_target -------------------------------------------------------------------------------------------- function mount_target (point : folder) return String is begin case point is when xports => return HT.USS (PM.configuration.dir_conspiracy); when packages => return HT.USS (PM.configuration.dir_packages); when toolchain => return HT.USS (PM.configuration.dir_toolchain); when distfiles => return HT.USS (PM.configuration.dir_distfiles); when ccache => return HT.USS (PM.configuration.dir_ccache); when others => return "ERROR"; end case; end mount_target; -------------------------------------------------------------------------------------------- -- forge_directory -------------------------------------------------------------------------------------------- procedure forge_directory (target : String) is begin DIR.Create_Path (New_Directory => target); exception when failed : others => TIO.Put_Line (EX.Exception_Information (failed)); raise scenario_unexpected with "failed to create " & target & " directory"; end forge_directory; -------------------------------------------------------------------------------------------- -- folder_access -------------------------------------------------------------------------------------------- procedure folder_access (path : String; operation : folder_operation) is cmd_freebsd : constant String := "/bin/chflags"; cmd_dragonfly : constant String := "/usr/bin/chflags"; cmd_linux : constant String := "/usr/bin/chattr"; cmd_solaris : constant String := "/usr/bin/chmod"; flag_lock : constant String := " schg "; flag_unlock : constant String := " noschg "; chattr_lock : constant String := " +i "; chattr_unlock : constant String := " -i "; sol_lock : constant String := " S+ci "; sol_unlock : constant String := " S-ci "; command : HT.Text; begin if not DIR.Exists (path) then -- e.g. <slave>/var/empty does not exist on NetBSD return; end if; if platform_type = linux then -- chattr does not work on tmpfs partitions -- It appears immutable locking can't be supported on Linux return; end if; case platform_type is when freebsd => command := HT.SUS (cmd_freebsd); when dragonfly | netbsd | openbsd | macos => command := HT.SUS (cmd_dragonfly); when linux => command := HT.SUS (cmd_linux); when sunos => command := HT.SUS (cmd_solaris); end case; case platform_type is when freebsd | dragonfly | netbsd | openbsd | macos => case operation is when lock => HT.SU.Append (command, flag_lock & path); when unlock => HT.SU.Append (command, flag_unlock & path); end case; when linux => case operation is when lock => HT.SU.Append (command, chattr_lock & path); when unlock => HT.SU.Append (command, chattr_unlock & path); end case; when sunos => case operation is when lock => HT.SU.Append (command, sol_lock & path); when unlock => HT.SU.Append (command, sol_unlock & path); end case; end case; execute (HT.USS (command)); end folder_access; -------------------------------------------------------------------------------------------- -- get_workzone_path -------------------------------------------------------------------------------------------- function get_workzone_path return String is begin return get_slave_mount (workzone_id); end get_workzone_path; -------------------------------------------------------------------------------------------- -- launch_workzone -------------------------------------------------------------------------------------------- procedure launch_workzone is zone_base : constant String := get_workzone_path; begin forge_directory (zone_base); if not PM.configuration.avoid_tmpfs then -- Limit slave to 32Mb mount_tmpfs (zone_base, 32); end if; end launch_workzone; -------------------------------------------------------------------------------------------- -- destroy_workzone -------------------------------------------------------------------------------------------- procedure destroy_workzone is zone_base : constant String := get_workzone_path; begin if not PM.configuration.avoid_tmpfs then unmount (zone_base, 50); end if; annihilate_directory_tree (zone_base); end destroy_workzone; -------------------------------------------------------------------------------------------- -- clear_workzone_directory -------------------------------------------------------------------------------------------- procedure clear_workzone_directory (subpath : String) is zone_base : constant String := get_workzone_path; begin annihilate_directory_tree (zone_base & "/" & subpath); end clear_workzone_directory; -------------------------------------------------------------------------------------------- -- launch_slave -------------------------------------------------------------------------------------------- procedure launch_slave (id : builders; need_procfs : Boolean := False) is slave_base : constant String := get_slave_mount (id); slave_local : constant String := slave_base & "_localbase"; dir_system : constant String := HT.USS (PM.configuration.dir_sysroot); lbase : constant String := HT.USS (PM.configuration.dir_localbase); etc_path : constant String := location (slave_base, etc); begin forge_directory (slave_base); if PM.configuration.avoid_tmpfs then if lbase = bsd_localbase then forge_directory (location (slave_local, toolchain)); mount_nullfs (slave_local, slave_base & lbase, readwrite); else forge_directory (location (slave_base, toolchain)); end if; else -- Limit slave to 16Gb, covers localbase + construction mainly mount_tmpfs (slave_base, 16 * 1024); if lbase = bsd_localbase then mount_tmpfs (slave_base & bsd_localbase, 12 * 1024); end if; forge_directory (location (slave_base, toolchain)); end if; for mnt in safefolders'Range loop forge_directory (location (slave_base, mnt)); end loop; mount_nullfs (location (dir_system, bin), location (slave_base, bin)); mount_nullfs (location (dir_system, usr), location (slave_base, usr)); case platform_type is when freebsd | dragonfly | netbsd | openbsd => mount_nullfs (location (dir_system, libexec), location (slave_base, libexec)); when linux => mount_nullfs (location (dir_system, lib), location (slave_base, lib)); mount_nullfs (location (dir_system, lib64), location (slave_base, lib64)); when macos | sunos => null; -- for now end case; folder_access (location (slave_base, home), lock); folder_access (location (slave_base, root), lock); mount_nullfs (mount_target (xports), location (slave_base, xports)); mount_nullfs (mount_target (packages), location (slave_base, packages), mode => readwrite); mount_nullfs (mount_target (distfiles), location (slave_base, distfiles), mode => readwrite); if need_procfs or else platform_type = linux then mount_procfs (path_to_proc => location (slave_base, proc)); end if; if DIR.Exists (mount_target (ccache)) then mount_nullfs (mount_target (ccache), location (slave_base, ccache), mode => readwrite); end if; mount_devices (location (slave_base, dev)); populate_var_folder (location (slave_base, var)); copy_rc_default (etc_path); copy_resolv_conf (etc_path); copy_ldconfig_hints (slave_base & "/var/run"); create_make_conf (etc_path); install_passwd_and_group (etc_path); create_etc_services (etc_path); create_etc_shells (etc_path); install_linux_ldsoconf (location (slave_base, etc_ldsocnf)); exception when hiccup : others => TIO.Put_Line (abnormal_log, "LAUNCH SLAVE" & id'Img & " FAILED: " & EX.Exception_Information (hiccup)); Signals.initiate_shutdown; end launch_slave; -------------------------------------------------------------------------------------------- -- destroy_slave -------------------------------------------------------------------------------------------- procedure destroy_slave (id : builders; need_procfs : Boolean := False) is slave_base : constant String := get_slave_mount (id); slave_local : constant String := slave_base & "_localbase"; dir_system : constant String := HT.USS (PM.configuration.dir_sysroot); lbase : constant String := HT.USS (PM.configuration.dir_localbase); counter : Natural := 0; begin unmount_devices (location (slave_base, dev)); if DIR.Exists (mount_target (ccache)) then unmount (location (slave_base, ccache)); end if; if need_procfs or else platform_type = linux then unmount_procfs (location (slave_base, proc)); end if; unmount (location (slave_base, distfiles)); unmount (location (slave_base, packages)); unmount (location (slave_base, xports)); if DIR.Exists (location (slave_base, toolchain) & "/bin") then unmount (location (slave_base, toolchain)); end if; folder_access (location (slave_base, root), unlock); folder_access (location (slave_base, home), unlock); folder_access (location (slave_base, var) & "/empty", unlock); unmount (location (slave_base, bin)); unmount (location (slave_base, usr)); case platform_type is when freebsd | dragonfly | netbsd | openbsd => unmount (location (slave_base, libexec)); when linux => unmount (location (slave_base, lib)); unmount (location (slave_base, lib64)); when macos | sunos => null; end case; if PM.configuration.avoid_tmpfs then unmount (slave_base & lbase, 5); annihilate_directory_tree (slave_local); else if lbase = bsd_localbase then unmount (slave_base & lbase, 5); end if; unmount (slave_base, 50); end if; annihilate_directory_tree (slave_base); exception when hiccup : others => TIO.Put_Line (abnormal_log, "DESTROY SLAVE" & id'Img & " FAILED: " & EX.Exception_Information (hiccup)); Signals.initiate_shutdown; end destroy_slave; -------------------------------------------------------------------------------------------- -- hook_toolchain -------------------------------------------------------------------------------------------- procedure hook_toolchain (id : builders) is slave_base : constant String := get_slave_mount (id); begin mount_nullfs (mount_target (toolchain), location (slave_base, toolchain)); end hook_toolchain; -------------------------------------------------------------------------------------------- -- unhook_toolchain -------------------------------------------------------------------------------------------- procedure unhook_toolchain (id : builders) is slave_base : constant String := get_slave_mount (id); begin unmount (location (slave_base, toolchain)); end unhook_toolchain; -------------------------------------------------------------------------------------------- -- slave_name -------------------------------------------------------------------------------------------- function slave_name (id : builders) return String is id_image : constant String := HT.int2str (Integer (id)); suffix : String := "SL00"; begin if id < 10 then suffix (4) := id_image (id_image'First); else suffix (3 .. 4) := id_image (id_image'First .. id_image'First + 1); end if; return suffix; end slave_name; -------------------------------------------------------------------------------------------- -- populate_var_folder -------------------------------------------------------------------------------------------- procedure populate_var_folder (path : String) is begin forge_directory (path & "/cache"); forge_directory (path & "/cron"); forge_directory (path & "/db"); forge_directory (path & "/empty"); forge_directory (path & "/games"); forge_directory (path & "/log"); forge_directory (path & "/mail"); forge_directory (path & "/msgs"); forge_directory (path & "/preserve"); forge_directory (path & "/run"); forge_directory (path & "/spool"); forge_directory (path & "/tmp"); end populate_var_folder; -------------------------------------------------------------------------------------------- -- copy_ldconfig_hints -------------------------------------------------------------------------------------------- procedure copy_ldconfig_hints (path_to_varrun : String) is mm : constant String := get_master_mount; hints : constant String := "/ld-elf.so.hints"; nhints : constant String := "/ld.so.hints"; begin case platform_type is when dragonfly | freebsd => DIR.Copy_File (mm & hints, path_to_varrun & hints); when netbsd | openbsd => DIR.Copy_File (mm & nhints, path_to_varrun & nhints); when macos | linux | sunos => null; end case; end copy_ldconfig_hints; -------------------------------------------------------------------------------------------- -- populate_var_folder -------------------------------------------------------------------------------------------- procedure copy_rc_default (path_to_etc : String) is mm : constant String := get_master_mount; rcconf : constant String := "/rc.conf"; begin if DIR.Exists (mm & rcconf) then DIR.Copy_File (Source_Name => mm & rcconf, Target_Name => path_to_etc & "/defaults" & rcconf); end if; end copy_rc_default; -------------------------------------------------------------------------------------------- -- copy_resolv_conf -------------------------------------------------------------------------------------------- procedure copy_resolv_conf (path_to_etc : String) is original : constant String := "/etc/resolv.conf"; begin if DIR.Exists (original) then DIR.Copy_File (Source_Name => original, Target_Name => path_to_etc & "/resolv.conf"); end if; end copy_resolv_conf; -------------------------------------------------------------------------------------------- -- install_passwd -------------------------------------------------------------------------------------------- procedure install_passwd_and_group (path_to_etc : String) is procedure install (filename : String); mm : constant String := get_master_mount; maspwd : constant String := "/master.passwd"; passwd : constant String := "/passwd"; spwd : constant String := "/spwd.db"; pwd : constant String := "/pwd.db"; group : constant String := "/group"; mtree1 : constant String := "/mtree.preconfig.exclude"; mtree2 : constant String := "/mtree.prestage.exclude"; trmcap : constant String := "/termcap"; ldcnf2 : constant String := "/ld.so.conf"; procedure install (filename : String) is begin if DIR.Exists (mm & filename) then DIR.Copy_File (Source_Name => mm & filename, Target_Name => path_to_etc & filename); end if; end install; begin install (passwd); install (maspwd); install (spwd); install (pwd); install (group); install (mtree1); install (mtree2); install (trmcap); install (ldcnf2); end install_passwd_and_group; -------------------------------------------------------------------------------------------- -- install_linux_ldsoconf -------------------------------------------------------------------------------------------- procedure install_linux_ldsoconf (path_to_etc_ldsocnf : String) is procedure install (filename : String); mm : constant String := get_master_mount; ldconf : constant String := "/x86_64-linux-gnu.conf"; procedure install (filename : String) is begin if DIR.Exists (mm & filename) then DIR.Copy_File (Source_Name => mm & filename, Target_Name => path_to_etc_ldsocnf & filename); end if; end install; begin install (ldconf); end install_linux_ldsoconf; -------------------------------------------------------------------------------------------- -- create_etc_services -------------------------------------------------------------------------------------------- procedure create_etc_services (path_to_etc : String) is svcfile : TIO.File_Type; begin TIO.Create (File => svcfile, Mode => TIO.Out_File, Name => path_to_etc & "/services"); TIO.Put_Line (svcfile, "ftp 21/tcp" & LAT.LF & "ftp 21/udp" & LAT.LF & "ssh 22/tcp" & LAT.LF & "ssh 22/udp" & LAT.LF & "http 80/tcp" & LAT.LF & "http 80/udp" & LAT.LF & "https 443/tcp" & LAT.LF & "https 443/udp" & LAT.LF); TIO.Close (svcfile); end create_etc_services; -------------------------------------------------------------------------------------------- -- create_etc_shells -------------------------------------------------------------------------------------------- procedure create_etc_shells (path_to_etc : String) is shells : TIO.File_Type; begin TIO.Create (File => shells, Mode => TIO.Out_File, Name => path_to_etc & "/shells"); TIO.Put_Line (shells, "/bin/sh"); TIO.Put_Line (shells, "/bin/csh"); if platform_type = linux then TIO.Put_Line (shells, "/bin/bash"); end if; TIO.Close (shells); end create_etc_shells; -------------------------------------------------------------------------------------------- -- create_make_conf -------------------------------------------------------------------------------------------- procedure create_make_conf (path_to_etc : String) is procedure override_defaults (label : String; value : HT.Text); makeconf : TIO.File_Type; profilemc : constant String := PM.raven_confdir & "/" & HT.USS (PM.configuration.profile) & "-make.conf"; profile : constant String := HT.USS (PM.configuration.profile); mjnum : constant Integer := Integer (PM.configuration.jobs_limit); procedure override_defaults (label : String; value : HT.Text) is begin if not (HT.equivalent (value, ports_default)) then TIO.Put_Line (makeconf, "DEFAULT_VERSIONS+=" & label & "=" & HT.USS (value)); end if; end override_defaults; begin TIO.Create (File => makeconf, Mode => TIO.Out_File, Name => path_to_etc & "/make.conf"); TIO.Put_Line (makeconf, "RAVENPROFILE=" & profile & LAT.LF & "RAVENBASE=" & HT.USS (PM.configuration.dir_localbase) & LAT.LF & "WRKDIRPREFIX=/construction" & LAT.LF & "DISTDIR=/distfiles" & LAT.LF & "NUMBER_CPUS=" & HT.int2str (Integer (PM.configuration.number_cores)) & LAT.LF & "MAKE_JOBS_NUMBER_LIMIT=" & HT.int2str (mjnum)); if developer_mode then TIO.Put_Line (makeconf, "DEVELOPER=1"); TIO.Put_Line (makeconf, "PATCH_DEBUG=yes"); end if; if DIR.Exists (HT.USS (PM.configuration.dir_ccache)) then TIO.Put_Line (makeconf, "BUILD_WITH_CCACHE=yes"); TIO.Put_Line (makeconf, "CCACHE_DIR=/ccache"); end if; override_defaults ("firebird", PM.configuration.def_firebird); override_defaults ("lua", PM.configuration.def_lua); override_defaults ("mysql", PM.configuration.def_mysql_group); override_defaults ("perl5", PM.configuration.def_perl); override_defaults ("php", PM.configuration.def_php); override_defaults ("pgsql", PM.configuration.def_postgresql); override_defaults ("python3", PM.configuration.def_python3); override_defaults ("ruby", PM.configuration.def_ruby); override_defaults ("ssl", PM.configuration.def_ssl); override_defaults ("tcl", PM.configuration.def_tcl_tk); concatenate_makeconf (makeconf, profilemc); TIO.Close (makeconf); end create_make_conf; -------------------------------------------------------------------------------------------- -- create_make_conf -------------------------------------------------------------------------------------------- procedure concatenate_makeconf (makeconf_handle : TIO.File_Type; target_name : String) is fragment : TIO.File_Type; begin if DIR.Exists (target_name) then TIO.Open (File => fragment, Mode => TIO.In_File, Name => target_name); while not TIO.End_Of_File (fragment) loop declare Line : String := TIO.Get_Line (fragment); begin TIO.Put_Line (makeconf_handle, Line); end; end loop; TIO.Close (fragment); end if; exception when others => null; end concatenate_makeconf; end Replicant;
stcarrez/ada-wiki
Ada
4,730
adb
----------------------------------------------------------------------- -- wiki-strings -- Wiki string types and operations -- Copyright (C) 2016, 2017, 2020, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Wiki.Helpers; package body Wiki.Strings is -- ------------------------------ -- Search for the first occurrence of the character in the builder and -- starting after the from index. Returns the index of the first occurence or 0. -- ------------------------------ function Index (Source : in BString; Char : in WChar; From : in Positive := 1) return Natural is function Find (Content : in WString) return Natural; function Find (Content : in WString) return Natural is begin for I in Content'Range loop if Content (I) = Char then return I; end if; end loop; return 0; end Find; function Find_Builder is new Wide_Wide_Builders.Find (Find); begin return Find_Builder (Source, From); end Index; -- ------------------------------ -- Find the last position of the character in the string and starting -- at the given position. Stop at the first character different than `Char`. -- ------------------------------ function Last_Position (Source : in BString; Char : in WChar; From : in Positive := 1) return Natural is function Find (Content : in WString) return Natural; function Find (Content : in WString) return Natural is begin for I in Content'Range loop if Content (I) /= Char then return I; end if; end loop; return 0; end Find; function Find_Builder is new Wide_Wide_Builders.Find (Find); begin return Find_Builder (Source, From); end Last_Position; -- ------------------------------ -- Count the the number of consecutive occurence of the given character -- and starting at the given position. -- ------------------------------ function Count_Occurence (Source : in BString; Char : in WChar; From : in Positive := 1) return Natural is Pos : constant Natural := Last_Position (Source, Char, From); begin if Pos > From then return Pos - From; else return 0; end if; end Count_Occurence; function Count_Occurence (Source : in WString; Char : in WChar; From : in Positive := 1) return Natural is Pos : Positive := From; begin while Pos <= Source'Last and then Source (Pos) = Char loop Pos := Pos + 1; end loop; return Pos - From; end Count_Occurence; function Skip_Spaces (Source : in BString; From : in Positive; Last : in Positive) return Positive is Pos : Positive := From; begin while Pos <= Last and then Helpers.Is_Space_Or_Newline (Element (Source, Pos)) loop Pos := Pos + 1; end loop; return Pos; end Skip_Spaces; procedure Scan_Line_Fragment (Source : in BString; Process : not null access procedure (Text : in WString; Offset : in Natural)) is procedure Parse_Line_Fragment (Content : in Wiki.Strings.WString); Offset : Natural := 0; procedure Parse_Line_Fragment (Content : in Wiki.Strings.WString) is begin Process (Content, Offset); Offset := Offset + Content'Length; end Parse_Line_Fragment; procedure Parse_Line_Fragment is new Wiki.Strings.Wide_Wide_Builders.Get (Parse_Line_Fragment); pragma Inline (Parse_Line_Fragment); begin Parse_Line_Fragment (Source); end Scan_Line_Fragment; end Wiki.Strings;
optikos/oasis
Ada
4,289
adb
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package body Program.Nodes.Delay_Statements is function Create (Delay_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Until_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Expression : not null Program.Elements.Expressions.Expression_Access; Semicolon_Token : not null Program.Lexical_Elements .Lexical_Element_Access) return Delay_Statement is begin return Result : Delay_Statement := (Delay_Token => Delay_Token, Until_Token => Until_Token, Expression => Expression, Semicolon_Token => Semicolon_Token, Enclosing_Element => null) do Initialize (Result); end return; end Create; function Create (Expression : 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_Delay_Statement is begin return Result : Implicit_Delay_Statement := (Expression => Expression, Is_Part_Of_Implicit => Is_Part_Of_Implicit, Is_Part_Of_Inherited => Is_Part_Of_Inherited, Is_Part_Of_Instance => Is_Part_Of_Instance, Enclosing_Element => null) do Initialize (Result); end return; end Create; overriding function Expression (Self : Base_Delay_Statement) return not null Program.Elements.Expressions.Expression_Access is begin return Self.Expression; end Expression; overriding function Delay_Token (Self : Delay_Statement) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Delay_Token; end Delay_Token; overriding function Until_Token (Self : Delay_Statement) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Until_Token; end Until_Token; overriding function Semicolon_Token (Self : Delay_Statement) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Semicolon_Token; end Semicolon_Token; overriding function Is_Part_Of_Implicit (Self : Implicit_Delay_Statement) return Boolean is begin return Self.Is_Part_Of_Implicit; end Is_Part_Of_Implicit; overriding function Is_Part_Of_Inherited (Self : Implicit_Delay_Statement) return Boolean is begin return Self.Is_Part_Of_Inherited; end Is_Part_Of_Inherited; overriding function Is_Part_Of_Instance (Self : Implicit_Delay_Statement) return Boolean is begin return Self.Is_Part_Of_Instance; end Is_Part_Of_Instance; procedure Initialize (Self : aliased in out Base_Delay_Statement'Class) is begin Set_Enclosing_Element (Self.Expression, Self'Unchecked_Access); null; end Initialize; overriding function Is_Delay_Statement_Element (Self : Base_Delay_Statement) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Delay_Statement_Element; overriding function Is_Statement_Element (Self : Base_Delay_Statement) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Statement_Element; overriding procedure Visit (Self : not null access Base_Delay_Statement; Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is begin Visitor.Delay_Statement (Self); end Visit; overriding function To_Delay_Statement_Text (Self : aliased in out Delay_Statement) return Program.Elements.Delay_Statements.Delay_Statement_Text_Access is begin return Self'Unchecked_Access; end To_Delay_Statement_Text; overriding function To_Delay_Statement_Text (Self : aliased in out Implicit_Delay_Statement) return Program.Elements.Delay_Statements.Delay_Statement_Text_Access is pragma Unreferenced (Self); begin return null; end To_Delay_Statement_Text; end Program.Nodes.Delay_Statements;
DrenfongWong/tkm-rpc
Ada
4,728
adb
with Tkmrpc.Operations.Ike; with Tkmrpc.Operation_Handlers.Ike.Tkm_Version; with Tkmrpc.Operation_Handlers.Ike.Tkm_Limits; with Tkmrpc.Operation_Handlers.Ike.Tkm_Reset; with Tkmrpc.Operation_Handlers.Ike.Nc_Reset; with Tkmrpc.Operation_Handlers.Ike.Nc_Create; with Tkmrpc.Operation_Handlers.Ike.Dh_Reset; with Tkmrpc.Operation_Handlers.Ike.Dh_Create; with Tkmrpc.Operation_Handlers.Ike.Dh_Generate_Key; with Tkmrpc.Operation_Handlers.Ike.Cc_Reset; with Tkmrpc.Operation_Handlers.Ike.Cc_Set_User_Certificate; with Tkmrpc.Operation_Handlers.Ike.Cc_Add_Certificate; with Tkmrpc.Operation_Handlers.Ike.Cc_Check_Ca; with Tkmrpc.Operation_Handlers.Ike.Ae_Reset; with Tkmrpc.Operation_Handlers.Ike.Isa_Reset; with Tkmrpc.Operation_Handlers.Ike.Isa_Create; with Tkmrpc.Operation_Handlers.Ike.Isa_Sign; with Tkmrpc.Operation_Handlers.Ike.Isa_Auth; with Tkmrpc.Operation_Handlers.Ike.Isa_Create_Child; with Tkmrpc.Operation_Handlers.Ike.Isa_Skip_Create_First; with Tkmrpc.Operation_Handlers.Ike.Esa_Reset; with Tkmrpc.Operation_Handlers.Ike.Esa_Create; with Tkmrpc.Operation_Handlers.Ike.Esa_Create_No_Pfs; with Tkmrpc.Operation_Handlers.Ike.Esa_Create_First; with Tkmrpc.Operation_Handlers.Ike.Esa_Select; package body Tkmrpc.Dispatchers.Ike is ------------------------------------------------------------------------- procedure Dispatch (Req : Request.Data_Type; Res : out Response.Data_Type) is begin case Req.Header.Operation is when Operations.Ike.Tkm_Version => Operation_Handlers.Ike.Tkm_Version.Handle (Req => Req, Res => Res); when Operations.Ike.Tkm_Limits => Operation_Handlers.Ike.Tkm_Limits.Handle (Req => Req, Res => Res); when Operations.Ike.Tkm_Reset => Operation_Handlers.Ike.Tkm_Reset.Handle (Req => Req, Res => Res); when Operations.Ike.Nc_Reset => Operation_Handlers.Ike.Nc_Reset.Handle (Req => Req, Res => Res); when Operations.Ike.Nc_Create => Operation_Handlers.Ike.Nc_Create.Handle (Req => Req, Res => Res); when Operations.Ike.Dh_Reset => Operation_Handlers.Ike.Dh_Reset.Handle (Req => Req, Res => Res); when Operations.Ike.Dh_Create => Operation_Handlers.Ike.Dh_Create.Handle (Req => Req, Res => Res); when Operations.Ike.Dh_Generate_Key => Operation_Handlers.Ike.Dh_Generate_Key.Handle (Req => Req, Res => Res); when Operations.Ike.Cc_Reset => Operation_Handlers.Ike.Cc_Reset.Handle (Req => Req, Res => Res); when Operations.Ike.Cc_Set_User_Certificate => Operation_Handlers.Ike.Cc_Set_User_Certificate.Handle (Req => Req, Res => Res); when Operations.Ike.Cc_Add_Certificate => Operation_Handlers.Ike.Cc_Add_Certificate.Handle (Req => Req, Res => Res); when Operations.Ike.Cc_Check_Ca => Operation_Handlers.Ike.Cc_Check_Ca.Handle (Req => Req, Res => Res); when Operations.Ike.Ae_Reset => Operation_Handlers.Ike.Ae_Reset.Handle (Req => Req, Res => Res); when Operations.Ike.Isa_Reset => Operation_Handlers.Ike.Isa_Reset.Handle (Req => Req, Res => Res); when Operations.Ike.Isa_Create => Operation_Handlers.Ike.Isa_Create.Handle (Req => Req, Res => Res); when Operations.Ike.Isa_Sign => Operation_Handlers.Ike.Isa_Sign.Handle (Req => Req, Res => Res); when Operations.Ike.Isa_Auth => Operation_Handlers.Ike.Isa_Auth.Handle (Req => Req, Res => Res); when Operations.Ike.Isa_Create_Child => Operation_Handlers.Ike.Isa_Create_Child.Handle (Req => Req, Res => Res); when Operations.Ike.Isa_Skip_Create_First => Operation_Handlers.Ike.Isa_Skip_Create_First.Handle (Req => Req, Res => Res); when Operations.Ike.Esa_Reset => Operation_Handlers.Ike.Esa_Reset.Handle (Req => Req, Res => Res); when Operations.Ike.Esa_Create => Operation_Handlers.Ike.Esa_Create.Handle (Req => Req, Res => Res); when Operations.Ike.Esa_Create_No_Pfs => Operation_Handlers.Ike.Esa_Create_No_Pfs.Handle (Req => Req, Res => Res); when Operations.Ike.Esa_Create_First => Operation_Handlers.Ike.Esa_Create_First.Handle (Req => Req, Res => Res); when Operations.Ike.Esa_Select => Operation_Handlers.Ike.Esa_Select.Handle (Req => Req, Res => Res); when others => Res := Response.Null_Data; Res.Header.Operation := Req.Header.Operation; end case; Res.Header.Request_Id := Req.Header.Request_Id; end Dispatch; end Tkmrpc.Dispatchers.Ike;
erik/ada-irc
Ada
8,537
ads
-- This package implements the main object used by the library, as -- well as several functions to manipulate it. with GNAT.Sockets; with GNAT.Regpat; with Ada.Strings.Unbounded; with Ada.Containers.Vectors; with Irc.Message; private with Ada.Streams; private with Ada.Characters.Latin_1; private with Ada.Characters.Handling; package Irc.Bot is package SU renames Ada.Strings.Unbounded; use type SU.Unbounded_String; use Ada.Containers; package Unbounded_Vector is new Vectors (Natural, SU.Unbounded_String); -- Irc.Bot.Connection is the main record that is used for the -- creation of bots. type Connection is tagged private; -- Contains various attributes of the Connection's current nick. type Nick_Attributes is record Nick : SU.Unbounded_String := SU.To_Unbounded_String ("adabot"); Realname : SU.Unbounded_String := SU.To_Unbounded_String ("adabot"); Password : SU.Unbounded_String; end record; -- Used for bot command callbacks type Command_Proc is access procedure (Conn : in out Connection; Msg : Message.Message); ----------------------------------- -- Irc.Bot.Connection Creation -- ----------------------------------- function Create (Server : String; Port : GNAT.Sockets.Port_Type; Nick : String := "adabot") return Connection; procedure Connect (Conn : in out Connection); procedure Disconnect (Conn : in out Connection); ---------------------------- -- Sending IRC commands -- ---------------------------- -- Any function or procedure that sends or receives from the IRC -- server will raise an Irc.Bot.Not_Connected error if the -- Connection is not currently active. -- Sends a standard start-up identify sequence (specifically, NICK -- followed by USER). This may be expanded in the future to -- auto-identify with Nickserv, but for now, when this is desired, -- run Command with the proper arguments. procedure Identify (This : Connection); -- Sends a PRIVMSG command to the specified nick or channel with -- the given message. procedure Privmsg (This : Connection; Chan_Or_Nick, Message : String); -- Joins the specified channel. No error checking is done to make -- sure the channel name is valid, so if you want to guarantee -- that the bot successfully joins, add a handler for the IRC -- protocol's "no such channel" error. procedure Join (This : Connection; Channel : String); -- Generic method of sending a command to the IRC server. Sends to -- the server the command and args joined by a single space procedure Command (This : Connection; Cmd, Args : String); -- Given a string, this function will append a CRLF and send the -- line to the server as-is. In most cases, the Command procedure -- would be better for this, but could potentially be used in -- special cases. procedure Send_Line (This : Connection; Line : String); -- Like the Send_Line procedure, but does not append a CRLF to the -- message. procedure Send_Raw (This : Connection; Raw : String); ----------------------------------- -- Reading from the IRC server -- ----------------------------------- procedure Read_Line (This : Connection; Buffer : out SU.Unbounded_String); ------------------------------- -- Adding command handlers -- ------------------------------- -- Irc.Bot.Connection's main functionality and extensibility comes -- from the callbacks given to it, which can either be strings or -- regular expressions. Commands are evaluated in sequence, -- meaning that if multiple commands match a specified string or -- regular expression, they will each be run in the order they are -- given. -- Adds a command that will be called whenever the provided -- message is received. For PRIVMSG commands, see On_Privmsg. procedure On_Message (This : in out Connection; OnMsg : String; Func : Command_Proc); -- Allows the creation of a command triggered by a regular -- expression, the given string is interpreted as a regular -- expression and added. procedure On_Regexp (This : in out Connection; OnRegexp : String; Func : Command_Proc); -- Allows a more customized regular expression to be used for a -- command (using case insensitivity, for example) procedure On_Regexp (This : in out Connection; OnRegexp : GNAT.Regpat.Pattern_Matcher; Func : Command_Proc); -- Add a callback to be Called whenever a PRIVMSG content matches -- the regular expression "^OnMsg". procedure On_Privmsg (This : in out Connection; OnMsg : String; Func : Command_Proc); ---------------------- -- Other commands -- ---------------------- -- Loops through commands, calling ones that apply to the given -- message. procedure Do_Message (This : in out Connection; Msg : Message.Message); -- Checks if a given nick or hostname is considered an admin by -- the admins set through the Add_Administrator procedure. function Is_Admin (Conn : in Connection; Sender : SU.Unbounded_String) return Boolean; ----------------------------------------------- -- Attribute accessors procedures/functions -- ----------------------------------------------- function Get_Attributes (Conn : in Connection) return Nick_Attributes; pragma Inline (Get_Attributes); procedure Set_Attributes (Conn : in out Connection; Nick : Nick_Attributes); function Get_Administrators (Conn : in Connection) return Unbounded_Vector.Vector; function Get_Default_Channels (Conn : in Connection) return Unbounded_Vector.Vector; -- Adds a new administrator to check against (for use with the -- Is_Admin function) procedure Add_Administrator (Conn : in out Connection; Admin : String); procedure Add_Administrator (Conn : in out Connection; Admin : SU.Unbounded_String); -- Adds a channel to be joined when a 001 is received from the -- server (when the default command set from Irc.Commands has been -- installed on the bot) procedure Add_Default_Channel (Conn : in out Connection; Channel : String); procedure Add_Default_Channel (Conn : in out Connection; Channel : SU.Unbounded_String); ------------------ -- Exceptions -- ------------------ Socket_Read_Error : exception; Not_Connected : exception; --------------------------- -- Private declarations -- --------------------------- private package Regexp renames GNAT.Regpat; CRLF : constant String := Ada.Characters.Latin_1.CR & Ada.Characters.Latin_1.LF; -- Provides a simple runtime check to guarantee that the -- given Connection is active before trying to send / receive. -- raises Not_Connected unless the connection is active. procedure Should_Be_Connected (This : Connection); procedure Privmsg_Command_Hook (This : in out Connection; Msg : Message.Message); type Command_Pair is record Func : Command_Proc; Regex : Regexp.Pattern_Matcher (1024); end record; package Command_Vector is new Vectors (Natural, Command_Pair); type Connection is tagged record Sock : GNAT.Sockets.Socket_Type; Address : GNAT.Sockets.Sock_Addr_Type; Connected : Boolean := False; Nick : Nick_Attributes; Commands : Command_Vector.Vector; Privmsg_Commands : Command_Vector.Vector; Administrators : Unbounded_Vector.Vector; Default_Channels : Unbounded_Vector.Vector; end record; end Irc.Bot;
sungyeon/drake
Ada
2,460
adb
with System.Synchronous_Objects.Abortable; with System.Tasks; package body Ada.Synchronous_Barriers is procedure Do_Wait ( Object : in out Synchronous_Barrier; Notified : out Boolean; Aborted : out Boolean); procedure Do_Wait ( Object : in out Synchronous_Barrier; Notified : out Boolean; Aborted : out Boolean) is Order : Natural; begin System.Synchronous_Objects.Enter (Object.Mutex); Object.Blocked := Object.Blocked + 1; Order := Object.Blocked rem Object.Release_Threshold; Notified := Order = 1 or else Object.Release_Threshold = 1; -- first one if Order = 0 then System.Synchronous_Objects.Set (Object.Event); Aborted := System.Tasks.Is_Aborted; Object.Unblocked := Object.Unblocked + 1; else loop System.Synchronous_Objects.Leave (Object.Mutex); System.Synchronous_Objects.Abortable.Wait (Object.Event, Aborted); System.Synchronous_Objects.Enter (Object.Mutex); exit when Object.Blocked >= Object.Release_Threshold or else Aborted; end loop; Object.Unblocked := Object.Unblocked + 1; end if; if Object.Unblocked = Object.Release_Threshold then Object.Blocked := Object.Blocked - Object.Release_Threshold; Object.Unblocked := 0; if Object.Blocked < Object.Release_Threshold then System.Synchronous_Objects.Reset (Object.Event); end if; end if; System.Synchronous_Objects.Leave (Object.Mutex); end Do_Wait; -- implementation procedure Wait_For_Release ( The_Barrier : in out Synchronous_Barrier; Notified : out Boolean) is Aborted : Boolean; begin System.Tasks.Enable_Abort; Do_Wait (The_Barrier, Notified, Aborted => Aborted); System.Tasks.Disable_Abort (Aborted); end Wait_For_Release; overriding procedure Initialize (Object : in out Synchronous_Barrier) is begin Object.Blocked := 0; Object.Unblocked := 0; System.Synchronous_Objects.Initialize (Object.Mutex); System.Synchronous_Objects.Initialize (Object.Event); end Initialize; overriding procedure Finalize (Object : in out Synchronous_Barrier) is begin System.Synchronous_Objects.Finalize (Object.Mutex); System.Synchronous_Objects.Finalize (Object.Event); end Finalize; end Ada.Synchronous_Barriers;
annexi-strayline/ASAP-Unicode
Ada
3,628
ads
------------------------------------------------------------------------------ -- -- -- Unicode Utilities -- -- -- -- Normalization Form Utilities -- -- Quick Check Query Facilities -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Copyright (C) 2019, ANNEXI-STRAYLINE Trans-Human Ltd. -- -- All rights reserved. -- -- -- -- Original Contributors: -- -- * Richard Wai (ANNEXI-STRAYLINE) -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- -- -- * Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -- -- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ package Unicode.Normalization.Quick_Check with Pure is type Quick_Check_Result is (Yes, No, Maybe); end Unicode.Normalization.Quick_Check;
reznikmm/matreshka
Ada
4,051
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_Table_Centering_Attributes; package Matreshka.ODF_Style.Table_Centering_Attributes is type Style_Table_Centering_Attribute_Node is new Matreshka.ODF_Style.Abstract_Style_Attribute_Node and ODF.DOM.Style_Table_Centering_Attributes.ODF_Style_Table_Centering_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Table_Centering_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Style_Table_Centering_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Style.Table_Centering_Attributes;
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.Config_Config_Item_Elements is pragma Preelaborate; type ODF_Config_Config_Item is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Config_Config_Item_Access is access all ODF_Config_Config_Item'Class with Storage_Size => 0; end ODF.DOM.Config_Config_Item_Elements;
Rodeo-McCabe/orka
Ada
4,586
adb
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2019 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. package body Orka.Inputs.Joysticks.Default is overriding function Current_State (Object : Abstract_Joystick_Input) return Joystick_State is (Object.Current_State); overriding function Last_State (Object : Abstract_Joystick_Input) return Joystick_State is (Object.Last_State); overriding procedure Update_State (Object : in out Abstract_Joystick_Input; Process : access procedure (Value : in out Axis_Position; Index : Positive)) is begin Object.Last_State := Object.Current_State; Object.Current_State := Abstract_Joystick_Input'Class (Object).State; if Process /= null then for Index in 1 .. Object.Current_State.Axis_Count loop Process (Object.Current_State.Axes (Index), Index); end loop; end if; end Update_State; ----------------------------------------------------------------------------- type Pointer_Joystick_Input is new Abstract_Joystick_Input with record Pointer : Inputs.Pointers.Pointer_Input_Ptr; Axes : Orka.Transforms.Doubles.Vectors.Vector4 := (others => 0.0); Scales : Orka.Transforms.Doubles.Vectors.Vector4; end record; overriding function Is_Present (Object : Pointer_Joystick_Input) return Boolean is (True); overriding function Name (Object : Pointer_Joystick_Input) return String is ("Pointer"); overriding function GUID (Object : Pointer_Joystick_Input) return String is ("pointer"); overriding function Is_Gamepad (Object : Pointer_Joystick_Input) return Boolean is (False); overriding function State (Object : in out Pointer_Joystick_Input) return Joystick_State is use type GL.Types.Double; function To_Button (Value : Boolean) return Button_State is (if Value then Pressed else Released); function Clamp (Value, Minimum, Maximum : GL.Types.Double) return GL.Types.Double is (GL.Types.Double'Max (Minimum, GL.Types.Double'Min (Value, Maximum))); Limit_X : constant GL.Types.Double := 1.0 / Object.Scales (X); Limit_Y : constant GL.Types.Double := 1.0 / Object.Scales (Y); Limit_Z : constant GL.Types.Double := 1.0 / Object.Scales (Z); Limit_W : constant GL.Types.Double := 1.0 / Object.Scales (W); begin if Object.Pointer.Locked then Object.Axes (X) := Clamp (Object.Axes (X) + Object.Pointer.Delta_X, -Limit_X, Limit_X); Object.Axes (Y) := Clamp (Object.Axes (Y) - Object.Pointer.Delta_Y, -Limit_Y, Limit_Y); end if; Object.Axes (Z) := Clamp (Object.Axes (Z) + Object.Pointer.Scroll_X, -Limit_Z, Limit_Z); Object.Axes (W) := Clamp (Object.Axes (W) - Object.Pointer.Scroll_Y, -Limit_W, Limit_W); return Result : Joystick_State (Button_Count => 3, Axis_Count => 4, Hat_Count => 0) do Result.Buttons (1) := To_Button (Object.Pointer.Button_Pressed (Inputs.Pointers.Left)); Result.Buttons (2) := To_Button (Object.Pointer.Button_Pressed (Inputs.Pointers.Right)); Result.Buttons (3) := To_Button (Object.Pointer.Button_Pressed (Inputs.Pointers.Middle)); Result.Axes (1) := Axis_Position (Object.Axes (X) * Object.Scales (X)); Result.Axes (2) := Axis_Position (Object.Axes (Y) * Object.Scales (Y)); Result.Axes (3) := Axis_Position (Object.Axes (Z) * Object.Scales (Z)); Result.Axes (4) := Axis_Position (Object.Axes (W) * Object.Scales (W)); end return; end State; function Create_Joystick_Input (Pointer : Inputs.Pointers.Pointer_Input_Ptr; Scales : Orka.Transforms.Doubles.Vectors.Vector4) return Joystick_Input_Ptr is begin return new Pointer_Joystick_Input'(Abstract_Joystick_Input with Pointer => Pointer, Scales => Scales, others => <>); end Create_Joystick_Input; end Orka.Inputs.Joysticks.Default;
tj800x/SPARKNaCl
Ada
7,182
adb
package body SPARKNaCl.Core with SPARK_Mode => On is --=============================== -- Local subprogram declarations -- and renamings --=============================== function RL32 (X : in U32; C : in Natural) return U32 renames Rotate_Left; procedure ST32 (X : out Bytes_4; U : in U32) with Global => null; function LD32 (X : in Bytes_4) return U32 with Global => null; -- Derives intermediate values X and Y from Input, K and C. -- Common to both Salsa20 and HSalsa20 procedure Core_Common (Input : in Bytes_16; K : in Salsa20_Key; C : in Bytes_16; X : out U32_Seq_16; Y : out U32_Seq_16) with Global => null; --=============================== -- Local subprogram bodies --=============================== procedure ST32 (X : out Bytes_4; U : in U32) is T : U32 := U; begin for I in X'Range loop X (I) := Byte (T mod 256); T := Shift_Right (T, 8); end loop; end ST32; function LD32 (X : in Bytes_4) return U32 is U : U32; begin U := U32 (X (3)); U := Shift_Left (U, 8) or U32 (X (2)); U := Shift_Left (U, 8) or U32 (X (1)); return Shift_Left (U, 8) or U32 (X (0)); end LD32; procedure Core_Common (Input : in Bytes_16; K : in Salsa20_Key; C : in Bytes_16; X : out U32_Seq_16; Y : out U32_Seq_16) is W : U32_Seq_16; T : U32_Seq_4; -- Common to all iterations of the inner loop, -- so factored out here. procedure Adjust_T with Global => (In_Out => T); procedure Adjust_T is begin T (1) := T (1) xor RL32 (T (0) + T (3), 7); T (2) := T (2) xor RL32 (T (1) + T (0), 9); T (3) := T (3) xor RL32 (T (2) + T (1), 13); T (0) := T (0) xor RL32 (T (3) + T (2), 18); end Adjust_T; begin W := (others => 0); -- In C this is a loop, but we unroll and make single -- aggregate assignment to initialize the whole of X. X := (0 => LD32 (C (0 .. 3)), 1 => LD32 (Bytes_4 (K.F (0 .. 3))), 6 => LD32 (Input (0 .. 3)), 11 => LD32 (Bytes_4 (K.F (16 .. 19))), 5 => LD32 (C (4 .. 7)), 2 => LD32 (Bytes_4 (K.F (4 .. 7))), 7 => LD32 (Input (4 .. 7)), 12 => LD32 (Bytes_4 (K.F (20 .. 23))), 10 => LD32 (C (8 .. 11)), 3 => LD32 (Bytes_4 (K.F (8 .. 11))), 8 => LD32 (Input (8 .. 11)), 13 => LD32 (Bytes_4 (K.F (24 .. 27))), 15 => LD32 (C (12 .. 15)), 4 => LD32 (Bytes_4 (K.F (12 .. 15))), 9 => LD32 (Input (12 .. 15)), 14 => LD32 (Bytes_4 (K.F (28 .. 31)))); Y := X; for I in Index_20 loop -- This inner loop has been unrolled manually and -- simplified in SPARKNaCl. -- -- ORIGINAL CODE: -- for J in Index_4 loop -- T := (0 => X ((5 * J) mod 16), -- 1 => X ((5 * J + 4) mod 16), -- 2 => X ((5 * J + 8) mod 16), -- 3 => X ((5 * J + 12) mod 16)); -- T (1) := T (1) xor RL32 (T (0) + T (3), 7); -- T (2) := T (2) xor RL32 (T (1) + T (0), 9); -- T (3) := T (3) xor RL32 (T (2) + T (1), 13); -- T (0) := T (0) xor RL32 (T (3) + T (2), 18); -- W (4 * J + ((J + 0) mod 4)) := T (0); -- W (4 * J + ((J + 1) mod 4)) := T (1); -- W (4 * J + ((J + 2) mod 4)) := T (2); -- W (4 * J + ((J + 3) mod 4)) := T (3); -- end loop; -- Begin loop unrolling -- -- Iteration with J = 0 -- T := (0 => X (0), 1 => X (4), 2 => X (8), 3 => X (12)); Adjust_T; W (0) := T (0); W (1) := T (1); W (2) := T (2); W (3) := T (3); -- Iteration with J = 1 -- T := (0 => X (5), 1 => X (9), 2 => X (13), 3 => X (1)); Adjust_T; W (5) := T (0); W (6) := T (1); W (7) := T (2); W (4) := T (3); -- Iteration with J = 2 -- T := (0 => X (10), 1 => X (14), 2 => X (2), 3 => X (6)); Adjust_T; W (10) := T (0); W (11) := T (1); W (8) := T (2); W (9) := T (3); -- Iteration with J = 3 -- T := (0 => X (15), 1 => X (3), 2 => X (7), 3 => X (11)); Adjust_T; W (15) := T (0); W (12) := T (1); W (13) := T (2); W (14) := T (3); -- End loop unrolling -- X := W; end loop; end Core_Common; -------------------------------------------------------- -- Exported suprogram bodies -------------------------------------------------------- function Construct (K : in Bytes_32) return Salsa20_Key is begin return Salsa20_Key'(F => K); end Construct; procedure Construct (K : out Salsa20_Key; X : in Bytes_32) is begin K.F := X; end Construct; function Serialize (K : in Salsa20_Key) return Bytes_32 is begin return K.F; end Serialize; procedure Sanitize (K : out Salsa20_Key) is begin Sanitize (K.F); end Sanitize; -------------------------------------------------------- -- Salsa20 Core subprograms -------------------------------------------------------- procedure Salsa20 (Output : out Bytes_64; Input : in Bytes_16; K : in Salsa20_Key; C : in Bytes_16) is X, Y : U32_Seq_16; begin Core_Common (Input, K, C, X, Y); -- Salsa20 Output stage -- derives Output from X, Y Output := (others => 0); for I in Index_16 loop ST32 (Output (4 * I .. 4 * I + 3), X (I) + Y (I)); end loop; end Salsa20; procedure HSalsa20 (Output : out Bytes_32; Input : in Bytes_16; K : in Salsa20_Key; C : in Bytes_16) is X, Y : U32_Seq_16; begin Core_Common (Input, K, C, X, Y); -- HSalsa20 output stage -- derives Output from X, Y, C, Input for I in Index_16 loop X (I) := X (I) + Y (I); end loop; for I in Index_4 loop X (5 * I) := X (5 * I) - LD32 (C (4 * I .. 4 * I + 3)); X (6 + I) := X (6 + I) - LD32 (Input (4 * I .. 4 * I + 3)); end loop; Output := (others => 0); for I in Index_4 loop ST32 (Output (4 * I .. 4 * I + 3), X (5 * I)); ST32 (Output (4 * I + 16 .. 4 * I + 19), X (6 + I)); end loop; end HSalsa20; end SPARKNaCl.Core;
nerilex/ada-util
Ada
2,945
adb
----------------------------------------------------------------------- -- util-http-clients-mockups -- HTTP Clients -- Copyright (C) 2011, 2012 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Files; with Util.Http.Mockups; package body Util.Http.Clients.Mockups is use Ada.Strings.Unbounded; Manager : aliased File_Http_Manager; -- ------------------------------ -- Register the Http manager. -- ------------------------------ procedure Register is begin Default_Http_Manager := Manager'Access; end Register; -- ------------------------------ -- Set the path of the file that contains the response for the next -- <b>Do_Get</b> and <b>Do_Post</b> calls. -- ------------------------------ procedure Set_File (Path : in String) is begin Manager.File := To_Unbounded_String (Path); end Set_File; procedure Create (Manager : in File_Http_Manager; Http : in out Client'Class) is pragma Unreferenced (Manager); begin Http.Delegate := new Util.Http.Mockups.Mockup_Request; end Create; procedure Do_Get (Manager : in File_Http_Manager; Http : in Client'Class; URI : in String; Reply : out Response'Class) is pragma Unreferenced (Http, URI); Rep : constant Util.Http.Mockups.Mockup_Response_Access := new Util.Http.Mockups.Mockup_Response; Content : Ada.Strings.Unbounded.Unbounded_String; begin Reply.Delegate := Rep.all'Access; Util.Files.Read_File (Path => To_String (Manager.File), Into => Content, Max_Size => 100000); Rep.Set_Body (To_String (Content)); Rep.Set_Status (SC_OK); end Do_Get; procedure Do_Post (Manager : in File_Http_Manager; Http : in Client'Class; URI : in String; Data : in String; Reply : out Response'Class) is pragma Unreferenced (Data); begin Manager.Do_Get (Http, URI, Reply); end Do_Post; end Util.Http.Clients.Mockups;
wookey-project/ewok-legacy
Ada
5,456
adb
-- -- Copyright 2018 The wookey project team <[email protected]> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- with ewok.tasks; use ewok.tasks; with ewok.tasks_shared; use ewok.tasks_shared; with ewok.gpio; with ewok.exti; with ewok.exported.gpios; use ewok.exported.gpios; with ewok.sanitize; package body ewok.syscalls.cfg.gpio with spark_mode => off is procedure gpio_set (caller_id : in ewok.tasks_shared.t_task_id; params : in out t_parameters; mode : in ewok.tasks_shared.t_task_mode) is ref : ewok.exported.gpios.t_gpio_ref with address => params(1)'address; val : unsigned_8 with address => params(2)'address; begin -- Task initialization is complete ? if not is_init_done (caller_id) then goto ret_denied; end if; -- Valid t_gpio_ref ? if not ref.pin'valid or not ref.port'valid then goto ret_inval; end if; -- Does that GPIO really belongs to the caller ? if not ewok.gpio.belong_to (caller_id, ref) then goto ret_denied; end if; -- Write the pin if val >= 1 then ewok.gpio.write_pin (ref, 1); else ewok.gpio.write_pin (ref, 0); end if; set_return_value (caller_id, mode, SYS_E_DONE); ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE); return; <<ret_inval>> set_return_value (caller_id, mode, SYS_E_INVAL); ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE); return; <<ret_denied>> set_return_value (caller_id, mode, SYS_E_DENIED); ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE); return; end gpio_set; procedure gpio_get (caller_id : in ewok.tasks_shared.t_task_id; params : in out t_parameters; mode : in ewok.tasks_shared.t_task_mode) is ref : ewok.exported.gpios.t_gpio_ref with address => params(1)'address; val : unsigned_8 with address => to_address (params(2)); begin -- Task initialization is complete ? if not is_init_done (caller_id) then goto ret_denied; end if; -- Valid t_gpio_ref ? if not ref.pin'valid or not ref.port'valid then goto ret_inval; end if; -- Does &val is in the caller address space ? if not ewok.sanitize.is_word_in_data_slot (to_system_address (val'address), caller_id, mode) then goto ret_denied; end if; -- Read the pin val := unsigned_8 (ewok.gpio.read_pin (ref)); set_return_value (caller_id, mode, SYS_E_DONE); ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE); return; <<ret_inval>> set_return_value (caller_id, mode, SYS_E_INVAL); ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE); return; <<ret_denied>> set_return_value (caller_id, mode, SYS_E_DENIED); ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE); return; end gpio_get; -- Unlock EXTI line associated to given GPIO, if the EXTI -- line has been locked by the kernel (exti lock parameter is -- set to 'true'. procedure gpio_unlock_exti (caller_id : in ewok.tasks_shared.t_task_id; params : in out t_parameters; mode : in ewok.tasks_shared.t_task_mode) is ref : ewok.exported.gpios.t_gpio_ref with address => params(1)'address; cfg : ewok.exported.gpios.t_gpio_config_access; begin -- Task initialization is complete ? if not is_init_done (caller_id) then goto ret_denied; end if; -- Valid t_gpio_ref ? if not ref.pin'valid or not ref.port'valid then goto ret_inval; end if; -- Does that GPIO really belongs to the caller ? if not ewok.gpio.belong_to (caller_id, ref) then goto ret_denied; end if; cfg := ewok.gpio.get_config(ref); -- Does that GPIO has an EXTI line which is lockable ? if cfg.all.exti_trigger = GPIO_EXTI_TRIGGER_NONE or cfg.all.exti_lock = GPIO_EXTI_UNLOCKED then goto ret_inval; end if; ewok.exti.enable(ref); set_return_value (caller_id, mode, SYS_E_DONE); ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE); return; <<ret_inval>> set_return_value (caller_id, mode, SYS_E_INVAL); ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE); return; <<ret_denied>> set_return_value (caller_id, mode, SYS_E_DENIED); ewok.tasks.set_state (caller_id, mode, TASK_STATE_RUNNABLE); return; end gpio_unlock_exti; end ewok.syscalls.cfg.gpio;
reznikmm/matreshka
Ada
3,969
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Text_Suffix_Attributes; package Matreshka.ODF_Text.Suffix_Attributes is type Text_Suffix_Attribute_Node is new Matreshka.ODF_Text.Abstract_Text_Attribute_Node and ODF.DOM.Text_Suffix_Attributes.ODF_Text_Suffix_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Text_Suffix_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Text_Suffix_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Text.Suffix_Attributes;
AdaCore/libadalang
Ada
12,577
adb
------------------------------------------------------------------------------ -- C O D E P E E R -- -- -- -- Copyright (C) 2008-2017, AdaCore -- -- -- -- This is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. This software is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- -- License for more details. You should have received a copy of the GNU -- -- General Public License distributed with this software; see file -- -- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy -- -- of the license. -- -- -- -- The CodePeer technology was originally developed by SofCheck, Inc. -- ------------------------------------------------------------------------------ with BE.Obj_Ids.Constant_Init_Procs; with BE.Obj_Ids.Global_Constants; with BE.Obj_Ids.SCIL_Extension.Update; with BE.Driver; with BE.SCIL.Decl_Regions; with ST.Mains.Debug_Flags; pragma Elaborate_All (ST.Mains.Debug_Flags); with Utils.Storage_Management.Varying_Pools.Debug; package body BE.Obj_Ids.Region_Information.Factory is Test_Reinit_Dmods : constant Boolean := ST.Mains.Debug_Flags.Flag_Is_On ("reinit_dmods", On_By_Default => False); -- This seems to cause "too many iterations" in picocontainer (3/20/06) procedure Init_Module_Region_Info (Node : SCIL.Module; Is_Imported : Boolean) is -- Init region info associated with given module and Is_Imported flag. use type SCIL.Decl_Region; -- for "+" Within : Varying_Pools.Within_Pool (Driver.Cur_Obj_Ids_Cumulative_Pool); pragma Unreferenced (Within); Module_Info : constant Module_Info_Ptr := new Module_Info_Rec; begin -- Initialize Module_Info record Module_Info.Module_Is_Imported := Is_Imported; Module_Info.Level_Num := 0; Module_Info.Associated_Decl_Region := +Node; Module_Info.Associated_Module := Node; Module_Info.Shadow_Obj_Table := null; Module_Info.Global_Const_Init_Table := Constant_Init_Procs.No_Constant_Init_Proc_Mapping; Module_Info.Global_Const_Ref_Table := Global_Constants.No_Obj_Id_Global_Constant_Mapping; -- Initialize shadow-obj table with access-discrim to module Module_Info.Shadow_Obj_Table := new Obj_Table (Module_Info.Associated_Module'Unchecked_Access); Module_Info.Global_Const_Init_Table := Constant_Init_Procs.New_Empty_Constant_Init_Proc_Mapping; Module_Info.Global_Const_Ref_Table := Global_Constants.New_Empty_Global_Constant_Mapping; -- Now store the region info in an extension of module node SCIL_Extension.Update.Set_Decl_Region_Info (+Node, Region_Info_Ptr (Module_Info)); end Init_Module_Region_Info; procedure Reinit_Module_Region_Info (Node : SCIL.Module) is -- Reinit region that was marked Imported before -- to be non-imported. Module_Info : constant Module_Info_Ptr := Associated_Region_Info (Node); pragma Assert (Module_Info.Module_Is_Imported); begin Module_Info.Module_Is_Imported := False; end Reinit_Module_Region_Info; procedure Init_Procedure_Body_Region_Info (Node : SCIL.Procedure_Body) is -- Init region info associated with given procedure body use type SCIL.Decl_Region; -- for "+" Null_VM : Known_Value_Sets.Obj_Id_Value_Mapping; -- default is null; Within : Varying_Pools.Within_Pool (Driver.Cur_Obj_Ids_Cumulative_Pool); pragma Unreferenced (Within); Reg_Info : constant Region_Info_Ptr := new Procedure_Body_Info_Rec; Proc_Info : constant Procedure_Body_Info_Ptr := Procedure_Body_Info_Ptr (Reg_Info); begin Proc_Info.Proc_Is_Poisoned := False; Proc_Info.Level_Num := SCIL.Decl_Regions.Region_Level (+Node); Proc_Info.Associated_Decl_Region := +Node; Proc_Info.Enclosing_Region_Info := Associated_Region_Info (SCIL.Decl_Regions.Container (Node)); Obj_Id_Sets.Make_Empty (Proc_Info.DMOD_Set); Obj_Id_Sets.Make_Empty (Proc_Info.Proc_Obj_Id_In_Progress); Obj_Id_Sets.Make_Empty (Proc_Info.Final_DMOD_Set); Obj_Id_Sets.Make_Empty (Proc_Info.Uplevel_Referenced_Constants); Obj_Id_Sets.Make_Empty (Proc_Info.Exported_New_Objects); Obj_Id_Sets.Make_Empty (Proc_Info.Exported_Unknown_Results); -- Formals is constructed when needed from info on procedure body -- (maybe not a good idea?) Proc_Info.KVS_Clock := 0; Proc_Info.Proc_Obj_Id_Alias_Mapping := Aliasing.New_Empty_Alias_Mapping; Proc_Info.Proc_Obj_Id_Tracked_Alias_Mapping := Aliasing.New_Empty_Alias_Mapping; Proc_Info.Proc_Obj_Id_Other_Alias_Mapping := Aliasing.New_Empty_Alias_Mapping; Proc_Info.Proc_Obj_Id_Value_Mapping := Null_VM; Obj_Id_Sets.Make_Empty (Proc_Info.Final_UPE_Set); Obj_Id_Sets.Make_Empty (Proc_Info.Final_EAV_Set); Proc_Info.DMOD_Values := Known_Value_Sets.New_Empty_Value_Mapping; Proc_Info.DMOD_Change_Counts := Known_Value_Sets.New_Empty_Change_Count_Mapping; Proc_Info.Index_Change_Counts := Known_Value_Sets.New_Empty_Change_Count_Mapping; Proc_Info.Index_Mapping := Known_Value_Sets.New_Empty_Index_Mapping; Proc_Info.Proc_Obj_Id_Static_Components_Mapping := Tracked_Components.New_Empty_Components_Mapping; Proc_Info.Proc_Obj_Id_Dynamic_Components_Mapping := Tracked_Components.New_Empty_Components_Mapping; Obj_Id_Sets.Make_Empty (Proc_Info.Proc_Referenced_Obj_Ids); Obj_Id_Sets.Make_Empty (Proc_Info.Refed_Obj_Id_Exporters); Obj_Id_Sets.Make_Empty (Proc_Info.Caller_Relevant_Refed_Obj_Ids); Proc_Info.Proc_Heap_Array_Mapping := SCIL_To_Obj_Id_Mappings.New_Empty_SCIL_To_Obj_Id_Mapping; Obj_Id_Sets.Make_Empty (Proc_Info.Obj_Ids_Already_Tracked); Obj_Id_Sets.Make_Empty (Proc_Info.Composite_Objs_Outside_Of_Loop); Obj_Id_Sets.Make_Empty (Proc_Info.Composite_Objs_Of_Current_Loop); Proc_Info.Do_Not_Untrack_Types := SCIL.SCIL_Node_Sets.New_Empty_SCIL_Node_Set; Proc_Info.Matching_Type_Info := Matching_Types.New_Empty_Matching_Type_Info; Proc_Info.Procedure_Effects := Known_Value_Sets.Empty_Procedure_Effects; Proc_Info.Rerun_Obj_Main := False; Proc_Info.Iterate_Obj_Id := False; Proc_Info.Is_Part_Of_Loop := False; Proc_Info.Procedure_Effect_Timestamp := 0; Proc_Info.Procedure_Dependence_Mapping := Procedure_Dependence.New_Empty_Dependence_Mapping; Proc_Info.In_Param_Designated_Obj_Mapping := Obj_Id_Mappings.New_Empty_Obj_Id_Mapping; SCIL_Extension.Update.Set_Decl_Region_Info (+Node, Reg_Info); end Init_Procedure_Body_Region_Info; procedure Reinit_Procedure_Body_Region_Info (Node : SCIL.Procedure_Body) is -- Init region info associated with given procedure body. -- NOTE: This involves only the data that starts fresh on each -- iteration. In particular, we do not re-init the -- information that is caller visible (e.g. DMOD_Values). use type SCIL.Decl_Region; -- for "+" Region_Info : constant Procedure_Body_Info_Ptr := Procedure_Body_Info_Ptr (Associated_Region_Info (+Node)); pragma Assert (Driver.Cur_Temp_Pool = Varying_Pools.Debug.Get_Current_Pool); Temp_Pool_VM : constant Known_Value_Sets.Obj_Id_Value_Mapping := Known_Value_Sets.New_Empty_Value_Mapping; begin Obj_Id_Sets.Reinit (Region_Info.Obj_Ids_Already_Tracked); Obj_Id_Sets.Reinit (Region_Info.Composite_Objs_Outside_Of_Loop); Obj_Id_Sets.Reinit (Region_Info.Composite_Objs_Of_Current_Loop); SCIL.SCIL_Node_Sets.Reinit (Region_Info.Do_Not_Untrack_Types); Obj_Id_Sets.Reinit (Region_Info.Proc_Obj_Id_In_Progress); Obj_Id_Sets.Reinit (Region_Info.Refed_Obj_Id_Exporters); -- Reinitialize structures that live in Cumulative Pool -- TBD: We should dealloate the existing space occupied -- by these data structures. Perhaps these should -- be in the "batch" pool since they aren't of interest -- to callers, only to subsequent phases. By putting -- them in the "batch" pool we would get some amount -- of automatic cleanup. declare Within : Varying_Pools.Within_Pool (Driver.Cur_Obj_Ids_Cumulative_Pool); pragma Unreferenced (Within); begin if Test_Reinit_Dmods then -- Reinitialize the DMOD set (prior final DMODs saved in -- Final_DMOD_Set) -- NOTE: This seems to cause "too many iterations" -- in picocontainer (3/20/06) Obj_Id_Sets.Deallocate (Region_Info.DMOD_Set); end if; Region_Info.KVS_Clock := 0; Region_Info.Proc_Obj_Id_Value_Mapping := Temp_Pool_VM; Region_Info.Proc_Obj_Id_Alias_Mapping := Aliasing.New_Empty_Alias_Mapping; Region_Info.Proc_Obj_Id_Tracked_Alias_Mapping := Aliasing.New_Empty_Alias_Mapping; Region_Info.Proc_Obj_Id_Other_Alias_Mapping := Aliasing.New_Empty_Alias_Mapping; Region_Info.Rerun_Obj_Main := False; Region_Info.Iterate_Obj_Id := False; Region_Info.Is_Part_Of_Loop := False; -- NOTE: We are now reinitializing the static tracked-components -- mapping as well as the above information, to help -- ensure that the effects of obj-id stabilize. -- It turns out the presence of a component in the tracked -- components mapping affects obj-id "expansion" during value -- tracking, and if a tracked component is added during -- value tracking itself, on subsequent passes its presence -- earlier could affect the final results. By starting the -- mapping back at empty on each iteration, we avoid that -- problem. Region_Info.Proc_Obj_Id_Static_Components_Mapping := Tracked_Components.New_Empty_Components_Mapping; end; -- NOTE: We could reinit the procedure dependence mapping here, -- but that seems to be fairly slow, and it seems -- relatively rare that on a subsequent pass, a given -- dependence doesn't appear at all (e.g. due to an overflow -- situation) and the corresponding procedure does in fact -- change. end Reinit_Procedure_Body_Region_Info; procedure Reset_Before_Value_Tracker_Iteration (Proc_Info : Procedure_Body_Info_Ptr) is -- Reset mappings and sets before iterating value tracker -- due to new composite-obj subcomponent. pragma Assert (Driver.Cur_Temp_Pool = Varying_Pools.Debug.Get_Current_Pool); begin Obj_Id_Sets.Make_Empty (Proc_Info.Composite_Objs_Outside_Of_Loop); Obj_Id_Sets.Make_Empty (Proc_Info.Composite_Objs_Of_Current_Loop); Proc_Info.KVS_Clock := 0; Known_Value_Sets.Reset_Value_Mapping (Proc_Info.Proc_Obj_Id_Value_Mapping); Proc_Info.Iterate_Obj_Id := False; Proc_Info.Is_Part_Of_Loop := False; end Reset_Before_Value_Tracker_Iteration; end BE.Obj_Ids.Region_Information.Factory;
reznikmm/matreshka
Ada
3,774
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Style_Default_Outline_Level_Attributes is pragma Preelaborate; type ODF_Style_Default_Outline_Level_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Style_Default_Outline_Level_Attribute_Access is access all ODF_Style_Default_Outline_Level_Attribute'Class with Storage_Size => 0; end ODF.DOM.Style_Default_Outline_Level_Attributes;
devkw/Amass
Ada
466
ads
-- Copyright 2017 Jeff Foley. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. name = "Wayback" type = "archive" function start() setratelimit(1) end function vertical(ctx, domain) crawl(ctx, buildurl(domain)) end function resolved(ctx, name) crawl(ctx, buildurl(name)) end function buildurl(domain) return "http://web.archive.org/web/" .. os.date("%Y") .. "/" .. domain end
ekoeppen/STM32_Generic_Ada_Drivers
Ada
4,106
ads
pragma Style_Checks (Off); -- This spec has been automatically generated from STM32L0x1.svd pragma Restrictions (No_Elaboration_Code); with System; package STM32_SVD.STK is pragma Preelaborate; --------------- -- Registers -- --------------- subtype CSR_ENABLE_Field is STM32_SVD.Bit; subtype CSR_TICKINT_Field is STM32_SVD.Bit; subtype CSR_CLKSOURCE_Field is STM32_SVD.Bit; subtype CSR_COUNTFLAG_Field is STM32_SVD.Bit; -- SysTick control and status register type CSR_Register is record -- Counter enable ENABLE : CSR_ENABLE_Field := 16#0#; -- SysTick exception request enable TICKINT : CSR_TICKINT_Field := 16#0#; -- Clock source selection CLKSOURCE : CSR_CLKSOURCE_Field := 16#0#; -- unspecified Reserved_3_15 : STM32_SVD.UInt13 := 16#0#; -- COUNTFLAG COUNTFLAG : CSR_COUNTFLAG_Field := 16#0#; -- unspecified Reserved_17_31 : STM32_SVD.UInt15 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CSR_Register use record ENABLE at 0 range 0 .. 0; TICKINT at 0 range 1 .. 1; CLKSOURCE at 0 range 2 .. 2; Reserved_3_15 at 0 range 3 .. 15; COUNTFLAG at 0 range 16 .. 16; Reserved_17_31 at 0 range 17 .. 31; end record; subtype RVR_RELOAD_Field is STM32_SVD.UInt24; -- SysTick reload value register type RVR_Register is record -- RELOAD value RELOAD : RVR_RELOAD_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 RVR_Register use record RELOAD at 0 range 0 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; subtype CVR_CURRENT_Field is STM32_SVD.UInt24; -- SysTick current value register type CVR_Register is record -- Current counter value CURRENT : CVR_CURRENT_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 CVR_Register use record CURRENT at 0 range 0 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; subtype CALIB_TENMS_Field is STM32_SVD.UInt24; subtype CALIB_SKEW_Field is STM32_SVD.Bit; subtype CALIB_NOREF_Field is STM32_SVD.Bit; -- SysTick calibration value register type CALIB_Register is record -- Calibration value TENMS : CALIB_TENMS_Field := 16#0#; -- unspecified Reserved_24_29 : STM32_SVD.UInt6 := 16#0#; -- SKEW flag: Indicates whether the TENMS value is exact SKEW : CALIB_SKEW_Field := 16#0#; -- NOREF flag. Reads as zero NOREF : CALIB_NOREF_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CALIB_Register use record TENMS at 0 range 0 .. 23; Reserved_24_29 at 0 range 24 .. 29; SKEW at 0 range 30 .. 30; NOREF at 0 range 31 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- SysTick timer type STK_Peripheral is record -- SysTick control and status register CSR : aliased CSR_Register; -- SysTick reload value register RVR : aliased RVR_Register; -- SysTick current value register CVR : aliased CVR_Register; -- SysTick calibration value register CALIB : aliased CALIB_Register; end record with Volatile; for STK_Peripheral use record CSR at 16#0# range 0 .. 31; RVR at 16#4# range 0 .. 31; CVR at 16#8# range 0 .. 31; CALIB at 16#C# range 0 .. 31; end record; -- SysTick timer STK_Periph : aliased STK_Peripheral with Import, Address => STK_Base; end STM32_SVD.STK;
reznikmm/matreshka
Ada
5,823
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Generic_Collections; package AMF.UML.Destruction_Occurrence_Specifications.Collections is pragma Preelaborate; package UML_Destruction_Occurrence_Specification_Collections is new AMF.Generic_Collections (UML_Destruction_Occurrence_Specification, UML_Destruction_Occurrence_Specification_Access); type Set_Of_UML_Destruction_Occurrence_Specification is new UML_Destruction_Occurrence_Specification_Collections.Set with null record; Empty_Set_Of_UML_Destruction_Occurrence_Specification : constant Set_Of_UML_Destruction_Occurrence_Specification; type Ordered_Set_Of_UML_Destruction_Occurrence_Specification is new UML_Destruction_Occurrence_Specification_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_UML_Destruction_Occurrence_Specification : constant Ordered_Set_Of_UML_Destruction_Occurrence_Specification; type Bag_Of_UML_Destruction_Occurrence_Specification is new UML_Destruction_Occurrence_Specification_Collections.Bag with null record; Empty_Bag_Of_UML_Destruction_Occurrence_Specification : constant Bag_Of_UML_Destruction_Occurrence_Specification; type Sequence_Of_UML_Destruction_Occurrence_Specification is new UML_Destruction_Occurrence_Specification_Collections.Sequence with null record; Empty_Sequence_Of_UML_Destruction_Occurrence_Specification : constant Sequence_Of_UML_Destruction_Occurrence_Specification; private Empty_Set_Of_UML_Destruction_Occurrence_Specification : constant Set_Of_UML_Destruction_Occurrence_Specification := (UML_Destruction_Occurrence_Specification_Collections.Set with null record); Empty_Ordered_Set_Of_UML_Destruction_Occurrence_Specification : constant Ordered_Set_Of_UML_Destruction_Occurrence_Specification := (UML_Destruction_Occurrence_Specification_Collections.Ordered_Set with null record); Empty_Bag_Of_UML_Destruction_Occurrence_Specification : constant Bag_Of_UML_Destruction_Occurrence_Specification := (UML_Destruction_Occurrence_Specification_Collections.Bag with null record); Empty_Sequence_Of_UML_Destruction_Occurrence_Specification : constant Sequence_Of_UML_Destruction_Occurrence_Specification := (UML_Destruction_Occurrence_Specification_Collections.Sequence with null record); end AMF.UML.Destruction_Occurrence_Specifications.Collections;
reznikmm/matreshka
Ada
4,033
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.Form_Image_Position_Attributes; package Matreshka.ODF_Form.Image_Position_Attributes is type Form_Image_Position_Attribute_Node is new Matreshka.ODF_Form.Abstract_Form_Attribute_Node and ODF.DOM.Form_Image_Position_Attributes.ODF_Form_Image_Position_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Form_Image_Position_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Form_Image_Position_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Form.Image_Position_Attributes;
reznikmm/matreshka
Ada
4,021
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with AMF.Internals.Tables.CMOF_Attributes; with AMF.Internals.Element_Collections; package body AMF.Internals.CMOF_Relationships is use AMF.Internals.Tables.CMOF_Attributes; ------------------------- -- Get_Related_Element -- ------------------------- overriding function Get_Related_Element (Self : not null access constant CMOF_Relationship_Proxy) return AMF.CMOF.Elements.Collections.Set_Of_CMOF_Element is begin return AMF.CMOF.Elements.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (Internal_Get_Related_Element (Self.Element))); end Get_Related_Element; end AMF.Internals.CMOF_Relationships;
reznikmm/matreshka
Ada
4,417
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- SQL Database Access -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This package provides set of options to configure database drivers. ------------------------------------------------------------------------------ private with Ada.Containers.Hashed_Maps; with League.Strings; private with League.Strings.Hash; package SQL.Options is pragma Preelaborate; type SQL_Options is tagged private; procedure Set (Self : in out SQL_Options; Name : League.Strings.Universal_String; Value : League.Strings.Universal_String); function Get (Self : SQL_Options; Name : League.Strings.Universal_String) return League.Strings.Universal_String; function Is_Set (Self : SQL_Options; Name : League.Strings.Universal_String) return Boolean; private package String_Maps is new Ada.Containers.Hashed_Maps (League.Strings.Universal_String, League.Strings.Universal_String, League.Strings.Hash, League.Strings."=", League.Strings."="); type SQL_Options is tagged record Set : String_Maps.Map; end record; end SQL.Options;
shibayan/openapi-generator
Ada
7,802
ads
-- OpenAPI Petstore -- This is a sample server Petstore server. For this sample, you can use the api key `special_key` to test the authorization filters. -- -- The version of the OpenAPI document: 1.0.0 -- -- -- NOTE: This package is auto generated by OpenAPI-Generator 6.0.0-SNAPSHOT. -- https://openapi-generator.tech -- Do not edit the class manually. with Swagger.Streams; with Ada.Containers.Vectors; package Samples.Petstore.Models is pragma Style_Checks ("-mr"); -- ------------------------------ -- An uploaded response -- Describes the result of uploading an image resource -- ------------------------------ type ApiResponse_Type is record Code : Swagger.Nullable_Integer; P_Type : Swagger.Nullable_UString; Message : Swagger.Nullable_UString; end record; package ApiResponse_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => ApiResponse_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in ApiResponse_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in ApiResponse_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out ApiResponse_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out ApiResponse_Type_Vectors.Vector); -- ------------------------------ -- Pet Tag -- A tag for a pet -- ------------------------------ type Tag_Type is record Id : Swagger.Nullable_Long; Name : Swagger.Nullable_UString; end record; package Tag_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Tag_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Tag_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Tag_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Tag_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Tag_Type_Vectors.Vector); -- ------------------------------ -- Pet category -- A category for a pet -- ------------------------------ type Category_Type is record Id : Swagger.Nullable_Long; Name : Swagger.Nullable_UString; end record; package Category_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Category_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Category_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Category_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Category_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Category_Type_Vectors.Vector); -- ------------------------------ -- a Pet -- A pet for sale in the pet store -- ------------------------------ type Pet_Type is record Id : Swagger.Nullable_Long; Category : Samples.Petstore.Models.Category_Type; Name : Swagger.UString; Photo_Urls : Swagger.UString_Vectors.Vector; Tags : Samples.Petstore.Models.Tag_Type_Vectors.Vector; Status : Swagger.Nullable_UString; end record; package Pet_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Pet_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Pet_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Pet_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Pet_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Pet_Type_Vectors.Vector); -- ------------------------------ -- Pet Order -- An order for a pets from the pet store -- ------------------------------ type Order_Type is record Id : Swagger.Nullable_Long; Pet_Id : Swagger.Nullable_Long; Quantity : Swagger.Nullable_Integer; Ship_Date : Swagger.Nullable_Date; Status : Swagger.Nullable_UString; Complete : Swagger.Nullable_Boolean; end record; package Order_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Order_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Order_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Order_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Order_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Order_Type_Vectors.Vector); -- ------------------------------ -- a User -- A User who is purchasing from the pet store -- ------------------------------ type User_Type is record Id : Swagger.Nullable_Long; Username : Swagger.Nullable_UString; First_Name : Swagger.Nullable_UString; Last_Name : Swagger.Nullable_UString; Email : Swagger.Nullable_UString; Password : Swagger.Nullable_UString; Phone : Swagger.Nullable_UString; User_Status : Swagger.Nullable_Integer; end record; package User_Type_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => User_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in User_Type); procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in User_Type_Vectors.Vector); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out User_Type); procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out User_Type_Vectors.Vector); end Samples.Petstore.Models;
AdaCore/Ada_Drivers_Library
Ada
4,174
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2016, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- This file contains the source code for an interactive program to be run on -- a host computer, to communicate via serial port with a program running on -- a target board. It uses streams to send and receive strings to/from the -- target board program. -- The program can be connected to the target board with a serial cable that -- presents a serial port to the host operating system. The "README.md" file -- associated with this project describes such a cable. -- You can change the COM port number, or even get it from the command line -- as an argument, but it must match what the host OS sees from the USB-COM -- cable. This program has been run successfully on Windows 7 but should run -- on Linux as well. -- When running it, enter a string at the prompt (">") or just hit carriage -- return if you are ready to quit. If you do enter a string, it will be sent -- to the target board, along with the bounds. The program running on the -- target echos it back so this host app will show that response from the -- board. with GNAT.IO; use GNAT.IO; with GNAT.Serial_Communications; use GNAT.Serial_Communications; procedure Host is COM : aliased Serial_Port; COM3 : constant Port_Name := Name (3); Outgoing : String (1 .. 1024); -- arbitrary Last : Natural; begin COM.Open (COM3); COM.Set (Rate => B115200, Block => False); loop Put ("> "); Get_Line (Outgoing, Last); exit when Last = Outgoing'First - 1; Put_Line ("Sending: '" & Outgoing (1 .. Last) & "'"); String'Output (COM'Access, Outgoing (1 .. Last)); declare Incoming : constant String := String'Input (COM'Access); begin Put_Line ("From board: " & Incoming); end; end loop; COM.Close; end Host;
anthony-arnold/AdaID
Ada
10,883
adb
-- (C) Copyright 1999 by John Halleck,All rights reserved. -- Basic Transformation functions of NSA's Secure Hash Algorithm -- This is part of a project at http://www.cc.utah.edu/~nahaj/ package body SHA.Process_Data is Default_Context : Context; -- Standard context for people that don't need -- -- to hash more than one stream at a time; --------------------------------------------------------------------------- -- Totally local functions. -- Raw transformation of the data. procedure Transform (Given : in out Context); -- This is the basic work horse of the standard. Everything else here -- is just frame around this. -- Align data and place in buffer. (Arbitrary chunks.) procedure Graft_On (Given : in out Context; Raw : Unsigned_32; Size : Bit_Index; Increment_Count : Boolean := True); --------------------------------------------------------------------------- -- On with the show ----------------------------------------- -- Quick and easy routine for the most common simple case. function Digest_A_String (Given : String) return Digest is Temp : Context; -- Let's make this totally independent of anything -- -- else the user may be doing. Result : Digest; begin Initialize (Temp); for I in Given'First .. Given'Last loop Add (Byte (Character'Pos (Given (I))), Temp); end loop; Finalize (Result, Temp); return Result; end Digest_A_String; -- Start out the buffer with a good starting state. -- Note that there are assumptions ALL over the code that the -- buffer starts out with zeros. procedure Initialize is begin if Default_Context.Initialized then raise SHA_Second_Initialize; end if; Default_Context := Initial_Value; Default_Context.Initialized := True; end Initialize; procedure Initialize (Given : in out Context) is begin if Given.Initialized then raise SHA_Second_Initialize; end if; Given := Initial_Value; Given.Initialized := True; end Initialize; -- Procedures to add to the data being hashed. procedure Add (Data : Bit) is begin if not Default_Context.Initialized then raise SHA_Not_Initialized; end if; Graft_On (Default_Context, Unsigned_32 (Data), 1); end Add; procedure Add (Data : Bit; Given : in out Context) is begin if not Given.Initialized then raise SHA_Not_Initialized; end if; Graft_On (Given, Unsigned_32 (Data), 1); end Add; procedure Add (Data : Byte) is begin if not Default_Context.Initialized then raise SHA_Not_Initialized; end if; Graft_On (Default_Context, Unsigned_32 (Data), 8); end Add; procedure Add (Data : Byte; Given : in out Context) is begin if not Given.Initialized then raise SHA_Not_Initialized; end if; Graft_On (Given, Unsigned_32 (Data), 8); end Add; procedure Add (Data : Word) is begin if not Default_Context.Initialized then raise SHA_Not_Initialized; end if; Graft_On (Default_Context, Unsigned_32 (Data), 16); end Add; procedure Add (Data : Word; Given : in out Context) is begin if not Given.Initialized then raise SHA_Not_Initialized; end if; Graft_On (Given, Unsigned_32 (Data), 16); end Add; procedure Add (Data : Long) is begin if not Default_Context.Initialized then raise SHA_Not_Initialized; end if; Graft_On (Default_Context, Unsigned_32 (Data), 32); end Add; procedure Add (Data : Long; Given : in out Context) is begin if not Given.Initialized then raise SHA_Not_Initialized; end if; Graft_On (Given, Unsigned_32 (Data), 32); end Add; procedure Add (Data : Long; Size : Bit_Index) is begin if not Default_Context.Initialized then raise SHA_Not_Initialized; end if; Graft_On (Default_Context, Unsigned_32 (Data), Size); end Add; procedure Add (Data : Long; Size : Bit_Index; Given : in out Context) is begin if not Given.Initialized then raise SHA_Not_Initialized; end if; Graft_On (Given, Unsigned_32 (Data), Size); end Add; -- Get the final digest. function Finalize return Digest is Result : Digest; begin Finalize (Result, Default_Context); return Result; end Finalize; procedure Finalize (Result : out Digest) is begin Finalize (Result, Default_Context); end Finalize; procedure Finalize (Result : out Digest; Given : in out Context) is begin if not Given.Initialized then raise SHA_Not_Initialized; end if; -- The standard requires the Data be padded with a single 1 bit. Graft_On (Given, 1, 1, False); -- We may have to make room for the count to be put on the last block. if Given.Next_Word >= Given.Data'Last - 1 then -- Room for the count? if not (Given.Next_Word = Given.Data'Last - 1 and then Given.Remaining_Bits = 32) then Transform (Given); end if; end if; -- Ok, now we can just add the count on. Given.Data (Given.Data'Last - 1) := Given.Count_High; Given.Data (Given.Data'Last) := Given.Count_Low; -- And now we just transform that. Transform (Given); -- Ok, we are done. Given.Initialized := False; -- One aught not to reused this without -- appropriate re-initialization. Result := Given.Current; end Finalize; --------------------------------------------------------------------------- -- Actually put the bits we have into the buffer properly aligned. procedure Graft_On (Given : in out Context; Raw : Unsigned_32; Size : Bit_Index; Increment_Count : Boolean := True) is Offset : Integer range -31 .. 32; -- How far to move to align this? Overflow : Bit_Index := 0; -- How much is into the next word? Remainder : Unsigned_32 := 0; -- What data has to be done in cleanup? Value : Unsigned_32 := Raw; -- What value are we Really working with? begin pragma Inline (Graft_On); -- Huh? if Size = 0 then return; end if; -- How do we have to align the data to fit? Offset := Integer (Given.Remaining_Bits) -- Amount used - Integer (Size); -- Minus amount we have. if Offset > 0 then Value := Shift_Left (Value, Offset); elsif Offset < 0 then Remainder := Shift_Left (Value, 32 + Offset); -- -- Really "- -Offset" Value := Shift_Right (Value, -Offset); Overflow := Bit_Index (-Offset); end if; -- Insert the actual value into the table. Given.Data (Given.Next_Word) := Given.Data (Given.Next_Word) or Value; -- Update where we are in the table. if Offset > 0 then -- Not on a word boundry Given.Remaining_Bits := Given.Remaining_Bits - Size; elsif Given.Next_Word < Data_Buffer'Last then Given.Next_Word := Given.Next_Word + 1; Given.Remaining_Bits := 32; else Transform (Given); -- Also clears everything out of the buffer. end if; -- Handle anything that overflows into the next word. if Overflow /= 0 then Given.Data (Given.Next_Word) := Given.Data (Given.Next_Word) or Remainder; Given.Remaining_Bits := 32 - Overflow; end if; if Increment_Count then Given.Count_Low := Given.Count_Low + Unsigned_32 (Size); if Given.Count_Low < Unsigned_32 (Size) then Given.Count_High := Given.Count_High + 1; if Given.Count_High = 0 then raise SHA_Overflow; end if; -- The standard is only defined up to a total size of what -- you are hashing of 2**64 bits. end if; end if; end Graft_On; --------------------------------------------------------------------------- -- The actual SHA transformation of a block of data. -- Yes, it is cryptic... But it is a pretty much direct transliteration -- of the standard, variable names and all. procedure Transform (Given : in out Context) is Temp : Unsigned_32; -- Buffer to work in. type Work_Buffer is array (0 .. 79) of Unsigned_32; W : Work_Buffer; -- How much is filled from the data, how much is filled by expansion. Fill_Start : constant := Work_Buffer'First + Data_Buffer'Length; Data_End : constant := Fill_Start - 1; A : Unsigned_32 := Given.Current (0); B : Unsigned_32 := Given.Current (1); C : Unsigned_32 := Given.Current (2); D : Unsigned_32 := Given.Current (3); E : Unsigned_32 := Given.Current (4); begin for I in Work_Buffer'First .. Data_End loop W (I) := Given.Data (Word_Range (I)); end loop; for I in Fill_Start .. Work_Buffer'Last loop W (I) := Rotate_Left ( W (I - 3) xor W (I - 8) xor W (I - 14) xor W (I - 16), 1 ); end loop; for I in Work_Buffer'Range loop Temp := W (I) + Rotate_Left (A, 5) + E; case I is when 0 .. 19 => Temp := Temp + 16#5A827999# + ((B and C) or ((not B) and D)); when 20 .. 39 => Temp := Temp + 16#6ED9EBA1# + (B xor C xor D); when 40 .. 59 => Temp := Temp + 16#8F1BBCDC# + ((B and C) or (B and D) or (C and D)); when 60 .. 79 => Temp := Temp + 16#CA62C1D6# + (B xor C xor D); end case; E := D; D := C; C := Rotate_Right (B, 2); -- The standard really says rotate left 30. B := A; A := Temp; end loop; Given.Current := (Given.Current (0) + A, Given.Current (1) + B, Given.Current (2) + C, Given.Current (3) + D, Given.Current (4) + E ); Given.Remaining_Bits := 32; Given.Next_Word := 0; Given.Data := (others => 0); -- *THIS MUST BE DONE* end Transform; end SHA.Process_Data;
annexi-strayline/ASAP-HEX
Ada
4,458
ads
------------------------------------------------------------------------------ -- -- -- Generic HEX String Handling Package -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Copyright (C) 2018-2021, ANNEXI-STRAYLINE Trans-Human Ltd. -- -- All rights reserved. -- -- -- -- Original Contributors: -- -- * Richard Wai, Ensi Martini, Aninda Poddar, Noshen Atashe -- -- (ANNEXI-STRAYLINE) -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- -- -- * Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -- -- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- Standard, verified package to represent an 16-bit modular value with Interfaces; with Hex.Modular_Codec; package Hex.Unsigned_16 with SPARK_Mode is pragma Assertion_Policy (Pre => Check, Post => Ignore, Assert => Ignore); subtype Unsigned_16 is Interfaces.Unsigned_16; use type Unsigned_16; package Codec is new Hex.Modular_Codec (Modular_Value => Unsigned_16, Bit_Width => 16); Maximum_Length: Positive renames Codec.Max_Nibbles; function Decode (Input: String) return Unsigned_16 renames Codec.Decode; procedure Decode (Input : in String; Value : out Unsigned_16) renames Codec.Decode; function Encode (Value: Unsigned_16; Use_Case: Set_Case := Lower_Case) return String renames Codec.Encode; procedure Encode (Value : in Unsigned_16; Buffer : out String; Use_Case: in Set_Case := Lower_Case) renames Codec.Encode; end Hex.Unsigned_16;
AdaCore/training_material
Ada
18,115
ads
pragma Ada_2005; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; package avx512vlbwintrin_h is -- Copyright (C) 2014-2017 Free Software Foundation, Inc. -- This file is part of GCC. -- GCC 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, or (at your option) -- any later version. -- GCC 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. -- 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/>. -- skipped func _mm256_mask_mov_epi8 -- skipped func _mm256_maskz_mov_epi8 -- skipped func _mm_mask_mov_epi8 -- skipped func _mm_maskz_mov_epi8 -- skipped func _mm256_mask_storeu_epi8 -- skipped func _mm_mask_storeu_epi8 -- skipped func _mm256_mask_loadu_epi16 -- skipped func _mm256_maskz_loadu_epi16 -- skipped func _mm_mask_loadu_epi16 -- skipped func _mm_maskz_loadu_epi16 -- skipped func _mm256_mask_mov_epi16 -- skipped func _mm256_maskz_mov_epi16 -- skipped func _mm_mask_mov_epi16 -- skipped func _mm_maskz_mov_epi16 -- skipped func _mm256_mask_loadu_epi8 -- skipped func _mm256_maskz_loadu_epi8 -- skipped func _mm_mask_loadu_epi8 -- skipped func _mm_maskz_loadu_epi8 -- skipped func _mm256_cvtepi16_epi8 -- skipped func _mm256_mask_cvtepi16_epi8 -- skipped func _mm256_maskz_cvtepi16_epi8 -- skipped func _mm_cvtsepi16_epi8 -- skipped func _mm_mask_cvtsepi16_epi8 -- skipped func _mm_maskz_cvtsepi16_epi8 -- skipped func _mm256_cvtsepi16_epi8 -- skipped func _mm256_mask_cvtsepi16_epi8 -- skipped func _mm256_maskz_cvtsepi16_epi8 -- skipped func _mm_cvtusepi16_epi8 -- skipped func _mm_mask_cvtusepi16_epi8 -- skipped func _mm_maskz_cvtusepi16_epi8 -- skipped func _mm256_cvtusepi16_epi8 -- skipped func _mm256_mask_cvtusepi16_epi8 -- skipped func _mm256_maskz_cvtusepi16_epi8 -- skipped func _mm256_mask_broadcastb_epi8 -- skipped func _mm256_maskz_broadcastb_epi8 -- skipped func _mm256_mask_set1_epi8 -- skipped func _mm256_maskz_set1_epi8 -- skipped func _mm_mask_broadcastb_epi8 -- skipped func _mm_maskz_broadcastb_epi8 -- skipped func _mm_mask_set1_epi8 -- skipped func _mm_maskz_set1_epi8 -- skipped func _mm256_mask_broadcastw_epi16 -- skipped func _mm256_maskz_broadcastw_epi16 -- skipped func _mm256_mask_set1_epi16 -- skipped func _mm256_maskz_set1_epi16 -- skipped func _mm_mask_broadcastw_epi16 -- skipped func _mm_maskz_broadcastw_epi16 -- skipped func _mm_mask_set1_epi16 -- skipped func _mm_maskz_set1_epi16 -- skipped func _mm256_permutexvar_epi16 -- skipped func _mm256_maskz_permutexvar_epi16 -- skipped func _mm256_mask_permutexvar_epi16 -- skipped func _mm_permutexvar_epi16 -- skipped func _mm_maskz_permutexvar_epi16 -- skipped func _mm_mask_permutexvar_epi16 -- skipped func _mm256_permutex2var_epi16 -- idx -- skipped func _mm256_mask_permutex2var_epi16 -- idx -- skipped func _mm256_mask2_permutex2var_epi16 -- idx -- skipped func _mm256_maskz_permutex2var_epi16 -- idx -- skipped func _mm_permutex2var_epi16 -- idx -- skipped func _mm_mask_permutex2var_epi16 -- idx -- skipped func _mm_mask2_permutex2var_epi16 -- idx -- skipped func _mm_maskz_permutex2var_epi16 -- idx -- skipped func _mm256_mask_maddubs_epi16 -- skipped func _mm256_maskz_maddubs_epi16 -- skipped func _mm_mask_maddubs_epi16 -- skipped func _mm_maskz_maddubs_epi16 -- skipped func _mm256_mask_madd_epi16 -- skipped func _mm256_maskz_madd_epi16 -- skipped func _mm_mask_madd_epi16 -- skipped func _mm_maskz_madd_epi16 -- skipped func _mm_movepi8_mask -- skipped func _mm256_movepi8_mask -- skipped func _mm_movepi16_mask -- skipped func _mm256_movepi16_mask -- skipped func _mm_movm_epi8 -- skipped func _mm256_movm_epi8 -- skipped func _mm_movm_epi16 -- skipped func _mm256_movm_epi16 -- skipped func _mm_test_epi8_mask -- skipped func _mm_mask_test_epi8_mask -- skipped func _mm256_test_epi8_mask -- skipped func _mm256_mask_test_epi8_mask -- skipped func _mm_test_epi16_mask -- skipped func _mm_mask_test_epi16_mask -- skipped func _mm256_test_epi16_mask -- skipped func _mm256_mask_test_epi16_mask -- skipped func _mm256_maskz_min_epu16 -- skipped func _mm256_mask_min_epu16 -- skipped func _mm_maskz_min_epu16 -- skipped func _mm_mask_min_epu16 -- skipped func _mm256_maskz_min_epi16 -- skipped func _mm256_mask_min_epi16 -- skipped func _mm256_maskz_max_epu8 -- skipped func _mm256_mask_max_epu8 -- skipped func _mm_maskz_max_epu8 -- skipped func _mm_mask_max_epu8 -- skipped func _mm256_maskz_max_epi8 -- skipped func _mm256_mask_max_epi8 -- skipped func _mm_maskz_max_epi8 -- skipped func _mm_mask_max_epi8 -- skipped func _mm256_maskz_min_epu8 -- skipped func _mm256_mask_min_epu8 -- skipped func _mm_maskz_min_epu8 -- skipped func _mm_mask_min_epu8 -- skipped func _mm256_maskz_min_epi8 -- skipped func _mm256_mask_min_epi8 -- skipped func _mm_maskz_min_epi8 -- skipped func _mm_mask_min_epi8 -- skipped func _mm256_maskz_max_epi16 -- skipped func _mm256_mask_max_epi16 -- skipped func _mm_maskz_max_epi16 -- skipped func _mm_mask_max_epi16 -- skipped func _mm256_maskz_max_epu16 -- skipped func _mm256_mask_max_epu16 -- skipped func _mm_maskz_max_epu16 -- skipped func _mm_mask_max_epu16 -- skipped func _mm_maskz_min_epi16 -- skipped func _mm_mask_min_epi16 -- skipped func _mm256_cmpneq_epi8_mask -- skipped func _mm256_cmplt_epi8_mask -- skipped func _mm256_cmpge_epi8_mask -- skipped func _mm256_cmple_epi8_mask -- skipped func _mm256_cmpneq_epi16_mask -- skipped func _mm256_cmplt_epi16_mask -- skipped func _mm256_cmpge_epi16_mask -- skipped func _mm256_cmple_epi16_mask -- skipped func _mm_cmpneq_epu8_mask -- skipped func _mm_cmplt_epu8_mask -- skipped func _mm_cmpge_epu8_mask -- skipped func _mm_cmple_epu8_mask -- skipped func _mm_cmpneq_epu16_mask -- skipped func _mm_cmplt_epu16_mask -- skipped func _mm_cmpge_epu16_mask -- skipped func _mm_cmple_epu16_mask -- skipped func _mm_cmpneq_epi8_mask -- skipped func _mm_cmplt_epi8_mask -- skipped func _mm_cmpge_epi8_mask -- skipped func _mm_cmple_epi8_mask -- skipped func _mm_cmpneq_epi16_mask -- skipped func _mm_cmplt_epi16_mask -- skipped func _mm_cmpge_epi16_mask -- skipped func _mm_cmple_epi16_mask -- skipped func _mm256_mask_mulhrs_epi16 -- skipped func _mm256_maskz_mulhrs_epi16 -- skipped func _mm256_mask_mulhi_epu16 -- skipped func _mm256_maskz_mulhi_epu16 -- skipped func _mm256_mask_mulhi_epi16 -- skipped func _mm256_maskz_mulhi_epi16 -- skipped func _mm_mask_mulhi_epi16 -- skipped func _mm_maskz_mulhi_epi16 -- skipped func _mm_mask_mulhi_epu16 -- skipped func _mm_maskz_mulhi_epu16 -- skipped func _mm_mask_mulhrs_epi16 -- skipped func _mm_maskz_mulhrs_epi16 -- skipped func _mm256_mask_mullo_epi16 -- skipped func _mm256_maskz_mullo_epi16 -- skipped func _mm_mask_mullo_epi16 -- skipped func _mm_maskz_mullo_epi16 -- skipped func _mm256_mask_cvtepi8_epi16 -- skipped func _mm256_maskz_cvtepi8_epi16 -- skipped func _mm_mask_cvtepi8_epi16 -- skipped func _mm_maskz_cvtepi8_epi16 -- skipped func _mm256_mask_cvtepu8_epi16 -- skipped func _mm256_maskz_cvtepu8_epi16 -- skipped func _mm_mask_cvtepu8_epi16 -- skipped func _mm_maskz_cvtepu8_epi16 -- skipped func _mm256_mask_avg_epu8 -- skipped func _mm256_maskz_avg_epu8 -- skipped func _mm_mask_avg_epu8 -- skipped func _mm_maskz_avg_epu8 -- skipped func _mm256_mask_avg_epu16 -- skipped func _mm256_maskz_avg_epu16 -- skipped func _mm_mask_avg_epu16 -- skipped func _mm_maskz_avg_epu16 -- skipped func _mm256_mask_add_epi8 -- skipped func _mm256_maskz_add_epi8 -- skipped func _mm256_mask_add_epi16 -- skipped func _mm256_maskz_add_epi16 -- skipped func _mm256_mask_adds_epi8 -- skipped func _mm256_maskz_adds_epi8 -- skipped func _mm256_mask_adds_epi16 -- skipped func _mm256_maskz_adds_epi16 -- skipped func _mm256_mask_adds_epu8 -- skipped func _mm256_maskz_adds_epu8 -- skipped func _mm256_mask_adds_epu16 -- skipped func _mm256_maskz_adds_epu16 -- skipped func _mm256_mask_sub_epi8 -- skipped func _mm256_maskz_sub_epi8 -- skipped func _mm256_mask_sub_epi16 -- skipped func _mm256_maskz_sub_epi16 -- skipped func _mm256_mask_subs_epi8 -- skipped func _mm256_maskz_subs_epi8 -- skipped func _mm256_mask_subs_epi16 -- skipped func _mm256_maskz_subs_epi16 -- skipped func _mm256_mask_subs_epu8 -- skipped func _mm256_maskz_subs_epu8 -- skipped func _mm256_mask_subs_epu16 -- skipped func _mm256_maskz_subs_epu16 -- skipped func _mm_mask_add_epi8 -- skipped func _mm_maskz_add_epi8 -- skipped func _mm_mask_add_epi16 -- skipped func _mm_maskz_add_epi16 -- skipped func _mm256_mask_unpackhi_epi8 -- skipped func _mm256_maskz_unpackhi_epi8 -- skipped func _mm_mask_unpackhi_epi8 -- skipped func _mm_maskz_unpackhi_epi8 -- skipped func _mm256_mask_unpackhi_epi16 -- skipped func _mm256_maskz_unpackhi_epi16 -- skipped func _mm_mask_unpackhi_epi16 -- skipped func _mm_maskz_unpackhi_epi16 -- skipped func _mm256_mask_unpacklo_epi8 -- skipped func _mm256_maskz_unpacklo_epi8 -- skipped func _mm_mask_unpacklo_epi8 -- skipped func _mm_maskz_unpacklo_epi8 -- skipped func _mm256_mask_unpacklo_epi16 -- skipped func _mm256_maskz_unpacklo_epi16 -- skipped func _mm_mask_unpacklo_epi16 -- skipped func _mm_maskz_unpacklo_epi16 -- skipped func _mm_cmpeq_epi8_mask -- skipped func _mm_cmpeq_epu8_mask -- skipped func _mm_mask_cmpeq_epu8_mask -- skipped func _mm_mask_cmpeq_epi8_mask -- skipped func _mm256_cmpeq_epu8_mask -- skipped func _mm256_cmpeq_epi8_mask -- skipped func _mm256_mask_cmpeq_epu8_mask -- skipped func _mm256_mask_cmpeq_epi8_mask -- skipped func _mm_cmpeq_epu16_mask -- skipped func _mm_cmpeq_epi16_mask -- skipped func _mm_mask_cmpeq_epu16_mask -- skipped func _mm_mask_cmpeq_epi16_mask -- skipped func _mm256_cmpeq_epu16_mask -- skipped func _mm256_cmpeq_epi16_mask -- skipped func _mm256_mask_cmpeq_epu16_mask -- skipped func _mm256_mask_cmpeq_epi16_mask -- skipped func _mm_cmpgt_epu8_mask -- skipped func _mm_cmpgt_epi8_mask -- skipped func _mm_mask_cmpgt_epu8_mask -- skipped func _mm_mask_cmpgt_epi8_mask -- skipped func _mm256_cmpgt_epu8_mask -- skipped func _mm256_cmpgt_epi8_mask -- skipped func _mm256_mask_cmpgt_epu8_mask -- skipped func _mm256_mask_cmpgt_epi8_mask -- skipped func _mm_cmpgt_epu16_mask -- skipped func _mm_cmpgt_epi16_mask -- skipped func _mm_mask_cmpgt_epu16_mask -- skipped func _mm_mask_cmpgt_epi16_mask -- skipped func _mm256_cmpgt_epu16_mask -- skipped func _mm256_cmpgt_epi16_mask -- skipped func _mm256_mask_cmpgt_epu16_mask -- skipped func _mm256_mask_cmpgt_epi16_mask -- skipped func _mm_testn_epi8_mask -- skipped func _mm_mask_testn_epi8_mask -- skipped func _mm256_testn_epi8_mask -- skipped func _mm256_mask_testn_epi8_mask -- skipped func _mm_testn_epi16_mask -- skipped func _mm_mask_testn_epi16_mask -- skipped func _mm256_testn_epi16_mask -- skipped func _mm256_mask_testn_epi16_mask -- skipped func _mm256_mask_shuffle_epi8 -- skipped func _mm256_maskz_shuffle_epi8 -- skipped func _mm_mask_shuffle_epi8 -- skipped func _mm_maskz_shuffle_epi8 -- skipped func _mm256_maskz_packs_epi16 -- skipped func _mm256_mask_packs_epi16 -- skipped func _mm_maskz_packs_epi16 -- skipped func _mm_mask_packs_epi16 -- skipped func _mm256_maskz_packus_epi16 -- skipped func _mm256_mask_packus_epi16 -- skipped func _mm_maskz_packus_epi16 -- skipped func _mm_mask_packus_epi16 -- skipped func _mm256_mask_abs_epi8 -- skipped func _mm256_maskz_abs_epi8 -- skipped func _mm_mask_abs_epi8 -- skipped func _mm_maskz_abs_epi8 -- skipped func _mm256_mask_abs_epi16 -- skipped func _mm256_maskz_abs_epi16 -- skipped func _mm_mask_abs_epi16 -- skipped func _mm_maskz_abs_epi16 -- skipped func _mm256_cmpneq_epu8_mask -- skipped func _mm256_cmplt_epu8_mask -- skipped func _mm256_cmpge_epu8_mask -- skipped func _mm256_cmple_epu8_mask -- skipped func _mm256_cmpneq_epu16_mask -- skipped func _mm256_cmplt_epu16_mask -- skipped func _mm256_cmpge_epu16_mask -- skipped func _mm256_cmple_epu16_mask -- skipped func _mm256_mask_storeu_epi16 -- skipped func _mm_mask_storeu_epi16 -- skipped func _mm_mask_adds_epi16 -- skipped func _mm_mask_subs_epi8 -- skipped func _mm_maskz_subs_epi8 -- skipped func _mm_mask_subs_epi16 -- skipped func _mm_maskz_subs_epi16 -- skipped func _mm_mask_subs_epu8 -- skipped func _mm_maskz_subs_epu8 -- skipped func _mm_mask_subs_epu16 -- skipped func _mm_maskz_subs_epu16 -- skipped func _mm256_mask_srl_epi16 -- skipped func _mm256_maskz_srl_epi16 -- skipped func _mm_mask_srl_epi16 -- skipped func _mm_maskz_srl_epi16 -- skipped func _mm256_mask_sra_epi16 -- skipped func _mm256_maskz_sra_epi16 -- skipped func _mm_mask_sra_epi16 -- skipped func _mm_maskz_sra_epi16 -- skipped func _mm_maskz_adds_epi16 -- skipped func _mm_mask_adds_epu8 -- skipped func _mm_maskz_adds_epu8 -- skipped func _mm_mask_adds_epu16 -- skipped func _mm_maskz_adds_epu16 -- skipped func _mm_mask_sub_epi8 -- skipped func _mm_maskz_sub_epi8 -- skipped func _mm_mask_sub_epi16 -- skipped func _mm_maskz_sub_epi16 -- skipped func _mm_mask_adds_epi8 -- skipped func _mm_maskz_adds_epi8 -- skipped func _mm_cvtepi16_epi8 -- skipped func _mm_mask_cvtepi16_epi8 -- skipped func _mm_maskz_cvtepi16_epi8 -- skipped func _mm256_srav_epi16 -- skipped func _mm256_mask_srav_epi16 -- skipped func _mm256_maskz_srav_epi16 -- skipped func _mm_srav_epi16 -- skipped func _mm_mask_srav_epi16 -- skipped func _mm_maskz_srav_epi16 -- skipped func _mm256_srlv_epi16 -- skipped func _mm256_mask_srlv_epi16 -- skipped func _mm256_maskz_srlv_epi16 -- skipped func _mm_srlv_epi16 -- skipped func _mm_mask_srlv_epi16 -- skipped func _mm_maskz_srlv_epi16 -- skipped func _mm256_sllv_epi16 -- skipped func _mm256_mask_sllv_epi16 -- skipped func _mm256_maskz_sllv_epi16 -- skipped func _mm_sllv_epi16 -- skipped func _mm_mask_sllv_epi16 -- skipped func _mm_maskz_sllv_epi16 -- skipped func _mm_mask_sll_epi16 -- skipped func _mm_maskz_sll_epi16 -- skipped func _mm256_mask_sll_epi16 -- skipped func _mm256_maskz_sll_epi16 -- skipped func _mm256_maskz_packus_epi32 -- skipped func _mm256_mask_packus_epi32 -- skipped func _mm_maskz_packus_epi32 -- skipped func _mm_mask_packus_epi32 -- skipped func _mm256_maskz_packs_epi32 -- skipped func _mm256_mask_packs_epi32 -- skipped func _mm_maskz_packs_epi32 -- skipped func _mm_mask_packs_epi32 -- skipped func _mm_mask_cmpneq_epu8_mask -- skipped func _mm_mask_cmplt_epu8_mask -- skipped func _mm_mask_cmpge_epu8_mask -- skipped func _mm_mask_cmple_epu8_mask -- skipped func _mm_mask_cmpneq_epu16_mask -- skipped func _mm_mask_cmplt_epu16_mask -- skipped func _mm_mask_cmpge_epu16_mask -- skipped func _mm_mask_cmple_epu16_mask -- skipped func _mm_mask_cmpneq_epi8_mask -- skipped func _mm_mask_cmplt_epi8_mask -- skipped func _mm_mask_cmpge_epi8_mask -- skipped func _mm_mask_cmple_epi8_mask -- skipped func _mm_mask_cmpneq_epi16_mask -- skipped func _mm_mask_cmplt_epi16_mask -- skipped func _mm_mask_cmpge_epi16_mask -- skipped func _mm_mask_cmple_epi16_mask -- skipped func _mm256_mask_cmpneq_epu8_mask -- skipped func _mm256_mask_cmplt_epu8_mask -- skipped func _mm256_mask_cmpge_epu8_mask -- skipped func _mm256_mask_cmple_epu8_mask -- skipped func _mm256_mask_cmpneq_epu16_mask -- skipped func _mm256_mask_cmplt_epu16_mask -- skipped func _mm256_mask_cmpge_epu16_mask -- skipped func _mm256_mask_cmple_epu16_mask -- skipped func _mm256_mask_cmpneq_epi8_mask -- skipped func _mm256_mask_cmplt_epi8_mask -- skipped func _mm256_mask_cmpge_epi8_mask -- skipped func _mm256_mask_cmple_epi8_mask -- skipped func _mm256_mask_cmpneq_epi16_mask -- skipped func _mm256_mask_cmplt_epi16_mask -- skipped func _mm256_mask_cmpge_epi16_mask -- skipped func _mm256_mask_cmple_epi16_mask end avx512vlbwintrin_h;
AdaCore/gpr
Ada
1,968
ads
-- -- Copyright (C) 2020-2023, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-Exception -- -- Compiler iterator with GPR2.Environment; package GPR2.KB.Compiler_Iterator is type Object is abstract tagged null record; -- An iterator that searches for all known compilers in a list of -- directories. Whenever a new compiler is found, the Callback primitive -- operation is called. procedure Callback (Self : in out Object; Base : in out KB.Object; Comp : KB.Compiler; Runtime_Specified : Boolean; From_Extra_Dir : Boolean; Continue : out Boolean) is abstract; -- Called whenever a new compiler is discovered. -- It might be discovered either in a path added through a --config -- parameter (in which case From_Extra_Dir is True), or in a path specified -- in the environment variable $PATH (in which case it is False). If the -- directory is both in Extra_Dirs and in $PATH, From_Extra_Dir is set to -- False. -- If Runtime_Specified is True, only filters with a specified runtime are -- applied. -- -- On exit, Continue should be set to False if there is no need to discover -- further compilers (however there will be no possibility to restart the -- search at the same point later on). procedure Foreach_In_Path (Self : in out Object'Class; Base : in out KB.Object; On_Target : Name_Type; Environment : GPR2.Environment.Object; Extra_Dirs : String := ""); -- Find all compilers in "Extra_Dirs & $PATH". -- Extra_Dirs should typically be the list of directories coming from -- GPR2.Project.Configuration.Description parameters. -- The only filtering done is the target, for optimization purposes (no -- need to compute all info about the compiler if we know it will not be -- used anyway). end GPR2.KB.Compiler_Iterator;
reznikmm/torrent
Ada
10,790
adb
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Ada.Containers.Vectors; with League.Text_Codecs; package body Torrent.Trackers is --------------- -- Event_URL -- --------------- function Event_URL (Tracker : League.IRIs.IRI; Info_Hash : SHA1; Peer_Id : SHA1; Port : Positive; Uploaded : Ada.Streams.Stream_Element_Count; Downloaded : Ada.Streams.Stream_Element_Count; Left : Ada.Streams.Stream_Element_Count; Event : Announcement_Kind) return League.IRIs.IRI is subtype SHA1_URL_Encoded is Wide_Wide_String (1 .. 60); function URL_Encoded (Value : SHA1) return SHA1_URL_Encoded; ----------------- -- URL_Encoded -- ----------------- function URL_Encoded (Value : SHA1) return SHA1_URL_Encoded is Text : constant SHA1_Image := Image (Value); begin return Result : SHA1_URL_Encoded do for J in 0 .. 19 loop Result (3 * J + 1) := '%'; Result (3 * J + 2) := Text (2 * J + 1); Result (3 * J + 3) := Text (2 * J + 2); end loop; end return; end URL_Encoded; Port_Img : constant Wide_Wide_String := Positive'Wide_Wide_Image (Port); Up_Img : constant Wide_Wide_String := Ada.Streams.Stream_Element_Count'Wide_Wide_Image (Uploaded); Down_Img : constant Wide_Wide_String := Ada.Streams.Stream_Element_Count'Wide_Wide_Image (Downloaded); Left_Img : constant Wide_Wide_String := Ada.Streams.Stream_Element_Count'Wide_Wide_Image (Left); Query : League.Strings.Universal_String := Tracker.Query; Result : League.IRIs.IRI := Tracker; begin if not Query.Is_Empty then Query.Append ("&"); end if; Query.Append ("info_hash="); Query.Append (URL_Encoded (Info_Hash)); Query.Append ("&peer_id="); Query.Append (URL_Encoded (Peer_Id)); Query.Append ("&port="); Query.Append (Port_Img (2 .. Port_Img'Last)); Query.Append ("&uploaded="); Query.Append (Up_Img (2 .. Up_Img'Last)); Query.Append ("&downloaded="); Query.Append (Down_Img (2 .. Down_Img'Last)); Query.Append ("&left="); Query.Append (Left_Img (2 .. Left_Img'Last)); Query.Append ("&compact=1"); case Event is when Started => Query.Append ("&event="); Query.Append ("started"); when Completed => Query.Append ("&event="); Query.Append ("completed"); when Stopped => Query.Append ("&event="); Query.Append ("stopped"); when Regular => null; end case; Result.Set_Query (Query); return Result; end Event_URL; -------------------- -- Failure_Reason -- -------------------- function Failure_Reason (Self : Response'Class) return League.Strings.Universal_String is begin return Self.Failure_Reason; end Failure_Reason; -------------- -- Interval -- -------------- function Interval (Self : Response'Class) return Duration is begin return Self.Interval; end Interval; ---------------- -- Is_Failure -- ---------------- function Is_Failure (Self : Response'Class) return Boolean is begin return Self.Is_Failure; end Is_Failure; ----------- -- Parse -- ----------- function Parse (Data : Ada.Streams.Stream_Element_Array) return Response is use type Ada.Streams.Stream_Element; use type Ada.Streams.Stream_Element_Count; use type League.Strings.Universal_String; subtype Digit is Ada.Streams.Stream_Element range Character'Pos ('0') .. Character'Pos ('9'); function "+" (Text : Wide_Wide_String) return League.Strings.Universal_String renames League.Strings.To_Universal_String; Buffer : Ada.Streams.Stream_Element_Array renames Data; Next : Ada.Streams.Stream_Element_Count := Buffer'First; Error : constant String := "Can't parse tracker's reply."; Codec : constant League.Text_Codecs.Text_Codec := League.Text_Codecs.Codec (+"utf-8"); package Peer_Vectors is new Ada.Containers.Vectors (Positive, Peer); procedure Expect (Char : Ada.Streams.Stream_Element); procedure Parse_Int (Value : out Integer); procedure Parse_String (Value : out League.Strings.Universal_String); procedure Parse_Peers_String (Result : out Peer_Vectors.Vector); procedure Parse_IP (Value : out League.Strings.Universal_String); procedure Parse_Port (Value : out Natural); package Constants is Interval : constant League.Strings.Universal_String := +"interval"; Peers : constant League.Strings.Universal_String := +"peers"; Failure : constant League.Strings.Universal_String := +"failure reason"; end Constants; ------------ -- Expect -- ------------ procedure Expect (Char : Ada.Streams.Stream_Element) is begin if Buffer (Next) = Char then Next := Next + 1; else raise Constraint_Error with Error; end if; end Expect; --------------- -- Parse_Int -- --------------- procedure Parse_Int (Value : out Integer) is begin Expect (Character'Pos ('i')); Value := 0; while Buffer (Next) in Digit loop Value := Value * 10 + Integer (Buffer (Next)) - Character'Pos ('0'); Expect (Buffer (Next)); end loop; Expect (Character'Pos ('e')); end Parse_Int; -------------- -- Parse_IP -- -------------- procedure Parse_IP (Value : out League.Strings.Universal_String) is X1 : constant Wide_Wide_String := Ada.Streams.Stream_Element'Wide_Wide_Image (Buffer (Next)); X2 : Wide_Wide_String := Ada.Streams.Stream_Element'Wide_Wide_Image (Buffer (Next + 1)); X3 : Wide_Wide_String := Ada.Streams.Stream_Element'Wide_Wide_Image (Buffer (Next + 2)); X4 : Wide_Wide_String := Ada.Streams.Stream_Element'Wide_Wide_Image (Buffer (Next + 3)); begin X2 (1) := '.'; X3 (1) := '.'; X4 (1) := '.'; Value.Clear; Value.Append (X1 (2 .. X1'Last)); Value.Append (X2); Value.Append (X3); Value.Append (X4); Next := Next + 4; end Parse_IP; ------------------------ -- Parse_Peers_String -- ------------------------ procedure Parse_Peers_String (Result : out Peer_Vectors.Vector) is Len : Ada.Streams.Stream_Element_Count := 0; begin while Buffer (Next) in Digit loop Len := Len * 10 + Ada.Streams.Stream_Element_Count (Buffer (Next)) - Character'Pos ('0'); Expect (Buffer (Next)); end loop; if Len mod 6 /= 0 then raise Constraint_Error with Error; end if; Expect (Character'Pos (':')); Result.Reserve_Capacity (Ada.Containers.Count_Type (Len / 6)); for J in 1 .. Len / 6 loop declare Item : Peer; begin Item.Id := (others => 0); Parse_IP (Item.Address); Parse_Port (Item.Port); Result.Append (Item); end; end loop; end Parse_Peers_String; ---------------- -- Parse_Port -- ---------------- procedure Parse_Port (Value : out Natural) is begin Value := Natural (Buffer (Next)) * 256 + Natural (Buffer (Next + 1)); Next := Next + 2; end Parse_Port; ------------------ -- Parse_String -- ------------------ procedure Parse_String (Value : out League.Strings.Universal_String) is Len : Ada.Streams.Stream_Element_Count := 0; begin while Buffer (Next) in Digit loop Len := Len * 10 + Ada.Streams.Stream_Element_Count (Buffer (Next)) - Character'Pos ('0'); Expect (Buffer (Next)); end loop; Expect (Character'Pos (':')); Value := Codec.Decode (Buffer (Next .. Next + Len - 1)); Next := Next + Len; end Parse_String; Key : League.Strings.Universal_String; Failure : League.Strings.Universal_String; Interval : Integer := 0; Peers : Peer_Vectors.Vector; Ignore : Integer; begin Expect (Character'Pos ('d')); while Buffer (Next) /= Character'Pos ('e') loop Parse_String (Key); if Key = Constants.Failure then Parse_String (Failure); elsif Key = Constants.Interval then Parse_Int (Interval); elsif Key = Constants.Peers then if Buffer (Next) in Digit then Parse_Peers_String (Peers); else raise Constraint_Error with "Unimplemented peers reading"; end if; elsif Buffer (Next) = Character'Pos ('i') then Parse_Int (Ignore); else raise Constraint_Error with Error; end if; end loop; Expect (Character'Pos ('e')); return Result : Response (Peer_Count => Peers.Last_Index) do Result.Is_Failure := not Failure.Is_Empty; Result.Failure_Reason := Failure; Result.Interval := Duration (Interval); for J in Result.Peers'Range loop Result.Peers (J) := Peers.Element (J); end loop; end return; end Parse; ------------------ -- Peer_Address -- ------------------ function Peer_Address (Self : Response'Class; Index : Positive) return League.Strings.Universal_String is begin return Self.Peers (Index).Address; end Peer_Address; ---------------- -- Peer_Count -- ---------------- function Peer_Count (Self : Response'Class) return Natural is begin return Self.Peer_Count; end Peer_Count; ------------- -- Peer_Id -- ------------- function Peer_Id (Self : Response'Class; Index : Positive) return SHA1 is begin return Self.Peers (Index).Id; end Peer_Id; --------------- -- Peer_Port -- --------------- function Peer_Port (Self : Response'Class; Index : Positive) return Natural is begin return Self.Peers (Index).Port; end Peer_Port; end Torrent.Trackers;
persan/A-gst
Ada
3,804
ads
pragma Ada_2005; pragma Style_Checks (Off); pragma Warnings (Off); with Interfaces.C; use Interfaces.C; with glib; with glib.Values; with System; with System; with GLIB; -- with GStreamer.GST_Low_Level.glibconfig_h; with GStreamer.GST_Low_Level.gstreamer_0_10_gst_fft_gstfft_h; package GStreamer.GST_Low_Level.gstreamer_0_10_gst_fft_gstffts16_h is -- GStreamer -- * Copyright (C) <2007> Sebastian Dröge <[email protected]> -- * -- * This library is free software; you can redistribute it and/or -- * modify it under the terms of the GNU Library General Public -- * License as published by the Free Software Foundation; either -- * version 2 of the License, or (at your option) any later version. -- * -- * This library is distributed in the hope that it will be useful, -- * but WITHOUT ANY WARRANTY; without even the implied warranty of -- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- * Library General Public License for more details. -- * -- * You should have received a copy of the GNU Library General Public -- * License along with this library; if not, write to the -- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- * Boston, MA 02111-1307, USA. -- type GstFFTS16; type u_GstFFTS16_u_padding_array is array (0 .. 3) of System.Address; --subtype GstFFTS16 is u_GstFFTS16; -- gst/fft/gstffts16.h:30 type GstFFTS16Complex; --subtype GstFFTS16Complex is u_GstFFTS16Complex; -- gst/fft/gstffts16.h:31 -- FIXME 0.11: Move the struct definition to the sources, -- * there's no reason to have it public. -- --* -- * GstFFTS16: -- * -- * Instance structure for #GstFFTS16. -- * -- -- <private> type GstFFTS16 is record cfg : System.Address; -- gst/fft/gstffts16.h:44 inverse : aliased GLIB.gboolean; -- gst/fft/gstffts16.h:45 len : aliased GLIB.gint; -- gst/fft/gstffts16.h:46 u_padding : u_GstFFTS16_u_padding_array; -- gst/fft/gstffts16.h:47 end record; pragma Convention (C_Pass_By_Copy, GstFFTS16); -- gst/fft/gstffts16.h:42 -- Copy of kiss_fft_s16_cpx for documentation reasons, -- * do NOT change! --* -- * GstFFTS16Complex: -- * @r: Real part -- * @i: Imaginary part -- * -- * Data type for complex numbers composed of -- * signed 16 bit integers. -- * -- type GstFFTS16Complex is record r : aliased GLIB.gint16; -- gst/fft/gstffts16.h:64 i : aliased GLIB.gint16; -- gst/fft/gstffts16.h:65 end record; pragma Convention (C_Pass_By_Copy, GstFFTS16Complex); -- gst/fft/gstffts16.h:62 -- Functions function gst_fft_s16_new (len : GLIB.gint; inverse : GLIB.gboolean) return access GstFFTS16; -- gst/fft/gstffts16.h:70 pragma Import (C, gst_fft_s16_new, "gst_fft_s16_new"); procedure gst_fft_s16_fft (self : access GstFFTS16; timedata : access GLIB.gint16; freqdata : access GstFFTS16Complex); -- gst/fft/gstffts16.h:71 pragma Import (C, gst_fft_s16_fft, "gst_fft_s16_fft"); procedure gst_fft_s16_inverse_fft (self : access GstFFTS16; freqdata : access constant GstFFTS16Complex; timedata : access GLIB.gint16); -- gst/fft/gstffts16.h:72 pragma Import (C, gst_fft_s16_inverse_fft, "gst_fft_s16_inverse_fft"); procedure gst_fft_s16_free (self : access GstFFTS16); -- gst/fft/gstffts16.h:73 pragma Import (C, gst_fft_s16_free, "gst_fft_s16_free"); procedure gst_fft_s16_window (self : access GstFFTS16; timedata : access GLIB.gint16; window : GStreamer.GST_Low_Level.gstreamer_0_10_gst_fft_gstfft_h.GstFFTWindow); -- gst/fft/gstffts16.h:75 pragma Import (C, gst_fft_s16_window, "gst_fft_s16_window"); end GStreamer.GST_Low_Level.gstreamer_0_10_gst_fft_gstffts16_h;
reznikmm/matreshka
Ada
10,544
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2016-2017, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with WebAPI.DOM.Documents; with WebAPI.DOM.Elements; package body WUI.Widgets.Windows is ------------------ -- Constructors -- ------------------ package body Constructors is ---------------- -- Initialize -- ---------------- procedure Initialize (Self : in out Window'Class; Element : not null WebAPI.HTML.Elements.HTML_Element_Access) is begin Self.Enclosing_Div := WebAPI.HTML.Elements.HTML_Element_Access (Element); WUI.Widgets.Constructors.Initialize (Self, Element); end Initialize; ---------------- -- Initialize -- ---------------- procedure Initialize (Self : in out Window'Class; Parent : not null access WUI.Widgets.Abstract_Widget'Class; Title : League.Strings.Universal_String) is Document : constant WebAPI.DOM.Documents.Document_Access := Parent.Element.Get_Owner_Document; Enclosing : constant not null WebAPI.DOM.Elements.Element_Access := Document.Create_Element (+"div"); Head : constant not null WebAPI.DOM.Elements.Element_Access := Document.Create_Element (+"div"); Corner : constant not null WebAPI.DOM.Elements.Element_Access := Document.Create_Element (+"div"); Content : constant not null WebAPI.DOM.Elements.Element_Access := Document.Create_Element (+"div"); begin Self.Enclosing_Div := WebAPI.HTML.Elements.HTML_Element_Access (Enclosing); Head.Set_Text_Content (Title); Head.Set_Class_Name (+"window-title"); Enclosing.Set_Class_Name (+"window"); Enclosing.Append_Child (Head); Content.Set_Class_Name (+"window-body"); Enclosing.Append_Child (Content); Corner.Set_Class_Name (+"window-corner"); Enclosing.Append_Child (Corner); WUI.Widgets.Constructors.Initialize (Self, WebAPI.HTML.Elements.HTML_Element_Access (Content)); WUI.Widgets.Constructors.Initialize (Self.Slider, WebAPI.HTML.Elements.HTML_Element_Access (Head)); WUI.Widgets.Constructors.Initialize (Self.Resizer, WebAPI.HTML.Elements.HTML_Element_Access (Corner)); Parent.Element.Append_Child (Enclosing); end Initialize; end Constructors; ------------- -- Sliders -- ------------- package body Sliders is ---------------------- -- Mouse_Move_Event -- ---------------------- overriding procedure Mouse_Move_Event (Self : in out Slider; Event : in out WUI.Events.Mouse.Move.Mouse_Move_Event'Class) is begin if Self.Active then Self.Win_X := Self.Win_X + Integer (Event.X - Self.Prev_X); Self.Win_Y := Self.Win_Y + Integer (Event.Y - Self.Prev_Y); Self.Parent.Set_Position (Self.Win_Y, Self.Win_X); Self.Prev_X := Event.X; Self.Prev_Y := Event.Y; end if; end Mouse_Move_Event; ---------------------- -- Mouse_Move_Event -- ---------------------- overriding procedure Mouse_Move_Event (Self : in out Resizer; Event : in out WUI.Events.Mouse.Move.Mouse_Move_Event'Class) is begin if Self.Active then Self.Win_X := Self.Win_X + Integer (Event.X - Self.Prev_X); Self.Win_Y := Self.Win_Y + Integer (Event.Y - Self.Prev_Y); Self.Parent.Set_Size (Self.Win_Y, Self.Win_X); Self.Prev_X := Event.X; Self.Prev_Y := Event.Y; end if; end Mouse_Move_Event; ----------------------- -- Mouse_Press_Event -- ----------------------- overriding procedure Mouse_Press_Event (Self : in out Slider; Event : in out WUI.Events.Mouse.Button.Mouse_Button_Event'Class) is begin Self.Active := True; Self.Prev_X := Event.X; Self.Prev_Y := Event.Y; Self.Win_X := Self.Parent.Left; Self.Win_Y := Self.Parent.Top; end Mouse_Press_Event; ----------------------- -- Mouse_Press_Event -- ----------------------- overriding procedure Mouse_Press_Event (Self : in out Resizer; Event : in out WUI.Events.Mouse.Button.Mouse_Button_Event'Class) is begin Self.Active := True; Self.Prev_X := Event.X; Self.Prev_Y := Event.Y; Self.Win_X := Self.Parent.Width; Self.Win_Y := Self.Parent.Height; end Mouse_Press_Event; ------------------------- -- Mouse_Release_Event -- ------------------------- overriding procedure Mouse_Release_Event (Self : in out Slider; Event : in out WUI.Events.Mouse.Button.Mouse_Button_Event'Class) is begin Self.Active := False; end Mouse_Release_Event; end Sliders; ------------ -- Height -- ------------ not overriding function Height (Self : Window) return Integer is begin return Integer (Self.Enclosing_Div.Get_Offset_Height); end Height; ---------- -- Left -- ---------- not overriding function Left (Self : Window) return Integer is begin return Integer (Self.Enclosing_Div.Get_Offset_Left); end Left; ----------- -- Width -- ----------- not overriding function Width (Self : Window) return Integer is begin return Integer (Self.Enclosing_Div.Get_Offset_Width); end Width; ------------------ -- Set_Position -- ------------------ not overriding procedure Set_Position (Self : in out Window; Top : Integer; Left : Integer) is begin Self.Set_Style (Top, Left, Self.Height, Self.Width); end Set_Position; -------------- -- Set_Size -- -------------- not overriding procedure Set_Size (Self : in out Window; Height : Integer; Width : Integer) is begin Self.Set_Style (Self.Top, Self.Left, Height, Width); end Set_Size; --------------- -- Set_Style -- --------------- not overriding procedure Set_Style (Self : in out Window; Top : Integer; Left : Integer; Height : Integer; Width : Integer) is use type League.Strings.Universal_String; Top_Image : constant Wide_Wide_String := Integer'Wide_Wide_Image (Top); Left_Image : constant Wide_Wide_String := Integer'Wide_Wide_Image (Left); Height_Image : constant Wide_Wide_String := Integer'Wide_Wide_Image (Height); Width_Image : constant Wide_Wide_String := Integer'Wide_Wide_Image (Width); Style : League.Strings.Universal_String := +"top:"; begin Style := Style & Top_Image & "px; left:" & Left_Image & "px;" & "height:" & Height_Image & "px; width:" & Width_Image & "px;"; Self.Enclosing_Div.Set_Attribute (+"style", Style); end Set_Style; --------- -- Top -- --------- not overriding function Top (Self : Window) return Integer is begin return Integer (Self.Enclosing_Div.Get_Offset_Top); end Top; end WUI.Widgets.Windows;
iyan22/AprendeAda
Ada
1,545
adb
with Datos; use Datos; procedure Posicion_Lista_Ordenada ( L : Lista; Num : Integer; Found : out Boolean; PosDev : out Natural ) is -- pre: L esta ordenada, con sus valores de menor a mayor -- post: Esta valdra true si Num pertenece a L y false si no -- Pos es la posicion de la primera aparicion de Num, -- en caso de que Num pertenezca a L, y si no -- devolverá la posición en que debería colocarse LCopia : Lista; Finish : Boolean; Pos : Integer; begin -- Definición de variables LCopia := L; Pos := 0; PosDev := 0; Found := False; Finish := False; -- Si la lista esta vacia devolvemos la primera posicion if LCopia = null then PosDev := 1; end if; -- Mientras que el elemento/lista no este vacio y no haya sido encontrado, ni orden de acabar while LCopia /= null and Found = False and Finish = False loop Pos := Pos+1; -- Incrementamos la posicion -- Si el elemento es igual if LCopia.all.info = Num then Found := True; Finish := True; PosDev := Pos; -- Si el elemento es menor elsif LCopia.all.info > Num then Finish := True; PosDev := Pos; -- Si el siguiente, esta vacio, o sino esta vacio y ademas es mayor a Num elsif LCopia.all.sig = null or (LCopia.all.sig /= null and then LCopia.all.sig.all.info > Num) then PosDev := Pos+1; Finish := True; end if; -- Si no sabemos donde insertarlo avanzamos a analizar el siguiente elemento LCopia := LCopia.all.sig; end loop; end Posicion_Lista_Ordenada;