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/gpr
Ada
85
adb
package body PACK is function Functions_Test return String is separate; end PACK;
reznikmm/matreshka
Ada
3,993
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Draw_Modifiers_Attributes; package Matreshka.ODF_Draw.Modifiers_Attributes is type Draw_Modifiers_Attribute_Node is new Matreshka.ODF_Draw.Abstract_Draw_Attribute_Node and ODF.DOM.Draw_Modifiers_Attributes.ODF_Draw_Modifiers_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Draw_Modifiers_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Draw_Modifiers_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Draw.Modifiers_Attributes;
sungyeon/drake
Ada
3,526
adb
with Ada.Exceptions; with Ada.Interrupts.Names; with Ada.Unchecked_Conversion; with System.Formatting; with System.Long_Long_Integer_Types; with System.Unwind.Occurrences; with C.signal; package body System.Native_Interrupts.Vector is use type Ada.Interrupts.Parameterless_Handler; use type C.signed_int; use type C.unsigned_int; use type C.signal.p_sig_fn_t; subtype Word_Unsigned is Long_Long_Integer_Types.Word_Unsigned; procedure Report ( Interrupt : Interrupt_Id; X : Ada.Exceptions.Exception_Occurrence); procedure Report ( Interrupt : Interrupt_Id; X : Ada.Exceptions.Exception_Occurrence) is function Cast is new Ada.Unchecked_Conversion ( Ada.Exceptions.Exception_Occurrence, Unwind.Exception_Occurrence); Name_Prefix : constant String := "Interrupt "; Name : String (1 .. Name_Prefix'Length + Interrupt_Id'Width); Name_Last : Natural; Error : Boolean; begin Name (1 .. Name_Prefix'Length) := Name_Prefix; Formatting.Image ( Word_Unsigned (Interrupt), Name (Name_Prefix'Length + 1 .. Name'Last), Name_Last, Error => Error); Unwind.Occurrences.Report (Cast (X), Name (1 .. Name_Last)); end Report; type Signal_Rec is record Installed_Handler : Parameterless_Handler; Saved : aliased C.signal.p_sig_fn_t; end record; pragma Suppress_Initialization (Signal_Rec); type Signal_Vec is array ( C.signed_int range C.signed_int (Ada.Interrupts.Names.First_Interrupt_Id) .. C.signed_int (Ada.Interrupts.Names.Last_Interrupt_Id)) of Signal_Rec; pragma Suppress_Initialization (Signal_Vec); Table : Signal_Vec; procedure Handler (Signal_Number : C.signed_int) with Convention => C; procedure Handler (Signal_Number : C.signed_int) is begin Table (Signal_Number).Installed_Handler.all; exception -- CXC3004, an exception propagated from a handler has no effect when E : others => Report (Interrupt_Id (Signal_Number), E); end Handler; -- implementation function Current_Handler (Interrupt : Interrupt_Id) return Parameterless_Handler is begin return Table (Interrupt).Installed_Handler; end Current_Handler; procedure Exchange_Handler ( Old_Handler : out Parameterless_Handler; New_Handler : Parameterless_Handler; Interrupt : Interrupt_Id) is Item : Signal_Rec renames Table (Interrupt); begin Old_Handler := Item.Installed_Handler; if Old_Handler = null and then New_Handler /= null then declare Old_Action : C.signal.p_sig_fn_t; begin Old_Action := C.signal.signal ( C.signed_int (Interrupt), Handler'Access); if Old_Action = C.signal.SIG_ERR then raise Program_Error; end if; Old_Action := Item.Saved; end; elsif Old_Handler /= null and then New_Handler = null then declare Old_Action : C.signal.p_sig_fn_t; begin Old_Action := C.signal.signal ( C.signed_int (Interrupt), Item.Saved); if Old_Action = C.signal.SIG_ERR then raise Program_Error; end if; end; end if; Item.Installed_Handler := New_Handler; end Exchange_Handler; end System.Native_Interrupts.Vector;
reznikmm/matreshka
Ada
2,164
adb
with Ada.Command_Line; with Ada.Strings.Wide_Wide_Fixed; with Ada.Wide_Wide_Text_IO; with League.Regexps; with League.Strings; with Matreshka.Internals.Regexps.Compiler.Debug; with Matreshka.Internals.Regexps.Engine.Debug; procedure Demo is function Read (File_Name : String) return League.Strings.Universal_String; ---------- -- Read -- ---------- function Read (File_Name : String) return League.Strings.Universal_String is File : Ada.Wide_Wide_Text_IO.File_Type; Buffer : Wide_Wide_String (1 .. 1024); Last : Natural; begin Ada.Wide_Wide_Text_IO.Open (File, Ada.Wide_Wide_Text_IO.In_File, File_Name, "wcem=8"); Ada.Wide_Wide_Text_IO.Get_Line (File, Buffer, Last); Ada.Wide_Wide_Text_IO.Close (File); return League.Strings.To_Universal_String (Buffer (1 .. Last)); end Read; Expression : League.Strings.Universal_String := Read (Ada.Command_Line.Argument (1)); String : League.Strings.Universal_String := Read (Ada.Command_Line.Argument (2)); Pattern : League.Regexps.Regexp_Pattern := League.Regexps.Compile (Expression); Match : League.Regexps.Regexp_Match := Pattern.Find_Match (String); begin if Match.Is_Matched then Ada.Wide_Wide_Text_IO.Put_Line ("Match found:" & Integer'Wide_Wide_Image (Match.First_Index) & " .." & Integer'Wide_Wide_Image (Match.Last_Index) & " => '" & League.Strings.To_Wide_Wide_String (Match.Capture) & "'"); for J in 1 .. Match.Capture_Count loop Ada.Wide_Wide_Text_IO.Put_Line (" \" & Ada.Strings.Wide_Wide_Fixed.Trim (Integer'Wide_Wide_Image (J), Ada.Strings.Both) & ":" & Integer'Wide_Wide_Image (Match.First_Index (J)) & " .." & Integer'Wide_Wide_Image (Match.Last_Index (J)) & " => '" & League.Strings.To_Wide_Wide_String (Match.Capture (J)) & "'"); end loop; else Ada.Wide_Wide_Text_IO.Put_Line ("Not matched"); end if; end Demo;
AdaCore/langkit
Ada
6,152
adb
-- -- Copyright (C) 2014-2022, AdaCore -- SPDX-License-Identifier: Apache-2.0 -- with Ada.Unchecked_Conversion; with System; package body Langkit_Support.Bump_Ptr_Vectors is function Alloc_Chunk (P : Bump_Ptr_Pool; S : Natural) return Chunk_Access; ----------------- -- Alloc_Chunk -- ----------------- function Alloc_Chunk (P : Bump_Ptr_Pool; S : Natural) return Chunk_Access is subtype C is Chunk (S); function To_Pointer is new Ada.Unchecked_Conversion (System.Address, Chunk_Access); Ret_Memory : constant System.Address := Allocate (P, C'Max_Size_In_Storage_Elements); -- Allocate a chunk of memory for the result -- discriminated record... Ret_Disc : Natural; for Ret_Disc'Address use Ret_Memory; -- And initialize its discriminant properly as the -- runtime would do with regular allocation. begin Ret_Disc := S; return To_Pointer (Ret_Memory); end Alloc_Chunk; function Create (P : Bump_Ptr_Pool) return Vector is (Vector'(Pool => P, others => <>)); ------------ -- Append -- ------------ procedure Append (Self : in out Vector; Element : Element_Type) is procedure Init_Chunk (C : in out Chunk) with Inline; ---------------- -- Init_Chunk -- ---------------- procedure Init_Chunk (C : in out Chunk) is begin C.Next_Chunk := null; C.Length := 0; end Init_Chunk; Old_Chunk : Chunk_Access; begin -- First append, create a chunk and initialize it if Self.Length = 0 then Self.First_Chunk := Alloc_Chunk (Self.Pool, 2); Init_Chunk (Self.First_Chunk.all); Self.Current_Chunk := Self.First_Chunk; end if; -- We filled the current chunk completely, create a new chunk and -- initialize it, chain it with the previous chunk. if Self.Current_Chunk.Length = Self.Current_Chunk.Capacity then Old_Chunk := Self.Current_Chunk; Self.Current_Chunk := Alloc_Chunk (Self.Pool, Old_Chunk.Capacity * 2); Init_Chunk (Self.Current_Chunk.all); Old_Chunk.Next_Chunk := Self.Current_Chunk; end if; -- At this stage we know the current chunk can contain element, insert -- it. Self.Current_Chunk.Length := Self.Current_Chunk.Length + 1; Self.Length := Self.Length + 1; Self.Current_Chunk.Elements (Self.Current_Chunk.Length) := Element; end Append; --------- -- Get -- --------- function Get (Self : Vector; C : Cursor) return Element_Type is pragma Unreferenced (Self); begin return C.Chunk.Elements (C.Index_In_Chunk); end Get; ------------------ -- Get_At_Index -- ------------------ function Get_At_Index (Self : Vector; I : Index_Type) return Element_Type is function Get_In_Chunk (Chunk : Chunk_Access; Chunk_Start_Index : Index_Type) return Element_Type is (Chunk.Elements (I - Chunk_Start_Index + 1)); -- Assuming that 1) Chunk's first element has index Chunk_Start_Index -- and that 2) the I index is inside this chunk, return the element -- corresponding to I. begin -- As the size of chunks double for each appended chunk, the element we -- are looking for should be in the current chunk more than half of the -- times (assuming equiprobable accesses). So let's just check if it's -- the case. declare Current_Chunk_Start_Index : constant Index_Type := Index_Type'First + Self.Length - Self.Current_Chunk.Length; begin if I >= Current_Chunk_Start_Index then return Get_In_Chunk (Self.Current_Chunk, Current_Chunk_Start_Index); end if; end; -- We had no luck: go through all chunks to find the one that contains -- the element at index I. declare Chunk_Start_Index : Index_Type := Index_Type'First; Current_Chunk : Chunk_Access := Self.First_Chunk; begin while Current_Chunk /= null and then I >= Chunk_Start_Index + Current_Chunk.Capacity loop Chunk_Start_Index := Chunk_Start_Index + Current_Chunk.Capacity; Current_Chunk := Current_Chunk.Next_Chunk; end loop; return Get_In_Chunk (Current_Chunk, Chunk_Start_Index); end; end Get_At_Index; ---------------- -- Get_Access -- ---------------- function Get_Access (Self : Vector; C : Cursor) return Element_Access is pragma Unreferenced (Self); begin return C.Chunk.Elements (C.Index_In_Chunk)'Unrestricted_Access; end Get_Access; ------------ -- Length -- ------------ function Length (Self : Vector) return Natural is begin return Self.Length; end Length; ----------- -- First -- ----------- function First (Self : Vector) return Cursor is begin return Cursor'(Chunk => Self.First_Chunk, Index_In_Chunk => 1); end First; ---------- -- Next -- ---------- function Next (Self : Vector; C : Cursor) return Cursor is pragma Unreferenced (Self); begin if C.Index_In_Chunk = C.Chunk.Capacity then return Cursor'(C.Chunk.Next_Chunk, 1); else return Cursor'(C.Chunk, C.Index_In_Chunk + 1); end if; end Next; ----------------- -- Has_Element -- ----------------- function Has_Element (Self : Vector; C : Cursor) return Boolean is pragma Unreferenced (Self); begin return C.Chunk /= null and then C.Index_In_Chunk <= C.Chunk.Length; end Has_Element; ----------------- -- First_Index -- ----------------- function First_Index (Self : Vector) return Index_Type is pragma Unreferenced (Self); begin return Index_Type'First; end First_Index; ---------------- -- Last_Index -- ---------------- function Last_Index (Self : Vector) return Integer is begin return Index_Type'First + Length (Self) - 1; end Last_Index; end Langkit_Support.Bump_Ptr_Vectors;
reznikmm/matreshka
Ada
3,679
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.Smil_End_Attributes is pragma Preelaborate; type ODF_Smil_End_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Smil_End_Attribute_Access is access all ODF_Smil_End_Attribute'Class with Storage_Size => 0; end ODF.DOM.Smil_End_Attributes;
reznikmm/matreshka
Ada
4,221
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$ ------------------------------------------------------------------------------ package AMF.Internals.Collections.Strings.Proxies is pragma Preelaborate; type Shared_String_Collection_Proxy is new Shared_String_Collection with record Collection : AMF.Internals.AMF_Collection_Of_String; end record; overriding procedure Reference (Self : not null access Shared_String_Collection_Proxy) is null; overriding procedure Unreference (Self : not null access Shared_String_Collection_Proxy) is null; overriding function Length (Self : not null access constant Shared_String_Collection_Proxy) return Natural; overriding procedure Clear (Self : not null access Shared_String_Collection_Proxy); overriding function Element (Self : not null access constant Shared_String_Collection_Proxy; Index : Positive) return League.Strings.Universal_String; end AMF.Internals.Collections.Strings.Proxies;
egustafson/sandbox
Ada
868
adb
with text_io, task_control; use text_io, task_control; procedure ptask is -- y : duration := 0.0005; package int_io is new integer_io (integer); use int_io; task looper is end; task body looper is begin for j in 1 .. 100 loop put (j); new_line; end loop; new_line; put_line ("task integers complete"); new_line; end; task scooper is end; task body scooper is begin task_control.set_time_slice (0.001); for k in 1..4 loop for j in 'A'..'Z' loop put (j); new_line; end loop; new_line; end loop; put_line ("task letters complete"); new_line; end; begin -- ptask task_control.pre_emption_on; for x in 1000 ..1020 loop -- task_control.set_time_slice (y); -- y := y + y; put(x); new_line; end loop; put_line ("proc complete"); end ptask;
apple-oss-distributions/old_ncurses
Ada
10,532
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- ncurses -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 2000 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Eugene V. Melaragno <[email protected]> 2000 -- Version Control -- $Revision: 1.1.1.1 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ with ncurses2.util; use ncurses2.util; with ncurses2.genericPuts; with Terminal_Interface.Curses; use Terminal_Interface.Curses; with Ada.Strings.Unbounded; with Ada.Strings.Fixed; procedure ncurses2.acs_display is use Int_IO; procedure show_upper_chars (first : Integer); function show_1_acs (N : Integer; name : String; code : Attributed_Character) return Integer; procedure show_acs_chars; procedure show_upper_chars (first : Integer) is C1 : Boolean := (first = 128); last : Integer := first + 31; package p is new ncurses2.genericPuts (200); use p; use p.BS; use Ada.Strings.Unbounded; tmpa : Unbounded_String; tmpb : BS.Bounded_String; begin Erase; Switch_Character_Attribute (Attr => (Bold_Character => True, others => False)); Move_Cursor (Line => 0, Column => 20); tmpa := To_Unbounded_String ("Display of "); if C1 then tmpa := tmpa & "C1"; else tmpa := tmpa & "GR"; end if; tmpa := tmpa & " Character Codes "; myPut (tmpb, first); Append (tmpa, To_String (tmpb)); Append (tmpa, " to "); myPut (tmpb, last); Append (tmpa, To_String (tmpb)); Add (Str => To_String (tmpa)); Switch_Character_Attribute (On => False, Attr => (Bold_Character => True, others => False)); Refresh; for code in first .. last loop declare row : Line_Position := Line_Position (4 + ((code - first) mod 16)); col : Column_Position := Column_Position (((code - first) / 16) * Integer (Columns) / 2); tmp3 : String (1 .. 3); tmpx : String (1 .. Integer (Columns / 4)); reply : Key_Code; begin Put (tmp3, code); myPut (tmpb, code, 16); tmpa := To_Unbounded_String (tmp3 & " (" & To_String (tmpb) & ')'); Ada.Strings.Fixed.Move (To_String (tmpa), tmpx, Justify => Ada.Strings.Right); Add (Line => row, Column => col, Str => tmpx & ' ' & ':' & ' '); if C1 then Set_NoDelay_Mode (Mode => True); end if; Add_With_Immediate_Echo (Ch => Code_To_Char (Key_Code (code))); -- TODO check this if C1 then reply := Getchar; while reply /= Key_None loop Add (Ch => Code_To_Char (reply)); Nap_Milli_Seconds (10); reply := Getchar; end loop; Set_NoDelay_Mode (Mode => False); end if; end; end loop; end show_upper_chars; function show_1_acs (N : Integer; name : String; code : Attributed_Character) return Integer is height : constant Integer := 16; row : Line_Position := Line_Position (4 + (N mod height)); col : Column_Position := Column_Position ((N / height) * Integer (Columns) / 2); tmpx : String (1 .. Integer (Columns) / 3); begin Ada.Strings.Fixed.Move (name, tmpx, Justify => Ada.Strings.Right, Drop => Ada.Strings.Left); Add (Line => row, Column => col, Str => tmpx & ' ' & ':' & ' '); -- we need more room than C because our identifiers are longer -- 22 chars actually Add (Ch => code); return N + 1; end show_1_acs; procedure show_acs_chars is n : Integer; begin Erase; Switch_Character_Attribute (Attr => (Bold_Character => True, others => False)); Add (Line => 0, Column => 20, Str => "Display of the ACS Character Set"); Switch_Character_Attribute (On => False, Attr => (Bold_Character => True, others => False)); Refresh; -- the following is useful to generate the below -- grep '^[ ]*ACS_' ../src/terminal_interface-curses.ads | -- awk '{print "n := show_1_acs(n, \""$1"\", ACS_Map("$1"));"}' n := show_1_acs (0, "ACS_Upper_Left_Corner", ACS_Map (ACS_Upper_Left_Corner)); n := show_1_acs (n, "ACS_Lower_Left_Corner", ACS_Map (ACS_Lower_Left_Corner)); n := show_1_acs (n, "ACS_Upper_Right_Corner", ACS_Map (ACS_Upper_Right_Corner)); n := show_1_acs (n, "ACS_Lower_Right_Corner", ACS_Map (ACS_Lower_Right_Corner)); n := show_1_acs (n, "ACS_Left_Tee", ACS_Map (ACS_Left_Tee)); n := show_1_acs (n, "ACS_Right_Tee", ACS_Map (ACS_Right_Tee)); n := show_1_acs (n, "ACS_Bottom_Tee", ACS_Map (ACS_Bottom_Tee)); n := show_1_acs (n, "ACS_Top_Tee", ACS_Map (ACS_Top_Tee)); n := show_1_acs (n, "ACS_Horizontal_Line", ACS_Map (ACS_Horizontal_Line)); n := show_1_acs (n, "ACS_Vertical_Line", ACS_Map (ACS_Vertical_Line)); n := show_1_acs (n, "ACS_Plus_Symbol", ACS_Map (ACS_Plus_Symbol)); n := show_1_acs (n, "ACS_Scan_Line_1", ACS_Map (ACS_Scan_Line_1)); n := show_1_acs (n, "ACS_Scan_Line_9", ACS_Map (ACS_Scan_Line_9)); n := show_1_acs (n, "ACS_Diamond", ACS_Map (ACS_Diamond)); n := show_1_acs (n, "ACS_Checker_Board", ACS_Map (ACS_Checker_Board)); n := show_1_acs (n, "ACS_Degree", ACS_Map (ACS_Degree)); n := show_1_acs (n, "ACS_Plus_Minus", ACS_Map (ACS_Plus_Minus)); n := show_1_acs (n, "ACS_Bullet", ACS_Map (ACS_Bullet)); n := show_1_acs (n, "ACS_Left_Arrow", ACS_Map (ACS_Left_Arrow)); n := show_1_acs (n, "ACS_Right_Arrow", ACS_Map (ACS_Right_Arrow)); n := show_1_acs (n, "ACS_Down_Arrow", ACS_Map (ACS_Down_Arrow)); n := show_1_acs (n, "ACS_Up_Arrow", ACS_Map (ACS_Up_Arrow)); n := show_1_acs (n, "ACS_Board_Of_Squares", ACS_Map (ACS_Board_Of_Squares)); n := show_1_acs (n, "ACS_Lantern", ACS_Map (ACS_Lantern)); n := show_1_acs (n, "ACS_Solid_Block", ACS_Map (ACS_Solid_Block)); n := show_1_acs (n, "ACS_Scan_Line_3", ACS_Map (ACS_Scan_Line_3)); n := show_1_acs (n, "ACS_Scan_Line_7", ACS_Map (ACS_Scan_Line_7)); n := show_1_acs (n, "ACS_Less_Or_Equal", ACS_Map (ACS_Less_Or_Equal)); n := show_1_acs (n, "ACS_Greater_Or_Equal", ACS_Map (ACS_Greater_Or_Equal)); n := show_1_acs (n, "ACS_PI", ACS_Map (ACS_PI)); n := show_1_acs (n, "ACS_Not_Equal", ACS_Map (ACS_Not_Equal)); n := show_1_acs (n, "ACS_Sterling", ACS_Map (ACS_Sterling)); end show_acs_chars; c1 : Key_Code; c : Character := 'a'; begin loop case c is when 'a' => show_acs_chars; when '0' | '1' | '2' | '3' => show_upper_chars (ctoi (c) * 32 + 128); when others => null; end case; Add (Line => Lines - 3, Column => 0, Str => "Note: ANSI terminals may not display C1 characters."); Add (Line => Lines - 2, Column => 0, Str => "Select: a=ACS, 0=C1, 1,2,3=GR characters, q=quit"); Refresh; c1 := Getchar; c := Code_To_Char (c1); exit when c = 'q' or c = 'x'; end loop; Pause; Erase; End_Windows; end ncurses2.acs_display;
reznikmm/matreshka
Ada
4,199
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-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$ ------------------------------------------------------------------------------ pragma Restrictions (No_Elaboration_Code); -- GNAT: enforce generation of preinitialized data section instead of -- generation of elaboration code. package Matreshka.Internals.Unicode.Ucd.Core_02A6 is pragma Preelaborate; Group_02A6 : aliased constant Core_Second_Stage := (16#D7# .. 16#FF# => -- 02A6D7 .. 02A6FF (Unassigned, Wide, Other, Other, Other, Ideographic, (others => False)), others => (Other_Letter, Wide, Other, Other, O_Letter, Ideographic, (Ideographic | Unified_Ideograph | Alphabetic | Grapheme_Base | ID_Continue | ID_Start | XID_Continue | XID_Start => True, others => False))); end Matreshka.Internals.Unicode.Ucd.Core_02A6;
reznikmm/matreshka
Ada
3,675
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Attributes.Style.Parent_Style_Name is type ODF_Style_Parent_Style_Name is new XML.DOM.Attributes.DOM_Attribute with private; private type ODF_Style_Parent_Style_Name is new XML.DOM.Attributes.DOM_Attribute with null record; end ODF.DOM.Attributes.Style.Parent_Style_Name;
tum-ei-rcs/StratoX
Ada
2,918
ads
----------------------------------------------------------------------------- -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S Y S T E M . L I B M _ D O U B L E . S Q R T -- -- -- -- S p e c -- -- -- -- Copyright (C) 2014-2015, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- 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 is the Ada Cert Math specific implementation of sqrt for IEEE 64 bit with System.Libm_Prefix; package System.Libm_Double.Squareroot is pragma Pure; package SLP renames System.Libm_Prefix; function Sqrt (X : Long_Float) return Long_Float with Export, Convention => C, External_Name => SLP.Prefix & "sqrt"; -- The Sqrt function returns the following special values: -- C99 special values: -- Sqrt (+-0) = +-0 -- Sqrt (INF) = INF -- Sqrt (X) = NaN, for X < 0.0 end System.Libm_Double.Squareroot;
Fabien-Chouteau/AGATE
Ada
2,526
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2017-2018, Fabien Chouteau -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ generic Priority : Task_Priority; Name : String; package AGATE.API.Static_Mutex is function ID return Mutex_ID; end AGATE.API.Static_Mutex;
charlie5/aIDE
Ada
133
ads
with AdaM.Environment; procedure AdaM.parse (File : in String; Into : in out AdaM.Environment.item);
reznikmm/matreshka
Ada
6,920
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.Outline_Style_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_Outline_Style_Element_Node is begin return Self : Text_Outline_Style_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_Outline_Style_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Enter_Text_Outline_Style (ODF.DOM.Text_Outline_Style_Elements.ODF_Text_Outline_Style_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Enter_Node (Visitor, Control); end if; end Enter_Node; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Text_Outline_Style_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Outline_Style_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Text_Outline_Style_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Leave_Text_Outline_Style (ODF.DOM.Text_Outline_Style_Elements.ODF_Text_Outline_Style_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Leave_Node (Visitor, Control); end if; end Leave_Node; ---------------- -- Visit_Node -- ---------------- overriding procedure Visit_Node (Self : not null access Text_Outline_Style_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then ODF.DOM.Iterators.Abstract_ODF_Iterator'Class (Iterator).Visit_Text_Outline_Style (Visitor, ODF.DOM.Text_Outline_Style_Elements.ODF_Text_Outline_Style_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Visit_Node (Iterator, Visitor, Control); end if; end Visit_Node; begin Matreshka.DOM_Documents.Register_Element (Matreshka.ODF_String_Constants.Text_URI, Matreshka.ODF_String_Constants.Outline_Style_Element, Text_Outline_Style_Element_Node'Tag); end Matreshka.ODF_Text.Outline_Style_Elements;
stcarrez/ada-util
Ada
13,766
adb
-- -- Copyright (c) 2007-2009 Tero Koskinen <[email protected]> -- -- Permission to use, copy, modify, and distribute this software for any -- purpose with or without fee is hereby granted, provided that the above -- copyright notice and this permission notice appear in all copies. -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- with Ada.Unchecked_Deallocation; package body Ahven.Results is use Ahven.Results.Result_List; use Ahven.Results.Result_Info_List; -- Bunch of setters and getters. -- The implementation is straightforward. procedure Set_Test_Name (Info : in out Result_Info; Name : Bounded_String) is begin Info.Test_Name := Name; end Set_Test_Name; procedure Set_Routine_Name (Info : in out Result_Info; Name : Bounded_String) is begin Info.Routine_Name := Name; end Set_Routine_Name; procedure Set_Message (Info : in out Result_Info; Message : Bounded_String) is begin Info.Message := Message; end Set_Message; procedure Set_Test_Name (Info : in out Result_Info; Name : String) is begin Set_Test_Name (Info, To_Bounded_String (Name)); end Set_Test_Name; procedure Set_Routine_Name (Info : in out Result_Info; Name : String) is begin Set_Routine_Name (Info, To_Bounded_String (Name)); end Set_Routine_Name; procedure Set_Message (Info : in out Result_Info; Message : String) is begin Set_Message (Info, To_Bounded_String (Message)); end Set_Message; procedure Set_Long_Message (Info : in out Result_Info; Message : Bounded_String) is begin Set_Long_Message (Info, To_String (Message)); end Set_Long_Message; procedure Set_Long_Message (Info : in out Result_Info; Message : Long_AStrings.Bounded_String) is begin Info.Long_Message := Message; end Set_Long_Message; procedure Set_Long_Message (Info : in out Result_Info; Message : String) is begin Set_Long_Message (Info, Long_AStrings.To_Bounded_String (Message)); end Set_Long_Message; procedure Set_Execution_Time (Info : in out Result_Info; Elapsed_Time : Duration) is begin Info.Execution_Time := Elapsed_Time; end Set_Execution_Time; procedure Set_Output_File (Info : in out Result_Info; Filename : Bounded_String) is begin Info.Output_File := Filename; end Set_Output_File; procedure Set_Output_File (Info : in out Result_Info; Filename : String) is begin Set_Output_File (Info, To_Bounded_String (Filename)); end Set_Output_File; function Get_Test_Name (Info : Result_Info) return String is begin return To_String (Info.Test_Name); end Get_Test_Name; function Get_Routine_Name (Info : Result_Info) return String is begin return To_String (Info.Routine_Name); end Get_Routine_Name; function Get_Message (Info : Result_Info) return String is begin return To_String (Info.Message); end Get_Message; function Get_Long_Message (Info : Result_Info) return String is begin return Long_AStrings.To_String (Info.Long_Message); end Get_Long_Message; function Get_Execution_Time (Info : Result_Info) return Duration is begin return Info.Execution_Time; end Get_Execution_Time; function Get_Output_File (Info : Result_Info) return Bounded_String is begin return Info.Output_File; end Get_Output_File; procedure Add_Child (Collection : in out Result_Collection; Child : Result_Collection_Access) is begin Append (Collection.Children, (Ptr => Child)); end Add_Child; procedure Add_Error (Collection : in out Result_Collection; Info : Result_Info) is begin Append (Collection.Errors, Info); end Add_Error; procedure Add_Skipped (Collection : in out Result_Collection; Info : Result_Info) is begin Append (Collection.Skips, Info); end Add_Skipped; procedure Add_Failure (Collection : in out Result_Collection; Info : Result_Info) is begin Append (Collection.Failures, Info); end Add_Failure; procedure Add_Pass (Collection : in out Result_Collection; Info : Result_Info) is begin Append (Collection.Passes, Info); end Add_Pass; -- When Result_Collection is released, it recursively releases -- its all children. procedure Release (Collection : in out Result_Collection) is procedure Free is new Ada.Unchecked_Deallocation (Object => Result_Collection, Name => Result_Collection_Access); Position : Result_List.Cursor := First (Collection.Children); Ptr : Result_Collection_Access := null; begin loop exit when not Is_Valid (Position); Ptr := Data (Position).Ptr; Release (Ptr.all); Free (Ptr); Position := Next (Position); end loop; Clear (Collection.Children); -- No need to call Free for these three since -- they are stored as plain objects instead of pointers. Clear (Collection.Errors); Clear (Collection.Failures); Clear (Collection.Passes); end Release; procedure Set_Name (Collection : in out Result_Collection; Name : Bounded_String) is begin Collection.Test_Name := Name; end Set_Name; procedure Set_Parent (Collection : in out Result_Collection; Parent : Result_Collection_Access) is begin Collection.Parent := Parent; end Set_Parent; function Test_Count (Collection : Result_Collection) return Natural is Count : Natural := Result_Info_List.Length (Collection.Errors) + Result_Info_List.Length (Collection.Failures) + Result_Info_List.Length (Collection.Skips) + Result_Info_List.Length (Collection.Passes); Position : Result_List.Cursor := First (Collection.Children); begin loop exit when not Is_Valid (Position); Count := Count + Test_Count (Data (Position).Ptr.all); Position := Next (Position); end loop; return Count; end Test_Count; function Direct_Test_Count (Collection : Result_Collection) return Natural is begin return Length (Collection.Errors) + Length (Collection.Failures) + Length (Collection.Passes); end Direct_Test_Count; function Pass_Count (Collection : Result_Collection) return Natural is Count : Natural := Length (Collection.Passes); Position : Result_List.Cursor := First (Collection.Children); begin loop exit when not Is_Valid (Position); Count := Count + Pass_Count (Data (Position).Ptr.all); Position := Next (Position); end loop; return Count; end Pass_Count; function Error_Count (Collection : Result_Collection) return Natural is Count : Natural := Length (Collection.Errors); Position : Result_List.Cursor := First (Collection.Children); begin loop exit when not Is_Valid (Position); Count := Count + Error_Count (Data (Position).Ptr.all); Position := Next (Position); end loop; return Count; end Error_Count; function Failure_Count (Collection : Result_Collection) return Natural is Count : Natural := Length (Collection.Failures); Position : Result_List.Cursor := First (Collection.Children); begin loop exit when not Is_Valid (Position); Count := Count + Failure_Count (Data (Position).Ptr.all); Position := Next (Position); end loop; return Count; end Failure_Count; function Skipped_Count (Collection : Result_Collection) return Natural is Count : Natural := Length (Collection.Skips); Position : Result_List.Cursor := First (Collection.Children); begin loop exit when not Is_Valid (Position); Count := Count + Skipped_Count (Data (Position).Ptr.all); Position := Next (Position); end loop; return Count; end Skipped_Count; function Get_Test_Name (Collection : Result_Collection) return Bounded_String is begin return Collection.Test_Name; end Get_Test_Name; function Get_Parent (Collection : Result_Collection) return Result_Collection_Access is begin return Collection.Parent; end Get_Parent; function Get_Execution_Time (Collection : Result_Collection) return Duration is Position : Result_Info_List.Cursor; Total_Time : Duration := 0.0; Child_Position : Result_List.Cursor; begin Position := First (Collection.Passes); Pass_Loop : loop exit Pass_Loop when not Is_Valid (Position); Total_Time := Total_Time + Get_Execution_Time (Data (Position)); Position := Next (Position); end loop Pass_Loop; Position := First (Collection.Failures); Failure_Loop : loop exit Failure_Loop when not Is_Valid (Position); Total_Time := Total_Time + Get_Execution_Time (Data (Position)); Position := Next (Position); end loop Failure_Loop; Position := First (Collection.Errors); Error_Loop : loop exit Error_Loop when not Is_Valid (Position); Total_Time := Total_Time + Get_Execution_Time (Data (Position)); Position := Next (Position); end loop Error_Loop; Child_Loop : loop exit Child_Loop when not Result_List.Is_Valid (Child_Position); Total_Time := Total_Time + Get_Execution_Time (Result_List.Data (Child_Position).Ptr.all); Child_Position := Result_List.Next (Child_Position); end loop Child_Loop; return Total_Time; end Get_Execution_Time; function First_Pass (Collection : Result_Collection) return Result_Info_Cursor is begin return First (Collection.Passes); end First_Pass; function First_Failure (Collection : Result_Collection) return Result_Info_Cursor is begin return First (Collection.Failures); end First_Failure; function First_Skipped (Collection : Result_Collection) return Result_Info_Cursor is begin return First (Collection.Skips); end First_Skipped; function First_Error (Collection : Result_Collection) return Result_Info_Cursor is begin return First (Collection.Errors); end First_Error; overriding function Next (Position : Result_Info_Cursor) return Result_Info_Cursor is begin return Result_Info_Cursor (Result_Info_List.Next (Result_Info_List.Cursor (Position))); end Next; overriding function Data (Position : Result_Info_Cursor) return Result_Info is begin return Result_Info_List.Data (Result_Info_List.Cursor (Position)); end Data; overriding function Is_Valid (Position : Result_Info_Cursor) return Boolean is begin return Result_Info_List.Is_Valid (Result_Info_List.Cursor (Position)); end Is_Valid; function First_Child (Collection : in Result_Collection) return Result_Collection_Cursor is begin return First (Collection.Children); end First_Child; overriding function Next (Position : Result_Collection_Cursor) return Result_Collection_Cursor is begin return Result_Collection_Cursor (Result_List.Next (Result_List.Cursor (Position))); end Next; overriding function Is_Valid (Position : Result_Collection_Cursor) return Boolean is begin return Result_List.Is_Valid (Result_List.Cursor (Position)); end Is_Valid; function Data (Position : Result_Collection_Cursor) return Result_Collection_Access is begin return Result_List.Data (Result_List.Cursor (Position)).Ptr; end Data; function Child_Depth (Collection : Result_Collection) return Natural is function Child_Depth_Impl (Coll : Result_Collection; Level : Natural) return Natural; function Child_Depth_Impl (Coll : Result_Collection; Level : Natural) return Natural is Max : Natural := 0; Current : Natural := 0; Position : Result_List.Cursor := Result_List.First (Coll.Children); begin loop exit when not Is_Valid (Position); Current := Child_Depth_Impl (Data (Position).Ptr.all, Level + 1); if Max < Current then Max := Current; end if; Position := Result_List.Next (Position); end loop; return Level + Max; end Child_Depth_Impl; begin return Child_Depth_Impl (Collection, 0); end Child_Depth; end Ahven.Results;
reznikmm/matreshka
Ada
3,555
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Tools 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$ ------------------------------------------------------------------------------ package Generator.Attributes is procedure Generate_Attributes_Mapping_Specification; procedure Generate_Attributes_Specification; procedure Generate_Attributes_Implementation; end Generator.Attributes;
sungyeon/drake
Ada
1,198
ads
pragma License (Unrestricted); -- implementation unit specialized for POSIX (Darwin, FreeBSD, or Linux) with C.sys.time; -- struct timeval with C.sys.types; -- time_t with C.time; -- struct timespec package System.Native_Time is pragma Preelaborate; -- representation type Nanosecond_Number is range -(2 ** (Duration'Size - 1)) .. 2 ** (Duration'Size - 1) - 1; for Nanosecond_Number'Size use Duration'Size; -- convert time span function To_timespec (D : C.sys.time.struct_timeval) return C.time.struct_timespec; function To_timespec (D : Duration) return C.time.struct_timespec; function To_Duration (D : C.time.struct_timespec) return Duration; function To_Duration (D : C.sys.types.time_t) return Duration; pragma Pure_Function (To_timespec); pragma Pure_Function (To_Duration); -- for delay procedure Simple_Delay_For (D : Duration); type Delay_For_Handler is access procedure (D : Duration); pragma Favor_Top_Level (Delay_For_Handler); -- equivalent to Timed_Delay (s-soflin.ads) Delay_For_Hook : not null Delay_For_Handler := Simple_Delay_For'Access; procedure Delay_For (D : Duration); end System.Native_Time;
reznikmm/increment
Ada
14,318
adb
-- Copyright (c) 2015-2017 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Incr.Nodes.Tokens; package body Incr.Nodes is To_Diff : constant array (Boolean) of Integer := (False => -1, True => 1); ------------------ -- Constructors -- ------------------ package body Constructors is ---------------- -- Initialize -- ---------------- procedure Initialize (Self : aliased in out Node_With_Parent'Class) is begin Versioned_Booleans.Initialize (Self.Exist, False); Versioned_Booleans.Initialize (Self.LC, False); Versioned_Booleans.Initialize (Self.LE, False); Versioned_Nodes.Initialize (Self.Parent, null); end Initialize; ------------------------ -- Initialize_Ancient -- ------------------------ procedure Initialize_Ancient (Self : aliased in out Node_With_Parent'Class; Parent : Node_Access) is begin Versioned_Booleans.Initialize (Self.Exist, True); Versioned_Booleans.Initialize (Self.LC, False); Versioned_Booleans.Initialize (Self.LE, False); Versioned_Nodes.Initialize (Self.Parent, Parent); end Initialize_Ancient; end Constructors; ------------ -- Exists -- ------------ overriding function Exists (Self : Node_With_Exist; Time : Version_Trees.Version) return Boolean is begin return Versioned_Booleans.Get (Self.Exist, Time); end Exists; ----------------- -- Child_Index -- ----------------- function Child_Index (Self : Node'Class; Child : Constant_Node_Access; Time : Version_Trees.Version) return Natural is begin for J in 1 .. Self.Arity loop if Constant_Node_Access (Self.Child (J, Time)) = Child then return J; end if; end loop; return 0; end Child_Index; -------------------- -- Discard_Parent -- -------------------- overriding procedure Discard_Parent (Self : in out Node_With_Parent) is Changed : Boolean; Ignore : Integer := 0; Now : constant Version_Trees.Version := Self.Document.History.Changing; begin Changed := Self.Local_Changes > 0 or Self.Nested_Changes > 0; if Changed then Self.Propagate_Nested_Changes (-1); end if; Versioned_Nodes.Discard (Self.Parent, Now, Ignore); if Changed then Self.Propagate_Nested_Changes (1); end if; end Discard_Parent; ----------------- -- First_Token -- ----------------- function First_Token (Self : aliased in out Node'Class; Time : Version_Trees.Version) return Tokens.Token_Access is Child : Node_Access; begin if Self.Arity > 0 then Child := Self.Child (1, Time); if Child.Is_Token then return Tokens.Token_Access (Child); else return Child.First_Token (Time); end if; elsif Self.Is_Token then return Tokens.Token'Class (Self)'Access; else return null; end if; end First_Token; -------------- -- Get_Flag -- -------------- overriding function Get_Flag (Self : Node_With_Exist; Flag : Transient_Flags) return Boolean is begin return Self.Flag (Flag); end Get_Flag; ---------------- -- Last_Token -- ---------------- function Last_Token (Self : aliased in out Node'Class; Time : Version_Trees.Version) return Tokens.Token_Access is Child : Node_Access; begin if Self.Arity > 0 then Child := Self.Child (Self.Arity, Time); if Child.Is_Token then return Tokens.Token_Access (Child); else return Child.Last_Token (Time); end if; elsif Self.Is_Token then return Tokens.Token'Class (Self)'Access; else return null; end if; end Last_Token; ------------------- -- Local_Changes -- ------------------- overriding function Local_Changes (Self : Node_With_Exist; From : Version_Trees.Version; To : Version_Trees.Version) return Boolean is use type Version_Trees.Version; Time : Version_Trees.Version := To; begin if Self.Document.History.Is_Changing (To) then -- Self.LC doesn't contain Local_Changes for Is_Changing version yet -- Take it from Self.Nested_Changes if Self.Local_Changes > 0 then return True; elsif Time = From then return False; end if; Time := Self.Document.History.Parent (Time); end if; while Time /= From loop if Versioned_Booleans.Get (Self.LC, Time) then return True; end if; Time := Self.Document.History.Parent (Time); end loop; return False; end Local_Changes; --------------------------- -- Mark_Deleted_Children -- --------------------------- procedure Mark_Deleted_Children (Self : in out Node'Class) is function Find_Root (Node : Node_Access) return Node_Access; -- Find top root accessible from the Node procedure Delete_Tree (Node : not null Node_Access; Parent : Node_Access; Index : Positive); -- Check Node if it's disjointed from ultra-root. -- Delete a subtree rooted from Node if so. -- If Parent /= null also set Parent.Child(Index) to null. Now : constant Version_Trees.Version := Self.Document.History.Changing; ----------------- -- In_The_Tree -- ----------------- function Find_Root (Node : Node_Access) return Node_Access is Child : not null Nodes.Node_Access := Node; begin loop declare Parent : constant Nodes.Node_Access := Child.Parent (Now); begin if Parent = null then return Child; else Child := Parent; end if; end; end loop; end Find_Root; ----------------- -- Delete_Tree -- ----------------- procedure Delete_Tree (Node : not null Node_Access; Parent : Node_Access; Index : Positive) is Changes : Integer := 0; begin if not Node.Exists (Now) then return; elsif Node.Parent (Now) /= Parent then declare Root : constant Node_Access := Find_Root (Node); begin if Root = Self.Document.Ultra_Root then return; end if; end; end if; for J in 1 .. Node.Arity loop declare Child : constant Node_Access := Node.Child (J, Now); begin Delete_Tree (Child, Node, J); end; end loop; Versioned_Booleans.Set (Node_With_Exist (Node.all).Exist, False, Now, Changes => Changes); if Parent /= null then Parent.Set_Child (Index, null); end if; end Delete_Tree; Prev : constant Version_Trees.Version := Self.Document.History.Parent (Now); Child : Node_Access; begin for J in 1 .. Self.Arity loop Child := Self.Child (J, Prev); if Child /= null and then Child.Exists (Now) and then Child.Parent (Now) /= Self'Unchecked_Access then Child := Find_Root (Child); if Child /= Self.Document.Ultra_Root then Delete_Tree (Child, null, J); end if; end if; end loop; end Mark_Deleted_Children; ------------------ -- Local_Errors -- ------------------ overriding function Local_Errors (Self : Node_With_Exist; Time : Version_Trees.Version) return Boolean is begin return Versioned_Booleans.Get (Self.LE, Time); end Local_Errors; ------------------ -- Next_Subtree -- ------------------ function Next_Subtree (Self : Node'Class; Time : Version_Trees.Version) return Node_Access is Node : Constant_Node_Access := Self'Unchecked_Access; Parent : Node_Access := Node.Parent (Time); Child : Node_Access; begin while Parent /= null loop declare J : constant Natural := Parent.Child_Index (Node, Time); begin if J in 1 .. Parent.Arity - 1 then for K in J + 1 .. Parent.Arity loop Child := Parent.Child (K, Time); if Child /= null then return Child; end if; end loop; end if; end; Node := Constant_Node_Access (Parent); Parent := Node.Parent (Time); end loop; return null; end Next_Subtree; --------------- -- On_Commit -- --------------- overriding procedure On_Commit (Self : in out Node_With_Exist; Parent : Node_Access) is Now : constant Version_Trees.Version := Self.Document.History.Changing; This : constant Node_Access := Self'Unchecked_Access; Child : Node_Access; Diff : Integer := 0; -- Ignore this diff begin pragma Assert (Node'Class (Self).Parent (Now) = Parent); Versioned_Booleans.Set (Self.LC, Self.Local_Changes > 0, Now, Diff); Self.Nested_Changes := 0; Self.Local_Changes := 0; Self.Flag := (others => False); for J in 1 .. This.Arity loop Child := This.Child (J, Now); if Child /= null then Child.On_Commit (Self'Unchecked_Access); end if; end loop; end On_Commit; ------------ -- Parent -- ------------ overriding function Parent (Self : Node_With_Parent; Time : Version_Trees.Version) return Node_Access is begin return Versioned_Nodes.Get (Self.Parent, Time); end Parent; ---------------------- -- Previous_Subtree -- ---------------------- function Previous_Subtree (Self : Node'Class; Time : Version_Trees.Version) return Node_Access is Node : Constant_Node_Access := Self'Unchecked_Access; Parent : Node_Access := Node.Parent (Time); Child : Node_Access; begin while Parent /= null loop declare J : constant Natural := Parent.Child_Index (Node, Time); begin if J in 2 .. Parent.Arity then for K in reverse 1 .. J - 1 loop Child := Parent.Child (K, Time); if Child /= null then return Child; end if; end loop; end if; end; Node := Constant_Node_Access (Parent); Parent := Node.Parent (Time); end loop; return null; end Previous_Subtree; ------------------------------ -- Propagate_Nested_Changes -- ------------------------------ procedure Propagate_Nested_Changes (Self : in out Node'Class; Diff : Integer) is Parent : constant Node_Access := Self.Parent (Self.Document.History.Changing); begin if Parent /= null then Parent.On_Nested_Changes (Diff); end if; end Propagate_Nested_Changes; ------------------------------ -- Propagate_Nested_Changes -- ------------------------------ overriding procedure On_Nested_Changes (Self : in out Node_With_Exist; Diff : Integer) is Before : Boolean; After : Boolean; begin Before := Self.Local_Changes > 0 or Self.Nested_Changes > 0; Self.Nested_Changes := Self.Nested_Changes + Diff; After := Self.Local_Changes > 0 or Self.Nested_Changes > 0; if Before /= After then Self.Propagate_Nested_Changes (To_Diff (After)); end if; end On_Nested_Changes; -------------- -- Set_Flag -- -------------- overriding procedure Set_Flag (Self : in out Node_With_Exist; Flag : Transient_Flags; Value : Boolean := True) is Before : Boolean; After : Boolean; begin Before := (Self.Flag and Local_Changes_Mask) /= No_Flags; Self.Flag (Flag) := Value; After := (Self.Flag and Local_Changes_Mask) /= No_Flags; if Before /= After then Self.Update_Local_Changes (To_Diff (After)); end if; end Set_Flag; ---------------------- -- Set_Local_Errors -- ---------------------- overriding procedure Set_Local_Errors (Self : in out Node_With_Exist; Value : Boolean := True) is Now : constant Version_Trees.Version := Self.Document.History.Changing; Diff : Integer := 0; begin Versioned_Booleans.Set (Self.LE, Value, Now, Diff); Self.Update_Local_Changes (Diff); end Set_Local_Errors; ---------------- -- Set_Parent -- ---------------- overriding procedure Set_Parent (Self : in out Node_With_Parent; Value : Node_Access) is Changed : Boolean; Ignore : Integer := 0; Now : constant Version_Trees.Version := Self.Document.History.Changing; begin Changed := Self.Local_Changes > 0 or Self.Nested_Changes > 0; if Changed then Self.Propagate_Nested_Changes (-1); end if; Versioned_Nodes.Set (Self.Parent, Value, Now, Ignore); if Changed then Self.Propagate_Nested_Changes (1); end if; end Set_Parent; -------------------------- -- Update_Local_Changes -- -------------------------- not overriding procedure Update_Local_Changes (Self : in out Node_With_Exist; Diff : Integer) is Before : Boolean; After : Boolean; begin Before := Self.Local_Changes > 0 or Self.Nested_Changes > 0; Self.Local_Changes := Self.Local_Changes + Diff; After := Self.Local_Changes > 0 or Self.Nested_Changes > 0; if Before /= After then Self.Propagate_Nested_Changes (To_Diff (After)); end if; end Update_Local_Changes; end Incr.Nodes;
AdaCore/libadalang
Ada
129
ads
with Types; package Pkg.Foo is procedure F; X : Types.Int; end Pkg.Foo; package Pkg.Bar is procedure G; end Pkg.Bar;
io7m/coreland-vector-ada
Ada
1,441
adb
with ada.text_io; with vector; with vector.sum; procedure sum_single is package io renames ada.text_io; package v16 is new vector (16); package v16_sum is new v16.sum; use type v16.scalar_f_t; base_a : constant v16.vector_f_t := (others => 1.0); want : constant v16.scalar_f_t := 16.0; testno : integer := 0; procedure sys_exit (e: integer); pragma import (c, sys_exit, "exit"); procedure fail (want, got : v16.scalar_f_t) is s_tnum : constant string := integer'image (testno); s_want : constant string := v16.scalar_f_t'image (want); s_got : constant string := v16.scalar_f_t'image (got); begin io.put_line ("[" & s_tnum & "] fail " & s_want & " /= " & s_got); sys_exit (1); end fail; procedure pass (want, got : v16.scalar_f_t) is s_tnum : constant string := integer'image (testno); s_want : constant string := v16.scalar_f_t'image (want); s_got : constant string := v16.scalar_f_t'image (got); begin io.put_line ("[" & s_tnum & "] " & s_want & " = " & s_got); end pass; procedure check (got : v16.scalar_f_t) is begin if (want /= got) then fail (want, got); else pass (want, got); end if; testno := testno + 1; end check; begin -- -- sum, in place -- declare tmp_a : constant v16.vector_f_t := base_a; got : constant v16.scalar_f_t := v16_sum.f (tmp_a); begin check (got); end; end sum_single;
reznikmm/matreshka
Ada
3,633
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Elements.Generic_Hash; function AMF.UML.Value_Specifications.Hash is new AMF.Elements.Generic_Hash (UML_Value_Specification, UML_Value_Specification_Access);
sparre/Command-Line-Parser-Generator
Ada
69
ads
package Good_Example is procedure No_Arguments; end Good_Example;
optikos/oasis
Ada
4,662
adb
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package body Program.Nodes.Defining_Expanded_Names is function Create (Prefix : not null Program.Elements.Expressions.Expression_Access; Dot_Token : not null Program.Lexical_Elements.Lexical_Element_Access; Selector : not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access) return Defining_Expanded_Name is begin return Result : Defining_Expanded_Name := (Prefix => Prefix, Dot_Token => Dot_Token, Selector => Selector, Enclosing_Element => null) do Initialize (Result); end return; end Create; function Create (Prefix : not null Program.Elements.Expressions .Expression_Access; Selector : not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False) return Implicit_Defining_Expanded_Name is begin return Result : Implicit_Defining_Expanded_Name := (Prefix => Prefix, Selector => Selector, 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 Prefix (Self : Base_Defining_Expanded_Name) return not null Program.Elements.Expressions.Expression_Access is begin return Self.Prefix; end Prefix; overriding function Selector (Self : Base_Defining_Expanded_Name) return not null Program.Elements.Defining_Identifiers .Defining_Identifier_Access is begin return Self.Selector; end Selector; overriding function Dot_Token (Self : Defining_Expanded_Name) return not null Program.Lexical_Elements.Lexical_Element_Access is begin return Self.Dot_Token; end Dot_Token; overriding function Image (Self : Defining_Expanded_Name) return Text is begin return Self.Dot_Token.Image; end Image; overriding function Is_Part_Of_Implicit (Self : Implicit_Defining_Expanded_Name) return Boolean is begin return Self.Is_Part_Of_Implicit; end Is_Part_Of_Implicit; overriding function Is_Part_Of_Inherited (Self : Implicit_Defining_Expanded_Name) return Boolean is begin return Self.Is_Part_Of_Inherited; end Is_Part_Of_Inherited; overriding function Is_Part_Of_Instance (Self : Implicit_Defining_Expanded_Name) return Boolean is begin return Self.Is_Part_Of_Instance; end Is_Part_Of_Instance; overriding function Image (Self : Implicit_Defining_Expanded_Name) return Text is pragma Unreferenced (Self); begin return ""; end Image; procedure Initialize (Self : aliased in out Base_Defining_Expanded_Name'Class) is begin Set_Enclosing_Element (Self.Prefix, Self'Unchecked_Access); Set_Enclosing_Element (Self.Selector, Self'Unchecked_Access); null; end Initialize; overriding function Is_Defining_Expanded_Name_Element (Self : Base_Defining_Expanded_Name) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Defining_Expanded_Name_Element; overriding function Is_Defining_Name_Element (Self : Base_Defining_Expanded_Name) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Defining_Name_Element; overriding procedure Visit (Self : not null access Base_Defining_Expanded_Name; Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is begin Visitor.Defining_Expanded_Name (Self); end Visit; overriding function To_Defining_Expanded_Name_Text (Self : aliased in out Defining_Expanded_Name) return Program.Elements.Defining_Expanded_Names .Defining_Expanded_Name_Text_Access is begin return Self'Unchecked_Access; end To_Defining_Expanded_Name_Text; overriding function To_Defining_Expanded_Name_Text (Self : aliased in out Implicit_Defining_Expanded_Name) return Program.Elements.Defining_Expanded_Names .Defining_Expanded_Name_Text_Access is pragma Unreferenced (Self); begin return null; end To_Defining_Expanded_Name_Text; end Program.Nodes.Defining_Expanded_Names;
gitter-badger/libAnne
Ada
7,798
adb
with Ada.Unchecked_Deallocation; package body Containers.Lists.Doubly_Linked is ---------- -- Node -- ---------- procedure Deallocate is new Ada.Unchecked_Deallocation(Node, Node_Access); function Value(Self : Node) return Value_Type is (Self.Value); function Value(Self : Node_Access) return Value_Type is (Self.all.Value); function Afore(Self : Node_Access) return Node_Access is (Self.Fore); function Ahind(Self : Node_Access) return Node_Access is (Self.Hind); ---------- -- List -- ---------- function Is_Empty(Self : in List) return Boolean is (Self.Foremost = null and Self.Hindmost = null); function Foremost(Self : in List) return Node_Access is (Self.Foremost); function Foremost(Self : in List) return Value_Type is (Self.Foremost.Value); function Hindmost(Self : in List) return Node_Access is (Self.Hindmost); function Hindmost(Self : in List) return Value_Type is (Self.Hindmost.Value); procedure Forebind(Self : in out List; Value : in Value_Type) is begin Self.Foremost := new Node'(Value, null, Self.Foremost); if Self.Hindmost = null then --Hindmost isn't set, so this is the first node in the list, set it as both Self.Hindmost := Self.Foremost; else Self.Foremost.Hind.Fore := Self.Foremost; end if; Self.Length := Self.Length + 1; end Forebind; procedure Hindbind(Self : in out List; Value : in Value_Type) is begin Self.Hindmost := new Node'(Value, Self.Hindmost, null); if Self.Foremost = null then --Foremost isn't set, so this is the first node in the list, set it as both Self.Foremost := Self.Hindmost; else Self.Hindmost.Fore.Hind := Self.Hindmost; end if; Self.Length := Self.Length + 1; end Hindbind; procedure Forefree(Self : in out List) is N : Node_Access := Self.Foremost; begin Self.Foremost := Self.Foremost.Hind; Self.Length := Self.Length - 1; Deallocate(N); end Forefree; procedure Hindfree(Self : in out List) is N : Node_Access := Self.Hindmost; begin Self.Hindmost := Self.Hindmost.Fore; Self.Hindmost.Hind := null; Self.Length := Self.Length - 1; Deallocate(N); end Hindfree; procedure Free(Self : in out List; Index : in Positive) is N : Node_Access := Self.Foremost; I : Positive := 1; begin if Index = 1 then Self.Forefree; return; end if; if Index = Self.Length then Self.Hindfree; return; end if; while I < Index loop N := N.Hind; I := I + 1; end loop; N.Fore.Hind := N.Hind; N.Hind.Fore := N.Fore; Self.Length := Self.Length - 1; Deallocate(N); end Free; procedure Apply(Self : in out List; Call : access Procedure(Value : in out Value_Type)) is N : Node_Access := Self.Foremost; begin while N /= null loop Call(N.Value); N := N.Hind; end loop; end Apply; procedure Apply(Self : in out List; Call : access Function(Value : Value_Type) return Value_Type) is N : Node_Access := Self.Foremost; begin while N /= null loop N.Value := Call(N.Value); N := N.Hind; end loop; end Apply; function Contains(Self : in List; Value : in Value_Type) return Boolean is N : Node_Access := Self.Foremost; begin while N /= null loop if N.Value = Value then return True; end if; N := N.Hind; end loop; return False; end Contains; function Former(Self : in List; Amount : in Positive := 1) return List is Result : List; begin for I in 1..Amount loop Result.Hindbind(Self(I)); end loop; return Result; end Former; function Hinder(Self : in List; Amount : in Positive := 1) return List is Result : List; begin for I in Self.Length-Amount+1 .. Self.Length loop Result.Hindbind(Self(I)); end loop; return Result; end Hinder; function Where(Self : in List; Query : access function(Self : in Node) return Boolean) return List is Result : List; N : Node_Access := Self.Foremost; begin while N /= null loop if Query(N.all) then Result.Hindbind(N.Value); end if; N := N.Hind; end loop; return Result; end Where; function Where(Self : in List; Query : access function(Self : in Value_Type) return Boolean) return List is Result : List; N : Node_Access := Self.Foremost; begin while N /= null loop if Query(N.Value) then Result.Hindbind(N.Value); end if; N := N.Hind; end loop; return Result; end Where; function Flip(Self : in List) return List is Result : List; N : Node_Access := Self.Foremost; begin while N /= null loop Result.Forebind(N.Value); N := N.Hind; end loop; return Result; end Flip; procedure Clear(Self : in out List) is N : Node_Access; begin loop exit when Self.Foremost = null; N := Self.Foremost; Self.Foremost := Self.Foremost.Hind; Deallocate(N); end loop; Self.Length := 0; end Clear; function Copy(Self : List) return List is Result : List; N : Node_Access := Self.Foremost; begin while N /= null loop Result.Hindbind(N.Value); N := N.Hind; end loop; return Result; end Copy; function Length(Self : List) return Natural is (Self.Length); function Size(Self : List) return Natural is (Self'Size + (Self.Length * Node'Size)); ----------- -- Array -- ----------- function Each(Self : in List) return Value_Array is Result : Value_Array(1..Self.Length); N : Node_Access := Self.Foremost; I : Integer := 1; begin while N /= null loop Result(I) := N.Value; N := N.Hind; I := I + 1; end loop; return Result; end Each; procedure Forebind(Self : in out List; Values : in Value_Array) is begin for Value of reverse Values loop Self.Forebind(Value); end loop; end Forebind; procedure Hindbind(Self : in out List; Values : in Value_Array) is begin for Value of Values loop Self.Hindbind(Value); end loop; end Hindbind; ------------ -- Cursor -- ------------ function Has_Element(Self : Cursor) return Boolean is (Self.Node /= null); -------------- -- Iterator -- -------------- function First(Self : Iterator) return Cursor is begin return Cursor'(List => Self.List, Node => Self.List.Foremost); end First; function Next(Self : Iterator; Position : Cursor) return Cursor is begin return Cursor'(List => Self.List, Node => Position.Node.Hind); end Next; function Last(Self : Iterator) return Cursor is begin return Cursor'(List => Self.List, Node => Self.List.Hindmost); end Last; function Previous(Self : Iterator; Position : Cursor) return Cursor is begin return Cursor'(List => Self.List, Node => Position.Node.Fore); end Previous; ------------- -- Private -- ------------- function Constant_Indexer (Self : in List; Index : in Positive) return Constant_Reference is I : Integer := 1; N : Node_Access := Self.Foremost; begin while I /= Index loop N := N.Hind; I := I + 1; end loop; return Constant_Reference'(Value => new Value_Type'(N.Value)); end Constant_Indexer; function Constant_Indexer(Self : in List; Index : in Cursor) return Constant_Reference is pragma Unreferenced(Self); begin return Constant_Reference'(Value => new Value_Type'(Index.Node.Value)); end Constant_Indexer; function Variable_Indexer (Self : in List; Index : in Positive) return Variable_Reference is I : Integer := 1; N : Node_Access := Self.Foremost; begin while I /= Index loop N := N.Hind; I := I + 1; end loop; return Variable_Reference'(Value => new Value_Type'(N.Value)); end Variable_Indexer; function Variable_Indexer(Self : in List; Index : in Cursor) return Variable_Reference is begin return Variable_Reference'(Value => new Value_Type'(Index.Node.Value)); end Variable_Indexer; function Iterate(Self : in List) return Iterator_Interfaces.Reversible_Iterator'Class is begin return Iterator'(List => Self'Unrestricted_Access); end Iterate; end Containers.Lists.Doubly_Linked;
reznikmm/matreshka
Ada
5,491
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Internals.Utp_Elements; with AMF.UML.Behaviors; with AMF.Utp.Test_Cases.Collections; with AMF.Utp.Test_Suites; with AMF.Visitors; package AMF.Internals.Utp_Test_Suites is type Utp_Test_Suite_Proxy is limited new AMF.Internals.Utp_Elements.Utp_Element_Proxy and AMF.Utp.Test_Suites.Utp_Test_Suite with null record; overriding function Get_Base_Behavior (Self : not null access constant Utp_Test_Suite_Proxy) return AMF.UML.Behaviors.UML_Behavior_Access; -- Getter of TestSuite::base_Behavior. -- overriding procedure Set_Base_Behavior (Self : not null access Utp_Test_Suite_Proxy; To : AMF.UML.Behaviors.UML_Behavior_Access); -- Setter of TestSuite::base_Behavior. -- overriding function Get_Test_Case (Self : not null access constant Utp_Test_Suite_Proxy) return AMF.Utp.Test_Cases.Collections.Set_Of_Utp_Test_Case; -- Getter of TestSuite::testCase. -- overriding function Get_Priority (Self : not null access constant Utp_Test_Suite_Proxy) return AMF.Optional_String; -- Getter of TestSuite::priority. -- overriding procedure Set_Priority (Self : not null access Utp_Test_Suite_Proxy; To : AMF.Optional_String); -- Setter of TestSuite::priority. -- overriding procedure Enter_Element (Self : not null access constant Utp_Test_Suite_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); overriding procedure Leave_Element (Self : not null access constant Utp_Test_Suite_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); overriding procedure Visit_Element (Self : not null access constant Utp_Test_Suite_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); end AMF.Internals.Utp_Test_Suites;
reznikmm/matreshka
Ada
5,126
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with League.Holders; package AMF.UMLDI.Holders is pragma Preelaborate; -- UMLAssociationOrConnectorOrLinkShapeKind [0..1] function Element (Holder : League.Holders.Holder) return AMF.UMLDI.Optional_UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Kind; function To_Holder (Element : AMF.UMLDI.Optional_UMLDI_UML_Association_Or_Connector_Or_Link_Shape_Kind) return League.Holders.Holder; -- UMLInheritedStateBorderKind [0..1] function Element (Holder : League.Holders.Holder) return AMF.UMLDI.Optional_UMLDI_UML_Inherited_State_Border_Kind; function To_Holder (Element : AMF.UMLDI.Optional_UMLDI_UML_Inherited_State_Border_Kind) return League.Holders.Holder; -- UMLInteractionDiagramKind [0..1] function Element (Holder : League.Holders.Holder) return AMF.UMLDI.Optional_UMLDI_UML_Interaction_Diagram_Kind; function To_Holder (Element : AMF.UMLDI.Optional_UMLDI_UML_Interaction_Diagram_Kind) return League.Holders.Holder; -- UMLInteractionTableLabelKind [0..1] function Element (Holder : League.Holders.Holder) return AMF.UMLDI.Optional_UMLDI_UML_Interaction_Table_Label_Kind; function To_Holder (Element : AMF.UMLDI.Optional_UMLDI_UML_Interaction_Table_Label_Kind) return League.Holders.Holder; -- UMLNavigabilityNotationKind [0..1] function Element (Holder : League.Holders.Holder) return AMF.UMLDI.Optional_UMLDI_UML_Navigability_Notation_Kind; function To_Holder (Element : AMF.UMLDI.Optional_UMLDI_UML_Navigability_Notation_Kind) return League.Holders.Holder; end AMF.UMLDI.Holders;
Fabien-Chouteau/Ada_Drivers_Library
Ada
5,412
ads
-- This spec has been automatically generated from cm7.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; -- 24Bit System Tick Timer for use in RTOS package Cortex_M_SVD.SysTick is pragma Preelaborate; --------------- -- Registers -- --------------- -- Enable SysTick Timer type CSR_ENABLE_Field is ( -- counter disabled Disable, -- counter enabled Enable) with Size => 1; for CSR_ENABLE_Field use (Disable => 0, Enable => 1); -- Generate Tick Interrupt type CSR_TICKINT_Field is ( -- Counting down to zero does not assert the SysTick exception request Enable, -- Counting down to zero asserts the SysTick exception request Disable) with Size => 1; for CSR_TICKINT_Field use (Enable => 0, Disable => 1); -- Source to count from type CSR_CLKSOURCE_Field is ( -- External Clock External_Clk, -- CPU Clock Cpu_Clk) with Size => 1; for CSR_CLKSOURCE_Field use (External_Clk => 0, Cpu_Clk => 1); -- SysTick Control and Status Register type SYST_CSR_Register is record -- Enable SysTick Timer ENABLE : CSR_ENABLE_Field := Cortex_M_SVD.SysTick.Disable; -- Generate Tick Interrupt TICKINT : CSR_TICKINT_Field := Cortex_M_SVD.SysTick.Enable; -- Source to count from CLKSOURCE : CSR_CLKSOURCE_Field := Cortex_M_SVD.SysTick.Cpu_Clk; -- unspecified Reserved_3_15 : HAL.UInt13 := 16#0#; -- SysTick counted to zero COUNTFLAG : 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 SYST_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 SYST_RVR_RELOAD_Field is HAL.UInt24; -- SysTick Reload Value Register type SYST_RVR_Register is record -- Value to auto reload SysTick after reaching zero RELOAD : SYST_RVR_RELOAD_Field := 16#0#; -- unspecified Reserved_24_31 : HAL.UInt8 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SYST_RVR_Register use record RELOAD at 0 range 0 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; subtype SYST_CVR_CURRENT_Field is HAL.UInt24; -- SysTick Current Value Register type SYST_CVR_Register is record -- Current value CURRENT : SYST_CVR_CURRENT_Field := 16#0#; -- unspecified Reserved_24_31 : HAL.UInt8 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SYST_CVR_Register use record CURRENT at 0 range 0 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; subtype SYST_CALIB_TENMS_Field is HAL.UInt24; -- Clock Skew type CALIB_SKEW_Field is ( -- 10ms calibration value is exact Exact, -- 10ms calibration value is inexact, because of the clock frequency Inexact) with Size => 1; for CALIB_SKEW_Field use (Exact => 0, Inexact => 1); -- No Ref type CALIB_NOREF_Field is ( -- Ref Clk available Ref_Clk_Available, -- Ref Clk not available Ref_Clk_Unavailable) with Size => 1; for CALIB_NOREF_Field use (Ref_Clk_Available => 0, Ref_Clk_Unavailable => 1); -- SysTick Calibration Value Register type SYST_CALIB_Register is record -- Read-only. Reload value to use for 10ms timing TENMS : SYST_CALIB_TENMS_Field; -- unspecified Reserved_24_29 : HAL.UInt6; -- Read-only. Clock Skew SKEW : CALIB_SKEW_Field; -- Read-only. No Ref NOREF : CALIB_NOREF_Field; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SYST_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 -- ----------------- -- 24Bit System Tick Timer for use in RTOS type SysTick_Peripheral is record -- SysTick Control and Status Register CSR : aliased SYST_CSR_Register; -- SysTick Reload Value Register RVR : aliased SYST_RVR_Register; -- SysTick Current Value Register CVR : aliased SYST_CVR_Register; -- SysTick Calibration Value Register CALIB : aliased SYST_CALIB_Register; end record with Volatile; for SysTick_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; -- 24Bit System Tick Timer for use in RTOS SysTick_Periph : aliased SysTick_Peripheral with Import, Address => SysTick_Base; end Cortex_M_SVD.SysTick;
Tim-Tom/project-euler
Ada
910
ads
package Problem_58 is -- Starting with 1 and spiralling anticlockwise in the following way, a -- square spiral with side length 7 is formed. -- -- 37 36 35 34 33 32 31 -- 38 17 16 15 14 13 30 -- 39 18 5 4 3 12 29 -- 40 19 6 1 2 11 28 -- 41 20 7 8 9 10 27 -- 42 21 22 23 24 25 26 -- 43 44 45 46 47 48 49 -- -- It is interesting to note that the odd squares lie along the bottom right -- diagonal, but what is more interesting is that 8 out of the 13 numbers -- lying along both diagonals are prime; that is, a ratio of 8/13 ~= 62%. -- -- If one complete new layer is wrapped around the spiral above, a square -- spiral with side length 9 will be formed. If this process is continued, -- what is the side length of the square spiral for which the ratio of primes -- along both diagonals first falls below 10%? procedure Solve; end Problem_58;
ytomino/vampire
Ada
1,050
adb
-- The Village of Vampire by YT, このソースコードはNYSLです with Ada.Exceptions; with Ada.Streams.Stream_IO; with Serialization.YAML; with YAML.Streams; with Vampire.Villages.Village_IO; procedure Vampire.Villages.Load ( Name : in String; Village : in out Village_Type; Info_Only : in Boolean := False) is File : Ada.Streams.Stream_IO.File_Type; begin Ada.Streams.Stream_IO.Open ( File, Ada.Streams.Stream_IO.In_File, Name => Name); declare Parser : aliased YAML.Parser := YAML.Streams.Create (Ada.Streams.Stream_IO.Stream (File)); begin Village_IO.IO ( Serialization.YAML.Reading (Parser'Access, Village_IO.Yaml_Type).Serializer, Village, Info_Only); YAML.Finish (Parser); end; Ada.Streams.Stream_IO.Close (File); exception when E : others => declare Message : constant String := Name & ": " & Ada.Exceptions.Exception_Message (E); begin Ada.Debug.Put (Message); Ada.Exceptions.Raise_Exception ( Ada.Exceptions.Exception_Identity (E), Message); end; end Vampire.Villages.Load;
AdaCore/libadalang
Ada
108
ads
package Foo is type U is private; private type U is record F : Integer; end record; end Foo;
reznikmm/matreshka
Ada
6,888
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_Presentation.Dim_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Presentation_Dim_Element_Node is begin return Self : Presentation_Dim_Element_Node do Matreshka.ODF_Presentation.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Presentation_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Presentation_Dim_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_Presentation_Dim (ODF.DOM.Presentation_Dim_Elements.ODF_Presentation_Dim_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 Presentation_Dim_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Dim_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Presentation_Dim_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_Presentation_Dim (ODF.DOM.Presentation_Dim_Elements.ODF_Presentation_Dim_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 Presentation_Dim_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_Presentation_Dim (Visitor, ODF.DOM.Presentation_Dim_Elements.ODF_Presentation_Dim_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.Presentation_URI, Matreshka.ODF_String_Constants.Dim_Element, Presentation_Dim_Element_Node'Tag); end Matreshka.ODF_Presentation.Dim_Elements;
zhmu/ananas
Ada
2,329
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . W I D E _ W I D E _ T E X T _ I O . M O D U L A R _ I O -- -- -- -- S p e c -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- -- copy and modify this specification, provided that if you redistribute a -- -- modified version, any changes that you have made are clearly indicated. -- -- -- ------------------------------------------------------------------------------ -- In Ada 95, the package Ada.Wide_Wide_Text_IO.Modular_IO is a subpackage -- of Wide_Wide_Text_IO. In GNAT we make it a child package to avoid loading -- the necessary code if Modular_IO is not instantiated. See the routine -- Rtsfind.Check_Text_IO_Special_Unit for a description of how we patch up -- the difference in semantics so that it is invisible to the Ada programmer. private generic type Num is mod <>; package Ada.Wide_Wide_Text_IO.Modular_IO is Default_Width : Field := Num'Width; Default_Base : Number_Base := 10; procedure Get (File : File_Type; Item : out Num; Width : Field := 0); procedure Get (Item : out Num; Width : Field := 0); procedure Put (File : File_Type; Item : Num; Width : Field := Default_Width; Base : Number_Base := Default_Base); procedure Put (Item : Num; Width : Field := Default_Width; Base : Number_Base := Default_Base); procedure Get (From : Wide_Wide_String; Item : out Num; Last : out Positive); procedure Put (To : out Wide_Wide_String; Item : Num; Base : Number_Base := Default_Base); end Ada.Wide_Wide_Text_IO.Modular_IO;
landgraf/nanomsg-ada
Ada
3,802
adb
-- The MIT License (MIT) -- Copyright (c) 2015 Pavel Zhukov <[email protected]> -- Permission is hereby granted, free of charge, to any person obtaining a copy -- of this software and associated documentation files (the "Software"), to deal -- in the Software without restriction, including without limitation the rights -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -- copies of the Software, and to permit persons to whom the Software is -- furnished to do so, subject to the following conditions: -- The above copyright notice and this permission notice shall be included in all -- copies or substantial portions of the Software. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -- SOFTWARE. with Nanomsg.Domains; with Nanomsg.Pair; with Aunit.Assertions; with Nanomsg.Messages; package body Nanomsg.Test_Pair is procedure Run_Test (T : in out TC) is use Aunit.Assertions; Address : constant String := "tcp://127.0.0.1:5555"; Request : constant String := "Calculate : 2 + 2"; Reply : constant String := "Answer: 4"; Req_Send : Nanomsg.Messages.Message_T; Req_Rcv : Nanomsg.Messages.Message_T := Nanomsg.Messages.Empty_Message; Rep_Send : Nanomsg.Messages.Message_T; Rep_Rcv : Nanomsg.Messages.Message_T := Nanomsg.Messages.Empty_Message; begin Nanomsg.Messages.From_String (Req_Send, Request); Nanomsg.Messages.From_String (Rep_Send, Reply); Nanomsg.Socket.Init (T.Socket1, Nanomsg.Domains.Af_Sp, Nanomsg.Pair.Nn_PAIR); Nanomsg.Socket.Init (T.Socket2, Nanomsg.Domains.Af_Sp, Nanomsg.Pair.Nn_PAIR); Assert (Condition => not T.Socket1.Is_Null, Message => "Failed to initialize socket1"); Assert (Condition => not T.Socket2.Is_Null, Message => "Failed to initialize socket2"); Assert (Condition => T.Socket1.Get_Fd /= T.Socket2.Get_Fd, Message => "Descriptors collision!"); Nanomsg.Socket.Bind (T.Socket2, "tcp://*:5555"); Nanomsg.Socket.Connect (T.Socket1, Address); Assert (Condition => T.Socket1.Is_Ready (To_Send => True, To_Receive => False), Message => "Socket 1 is not ready"); Assert (Condition => T.Socket2.Is_Ready (To_Send => True, To_Receive => False), Message => "Socket 2 is not ready"); -- Pair is bi-directional communication -- Sendting few messages for I in 1 .. 10 loop T.Socket1.Send (Req_Send); T.Socket2.Receive (Req_Rcv); Assert (Condition => Req_Rcv.Text = Request, Message => "Request damaged in tranmission"); end loop; -- Sending messages in reverse direction for I in 1 .. 10 loop T.Socket2.Send (Rep_Send); T.Socket1.Receive (Rep_Rcv); Assert (Condition => Rep_Rcv.Text = Reply, Message => "Reply damaged in tranmission"); end loop; end Run_Test; function Name (T : TC) return Message_String is begin return Aunit.Format ("Test case name : Pair pattern test"); end Name; procedure Tear_Down (T : in out Tc) is begin if T.Socket1.Get_Fd >= 0 then T.Socket1.Close; end if; if T.Socket2.Get_Fd >= 0 then T.Socket2.Close; end if; end Tear_Down; end Nanomsg.Test_Pair;
BrickBot/Bound-T-H8-300
Ada
53,017
adb
-- Flow.Computation (body) -- -- A component of the Bound-T Worst-Case Execution Time Tool. -- ------------------------------------------------------------------------------- -- Copyright (c) 1999 .. 2015 Tidorum Ltd -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- 1. Redistributions of source code must retain the above copyright notice, this -- list of conditions and the following disclaimer. -- 2. Redistributions in binary form must reproduce the above copyright notice, -- this list of conditions and the following disclaimer in the documentation -- and/or other materials provided with the distribution. -- -- This software is provided by the copyright holders and contributors "as is" and -- any express or implied warranties, including, but not limited to, the implied -- warranties of merchantability and fitness for a particular purpose are -- disclaimed. In no event shall the copyright owner or contributors be liable for -- any direct, indirect, incidental, special, exemplary, or consequential damages -- (including, but not limited to, procurement of substitute goods or services; -- loss of use, data, or profits; or business interruption) however caused and -- on any theory of liability, whether in contract, strict liability, or tort -- (including negligence or otherwise) arising in any way out of the use of this -- software, even if advised of the possibility of such damage. -- -- Other modules (files) of this software composition should contain their -- own copyright statements, which may have different copyright and usage -- conditions. The above conditions apply to this file. ------------------------------------------------------------------------------- -- -- $Revision: 1.24 $ -- $Date: 2015/10/24 20:05:47 $ -- -- $Log: flow-computation.adb,v $ -- Revision 1.24 2015/10/24 20:05:47 niklas -- Moved to free licence. -- -- Revision 1.23 2011-09-06 17:50:00 niklas -- Added Is_Final (Node_T, ..) for help with ALF export. -- -- Revision 1.22 2009-10-07 19:26:10 niklas -- BT-CH-0183: Cell-sets are a tagged-type class. -- -- Revision 1.21 2009-05-15 12:16:47 niklas -- BT-CH-0173: Handling cells used by Range_Post constraints. -- -- Revision 1.20 2008/04/22 12:40:41 niklas -- Added Mark_Infeasible for a node edge. -- -- Revision 1.19 2008/02/18 12:58:27 niklas -- Added functions Final_Nodes and Successors (return Node_List_T) -- for use in SPARC RW-trap analysis. -- -- Revision 1.18 2007/12/17 13:54:35 niklas -- BT-CH-0098: Assertions on stack usage and final stack height, etc. -- -- Revision 1.17 2007/10/28 09:32:45 niklas -- BT-CH-0092: Arithmetic analysis of dynamic data refs is optional. -- -- Revision 1.16 2007/10/26 12:44:34 niklas -- BT-CH-0091: Reanalyse a boundable edge only if its domain grows. -- -- Revision 1.15 2007/10/02 20:49:22 niklas -- Added Unresolved_Dynamic_Edges_From (Step, Model). -- -- Revision 1.14 2007/08/06 09:29:57 niklas -- Added Model_T.Index to identify model objects. Added Next_Index and -- Set_Index to keep count and extended Refer_To_Primitive_Model and -- Ensure_Single_Ref to Set the Index of the new model object. -- Implemented Opt.Trace_Models by extending Discard, Refer, Changed, -- Mark_Clean, Ensure_Single_Ref and Set_Effect to trace their actions. -- Added functions Spick and Ident_Ref to show model identity and state. -- -- Revision 1.13 2007/03/29 15:18:01 niklas -- BT-CH-0056. -- -- Revision 1.12 2007/01/25 21:25:14 niklas -- BT-CH-0043. -- -- Revision 1.11 2007/01/13 13:51:03 niklas -- BT-CH-0041. -- -- Revision 1.10 2006/11/26 22:07:25 niklas -- BT-CH-0039. -- -- Revision 1.9 2006/10/24 08:44:30 niklas -- BT-CH-0028. -- -- Revision 1.8 2005/09/20 09:50:44 niklas -- Added Mark_Infeasible (Loop). -- -- Revision 1.7 2005/09/12 19:02:58 niklas -- BT-CH-0008. -- -- Revision 1.6 2005/09/03 11:50:28 niklas -- BT-CH-0006. -- -- Revision 1.5 2005/06/29 19:35:55 niklas -- Added Exit_Edges. -- -- Revision 1.4 2005/05/09 15:28:16 niklas -- Added the functions Feasible (Steps), Number_Into (Step), Final_Steps, -- Successors (Step) and Total_Defining_Assignments, all to support -- value-origin analysis. -- -- Revision 1.3 2005/03/20 15:12:06 niklas -- Corrected Steps_With_Dynamic_Effect to return only feasible steps. -- -- Revision 1.2 2005/02/23 09:05:17 niklas -- BT-CH-0005. -- -- Revision 1.1 2005/02/16 21:11:43 niklas -- BT-CH-0002. -- with Ada.Unchecked_Deallocation; with Faults; with Flow.Calls; with Flow.Computation.Opt; with Flow.Pruning; with Flow.Pruning.Opt; with Output; with Storage.Bitvec_Cell_Sets; package body Flow.Computation is Next_Index : Model_Index_T := Model_Index_T'First; -- -- The index for the next Model_T object to be allocated from -- the heap. procedure Set_Index (Model : in out Model_T) -- -- Gives the Model its unique Index. -- is begin Model.Index := Next_Index; Next_Index := Next_Index + 1; end Set_Index; procedure Unchecked_Deallocate is new Ada.Unchecked_Deallocation ( Name => Model_Access_T, Object => Model_T); -- -- Deallocates a heap-allocated computation model. procedure Deallocate (Item : in out Model_Access_T) -- -- Deallocation controlled by Opt.Deallocate. -- is begin if Opt.Deallocate then Unchecked_Deallocate (Item); else Item := null; end if; exception when others => Faults.Deallocation; end Deallocate; function Model (Ref : Model_Ref) return Model_T is begin return Ref.Ref.all; end Model; function Is_Null (Model : Model_Ref) return Boolean is begin return Model.Ref = null; end Is_Null; function Spick (Item : Model_Ref) return String -- -- Says whether a model is clean or dirty. -- is begin if Item.Ref.Clean then return "clean"; else return "dirty"; end if; end Spick; function Ident_Ref (Item : Model_Ref) return String -- -- A description of the identity of the referenced model, for -- tracing purposes. -- is begin if Item.Ref = null then return "null model"; else return "computation model #" & Model_Index_T'Image (Item.Ref.Index) & " (" & Output.Image (Item.Ref.References) & " refs, " & Spick (Item) & ')'; end if; end Ident_Ref; procedure Discard (Model : in out Model_Ref) is begin if Opt.Trace_Models then Output.Trace ("Discarding ref to " & Ident_Ref (Model)); end if; if Model.Ref /= null then Model.Ref.References := Model.Ref.References - 1; if Model.Ref.References = 0 then Deallocate (Model.Ref); end if; Model.Ref := null; end if; exception when others => Faults.Deallocation; end Discard; procedure Refer ( From : in out Model_Ref; To : in Model_Ref) is begin if Opt.Trace_Models then Output.Trace ( "Referring to " & Ident_Ref (To) & ", was " & Ident_Ref (From)); end if; if From.Ref /= To.Ref then -- A real change in references, and no risk of -- killing To.Ref.all by Discarding From. Discard (From); To.Ref.References := To.Ref.References + 1; From.Ref := To.Ref; end if; end Refer; procedure Fill_Primitive_Model ( Subprogram : in Programs.Subprogram_T; Graph : in Graph_T; Model : out Model_T) -- -- Fills the Model with the primitive computation model built -- into the Graph for the Subprogram. -- is Calls : constant Programs.Call_List_T := Programs.Calls_From (Subprogram); -- All the calls in this Subprogram, perhaps including calls of -- "unused" callees. Call : Programs.Call_T; -- One of the Calls. procedure Fill_Infeasible (Edges : Step_Edge_List_T) -- -- Sets these edges to be infeasible. (We do not use the -- procedure Mark_Infeasible because we do not want to mess -- with copy-on-change at this point.) -- is begin for E in Edges'Range loop Model.Condition(Index (Edges(E))) := Arithmetic.Never; end loop; end Fill_Infeasible; begin -- Fill_Primitive_Model Model.References := 0; Model.Clean := True; -- This may be changed below if we find some feasible -- calls, because the protocols of these calls are -- considered to be changed. Model.Subprogram := Subprogram; Model.Graph := Graph; Model.Pruned := True; -- This may be changed below if we find some infeasible -- parts in the graph. -- Initially all steps are feasible (except for calls -- to Unused subprograms, see later): for S in Model.Effect'Range loop Model.Effect(S) := Effect (Step_At (S, Graph)); Model.Feasible(S) := True; -- May be reset below for unused calls. end loop; -- Initially all edges have the decoded condition: for E in Model.Condition'Range loop Model.Condition(E) := Condition (Edge_At (E, Graph)); end loop; -- Set the initial properties of the calls: for C in Calls'Range loop Call := Calls(C); Model.Protocol(C) := Programs.Protocol (Call); Model.New_Proto(C) := True; -- This signals later analysis phases that the effect -- of this Call must be computed before any analysis -- of the data-flow in this Model. if Programs.Unused (Call) then -- Calls to unused subprograms are infeasible. Model.Feasible(Index (Programs.Step (Call))) := False; Model.Pruned := False; else Model.Clean := False; -- Because the protocol of this feasible Call was changed. end if; Model.Returns(C) := Programs.Returns (Programs.Callee (Call)); if not Model.Returns(C) then -- All edges leaving non-returning calls are infeasible. Fill_Infeasible (Flow.Edges_From (Programs.Step (Call), Graph)); Model.Pruned := False; end if; end loop; end Fill_Primitive_Model; function Primitive_Model (Subprogram : Programs.Subprogram_T) return Model_T is Graph : constant Graph_T := Programs.Flow_Graph (Subprogram); -- The flow-graph of the Subprogram, for the model. Model : Model_T ( Steps => Max_Step (Graph), Edges => Max_Step_Edge (Graph), Calls => Programs.Number_Of_Calls_From (Subprogram)); -- The model to be built. begin Fill_Primitive_Model (Subprogram, Graph, Model); return Model; end Primitive_Model; procedure Refer_To_Primitive_Model ( Subprogram : in Programs.Subprogram_T; Model : in out Model_Ref) is Graph : constant Graph_T := Programs.Flow_Graph (Subprogram); -- The flow-graph of the Subprogram, for the model. begin Discard (Model); Model.Ref := new Model_T ( Steps => Max_Step (Graph), Edges => Max_Step_Edge (Graph), Calls => Programs.Number_Of_Calls_From (Subprogram)); -- The model to be built. Set_Index (Model.Ref.all); Fill_Primitive_Model (Subprogram, Graph, Model.Ref.all); Model.Ref.References := 1; -- There is one reference, Model. if Opt.Trace_Models then Output.Trace ("Created primitive " & Ident_Ref (Model)); end if; end Refer_To_Primitive_Model; function Changed (Model : in Model_Ref) return Boolean is begin return not Model.Ref.Clean; end Changed; procedure Mark_Clean (Model : in Model_Ref) is begin if Opt.Trace_Models then Output.Trace ("Marking as clean " & Ident_Ref (Model)); end if; for N in Model.Ref.New_Proto'Range loop Model.Ref.New_Proto(N) := False; end loop; Model.Ref.Clean := True; end Mark_Clean; function Subprogram (Model : Model_Ref) return Programs.Subprogram_T is begin return Model.Ref.Subprogram; end Subprogram; function Program (Model : Model_Ref) return Programs.Program_T is begin return Programs.Program (Model.Ref.Subprogram); end Program; function Graph (Under : Model_Ref) return Graph_T is begin return Under.Ref.Graph; end Graph; function Max_Step (Within : Model_Ref) return Step_Index_T is begin return Max_Step (Graph (Within)); end Max_Step; function Effect (Step : Step_Index_T; Under : Model_Ref) return Arithmetic.Effect_Ref is begin return Under.Ref.Effect(Step); end Effect; function Effect (Step : Step_T; Under : Model_Ref) return Arithmetic.Effect_Ref is begin return Under.Ref.Effect(Index (Step)); end Effect; function Effect (Step : Step_T; Under : Model_Ref) return Arithmetic.Effect_T is begin return Under.Ref.Effect(Index (Step)).all; end Effect; function Condition (Edge : Step_Edge_T; Under : Model_Ref) return Arithmetic.Condition_T is begin return Under.Ref.Condition(Index (Edge)); end Condition; function Condition (Edge : Edge_T; Under : Model_Ref) return Arithmetic.Condition_T is begin return Condition (Step_Edge(Edge), Under); end Condition; function Is_Feasible (Model : Model_Ref) return Boolean is begin return Is_Feasible (Entry_Step (Graph (Model)), Model); end Is_Feasible; function Is_Feasible (Step : Step_Index_T; Under : Model_Ref) return Boolean is begin return Under.Ref.Feasible(Step); end Is_Feasible; function Is_Feasible (Step : Step_T; Under : Model_Ref) return Boolean is begin return Under.Ref.Feasible(Index (Step)); end Is_Feasible; function Is_Feasible (Edge : Step_Edge_Index_T; Under : Model_Ref) return Boolean is use type Arithmetic.Condition_T; begin return Under.Ref.Condition(Edge) /= Arithmetic.Never; end Is_Feasible; function Is_Feasible (Edge : Step_Edge_T; Under : Model_Ref) return Boolean is use type Arithmetic.Condition_T; begin return Under.Ref.Condition(Index (Edge)) /= Arithmetic.Never; end Is_Feasible; function Is_Feasible (Node : Node_Index_T; Under : Model_Ref) return Boolean is begin return Is_Feasible ( Step => First_Step (Node_At (Node, Graph (Under))), Under => Under); end Is_Feasible; function Is_Feasible (Node : Node_T; Under : Model_Ref) return Boolean is begin return Is_Feasible (First_Step (Node), Under); end Is_Feasible; function Is_Feasible (Edge : Edge_Index_T; Under : Model_Ref) return Boolean is begin return Is_Feasible ( Edge => Step_Edge (Edge_At (Edge, Graph (Under))), Under => Under); end Is_Feasible; function Is_Feasible (Edge : Edge_T; Under : Model_Ref) return Boolean is begin return Is_Feasible (Step_Edge (Edge), Under); end Is_Feasible; function Some_Feasible (Edges : Edge_List_T; Under : Model_Ref) return Boolean is begin for E in Edges'Range loop if Is_Feasible (Edges(E), Under) then return True; end if; end loop; return False; end Some_Feasible; function Is_Feasible (Call : Programs.Call_T; Under : Model_Ref) return Boolean is begin return Is_Feasible (Programs.Step (Call), Under); -- and Programs.Is_Feasible (Programs.Callee (Call)); -- TBA end Is_Feasible; function Is_Feasible (Luup : Loops.Loop_T; Under : Model_Ref) return Boolean is begin return Is_Feasible ( Step => First_Step (Loops.Head_Node (Luup)), Under => Under); end Is_Feasible; function Is_Eternal (Luup : Loops.Loop_T; Under : Model_Ref) return Boolean is begin if Loops.Eternal (Luup) then -- The loop has no exit edges at all. return True; else -- The loop has some exit edges, but is eternal if none -- of the exit edges are feasible. return not Some_Feasible ( Edges => Loops.Exit_Edges (Luup, Graph (Under)), Under => Under); end if; end Is_Eternal; function Is_Repeatable (Luup : Loops.Loop_T; Under : Model_Ref) return Boolean is begin return Some_Feasible ( Edges => Loops.Repeat_Edges (Luup, Graph (Under)), Under => Under); end Is_Repeatable; function Target_Range (Step : Step_T; Under : Model_Ref) return Storage.Alias_Range_T is begin return Arithmetic.Target_Range (Under.Ref.Effect(Index (Step)).all); end Target_Range; function Calling_Protocol ( Call_Index : Programs.Call_Index_T; Under : Model_Ref) return Calling.Protocol_Ref is begin return Under.Ref.Protocol(Call_Index); end Calling_Protocol; function Calling_Protocol ( Call : Programs.Call_T; Under : Model_Ref) return Calling.Protocol_Ref is begin return Under.Ref.Protocol(Programs.Index (Call)); end Calling_Protocol; function Calling_Protocol_Is_Static ( Call : Programs.Call_T; Under : Model_Ref) return Boolean is begin return Calling.Static (Calling_Protocol (Call, Under).all); end Calling_Protocol_Is_Static; function Calling_Protocol_Changed ( Call : Programs.Call_T; Under : Model_Ref) return Boolean is begin return Under.Ref.New_Proto(Programs.Index (Call)); end Calling_Protocol_Changed; function Returns ( Call : Programs.Call_T; Under : Model_Ref) return Boolean is begin return Under.Ref.Returns(Programs.Index (Call)); end Returns; -- -- Properties of the feasible parts of a model -- function Feasible (Steps : Step_List_T; Under : Model_Ref) return Step_List_T is Result : Step_List_T (1 .. Steps'Length); Last : Natural := 0; -- The result will be Result(1 .. Last). begin for S in Steps'Range loop if Is_Feasible (Steps(S), Under) then Last := Last + 1; Result(Last) := Steps(S); end if; end loop; return Result(1 .. Last); end Feasible; function Edges_Into (Step : Step_T; Under : Model_Ref) return Step_Edge_List_T is Candidates : Step_Edge_List_T := Edges_Into (Step, Under.Ref.Graph); -- All the edges into the Step, whether feasible or not. Last : Natural := Candidates'First - 1; -- The final result will be Candidates(Candidates'First .. Last). begin for C in Candidates'Range loop if Is_Feasible (Candidates(C), Under) then Last := Last + 1; if Last < C then Candidates(Last) := Candidates(C); -- else Candidates(C) is already in place. end if; end if; end loop; return Candidates(Candidates'First .. Last); end Edges_Into; function Edges_From (Step : Step_T; Under : Model_Ref) return Step_Edge_List_T is Candidates : Step_Edge_List_T := Edges_From (Step, Under.Ref.Graph); -- All the edges from the Step, whether feasible or not. Last : Natural := Candidates'First - 1; -- The final result will be Candidates(Candidates'First .. Last). begin for C in Candidates'Range loop if Is_Feasible (Candidates(C), Under) then Last := Last + 1; if Last < C then Candidates(Last) := Candidates(C); -- else Candidates(C) is already in place. end if; end if; end loop; return Candidates(Candidates'First .. Last); end Edges_From; function Number_Into (Step : Step_T; Under : Model_Ref) return Natural is Candidates : constant Step_Edge_List_T := Edges_Into (Step, Under.Ref.Graph); -- All the edges into the Step, whether feasible or not. Number : Natural := 0; -- The number of feasible Candidates. begin for C in Candidates'Range loop if Is_Feasible (Candidates(C), Under) then Number := Number + 1; end if; end loop; return Number; end Number_Into; function Is_Final (Step : Step_T; Under : Model_Ref) return Boolean is Candidates : Step_Edge_List_T := Edges_From (Step, Under.Ref.Graph); -- All the edges from the Step, whether feasible or not. begin for C in Candidates'Range loop if Is_Feasible (Candidates(C), Under) then -- This is not a final step. return False; end if; end loop; -- No feasible Candidates. The Step is final. return True; end Is_Final; function Final_Steps (Under : Model_Ref) return Step_List_T is begin return Feasible ( Steps => Return_Steps (Graph (Under)), Under => Under); end Final_Steps; function Is_Final (Node : Node_T; Under : Model_Ref) return Boolean is begin return Number_From (Node, Under) = 0; end Is_Final; function Final_Nodes (Under : Model_Ref) return Node_List_T is begin return Nodes_Containing ( Steps => Final_Steps (Under), Graph => Graph (Under)); end Final_Nodes; function Returns (Under : Model_Ref) return Boolean is begin return Final_Steps (Under)'Length > 0; end Returns; function Non_Returning_Call_Steps (Under : Model_Ref) return Step_List_T is Steps : Step_List_T (1 .. Under.Ref.Calls); Last : Natural := 0; -- The result will be Steps(1 .. Last). Step : Step_T; -- One of the call steps. begin for R in Under.Ref.Returns'Range loop if not Under.Ref.Returns(R) then -- This is a non-returning call. Step := Programs.Step (Programs.Call ( From => Under.Ref.Subprogram, Index => R)); if Is_Feasible (Step, Under) then Last := Last + 1; Steps(Last) := Step; end if; end if; end loop; return Steps(1 .. Last); end Non_Returning_Call_Steps; function Predecessors (Step : Step_T; Under : Model_Ref) return Step_List_T is begin return Sources (Edges_Into (Step, Under)); end Predecessors; function Successors (Step : Step_T; Under : Model_Ref) return Step_List_T is begin return Targets (Edges_From (Step, Under)); end Successors; function Edges_Into (Node : Node_T; Under : Model_Ref) return Edge_List_T is begin return Feasible ( Edges => Edges_Into (Node, Graph (Under)), Under => Under); end Edges_Into; function Number_From (Node : Node_T; Under : Model_Ref) return Natural is begin return Edges_From (Node, Under)'Length; end Number_From; function Edges_From (Node : Node_T; Under : Model_Ref) return Edge_List_T is begin return Feasible ( Edges => Edges_From (Node, Graph (Under)), Under => Under); end Edges_From; function Successors (Node : Node_T; Under : Model_Ref) return Node_List_T is begin return Targets (Edges_From (Node, Under)); end Successors; function Is_Feasible (Edge : Dynamic_Edge_T; Under : Model_Ref) return Boolean is begin return Is_Feasible (Source (Edge.all), Under); end Is_Feasible; function Dynamic_Edges (Under : Model_Ref) return Dynamic_Edge_List_T is Cands : constant Dynamic_Edge_List_T := Dynamic_Edges (Under.Ref.Graph); -- All the dynamic edges, feasible or not. Result : Dynamic_Edge_List_T (1 .. Cands'Length); Last : Natural := 0; -- The result will be Result(1 .. Last). begin for C in Cands'Range loop if Is_Feasible (Cands(C), Under) then -- Good one. Last := Last + 1; Result(Last) := Cands(C); end if; end loop; return Result(1 .. Last); end Dynamic_Edges; function Unstable_Dynamic_Edges (Under : Model_Ref) return Dynamic_Edge_List_T is Cands : constant Dynamic_Edge_List_T := Dynamic_Edges (Under); -- All the feasible dynamic edges. Result : Dynamic_Edge_List_T (1 .. Cands'Length); Last : Natural := 0; -- The result will be Result(1 .. Last). begin for C in Cands'Range loop if Cands(C).Unstable then Last := Last + 1; Result(Last) := Cands(C); end if; end loop; return Result(1 .. Last); end Unstable_Dynamic_Edges; function Unstable_Dynamic_Edges_From ( Source : Step_T; Under : Model_Ref) return Dynamic_Edge_List_T is Cands : constant Dynamic_Edge_List_T := Unstable_Dynamic_Edges (Under); -- All the feasible unstable dynamic edges. Result : Dynamic_Edge_List_T (1 .. Cands'Length); Last : Natural := 0; -- The result will be Result(1 .. Last). begin for C in Cands'Range loop if Flow.Source (Cands(C).all) = Source then -- An unstable edge from this Source. Last := Last + 1; Result(Last) := Cands(C); end if; end loop; return Result(1 .. Last); end Unstable_Dynamic_Edges_From; function Dynamic_Flow (Under : Model_Ref) return Edge_Resolution_T is Edges : constant Dynamic_Edge_List_T := Dynamic_Edges (Under); -- The feasible dynamic edges. Overall_State : Edge_Resolution_T := Stable; -- The result state. begin for E in Edges'Range loop Overall_State := Edge_Resolution_T'Min ( Overall_State, State (Edges(E).all)); end loop; return Overall_State; end Dynamic_Flow; function Loops_Of (Model : Model_Ref) return Loops.Loop_List_T is Luups : constant Loops.Loops_T := Programs.Loops_Of (Subprogram (Model)); -- All the loops in the flow-graph, without regard to the Model. Result : Loops.Loop_List_T (1 .. Luups'Length); Last : Natural := 0; -- The result will be Result(1 .. Last). Luup : Loops.Loop_T; -- One of the Loops. Index : Loops.Loop_Index_T; -- The index of the Luup. Feasible, Eternal, Repeatable : Boolean; -- Properties of the Luup under the Model. begin for L in Luups'Range loop Luup := Luups(L); Index := Loops.Loop_Index (Luup); Feasible := Is_Feasible (Luup, Model); Eternal := Is_Eternal (Luup, Model); Repeatable := Is_Repeatable (Luup, Model); -- Remark on interesting changes: if not Feasible then Output.Note ( "Loop" & Loops.Loop_Index_T'Image (Index) & " is not feasibly enterable."); else -- The loop is at least feasible. if not Repeatable then Output.Note ( "Loop" & Loops.Loop_Index_T'Image (Index) & " is not feasibly repeatable."); end if; if Eternal and not Loops.Eternal (Luup) then Output.Note ( "Loop" & Loops.Loop_Index_T'Image (Index) & " is not feasibly exitable."); end if; end if; -- Selection: if Feasible and Repeatable then -- This loop is still relevant under the Model. if Eternal then -- Under the Model, this loop is eternal. Loops.Mark_As_Eternal (Luup); end if; Last := Last + 1; Result(Last) := Luup; end if; end loop; return Result(1 .. Last); end Loops_Of; function Feasible (Edges : Edge_List_T; Under : Model_Ref) return Edge_List_T is Result : Edge_List_T (1 .. Edges'Length); Last : Natural := 0; -- The result will be Result(1 .. Last). begin for E in Edges'Range loop if Is_Feasible (Edges(E), Under) then Last := Last + 1; Result(Last) := Edges(E); end if; end loop; return Result(1 .. Last); end Feasible; function Entry_Edges ( Luup : Loops.Loop_T; Under : Model_Ref) return Flow.Edge_List_T is begin return Feasible ( Edges => Loops.Entry_Edges (Luup, Graph (Under)), Under => Under); end Entry_Edges; function Neck_Edges ( Luup : Loops.Loop_T; Under : Model_Ref) return Flow.Edge_List_T is begin return Feasible ( Edges => Loops.Neck_Edges (Luup, Graph (Under)), Under => Under); end Neck_Edges; function Repeat_Edges ( Luup : Loops.Loop_T; Under : Model_Ref) return Flow.Edge_List_T is begin return Feasible ( Edges => Loops.Repeat_Edges (Luup, Graph (Under)), Under => Under); end Repeat_Edges; function Exit_Edges ( Luup : Loops.Loop_T; Under : Model_Ref) return Flow.Edge_List_T is begin return Feasible ( Edges => Loops.Exit_Edges (Luup, Graph (Under)), Under => Under); end Exit_Edges; function Cells_In ( Model : Model_Ref; Calls : Boolean) return Storage.Cell_Set_T is use type Arithmetic.Condition_T; subtype Cell_Set_T is Storage.Bitvec_Cell_Sets.Set_T; -- The kind of cell-sets we use in this operation. Mo : Model_T renames Model.Ref.all; Cells : Cell_Set_T; -- The set to be built up, initially empty. Dyn_Edges : constant Dynamic_Edge_List_T := Dynamic_Edges (Model); -- All the feasible dynamic edges. begin -- Include all cells named in the effects of steps, S: for S in Mo.Effect'Range loop if Mo.Feasible(S) and then ( Calls or else not Flow.Calls.Is_Call (Step_At (S, Mo.Graph))) then -- The effect of this step shall be included. Arithmetic.Add_Cells_Used ( By => Mo.Effect(S).all, Refs => True, Post => True, To => Cells); Arithmetic.Add_Cells_Defined ( By => Mo.Effect(S).all, To => Cells); end if; end loop; -- Include all cells used in the conditions of edges, E: for E in Mo.Condition'Range loop if Mo.Condition(E) /= Arithmetic.Never then Arithmetic.Add_Cells_Used ( By => Mo.Condition(E), Refs => True, To => Cells); end if; end loop; -- Include all basis cells for dynamic boundable edges, D: for D in Dyn_Edges'Range loop if Is_Feasible (Dyn_Edges(D), Model) then Add_Basis_Cells ( From => Dyn_Edges(D).all, To => Cells); end if; end loop; -- Include all basis cells for protocols in calls, C: for C in Mo.Protocol'Range loop if Is_Feasible (Programs.Call (Mo.Subprogram, C), Model) then Calling.Add_Basis_Cells ( From => Mo.Protocol(C).all, To => Cells); end if; end loop; return Cells; end Cells_In; function Is_Defined ( Cell : Storage.Cell_T; By : Step_T; Under : Model_Ref) return Boolean is begin return Under.Ref.Feasible(Index (By)) and then Arithmetic.Is_Defined ( Cell => Cell, By => Under.Ref.Effect(Index (By)).all); end Is_Defined; function Cells_Defined (By : Model_Ref) return Storage.Cell_Set_T is subtype Cell_Set_T is Storage.Bitvec_Cell_Sets.Set_T; -- The kind of cell-set we use in this operation. Mo : Model_T renames By.Ref.all; Cells : Cell_Set_T; -- The set to be built up, initially empty. begin -- Include all cells defined in the effects of steps, S: for S in Mo.Effect'Range loop if Mo.Feasible(S) then Arithmetic.Add_Cells_Defined ( By => Mo.Effect(S).all, To => Cells); end if; end loop; return Cells; end Cells_Defined; function Steps_Defining (Cell : Storage.Cell_T; Under : Model_Ref) return Step_List_T is Graph : constant Graph_T := Flow.Computation.Graph (Under); -- The flow-graph under this model. Steps : Step_List_T (1 .. Natural (Max_Step (Graph))); Num : Natural := 0; -- Steps (1 .. Num) accumulates the steps to be returned. Step : Step_T; -- A step being considered. begin -- Trivial implementation by scanning all the steps -- and collecting the ones which change the Cell: for I in 1 .. Max_Step (Graph) loop Step := Step_At (Index => I, Within => Graph); if Is_Feasible (Step, Under) and then Arithmetic.Is_Defined (Cell => Cell, By => Effect (Step, Under)) then Num := Num + 1; Steps(Num) := Step; end if; end loop; return Steps(1 .. Num); end Steps_Defining; function Max_Effect_Length (Under : Computation.Model_Ref) return Natural is Max_Len : Natural := 0; -- The cumulative maximum length. begin for S in Under.Ref.Effect'Range loop if Under.Ref.Feasible(S) then Max_Len := Natural'Max (Max_Len, Under.Ref.Effect(S)'Length); end if; end loop; return Max_Len; end Max_Effect_Length; function Total_Defining_Assignments (Under : Model_Ref) return Natural is Total : Natural := 0; -- The cumulative total of defining assignments. begin for S in Under.Ref.Effect'Range loop if Under.Ref.Feasible(S) then Total := Total + Arithmetic.Defining_Assignments (Under.Ref.Effect(S).all); end if; end loop; return Total; end Total_Defining_Assignments; procedure Add_Cells_Used ( By : in Step_Edge_List_T; Under : in Model_Ref; To : in out Storage.Cell_Set_T) -- -- Adds the cells used By the preconditions of the given edges, -- Under a given computation model, To a set of cells. -- Basis cells for dynamic memory references are included. -- is begin for B in By'Range loop Arithmetic.Add_Cells_Used ( By => Condition (By(B), Under), Refs => True, To => To); end loop; end Add_Cells_Used; procedure Add_Cells_Used ( By : in Step_List_T; Under : in Model_Ref; To : in out Storage.Cell_Set_T) -- -- Adds the cells used By the given steps and edges leaving the -- steps, Under a given computation model, To a set of cells. -- Basis cells of boundable memory references are included. -- Basis cells of dynamic edges leaving the steps are included. -- Basis cells for calling protocols are omitted. TBA? -- is begin for B in By'Range loop Arithmetic.Add_Cells_Used ( By => Effect (By(B), Under), Refs => True, Post => False, To => To); Add_Cells_Used ( By => Flow.Edges_From (By(B), Graph (Under)), Under => Under, To => To); Add_Basis_Cells ( From => Dynamic_Edges_From (By(B), Graph (Under)), To => To); end loop; end Add_Cells_Used; function Cells_Used ( Nodes : Node_List_T; Under : Model_Ref) return Storage.Cell_List_T is package Cell_Sets renames Storage.Bitvec_Cell_Sets; -- The kind of cell-set we use in this operation. Used : Cell_Sets.Set_T; -- Collects the used cells, initially empty. begin for N in Nodes'Range loop Add_Cells_Used ( By => Steps_In (Nodes(N)), Under => Under, To => Used); end loop; return Cell_Sets.To_List (Used); end Cells_Used; procedure Add_Cells_Defined ( By : in Step_List_T; Under : in Model_Ref; To : in out Storage.Cell_Set_T) -- -- Adds the cells defined By the given steps, Under a given -- computation model, To a set of cells. -- is begin for B in By'Range loop Arithmetic.Add_Cells_Defined ( By => Effect (By(B), Under), To => To); end loop; end Add_Cells_Defined; function Cells_Defined ( Nodes : Node_List_T; Under : Model_Ref) return Storage.Cell_List_T is package Cell_Sets renames Storage.Bitvec_Cell_Sets; -- The kind of cell-set we use in this operation. Defined : Cell_Sets.Set_T; -- Collects the defined cells. begin for N in Nodes'Range loop Add_Cells_Defined ( By => Steps_In (Nodes(N)), Under => Under, To => Defined); end loop; return Cell_Sets.To_List (Defined); end Cells_Defined; function Is_Used ( Cell : Storage.Cell_T; By : Step_Edge_List_T; Under : Model_Ref) return Boolean -- -- Whether the Cell is used By the precondition of some of the -- given edges, Under the given computation model. -- is begin for B in By'Range loop if Arithmetic.Is_Used ( Cell => Cell, By => Condition (By(B), Under)) then -- Yes, used in this edge. return True; end if; end loop; -- Not used in these edges. return False; end Is_Used; function Is_Used ( Location : Storage.Location_T; By : Step_T; Under : Model_Ref) return Boolean -- -- Whether the Location is used By the effect of the step or by a -- precondition on an edge leaving the step, Under a given -- computation model. -- is Here : constant Processor.Code_Address_T := Prime_Address (By); -- The code address of the step, for mapping with the -- Location. Dynamic_Edges : constant Dynamic_Edge_List_T := Dynamic_Edges_From (Source => By, Within => Graph (Under)); -- The dynamic edges leaving the Step. Cell : Storage.Cell_T; -- One of the cells for the location. begin for L in Location'Range loop if Storage.In_Range ( Address => Here, Rainge => Location(L).Address) then -- The location maps Here to a cell. Cell := Location(L).Cell; -- Check the effect: if Arithmetic.Is_Used ( Cell => Cell, By => Effect (By, Under)) then -- This cell is used in the effect. return True; end if; -- Check the leaving edges: if Is_Used ( Cell => Cell, By => Flow.Edges_From (By, Graph (Under)), Under => Under) then -- This cell is used in a precondition on a -- leaving edge. return True; end if; -- Check the dynamic leaving edges: for D in Dynamic_Edges'Range loop if Storage.Is_Member ( Cell => Cell, Of_List => Basis (Dynamic_Edges(D).all)) then -- This cell is used in the basis of a dynamic edge. return True; end if; end loop; end if; end loop; -- Location is not used: return False; end Is_Used; function Is_Used ( Location : Storage.Location_T; By : Step_List_T; Under : Model_Ref) return Boolean -- -- Whether the Location is used By some of the given steps or the -- edges leaving the steps, Under a given computation model. -- is begin for B in By'Range loop if Is_Used ( Location => Location, By => By(B), Under => Under) then -- Yes, used in this step. return True; end if; end loop; -- Not used in these steps. return False; end Is_Used; function Is_Used ( Location : Storage.Location_T; By : Node_List_T; Under : Model_Ref) return Boolean is begin for B in By'Range loop if Is_Used ( Location => Location, By => Steps_In (By(B)), Under => Under) then -- Yes, used in this node. return True; end if; end loop; -- Not used in any of these nodes. return False; end Is_Used; function Is_Defined ( Location : Storage.Location_T; By : Step_T; Under : Model_Ref) return Boolean -- -- Whether the Location is defined By the effect of the step, Under -- a given computation model. -- is Here : constant Processor.Code_Address_T := Prime_Address (By); -- The code address of the step, for mapping with the -- Location. Cell : Storage.Cell_T; -- One of the cells for the location. begin for L in Location'Range loop if Storage.In_Range ( Address => Here, Rainge => Location(L).Address) then -- The location maps Here to a cell. Cell := Location(L).Cell; -- Check the effect: if Arithmetic.Is_Defined ( Cell => Cell, By => Effect (By, Under)) then -- This cell is defined in this step. return True; end if; end if; end loop; -- Location is not defined: return False; end Is_Defined; function Is_Defined ( Location : Storage.Location_T; By : Step_List_T; Under : Model_Ref) return Boolean -- -- Whether the Location is defined By some of the given steps, -- Under a given computation model. -- is begin for B in By'Range loop if Is_Defined ( Location => Location, By => By(B), Under => Under) then -- Yes, defined in this step. return True; end if; end loop; -- Not defined in these steps. return False; end Is_Defined; function Is_Defined ( Location : Storage.Location_T; By : Node_List_T; Under : Model_Ref) return Boolean is begin for B in By'Range loop if Is_Defined ( Location => Location, By => Steps_In (By(B)), Under => Under) then -- Yes, defined in this node. return True; end if; end loop; -- Not defined in any of these nodes. return False; end Is_Defined; function Steps_With_Dynamic_Effect (Under : Model_Ref) return Step_List_T is Effect : Effects_T renames Under.Ref.Effect; Feasible : Feasibility_T renames Under.Ref.Feasible; Steps : Step_List_T (1 .. Effect'Length); -- Collects the result. Last : Natural := 0; -- Steps(1 .. Last) is the result. begin for E in Effect'Range loop if Feasible(E) and then Arithmetic.Dynamic (Effect(E).all) then Last := Last + 1; Steps(Last) := Step_At ( Index => E, Within => Under.Ref.Graph); end if; end loop; return Steps(1 .. Last); end Steps_With_Dynamic_Effect; function Edges_With_Dynamic_Condition (Under : Model_Ref) return Step_Edge_List_T is Condition : Conditions_T renames Under.Ref.Condition; Edges: Step_Edge_List_T (1 .. Condition'Length); -- Collects the result. Last : Natural := 0; -- Edges(1 .. Last) is the result. begin for C in Condition'Range loop if Arithmetic.Dynamic (Condition(C)) then -- The condition has a dynamic reference. Also, the -- edge is feasible, because infeasible edges have a -- False condition which has no dynamic reference. Last := Last + 1; Edges(Last) := Edge_At ( Index => C, Within => Under.Ref.Graph); end if; end loop; return Edges(1 .. Last); end Edges_With_Dynamic_Condition; function Calls_From (Model : Model_Ref) return Programs.Call_List_T is Candidates : Programs.Call_List_T := Programs.Calls_From (Subprogram (Model)); -- All the calls from the subprogram, whether feasible or not. Last : Natural := Candidates'First - 1; -- The final result will be Candidates(Candidates'First .. Last). begin for C in Candidates'Range loop if Is_Feasible (Candidates(C), Model) then Last := Last + 1; if Last < C then Candidates(Last) := Candidates(C); -- else Candidates(C) is already in place. end if; end if; end loop; return Candidates(Candidates'First .. Last); end Calls_From; -- -- Operations to modify a model -- procedure Ensure_Single_Ref (Model : in out Model_Ref) -- -- Ensures that Model is the only reference to its underlying -- computation model, by making a copy of the model if necessary. -- Since this is used only when making a change to the Model, -- we also mark the Model (the copy, if one is made) as "changed". -- is Original : constant Model_Access_T := Model.Ref; -- Accesses the underlying Model_T. Copy : Model_Access_T; -- Access the copy, if one is made. begin if Original.References > 1 then -- There are other references to this model, so we -- will copy it and make Model refer to the copy. if Opt.Trace_Models then Output.Trace ("Copy " & Ident_Ref (Model)); end if; if not Original.Clean then Output.Fault ( Location => "Flow.Computation.Ensure_Single_Ref", Text => "Original model is not clean."); end if; if not Original.Pruned then Output.Fault ( Location => "Flow.Computation.Ensure_Single_Ref", Text => "Original model is not pruned."); end if; Original.References := Original.References - 1; -- The Model will no longer refer to the Original. Copy := new Model_T'(Original.all); Set_Index (Copy.all); Copy.References := 1; -- The Model will refer to the Copy. Model.Ref := Copy; end if; if Opt.Trace_Models then Output.Trace ("Marking as dirty " & Ident_Ref (Model)); end if; Model.Ref.Clean := False; end Ensure_Single_Ref; procedure Set_Effect ( Step : in Step_T; To : in Arithmetic.Effect_Ref; Under : in out Model_Ref) is use type Arithmetic.Effect_Ref; S : constant Step_Index_T := Index (Step); begin if To /= Under.Ref.Effect(S) then -- A real change. if Opt.Trace_Models then Output.Trace ( "Setting effect of step" & Step_Index_T'Image (Index (Step)) & " in " & Ident_Ref (Under) & " to " & Arithmetic.Image (To.all)); end if; Ensure_Single_Ref (Under); Under.Ref.Effect(S) := To; end if; end Set_Effect; procedure Mark_Infeasible ( Step : in Step_T; Under : in out Model_Ref) is S : constant Step_Index_T := Index (Step); begin if Under.Ref.Feasible(S) then -- A real change. Ensure_Single_Ref (Under); Under.Ref.Feasible(S) := False; Under.Ref.Pruned := False; end if; end Mark_Infeasible; procedure Set_Condition ( On : in Step_Edge_T; To : in Arithmetic.Condition_T; Under : in out Model_Ref) is use type Arithmetic.Condition_T; E : constant Step_Edge_Index_T := Index (On); begin if To /= Under.Ref.Condition(E) then -- A real change. Ensure_Single_Ref (Under); Under.Ref.Condition(E) := To; if To = Arithmetic.Never then -- This edge is now infeasible. Under.Ref.Pruned := False; end if; end if; end Set_Condition; procedure Mark_Infeasible ( Edge : in Step_Edge_T; Under : in out Model_Ref) is begin Set_Condition ( On => Edge, To => Arithmetic.Never, Under => Under); end Mark_Infeasible; procedure Mark_Infeasible ( Edges : in Step_Edge_List_T; Under : in out Model_Ref) is begin for E in Edges'Range loop Mark_Infeasible ( Edge => Edges(E), Under => Under); end loop; end Mark_Infeasible; procedure Mark_Infeasible ( Edge : in Edge_T; Under : in out Model_Ref) is begin Mark_Infeasible ( Edge => Step_Edge (Edge), Under => Under); end Mark_Infeasible; procedure Mark_Infeasible ( Edges : in Edge_List_T; Under : in out Model_Ref) is begin for E in Edges'Range loop Mark_Infeasible ( Edge => Step_Edge (Edges(E)), Under => Under); end loop; end Mark_Infeasible; procedure Mark_Infeasible ( Call : in Programs.Call_T; Under : in out Model_Ref) is begin Mark_Infeasible (Programs.Step (Call), Under); end Mark_Infeasible; procedure Mark_Infeasible ( Luup : in Loops.Loop_T; Under : in out Model_Ref) is begin Mark_Infeasible (Loops.Head_Step (Luup), Under); end Mark_Infeasible; procedure Set_Calling_Protocol ( Call : in Programs.Call_T; To : in Calling.Protocol_Ref; Under : in out Model_Ref) is use type Calling.Protocol_Ref; Index : constant Programs.Call_Index_T := Programs.Index (Call); -- The index of this Call in the calling subprogram. begin if To /= Under.Ref.Protocol(Index) then -- A real change. Ensure_Single_Ref (Under); Under.Ref.Protocol (Index) := To; Under.Ref.New_Proto(Index) := True; -- TBA discard the old protocol if no longer used elsewhere. end if; end Set_Calling_Protocol; procedure Mark_No_Return ( From : in Programs.Call_T; To : in out Model_Ref) is Index : constant Programs.Call_Index_T := Programs.Index (From); -- The index of this call in the calling subprogram. begin if To.Ref.Returns(Index) then -- A real change. Ensure_Single_Ref (To); To.Ref.Returns(Index) := False; Mark_Infeasible ( Edges => Edges_From (Programs.Step (From), To), Under => To); end if; end Mark_No_Return; procedure Prune (Model : in out Model_Ref) is begin if Pruning.Opt.Prune and not Model.Ref.Pruned then Ensure_Single_Ref (Model); Flow.Pruning.Prune (Model); Model.Ref.Pruned := True; end if; end Prune; end Flow.Computation;
AdaCore/Ada_Drivers_Library
Ada
6,656
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.DBG is pragma Preelaborate; --------------- -- Registers -- --------------- subtype DBGMCU_IDCODE_DEV_ID_Field is HAL.UInt12; subtype DBGMCU_IDCODE_REV_ID_Field is HAL.UInt16; -- IDCODE type DBGMCU_IDCODE_Register is record -- Read-only. DEV_ID DEV_ID : DBGMCU_IDCODE_DEV_ID_Field; -- unspecified Reserved_12_15 : HAL.UInt4; -- Read-only. REV_ID REV_ID : DBGMCU_IDCODE_REV_ID_Field; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DBGMCU_IDCODE_Register use record DEV_ID at 0 range 0 .. 11; Reserved_12_15 at 0 range 12 .. 15; REV_ID at 0 range 16 .. 31; end record; subtype DBGMCU_CR_TRACE_MODE_Field is HAL.UInt2; -- Control Register type DBGMCU_CR_Register is record -- DBG_SLEEP DBG_SLEEP : Boolean := False; -- DBG_STOP DBG_STOP : Boolean := False; -- DBG_STANDBY DBG_STANDBY : Boolean := False; -- unspecified Reserved_3_4 : HAL.UInt2 := 16#0#; -- TRACE_IOEN TRACE_IOEN : Boolean := False; -- TRACE_MODE TRACE_MODE : DBGMCU_CR_TRACE_MODE_Field := 16#0#; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DBGMCU_CR_Register use record DBG_SLEEP at 0 range 0 .. 0; DBG_STOP at 0 range 1 .. 1; DBG_STANDBY at 0 range 2 .. 2; Reserved_3_4 at 0 range 3 .. 4; TRACE_IOEN at 0 range 5 .. 5; TRACE_MODE at 0 range 6 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; -- Debug MCU APB1 Freeze registe type DBGMCU_APB1_FZ_Register is record -- DBG_TIM2_STOP DBG_TIM2_STOP : Boolean := False; -- DBG_TIM3 _STOP DBG_TIM3_STOP : Boolean := False; -- DBG_TIM4_STOP DBG_TIM4_STOP : Boolean := False; -- DBG_TIM5_STOP DBG_TIM5_STOP : Boolean := False; -- DBG_TIM6_STOP DBG_TIM6_STOP : Boolean := False; -- DBG_TIM7_STOP DBG_TIM7_STOP : Boolean := False; -- DBG_TIM12_STOP DBG_TIM12_STOP : Boolean := False; -- DBG_TIM13_STOP DBG_TIM13_STOP : Boolean := False; -- DBG_TIM14_STOP DBG_TIM14_STOP : Boolean := False; -- unspecified Reserved_9_10 : HAL.UInt2 := 16#0#; -- DBG_WWDG_STOP DBG_WWDG_STOP : Boolean := False; -- DBG_IWDEG_STOP DBG_IWDEG_STOP : Boolean := False; -- unspecified Reserved_13_20 : HAL.UInt8 := 16#0#; -- DBG_J2C1_SMBUS_TIMEOUT DBG_J2C1_SMBUS_TIMEOUT : Boolean := False; -- DBG_J2C2_SMBUS_TIMEOUT DBG_J2C2_SMBUS_TIMEOUT : Boolean := False; -- DBG_J2C3SMBUS_TIMEOUT DBG_J2C3SMBUS_TIMEOUT : Boolean := False; -- unspecified Reserved_24_24 : HAL.Bit := 16#0#; -- DBG_CAN1_STOP DBG_CAN1_STOP : Boolean := False; -- DBG_CAN2_STOP DBG_CAN2_STOP : Boolean := False; -- unspecified Reserved_27_31 : HAL.UInt5 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DBGMCU_APB1_FZ_Register use record DBG_TIM2_STOP at 0 range 0 .. 0; DBG_TIM3_STOP at 0 range 1 .. 1; DBG_TIM4_STOP at 0 range 2 .. 2; DBG_TIM5_STOP at 0 range 3 .. 3; DBG_TIM6_STOP at 0 range 4 .. 4; DBG_TIM7_STOP at 0 range 5 .. 5; DBG_TIM12_STOP at 0 range 6 .. 6; DBG_TIM13_STOP at 0 range 7 .. 7; DBG_TIM14_STOP at 0 range 8 .. 8; Reserved_9_10 at 0 range 9 .. 10; DBG_WWDG_STOP at 0 range 11 .. 11; DBG_IWDEG_STOP at 0 range 12 .. 12; Reserved_13_20 at 0 range 13 .. 20; DBG_J2C1_SMBUS_TIMEOUT at 0 range 21 .. 21; DBG_J2C2_SMBUS_TIMEOUT at 0 range 22 .. 22; DBG_J2C3SMBUS_TIMEOUT at 0 range 23 .. 23; Reserved_24_24 at 0 range 24 .. 24; DBG_CAN1_STOP at 0 range 25 .. 25; DBG_CAN2_STOP at 0 range 26 .. 26; Reserved_27_31 at 0 range 27 .. 31; end record; -- Debug MCU APB2 Freeze registe type DBGMCU_APB2_FZ_Register is record -- TIM1 counter stopped when core is halted DBG_TIM1_STOP : Boolean := False; -- TIM8 counter stopped when core is halted DBG_TIM8_STOP : Boolean := False; -- unspecified Reserved_2_15 : HAL.UInt14 := 16#0#; -- TIM9 counter stopped when core is halted DBG_TIM9_STOP : Boolean := False; -- TIM10 counter stopped when core is halted DBG_TIM10_STOP : Boolean := False; -- TIM11 counter stopped when core is halted DBG_TIM11_STOP : Boolean := False; -- unspecified Reserved_19_31 : HAL.UInt13 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DBGMCU_APB2_FZ_Register use record DBG_TIM1_STOP at 0 range 0 .. 0; DBG_TIM8_STOP at 0 range 1 .. 1; Reserved_2_15 at 0 range 2 .. 15; DBG_TIM9_STOP at 0 range 16 .. 16; DBG_TIM10_STOP at 0 range 17 .. 17; DBG_TIM11_STOP at 0 range 18 .. 18; Reserved_19_31 at 0 range 19 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Debug support type DBG_Peripheral is record -- IDCODE DBGMCU_IDCODE : aliased DBGMCU_IDCODE_Register; -- Control Register DBGMCU_CR : aliased DBGMCU_CR_Register; -- Debug MCU APB1 Freeze registe DBGMCU_APB1_FZ : aliased DBGMCU_APB1_FZ_Register; -- Debug MCU APB2 Freeze registe DBGMCU_APB2_FZ : aliased DBGMCU_APB2_FZ_Register; end record with Volatile; for DBG_Peripheral use record DBGMCU_IDCODE at 16#0# range 0 .. 31; DBGMCU_CR at 16#4# range 0 .. 31; DBGMCU_APB1_FZ at 16#8# range 0 .. 31; DBGMCU_APB2_FZ at 16#C# range 0 .. 31; end record; -- Debug support DBG_Periph : aliased DBG_Peripheral with Import, Address => System'To_Address (16#E0042000#); end STM32_SVD.DBG;
charlie5/cBound
Ada
1,453
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces.C; with xcb.xcb_visualtype_t; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_visualtype_iterator_t is -- Item -- type Item is record data : access xcb.xcb_visualtype_t.Item; the_rem : aliased Interfaces.C.int; index : aliased Interfaces.C.int; end record; -- Item_Array -- type Item_Array is array (Interfaces.C.size_t range <>) of aliased xcb.xcb_visualtype_iterator_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_visualtype_iterator_t.Item, Element_Array => xcb.xcb_visualtype_iterator_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_visualtype_iterator_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_visualtype_iterator_t.Pointer, Element_Array => xcb.xcb_visualtype_iterator_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_visualtype_iterator_t;
twdroeger/ada-awa
Ada
21,598
ads
----------------------------------------------------------------------- -- AWA.Settings.Models -- AWA.Settings.Models ----------------------------------------------------------------------- -- File generated by ada-gen DO NOT MODIFY -- Template used: templates/model/package-spec.xhtml -- Ada Generator: https://ada-gen.googlecode.com/svn/trunk Revision 1095 ----------------------------------------------------------------------- -- Copyright (C) 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. ----------------------------------------------------------------------- pragma Warnings (Off); with ADO.Sessions; with ADO.Objects; with ADO.Statements; with ADO.SQL; with ADO.Schemas; with Ada.Containers.Vectors; with Ada.Strings.Unbounded; with Util.Beans.Objects; with Util.Beans.Basic.Lists; with AWA.Users.Models; pragma Warnings (On); package AWA.Settings.Models is pragma Style_Checks ("-mr"); type Setting_Ref is new ADO.Objects.Object_Ref with null record; type Global_Setting_Ref is new ADO.Objects.Object_Ref with null record; type User_Setting_Ref is new ADO.Objects.Object_Ref with null record; -- -------------------- -- The setting table defines all the possible settings -- that an application manages. This table is automatically -- populated when an application starts. It is not modified. -- -------------------- -- Create an object key for Setting. function Setting_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key; -- Create an object key for Setting from a string. -- Raises Constraint_Error if the string cannot be converted into the object key. function Setting_Key (Id : in String) return ADO.Objects.Object_Key; Null_Setting : constant Setting_Ref; function "=" (Left, Right : Setting_Ref'Class) return Boolean; -- Set the setting identifier. procedure Set_Id (Object : in out Setting_Ref; Value : in ADO.Identifier); -- Get the setting identifier. function Get_Id (Object : in Setting_Ref) return ADO.Identifier; -- Set the setting name. procedure Set_Name (Object : in out Setting_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String); procedure Set_Name (Object : in out Setting_Ref; Value : in String); -- Get the setting name. function Get_Name (Object : in Setting_Ref) return Ada.Strings.Unbounded.Unbounded_String; function Get_Name (Object : in Setting_Ref) return String; -- Load the entity identified by 'Id'. -- Raises the NOT_FOUND exception if it does not exist. procedure Load (Object : in out Setting_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier); -- Load the entity identified by 'Id'. -- Returns True in <b>Found</b> if the object was found and False if it does not exist. procedure Load (Object : in out Setting_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier; Found : out Boolean); -- Find and load the entity. overriding procedure Find (Object : in out Setting_Ref; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean); -- Save the entity. If the entity does not have an identifier, an identifier is allocated -- and it is inserted in the table. Otherwise, only data fields which have been changed -- are updated. overriding procedure Save (Object : in out Setting_Ref; Session : in out ADO.Sessions.Master_Session'Class); -- Delete the entity. overriding procedure Delete (Object : in out Setting_Ref; Session : in out ADO.Sessions.Master_Session'Class); overriding function Get_Value (From : in Setting_Ref; Name : in String) return Util.Beans.Objects.Object; -- Table definition SETTING_TABLE : constant ADO.Schemas.Class_Mapping_Access; -- Internal method to allocate the Object_Record instance overriding procedure Allocate (Object : in out Setting_Ref); -- Copy of the object. procedure Copy (Object : in Setting_Ref; Into : in out Setting_Ref); package Setting_Vectors is new Ada.Containers.Vectors (Index_Type => Natural, Element_Type => Setting_Ref, "=" => "="); subtype Setting_Vector is Setting_Vectors.Vector; procedure List (Object : in out Setting_Vector; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class); -- -------------------- -- The global setting holds some generic -- application configuration parameter -- which can be stored in the database. -- The global setting can be specific to a server. -- -------------------- -- Create an object key for Global_Setting. function Global_Setting_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key; -- Create an object key for Global_Setting from a string. -- Raises Constraint_Error if the string cannot be converted into the object key. function Global_Setting_Key (Id : in String) return ADO.Objects.Object_Key; Null_Global_Setting : constant Global_Setting_Ref; function "=" (Left, Right : Global_Setting_Ref'Class) return Boolean; -- Set the global setting identifier. procedure Set_Id (Object : in out Global_Setting_Ref; Value : in ADO.Identifier); -- Get the global setting identifier. function Get_Id (Object : in Global_Setting_Ref) return ADO.Identifier; -- Set the global setting value. procedure Set_Value (Object : in out Global_Setting_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String); procedure Set_Value (Object : in out Global_Setting_Ref; Value : in String); -- Get the global setting value. function Get_Value (Object : in Global_Setting_Ref) return Ada.Strings.Unbounded.Unbounded_String; function Get_Value (Object : in Global_Setting_Ref) return String; -- Get the global setting optimistic lock version. function Get_Version (Object : in Global_Setting_Ref) return Integer; -- Set the server to which this global setting applies. procedure Set_Server_Id (Object : in out Global_Setting_Ref; Value : in Integer); -- Get the server to which this global setting applies. function Get_Server_Id (Object : in Global_Setting_Ref) return Integer; -- Set the setting that corresponds to this global setting. procedure Set_Setting (Object : in out Global_Setting_Ref; Value : in AWA.Settings.Models.Setting_Ref'Class); -- Get the setting that corresponds to this global setting. function Get_Setting (Object : in Global_Setting_Ref) return AWA.Settings.Models.Setting_Ref'Class; -- Load the entity identified by 'Id'. -- Raises the NOT_FOUND exception if it does not exist. procedure Load (Object : in out Global_Setting_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier); -- Load the entity identified by 'Id'. -- Returns True in <b>Found</b> if the object was found and False if it does not exist. procedure Load (Object : in out Global_Setting_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier; Found : out Boolean); -- Find and load the entity. overriding procedure Find (Object : in out Global_Setting_Ref; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean); -- Save the entity. If the entity does not have an identifier, an identifier is allocated -- and it is inserted in the table. Otherwise, only data fields which have been changed -- are updated. overriding procedure Save (Object : in out Global_Setting_Ref; Session : in out ADO.Sessions.Master_Session'Class); -- Delete the entity. overriding procedure Delete (Object : in out Global_Setting_Ref; Session : in out ADO.Sessions.Master_Session'Class); overriding function Get_Value (From : in Global_Setting_Ref; Name : in String) return Util.Beans.Objects.Object; -- Table definition GLOBAL_SETTING_TABLE : constant ADO.Schemas.Class_Mapping_Access; -- Internal method to allocate the Object_Record instance overriding procedure Allocate (Object : in out Global_Setting_Ref); -- Copy of the object. procedure Copy (Object : in Global_Setting_Ref; Into : in out Global_Setting_Ref); package Global_Setting_Vectors is new Ada.Containers.Vectors (Index_Type => Natural, Element_Type => Global_Setting_Ref, "=" => "="); subtype Global_Setting_Vector is Global_Setting_Vectors.Vector; procedure List (Object : in out Global_Setting_Vector; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class); -- -------------------- -- The user setting holds the setting value for a given user. -- It is created the first time a user changes the default -- setting value. It is updated when the user modifies the setting. -- -------------------- -- Create an object key for User_Setting. function User_Setting_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key; -- Create an object key for User_Setting from a string. -- Raises Constraint_Error if the string cannot be converted into the object key. function User_Setting_Key (Id : in String) return ADO.Objects.Object_Key; Null_User_Setting : constant User_Setting_Ref; function "=" (Left, Right : User_Setting_Ref'Class) return Boolean; -- Set the user setting identifier. procedure Set_Id (Object : in out User_Setting_Ref; Value : in ADO.Identifier); -- Get the user setting identifier. function Get_Id (Object : in User_Setting_Ref) return ADO.Identifier; -- Set the setting value. procedure Set_Value (Object : in out User_Setting_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String); procedure Set_Value (Object : in out User_Setting_Ref; Value : in String); -- Get the setting value. function Get_Value (Object : in User_Setting_Ref) return Ada.Strings.Unbounded.Unbounded_String; function Get_Value (Object : in User_Setting_Ref) return String; -- Get the setting optimistic lock version. function Get_Version (Object : in User_Setting_Ref) return Integer; -- Set the setting that correspond to the value. procedure Set_Setting (Object : in out User_Setting_Ref; Value : in AWA.Settings.Models.Setting_Ref'Class); -- Get the setting that correspond to the value. function Get_Setting (Object : in User_Setting_Ref) return AWA.Settings.Models.Setting_Ref'Class; -- Set the user to which the setting value is associated. procedure Set_User (Object : in out User_Setting_Ref; Value : in AWA.Users.Models.User_Ref'Class); -- Get the user to which the setting value is associated. function Get_User (Object : in User_Setting_Ref) return AWA.Users.Models.User_Ref'Class; -- Load the entity identified by 'Id'. -- Raises the NOT_FOUND exception if it does not exist. procedure Load (Object : in out User_Setting_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier); -- Load the entity identified by 'Id'. -- Returns True in <b>Found</b> if the object was found and False if it does not exist. procedure Load (Object : in out User_Setting_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier; Found : out Boolean); -- Find and load the entity. overriding procedure Find (Object : in out User_Setting_Ref; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean); -- Save the entity. If the entity does not have an identifier, an identifier is allocated -- and it is inserted in the table. Otherwise, only data fields which have been changed -- are updated. overriding procedure Save (Object : in out User_Setting_Ref; Session : in out ADO.Sessions.Master_Session'Class); -- Delete the entity. overriding procedure Delete (Object : in out User_Setting_Ref; Session : in out ADO.Sessions.Master_Session'Class); overriding function Get_Value (From : in User_Setting_Ref; Name : in String) return Util.Beans.Objects.Object; -- Table definition USER_SETTING_TABLE : constant ADO.Schemas.Class_Mapping_Access; -- Internal method to allocate the Object_Record instance overriding procedure Allocate (Object : in out User_Setting_Ref); -- Copy of the object. procedure Copy (Object : in User_Setting_Ref; Into : in out User_Setting_Ref); private SETTING_NAME : aliased constant String := "awa_setting"; COL_0_1_NAME : aliased constant String := "id"; COL_1_1_NAME : aliased constant String := "name"; SETTING_DEF : aliased constant ADO.Schemas.Class_Mapping := (Count => 2, Table => SETTING_NAME'Access, Members => ( 1 => COL_0_1_NAME'Access, 2 => COL_1_1_NAME'Access) ); SETTING_TABLE : constant ADO.Schemas.Class_Mapping_Access := SETTING_DEF'Access; Null_Setting : constant Setting_Ref := Setting_Ref'(ADO.Objects.Object_Ref with null record); type Setting_Impl is new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER, Of_Class => SETTING_DEF'Access) with record Name : Ada.Strings.Unbounded.Unbounded_String; end record; type Setting_Access is access all Setting_Impl; overriding procedure Destroy (Object : access Setting_Impl); overriding procedure Find (Object : in out Setting_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean); overriding procedure Load (Object : in out Setting_Impl; Session : in out ADO.Sessions.Session'Class); procedure Load (Object : in out Setting_Impl; Stmt : in out ADO.Statements.Query_Statement'Class; Session : in out ADO.Sessions.Session'Class); overriding procedure Save (Object : in out Setting_Impl; Session : in out ADO.Sessions.Master_Session'Class); procedure Create (Object : in out Setting_Impl; Session : in out ADO.Sessions.Master_Session'Class); overriding procedure Delete (Object : in out Setting_Impl; Session : in out ADO.Sessions.Master_Session'Class); procedure Set_Field (Object : in out Setting_Ref'Class; Impl : out Setting_Access); GLOBAL_SETTING_NAME : aliased constant String := "awa_global_setting"; COL_0_2_NAME : aliased constant String := "id"; COL_1_2_NAME : aliased constant String := "value"; COL_2_2_NAME : aliased constant String := "version"; COL_3_2_NAME : aliased constant String := "server_id"; COL_4_2_NAME : aliased constant String := "setting_id"; GLOBAL_SETTING_DEF : aliased constant ADO.Schemas.Class_Mapping := (Count => 5, Table => GLOBAL_SETTING_NAME'Access, Members => ( 1 => COL_0_2_NAME'Access, 2 => COL_1_2_NAME'Access, 3 => COL_2_2_NAME'Access, 4 => COL_3_2_NAME'Access, 5 => COL_4_2_NAME'Access) ); GLOBAL_SETTING_TABLE : constant ADO.Schemas.Class_Mapping_Access := GLOBAL_SETTING_DEF'Access; Null_Global_Setting : constant Global_Setting_Ref := Global_Setting_Ref'(ADO.Objects.Object_Ref with null record); type Global_Setting_Impl is new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER, Of_Class => GLOBAL_SETTING_DEF'Access) with record Value : Ada.Strings.Unbounded.Unbounded_String; Version : Integer; Server_Id : Integer; Setting : AWA.Settings.Models.Setting_Ref; end record; type Global_Setting_Access is access all Global_Setting_Impl; overriding procedure Destroy (Object : access Global_Setting_Impl); overriding procedure Find (Object : in out Global_Setting_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean); overriding procedure Load (Object : in out Global_Setting_Impl; Session : in out ADO.Sessions.Session'Class); procedure Load (Object : in out Global_Setting_Impl; Stmt : in out ADO.Statements.Query_Statement'Class; Session : in out ADO.Sessions.Session'Class); overriding procedure Save (Object : in out Global_Setting_Impl; Session : in out ADO.Sessions.Master_Session'Class); procedure Create (Object : in out Global_Setting_Impl; Session : in out ADO.Sessions.Master_Session'Class); overriding procedure Delete (Object : in out Global_Setting_Impl; Session : in out ADO.Sessions.Master_Session'Class); procedure Set_Field (Object : in out Global_Setting_Ref'Class; Impl : out Global_Setting_Access); USER_SETTING_NAME : aliased constant String := "awa_user_setting"; COL_0_3_NAME : aliased constant String := "id"; COL_1_3_NAME : aliased constant String := "value"; COL_2_3_NAME : aliased constant String := "version"; COL_3_3_NAME : aliased constant String := "setting_id"; COL_4_3_NAME : aliased constant String := "user_id"; USER_SETTING_DEF : aliased constant ADO.Schemas.Class_Mapping := (Count => 5, Table => USER_SETTING_NAME'Access, Members => ( 1 => COL_0_3_NAME'Access, 2 => COL_1_3_NAME'Access, 3 => COL_2_3_NAME'Access, 4 => COL_3_3_NAME'Access, 5 => COL_4_3_NAME'Access) ); USER_SETTING_TABLE : constant ADO.Schemas.Class_Mapping_Access := USER_SETTING_DEF'Access; Null_User_Setting : constant User_Setting_Ref := User_Setting_Ref'(ADO.Objects.Object_Ref with null record); type User_Setting_Impl is new ADO.Objects.Object_Record (Key_Type => ADO.Objects.KEY_INTEGER, Of_Class => USER_SETTING_DEF'Access) with record Value : Ada.Strings.Unbounded.Unbounded_String; Version : Integer; Setting : AWA.Settings.Models.Setting_Ref; User : AWA.Users.Models.User_Ref; end record; type User_Setting_Access is access all User_Setting_Impl; overriding procedure Destroy (Object : access User_Setting_Impl); overriding procedure Find (Object : in out User_Setting_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean); overriding procedure Load (Object : in out User_Setting_Impl; Session : in out ADO.Sessions.Session'Class); procedure Load (Object : in out User_Setting_Impl; Stmt : in out ADO.Statements.Query_Statement'Class; Session : in out ADO.Sessions.Session'Class); overriding procedure Save (Object : in out User_Setting_Impl; Session : in out ADO.Sessions.Master_Session'Class); procedure Create (Object : in out User_Setting_Impl; Session : in out ADO.Sessions.Master_Session'Class); overriding procedure Delete (Object : in out User_Setting_Impl; Session : in out ADO.Sessions.Master_Session'Class); procedure Set_Field (Object : in out User_Setting_Ref'Class; Impl : out User_Setting_Access); end AWA.Settings.Models;
KLOC-Karsten/adaoled
Ada
3,096
adb
with GPIO; with SPI; with Interfaces; use Interfaces; with Ada.Text_IO; package body OLED_SH1106.Display is procedure Reset is begin GPIO.Write(OLED_RST, 1); delay 0.1; GPIO.Write(OLED_RST, 0); delay 0.1; GPIO.Write(OLED_RST, 1); delay 0.1; end Reset; procedure Write_Reg(Reg: Unsigned_8) is begin GPIO.Write(OLED_DC, 0); SPI.Write(Reg); end Write_Reg; procedure Start_Data is begin GPIO.Write(OLED_DC, 1); end Start_Data; procedure Write_Data(Data: Unsigned_8) is begin SPI.Write(Data); end Write_Data; procedure Init_Reg is begin Write_Reg(16#AE#); -- --turn off oled panel Write_Reg(16#02#); -- ---set low column address Write_Reg(16#10#); -- ---set high column address Write_Reg(16#40#); -- --set start line address Set Mapping RAM Display Start Line (0x00~0x3F) Write_Reg(16#81#); -- --set contrast control register Write_Reg(16#A0#); -- --Set SEG/Column Mapping Write_Reg(16#C0#); -- Set COM/Row Scan Direction Write_Reg(16#A6#); -- --set normal display Write_Reg(16#A8#); -- --set multiplex ratio(1 to 64) Write_Reg(16#3F#); -- --1/64 duty Write_Reg(16#D3#); -- -set display offset Shift Mapping RAM Counter (0x00~0x3F) Write_Reg(16#00#); -- -not offset Write_Reg(16#d5#); -- --set display clock divide ratio/oscillator frequency Write_Reg(16#80#); -- --set divide ratio, Set Clock as 100 Frames/Sec Write_Reg(16#D9#); -- --set pre-charge period Write_Reg(16#F1#); -- Set Pre-Charge as 15 Clocks & Discharge as 1 Clock Write_Reg(16#DA#); -- --set com pins hardware configuration Write_Reg(16#12#); Write_Reg(16#DB#); -- --set vcomh Write_Reg(16#40#); -- Set VCOM Deselect Level Write_Reg(16#20#); -- -Set Page Addressing Mode (0x00/0x01/0x02) Write_Reg(16#02#); -- Write_Reg(16#A4#); -- Disable Entire Display On (0xa4/0xa5) Write_Reg(16#A6#); -- Disable Inverse Display On (0xa6/a7) end Init_Reg; procedure Init_GPIOs is begin GPIO.Set_Mode(OLED_RST, GPIO.MODE_OUTPUT); GPIO.Set_Mode(OLED_DC, GPIO.MODE_OUTPUT); GPIO.Set_Mode(OLED_CS, GPIO.MODE_OUTPUT); GPIO.Set_Mode(KEY_UP_PIN, GPIO.MODE_INPUT); GPIO.Set_Mode(KEY_DOWN_PIN, GPIO.MODE_INPUT); GPIO.Set_Mode(KEY_LEFT_PIN, GPIO.MODE_INPUT); GPIO.Set_Mode(KEY_RIGHT_PIN, GPIO.MODE_INPUT); GPIO.Set_Mode(KEY_PRESS_PIN, GPIO.MODE_INPUT); GPIO.Set_Mode(KEY1_PIN, GPIO.MODE_INPUT); GPIO.Set_Mode(KEY2_PIN, GPIO.MODE_INPUT); GPIO.Set_Mode(KEY3_PIN, GPIO.MODE_INPUT); end Init_GPIOs; function Module_Init return Boolean is begin if GPIO.Init = 0 then return false; end if; Init_GPIOs; SPI.Start; SPI.Set_Bit_Order(SPI.BIT_ORDER_MSBFIRST); SPI.Set_Data_Mode(SPI.MODE0); SPI.Set_Clock_Divider(SPI.CLOCK_DIVIDER_128); SPI.Set_Chip_Select(SPI.CS0); SPI.Set_Chip_Select_Polarity(SPI.CS0, SPI.LOW); return true; end Module_Init; end OLED_SH1106.Display;
charlie5/lace
Ada
500
adb
package body Collada is function get_Matrix (From : in Float_array; Which : in Positive) return Matrix_4x4 is First : constant Positive := (Which - 1) * 16 + 1; the_Vector : constant math.Vector_16 := math.Vector_16 (From (First .. First + 15)); begin return math.to_Matrix_4x4 (the_Vector); end get_Matrix; function matrix_Count (From : in Float_array) return Natural is begin return From'Length / 16; end matrix_Count; end Collada;
stcarrez/ada-keystore
Ada
1,371
ads
----------------------------------------------------------------------- -- akt-commands-password-set -- Change the wallet password -- Copyright (C) 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. ----------------------------------------------------------------------- package AKT.Commands.Password.Set is type Command_Type is new AKT.Commands.Password.Command_Type with private; -- Change the wallet password. overriding procedure Execute (Command : in out Command_Type; Name : in String; Args : in Argument_List'Class; Context : in out Context_Type); private type Command_Type is new AKT.Commands.Password.Command_Type with null record; end AKT.Commands.Password.Set;
ytomino/gnat4drake
Ada
2,073
adb
with Ada.Unchecked_Deallocation; package body GNAT.Sockets is procedure Free is new Ada.Unchecked_Deallocation ( Ada.Streams.Stream_IO.File_Type, Socket_Type); function Addresses (E : Host_Entry_Type; N : Positive := 1) return Inet_Addr_Type is pragma Unreferenced (N); begin return ( Family => Family_Inet, Host_Name => Ada.Strings.Unbounded_Strings.To_Unbounded_String (String (E))); end Addresses; function Get_Host_By_Name (Name : String) return Host_Entry_Type is begin return Host_Entry_Type (Name); end Get_Host_By_Name; procedure Create_Socket ( Socket : out Socket_Type; Family : Family_Type := Family_Inet; Mode : Mode_Type := Socket_Stream) is pragma Unreferenced (Family); pragma Unreferenced (Mode); begin Socket := new Ada.Streams.Stream_IO.File_Type; end Create_Socket; procedure Close_Socket (Socket : in out Socket_Type) is begin Ada.Streams.Stream_IO.Close (Socket.all); Free (Socket); end Close_Socket; procedure Connect_Socket ( Socket : Socket_Type; Server : in out Sock_Addr_Type) is End_Point : constant Ada.Streams.Stream_IO.Sockets.End_Point := Ada.Streams.Stream_IO.Sockets.Resolve ( Ada.Strings.Unbounded_Strings.Constant_Reference ( Server.Addr.Host_Name).Element.all, Server.Port); begin Ada.Streams.Stream_IO.Sockets.Connect (Socket.all, End_Point); end Connect_Socket; procedure Receive_Socket ( Socket : Socket_Type; Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset; Flags : Request_Flag_Type := No_Request_Flag) is pragma Unreferenced (Flags); begin Ada.Streams.Stream_IO.Read (Socket.all, Item, Last); end Receive_Socket; function Stream (Socket : Socket_Type) return Stream_Access is begin return Ada.Streams.Stream_IO.Stream (Socket.all); end Stream; end GNAT.Sockets;
Fabien-Chouteau/shoot-n-loot
Ada
10,979
adb
-- Shoot'n'loot -- Copyright (c) 2020 Fabien Chouteau with GESTE_Config; use GESTE_Config; with GESTE.Grid; with GESTE.Tile_Bank; with GESTE.Sprite; with Monsters; with Chests; with Player; with Score_Display; with Sound; with Game_Assets; use Game_Assets; with Game_Assets.Tileset; with Game_Assets.Tileset_Collisions; with Game_Assets.level_0; with Game_Assets.level_1; with Game_Assets.level_2; with Game_Assets.level_3; with Game_Assets.level_4; with Game_Assets.level_5; with Game_Assets.level_6; with Game_Assets.level_7; with Game_Assets.level_8; with Game_Assets.Misc_Objects; use Game_Assets.Misc_Objects; package body Levels is Tile_Bank : aliased GESTE.Tile_Bank.Instance (Tileset.Tiles'Access, Tileset_Collisions.Tiles'Access, Palette'Access); Level_0_Back : aliased GESTE.Grid.Instance (Game_Assets.level_0.Back.Data'Access, Tile_Bank'Access); Level_0_Front : aliased GESTE.Grid.Instance (level_0.Front.Data'Access, Tile_Bank'Access); Level_0_Backcolor : aliased GESTE.Grid.Instance (level_0.Backcolor.Data'Access, Tile_Bank'Access); Level_1_Back : aliased GESTE.Grid.Instance (Game_Assets.level_1.Back.Data'Access, Tile_Bank'Access); Level_1_Front : aliased GESTE.Grid.Instance (level_1.Front.Data'Access, Tile_Bank'Access); Level_1_Backcolor : aliased GESTE.Grid.Instance (level_1.Backcolor.Data'Access, Tile_Bank'Access); Level_2_Back : aliased GESTE.Grid.Instance (level_2.Back.Data'Access, Tile_Bank'Access); Level_2_Front : aliased GESTE.Grid.Instance (level_2.Front.Data'Access, Tile_Bank'Access); Level_2_Backcolor : aliased GESTE.Grid.Instance (level_2.Backcolor.Data'Access, Tile_Bank'Access); Level_3_Back : aliased GESTE.Grid.Instance (level_3.Back.Data'Access, Tile_Bank'Access); Level_3_Front : aliased GESTE.Grid.Instance (level_3.Front.Data'Access, Tile_Bank'Access); Level_3_Backcolor : aliased GESTE.Grid.Instance (level_3.Backcolor.Data'Access, Tile_Bank'Access); Level_4_Back : aliased GESTE.Grid.Instance (level_4.Back.Data'Access, Tile_Bank'Access); Level_4_Front : aliased GESTE.Grid.Instance (level_4.Front.Data'Access, Tile_Bank'Access); Level_4_Backcolor : aliased GESTE.Grid.Instance (level_4.Backcolor.Data'Access, Tile_Bank'Access); Level_5_Back : aliased GESTE.Grid.Instance (level_5.Back.Data'Access, Tile_Bank'Access); Level_5_Front : aliased GESTE.Grid.Instance (level_5.Front.Data'Access, Tile_Bank'Access); Level_5_Backcolor : aliased GESTE.Grid.Instance (level_5.Backcolor.Data'Access, Tile_Bank'Access); Level_6_Back : aliased GESTE.Grid.Instance (level_6.Back.Data'Access, Tile_Bank'Access); Level_6_Front : aliased GESTE.Grid.Instance (level_6.Front.Data'Access, Tile_Bank'Access); Level_6_Backcolor : aliased GESTE.Grid.Instance (level_6.Backcolor.Data'Access, Tile_Bank'Access); Level_7_Back : aliased GESTE.Grid.Instance (level_7.Back.Data'Access, Tile_Bank'Access); Level_7_Front : aliased GESTE.Grid.Instance (level_7.Front.Data'Access, Tile_Bank'Access); Level_7_Backcolor : aliased GESTE.Grid.Instance (level_7.Backcolor.Data'Access, Tile_Bank'Access); Level_8_Back : aliased GESTE.Grid.Instance (level_8.Back.Data'Access, Tile_Bank'Access); Level_8_Front : aliased GESTE.Grid.Instance (level_8.Front.Data'Access, Tile_Bank'Access); Level_8_Backcolor : aliased GESTE.Grid.Instance (level_8.Backcolor.Data'Access, Tile_Bank'Access); Finish_Tile : constant Tile_Index := Item.Exit_Portal.Tile_Id; Finish_Position : GESTE.Pix_Point := (0, 0); Finish_Sprite : aliased GESTE.Sprite.Instance (Tile_Bank'Access, Finish_Tile); procedure Set_Finish (Obj : Object); procedure Move_To_Spawn (Obj : Object); ---------------- -- Set_Finish -- ---------------- procedure Set_Finish (Obj : Object) is begin Finish_Position := (Integer (Obj.X), Integer (Obj.Y) - Tile_Size); Finish_Sprite.Move (Finish_Position); Finish_Sprite.Set_Tile (Obj.Tile_Id); GESTE.Add (Finish_Sprite'Access, 2); Finish_Sprite.Enable_Collisions; end Set_Finish; ------------------- -- Move_To_Spawn -- ------------------- procedure Move_To_Spawn (Obj : Object) is begin Player.Spawn; Player.Move ((Integer (Obj.X) + Tile_Size / 2, Integer (Obj.Y) - Tile_Size / 2)); end Move_To_Spawn; ----------- -- Enter -- ----------- procedure Enter (Id : Level_Id) is begin GESTE.Remove_All; Score_Display.Init ((14 * Tile_Size, 15 * Tile_Size)); case Id is when Lvl_0 => Set_Finish (level_0.Markers.Finish); Move_To_Spawn (level_0.Markers.Spawn); Level_0_Backcolor.Move ((0, 0)); GESTE.Add (Level_0_Backcolor'Access, 0); Level_0_Back.Move ((0, 0)); Level_0_Back.Enable_Collisions; GESTE.Add (Level_0_Back'Access, 1); Level_0_Front.Move ((0, 0)); Level_0_Front.Enable_Collisions; GESTE.Add (Level_0_Front'Access, 3); Chests.Init (Game_Assets.level_0.Chests.Objects); Monsters.Init ((1 .. 0 => <>)); -- No monsters when Lvl_1 => Set_Finish (level_1.Markers.Finish); Move_To_Spawn (level_1.Markers.Spawn); Level_1_Backcolor.Move ((0, 0)); GESTE.Add (Level_1_Backcolor'Access, 0); Level_1_Back.Move ((0, 0)); Level_1_Back.Enable_Collisions; GESTE.Add (Level_1_Back'Access, 1); Level_1_Front.Move ((0, 0)); Level_1_Front.Enable_Collisions; GESTE.Add (Level_1_Front'Access, 3); Chests.Init (Game_Assets.level_1.Chests.Objects); Monsters.Init ((1 .. 0 => <>)); -- No monsters when Lvl_2 => Set_Finish (level_2.Markers.Finish); Move_To_Spawn (level_2.Markers.Spawn); Level_2_Backcolor.Move ((0, 0)); GESTE.Add (Level_2_Backcolor'Access, 0); Level_2_Back.Move ((0, 0)); Level_2_Back.Enable_Collisions; GESTE.Add (Level_2_Back'Access, 1); Level_2_Front.Move ((0, 0)); Level_2_Front.Enable_Collisions; GESTE.Add (Level_2_Front'Access, 3); Chests.Init (Game_Assets.level_2.Chests.Objects); Monsters.Init ((1 .. 0 => <>)); -- No monsters when Lvl_3 => Set_Finish (level_3.Markers.Finish); Move_To_Spawn (level_3.Markers.Spawn); Level_3_Backcolor.Move ((0, 0)); GESTE.Add (Level_3_Backcolor'Access, 0); Level_3_Back.Move ((0, 0)); Level_3_Back.Enable_Collisions; GESTE.Add (Level_3_Back'Access, 1); Level_3_Front.Move ((0, 0)); Level_3_Front.Enable_Collisions; GESTE.Add (Level_3_Front'Access, 3); Monsters.Init (Game_Assets.level_3.Monsters.Objects); Chests.Init (Game_Assets.level_3.Chests.Objects); when Lvl_4 => Set_Finish (level_4.Markers.Finish); Move_To_Spawn (level_4.Markers.Spawn); Level_4_Backcolor.Move ((0, 0)); GESTE.Add (Level_4_Backcolor'Access, 0); Level_4_Back.Move ((0, 0)); Level_4_Back.Enable_Collisions; GESTE.Add (Level_4_Back'Access, 1); Level_4_Front.Move ((0, 0)); Level_4_Front.Enable_Collisions; GESTE.Add (Level_4_Front'Access, 3); Chests.Init ((1 .. 0 => <>)); -- No Chests Monsters.Init (Game_Assets.level_4.Monsters.Objects); when Lvl_5 => Set_Finish (level_5.Markers.Finish); Move_To_Spawn (level_5.Markers.Spawn); Level_5_Backcolor.Move ((0, 0)); GESTE.Add (Level_5_Backcolor'Access, 0); Level_5_Back.Move ((0, 0)); Level_5_Back.Enable_Collisions; GESTE.Add (Level_5_Back'Access, 1); Level_5_Front.Move ((0, 0)); Level_5_Front.Enable_Collisions; GESTE.Add (Level_5_Front'Access, 3); Monsters.Init (Game_Assets.level_5.Monsters.Objects); Chests.Init (Game_Assets.level_5.Chests.Objects); when Lvl_6 => Set_Finish (level_6.Markers.Finish); Move_To_Spawn (level_6.Markers.Spawn); Level_6_Backcolor.Move ((0, 0)); GESTE.Add (Level_6_Backcolor'Access, 0); Level_6_Back.Move ((0, 0)); Level_6_Back.Enable_Collisions; GESTE.Add (Level_6_Back'Access, 1); Level_6_Front.Move ((0, 0)); Level_6_Front.Enable_Collisions; GESTE.Add (Level_6_Front'Access, 3); Monsters.Init (Game_Assets.level_6.Monsters.Objects); Chests.Init (Game_Assets.level_6.Chests.Objects); when Lvl_7 => Set_Finish (level_7.Markers.Finish); Move_To_Spawn (level_7.Markers.Spawn); Level_7_Backcolor.Move ((0, 0)); GESTE.Add (Level_7_Backcolor'Access, 0); Level_7_Back.Move ((0, 0)); Level_7_Back.Enable_Collisions; GESTE.Add (Level_7_Back'Access, 1); Level_7_Front.Move ((0, 0)); Level_7_Front.Enable_Collisions; GESTE.Add (Level_7_Front'Access, 3); Monsters.Init (Game_Assets.level_7.Monsters.Objects); Chests.Init (Game_Assets.level_7.Chests.Objects); when Lvl_8 => Set_Finish (level_8.Markers.Finish); Move_To_Spawn (level_8.Markers.Spawn); Level_8_Backcolor.Move ((0, 0)); GESTE.Add (Level_8_Backcolor'Access, 0); Level_8_Back.Move ((0, 0)); Level_8_Back.Enable_Collisions; GESTE.Add (Level_8_Back'Access, 1); Level_8_Front.Move ((0, 0)); Level_8_Front.Enable_Collisions; GESTE.Add (Level_8_Front'Access, 3); Monsters.Init (Game_Assets.level_8.Monsters.Objects); Chests.Init (Game_Assets.level_8.Chests.Objects); end case; end Enter; --------------- -- Open_Exit -- --------------- procedure Open_Exit is begin Finish_Sprite.Set_Tile (Finish_Tile); Finish_Sprite.Enable_Collisions (False); Sound.Play_Exit_Open; end Open_Exit; --------------- -- Test_Exit -- --------------- function Test_Exit (Pt : GESTE.Pix_Point) return Boolean is (Pt.X in Finish_Position.X .. Finish_Position.X + Tile_Size and then Pt.Y in Finish_Position.Y .. Finish_Position.Y + Tile_Size); end Levels;
reznikmm/matreshka
Ada
4,600
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Style.Distance_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Distance_Attribute_Node is begin return Self : Style_Distance_Attribute_Node do Matreshka.ODF_Style.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Style_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Style_Distance_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Distance_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Style_URI, Matreshka.ODF_String_Constants.Distance_Attribute, Style_Distance_Attribute_Node'Tag); end Matreshka.ODF_Style.Distance_Attributes;
reznikmm/matreshka
Ada
13,031
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with AMF.Elements; with AMF.Internals.Element_Collections; with AMF.Internals.Helpers; with AMF.Internals.Tables.UML_Attributes; with AMF.Visitors.UML_Iterators; with AMF.Visitors.UML_Visitors; with League.Strings.Internals; with Matreshka.Internals.Strings; package body AMF.Internals.UML_Includes is ------------------- -- Enter_Element -- ------------------- overriding procedure Enter_Element (Self : not null access constant UML_Include_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then AMF.Visitors.UML_Visitors.UML_Visitor'Class (Visitor).Enter_Include (AMF.UML.Includes.UML_Include_Access (Self), Control); end if; end Enter_Element; ------------------- -- Leave_Element -- ------------------- overriding procedure Leave_Element (Self : not null access constant UML_Include_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then AMF.Visitors.UML_Visitors.UML_Visitor'Class (Visitor).Leave_Include (AMF.UML.Includes.UML_Include_Access (Self), Control); end if; end Leave_Element; ------------------- -- Visit_Element -- ------------------- overriding procedure Visit_Element (Self : not null access constant UML_Include_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Iterator in AMF.Visitors.UML_Iterators.UML_Iterator'Class then AMF.Visitors.UML_Iterators.UML_Iterator'Class (Iterator).Visit_Include (Visitor, AMF.UML.Includes.UML_Include_Access (Self), Control); end if; end Visit_Element; ------------------ -- Get_Addition -- ------------------ overriding function Get_Addition (Self : not null access constant UML_Include_Proxy) return AMF.UML.Use_Cases.UML_Use_Case_Access is begin return AMF.UML.Use_Cases.UML_Use_Case_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Addition (Self.Element))); end Get_Addition; ------------------ -- Set_Addition -- ------------------ overriding procedure Set_Addition (Self : not null access UML_Include_Proxy; To : AMF.UML.Use_Cases.UML_Use_Case_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Addition (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Addition; ------------------------ -- Get_Including_Case -- ------------------------ overriding function Get_Including_Case (Self : not null access constant UML_Include_Proxy) return AMF.UML.Use_Cases.UML_Use_Case_Access is begin return AMF.UML.Use_Cases.UML_Use_Case_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Including_Case (Self.Element))); end Get_Including_Case; ------------------------ -- Set_Including_Case -- ------------------------ overriding procedure Set_Including_Case (Self : not null access UML_Include_Proxy; To : AMF.UML.Use_Cases.UML_Use_Case_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Including_Case (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Including_Case; ---------------- -- Get_Source -- ---------------- overriding function Get_Source (Self : not null access constant UML_Include_Proxy) return AMF.UML.Elements.Collections.Set_Of_UML_Element is begin return AMF.UML.Elements.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Source (Self.Element))); end Get_Source; ---------------- -- Get_Target -- ---------------- overriding function Get_Target (Self : not null access constant UML_Include_Proxy) return AMF.UML.Elements.Collections.Set_Of_UML_Element is begin return AMF.UML.Elements.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Target (Self.Element))); end Get_Target; ------------------------- -- Get_Related_Element -- ------------------------- overriding function Get_Related_Element (Self : not null access constant UML_Include_Proxy) return AMF.UML.Elements.Collections.Set_Of_UML_Element is begin return AMF.UML.Elements.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Related_Element (Self.Element))); end Get_Related_Element; --------------------------- -- Get_Client_Dependency -- --------------------------- overriding function Get_Client_Dependency (Self : not null access constant UML_Include_Proxy) return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency is begin return AMF.UML.Dependencies.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Client_Dependency (Self.Element))); end Get_Client_Dependency; ------------------------- -- Get_Name_Expression -- ------------------------- overriding function Get_Name_Expression (Self : not null access constant UML_Include_Proxy) return AMF.UML.String_Expressions.UML_String_Expression_Access is begin return AMF.UML.String_Expressions.UML_String_Expression_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Name_Expression (Self.Element))); end Get_Name_Expression; ------------------------- -- Set_Name_Expression -- ------------------------- overriding procedure Set_Name_Expression (Self : not null access UML_Include_Proxy; To : AMF.UML.String_Expressions.UML_String_Expression_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Name_Expression (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Name_Expression; ------------------- -- Get_Namespace -- ------------------- overriding function Get_Namespace (Self : not null access constant UML_Include_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access is begin return AMF.UML.Namespaces.UML_Namespace_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Namespace (Self.Element))); end Get_Namespace; ------------------------ -- Get_Qualified_Name -- ------------------------ overriding function Get_Qualified_Name (Self : not null access constant UML_Include_Proxy) return AMF.Optional_String is begin declare use type Matreshka.Internals.Strings.Shared_String_Access; Aux : constant Matreshka.Internals.Strings.Shared_String_Access := AMF.Internals.Tables.UML_Attributes.Internal_Get_Qualified_Name (Self.Element); begin if Aux = null then return (Is_Empty => True); else return (False, League.Strings.Internals.Create (Aux)); end if; end; end Get_Qualified_Name; ------------------------- -- All_Owning_Packages -- ------------------------- overriding function All_Owning_Packages (Self : not null access constant UML_Include_Proxy) return AMF.UML.Packages.Collections.Set_Of_UML_Package is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "All_Owning_Packages unimplemented"); raise Program_Error with "Unimplemented procedure UML_Include_Proxy.All_Owning_Packages"; return All_Owning_Packages (Self); end All_Owning_Packages; ----------------------------- -- Is_Distinguishable_From -- ----------------------------- overriding function Is_Distinguishable_From (Self : not null access constant UML_Include_Proxy; N : AMF.UML.Named_Elements.UML_Named_Element_Access; Ns : AMF.UML.Namespaces.UML_Namespace_Access) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented"); raise Program_Error with "Unimplemented procedure UML_Include_Proxy.Is_Distinguishable_From"; return Is_Distinguishable_From (Self, N, Ns); end Is_Distinguishable_From; --------------- -- Namespace -- --------------- overriding function Namespace (Self : not null access constant UML_Include_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Namespace unimplemented"); raise Program_Error with "Unimplemented procedure UML_Include_Proxy.Namespace"; return Namespace (Self); end Namespace; end AMF.Internals.UML_Includes;
Kurinkitos/Twizy-Security
Ada
259
adb
package body speedModule with SPARK_Mode is function speedtest(S : in Speed) return Boolean is begin if (0.0 <= S and then S <= 5.0) then return True; else return False; end if; end speedtest; end;
zhmu/ananas
Ada
193
ads
-- { dg-do compile } with Compile_Time1_Pkg; use Compile_Time1_Pkg; package Compile_Time1 is pragma Compile_Time_Error (Rec'Size /= Integer'Size, "wrong record size"); end Compile_Time1;
reznikmm/matreshka
Ada
4,687
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.Use_Soft_Page_Breaks_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Text_Use_Soft_Page_Breaks_Attribute_Node is begin return Self : Text_Use_Soft_Page_Breaks_Attribute_Node do Matreshka.ODF_Text.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Text_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Text_Use_Soft_Page_Breaks_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Use_Soft_Page_Breaks_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Text_URI, Matreshka.ODF_String_Constants.Use_Soft_Page_Breaks_Attribute, Text_Use_Soft_Page_Breaks_Attribute_Node'Tag); end Matreshka.ODF_Text.Use_Soft_Page_Breaks_Attributes;
reznikmm/webidl
Ada
7,135
ads
-- SPDX-FileCopyrightText: 2021 Max Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with League.Strings; with League.String_Vectors; with WebIDL.Arguments; with WebIDL.Constructors; with WebIDL.Enumerations; with WebIDL.Interfaces; with WebIDL.Interface_Members; with WebIDL.Types; package WebIDL.Factories is pragma Preelaborate; type Factory is limited interface; type Factory_Access is access all Factory'Class with Storage_Size => 0; not overriding function Enumeration (Self : in out Factory; Name : League.Strings.Universal_String; Values : League.String_Vectors.Universal_String_Vector) return not null WebIDL.Enumerations.Enumeration_Access is abstract; type Interface_Member_Vector is limited interface; type Interface_Member_Vector_Access is access all Interface_Member_Vector'Class with Storage_Size => 0; not overriding procedure Append (Self : in out Interface_Member_Vector; Item : not null WebIDL.Interface_Members.Interface_Member_Access) is abstract; not overriding function Interface_Members (Self : in out Factory) return not null Interface_Member_Vector_Access is abstract; type Argument_Vector is limited interface; type Argument_Vector_Access is access all Argument_Vector'Class with Storage_Size => 0; not overriding procedure Append (Self : in out Argument_Vector; Item : not null WebIDL.Arguments.Argument_Access) is abstract; not overriding function Arguments (Self : in out Factory) return not null Argument_Vector_Access is abstract; not overriding function New_Interface (Self : in out Factory; Name : League.Strings.Universal_String; Parent : League.Strings.Universal_String; Members : not null Interface_Member_Vector_Access) return not null WebIDL.Interfaces.Interface_Access is abstract; not overriding function Constructor (Self : in out Factory; Args : not null Argument_Vector_Access) return not null WebIDL.Constructors.Constructor_Access is abstract; not overriding function Argument (Self : in out Factory; Type_Def : WebIDL.Types.Type_Access; Name : League.Strings.Universal_String; Is_Options : Boolean; Has_Ellipsis : Boolean) return not null WebIDL.Arguments.Argument_Access is abstract; not overriding function Any (Self : in out Factory) return not null WebIDL.Types.Type_Access is abstract; not overriding function Object (Self : in out Factory) return not null WebIDL.Types.Type_Access is abstract; not overriding function Symbol (Self : in out Factory) return not null WebIDL.Types.Type_Access is abstract; not overriding function Undefined (Self : in out Factory) return not null WebIDL.Types.Type_Access is abstract; not overriding function Integer (Self : in out Factory; Is_Unsigned : Boolean; Long : Natural) return not null WebIDL.Types.Type_Access is abstract; not overriding function Float (Self : in out Factory; Restricted : Boolean; Double : Boolean) return not null WebIDL.Types.Type_Access is abstract; not overriding function Bool (Self : in out Factory) return not null WebIDL.Types.Type_Access is abstract; not overriding function Byte (Self : in out Factory) return not null WebIDL.Types.Type_Access is abstract; not overriding function Octet (Self : in out Factory) return not null WebIDL.Types.Type_Access is abstract; not overriding function BigInt (Self : in out Factory) return not null WebIDL.Types.Type_Access is abstract; not overriding function DOMString (Self : in out Factory) return not null WebIDL.Types.Type_Access is abstract; not overriding function ByteString (Self : in out Factory) return not null WebIDL.Types.Type_Access is abstract; not overriding function USVString (Self : in out Factory) return not null WebIDL.Types.Type_Access is abstract; not overriding function Sequence (Self : in out Factory; T : not null WebIDL.Types.Type_Access) return not null WebIDL.Types.Type_Access is abstract; -- The sequence<T> type is a parameterized type whose values are (possibly -- zero-length) lists of values of type T. not overriding function Frozen_Array (Self : in out Factory; T : not null WebIDL.Types.Type_Access) return not null WebIDL.Types.Type_Access is abstract; -- A frozen array type is a parameterized type whose values are references -- to objects that hold a fixed length array of unmodifiable values. The -- values in the array are of type T. not overriding function Observable_Array (Self : in out Factory; T : not null WebIDL.Types.Type_Access) return not null WebIDL.Types.Type_Access is abstract; -- An observable array type is a parameterized type whose values are -- references to a combination of a mutable list of objects of type T, as -- well as behavior to perform when author code modifies the contents of -- the list. not overriding function Record_Type (Self : in out Factory; Key : not null WebIDL.Types.Type_Access; Value : not null WebIDL.Types.Type_Access) return not null WebIDL.Types.Type_Access is abstract; -- A record type is a parameterized type whose values are ordered maps with -- keys that are instances of K and values that are instances of V. K must -- be one of DOMString, USVString, or ByteString. not overriding function Nullable (Self : in out Factory; T : not null WebIDL.Types.Type_Access) return not null WebIDL.Types.Type_Access is abstract; not overriding function Promise (Self : in out Factory; T : not null WebIDL.Types.Type_Access) return not null WebIDL.Types.Type_Access is abstract; -- A promise type is a parameterized type whose values are references -- to objects that “is used as a place holder for the eventual results -- of a deferred (and possibly asynchronous) computation result of an -- asynchronous operation”. not overriding function Buffer_Related_Type (Self : in out Factory; Name : League.Strings.Universal_String) return not null WebIDL.Types.Type_Access is abstract; type Union_Member_Vector is limited interface; type Union_Member_Vector_Access is access all Union_Member_Vector'Class with Storage_Size => 0; not overriding procedure Append (Self : in out Union_Member_Vector; Item : not null WebIDL.Types.Type_Access) is abstract; not overriding function Union_Members (Self : in out Factory) return not null Union_Member_Vector_Access is abstract; not overriding function Union (Self : in out Factory; T : not null Union_Member_Vector_Access) return not null WebIDL.Types.Type_Access is abstract; end WebIDL.Factories;
AdaCore/gpr
Ada
20
ads
package T is end T;
charlie5/cBound
Ada
1,385
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces.C; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_keysym_iterator_t is -- Item -- type Item is record data : access xcb.xcb_keysym_t; the_rem : aliased Interfaces.C.int; index : aliased Interfaces.C.int; end record; -- Item_Array -- type Item_Array is array (Interfaces.C.size_t range <>) of aliased xcb.xcb_keysym_iterator_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_keysym_iterator_t.Item, Element_Array => xcb.xcb_keysym_iterator_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_keysym_iterator_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_keysym_iterator_t.Pointer, Element_Array => xcb.xcb_keysym_iterator_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_keysym_iterator_t;
reznikmm/matreshka
Ada
4,632
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.Border_Color_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Table_Border_Color_Attribute_Node is begin return Self : Table_Border_Color_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_Border_Color_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Border_Color_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Table_URI, Matreshka.ODF_String_Constants.Border_Color_Attribute, Table_Border_Color_Attribute_Node'Tag); end Matreshka.ODF_Table.Border_Color_Attributes;
zhmu/ananas
Ada
41,526
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- G N A T . C A L E N D A R . T I M E _ I O -- -- -- -- B o d y -- -- -- -- Copyright (C) 1999-2022, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Ada.Characters.Handling; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Text_IO; with GNAT.Case_Util; package body GNAT.Calendar.Time_IO is type Month_Name is (January, February, March, April, May, June, July, August, September, October, November, December); function Month_Name_To_Number (Str : String) return Ada.Calendar.Month_Number; -- Converts a string that contains an abbreviated month name to a month -- number. Constraint_Error is raised if Str is not a valid month name. -- Comparison is case insensitive type Padding_Mode is (None, Zero, Space); type Sec_Number is mod 2 ** 64; -- Type used to compute the number of seconds since 01/01/1970. A 32 bit -- number will cover only a period of 136 years. This means that for date -- past 2106 the computation is not possible. A 64 bits number should be -- enough for a very large period of time. ----------------------- -- Local Subprograms -- ----------------------- function Image_Helper (Date : Ada.Calendar.Time; Picture : Picture_String; Time_Zone : Time_Zones.Time_Offset) return String; -- This is called by the two exported Image functions. It uses the local -- time zone for its computations, but uses Time_Zone when interpreting the -- "%:::z" tag. function Am_Pm (H : Natural) return String; -- Return AM or PM depending on the hour H function Hour_12 (H : Natural) return Positive; -- Convert a 1-24h format to a 0-12 hour format function Image (Str : String; Length : Natural := 0) return String; -- Return Str capitalized and cut to length number of characters. If -- length is 0, then no cut operation is performed. function Image (N : Sec_Number; Padding : Padding_Mode := Zero; Length : Natural := 0) return String; -- Return image of N. This number is eventually padded with zeros or spaces -- depending of the length required. If length is 0 then no padding occurs. function Image (N : Natural; Padding : Padding_Mode := Zero; Length : Natural := 0) return String; -- As above with N provided in Integer format procedure Parse_ISO_8601 (Date : String; Time : out Ada.Calendar.Time; Success : out Boolean); -- Subsidiary of function Value. It parses the string Date, interpreted as -- an ISO 8601 time representation, and returns corresponding Time value. -- Success is set to False when the string is not a supported ISO 8601 -- date. -- -- Examples: -- -- 2017-04-14T14:47:06 20170414T14:47:06 20170414T144706 -- 2017-04-14T14:47:06,12 20170414T14:47:06.12 -- 2017-04-14T19:47:06+05 20170414T09:00:06-05:47 ----------- -- Am_Pm -- ----------- function Am_Pm (H : Natural) return String is begin if H = 0 or else H > 12 then return "PM"; else return "AM"; end if; end Am_Pm; ------------- -- Hour_12 -- ------------- function Hour_12 (H : Natural) return Positive is begin if H = 0 then return 12; elsif H <= 12 then return H; else -- H > 12 return H - 12; end if; end Hour_12; ----------- -- Image -- ----------- function Image (Str : String; Length : Natural := 0) return String is use Ada.Characters.Handling; Local : constant String := To_Upper (Str (Str'First)) & To_Lower (Str (Str'First + 1 .. Str'Last)); begin if Length = 0 then return Local; else return Local (1 .. Length); end if; end Image; ----------- -- Image -- ----------- function Image (N : Natural; Padding : Padding_Mode := Zero; Length : Natural := 0) return String is begin return Image (Sec_Number (N), Padding, Length); end Image; ----------- -- Image -- ----------- function Image (N : Sec_Number; Padding : Padding_Mode := Zero; Length : Natural := 0) return String is function Pad_Char return String; -------------- -- Pad_Char -- -------------- function Pad_Char return String is begin case Padding is when None => return ""; when Zero => return "00"; when Space => return " "; end case; end Pad_Char; -- Local Declarations NI : constant String := Sec_Number'Image (N); NIP : constant String := Pad_Char & NI (2 .. NI'Last); -- Start of processing for Image begin if Length = 0 or else Padding = None then return NI (2 .. NI'Last); else return NIP (NIP'Last - Length + 1 .. NIP'Last); end if; end Image; ----------- -- Image -- ----------- function Image (Date : Ada.Calendar.Time; Picture : Picture_String; Time_Zone : Time_Zones.Time_Offset) return String is -- We subtract off the local time zone, and add in the requested -- Time_Zone, and then pass it on to Image_Helper, which uses the -- local time zone. use Time_Zones; Local_TZ : constant Time_Offset := Local_Time_Offset (Date); Minute_Offset : constant Integer := Integer (Time_Zone - Local_TZ); Second_Offset : constant Integer := Minute_Offset * 60; begin return Image_Helper (Date + Duration (Second_Offset), Picture, Time_Zone); end Image; ----------- -- Image -- ----------- function Image (Date : Ada.Calendar.Time; Picture : Picture_String) return String is use Time_Zones; Local_TZ : constant Time_Offset := Local_Time_Offset (Date); begin return Image_Helper (Date, Picture, Local_TZ); end Image; ------------------ -- Image_Helper -- ------------------ function Image_Helper (Date : Ada.Calendar.Time; Picture : Picture_String; Time_Zone : Time_Zones.Time_Offset) return String is Padding : Padding_Mode := Zero; -- Padding is set for one directive Result : Unbounded_String; Year : Year_Number; Month : Month_Number; Day : Day_Number; Hour : Hour_Number; Minute : Minute_Number; Second : Second_Number; Sub_Second : Second_Duration; P : Positive; begin -- Get current time in split format Split (Date, Year, Month, Day, Hour, Minute, Second, Sub_Second); -- Null picture string is error if Picture = "" then raise Picture_Error with "null picture string"; end if; -- Loop through characters of picture string, building result Result := Null_Unbounded_String; P := Picture'First; while P <= Picture'Last loop -- A directive has the following format "%[-_]." if Picture (P) = '%' then Padding := Zero; if P = Picture'Last then raise Picture_Error with "picture string ends with '%"; end if; -- Check for GNU extension to change the padding if Picture (P + 1) = '-' then Padding := None; P := P + 1; elsif Picture (P + 1) = '_' then Padding := Space; P := P + 1; end if; if P = Picture'Last then raise Picture_Error with "picture string ends with '- or '_"; end if; case Picture (P + 1) is -- Literal % when '%' => Result := Result & '%'; -- A newline when 'n' => Result := Result & ASCII.LF; -- A horizontal tab when 't' => Result := Result & ASCII.HT; -- Hour (00..23) when 'H' => Result := Result & Image (Hour, Padding, 2); -- Hour (01..12) when 'I' => Result := Result & Image (Hour_12 (Hour), Padding, 2); -- Hour ( 0..23) when 'k' => Result := Result & Image (Hour, Space, 2); -- Hour ( 1..12) when 'l' => Result := Result & Image (Hour_12 (Hour), Space, 2); -- Minute (00..59) when 'M' => Result := Result & Image (Minute, Padding, 2); -- AM/PM when 'p' => Result := Result & Am_Pm (Hour); -- Time, 12-hour (hh:mm:ss [AP]M) when 'r' => Result := Result & Image (Hour_12 (Hour), Padding, Length => 2) & ':' & Image (Minute, Padding, Length => 2) & ':' & Image (Second, Padding, Length => 2) & ' ' & Am_Pm (Hour); -- Seconds since 1970-01-01 00:00:00 UTC -- (a nonstandard extension) when 's' => declare -- Compute the number of seconds using Ada.Calendar.Time -- values rather than Julian days to account for Daylight -- Savings Time. Neg : Boolean := False; Sec : Duration := Date - Time_Of (1970, 1, 1, 0.0); begin -- Avoid rounding errors and perform special processing -- for dates earlier than the Unix Epoc. if Sec > 0.0 then Sec := Sec - 0.5; elsif Sec < 0.0 then Neg := True; Sec := abs (Sec + 0.5); end if; -- Prepend a minus sign to the result since Sec_Number -- cannot handle negative numbers. if Neg then Result := Result & "-" & Image (Sec_Number (Sec), None); else Result := Result & Image (Sec_Number (Sec), None); end if; end; -- Second (00..59) when 'S' => Result := Result & Image (Second, Padding, Length => 2); -- Milliseconds (3 digits) -- Microseconds (6 digits) -- Nanoseconds (9 digits) when 'i' | 'e' | 'o' => declare Sub_Sec : constant Long_Integer := Long_Integer (Sub_Second * 1_000_000_000); Img1 : constant String := Sub_Sec'Img; Img2 : constant String := "00000000" & Img1 (Img1'First + 1 .. Img1'Last); Nanos : constant String := Img2 (Img2'Last - 8 .. Img2'Last); begin case Picture (P + 1) is when 'i' => Result := Result & Nanos (Nanos'First .. Nanos'First + 2); when 'e' => Result := Result & Nanos (Nanos'First .. Nanos'First + 5); when 'o' => Result := Result & Nanos; when others => null; end case; end; -- Time, 24-hour (hh:mm:ss) when 'T' => Result := Result & Image (Hour, Padding, Length => 2) & ':' & Image (Minute, Padding, Length => 2) & ':' & Image (Second, Padding, Length => 2); -- Time zone. Append "+hh", "-hh", "+hh:mm", or "-hh:mm", as -- appropriate. when ':' => declare use type Time_Zones.Time_Offset; TZ_Form : constant Picture_String := "%:::z"; TZ : constant Natural := Natural (abs Time_Zone); begin if P + TZ_Form'Length - 1 <= Picture'Last and then Picture (P .. P + TZ_Form'Length - 1) = "%:::z" then if Time_Zone >= 0 then Result := Result & "+"; else Result := Result & "-"; end if; Result := Result & Image (Integer (TZ / 60), Padding, Length => 2); if TZ mod 60 /= 0 then Result := Result & ":"; Result := Result & Image (TZ mod 60, Padding, Length => 2); end if; P := P + TZ_Form'Length - 2; -- will add 2 below -- We do not support any of the other standard GNU -- time-zone formats (%z, %:z, %::z, %Z). else raise Picture_Error with "unsupported picture format"; end if; end; -- Locale's abbreviated weekday name (Sun..Sat) when 'a' => Result := Result & Image (Day_Name'Image (Day_Of_Week (Date)), 3); -- Locale's full weekday name, variable length -- (Sunday..Saturday) when 'A' => Result := Result & Image (Day_Name'Image (Day_Of_Week (Date))); -- Locale's abbreviated month name (Jan..Dec) when 'b' | 'h' => Result := Result & Image (Month_Name'Image (Month_Name'Val (Month - 1)), 3); -- Locale's full month name, variable length -- (January..December). when 'B' => Result := Result & Image (Month_Name'Image (Month_Name'Val (Month - 1))); -- Locale's date and time (Sat Nov 04 12:02:33 EST 1989) when 'c' => case Padding is when Zero => Result := Result & Image (Date, "%a %b %d %T %Y"); when Space => Result := Result & Image (Date, "%a %b %_d %_T %Y"); when None => Result := Result & Image (Date, "%a %b %-d %-T %Y"); end case; -- Day of month (01..31) when 'd' => Result := Result & Image (Day, Padding, 2); -- Date (mm/dd/yy) when 'D' | 'x' => Result := Result & Image (Month, Padding, 2) & '/' & Image (Day, Padding, 2) & '/' & Image (Year, Padding, 2); -- Day of year (001..366) when 'j' => Result := Result & Image (Day_In_Year (Date), Padding, 3); -- Month (01..12) when 'm' => Result := Result & Image (Month, Padding, 2); -- Week number of year with Sunday as first day of week -- (00..53) when 'U' => declare Offset : constant Natural := (Julian_Day (Year, 1, 1) + 1) mod 7; Week : constant Natural := 1 + ((Day_In_Year (Date) - 1) + Offset) / 7; begin Result := Result & Image (Week, Padding, 2); end; -- Day of week (0..6) with 0 corresponding to Sunday when 'w' => declare DOW : constant Natural range 0 .. 6 := (if Day_Of_Week (Date) = Sunday then 0 else Day_Name'Pos (Day_Of_Week (Date))); begin Result := Result & Image (DOW, Length => 1); end; -- Week number of year with Monday as first day of week -- (00..53) when 'W' => Result := Result & Image (Week_In_Year (Date), Padding, 2); -- Last two digits of year (00..99) when 'y' => declare Y : constant Natural := Year - (Year / 100) * 100; begin Result := Result & Image (Y, Padding, 2); end; -- Year (1970...) when 'Y' => Result := Result & Image (Year, None, 4); when others => raise Picture_Error with "unknown format character in picture string"; end case; -- Skip past % and format character P := P + 2; -- Character other than % is copied into the result else Result := Result & Picture (P); P := P + 1; end if; end loop; return To_String (Result); end Image_Helper; -------------------------- -- Month_Name_To_Number -- -------------------------- function Month_Name_To_Number (Str : String) return Ada.Calendar.Month_Number is subtype String3 is String (1 .. 3); Abbrev_Upper_Month_Names : constant array (Ada.Calendar.Month_Number) of String3 := ["JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"]; -- Short version of the month names, used when parsing date strings S : String := Str; begin GNAT.Case_Util.To_Upper (S); for J in Abbrev_Upper_Month_Names'Range loop if Abbrev_Upper_Month_Names (J) = S then return J; end if; end loop; return Abbrev_Upper_Month_Names'First; end Month_Name_To_Number; -------------------- -- Parse_ISO_8601 -- -------------------- procedure Parse_ISO_8601 (Date : String; Time : out Ada.Calendar.Time; Success : out Boolean) is pragma Unsuppress (All_Checks); -- This is necessary because the run-time library is usually compiled -- with checks suppressed, and we are relying on constraint checks in -- this code to catch syntax errors in the Date string (e.g. out of -- bounds slices). Index : Positive := Date'First; -- The current character scan index. After a call to Advance, Index -- points to the next character. Wrong_Syntax : exception; -- An exception used to signal that the scan pointer has reached an -- unexpected character in the source string, or if premature -- end-of-source was reached. procedure Advance; pragma Inline (Advance); -- Past the current character of Date procedure Advance_Digits (Num_Digits : Positive); pragma Inline (Advance_Digits); -- Past the given number of digit characters function Scan_Day return Day_Number; pragma Inline (Scan_Day); -- Scan the two digits of a day number and return its value function Scan_Hour return Hour_Number; pragma Inline (Scan_Hour); -- Scan the two digits of an hour number and return its value function Scan_Minute return Minute_Number; pragma Inline (Scan_Minute); -- Scan the two digits of a minute number and return its value function Scan_Month return Month_Number; pragma Inline (Scan_Month); -- Scan the two digits of a month number and return its value function Scan_Second return Second_Number; pragma Inline (Scan_Second); -- Scan the two digits of a second number and return its value function Scan_Separator (Expected_Symbol : Character) return Boolean; pragma Inline (Scan_Separator); -- If the current symbol matches the Expected_Symbol then advance the -- scanner index and return True; otherwise do nothing and return False procedure Scan_Separator (Required : Boolean; Separator : Character); pragma Inline (Scan_Separator); -- If Required then check that the current character matches Separator -- and advance the scanner index; if not Required then do nothing. function Scan_Subsecond return Second_Duration; pragma Inline (Scan_Subsecond); -- Scan all the digits of a subsecond number and return its value function Scan_Year return Year_Number; pragma Inline (Scan_Year); -- Scan the four digits of a year number and return its value function Symbol return Character; pragma Inline (Symbol); -- Return the current character being scanned ------------- -- Advance -- ------------- procedure Advance is begin -- Signal the end of the source string. This stops a complex scan -- by bottoming up any recursive calls till control reaches routine -- Scan, which handles the exception. if Index > Date'Last then raise Wrong_Syntax; -- Advance the scan pointer as long as there are characters to scan, -- in other words, the scan pointer has not passed the end of the -- source string. else Index := Index + 1; end if; end Advance; -------------------- -- Advance_Digits -- -------------------- procedure Advance_Digits (Num_Digits : Positive) is begin for J in 1 .. Num_Digits loop if Symbol not in '0' .. '9' then raise Wrong_Syntax; end if; Advance; -- past digit end loop; end Advance_Digits; -------------- -- Scan_Day -- -------------- function Scan_Day return Day_Number is From : constant Positive := Index; begin Advance_Digits (Num_Digits => 2); return Day_Number'Value (Date (From .. Index - 1)); end Scan_Day; --------------- -- Scan_Hour -- --------------- function Scan_Hour return Hour_Number is From : constant Positive := Index; begin Advance_Digits (Num_Digits => 2); return Hour_Number'Value (Date (From .. Index - 1)); end Scan_Hour; ----------------- -- Scan_Minute -- ----------------- function Scan_Minute return Minute_Number is From : constant Positive := Index; begin Advance_Digits (Num_Digits => 2); return Minute_Number'Value (Date (From .. Index - 1)); end Scan_Minute; ---------------- -- Scan_Month -- ---------------- function Scan_Month return Month_Number is From : constant Positive := Index; begin Advance_Digits (Num_Digits => 2); return Month_Number'Value (Date (From .. Index - 1)); end Scan_Month; ----------------- -- Scan_Second -- ----------------- function Scan_Second return Second_Number is From : constant Positive := Index; begin Advance_Digits (Num_Digits => 2); return Second_Number'Value (Date (From .. Index - 1)); end Scan_Second; -------------------- -- Scan_Separator -- -------------------- function Scan_Separator (Expected_Symbol : Character) return Boolean is begin if Symbol = Expected_Symbol then Advance; return True; else return False; end if; end Scan_Separator; -------------------- -- Scan_Separator -- -------------------- procedure Scan_Separator (Required : Boolean; Separator : Character) is begin if Required then if Symbol /= Separator then raise Wrong_Syntax; end if; Advance; -- Past the separator end if; end Scan_Separator; -------------------- -- Scan_Subsecond -- -------------------- function Scan_Subsecond return Second_Duration is From : constant Positive := Index; begin Advance_Digits (Num_Digits => 1); while Index <= Date'Length and then Symbol in '0' .. '9' loop Advance; end loop; return Second_Duration'Value ("0." & Date (From .. Index - 1)); end Scan_Subsecond; --------------- -- Scan_Year -- --------------- function Scan_Year return Year_Number is From : constant Positive := Index; begin Advance_Digits (Num_Digits => 4); return Year_Number'Value (Date (From .. Index - 1)); end Scan_Year; ------------ -- Symbol -- ------------ function Symbol return Character is begin -- Signal the end of the source string. This stops a complex scan by -- bottoming up any recursive calls till control reaches routine Scan -- which handles the exception. Certain scanning scenarios may handle -- this exception on their own. if Index > Date'Last then raise Wrong_Syntax; else return Date (Index); end if; end Symbol; -- Local variables use Time_Zones; Date_Separator : constant Character := '-'; Hour_Separator : constant Character := ':'; Day : Day_Number; Month : Month_Number; Year : Year_Number; Hour : Hour_Number := 0; Minute : Minute_Number := 0; Second : Second_Number := 0; Subsec : Second_Duration := 0.0; Time_Zone_Seen : Boolean := False; Time_Zone_Offset : Time_Offset; -- Valid only if Time_Zone_Seen Sep_Required : Boolean := False; -- True if a separator is seen (and therefore required after it!) subtype Sign_Type is Character with Predicate => Sign_Type in '+' | '-'; -- Start of processing for Parse_ISO_8601 begin -- Parse date Year := Scan_Year; Sep_Required := Scan_Separator (Date_Separator); Month := Scan_Month; Scan_Separator (Sep_Required, Date_Separator); Day := Scan_Day; if Index < Date'Last and then Symbol = 'T' then Advance; -- Parse time Hour := Scan_Hour; Sep_Required := Scan_Separator (Hour_Separator); Minute := Scan_Minute; Scan_Separator (Sep_Required, Hour_Separator); Second := Scan_Second; -- [ ('.' | ',') s{s} ] if Index <= Date'Last then -- A decimal fraction shall have at least one digit, and has as -- many digits as supported by the underlying implementation. -- The valid decimal separators are those specified in ISO 31-0, -- i.e. the comma [,] or full stop [.]. Of these, the comma is -- the preferred separator of ISO-8601. if Symbol = ',' or else Symbol = '.' then Advance; -- past decimal separator Subsec := Scan_Subsecond; end if; end if; -- [ ('Z' | ('+'|'-')hh':'mm) ] if Index <= Date'Last then Time_Zone_Seen := Symbol in 'Z' | Sign_Type; -- Suffix 'Z' signifies that this is UTC time (time zone 0) if Symbol = 'Z' then Time_Zone_Offset := 0; Advance; -- Difference between local time and UTC: It shall be expressed -- as positive (i.e. with the leading plus sign [+]) if the local -- time is ahead of or equal to UTC of day and as negative (i.e. -- with the leading minus sign [-]) if it is behind UTC of day. -- The minutes time element of the difference may only be omitted -- if the difference between the time scales is exactly an -- integral number of hours. elsif Symbol in Sign_Type then declare Time_Zone_Sign : constant Sign_Type := Symbol; Time_Zone_Hour : Hour_Number; Time_Zone_Minute : Minute_Number; begin Advance; Time_Zone_Hour := Scan_Hour; -- Past ':' if Index < Date'Last and then Symbol = Hour_Separator then Advance; Time_Zone_Minute := Scan_Minute; else Time_Zone_Minute := 0; end if; -- Compute Time_Zone_Offset Time_Zone_Offset := Time_Offset (Time_Zone_Hour * 60 + Time_Zone_Minute); case Time_Zone_Sign is when '+' => null; when '-' => Time_Zone_Offset := -Time_Zone_Offset; end case; end; else raise Wrong_Syntax; end if; end if; end if; -- Check for trailing characters if Index /= Date'Length + 1 then raise Wrong_Syntax; end if; -- If a time zone was specified, use Ada.Calendar.Formatting.Time_Of, -- and specify the time zone. Otherwise, call GNAT.Calendar.Time_Of, -- which uses local time. if Time_Zone_Seen then Time := Ada.Calendar.Formatting.Time_Of (Year, Month, Day, Hour, Minute, Second, Subsec, Time_Zone => Time_Zone_Offset); else Time := GNAT.Calendar.Time_Of (Year, Month, Day, Hour, Minute, Second, Subsec); end if; -- Notify that the input string was successfully parsed Success := True; exception when Wrong_Syntax | Constraint_Error => -- If constraint check fails, we want to behave the same as -- Wrong_Syntax; we want the caller (Value) to try other -- allowed syntaxes. Time := Time_Of (Year_Number'First, Month_Number'First, Day_Number'First); Success := False; end Parse_ISO_8601; ----------- -- Value -- ----------- function Value (Date : String) return Ada.Calendar.Time is pragma Unsuppress (All_Checks); -- see comment in Parse_ISO_8601 D : String (1 .. 21); D_Length : constant Natural := Date'Length; Year : Year_Number; Month : Month_Number; Day : Day_Number; Hour : Hour_Number; Minute : Minute_Number; Second : Second_Number; procedure Extract_Date (Year : out Year_Number; Month : out Month_Number; Day : out Day_Number; Time_Start : out Natural); -- Try and extract a date value from string D. Time_Start is set to the -- first character that could be the start of time data. procedure Extract_Time (Index : Positive; Hour : out Hour_Number; Minute : out Minute_Number; Second : out Second_Number; Check_Space : Boolean := False); -- Try and extract a time value from string D starting from position -- Index. Set Check_Space to True to check whether the character at -- Index - 1 is a space. Raise Constraint_Error if the portion of D -- corresponding to the date is not well formatted. ------------------ -- Extract_Date -- ------------------ procedure Extract_Date (Year : out Year_Number; Month : out Month_Number; Day : out Day_Number; Time_Start : out Natural) is begin if D (3) = '-' or else D (3) = '/' then if D_Length = 8 or else D_Length = 17 then -- Formats are "yy*mm*dd" or "yy*mm*dd hh:mm:ss" if D (6) /= D (3) then raise Constraint_Error; end if; Year := Year_Number'Value ("20" & D (1 .. 2)); Month := Month_Number'Value (D (4 .. 5)); Day := Day_Number'Value (D (7 .. 8)); Time_Start := 10; elsif D_Length = 10 or else D_Length = 19 then -- Formats are "mm*dd*yyyy" or "mm*dd*yyyy hh:mm:ss" if D (6) /= D (3) then raise Constraint_Error; end if; Year := Year_Number'Value (D (7 .. 10)); Month := Month_Number'Value (D (1 .. 2)); Day := Day_Number'Value (D (4 .. 5)); Time_Start := 12; elsif D_Length = 11 or else D_Length = 20 then -- Formats are "dd*mmm*yyyy" or "dd*mmm*yyyy hh:mm:ss" if D (7) /= D (3) then raise Constraint_Error; end if; Year := Year_Number'Value (D (8 .. 11)); Month := Month_Name_To_Number (D (4 .. 6)); Day := Day_Number'Value (D (1 .. 2)); Time_Start := 13; else raise Constraint_Error; end if; elsif D (3) = ' ' then if D_Length = 11 or else D_Length = 20 then -- Possible formats are "dd mmm yyyy", "dd mmm yyyy hh:mm:ss" if D (7) /= ' ' then raise Constraint_Error; end if; Year := Year_Number'Value (D (8 .. 11)); Month := Month_Name_To_Number (D (4 .. 6)); Day := Day_Number'Value (D (1 .. 2)); Time_Start := 13; else raise Constraint_Error; end if; else if D_Length = 8 or else D_Length = 17 then -- Possible formats are "yyyymmdd" or "yyyymmdd hh:mm:ss" Year := Year_Number'Value (D (1 .. 4)); Month := Month_Number'Value (D (5 .. 6)); Day := Day_Number'Value (D (7 .. 8)); Time_Start := 10; elsif D_Length = 10 or else D_Length = 19 then -- Possible formats are "yyyy*mm*dd" or "yyyy*mm*dd hh:mm:ss" if (D (5) /= '-' and then D (5) /= '/') or else D (8) /= D (5) then raise Constraint_Error; end if; Year := Year_Number'Value (D (1 .. 4)); Month := Month_Number'Value (D (6 .. 7)); Day := Day_Number'Value (D (9 .. 10)); Time_Start := 12; elsif D_Length = 11 or else D_Length = 20 then -- Possible formats are "yyyy*mmm*dd" if (D (5) /= '-' and then D (5) /= '/') or else D (9) /= D (5) then raise Constraint_Error; end if; Year := Year_Number'Value (D (1 .. 4)); Month := Month_Name_To_Number (D (6 .. 8)); Day := Day_Number'Value (D (10 .. 11)); Time_Start := 13; elsif D_Length = 12 or else D_Length = 21 then -- Formats are "mmm dd, yyyy" or "mmm dd, yyyy hh:mm:ss" if D (4) /= ' ' or else D (7) /= ',' or else D (8) /= ' ' then raise Constraint_Error; end if; Year := Year_Number'Value (D (9 .. 12)); Month := Month_Name_To_Number (D (1 .. 3)); Day := Day_Number'Value (D (5 .. 6)); Time_Start := 14; else raise Constraint_Error; end if; end if; end Extract_Date; ------------------ -- Extract_Time -- ------------------ procedure Extract_Time (Index : Positive; Hour : out Hour_Number; Minute : out Minute_Number; Second : out Second_Number; Check_Space : Boolean := False) is begin -- If no time was specified in the string (do not allow trailing -- character either) if Index = D_Length + 2 then Hour := 0; Minute := 0; Second := 0; else -- Not enough characters left ? if Index /= D_Length - 7 then raise Constraint_Error; end if; if Check_Space and then D (Index - 1) /= ' ' then raise Constraint_Error; end if; if D (Index + 2) /= ':' or else D (Index + 5) /= ':' then raise Constraint_Error; end if; Hour := Hour_Number'Value (D (Index .. Index + 1)); Minute := Minute_Number'Value (D (Index + 3 .. Index + 4)); Second := Second_Number'Value (D (Index + 6 .. Index + 7)); end if; end Extract_Time; -- Local Declarations Success : Boolean; Time_Start : Natural := 1; Time : Ada.Calendar.Time; -- Start of processing for Value begin -- Let's try parsing Date as a supported ISO-8601 format. If we do not -- succeed, then retry using all the other GNAT supported formats. Parse_ISO_8601 (Date, Time, Success); if Success then return Time; end if; -- Length checks if D_Length not in 8 | 10 | 11 | 12 | 17 | 19 | 20 | 21 then raise Constraint_Error; end if; -- After the correct length has been determined, it is safe to create -- a local string copy in order to avoid String'First N arithmetic. D (1 .. D_Length) := Date; if D_Length /= 8 or else D (3) /= ':' then Extract_Date (Year, Month, Day, Time_Start); Extract_Time (Time_Start, Hour, Minute, Second, Check_Space => True); else declare Discard : Second_Duration; begin Split (Clock, Year, Month, Day, Hour, Minute, Second, Sub_Second => Discard); end; Extract_Time (1, Hour, Minute, Second, Check_Space => False); end if; return Time_Of (Year, Month, Day, Hour, Minute, Second); end Value; -------------- -- Put_Time -- -------------- procedure Put_Time (Date : Ada.Calendar.Time; Picture : Picture_String) is begin Ada.Text_IO.Put (Image (Date, Picture)); end Put_Time; end GNAT.Calendar.Time_IO;
reznikmm/matreshka
Ada
7,022
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_Number.Percentage_Style_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Number_Percentage_Style_Element_Node is begin return Self : Number_Percentage_Style_Element_Node do Matreshka.ODF_Number.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Number_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Number_Percentage_Style_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Enter_Number_Percentage_Style (ODF.DOM.Number_Percentage_Style_Elements.ODF_Number_Percentage_Style_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Enter_Node (Visitor, Control); end if; end Enter_Node; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Number_Percentage_Style_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Percentage_Style_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Number_Percentage_Style_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Leave_Number_Percentage_Style (ODF.DOM.Number_Percentage_Style_Elements.ODF_Number_Percentage_Style_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Leave_Node (Visitor, Control); end if; end Leave_Node; ---------------- -- Visit_Node -- ---------------- overriding procedure Visit_Node (Self : not null access Number_Percentage_Style_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then ODF.DOM.Iterators.Abstract_ODF_Iterator'Class (Iterator).Visit_Number_Percentage_Style (Visitor, ODF.DOM.Number_Percentage_Style_Elements.ODF_Number_Percentage_Style_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Visit_Node (Iterator, Visitor, Control); end if; end Visit_Node; begin Matreshka.DOM_Documents.Register_Element (Matreshka.ODF_String_Constants.Number_URI, Matreshka.ODF_String_Constants.Percentage_Style_Element, Number_Percentage_Style_Element_Node'Tag); end Matreshka.ODF_Number.Percentage_Style_Elements;
charlie5/cBound
Ada
1,677
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_make_current_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; context_tag : aliased xcb.xcb_glx_context_tag_t; pad1 : aliased swig.int8_t_Array (0 .. 19); end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_glx_make_current_reply_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_make_current_reply_t.Item, Element_Array => xcb.xcb_glx_make_current_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_make_current_reply_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_make_current_reply_t.Pointer, Element_Array => xcb.xcb_glx_make_current_reply_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_glx_make_current_reply_t;
zhmu/ananas
Ada
270
adb
-- { dg-do run } with Tampering_Check1_IVectors; use Tampering_Check1_IVectors; with Tampering_Check1_Trim; procedure Tampering_Check1 is V : Vector; begin V.Append (-1); V.Append (-2); V.Append (-3); Tampering_Check1_Trim (V); end Tampering_Check1;
reznikmm/matreshka
Ada
4,584
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Style.Mirror_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Mirror_Attribute_Node is begin return Self : Style_Mirror_Attribute_Node do Matreshka.ODF_Style.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Style_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Style_Mirror_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Mirror_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Style_URI, Matreshka.ODF_String_Constants.Mirror_Attribute, Style_Mirror_Attribute_Node'Tag); end Matreshka.ODF_Style.Mirror_Attributes;
stcarrez/dynamo
Ada
8,813
adb
----------------------------------------------------------------------- -- dynamo -- Ada Code Generator -- Copyright (C) 2009, 2010, 2011, 2012, 2015, 2017, 2020 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with GNAT.Command_Line; use GNAT.Command_Line; with GNAT.Traceback.Symbolic; with Sax.Readers; with Ada.Text_IO; with Ada.Strings.Unbounded; with Ada.Exceptions; with Ada.Directories; with Ada.Command_Line; with Ada.Environment_Variables; with Util.Files; with Util.Log.Loggers; with Util.Systems.Os; with Util.Commands; with Gen.Utils.GNAT; with Gen.Generator; with Gen.Commands; with Gen.Configs; procedure Dynamo is use Ada; use Ada.Strings.Unbounded; use Ada.Directories; use Ada.Command_Line; use Gen.Commands; procedure Set_Config_Directory (Path : in String; Silent : in Boolean := False); procedure Print_Configuration (Generator : in Gen.Generator.Handler); -- Print environment variable setup procedure Print_Environment (Generator : in Gen.Generator.Handler; C_Env : in Boolean := False); function Get_Installation_Directory return String; Out_Dir : Unbounded_String; Config_Dir : Unbounded_String; Template_Dir : Unbounded_String; Status : Exit_Status := Success; Debug : Boolean := False; Print_Config : Boolean := False; Print_Env : Boolean := False; Print_CEnv : Boolean := False; First : Natural := 0; -- ------------------------------ -- Print information about dynamo configuration -- ------------------------------ procedure Print_Configuration (Generator : in Gen.Generator.Handler) is begin Ada.Text_IO.Put_Line ("Dynamo version : " & Gen.Configs.VERSION); Ada.Text_IO.Put_Line ("Config directory : " & Generator.Get_Config_Directory); Ada.Text_IO.Put_Line ("UML directory : " & Generator.Get_Parameter (Gen.Configs.GEN_UML_DIR)); Ada.Text_IO.Put_Line ("Templates directory : " & Generator.Get_Parameter (Gen.Configs.GEN_TEMPLATES_DIRS)); Ada.Text_IO.Put_Line ("GNAT project directory : " & Generator.Get_Parameter (Gen.Configs.GEN_GNAT_PROJECT_DIRS)); end Print_Configuration; -- ------------------------------ -- Print environment variable setup -- ------------------------------ procedure Print_Environment (Generator : in Gen.Generator.Handler; C_Env : in Boolean := False) is begin if C_Env then Ada.Text_IO.Put ("setenv " & Gen.Utils.GNAT.ADA_PROJECT_PATH_NAME & " """); else Ada.Text_IO.Put ("export " & Gen.Utils.GNAT.ADA_PROJECT_PATH_NAME & "="""); end if; if Ada.Environment_Variables.Exists (Gen.Utils.GNAT.ADA_PROJECT_PATH_NAME) then Ada.Text_IO.Put (Ada.Environment_Variables.Value (Gen.Utils.GNAT.ADA_PROJECT_PATH_NAME)); Ada.Text_IO.Put (Util.Systems.Os.Path_Separator); end if; Ada.Text_IO.Put_Line (Generator.Get_Parameter (Gen.Configs.GEN_GNAT_PROJECT_DIRS) & """"); end Print_Environment; -- ------------------------------ -- Verify and set the configuration path -- ------------------------------ procedure Set_Config_Directory (Path : in String; Silent : in Boolean := False) is Log_Path : constant String := Ada.Directories.Compose (Path, "log4j.properties"); begin -- Ignore if the config directory was already set. if Length (Config_Dir) > 0 then return; end if; -- Check that we can read some configuration file. if not Ada.Directories.Exists (Log_Path) then if not Silent then Ada.Text_IO.Put_Line ("Invalid config directory: " & Path); Status := Failure; end if; return; end if; -- Configure the logs Util.Log.Loggers.Initialize (Log_Path); Config_Dir := To_Unbounded_String (Path); end Set_Config_Directory; function Get_Installation_Directory return String is Name : constant String := Ada.Command_Line.Command_Name; Path : constant String := Ada.Directories.Containing_Directory (Name); begin if Path = "." then return "."; else return Ada.Directories.Containing_Directory (Path); end if; end Get_Installation_Directory; begin Initialize_Option_Scan (Stop_At_First_Non_Switch => True, Section_Delimiters => "targs"); -- Parse the command line loop case Getopt ("* v d e E o: t: c:") is when ASCII.NUL => exit; when 'o' => Out_Dir := To_Unbounded_String (Parameter & "/"); First := First + 1; when 't' => Template_Dir := To_Unbounded_String (Parameter & "/"); First := First + 1; when 'c' => Set_Config_Directory (Parameter); First := First + 1; when 'e' => Print_Env := True; when 'E' => Print_CEnv := True; when 'd' => Debug := True; when 'v' => Print_Config := True; when '*' => exit; when others => null; end case; First := First + 1; end loop; if Length (Config_Dir) = 0 then declare Dir : constant String := Get_Installation_Directory; begin Set_Config_Directory (Compose (Dir, "config"), True); Set_Config_Directory (Util.Files.Compose (Dir, "share/dynamo/base"), True); Set_Config_Directory (Gen.Configs.CONFIG_DIR, True); end; end if; if Status /= Success then Gen.Commands.Short_Help_Usage; Ada.Command_Line.Set_Exit_Status (Status); return; end if; if Ada.Command_Line.Argument_Count = 0 then Gen.Commands.Short_Help_Usage; Set_Exit_Status (Failure); return; end if; declare use type Gen.Commands.Command_Access; Args : Util.Commands.Default_Argument_List (First + 1); Cmd_Name : constant String := Full_Switch; Cmd : Gen.Commands.Command_Access; Generator : Gen.Generator.Handler; begin if Length (Out_Dir) > 0 then Gen.Generator.Set_Result_Directory (Generator, To_String (Out_Dir)); end if; if Length (Template_Dir) > 0 then Gen.Generator.Set_Template_Directory (Generator, Template_Dir); end if; Gen.Generator.Initialize (Generator, Config_Dir, Debug); if Print_Config then Print_Configuration (Generator); return; elsif Print_Env then Print_Environment (Generator, False); return; elsif Print_CEnv then Print_Environment (Generator, True); return; end if; Cmd := Gen.Commands.Driver.Find_Command (Cmd_Name); -- Check that the command exists. if Cmd = null then if Cmd_Name'Length > 0 then Ada.Text_IO.Put_Line ("Invalid command: '" & Cmd_Name & "'"); end if; Gen.Commands.Short_Help_Usage; Set_Exit_Status (Failure); return; end if; Cmd.Execute (Cmd_Name, Args, Generator); Ada.Command_Line.Set_Exit_Status (Gen.Generator.Get_Status (Generator)); end; exception when E : Invalid_Switch => Ada.Text_IO.Put_Line ("Invalid option: " & Ada.Exceptions.Exception_Message (E)); Gen.Commands.Short_Help_Usage; Ada.Command_Line.Set_Exit_Status (2); when E : Gen.Generator.Fatal_Error => Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Message (E)); Ada.Command_Line.Set_Exit_Status (1); when E : Sax.Readers.XML_Fatal_Error => Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Message (E)); Ada.Command_Line.Set_Exit_Status (1); when E : others => Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Message (E)); Ada.Text_IO.Put_Line (GNAT.Traceback.Symbolic.Symbolic_Traceback (E)); Ada.Command_Line.Set_Exit_Status (1); end Dynamo;
dan76/Amass
Ada
5,069
ads
-- Copyright © by Jeff Foley 2017-2023. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. -- SPDX-License-Identifier: Apache-2.0 local json = require("json") name = "ONYPHE" type = "api" function start() set_rate_limit(1) end function check() local c local cfg = datasrc_config() if (cfg ~= nil) then c = cfg.credentials end if (c ~= nil and c.key ~= nil and c.key ~= "") then return true end return false end function vertical(ctx, domain) local c local cfg = datasrc_config() if (cfg ~= nil) then c = cfg.credentials end if (c == nil or c.key == nil or c.key == "") then return end for page=1,1000 do local resp, err = request(ctx, { ['url']=vert_url(domain, page), ['header']={ ['Content-Type']="application/json", ['Authorization']="apikey " .. c.key, }, }) if (err ~= nil and err ~= "") then log(ctx, "vertical request to service failed: " .. err) return elseif (resp.status_code < 200 or resp.status_code >= 400) then log(ctx, "vertical request to service returned with status: " .. resp.status) return end d = json.decode(resp.body) if (d == nil) then log(ctx, "failed to decode the JSON response") return elseif (d.count == nil or d.count == 0 or #(d.results) == 0) then return end for _, r in pairs(d.results) do if (r['@category'] == "resolver") then new_name(ctx, r['hostname']) new_addr(ctx, r['ip'], r['hostname']) else for _, name in pairs(r['hostname']) do if in_scope(ctx, name) then new_name(ctx, name) end end if (r['subject'] ~= nil) then for _, name in pairs(r['subject']['altname']) do if in_scope(ctx, name) then new_name(ctx, name) end end end if (r['subdomains'] ~= nil) then for _, name in pairs(r['subdomains']) do if in_scope(ctx, name) then new_name(ctx, name) end end end end if (r['reverse'] ~= nil and in_scope(ctx, r['reverse'])) then new_name(ctx, r['reverse']) end if (r['forward'] ~= nil and in_scope(ctx, r['forward'])) then new_name(ctx, r['forward']) end end if (page == d.max_page) then break end end end function vert_url(domain, pagenum) return "https://www.onyphe.io/api/v2/summary/domain/" .. domain .. "?page=" .. pagenum end function horizontal(ctx, domain) local c local cfg = datasrc_config() if (cfg ~= nil) then c = cfg.credentials end if (c == nil or c.key == nil or c.key == "") then return end local ips, err = resolve(ctx, domain, "A") if (err ~= nil and err ~= "") then log(ctx, "horizontal resolve request to service failed: " .. err) return end for _, ip in pairs(ips) do for page=1,1000 do local resp, err = request(ctx, { ['url']=horizon_url(ip, page), ['header']={ ['Content-Type']="application/json", ['Authorization']="apikey " .. c.key, }, }) if (err ~= nil and err ~= "") then log(ctx, "horizontal request to service failed: " .. err) return elseif (resp.status_code < 200 or resp.status_code >= 400) then log(ctx, "horizontal request to service returned with status: " .. resp.status) return end d = json.decode(resp.body) if (d == nil) then log(ctx, "failed to decode the JSON horizontal response") return elseif (d.count == nil or d.count == 0 or #(d.results) == 0) then return end for _, r in pairs(d.results) do if (r['@category'] == "resolver") then associated(ctx, domain, r['domain']) elseif (r['@category'] == "datascan" and r['domain'] ~= nil) then for _, name in pairs(r['domain']) do associated(ctx, domain, name) end end end if (page == r.max_page) then break end end end end function horizon_url(ip, pagenum) return "https://www.onyphe.io/api/v2/summary/ip/" .. ip .. "?page=" .. pagenum end
AdaCore/gpr
Ada
1,884
adb
------------------------------------------------------------------------------ -- -- -- GPR2 PROJECT MANAGER -- -- -- -- Copyright (C) 2019-2023, 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 GNAT; see file COPYING. If not, -- -- see <http://www.gnu.org/licenses/>. -- -- -- ------------------------------------------------------------------------------ package body GPRname.Pattern.Language is ------------ -- Create -- ------------ function Create (Pattern : Pattern_Type; Language : Language_Type) return Object'Class is begin return Object'(GPRname.Pattern.Object (Create (Pattern)) with Language => +String (Language)); end Create; -------------- -- Language -- -------------- function Language (Self : Object) return Language_Type is (Language_Type (To_String (Self.Language))); end GPRname.Pattern.Language;
sungyeon/drake
Ada
1,456
adb
package body System.Form_Parameters is pragma Suppress (All_Checks); -- parsing form parameter procedure Get ( Form : String; Keyword_First : out Positive; Keyword_Last : out Natural; Item_First : out Positive; Item_Last : out Natural; Last : out Natural) is begin -- get keyword Keyword_First := Form'First; Keyword_Last := Keyword_First - 1; loop if Keyword_Last >= Form'Last then Item_First := Keyword_Last + 1; Item_Last := Keyword_Last; Last := Keyword_Last; exit; elsif Form (Keyword_Last + 1) = ',' then Item_First := Keyword_Last + 1; Item_Last := Keyword_Last; Last := Keyword_Last + 1; -- skip ',' exit; elsif Form (Keyword_Last + 1) = '=' then -- get value Item_First := Keyword_Last + 2; -- skip '=' Item_Last := Keyword_Last + 1; loop if Item_Last >= Form'Last then Last := Item_Last; exit; elsif Form (Item_Last + 1) = ',' then Last := Item_Last + 1; -- skip ',' exit; end if; Item_Last := Item_Last + 1; end loop; exit; end if; Keyword_Last := Keyword_Last + 1; end loop; end Get; end System.Form_Parameters;
iyan22/AprendeAda
Ada
487
adb
with vectores; use vectores; procedure eliminar_tercer_elemento_ordenada (V: in out Vector_de_enteros) is -- pre: los elementos de la lista estan ordenados -- post: si hay tres o mas elementos, el tercer elemento quedara eliminado -- y la lista mantendra el orden Inicio: Integer; begin Inicio:=V'First+2; if V'Length >= 3 then for I in Inicio..V'Last-1 loop V(I):=V(I+1); end loop; V(V'Last):=-1; end if; end eliminar_tercer_elemento_ordenada;
stcarrez/ada-awa
Ada
45,117
adb
----------------------------------------------------------------------- -- AWA.Settings.Models -- AWA.Settings.Models ----------------------------------------------------------------------- -- File generated by Dynamo DO NOT MODIFY -- Template used: templates/model/package-body.xhtml -- Ada Generator: https://github.com/stcarrez/dynamo Version 1.4.0 ----------------------------------------------------------------------- -- Copyright (C) 2023 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- pragma Warnings (Off); with Ada.Unchecked_Deallocation; pragma Warnings (On); package body AWA.Settings.Models is pragma Style_Checks ("-mrIu"); pragma Warnings (Off, "formal parameter * is not referenced"); pragma Warnings (Off, "use clause for type *"); pragma Warnings (Off, "use clause for private type *"); use type ADO.Objects.Object_Record_Access; use type ADO.Objects.Object_Ref; function Setting_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => SETTING_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Setting_Key; function Setting_Key (Id : in String) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => SETTING_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Setting_Key; function "=" (Left, Right : Setting_Ref'Class) return Boolean is begin return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right); end "="; procedure Set_Field (Object : in out Setting_Ref'Class; Impl : out Setting_Access) is Result : ADO.Objects.Object_Record_Access; begin Object.Prepare_Modify (Result); Impl := Setting_Impl (Result.all)'Access; end Set_Field; -- Internal method to allocate the Object_Record instance overriding procedure Allocate (Object : in out Setting_Ref) is Impl : Setting_Access; begin Impl := new Setting_Impl; ADO.Objects.Set_Object (Object, Impl.all'Access); end Allocate; -- ---------------------------------------- -- Data object: Setting -- ---------------------------------------- procedure Set_Id (Object : in out Setting_Ref; Value : in ADO.Identifier) is Impl : Setting_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value); end Set_Id; function Get_Id (Object : in Setting_Ref) return ADO.Identifier is Impl : constant Setting_Access := Setting_Impl (Object.Get_Object.all)'Access; begin return Impl.Get_Key_Value; end Get_Id; procedure Set_Name (Object : in out Setting_Ref; Value : in String) is Impl : Setting_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_String (Impl.all, 2, Impl.Name, Value); end Set_Name; procedure Set_Name (Object : in out Setting_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String) is Impl : Setting_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Unbounded_String (Impl.all, 2, Impl.Name, Value); end Set_Name; function Get_Name (Object : in Setting_Ref) return String is begin return Ada.Strings.Unbounded.To_String (Object.Get_Name); end Get_Name; function Get_Name (Object : in Setting_Ref) return Ada.Strings.Unbounded.Unbounded_String is Impl : constant Setting_Access := Setting_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Name; end Get_Name; -- Copy of the object. procedure Copy (Object : in Setting_Ref; Into : in out Setting_Ref) is Result : Setting_Ref; begin if not Object.Is_Null then declare Impl : constant Setting_Access := Setting_Impl (Object.Get_Load_Object.all)'Access; Copy : constant Setting_Access := new Setting_Impl; begin ADO.Objects.Set_Object (Result, Copy.all'Access); Copy.Copy (Impl.all); Copy.Name := Impl.Name; end; end if; Into := Result; end Copy; overriding procedure Find (Object : in out Setting_Ref; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Impl : constant Setting_Access := new Setting_Impl; begin Impl.Find (Session, Query, Found); if Found then ADO.Objects.Set_Object (Object, Impl.all'Access); else ADO.Objects.Set_Object (Object, null); Destroy (Impl); end if; end Find; procedure Load (Object : in out Setting_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier) is Impl : constant Setting_Access := new Setting_Impl; Found : Boolean; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); raise ADO.Objects.NOT_FOUND; end if; ADO.Objects.Set_Object (Object, Impl.all'Access); end Load; procedure Load (Object : in out Setting_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier; Found : out Boolean) is Impl : constant Setting_Access := new Setting_Impl; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); else ADO.Objects.Set_Object (Object, Impl.all'Access); end if; end Load; overriding procedure Save (Object : in out Setting_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl = null then Impl := new Setting_Impl; ADO.Objects.Set_Object (Object, Impl); end if; if not ADO.Objects.Is_Created (Impl.all) then Impl.Create (Session); else Impl.Save (Session); end if; end Save; overriding procedure Delete (Object : in out Setting_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl /= null then Impl.Delete (Session); end if; end Delete; -- -------------------- -- Free the object -- -------------------- overriding procedure Destroy (Object : access Setting_Impl) is type Setting_Impl_Ptr is access all Setting_Impl; procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Setting_Impl, Setting_Impl_Ptr); pragma Warnings (Off, "*redundant conversion*"); Ptr : Setting_Impl_Ptr := Setting_Impl (Object.all)'Access; pragma Warnings (On, "*redundant conversion*"); begin Unchecked_Free (Ptr); end Destroy; overriding procedure Find (Object : in out Setting_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, SETTING_DEF'Access); begin Stmt.Execute; if Stmt.Has_Elements then Object.Load (Stmt, Session); Stmt.Next; Found := not Stmt.Has_Elements; else Found := False; end if; end Find; overriding procedure Load (Object : in out Setting_Impl; Session : in out ADO.Sessions.Session'Class) is Found : Boolean; Query : ADO.SQL.Query; Id : constant ADO.Identifier := Object.Get_Key_Value; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Object.Find (Session, Query, Found); if not Found then raise ADO.Objects.NOT_FOUND; end if; end Load; overriding procedure Save (Object : in out Setting_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Update_Statement := Session.Create_Statement (SETTING_DEF'Access); begin if Object.Is_Modified (1) then Stmt.Save_Field (Name => COL_0_1_NAME, -- id Value => Object.Get_Key); Object.Clear_Modified (1); end if; if Object.Is_Modified (2) then Stmt.Save_Field (Name => COL_1_1_NAME, -- name Value => Object.Name); Object.Clear_Modified (2); end if; if Stmt.Has_Save_Fields then Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); declare Result : Integer; begin Stmt.Execute (Result); if Result /= 1 then if Result /= 0 then raise ADO.Objects.UPDATE_ERROR; end if; end if; end; end if; end Save; overriding procedure Create (Object : in out Setting_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Query : ADO.Statements.Insert_Statement := Session.Create_Statement (SETTING_DEF'Access); Result : Integer; begin Session.Allocate (Id => Object); Query.Save_Field (Name => COL_0_1_NAME, -- id Value => Object.Get_Key); Query.Save_Field (Name => COL_1_1_NAME, -- name Value => Object.Name); Query.Execute (Result); if Result /= 1 then raise ADO.Objects.INSERT_ERROR; end if; ADO.Objects.Set_Created (Object); end Create; overriding procedure Delete (Object : in out Setting_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Delete_Statement := Session.Create_Statement (SETTING_DEF'Access); begin Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Execute; end Delete; -- ------------------------------ -- Get the bean attribute identified by the name. -- ------------------------------ overriding function Get_Value (From : in Setting_Ref; Name : in String) return Util.Beans.Objects.Object is Obj : ADO.Objects.Object_Record_Access; Impl : access Setting_Impl; begin if From.Is_Null then return Util.Beans.Objects.Null_Object; end if; Obj := From.Get_Load_Object; Impl := Setting_Impl (Obj.all)'Access; if Name = "id" then return ADO.Objects.To_Object (Impl.Get_Key); elsif Name = "name" then return Util.Beans.Objects.To_Object (Impl.Name); end if; return Util.Beans.Objects.Null_Object; end Get_Value; procedure List (Object : in out Setting_Vector; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, SETTING_DEF'Access); begin Stmt.Execute; Setting_Vectors.Clear (Object); while Stmt.Has_Elements loop declare Item : Setting_Ref; Impl : constant Setting_Access := new Setting_Impl; begin Impl.Load (Stmt, Session); ADO.Objects.Set_Object (Item, Impl.all'Access); Object.Append (Item); end; Stmt.Next; end loop; end List; -- ------------------------------ -- Load the object from current iterator position -- ------------------------------ procedure Load (Object : in out Setting_Impl; Stmt : in out ADO.Statements.Query_Statement'Class; Session : in out ADO.Sessions.Session'Class) is pragma Unreferenced (Session); begin Object.Set_Key_Value (Stmt.Get_Identifier (0)); Object.Name := Stmt.Get_Unbounded_String (1); ADO.Objects.Set_Created (Object); end Load; function Global_Setting_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => GLOBAL_SETTING_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Global_Setting_Key; function Global_Setting_Key (Id : in String) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => GLOBAL_SETTING_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end Global_Setting_Key; function "=" (Left, Right : Global_Setting_Ref'Class) return Boolean is begin return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right); end "="; procedure Set_Field (Object : in out Global_Setting_Ref'Class; Impl : out Global_Setting_Access) is Result : ADO.Objects.Object_Record_Access; begin Object.Prepare_Modify (Result); Impl := Global_Setting_Impl (Result.all)'Access; end Set_Field; -- Internal method to allocate the Object_Record instance overriding procedure Allocate (Object : in out Global_Setting_Ref) is Impl : Global_Setting_Access; begin Impl := new Global_Setting_Impl; Impl.Version := 0; Impl.Server_Id := 0; ADO.Objects.Set_Object (Object, Impl.all'Access); end Allocate; -- ---------------------------------------- -- Data object: Global_Setting -- ---------------------------------------- procedure Set_Id (Object : in out Global_Setting_Ref; Value : in ADO.Identifier) is Impl : Global_Setting_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value); end Set_Id; function Get_Id (Object : in Global_Setting_Ref) return ADO.Identifier is Impl : constant Global_Setting_Access := Global_Setting_Impl (Object.Get_Object.all)'Access; begin return Impl.Get_Key_Value; end Get_Id; procedure Set_Value (Object : in out Global_Setting_Ref; Value : in String) is Impl : Global_Setting_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_String (Impl.all, 2, Impl.Value, Value); end Set_Value; procedure Set_Value (Object : in out Global_Setting_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String) is Impl : Global_Setting_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Unbounded_String (Impl.all, 2, Impl.Value, Value); end Set_Value; function Get_Value (Object : in Global_Setting_Ref) return String is begin return Ada.Strings.Unbounded.To_String (Object.Get_Value); end Get_Value; function Get_Value (Object : in Global_Setting_Ref) return Ada.Strings.Unbounded.Unbounded_String is Impl : constant Global_Setting_Access := Global_Setting_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Value; end Get_Value; function Get_Version (Object : in Global_Setting_Ref) return Integer is Impl : constant Global_Setting_Access := Global_Setting_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Version; end Get_Version; procedure Set_Server_Id (Object : in out Global_Setting_Ref; Value : in Integer) is Impl : Global_Setting_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Integer (Impl.all, 4, Impl.Server_Id, Value); end Set_Server_Id; function Get_Server_Id (Object : in Global_Setting_Ref) return Integer is Impl : constant Global_Setting_Access := Global_Setting_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Server_Id; end Get_Server_Id; procedure Set_Setting (Object : in out Global_Setting_Ref; Value : in Setting_Ref'Class) is Impl : Global_Setting_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Object (Impl.all, 5, Impl.Setting, Value); end Set_Setting; function Get_Setting (Object : in Global_Setting_Ref) return Setting_Ref'Class is Impl : constant Global_Setting_Access := Global_Setting_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Setting; end Get_Setting; -- Copy of the object. procedure Copy (Object : in Global_Setting_Ref; Into : in out Global_Setting_Ref) is Result : Global_Setting_Ref; begin if not Object.Is_Null then declare Impl : constant Global_Setting_Access := Global_Setting_Impl (Object.Get_Load_Object.all)'Access; Copy : constant Global_Setting_Access := new Global_Setting_Impl; begin ADO.Objects.Set_Object (Result, Copy.all'Access); Copy.Copy (Impl.all); Copy.Value := Impl.Value; Copy.Version := Impl.Version; Copy.Server_Id := Impl.Server_Id; Copy.Setting := Impl.Setting; end; end if; Into := Result; end Copy; overriding procedure Find (Object : in out Global_Setting_Ref; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Impl : constant Global_Setting_Access := new Global_Setting_Impl; begin Impl.Find (Session, Query, Found); if Found then ADO.Objects.Set_Object (Object, Impl.all'Access); else ADO.Objects.Set_Object (Object, null); Destroy (Impl); end if; end Find; procedure Load (Object : in out Global_Setting_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier) is Impl : constant Global_Setting_Access := new Global_Setting_Impl; Found : Boolean; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); raise ADO.Objects.NOT_FOUND; end if; ADO.Objects.Set_Object (Object, Impl.all'Access); end Load; procedure Load (Object : in out Global_Setting_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier; Found : out Boolean) is Impl : constant Global_Setting_Access := new Global_Setting_Impl; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); else ADO.Objects.Set_Object (Object, Impl.all'Access); end if; end Load; procedure Reload (Object : in out Global_Setting_Ref; Session : in out ADO.Sessions.Session'Class; Updated : out Boolean) is Result : ADO.Objects.Object_Record_Access; Impl : Global_Setting_Access; Query : ADO.SQL.Query; Id : ADO.Identifier; begin if Object.Is_Null then raise ADO.Objects.NULL_ERROR; end if; Object.Prepare_Modify (Result); Impl := Global_Setting_Impl (Result.all)'Access; Id := ADO.Objects.Get_Key_Value (Impl.all); Query.Bind_Param (Position => 1, Value => Id); Query.Bind_Param (Position => 2, Value => Impl.Version); Query.Set_Filter ("id = ? AND version != ?"); declare Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, GLOBAL_SETTING_DEF'Access); begin Stmt.Execute; if Stmt.Has_Elements then Updated := True; Impl.Load (Stmt, Session); else Updated := False; end if; end; end Reload; overriding procedure Save (Object : in out Global_Setting_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl = null then Impl := new Global_Setting_Impl; ADO.Objects.Set_Object (Object, Impl); end if; if not ADO.Objects.Is_Created (Impl.all) then Impl.Create (Session); else Impl.Save (Session); end if; end Save; overriding procedure Delete (Object : in out Global_Setting_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl /= null then Impl.Delete (Session); end if; end Delete; -- -------------------- -- Free the object -- -------------------- overriding procedure Destroy (Object : access Global_Setting_Impl) is type Global_Setting_Impl_Ptr is access all Global_Setting_Impl; procedure Unchecked_Free is new Ada.Unchecked_Deallocation (Global_Setting_Impl, Global_Setting_Impl_Ptr); pragma Warnings (Off, "*redundant conversion*"); Ptr : Global_Setting_Impl_Ptr := Global_Setting_Impl (Object.all)'Access; pragma Warnings (On, "*redundant conversion*"); begin Unchecked_Free (Ptr); end Destroy; overriding procedure Find (Object : in out Global_Setting_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, GLOBAL_SETTING_DEF'Access); begin Stmt.Execute; if Stmt.Has_Elements then Object.Load (Stmt, Session); Stmt.Next; Found := not Stmt.Has_Elements; else Found := False; end if; end Find; overriding procedure Load (Object : in out Global_Setting_Impl; Session : in out ADO.Sessions.Session'Class) is Found : Boolean; Query : ADO.SQL.Query; Id : constant ADO.Identifier := Object.Get_Key_Value; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Object.Find (Session, Query, Found); if not Found then raise ADO.Objects.NOT_FOUND; end if; end Load; overriding procedure Save (Object : in out Global_Setting_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Update_Statement := Session.Create_Statement (GLOBAL_SETTING_DEF'Access); begin if Object.Is_Modified (1) then Stmt.Save_Field (Name => COL_0_2_NAME, -- id Value => Object.Get_Key); Object.Clear_Modified (1); end if; if Object.Is_Modified (2) then Stmt.Save_Field (Name => COL_1_2_NAME, -- value Value => Object.Value); Object.Clear_Modified (2); end if; if Object.Is_Modified (4) then Stmt.Save_Field (Name => COL_3_2_NAME, -- server_id Value => Object.Server_Id); Object.Clear_Modified (4); end if; if Object.Is_Modified (5) then Stmt.Save_Field (Name => COL_4_2_NAME, -- setting_id Value => Object.Setting); Object.Clear_Modified (5); end if; if Stmt.Has_Save_Fields then Object.Version := Object.Version + 1; Stmt.Save_Field (Name => "version", Value => Object.Version); Stmt.Set_Filter (Filter => "id = ? and version = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Add_Param (Value => Object.Version - 1); declare Result : Integer; begin Stmt.Execute (Result); if Result /= 1 then if Result /= 0 then raise ADO.Objects.UPDATE_ERROR; else raise ADO.Objects.LAZY_LOCK; end if; end if; end; end if; end Save; overriding procedure Create (Object : in out Global_Setting_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Query : ADO.Statements.Insert_Statement := Session.Create_Statement (GLOBAL_SETTING_DEF'Access); Result : Integer; begin Object.Version := 1; Session.Allocate (Id => Object); Query.Save_Field (Name => COL_0_2_NAME, -- id Value => Object.Get_Key); Query.Save_Field (Name => COL_1_2_NAME, -- value Value => Object.Value); Query.Save_Field (Name => COL_2_2_NAME, -- version Value => Object.Version); Query.Save_Field (Name => COL_3_2_NAME, -- server_id Value => Object.Server_Id); Query.Save_Field (Name => COL_4_2_NAME, -- setting_id Value => Object.Setting); Query.Execute (Result); if Result /= 1 then raise ADO.Objects.INSERT_ERROR; end if; ADO.Objects.Set_Created (Object); end Create; overriding procedure Delete (Object : in out Global_Setting_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Delete_Statement := Session.Create_Statement (GLOBAL_SETTING_DEF'Access); begin Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Execute; end Delete; -- ------------------------------ -- Get the bean attribute identified by the name. -- ------------------------------ overriding function Get_Value (From : in Global_Setting_Ref; Name : in String) return Util.Beans.Objects.Object is Obj : ADO.Objects.Object_Record_Access; Impl : access Global_Setting_Impl; begin if From.Is_Null then return Util.Beans.Objects.Null_Object; end if; Obj := From.Get_Load_Object; Impl := Global_Setting_Impl (Obj.all)'Access; if Name = "id" then return ADO.Objects.To_Object (Impl.Get_Key); elsif Name = "value" then return Util.Beans.Objects.To_Object (Impl.Value); elsif Name = "server_id" then return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Server_Id)); end if; return Util.Beans.Objects.Null_Object; end Get_Value; procedure List (Object : in out Global_Setting_Vector; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, GLOBAL_SETTING_DEF'Access); begin Stmt.Execute; Global_Setting_Vectors.Clear (Object); while Stmt.Has_Elements loop declare Item : Global_Setting_Ref; Impl : constant Global_Setting_Access := new Global_Setting_Impl; begin Impl.Load (Stmt, Session); ADO.Objects.Set_Object (Item, Impl.all'Access); Object.Append (Item); end; Stmt.Next; end loop; end List; -- ------------------------------ -- Load the object from current iterator position -- ------------------------------ procedure Load (Object : in out Global_Setting_Impl; Stmt : in out ADO.Statements.Query_Statement'Class; Session : in out ADO.Sessions.Session'Class) is begin Object.Set_Key_Value (Stmt.Get_Identifier (0)); Object.Value := Stmt.Get_Unbounded_String (1); Object.Server_Id := Stmt.Get_Integer (3); if not Stmt.Is_Null (4) then Object.Setting.Set_Key_Value (Stmt.Get_Identifier (4), Session); end if; Object.Version := Stmt.Get_Integer (2); ADO.Objects.Set_Created (Object); end Load; function User_Setting_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => USER_SETTING_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end User_Setting_Key; function User_Setting_Key (Id : in String) return ADO.Objects.Object_Key is Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER, Of_Class => USER_SETTING_DEF'Access); begin ADO.Objects.Set_Value (Result, Id); return Result; end User_Setting_Key; function "=" (Left, Right : User_Setting_Ref'Class) return Boolean is begin return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right); end "="; procedure Set_Field (Object : in out User_Setting_Ref'Class; Impl : out User_Setting_Access) is Result : ADO.Objects.Object_Record_Access; begin Object.Prepare_Modify (Result); Impl := User_Setting_Impl (Result.all)'Access; end Set_Field; -- Internal method to allocate the Object_Record instance overriding procedure Allocate (Object : in out User_Setting_Ref) is Impl : User_Setting_Access; begin Impl := new User_Setting_Impl; Impl.Version := 0; ADO.Objects.Set_Object (Object, Impl.all'Access); end Allocate; -- ---------------------------------------- -- Data object: User_Setting -- ---------------------------------------- procedure Set_Id (Object : in out User_Setting_Ref; Value : in ADO.Identifier) is Impl : User_Setting_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value); end Set_Id; function Get_Id (Object : in User_Setting_Ref) return ADO.Identifier is Impl : constant User_Setting_Access := User_Setting_Impl (Object.Get_Object.all)'Access; begin return Impl.Get_Key_Value; end Get_Id; procedure Set_Value (Object : in out User_Setting_Ref; Value : in String) is Impl : User_Setting_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_String (Impl.all, 2, Impl.Value, Value); end Set_Value; procedure Set_Value (Object : in out User_Setting_Ref; Value : in Ada.Strings.Unbounded.Unbounded_String) is Impl : User_Setting_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Unbounded_String (Impl.all, 2, Impl.Value, Value); end Set_Value; function Get_Value (Object : in User_Setting_Ref) return String is begin return Ada.Strings.Unbounded.To_String (Object.Get_Value); end Get_Value; function Get_Value (Object : in User_Setting_Ref) return Ada.Strings.Unbounded.Unbounded_String is Impl : constant User_Setting_Access := User_Setting_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Value; end Get_Value; function Get_Version (Object : in User_Setting_Ref) return Integer is Impl : constant User_Setting_Access := User_Setting_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Version; end Get_Version; procedure Set_Setting (Object : in out User_Setting_Ref; Value : in Setting_Ref'Class) is Impl : User_Setting_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Object (Impl.all, 4, Impl.Setting, Value); end Set_Setting; function Get_Setting (Object : in User_Setting_Ref) return Setting_Ref'Class is Impl : constant User_Setting_Access := User_Setting_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.Setting; end Get_Setting; procedure Set_User (Object : in out User_Setting_Ref; Value : in AWA.Users.Models.User_Ref'Class) is Impl : User_Setting_Access; begin Set_Field (Object, Impl); ADO.Objects.Set_Field_Object (Impl.all, 5, Impl.User, Value); end Set_User; function Get_User (Object : in User_Setting_Ref) return AWA.Users.Models.User_Ref'Class is Impl : constant User_Setting_Access := User_Setting_Impl (Object.Get_Load_Object.all)'Access; begin return Impl.User; end Get_User; -- Copy of the object. procedure Copy (Object : in User_Setting_Ref; Into : in out User_Setting_Ref) is Result : User_Setting_Ref; begin if not Object.Is_Null then declare Impl : constant User_Setting_Access := User_Setting_Impl (Object.Get_Load_Object.all)'Access; Copy : constant User_Setting_Access := new User_Setting_Impl; begin ADO.Objects.Set_Object (Result, Copy.all'Access); Copy.Copy (Impl.all); Copy.Value := Impl.Value; Copy.Version := Impl.Version; Copy.Setting := Impl.Setting; Copy.User := Impl.User; end; end if; Into := Result; end Copy; overriding procedure Find (Object : in out User_Setting_Ref; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Impl : constant User_Setting_Access := new User_Setting_Impl; begin Impl.Find (Session, Query, Found); if Found then ADO.Objects.Set_Object (Object, Impl.all'Access); else ADO.Objects.Set_Object (Object, null); Destroy (Impl); end if; end Find; procedure Load (Object : in out User_Setting_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier) is Impl : constant User_Setting_Access := new User_Setting_Impl; Found : Boolean; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); raise ADO.Objects.NOT_FOUND; end if; ADO.Objects.Set_Object (Object, Impl.all'Access); end Load; procedure Load (Object : in out User_Setting_Ref; Session : in out ADO.Sessions.Session'Class; Id : in ADO.Identifier; Found : out Boolean) is Impl : constant User_Setting_Access := new User_Setting_Impl; Query : ADO.SQL.Query; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Impl.Find (Session, Query, Found); if not Found then Destroy (Impl); else ADO.Objects.Set_Object (Object, Impl.all'Access); end if; end Load; procedure Reload (Object : in out User_Setting_Ref; Session : in out ADO.Sessions.Session'Class; Updated : out Boolean) is Result : ADO.Objects.Object_Record_Access; Impl : User_Setting_Access; Query : ADO.SQL.Query; Id : ADO.Identifier; begin if Object.Is_Null then raise ADO.Objects.NULL_ERROR; end if; Object.Prepare_Modify (Result); Impl := User_Setting_Impl (Result.all)'Access; Id := ADO.Objects.Get_Key_Value (Impl.all); Query.Bind_Param (Position => 1, Value => Id); Query.Bind_Param (Position => 2, Value => Impl.Version); Query.Set_Filter ("id = ? AND version != ?"); declare Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, USER_SETTING_DEF'Access); begin Stmt.Execute; if Stmt.Has_Elements then Updated := True; Impl.Load (Stmt, Session); else Updated := False; end if; end; end Reload; overriding procedure Save (Object : in out User_Setting_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl = null then Impl := new User_Setting_Impl; ADO.Objects.Set_Object (Object, Impl); end if; if not ADO.Objects.Is_Created (Impl.all) then Impl.Create (Session); else Impl.Save (Session); end if; end Save; overriding procedure Delete (Object : in out User_Setting_Ref; Session : in out ADO.Sessions.Master_Session'Class) is Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object; begin if Impl /= null then Impl.Delete (Session); end if; end Delete; -- -------------------- -- Free the object -- -------------------- overriding procedure Destroy (Object : access User_Setting_Impl) is type User_Setting_Impl_Ptr is access all User_Setting_Impl; procedure Unchecked_Free is new Ada.Unchecked_Deallocation (User_Setting_Impl, User_Setting_Impl_Ptr); pragma Warnings (Off, "*redundant conversion*"); Ptr : User_Setting_Impl_Ptr := User_Setting_Impl (Object.all)'Access; pragma Warnings (On, "*redundant conversion*"); begin Unchecked_Free (Ptr); end Destroy; overriding procedure Find (Object : in out User_Setting_Impl; Session : in out ADO.Sessions.Session'Class; Query : in ADO.SQL.Query'Class; Found : out Boolean) is Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query, USER_SETTING_DEF'Access); begin Stmt.Execute; if Stmt.Has_Elements then Object.Load (Stmt, Session); Stmt.Next; Found := not Stmt.Has_Elements; else Found := False; end if; end Find; overriding procedure Load (Object : in out User_Setting_Impl; Session : in out ADO.Sessions.Session'Class) is Found : Boolean; Query : ADO.SQL.Query; Id : constant ADO.Identifier := Object.Get_Key_Value; begin Query.Bind_Param (Position => 1, Value => Id); Query.Set_Filter ("id = ?"); Object.Find (Session, Query, Found); if not Found then raise ADO.Objects.NOT_FOUND; end if; end Load; overriding procedure Save (Object : in out User_Setting_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Update_Statement := Session.Create_Statement (USER_SETTING_DEF'Access); begin if Object.Is_Modified (1) then Stmt.Save_Field (Name => COL_0_3_NAME, -- id Value => Object.Get_Key); Object.Clear_Modified (1); end if; if Object.Is_Modified (2) then Stmt.Save_Field (Name => COL_1_3_NAME, -- value Value => Object.Value); Object.Clear_Modified (2); end if; if Object.Is_Modified (4) then Stmt.Save_Field (Name => COL_3_3_NAME, -- setting_id Value => Object.Setting); Object.Clear_Modified (4); end if; if Object.Is_Modified (5) then Stmt.Save_Field (Name => COL_4_3_NAME, -- user_id Value => Object.User); Object.Clear_Modified (5); end if; if Stmt.Has_Save_Fields then Object.Version := Object.Version + 1; Stmt.Save_Field (Name => "version", Value => Object.Version); Stmt.Set_Filter (Filter => "id = ? and version = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Add_Param (Value => Object.Version - 1); declare Result : Integer; begin Stmt.Execute (Result); if Result /= 1 then if Result /= 0 then raise ADO.Objects.UPDATE_ERROR; else raise ADO.Objects.LAZY_LOCK; end if; end if; end; end if; end Save; overriding procedure Create (Object : in out User_Setting_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Query : ADO.Statements.Insert_Statement := Session.Create_Statement (USER_SETTING_DEF'Access); Result : Integer; begin Object.Version := 1; Session.Allocate (Id => Object); Query.Save_Field (Name => COL_0_3_NAME, -- id Value => Object.Get_Key); Query.Save_Field (Name => COL_1_3_NAME, -- value Value => Object.Value); Query.Save_Field (Name => COL_2_3_NAME, -- version Value => Object.Version); Query.Save_Field (Name => COL_3_3_NAME, -- setting_id Value => Object.Setting); Query.Save_Field (Name => COL_4_3_NAME, -- user_id Value => Object.User); Query.Execute (Result); if Result /= 1 then raise ADO.Objects.INSERT_ERROR; end if; ADO.Objects.Set_Created (Object); end Create; overriding procedure Delete (Object : in out User_Setting_Impl; Session : in out ADO.Sessions.Master_Session'Class) is Stmt : ADO.Statements.Delete_Statement := Session.Create_Statement (USER_SETTING_DEF'Access); begin Stmt.Set_Filter (Filter => "id = ?"); Stmt.Add_Param (Value => Object.Get_Key); Stmt.Execute; end Delete; -- ------------------------------ -- Get the bean attribute identified by the name. -- ------------------------------ overriding function Get_Value (From : in User_Setting_Ref; Name : in String) return Util.Beans.Objects.Object is Obj : ADO.Objects.Object_Record_Access; Impl : access User_Setting_Impl; begin if From.Is_Null then return Util.Beans.Objects.Null_Object; end if; Obj := From.Get_Load_Object; Impl := User_Setting_Impl (Obj.all)'Access; if Name = "id" then return ADO.Objects.To_Object (Impl.Get_Key); elsif Name = "value" then return Util.Beans.Objects.To_Object (Impl.Value); end if; return Util.Beans.Objects.Null_Object; end Get_Value; -- ------------------------------ -- Load the object from current iterator position -- ------------------------------ procedure Load (Object : in out User_Setting_Impl; Stmt : in out ADO.Statements.Query_Statement'Class; Session : in out ADO.Sessions.Session'Class) is begin Object.Set_Key_Value (Stmt.Get_Identifier (0)); Object.Value := Stmt.Get_Unbounded_String (1); if not Stmt.Is_Null (3) then Object.Setting.Set_Key_Value (Stmt.Get_Identifier (3), Session); end if; if not Stmt.Is_Null (4) then Object.User.Set_Key_Value (Stmt.Get_Identifier (4), Session); end if; Object.Version := Stmt.Get_Integer (2); ADO.Objects.Set_Created (Object); end Load; end AWA.Settings.Models;
zhmu/ananas
Ada
250
adb
-- { dg-do compile } procedure Class_Wide5 is type B is interface; type B_Child is new B with null record; type B_Ptr is access B'Class; procedure P (Obj : B_Ptr) is begin null; end; begin P (new B_child); -- Test end Class_Wide5;
etorri/protobuf-ada
Ada
11,674
adb
with AUnit.Assertions; with GNAT.Source_Info; with Ada.Streams.Stream_IO; with Protocol_Buffers.Generic_Assertions.Assertions; with Protocol_Buffers.Generated_Message_Utilities; with Protocol_Buffers.Wire_Format; with Test_Util; with Unittest.TestExtremeDefaultValues; with Unittest.TestRequired; with Unittest.TestRequiredForeign; with Unittest.TestReallyLargeTagNumber; with Unittest.TestMutualRecursionA; with Unittest.TestMutualRecursionB; with Unittest.TestAllTypes; package body Message_Tests is use Protocol_Buffers.Generic_Assertions.Assertions; use Protocol_Buffers.Generated_Message_Utilities; ---------- -- Name -- ---------- function Name (T : Test_Case) return Test_String is pragma Unreferenced (T); begin return Format ("Message_Tests"); end Name; -------------------- -- Register_Tests -- -------------------- procedure Register_Tests (T : in out Test_Case) is procedure Register_Routine (Test : in out AUnit.Test_Cases.Test_Case'Class; Routine : AUnit.Test_Cases.Test_Routine; Name : String) renames AUnit.Test_Cases.Registration.Register_Routine; begin Register_Routine (Test => T, Routine => Test_Floating_Point_Defaults'Access, Name => "Test_Floating_Point_Defaults"); Register_Routine (Test => T, Routine => Test_Extreme_Small_Integer_Defaults'Access, Name => "Test_Extreme_Small_Integer_Defaults"); Register_Routine (Test => T, Routine => Test_String_Defaults'Access, Name => "Test_String_Defaults"); Register_Routine (Test => T, Routine => Test_Required'Access, Name => "Test_Required"); Register_Routine (Test => T, Routine => Test_Required_Foreign'Access, Name => "Test_Required_Foreign"); Register_Routine (Test => T, Routine => Test_Really_Large_Tag_Number'Access, Name => "Test_Really_Large_Tag_Number"); Register_Routine (Test => T, Routine => Test_Mutual_Recursion'Access, Name => "Test_Mutual_Recursion"); Register_Routine (Test => T, Routine => Test_Enumeration_Values_In_Case_Statement'Access, Name => "Test_Enumeration_Values_In_Case_Statement"); Register_Routine (Test => T, Routine => Test_Accessors'Access, Name => "Test_Accessors"); Register_Routine (Test => T, Routine => Test_Clear'Access, Name => "Test_Clear"); Register_Routine (Test => T, Routine => Test_Clear_One_Field'Access, Name => "Test_Clear_One_Field"); end Register_Tests; ---------------------------------- -- Test_Floating_Point_Defaults -- ---------------------------------- procedure Test_Floating_Point_Defaults (T : in out Test_Cases.Test_Case'Class) is Message : Unittest.TestExtremeDefaultValues.Instance; use type Protocol_Buffers.Wire_Format.PB_Float; use type Protocol_Buffers.Wire_Format.PB_Double; begin Assert_Equal (0.0 , Message.Get_Zero_Float); Assert_Equal (1.0 , Message.Get_One_Float); Assert_Equal (1.5 , Message.Get_Small_Float); Assert_Equal (-1.0 , Message.Get_Negative_One_Float); Assert_Equal (-1.5 , Message.Get_Negative_Float); Assert_Equal (2.0e8 , Message.Get_Large_Float); Assert_Equal (-8.0e-28 , Message.Get_Small_Negative_Float); Assert_Equal (Positive_Infinity, Message.Get_Inf_Double); Assert_Equal (Negative_Infinity, Message.Get_Neg_Inf_Double); Assert_Equal (Positive_Infinity, Message.Get_Inf_Float); Assert_Equal (Negative_Infinity, Message.Get_Neg_Inf_Float); Assert_True (Message.Get_Nan_Float /= Message.Get_Nan_Float); Assert_True (Message.Get_Nan_Double /= Message.Get_Nan_Double); end Test_Floating_Point_Defaults; ----------------------------------------- -- Test_Extreme_Small_Integer_Defaults -- ----------------------------------------- procedure Test_Extreme_Small_Integer_Defaults (T : in out Test_Cases.Test_Case'Class) is Message : Unittest.TestExtremeDefaultValues.Instance; use type Protocol_Buffers.Wire_Format.PB_Int32; use type Protocol_BUffers.Wire_Format.PB_Int64; begin Assert_Equal (-16#8000_0000# , Message.Get_Really_Small_Int32); Assert_Equal (-16#8000_0000_0000_0000#, Message.Get_Really_Small_Int64); end Test_Extreme_Small_Integer_Defaults; -------------------------- -- Test_String_Defaults -- -------------------------- procedure Test_String_Defaults (T : in out Test_Cases.Test_Case'Class) is Message : Unittest.TestAllTypes.Instance; begin -- Function Get_Foo for a string should return a string initialized to its -- default value. Assert_Equal ("hello", Message.Get_Default_String); -- Check that we get the Message.Set_Default_String ("blah"); Message.Clear; Assert_Equal ("hello", Message.Get_Default_String); end Test_String_Defaults; ------------------- -- Test_Required -- ------------------- procedure Test_Required (T : in out Test_Cases.Test_Case'Class) is Message : Unittest.TestRequired.Instance; begin Assert_False (Message.Is_Initialized); Message.Set_A (1); Assert_False (Message.Is_Initialized); Message.Set_B (2); Assert_False (Message.Is_Initialized); Message.Set_C (3); Assert_True (Message.Is_Initialized); end Test_Required; --------------------------- -- Test_Required_Foreign -- --------------------------- procedure Test_Required_Foreign (T : in out Test_Cases.Test_Case'Class) is Message : Unittest.TestRequiredForeign.Instance; Dummy : access Unittest.TestRequired.Instance; pragma Unreferenced (Dummy); begin Assert_True (Message.Is_Initialized); Dummy := Message.Get_Optional_Message; Assert_False (Message.Is_Initialized); Message.Get_Optional_Message.Set_A (1); Message.Get_Optional_Message.Set_B (2); Message.Get_Optional_Message.Set_C (3); Assert_True (Message.Is_Initialized); Dummy := Message.Add_Repeated_Message; Assert_False (Message.Is_Initialized); Message.Get_Repeated_Message (0).Set_A(1); Message.Get_Repeated_Message (0).Set_B(2); Message.Get_Repeated_Message (0).Set_C(3); Assert_True (Message.Is_Initialized); end Test_Required_Foreign; ---------------------------------- -- Test_Really_Large_Tag_Number -- ---------------------------------- procedure Test_Really_Large_Tag_Number (T : in out Test_Cases.Test_Case'Class) is Stream : Ada.Streams.Stream_IO.Stream_Access; File : Ada.Streams.Stream_IO.File_Type; Test_File : String := "test_really_large_tag_number"; Message_1 : Unittest.TestReallyLargeTagNumber.Instance; Message_2 : Unittest.TestReallyLargeTagNumber.Instance; begin -- For the most part, if this compiles and runs then we're probably good. -- (The most likely cause for failure would be if something were attempting -- to allocate a lookup table of some sort using tag numbers as the index.) -- We'll try serializing just for fun. Ada.Streams.Stream_IO.Create (File => File, Mode => Ada.Streams.Stream_IO.Out_File, Name => Test_File); Stream := Ada.Streams.Stream_IO.Stream (File); Message_1.Set_A (1234); Message_1.Set_Bb (5678); Message_1.Serialize_To_Output_Stream (Stream); Ada.Streams.Stream_IO.Close (File); Ada.Streams.Stream_IO.Open (File => File, Mode => Ada.Streams.Stream_IO.In_File, Name => Test_File); Stream := Ada.Streams.Stream_IO.Stream (File); Message_2.Parse_From_Input_Stream (Stream); Assert_Equal (1234, Message_2.Get_A); Assert_Equal (5678, Message_2.Get_Bb); Ada.Streams.Stream_IO.Delete (File); end Test_Really_Large_Tag_Number; --------------------------- -- Test_Mutual_Recursion -- --------------------------- procedure Test_Mutual_Recursion (T : in out Test_Cases.Test_Case'Class) is Message : aliased Unittest.TestMutualRecursionA.Instance; Nested : access Unittest.TestMutualRecursionA.Instance := Message.Get_Bb.Get_A; Nested_2 : access Unittest.TestMutualRecursionA.Instance := Nested.Get_Bb.Get_A; use type Unittest.TestMutualRecursionA.TestMutualRecursionA_Access; begin -- Again, if the above compiles and runs, that's all we really have to -- test, but just for run we'll check that the system didn't somehow come -- up with a pointer loop... Assert (Message'Unchecked_Access /= Nested, ""); Assert (Message'Unchecked_Access /= Nested_2, ""); Assert (Nested /= Nested_2, ""); end Test_Mutual_Recursion; ----------------------------------------------- -- Test_Enumeration_Values_In_Case_Statement -- ----------------------------------------------- procedure Test_Enumeration_Values_In_Case_Statement (T : in out Test_Cases.Test_Case'Class) is A : Unittest.TestAllTypes.NestedEnum := Unittest.TestAllTypes.BAR; I : Protocol_Buffers.Wire_Format.PB_UInt32 := 0; begin -- Test that enumeration values can be used in case statements. This test -- doesn't actually do anything, the proof that it works is that it -- compiles. case A is when Unittest.TestAllTypes.FOO => I := 1; when Unittest.TestAllTypes.BAR => I := 2; when Unittest.TestAllTypes.BAZ => I := 3; -- no default case: We want to make sure the compiler recognizes that -- all cases are covered. (GNAT warns if you do not cover all cases of -- an enum in a switch.) end case; -- Token check just for fun. Assert_Equal (2, I); end Test_Enumeration_Values_In_Case_Statement; -------------------- -- Test_Accessors -- -------------------- procedure Test_Accessors (T : in out Test_Cases.Test_Case'Class) is Message : Unittest.TestAllTypes.Instance; begin -- Set every field to a unique value then go back and check all those -- values. Test_Util.Set_All_Fields (Message); Test_Util.Expect_All_Fields_Set (Message); Test_Util.Modify_Repeated_Fields (Message); Test_Util.Expect_Repeated_Fields_Modified (Message); end Test_Accessors; ---------------- -- Test_Clear -- ---------------- procedure Test_Clear (T : in out Test_Cases.Test_Case'Class) is Message : Unittest.TestAllTypes.Instance; begin Test_Util.Set_All_Fields (Message); Message.Clear; Test_Util.Expect_Clear (Message); end Test_Clear; -------------------------- -- Test_Clear_One_Field -- -------------------------- procedure Test_Clear_One_Field (T : in out Test_Cases.Test_Case'Class) is Message : Unittest.TestAllTypes.Instance; Original_Value : Protocol_Buffers.Wire_Format.PB_Int64; begin Test_Util.Set_All_Fields (Message); Original_Value := Message.Get_Optional_Int64; -- Clear the field and make sure that it shows up as cleared. Message.Clear_Optional_Int64; Assert_False (Message.Has_Optional_Int64); Assert_Equal (0, Message.Get_Optional_Int64); -- Other adjacent fields should not be cleared. Assert_True (Message.Has_Optional_Int32); Assert_True (Message.Has_Optional_Uint32); -- Make sure if we set it again, then all fields are set. Message.Set_Optional_Int64 (Original_Value); Test_Util.Expect_All_Fields_Set (Message); end Test_Clear_One_Field; end Message_Tests;
reznikmm/gela
Ada
14,705
adb
with Gela.Plain_Int_Sets.Cursors; with Gela.Types.Simple; with Gela.Types.Visitors; package body Gela.Resolve.Each is type Name_As_Expression_Cursor is new Gela.Interpretations.Expression_Cursor with record Name : Gela.Plain_Int_Sets.Cursors.Defining_Name_Cursor; TM : Gela.Type_Managers.Type_Manager_Access; Env : Gela.Semantic_Types.Env_Index; Tipe : Gela.Semantic_Types.Type_View_Index := 0; end record; procedure Step (Self : in out Name_As_Expression_Cursor'Class); overriding function Has_Element (Self : Name_As_Expression_Cursor) return Boolean; overriding procedure Next (Self : in out Name_As_Expression_Cursor); overriding function Get_Index (Self : Name_As_Expression_Cursor) return Gela.Interpretations.Interpretation_Index; overriding function Expression_Type (Self : Name_As_Expression_Cursor) return Gela.Semantic_Types.Type_View_Index; type Join_Cursor is new Gela.Interpretations.Expression_Cursor with record Name : Name_As_Expression_Cursor; Exp : Gela.Plain_Int_Sets.Cursors.Expression_Cursor; end record; overriding function Has_Element (Self : Join_Cursor) return Boolean; overriding procedure Next (Self : in out Join_Cursor); overriding function Get_Index (Self : Join_Cursor) return Gela.Interpretations.Interpretation_Index; overriding function Expression_Type (Self : Join_Cursor) return Gela.Semantic_Types.Type_View_Index; procedure Initialize (Self : in out Join_Cursor'Class; IM : access Gela.Interpretations.Interpretation_Manager'Class; TM : Gela.Type_Managers.Type_Manager_Access; Env : Gela.Semantic_Types.Env_Index; Set : Gela.Interpretations.Interpretation_Set_Index); type Prefix_Cursor is new Join_Cursor with record Is_Implicit_Dereference : Boolean := False; Implicit_Dereference_Type : Gela.Semantic_Types.Type_View_Index; end record; overriding procedure Next (Self : in out Prefix_Cursor); overriding function Expression_Type (Self : Prefix_Cursor) return Gela.Semantic_Types.Type_View_Index; procedure Step (Self : in out Prefix_Cursor'Class); type Prefer_Root_Cursor is new Gela.Interpretations.Expression_Cursor with record Has_Integer_Root : Boolean := False; Has_Real_Root : Boolean := False; Root_Cursor : Join_Cursor; Exp_Cursor : Join_Cursor; end record; procedure Step (Self : in out Prefer_Root_Cursor'Class); overriding function Has_Element (Self : Prefer_Root_Cursor) return Boolean; overriding procedure Next (Self : in out Prefer_Root_Cursor); overriding function Get_Index (Self : Prefer_Root_Cursor) return Gela.Interpretations.Interpretation_Index; overriding function Expression_Type (Self : Prefer_Root_Cursor) return Gela.Semantic_Types.Type_View_Index; procedure Initialize (Self : in out Prefer_Root_Cursor'Class; IM : access Gela.Interpretations.Interpretation_Manager'Class; TM : Gela.Type_Managers.Type_Manager_Access; Env : Gela.Semantic_Types.Env_Index; Set : Gela.Interpretations.Interpretation_Set_Index); --------------------- -- Expression_Type -- --------------------- overriding function Expression_Type (Self : Name_As_Expression_Cursor) return Gela.Semantic_Types.Type_View_Index is begin return Self.Tipe; end Expression_Type; --------------------- -- Expression_Type -- --------------------- overriding function Expression_Type (Self : Join_Cursor) return Gela.Semantic_Types.Type_View_Index is begin if Self.Name.Has_Element then return Self.Name.Expression_Type; else return Self.Exp.Expression_Type; end if; end Expression_Type; --------------- -- Get_Index -- --------------- overriding function Get_Index (Self : Name_As_Expression_Cursor) return Gela.Interpretations.Interpretation_Index is begin return Self.Name.Get_Index; end Get_Index; --------------- -- Get_Index -- --------------- overriding function Get_Index (Self : Join_Cursor) return Gela.Interpretations.Interpretation_Index is begin if Self.Name.Has_Element then return Self.Name.Get_Index; else return Self.Exp.Get_Index; end if; end Get_Index; --------------- -- Get_Index -- --------------- overriding function Get_Index (Self : Prefer_Root_Cursor) return Gela.Interpretations.Interpretation_Index is begin if Self.Root_Cursor.Has_Element then return Self.Root_Cursor.Get_Index; else return Self.Exp_Cursor.Get_Index; end if; end Get_Index; ----------------- -- Has_Element -- ----------------- overriding function Has_Element (Self : Name_As_Expression_Cursor) return Boolean is begin return Self.Name.Has_Element; end Has_Element; ----------------- -- Has_Element -- ----------------- overriding function Has_Element (Self : Join_Cursor) return Boolean is begin return Self.Name.Has_Element or else Self.Exp.Has_Element; end Has_Element; ----------------- -- Has_Element -- ----------------- overriding function Has_Element (Self : Prefer_Root_Cursor) return Boolean is begin return Self.Root_Cursor.Has_Element or else Self.Exp_Cursor.Has_Element; end Has_Element; procedure Initialize (Self : in out Join_Cursor'Class; IM : access Gela.Interpretations.Interpretation_Manager'Class; TM : Gela.Type_Managers.Type_Manager_Access; Env : Gela.Semantic_Types.Env_Index; Set : Gela.Interpretations.Interpretation_Set_Index) is begin Self.Exp := Gela.Plain_Int_Sets.Cursors.Expression_Cursor (IM.Expressions (Set).First); Self.Name.Name := Gela.Plain_Int_Sets.Cursors.Defining_Name_Cursor (IM.Defining_Names (Set).First); Self.Name.TM := TM; Self.Name.Env := Env; Self.Name.Tipe := 0; Self.Name.Step; end Initialize; ---------------- -- Initialize -- ---------------- procedure Initialize (Self : in out Prefer_Root_Cursor'Class; IM : access Gela.Interpretations.Interpretation_Manager'Class; TM : Gela.Type_Managers.Type_Manager_Access; Env : Gela.Semantic_Types.Env_Index; Set : Gela.Interpretations.Interpretation_Set_Index) is begin Self.Root_Cursor.Initialize (IM, TM, Env, Set); Self.Exp_Cursor.Initialize (IM, TM, Env, Set); Self.Step; end Initialize; ---------- -- Next -- ---------- overriding procedure Next (Self : in out Name_As_Expression_Cursor) is begin Self.Name.Next; Self.Step; end Next; ---------- -- Next -- ---------- overriding procedure Next (Self : in out Join_Cursor) is begin if Self.Name.Has_Element then Self.Name.Next; else Self.Exp.Next; end if; end Next; ---------- -- Next -- ---------- overriding procedure Next (Self : in out Prefer_Root_Cursor) is begin if Self.Root_Cursor.Has_Element then Self.Root_Cursor.Next; else Self.Exp_Cursor.Next; end if; Self.Step; end Next; ---------- -- Step -- ---------- procedure Step (Self : in out Name_As_Expression_Cursor'Class) is begin Self.Tipe := 0; while Self.Name.Has_Element loop declare Name : constant Gela.Elements.Defining_Names.Defining_Name_Access := Self.Name.Defining_Name; Decl : constant Gela.Elements.Element_Access := Name.Enclosing_Element; begin Self.Tipe := Self.TM.Type_Of_Object_Declaration (Self.Env, Decl); exit when Self.Tipe not in 0; Self.Name.Next; end; end loop; end Step; ---------- -- Step -- ---------- procedure Step (Self : in out Prefer_Root_Cursor'Class) is TM : constant Gela.Type_Managers.Type_Manager_Access := Self.Root_Cursor.Name.TM; Type_Index : Gela.Semantic_Types.Type_View_Index; Type_View : Gela.Types.Type_View_Access; begin -- In the first phase look for root types and return them while Self.Root_Cursor.Has_Element loop Type_Index := Self.Root_Cursor.Expression_Type; Type_View := TM.Get (Type_Index); if Type_View in null then null; -- Skip unknown types elsif Type_View.Is_Root then if Type_View.Is_Signed_Integer then Self.Has_Integer_Root := True; else Self.Has_Real_Root := True; end if; return; end if; Self.Root_Cursor.Next; end loop; -- In the second phase look for other types, if not hidden by root while Self.Exp_Cursor.Has_Element loop Type_Index := Self.Exp_Cursor.Expression_Type; Type_View := TM.Get (Type_Index); if Type_View in null then null; -- Skip unknown types elsif Type_View.Is_Root then null; -- Skip root types elsif Self.Has_Integer_Root and then Type_View.Is_Signed_Integer then null; -- Skip any integer type if we have integer_root elsif Self.Has_Real_Root and then Type_View.Is_Real then null; -- Skip any real type if we have real_root else -- Found other expression type, return it return; end if; Self.Exp_Cursor.Next; end loop; end Step; ---------- -- Step -- ---------- procedure Step (Self : in out Prefix_Cursor'Class) is package Type_Visiters is type Type_Visitor is new Gela.Types.Visitors.Type_Visitor with null record; overriding procedure Object_Access_Type (Self : in out Type_Visitor; Value : not null Gela.Types.Simple .Object_Access_Type_Access); end Type_Visiters; package body Type_Visiters is overriding procedure Object_Access_Type (Self : in out Type_Visitor; Value : not null Gela.Types.Simple .Object_Access_Type_Access) is pragma Unreferenced (Self); Index : constant Gela.Semantic_Types.Type_View_Index := Step.Self.Name.TM.Type_From_Subtype_Mark (Step.Self.Name.Env, Value.Get_Designated); begin Step.Self.Is_Implicit_Dereference := True; Step.Self.Implicit_Dereference_Type := Index; end Object_Access_Type; end Type_Visiters; View : Gela.Types.Type_View_Access; Visiter : Type_Visiters.Type_Visitor; begin if Self.Has_Element then View := Self.Name.TM.Get (Join_Cursor (Self).Expression_Type); end if; Self.Is_Implicit_Dereference := False; View.Visit_If_Assigned (Visiter); end Step; overriding procedure Next (Self : in out Prefix_Cursor) is begin if Self.Is_Implicit_Dereference then Self.Is_Implicit_Dereference := False; else Join_Cursor (Self).Next; Self.Step; end if; end Next; overriding function Expression_Type (Self : Prefix_Cursor) return Gela.Semantic_Types.Type_View_Index is begin if Self.Is_Implicit_Dereference then return Self.Implicit_Dereference_Type; else return Join_Cursor (Self).Expression_Type; end if; end Expression_Type; --------------------- -- Expression_Type -- --------------------- overriding function Expression_Type (Self : Prefer_Root_Cursor) return Gela.Semantic_Types.Type_View_Index is begin if Self.Root_Cursor.Has_Element then return Self.Root_Cursor.Expression_Type; else return Self.Exp_Cursor.Expression_Type; end if; end Expression_Type; package Join_Iterators is new Gela.Plain_Int_Sets.Cursors.Generic_Iterators (Cursor => Gela.Interpretations.Expression_Cursor, Next => Gela.Interpretations.Next, Some_Cursor => Join_Cursor, Iterators => Gela.Interpretations.Expression_Iterators); package Prefix_Iterators is new Gela.Plain_Int_Sets.Cursors.Generic_Iterators (Cursor => Gela.Interpretations.Expression_Cursor, Next => Gela.Interpretations.Next, Some_Cursor => Prefix_Cursor, Iterators => Gela.Interpretations.Expression_Iterators); package Prefer_Root_Iterators is new Gela.Plain_Int_Sets.Cursors.Generic_Iterators (Cursor => Gela.Interpretations.Expression_Cursor, Next => Gela.Interpretations.Next, Some_Cursor => Prefer_Root_Cursor, Iterators => Gela.Interpretations.Expression_Iterators); ----------------- -- Prefer_Root -- ----------------- function Prefer_Root (Self : access Gela.Interpretations.Interpretation_Manager'Class; TM : Gela.Type_Managers.Type_Manager_Access; Env : Gela.Semantic_Types.Env_Index; Set : Gela.Interpretations.Interpretation_Set_Index) return Gela.Interpretations.Expression_Iterators.Forward_Iterator'Class is begin return Result : Prefer_Root_Iterators.Iterator do Result.Cursor.Initialize (Self, TM, Env, Set); end return; end Prefer_Root; ------------ -- Prefix -- ------------ function Prefix (Self : access Gela.Interpretations.Interpretation_Manager'Class; TM : Gela.Type_Managers.Type_Manager_Access; Env : Gela.Semantic_Types.Env_Index; Set : Gela.Interpretations.Interpretation_Set_Index) return Gela.Interpretations.Expression_Iterators.Forward_Iterator'Class is begin return Result : Prefix_Iterators.Iterator do Result.Cursor.Initialize (Self, TM, Env, Set); Result.Cursor.Step; end return; end Prefix; ---------------- -- Expression -- ---------------- function Expression (Self : access Gela.Interpretations.Interpretation_Manager'Class; TM : Gela.Type_Managers.Type_Manager_Access; Env : Gela.Semantic_Types.Env_Index; Set : Gela.Interpretations.Interpretation_Set_Index) return Gela.Interpretations.Expression_Iterators.Forward_Iterator'Class is begin return Result : Join_Iterators.Iterator do Result.Cursor.Initialize (Self, TM, Env, Set); end return; end Expression; end Gela.Resolve.Each;
reznikmm/matreshka
Ada
4,266
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- 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$ ------------------------------------------------------------------------------ -- A filter is an object that performs filtering tasks on either the request -- to a resource (a servlet or static content), or on the response from a -- resource, or both. ------------------------------------------------------------------------------ with Servlet.Filter_Chains; with Servlet.Requests; with Servlet.Responses; package Servlet.Filters is pragma Preelaborate; type Filter is limited interface; not overriding procedure Do_Filter (Self : in out Filter; Request : Servlet.Requests.Servlet_Request'Class; Response : in out Servlet.Responses.Servlet_Response'Class; Chain : in out Servlet.Filter_Chains.Filter_Chain'Class) is abstract; -- The Do_Filter subprogram of the Filter is called by the container each -- time a request/response pair is passed through the chain due to a client -- request for a resource at the end of the chain. end Servlet.Filters;
zhmu/ananas
Ada
6,246
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . P A C K _ 7 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_79 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_79; 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_79 -- ------------ function Get_79 (Arr : System.Address; N : Natural; Rev_SSO : Boolean) return Bits_79 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_79; ------------ -- Set_79 -- ------------ procedure Set_79 (Arr : System.Address; N : Natural; E : Bits_79; 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_79; end System.Pack_79;
AdaCore/Ada_Drivers_Library
Ada
30,645
ads
-- This spec has been automatically generated from STM32F7x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.RTC is pragma Preelaborate; --------------- -- Registers -- --------------- subtype TR_SU_Field is HAL.UInt4; subtype TR_ST_Field is HAL.UInt3; subtype TR_MNU_Field is HAL.UInt4; subtype TR_MNT_Field is HAL.UInt3; subtype TR_HU_Field is HAL.UInt4; subtype TR_HT_Field is HAL.UInt2; -- time register type TR_Register is record -- Second units in BCD format SU : TR_SU_Field := 16#0#; -- Second tens in BCD format ST : TR_ST_Field := 16#0#; -- unspecified Reserved_7_7 : HAL.Bit := 16#0#; -- Minute units in BCD format MNU : TR_MNU_Field := 16#0#; -- Minute tens in BCD format MNT : TR_MNT_Field := 16#0#; -- unspecified Reserved_15_15 : HAL.Bit := 16#0#; -- Hour units in BCD format HU : TR_HU_Field := 16#0#; -- Hour tens in BCD format HT : TR_HT_Field := 16#0#; -- AM/PM notation PM : Boolean := False; -- unspecified Reserved_23_31 : HAL.UInt9 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TR_Register use record SU at 0 range 0 .. 3; ST at 0 range 4 .. 6; Reserved_7_7 at 0 range 7 .. 7; MNU at 0 range 8 .. 11; MNT at 0 range 12 .. 14; Reserved_15_15 at 0 range 15 .. 15; HU at 0 range 16 .. 19; HT at 0 range 20 .. 21; PM at 0 range 22 .. 22; Reserved_23_31 at 0 range 23 .. 31; end record; subtype DR_DU_Field is HAL.UInt4; subtype DR_DT_Field is HAL.UInt2; subtype DR_MU_Field is HAL.UInt4; subtype DR_WDU_Field is HAL.UInt3; subtype DR_YU_Field is HAL.UInt4; subtype DR_YT_Field is HAL.UInt4; -- date register type DR_Register is record -- Date units in BCD format DU : DR_DU_Field := 16#1#; -- Date tens in BCD format DT : DR_DT_Field := 16#0#; -- unspecified Reserved_6_7 : HAL.UInt2 := 16#0#; -- Month units in BCD format MU : DR_MU_Field := 16#1#; -- Month tens in BCD format MT : Boolean := False; -- Week day units WDU : DR_WDU_Field := 16#1#; -- Year units in BCD format YU : DR_YU_Field := 16#0#; -- Year tens in BCD format YT : DR_YT_Field := 16#0#; -- unspecified Reserved_24_31 : HAL.UInt8 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DR_Register use record DU at 0 range 0 .. 3; DT at 0 range 4 .. 5; Reserved_6_7 at 0 range 6 .. 7; MU at 0 range 8 .. 11; MT at 0 range 12 .. 12; WDU at 0 range 13 .. 15; YU at 0 range 16 .. 19; YT at 0 range 20 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; subtype CR_WCKSEL_Field is HAL.UInt3; subtype CR_OSEL_Field is HAL.UInt2; -- control register type CR_Register is record -- Wakeup clock selection WCKSEL : CR_WCKSEL_Field := 16#0#; -- Time-stamp event active edge TSEDGE : Boolean := False; -- Reference clock detection enable (50 or 60 Hz) REFCKON : Boolean := False; -- Bypass the shadow registers BYPSHAD : Boolean := False; -- Hour format FMT : Boolean := False; -- unspecified Reserved_7_7 : HAL.Bit := 16#0#; -- Alarm A enable ALRAE : Boolean := False; -- Alarm B enable ALRBE : Boolean := False; -- Wakeup timer enable WUTE : Boolean := False; -- Time stamp enable TSE : Boolean := False; -- Alarm A interrupt enable ALRAIE : Boolean := False; -- Alarm B interrupt enable ALRBIE : Boolean := False; -- Wakeup timer interrupt enable WUTIE : Boolean := False; -- Time-stamp interrupt enable TSIE : Boolean := False; -- Add 1 hour (summer time change) ADD1H : Boolean := False; -- Subtract 1 hour (winter time change) SUB1H : Boolean := False; -- Backup BKP : Boolean := False; -- Calibration output selection COSEL : Boolean := False; -- Output polarity POL : Boolean := False; -- Output selection OSEL : CR_OSEL_Field := 16#0#; -- Calibration output enable COE : Boolean := False; -- timestamp on internal event enable ITSE : Boolean := False; -- unspecified Reserved_25_31 : HAL.UInt7 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR_Register use record WCKSEL at 0 range 0 .. 2; TSEDGE at 0 range 3 .. 3; REFCKON at 0 range 4 .. 4; BYPSHAD at 0 range 5 .. 5; FMT at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; ALRAE at 0 range 8 .. 8; ALRBE at 0 range 9 .. 9; WUTE at 0 range 10 .. 10; TSE at 0 range 11 .. 11; ALRAIE at 0 range 12 .. 12; ALRBIE at 0 range 13 .. 13; WUTIE at 0 range 14 .. 14; TSIE at 0 range 15 .. 15; ADD1H at 0 range 16 .. 16; SUB1H at 0 range 17 .. 17; BKP at 0 range 18 .. 18; COSEL at 0 range 19 .. 19; POL at 0 range 20 .. 20; OSEL at 0 range 21 .. 22; COE at 0 range 23 .. 23; ITSE at 0 range 24 .. 24; Reserved_25_31 at 0 range 25 .. 31; end record; -- initialization and status register type ISR_Register is record -- Read-only. Alarm A write flag ALRAWF : Boolean := True; -- Read-only. Alarm B write flag ALRBWF : Boolean := True; -- Read-only. Wakeup timer write flag WUTWF : Boolean := True; -- Shift operation pending SHPF : Boolean := False; -- Read-only. Initialization status flag INITS : Boolean := False; -- Registers synchronization flag RSF : Boolean := False; -- Read-only. Initialization flag INITF : Boolean := False; -- Initialization mode INIT : Boolean := False; -- Alarm A flag ALRAF : Boolean := False; -- Alarm B flag ALRBF : Boolean := False; -- Wakeup timer flag WUTF : Boolean := False; -- Time-stamp flag TSF : Boolean := False; -- Time-stamp overflow flag TSOVF : Boolean := False; -- Tamper detection flag TAMP1F : Boolean := False; -- RTC_TAMP2 detection flag TAMP2F : Boolean := False; -- RTC_TAMP3 detection flag TAMP3F : Boolean := False; -- Read-only. Recalibration pending Flag RECALPF : 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 ISR_Register use record ALRAWF at 0 range 0 .. 0; ALRBWF at 0 range 1 .. 1; WUTWF at 0 range 2 .. 2; SHPF at 0 range 3 .. 3; INITS at 0 range 4 .. 4; RSF at 0 range 5 .. 5; INITF at 0 range 6 .. 6; INIT at 0 range 7 .. 7; ALRAF at 0 range 8 .. 8; ALRBF at 0 range 9 .. 9; WUTF at 0 range 10 .. 10; TSF at 0 range 11 .. 11; TSOVF at 0 range 12 .. 12; TAMP1F at 0 range 13 .. 13; TAMP2F at 0 range 14 .. 14; TAMP3F at 0 range 15 .. 15; RECALPF at 0 range 16 .. 16; Reserved_17_31 at 0 range 17 .. 31; end record; subtype PRER_PREDIV_S_Field is HAL.UInt15; subtype PRER_PREDIV_A_Field is HAL.UInt7; -- prescaler register type PRER_Register is record -- Synchronous prescaler factor PREDIV_S : PRER_PREDIV_S_Field := 16#FF#; -- unspecified Reserved_15_15 : HAL.Bit := 16#0#; -- Asynchronous prescaler factor PREDIV_A : PRER_PREDIV_A_Field := 16#7F#; -- unspecified Reserved_23_31 : HAL.UInt9 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for PRER_Register use record PREDIV_S at 0 range 0 .. 14; Reserved_15_15 at 0 range 15 .. 15; PREDIV_A at 0 range 16 .. 22; Reserved_23_31 at 0 range 23 .. 31; end record; subtype WUTR_WUT_Field is HAL.UInt16; -- wakeup timer register type WUTR_Register is record -- Wakeup auto-reload value bits WUT : WUTR_WUT_Field := 16#FFFF#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for WUTR_Register use record WUT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype ALRMAR_SU_Field is HAL.UInt4; subtype ALRMAR_ST_Field is HAL.UInt3; subtype ALRMAR_MNU_Field is HAL.UInt4; subtype ALRMAR_MNT_Field is HAL.UInt3; subtype ALRMAR_HU_Field is HAL.UInt4; subtype ALRMAR_HT_Field is HAL.UInt2; subtype ALRMAR_DU_Field is HAL.UInt4; subtype ALRMAR_DT_Field is HAL.UInt2; -- alarm A register type ALRMAR_Register is record -- Second units in BCD format SU : ALRMAR_SU_Field := 16#0#; -- Second tens in BCD format ST : ALRMAR_ST_Field := 16#0#; -- Alarm A seconds mask MSK1 : Boolean := False; -- Minute units in BCD format MNU : ALRMAR_MNU_Field := 16#0#; -- Minute tens in BCD format MNT : ALRMAR_MNT_Field := 16#0#; -- Alarm A minutes mask MSK2 : Boolean := False; -- Hour units in BCD format HU : ALRMAR_HU_Field := 16#0#; -- Hour tens in BCD format HT : ALRMAR_HT_Field := 16#0#; -- AM/PM notation PM : Boolean := False; -- Alarm A hours mask MSK3 : Boolean := False; -- Date units or day in BCD format DU : ALRMAR_DU_Field := 16#0#; -- Date tens in BCD format DT : ALRMAR_DT_Field := 16#0#; -- Week day selection WDSEL : Boolean := False; -- Alarm A date mask MSK4 : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ALRMAR_Register use record SU at 0 range 0 .. 3; ST at 0 range 4 .. 6; MSK1 at 0 range 7 .. 7; MNU at 0 range 8 .. 11; MNT at 0 range 12 .. 14; MSK2 at 0 range 15 .. 15; HU at 0 range 16 .. 19; HT at 0 range 20 .. 21; PM at 0 range 22 .. 22; MSK3 at 0 range 23 .. 23; DU at 0 range 24 .. 27; DT at 0 range 28 .. 29; WDSEL at 0 range 30 .. 30; MSK4 at 0 range 31 .. 31; end record; subtype ALRMBR_SU_Field is HAL.UInt4; subtype ALRMBR_ST_Field is HAL.UInt3; subtype ALRMBR_MNU_Field is HAL.UInt4; subtype ALRMBR_MNT_Field is HAL.UInt3; subtype ALRMBR_HU_Field is HAL.UInt4; subtype ALRMBR_HT_Field is HAL.UInt2; subtype ALRMBR_DU_Field is HAL.UInt4; subtype ALRMBR_DT_Field is HAL.UInt2; -- alarm B register type ALRMBR_Register is record -- Second units in BCD format SU : ALRMBR_SU_Field := 16#0#; -- Second tens in BCD format ST : ALRMBR_ST_Field := 16#0#; -- Alarm B seconds mask MSK1 : Boolean := False; -- Minute units in BCD format MNU : ALRMBR_MNU_Field := 16#0#; -- Minute tens in BCD format MNT : ALRMBR_MNT_Field := 16#0#; -- Alarm B minutes mask MSK2 : Boolean := False; -- Hour units in BCD format HU : ALRMBR_HU_Field := 16#0#; -- Hour tens in BCD format HT : ALRMBR_HT_Field := 16#0#; -- AM/PM notation PM : Boolean := False; -- Alarm B hours mask MSK3 : Boolean := False; -- Date units or day in BCD format DU : ALRMBR_DU_Field := 16#0#; -- Date tens in BCD format DT : ALRMBR_DT_Field := 16#0#; -- Week day selection WDSEL : Boolean := False; -- Alarm B date mask MSK4 : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ALRMBR_Register use record SU at 0 range 0 .. 3; ST at 0 range 4 .. 6; MSK1 at 0 range 7 .. 7; MNU at 0 range 8 .. 11; MNT at 0 range 12 .. 14; MSK2 at 0 range 15 .. 15; HU at 0 range 16 .. 19; HT at 0 range 20 .. 21; PM at 0 range 22 .. 22; MSK3 at 0 range 23 .. 23; DU at 0 range 24 .. 27; DT at 0 range 28 .. 29; WDSEL at 0 range 30 .. 30; MSK4 at 0 range 31 .. 31; end record; subtype WPR_KEY_Field is HAL.UInt8; -- write protection register type WPR_Register is record -- Write-only. Write protection key KEY : WPR_KEY_Field := 16#0#; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for WPR_Register use record KEY at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype SSR_SS_Field is HAL.UInt16; -- sub second register type SSR_Register is record -- Read-only. Sub second value SS : SSR_SS_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SSR_Register use record SS at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype SHIFTR_SUBFS_Field is HAL.UInt15; -- shift control register type SHIFTR_Register is record -- Write-only. Subtract a fraction of a second SUBFS : SHIFTR_SUBFS_Field := 16#0#; -- unspecified Reserved_15_30 : HAL.UInt16 := 16#0#; -- Write-only. Add one second ADD1S : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SHIFTR_Register use record SUBFS at 0 range 0 .. 14; Reserved_15_30 at 0 range 15 .. 30; ADD1S at 0 range 31 .. 31; end record; subtype TSTR_SU_Field is HAL.UInt4; subtype TSTR_ST_Field is HAL.UInt3; subtype TSTR_MNU_Field is HAL.UInt4; subtype TSTR_MNT_Field is HAL.UInt3; subtype TSTR_HU_Field is HAL.UInt4; subtype TSTR_HT_Field is HAL.UInt2; -- time stamp time register type TSTR_Register is record -- Read-only. Second units in BCD format SU : TSTR_SU_Field; -- Read-only. Second tens in BCD format ST : TSTR_ST_Field; -- unspecified Reserved_7_7 : HAL.Bit; -- Read-only. Minute units in BCD format MNU : TSTR_MNU_Field; -- Read-only. Minute tens in BCD format MNT : TSTR_MNT_Field; -- unspecified Reserved_15_15 : HAL.Bit; -- Read-only. Hour units in BCD format HU : TSTR_HU_Field; -- Read-only. Hour tens in BCD format HT : TSTR_HT_Field; -- Read-only. AM/PM notation PM : Boolean; -- unspecified Reserved_23_31 : HAL.UInt9; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TSTR_Register use record SU at 0 range 0 .. 3; ST at 0 range 4 .. 6; Reserved_7_7 at 0 range 7 .. 7; MNU at 0 range 8 .. 11; MNT at 0 range 12 .. 14; Reserved_15_15 at 0 range 15 .. 15; HU at 0 range 16 .. 19; HT at 0 range 20 .. 21; PM at 0 range 22 .. 22; Reserved_23_31 at 0 range 23 .. 31; end record; subtype TSDR_DU_Field is HAL.UInt4; subtype TSDR_DT_Field is HAL.UInt2; subtype TSDR_MU_Field is HAL.UInt4; subtype TSDR_WDU_Field is HAL.UInt3; -- time stamp date register type TSDR_Register is record -- Read-only. Date units in BCD format DU : TSDR_DU_Field; -- Read-only. Date tens in BCD format DT : TSDR_DT_Field; -- unspecified Reserved_6_7 : HAL.UInt2; -- Read-only. Month units in BCD format MU : TSDR_MU_Field; -- Read-only. Month tens in BCD format MT : Boolean; -- Read-only. Week day units WDU : TSDR_WDU_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TSDR_Register use record DU at 0 range 0 .. 3; DT at 0 range 4 .. 5; Reserved_6_7 at 0 range 6 .. 7; MU at 0 range 8 .. 11; MT at 0 range 12 .. 12; WDU at 0 range 13 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype TSSSR_SS_Field is HAL.UInt16; -- timestamp sub second register type TSSSR_Register is record -- Read-only. Sub second value SS : TSSSR_SS_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TSSSR_Register use record SS at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype CALR_CALM_Field is HAL.UInt9; -- calibration register type CALR_Register is record -- Calibration minus CALM : CALR_CALM_Field := 16#0#; -- unspecified Reserved_9_12 : HAL.UInt4 := 16#0#; -- Use a 16-second calibration cycle period CALW16 : Boolean := False; -- Use an 8-second calibration cycle period CALW8 : Boolean := False; -- Increase frequency of RTC by 488.5 ppm CALP : Boolean := False; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CALR_Register use record CALM at 0 range 0 .. 8; Reserved_9_12 at 0 range 9 .. 12; CALW16 at 0 range 13 .. 13; CALW8 at 0 range 14 .. 14; CALP at 0 range 15 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype TAMPCR_TAMPFREQ_Field is HAL.UInt3; subtype TAMPCR_TAMPFLT_Field is HAL.UInt2; subtype TAMPCR_TAMPPRCH_Field is HAL.UInt2; -- tamper configuration register type TAMPCR_Register is record -- Tamper 1 detection enable TAMP1E : Boolean := False; -- Active level for tamper 1 TAMP1TRG : Boolean := False; -- Tamper interrupt enable TAMPIE : Boolean := False; -- Tamper 2 detection enable TAMP2E : Boolean := False; -- Active level for tamper 2 TAMP2TRG : Boolean := False; -- Tamper 3 detection enable TAMP3E : Boolean := False; -- Active level for tamper 3 TAMP3TRG : Boolean := False; -- Activate timestamp on tamper detection event TAMPTS : Boolean := False; -- Tamper sampling frequency TAMPFREQ : TAMPCR_TAMPFREQ_Field := 16#0#; -- Tamper filter count TAMPFLT : TAMPCR_TAMPFLT_Field := 16#0#; -- Tamper precharge duration TAMPPRCH : TAMPCR_TAMPPRCH_Field := 16#0#; -- TAMPER pull-up disable TAMPPUDIS : Boolean := False; -- Tamper 1 interrupt enable TAMP1IE : Boolean := False; -- Tamper 1 no erase TAMP1NOERASE : Boolean := False; -- Tamper 1 mask flag TAMP1MF : Boolean := False; -- Tamper 2 interrupt enable TAMP2IE : Boolean := False; -- Tamper 2 no erase TAMP2NOERASE : Boolean := False; -- Tamper 2 mask flag TAMP2MF : Boolean := False; -- Tamper 3 interrupt enable TAMP3IE : Boolean := False; -- Tamper 3 no erase TAMP3NOERASE : Boolean := False; -- Tamper 3 mask flag TAMP3MF : Boolean := False; -- unspecified Reserved_25_31 : HAL.UInt7 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for TAMPCR_Register use record TAMP1E at 0 range 0 .. 0; TAMP1TRG at 0 range 1 .. 1; TAMPIE at 0 range 2 .. 2; TAMP2E at 0 range 3 .. 3; TAMP2TRG at 0 range 4 .. 4; TAMP3E at 0 range 5 .. 5; TAMP3TRG at 0 range 6 .. 6; TAMPTS at 0 range 7 .. 7; TAMPFREQ at 0 range 8 .. 10; TAMPFLT at 0 range 11 .. 12; TAMPPRCH at 0 range 13 .. 14; TAMPPUDIS at 0 range 15 .. 15; TAMP1IE at 0 range 16 .. 16; TAMP1NOERASE at 0 range 17 .. 17; TAMP1MF at 0 range 18 .. 18; TAMP2IE at 0 range 19 .. 19; TAMP2NOERASE at 0 range 20 .. 20; TAMP2MF at 0 range 21 .. 21; TAMP3IE at 0 range 22 .. 22; TAMP3NOERASE at 0 range 23 .. 23; TAMP3MF at 0 range 24 .. 24; Reserved_25_31 at 0 range 25 .. 31; end record; subtype ALRMASSR_SS_Field is HAL.UInt15; subtype ALRMASSR_MASKSS_Field is HAL.UInt4; -- alarm A sub second register type ALRMASSR_Register is record -- Sub seconds value SS : ALRMASSR_SS_Field := 16#0#; -- unspecified Reserved_15_23 : HAL.UInt9 := 16#0#; -- Mask the most-significant bits starting at this bit MASKSS : ALRMASSR_MASKSS_Field := 16#0#; -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ALRMASSR_Register use record SS at 0 range 0 .. 14; Reserved_15_23 at 0 range 15 .. 23; MASKSS at 0 range 24 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; subtype ALRMBSSR_SS_Field is HAL.UInt15; subtype ALRMBSSR_MASKSS_Field is HAL.UInt4; -- alarm B sub second register type ALRMBSSR_Register is record -- Sub seconds value SS : ALRMBSSR_SS_Field := 16#0#; -- unspecified Reserved_15_23 : HAL.UInt9 := 16#0#; -- Mask the most-significant bits starting at this bit MASKSS : ALRMBSSR_MASKSS_Field := 16#0#; -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ALRMBSSR_Register use record SS at 0 range 0 .. 14; Reserved_15_23 at 0 range 15 .. 23; MASKSS at 0 range 24 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; -- option register type OR_Register is record -- RTC_ALARM on PC13 output type RTC_ALARM_TYPE : Boolean := False; -- RTC_OUT remap RTC_OUT_RMP : Boolean := False; -- unspecified Reserved_2_31 : HAL.UInt30 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OR_Register use record RTC_ALARM_TYPE at 0 range 0 .. 0; RTC_OUT_RMP at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Real-time clock type RTC_Peripheral is record -- time register TR : aliased TR_Register; -- date register DR : aliased DR_Register; -- control register CR : aliased CR_Register; -- initialization and status register ISR : aliased ISR_Register; -- prescaler register PRER : aliased PRER_Register; -- wakeup timer register WUTR : aliased WUTR_Register; -- alarm A register ALRMAR : aliased ALRMAR_Register; -- alarm B register ALRMBR : aliased ALRMBR_Register; -- write protection register WPR : aliased WPR_Register; -- sub second register SSR : aliased SSR_Register; -- shift control register SHIFTR : aliased SHIFTR_Register; -- time stamp time register TSTR : aliased TSTR_Register; -- time stamp date register TSDR : aliased TSDR_Register; -- timestamp sub second register TSSSR : aliased TSSSR_Register; -- calibration register CALR : aliased CALR_Register; -- tamper configuration register TAMPCR : aliased TAMPCR_Register; -- alarm A sub second register ALRMASSR : aliased ALRMASSR_Register; -- alarm B sub second register ALRMBSSR : aliased ALRMBSSR_Register; -- option register OR_k : aliased OR_Register; -- backup register BKP0R : aliased HAL.UInt32; -- backup register BKP1R : aliased HAL.UInt32; -- backup register BKP2R : aliased HAL.UInt32; -- backup register BKP3R : aliased HAL.UInt32; -- backup register BKP4R : aliased HAL.UInt32; -- backup register BKP5R : aliased HAL.UInt32; -- backup register BKP6R : aliased HAL.UInt32; -- backup register BKP7R : aliased HAL.UInt32; -- backup register BKP8R : aliased HAL.UInt32; -- backup register BKP9R : aliased HAL.UInt32; -- backup register BKP10R : aliased HAL.UInt32; -- backup register BKP11R : aliased HAL.UInt32; -- backup register BKP12R : aliased HAL.UInt32; -- backup register BKP13R : aliased HAL.UInt32; -- backup register BKP14R : aliased HAL.UInt32; -- backup register BKP15R : aliased HAL.UInt32; -- backup register BKP16R : aliased HAL.UInt32; -- backup register BKP17R : aliased HAL.UInt32; -- backup register BKP18R : aliased HAL.UInt32; -- backup register BKP19R : aliased HAL.UInt32; -- backup register BKP20R : aliased HAL.UInt32; -- backup register BKP21R : aliased HAL.UInt32; -- backup register BKP22R : aliased HAL.UInt32; -- backup register BKP23R : aliased HAL.UInt32; -- backup register BKP24R : aliased HAL.UInt32; -- backup register BKP25R : aliased HAL.UInt32; -- backup register BKP26R : aliased HAL.UInt32; -- backup register BKP27R : aliased HAL.UInt32; -- backup register BKP28R : aliased HAL.UInt32; -- backup register BKP29R : aliased HAL.UInt32; -- backup register BKP30R : aliased HAL.UInt32; -- backup register BKP31R : aliased HAL.UInt32; end record with Volatile; for RTC_Peripheral use record TR at 16#0# range 0 .. 31; DR at 16#4# range 0 .. 31; CR at 16#8# range 0 .. 31; ISR at 16#C# range 0 .. 31; PRER at 16#10# range 0 .. 31; WUTR at 16#14# range 0 .. 31; ALRMAR at 16#1C# range 0 .. 31; ALRMBR at 16#20# range 0 .. 31; WPR at 16#24# range 0 .. 31; SSR at 16#28# range 0 .. 31; SHIFTR at 16#2C# range 0 .. 31; TSTR at 16#30# range 0 .. 31; TSDR at 16#34# range 0 .. 31; TSSSR at 16#38# range 0 .. 31; CALR at 16#3C# range 0 .. 31; TAMPCR at 16#40# range 0 .. 31; ALRMASSR at 16#44# range 0 .. 31; ALRMBSSR at 16#48# range 0 .. 31; OR_k at 16#4C# range 0 .. 31; BKP0R at 16#50# range 0 .. 31; BKP1R at 16#54# range 0 .. 31; BKP2R at 16#58# range 0 .. 31; BKP3R at 16#5C# range 0 .. 31; BKP4R at 16#60# range 0 .. 31; BKP5R at 16#64# range 0 .. 31; BKP6R at 16#68# range 0 .. 31; BKP7R at 16#6C# range 0 .. 31; BKP8R at 16#70# range 0 .. 31; BKP9R at 16#74# range 0 .. 31; BKP10R at 16#78# range 0 .. 31; BKP11R at 16#7C# range 0 .. 31; BKP12R at 16#80# range 0 .. 31; BKP13R at 16#84# range 0 .. 31; BKP14R at 16#88# range 0 .. 31; BKP15R at 16#8C# range 0 .. 31; BKP16R at 16#90# range 0 .. 31; BKP17R at 16#94# range 0 .. 31; BKP18R at 16#98# range 0 .. 31; BKP19R at 16#9C# range 0 .. 31; BKP20R at 16#A0# range 0 .. 31; BKP21R at 16#A4# range 0 .. 31; BKP22R at 16#A8# range 0 .. 31; BKP23R at 16#AC# range 0 .. 31; BKP24R at 16#B0# range 0 .. 31; BKP25R at 16#B4# range 0 .. 31; BKP26R at 16#B8# range 0 .. 31; BKP27R at 16#BC# range 0 .. 31; BKP28R at 16#C0# range 0 .. 31; BKP29R at 16#C4# range 0 .. 31; BKP30R at 16#C8# range 0 .. 31; BKP31R at 16#CC# range 0 .. 31; end record; -- Real-time clock RTC_Periph : aliased RTC_Peripheral with Import, Address => System'To_Address (16#40002800#); end STM32_SVD.RTC;
damaki/libkeccak
Ada
3,084
ads
------------------------------------------------------------------------------- -- Copyright (c) 2019, Daniel King -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- * Redistributions of source code must retain the above copyright -- notice, this list of conditions and the following disclaimer. -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- * The name of the copyright holder may not be used to endorse or promote -- Products derived from this software without specific prior written -- permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY -- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------- with Keccak.Generic_Duplex; with Keccak.Generic_Sponge; with Keccak.Padding; pragma Elaborate_All (Keccak.Generic_Duplex); pragma Elaborate_All (Keccak.Generic_Sponge); -- @summary -- Instantiation of Keccak-p[1600,14], with a Sponge and Duplex built on top of it. package Keccak.Keccak_1600.Rounds_14 with SPARK_Mode => On is procedure Permute is new KeccakF_1600_Permutation.Permute (Num_Rounds => 14); package Sponge is new Keccak.Generic_Sponge (State_Size_Bits => KeccakF_1600.State_Size_Bits, State_Type => State, Init_State => KeccakF_1600.Init, Permute => Permute, XOR_Bits_Into_State => KeccakF_1600_Lanes.XOR_Bits_Into_State, Extract_Data => KeccakF_1600_Lanes.Extract_Bytes, Pad => Keccak.Padding.Pad101_Multi_Blocks); package Duplex is new Keccak.Generic_Duplex (State_Size_Bits => KeccakF_1600.State_Size_Bits, State_Type => State, Init_State => KeccakF_1600.Init, Permute => Permute, XOR_Bits_Into_State => KeccakF_1600_Lanes.XOR_Bits_Into_State, Extract_Bits => KeccakF_1600_Lanes.Extract_Bits, Pad => Keccak.Padding.Pad101_Single_Block, Min_Padding_Bits => Keccak.Padding.Pad101_Min_Bits); end Keccak.Keccak_1600.Rounds_14;
Pateldisolution/tictactoe
Ada
729
adb
package body Stack with SPARK_Mode => On is Tab : array (1 .. Max_Size) of Board := (others => (others => (others => Empty))); -- The stack. We push and pop pointers to Values. ----------- -- Clear -- ----------- procedure Clear is begin Last := Tab'First - 1; end Clear; ---------- -- Push -- ---------- procedure Push (V : Board) is begin Last := Last + 1; Tab (Last) := V; end Push; --------- -- Pop -- --------- procedure Pop (V : out Board) is begin V := Tab (Last); Last := Last - 1; end Pop; --------- -- Top -- --------- function Top return Board is begin return Tab (Last); end Top; end Stack;
AdaCore/libadalang
Ada
1,190
adb
-- Test that name resolution for record members resolve to the member -- declaration in simple cases. package Foo is type Char is ('a', 'b', 'c'); type String is array (Positive range <>) of Char; type Integer is range 1 .. 100; type R1_Type is record A, B : Integer; C : Natural; end record; type R2_Type (N : Natural) is record I : Integer; S : String (1 .. N); end record; type R2_Array is array (Natural range <>) of R2_Type; subtype R3_Type is R2_Type (10); type R4_Type is record R1 : R1_Type; R2 : R2_Array (2); end record; R1_1 : R1_Type; function R1_2 return R1_Type is ((A => 1, B => 2, C => 3)); function R1_3 (I : Integer) return R1_Type is ((A => I, B => I * 2, C => 0)); R2_1 : R2_Type := (N => 1, others => <>); R2_2 : R2_Type (20); R3 : R3_Type; R4 : R4_Type; pragma Test (R1_1.A); pragma Test (R1_1.D); pragma Test (R1_2.A); pragma Test (R1_3 (1).A); pragma Test (R2_1.N); pragma Test (R2_1.S (1)); pragma Test (R2_1.A); pragma Test (R3.N); pragma Test (R3.S (1)); pragma Test (R4.R1.C); pragma Test (R4.R2 (1).I); end Foo;
BrickBot/Bound-T-H8-300
Ada
4,841
adb
-- Devices.Catalog (body) -- -- Author: Niklas Holsti, Tidorum Ltd. -- -- A component of the Bound-T Timing Analysis Tool. -- ------------------------------------------------------------------------------- -- Copyright (c) 1999 .. 2015 Tidorum Ltd -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- 1. Redistributions of source code must retain the above copyright notice, this -- list of conditions and the following disclaimer. -- 2. Redistributions in binary form must reproduce the above copyright notice, -- this list of conditions and the following disclaimer in the documentation -- and/or other materials provided with the distribution. -- -- This software is provided by the copyright holders and contributors "as is" and -- any express or implied warranties, including, but not limited to, the implied -- warranties of merchantability and fitness for a particular purpose are -- disclaimed. In no event shall the copyright owner or contributors be liable for -- any direct, indirect, incidental, special, exemplary, or consequential damages -- (including, but not limited to, procurement of substitute goods or services; -- loss of use, data, or profits; or business interruption) however caused and -- on any theory of liability, whether in contract, strict liability, or tort -- (including negligence or otherwise) arising in any way out of the use of this -- software, even if advised of the possibility of such damage. -- -- Other modules (files) of this software composition should contain their -- own copyright statements, which may have different copyright and usage -- conditions. The above conditions apply to this file. ------------------------------------------------------------------------------- -- -- $Revision: 1.2 $ -- $Date: 2015/10/24 20:05:47 $ -- -- $Log: devices-catalog.adb,v $ -- Revision 1.2 2015/10/24 20:05:47 niklas -- Moved to free licence. -- -- Revision 1.1 2012-01-19 20:13:56 niklas -- BT-CH-0224: Device.Catalog added. Device options updated. -- with Ada.Characters.Handling; with Ada.Strings.Unbounded; with Basic_Output; package body Devices.Catalog is -- --- Catalog items that represent a single device -- overriding function Device_By ( Name : String; From : One_Device_Item_T) return Device_Ref is use Ada.Characters.Handling; use Ada.Strings.Unbounded; Result : Device_Ref; -- The result, from the Factory. begin if To_Upper (To_String (From.Name)) = To_Upper (Name) then Result := From.Factory.all; Set_Name ( Device => Result.all, To => To_String (From.Name)); return Result; else return null; end if; end Device_By; overriding function Name_Of (Item : One_Device_Item_T) return String is begin return Ada.Strings.Unbounded.To_String (Item.Name); end Name_Of; -- --- Catalog operations -- Max_Items : constant := 200; -- -- The maximum number of items in the catalog. Items : array (1 .. Max_Items) of Item_Ref; Last_Item : Natural := 0; -- -- The catalog consists of Items(1..Last_Item). procedure Enter (Item : in Item_Ref) is begin if Last_Item < Items'Last then Last_Item := Last_Item + 1; Items(Last_Item) := Item; else Basic_Output.Fault ( Location => "Devices.Catalog.Enter", Text => "Catalog full, item """ & Name_Of (Item.all) & """ not entered."); end if; end Enter; procedure Enter ( Name : in String; Device : in One_Device_Factory_T) is use Ada.Strings.Unbounded; begin Enter (Item => new One_Device_Item_T'( Name => To_Unbounded_String (Name), Factory => Device)); end Enter; function Device_By (Name : String) return Device_Ref is Result : Device_Ref := null; -- The result. begin for I in Items'First .. Last_Item loop Result := Device_By ( Name => Name, From => Items(I).all); exit when Result /= null; end loop; return Result; end Device_By; procedure Reset (Iter : in out Iterator_T) is begin Iter.Index := 1; end Reset; function Item (Iter : Iterator_T) return Item_Ref is begin if Iter.Index <= Last_Item then return Items(Iter.Index); else return null; end if; end Item; procedure Next (Iter : in out Iterator_T) is begin Iter.Index := Iter.Index + 1; end Next; end Devices.Catalog;
MinimSecure/unum-sdk
Ada
1,882
adb
-- Copyright 2005-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/>. procedure P is type Index is (One, Two, Three); type Table is array (Integer range 1 .. 3) of Integer; type ETable is array (Index) of Integer; type RTable is array (Index range Two .. Three) of Integer; type UTable is array (Positive range <>) of Integer; type PTable is array (Index) of Boolean; pragma Pack (PTable); function Get_UTable (I : Integer) return UTable is begin return Utable'(1 => I, 2 => 2, 3 => 3); end Get_UTable; One_Two_Three : Table := (1, 2, 3); E_One_Two_Three : ETable := (1, 2, 3); R_Two_Three : RTable := (2, 3); U_One_Two_Three : UTable := Get_UTable (1); P_One_Two_Three : PTable := (False, True, True); Few_Reps : UTable := (1, 2, 3, 3, 3, 3, 3, 4, 5); Many_Reps : UTable := (1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 5); Empty : array (1 .. 0) of Integer := (others => 0); begin One_Two_Three (1) := 4; -- START E_One_Two_Three (One) := 4; R_Two_Three (Two) := 4; U_One_Two_Three (U_One_Two_Three'First) := 4; P_One_Two_Three (One) := True; Few_Reps (Few_Reps'First) := 2; Many_Reps (Many_Reps'First) := 2; Empty := (others => 1); end P;
AdaCore/gpr
Ada
25
ads
package Pck1 is end Pck1;
albertklee/SPARKZumo
Ada
4,806
ads
pragma SPARK_Mode; with Interfaces.C; use Interfaces.C; with Types; use Types; -- @summary -- This package exposes many Arduino runtime routines to Ada -- -- @description -- This package imports all of the necessary Arduino runtime library calls -- that are needed. -- package Sparkduino is -- Configures the specified pin to behave either as an input or an output -- @param Pin the number of the pin whose mode you wish to set -- @param Mode use PinMode'Pos (io_mode) where io_mode is of type PinMode -- see Types package for more info procedure SetPinMode (Pin : unsigned_char; Mode : unsigned_char) with Global => null; pragma Import (C, SetPinMode, "pinMode"); -- Write a HIGH or a LOW value to a digital pin. -- @param Pin the pin number -- @param Val use DigPinValue'Pos (state) where state is of type -- DigPinValue see Types package for more info procedure DigitalWrite (Pin : unsigned_char; Val : unsigned_char) with Global => null; pragma Import (C, DigitalWrite, "digitalWrite"); -- Reads the value from a specified digital pin, either HIGH or LOW. -- @param Pin the number of the digital pin you want to read -- @return an Integer that maps to HIGH or LOW with DigPinValue'Pos function DigitalRead (Pin : unsigned_char) return Integer with Global => null; pragma Import (C, DigitalRead, "digitalRead"); -- Returns the number of milliseconds since the Arduino board began running -- the current program. This number will overflow (go back to zero), -- after approximately 50 days. -- @return Number of milliseconds since the program started (unsigned long) function Millis return unsigned_long with Global => null; pragma Import (C, Millis, "millis"); -- Returns the number of microseconds since the Arduino board began -- running the current program. This number will overflow -- (go back to zero), after approximately 70 minutes. On 16 MHz Arduino -- boards (e.g. Duemilanove and Nano), this function has a resolution of -- four microseconds (i.e. the value returned is always a multiple of -- four). On 8 MHz Arduino boards (e.g. the LilyPad), this function has -- a resolution of eight microseconds. -- @return Returns the number of microseconds since the Arduino board began -- running the current program. (unsigned long) function Micros return unsigned_long with Global => null; pragma Import (C, Micros, "micros"); -- Pauses the program for the amount of time -- @param Time the number of microseconds to pause procedure DelayMicroseconds (Time : unsigned) with Global => null; pragma Import (C, DelayMicroseconds, "delayMicroseconds"); -- Pauses the program for the amount of time (in milliseconds) -- @param Time the number of milliseconds to pause procedure SysDelay (Time : unsigned_long) with Global => null; pragma Import (C, SysDelay, "delay"); -- AVR specific call which temporarily disables interrupts. procedure SEI; pragma Import (C, SEI, "sei_wrapper"); -- Print a string to the serial console -- @param Msg the string to print procedure Serial_Print (Msg : String) with SPARK_Mode => Off; -- Print a byte to the serial console -- @param Msg the string to prepend -- @param Val the byte to print procedure Serial_Print_Byte (Msg : String; Val : Byte) with SPARK_Mode => Off; -- Print a short to the serial console -- @param Msg the string to prepend -- @param Val the short to print procedure Serial_Print_Short (Msg : String; Val : short) with SPARK_Mode => Off; -- Print a float to the serial console -- @param Msg the string to prepend -- @param Val the float to print procedure Serial_Print_Float (Msg : String; Val : Float) with SPARK_Mode => Off; -- Print the format calibration data to the serial console -- @param Index the specific sensor calibration data to print -- @param Min the min sensor value in the calibration record -- @param Max the max sensor value in the calibration record procedure Serial_Print_Calibration (Index : Integer; Min : Sensor_Value; Max : Sensor_Value); pragma Import (C, Serial_Print_Calibration, "Serial_Print_Calibration"); -- analog pin mappings A0 : constant := 14; A1 : constant := 15; A2 : constant := 16; A3 : constant := 17; A4 : constant := 18; A5 : constant := 19; A6 : constant := 20; A7 : constant := 21; end Sparkduino;
kqr/qweyboard
Ada
2,173
adb
package body Configuration is procedure Get_Settings (Config : in out Settings) is I : Positive := 1; begin while I <= CLI.Argument_Count loop if Get_Argument (I, "-t", Config.Timeout) then null; elsif Get_Argument (I, "-l", Config.Language_File_Name) then null; elsif Get_Argument (I, "-v", Config.Log_Level) then null; elsif Get_Argument (I, "-vv", Config.Log_Level) then null; elsif Get_Argument (I, "-vvv", Config.Log_Level) then null; else raise ARGUMENTS_ERROR; end if; end loop; end Get_Settings; procedure Load_Language (Config : in out Settings) is begin if Length (Config.Language_File_Name) > 0 then Qweyboard.Languages.Parser.Parse (To_String (Config.Language_File_Name)); end if; end; function Get_Argument (Count : in out Positive; Flag : String; File_Name : in out Unbounded_String) return Boolean is begin if CLI.Argument (Count) /= Flag then return False; end if; File_Name := To_Unbounded_String (CLI.Argument (Count + 1)); Count := Count + 2; return True; end Get_Argument; function Get_Argument (Count : in out Positive; Flag : String; Timeout : in out Ada.Real_Time.Time_Span) return Boolean is begin if CLI.Argument (Count) /= Flag then return False; end if; Timeout := Ada.Real_Time.Milliseconds (Natural'Value (CLI.Argument (Count + 1))); Count := Count + 2; return True; exception when CONSTRAINT_ERROR => return False; end Get_Argument; function Get_Argument (Count : in out Positive; Flag : String; Verbosity : in out Logging.Verbosity_Level) return Boolean is begin if CLI.Argument (Count) /= Flag then return False; end if; if Flag = "-v" then Verbosity := Logging.Log_Warning; elsif Flag = "-vv" then Verbosity := Logging.Log_Info; elsif Flag = "-vvv" then Verbosity := Logging.Log_Chatty; else return False; end if; Count := Count + 1; return True; end; end Configuration;
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_Data_Style_Name_Attributes; package Matreshka.ODF_Style.Data_Style_Name_Attributes is type Style_Data_Style_Name_Attribute_Node is new Matreshka.ODF_Style.Abstract_Style_Attribute_Node and ODF.DOM.Style_Data_Style_Name_Attributes.ODF_Style_Data_Style_Name_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Data_Style_Name_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Style_Data_Style_Name_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Style.Data_Style_Name_Attributes;
reznikmm/matreshka
Ada
4,209
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.Table.Align.Internals is ------------ -- Create -- ------------ function Create (Node : Matreshka.ODF_Attributes.Table.Align.Table_Align_Access) return ODF.DOM.Attributes.Table.Align.ODF_Table_Align 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.Table.Align.Table_Align_Access) return ODF.DOM.Attributes.Table.Align.ODF_Table_Align is begin return (XML.DOM.Attributes.Internals.Wrap (Matreshka.DOM_Nodes.Attribute_Access (Node)) with null record); end Wrap; end ODF.DOM.Attributes.Table.Align.Internals;
darkestkhan/imago
Ada
3,688
adb
------------------------------------------------------------------------------ -- EMAIL: <[email protected]> -- -- License: ISC -- -- -- -- Copyright © 2015 - 2016 darkestkhan -- ------------------------------------------------------------------------------ -- Permission to use, copy, modify, and/or distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- The software is provided "as is" and the author disclaims all warranties -- -- with regard to this software including all implied warranties of -- -- merchantability and fitness. In no event shall the author be liable for -- -- any special, direct, indirect, or consequential damages or any damages -- -- whatsoever resulting from loss of use, data or profits, whether in an -- -- action of contract, negligence or other tortious action, arising out of -- -- or in connection with the use or performance of this software. -- ------------------------------------------------------------------------------ with Ada.Characters.Latin_1; with Interfaces.C; with Interfaces.C.Strings; package body Imago.ILUT is -------------------------------------------------------------------------- ------------------- -- R E N A M E S -- ------------------- --------------------------------------------------------------------------- package ASCII renames Ada.Characters.Latin_1; package IC renames Interfaces.C; package CStrings renames Interfaces.C.Strings; -------------------------------------------------------------------------- ------------------------------------------- -- S U B P R O G R A M ' S B O D I E S -- ------------------------------------------- --------------------------------------------------------------------------- function Get_String (String_Name: in IL.Enum) return String is function ilutGetString (String_Name: in IL.Enum) return CStrings.chars_ptr with Import => True, Convention => StdCall, External_Name => "ilutGetString"; begin return IC.To_Ada (CStrings.Value (ilutGetString (String_Name))); end Get_String; --------------------------------------------------------------------------- function GL_Load_Image (File_Name: in String) return GL.UInt is function ilutGLLoadImage (F: in IL.Pointer) return GL.UInt with Import => True, Convention => StdCall, External_Name => "ilutGLLoadImage"; CString: constant String := File_Name & ASCII.NUL; begin return ilutGLLoadImage (CString'Address); end GL_Load_Image; --------------------------------------------------------------------------- function GL_Save_Image ( File_Name: in String; Tex_ID: in GL.UInt ) return IL.Bool is function ilutGLSaveImage ( F: in IL.Pointer; Tex_ID: in GL.UInt ) return IL.Bool with Import => True, Convention => StdCall, External_Name => "ilutGLSaveImage"; CString: constant String := File_Name & ASCII.NUL; begin return ilutGLSaveImage (CString'Address, Tex_ID); end GL_Save_Image; --------------------------------------------------------------------------- end Imago.ILUT;
zhmu/ananas
Ada
746
adb
-- { dg-do compile { target i?86-*-* x86_64-*-* } } -- { dg-options "-O3 -msse2 -fdump-tree-optimized" } package body Vect11 is function "+" (X, Y : Sarray) return Sarray is R : Sarray; begin for I in Sarray'Range loop R(I) := X(I) + Y(I); end loop; return R; end; procedure Add (X, Y : Sarray; R : out Sarray) is begin for I in Sarray'Range loop R(I) := X(I) + Y(I); end loop; end; procedure Add (X, Y : not null access Sarray; R : not null access Sarray) is begin for I in Sarray'Range loop pragma Loop_Optimize (Ivdep); R(I) := X(I) + Y(I); end loop; end; end Vect11; -- { dg-final { scan-tree-dump-not "goto" "optimized" } }
zhmu/ananas
Ada
10,080
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . S E Q U E N T I A L _ I O -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ -- This is the generic template for Sequential_IO, i.e. the code that gets -- duplicated. We absolutely minimize this code by either calling routines -- in System.File_IO (for common file functions), or in System.Sequential_IO -- (for specialized Sequential_IO functions) with Ada.Unchecked_Conversion; with System; with System.Byte_Swapping; with System.CRTL; with System.File_Control_Block; with System.File_IO; with System.Storage_Elements; with Interfaces.C_Streams; use Interfaces.C_Streams; package body Ada.Sequential_IO is package FIO renames System.File_IO; package FCB renames System.File_Control_Block; package SIO renames System.Sequential_IO; package SSE renames System.Storage_Elements; SU : constant := System.Storage_Unit; subtype AP is FCB.AFCB_Ptr; subtype FP is SIO.File_Type; function To_FCB is new Ada.Unchecked_Conversion (File_Mode, FCB.File_Mode); function To_SIO is new Ada.Unchecked_Conversion (FCB.File_Mode, File_Mode); use type System.Bit_Order; use type System.CRTL.size_t; procedure Byte_Swap (Siz : in out size_t); -- Byte swap Siz --------------- -- Byte_Swap -- --------------- procedure Byte_Swap (Siz : in out size_t) is use System.Byte_Swapping; begin case size_t'Size is when 32 => Siz := size_t (Bswap_32 (U32 (Siz))); when 64 => Siz := size_t (Bswap_64 (U64 (Siz))); when others => raise Program_Error; end case; end Byte_Swap; ----------- -- Close -- ----------- procedure Close (File : in out File_Type) is begin FIO.Close (AP (File)'Unrestricted_Access); end Close; ------------ -- Create -- ------------ procedure Create (File : in out File_Type; Mode : File_Mode := Out_File; Name : String := ""; Form : String := "") is begin SIO.Create (FP (File), To_FCB (Mode), Name, Form); end Create; ------------ -- Delete -- ------------ procedure Delete (File : in out File_Type) is begin FIO.Delete (AP (File)'Unrestricted_Access); end Delete; ----------------- -- End_Of_File -- ----------------- function End_Of_File (File : File_Type) return Boolean is begin return FIO.End_Of_File (AP (File)); end End_Of_File; ----------- -- Flush -- ----------- procedure Flush (File : File_Type) is begin FIO.Flush (AP (File)); end Flush; ---------- -- Form -- ---------- function Form (File : File_Type) return String is begin return FIO.Form (AP (File)); end Form; ------------- -- Is_Open -- ------------- function Is_Open (File : File_Type) return Boolean is begin return FIO.Is_Open (AP (File)); end Is_Open; ---------- -- Mode -- ---------- function Mode (File : File_Type) return File_Mode is begin return To_SIO (FIO.Mode (AP (File))); end Mode; ---------- -- Name -- ---------- function Name (File : File_Type) return String is begin return FIO.Name (AP (File)); end Name; ---------- -- Open -- ---------- procedure Open (File : in out File_Type; Mode : File_Mode; Name : String; Form : String := "") is begin SIO.Open (FP (File), To_FCB (Mode), Name, Form); end Open; ---------- -- Read -- ---------- procedure Read (File : File_Type; Item : out Element_Type) is Siz : constant size_t := (Item'Size + SU - 1) / SU; Rsiz : size_t; begin FIO.Check_Read_Status (AP (File)); -- For non-definite type or type with discriminants, read size and -- raise Program_Error if it is larger than the size of the item. if not Element_Type'Definite or else Element_Type'Has_Discriminants then FIO.Read_Buf (AP (File), Rsiz'Address, size_t'Size / System.Storage_Unit); -- If item read has non-default scalar storage order, then the size -- will have been written with that same order, so byte swap it. if Element_Type'Scalar_Storage_Order /= System.Default_Bit_Order then Byte_Swap (Rsiz); end if; -- For a type with discriminants, we have to read into a temporary -- buffer if Item is constrained, to check that the discriminants -- are correct. if Element_Type'Has_Discriminants and then Item'Constrained then declare RsizS : constant SSE.Storage_Offset := SSE.Storage_Offset (Rsiz - 1); type SA is new SSE.Storage_Array (0 .. RsizS); for SA'Alignment use Standard'Maximum_Alignment; -- We will perform an unchecked conversion of a pointer-to-SA -- into pointer-to-Element_Type. We need to ensure that the -- source is always at least as strictly aligned as the target. type SAP is access all SA; type ItemP is access all Element_Type; pragma Warnings (Off); -- We have to turn warnings off for function To_ItemP, -- because it gets analyzed for all types, including ones -- which can't possibly come this way, and for which the -- size of the access types differs. function To_ItemP is new Ada.Unchecked_Conversion (SAP, ItemP); pragma Warnings (On); Buffer : aliased SA; pragma Unsuppress (Discriminant_Check); begin FIO.Read_Buf (AP (File), Buffer'Address, Rsiz); Item := To_ItemP (Buffer'Access).all; return; end; end if; -- In the case of a non-definite type, make sure the length is OK. -- We can't do this in the variant record case, because the size is -- based on the current discriminant, so may be apparently wrong. if not Element_Type'Has_Discriminants and then Rsiz > Siz then raise Program_Error; end if; FIO.Read_Buf (AP (File), Item'Address, Rsiz); -- For definite type without discriminants, use actual size of item else FIO.Read_Buf (AP (File), Item'Address, Siz); end if; end Read; ----------- -- Reset -- ----------- procedure Reset (File : in out File_Type; Mode : File_Mode) is begin FIO.Reset (AP (File)'Unrestricted_Access, To_FCB (Mode)); end Reset; procedure Reset (File : in out File_Type) is begin FIO.Reset (AP (File)'Unrestricted_Access); end Reset; ----------- -- Write -- ----------- procedure Write (File : File_Type; Item : Element_Type) is Siz : constant size_t := (Item'Size + SU - 1) / SU; -- Size to be written, in native representation Swapped_Siz : size_t := Siz; -- Same, possibly byte swapped to account for Element_Type endianness begin FIO.Check_Write_Status (AP (File)); -- For non-definite types or types with discriminants, write the size if not Element_Type'Definite or else Element_Type'Has_Discriminants then -- If item written has non-default scalar storage order, then the -- size is written with that same order, so byte swap it. if Element_Type'Scalar_Storage_Order /= System.Default_Bit_Order then Byte_Swap (Swapped_Siz); end if; FIO.Write_Buf (AP (File), Swapped_Siz'Address, size_t'Size / System.Storage_Unit); end if; FIO.Write_Buf (AP (File), Item'Address, Siz); end Write; end Ada.Sequential_IO;
sungyeon/drake
Ada
7,273
adb
with System.Long_Long_Float_Types; package body Ada.Float is pragma Suppress (All_Checks); function Infinity return Float_Type is begin if Float_Type'Digits <= Standard.Float'Digits then declare function inff return Standard.Float with Import, Convention => Intrinsic, External_Name => "__builtin_inff"; begin return Float_Type (inff); end; elsif Float_Type'Digits <= Long_Float'Digits then declare function inf return Long_Float with Import, Convention => Intrinsic, External_Name => "__builtin_inf"; begin return Float_Type (inf); end; else declare function infl return Long_Long_Float with Import, Convention => Intrinsic, External_Name => "__builtin_infl"; begin return Float_Type (infl); end; end if; end Infinity; function NaN return Float_Type is begin if Float_Type'Digits <= Standard.Float'Digits then declare function nanf (tagp : access constant Character) return Standard.Float with Import, Convention => Intrinsic, External_Name => "__builtin_nanf"; Z : constant array (0 .. 0) of aliased Character := (0 => Character'Val (0)); begin return Float_Type (nanf (Z (0)'Access)); end; elsif Float_Type'Digits <= Long_Float'Digits then declare function nan (tagp : access constant Character) return Long_Float with Import, Convention => Intrinsic, External_Name => "__builtin_nan"; Z : constant array (0 .. 0) of aliased Character := (0 => Character'Val (0)); begin return Float_Type (nan (Z (0)'Access)); end; else declare function nanl (tagp : access constant Character) return Long_Long_Float with Import, Convention => Intrinsic, External_Name => "__builtin_nanl"; Z : constant array (0 .. 0) of aliased Character := (0 => Character'Val (0)); begin return Float_Type (nanl (Z (0)'Access)); end; end if; end NaN; function Is_Infinity (X : Float_Type) return Boolean is begin if Float_Type'Digits <= Standard.Float'Digits then declare function isinff (x : Standard.Float) return Integer with Import, Convention => Intrinsic, External_Name => "__builtin_isinff"; begin return isinff (Standard.Float (X)) /= 0; end; elsif Float_Type'Digits <= Long_Float'Digits then declare function isinf (x : Long_Float) return Integer with Import, Convention => Intrinsic, External_Name => "__builtin_isinf"; pragma Warnings (Off, isinf); -- [gcc 4.6] excessive prototype checking begin return isinf (Long_Float (X)) /= 0; end; else declare function isinfl (x : Long_Long_Float) return Integer with Import, Convention => Intrinsic, External_Name => "__builtin_isinfl"; begin return isinfl (Long_Long_Float (X)) /= 0; end; end if; end Is_Infinity; function Is_NaN (X : Float_Type) return Boolean is begin if Float_Type'Digits <= Standard.Float'Digits then declare function isnanf (x : Standard.Float) return Integer with Import, Convention => Intrinsic, External_Name => "__builtin_isnanf"; begin return isnanf (Standard.Float (X)) /= 0; end; elsif Float_Type'Digits <= Long_Float'Digits then declare function isnan (x : Long_Float) return Integer with Import, Convention => Intrinsic, External_Name => "__builtin_isnan"; pragma Warnings (Off, isnan); -- [gcc 4.6] excessive prototype checking begin return isnan (Long_Float (X)) /= 0; end; else declare function isnanl (x : Long_Long_Float) return Integer with Import, Convention => Intrinsic, External_Name => "__builtin_isnanl"; begin return isnanl (Long_Long_Float (X)) /= 0; end; end if; end Is_NaN; procedure Divide ( Dividend : Dividend_Type; Divisor : Divisor_Type; Quotient : out Quotient_Type; Remainder : out Remainder_Type) is begin System.Long_Long_Float_Types.Divide ( Long_Long_Float (Dividend), Long_Long_Float (Divisor), Long_Long_Float (Quotient), Long_Long_Float (Remainder)); end Divide; procedure Divide_By_1 ( Dividend : Dividend_Type; Quotient : out Quotient_Type; Remainder : out Remainder_Type) is begin if Dividend_Type'Digits <= Standard.Float'Digits then declare function modff ( value : Standard.Float; iptr : access Standard.Float) return Standard.Float with Import, Convention => Intrinsic, External_Name => "__builtin_modff"; Q : aliased Standard.Float; begin Remainder := Remainder_Type ( modff (Standard.Float (Dividend), Q'Access)); Quotient := Quotient_Type (Q); end; elsif Dividend_Type'Digits <= Long_Float'Digits then declare function modf ( value : Long_Float; iptr : access Long_Float) return Long_Float with Import, Convention => Intrinsic, External_Name => "__builtin_modf"; Q : aliased Long_Float; begin Remainder := Remainder_Type ( modf (Long_Float (Dividend), Q'Access)); Quotient := Quotient_Type (Q); end; else declare function modfl ( value : Long_Long_Float; iptr : access Long_Long_Float) return Long_Long_Float with Import, Convention => Intrinsic, External_Name => "__builtin_modfl"; Q : aliased Long_Long_Float; begin Remainder := Remainder_Type ( modfl (Long_Long_Float (Dividend), Q'Access)); Quotient := Quotient_Type (Q); end; end if; end Divide_By_1; procedure Modulo_Divide_By_1 ( Dividend : Dividend_Type; Quotient : out Quotient_Type; Remainder : out Remainder_Type) is procedure Divide_By_1 is new Float.Divide_By_1 (Dividend_Type, Quotient_Type, Remainder_Type); begin Divide_By_1 (Dividend, Quotient, Remainder); if Remainder < 0.0 then Quotient := Quotient - 1.0; Remainder := Remainder + 1.0; end if; end Modulo_Divide_By_1; end Ada.Float;
Fabien-Chouteau/GESTE
Ada
3,349
ads
------------------------------------------------------------------------------ -- -- -- GESTE -- -- -- -- Copyright (C) 2018 Fabien Chouteau -- -- -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with GESTE.Maths_Types; use GESTE.Maths_Types; package GESTE.Maths is function Sin (A : Value) return Value with Post => Sin'Result in -1.0 .. 1.0; function Cos (A : Value) return Value with Post => Cos'Result in -1.0 .. 1.0; function To_Degrees (A : Value) return Value; function To_Rad (A : Value) return Value; function "-" (V : Vect) return Vect; function "*" (V : Vect; F : Value) return Vect; function "*" (F : Value; V : Vect) return Vect; function "+" (V : Vect; F : Value) return Vect; function "+" (F : Value; V : Vect) return Vect; function "+" (V1, V2 : Vect) return Vect; function Sqrt (V : Value) return Value; function Magnitude (V : Vect) return Value; end GESTE.Maths;
BrickBot/Bound-T-H8-300
Ada
3,995
adb
-- Options.Devices_Valued (body) -- -- A component of the Bound-T Worst-Case Execution Time Tool. -- ------------------------------------------------------------------------------- -- Copyright (c) 1999 .. 2015 Tidorum Ltd -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- 1. Redistributions of source code must retain the above copyright notice, this -- list of conditions and the following disclaimer. -- 2. Redistributions in binary form must reproduce the above copyright notice, -- this list of conditions and the following disclaimer in the documentation -- and/or other materials provided with the distribution. -- -- This software is provided by the copyright holders and contributors "as is" and -- any express or implied warranties, including, but not limited to, the implied -- warranties of merchantability and fitness for a particular purpose are -- disclaimed. In no event shall the copyright owner or contributors be liable for -- any direct, indirect, incidental, special, exemplary, or consequential damages -- (including, but not limited to, procurement of substitute goods or services; -- loss of use, data, or profits; or business interruption) however caused and -- on any theory of liability, whether in contract, strict liability, or tort -- (including negligence or otherwise) arising in any way out of the use of this -- software, even if advised of the possibility of such damage. -- -- Other modules (files) of this software composition should contain their -- own copyright statements, which may have different copyright and usage -- conditions. The above conditions apply to this file. ------------------------------------------------------------------------------- -- -- $Revision: 1.2 $ -- $Date: 2015/10/24 20:05:50 $ -- -- $Log: options-device_valued.adb,v $ -- Revision 1.2 2015/10/24 20:05:50 niklas -- Moved to free licence. -- -- Revision 1.1 2012-01-19 21:03:39 niklas -- First version. -- package body Options.Device_Valued is use type Devices.Device_Ref; use type Devices.Catalog.Item_Ref; overriding function Type_And_Default (Option : access Option_T) return String is begin if Option.Default /= null then return "Device name, default " & Devices.Name (Option.Default.all) & '.'; else return "Device name, no default"; end if; end Type_And_Default; overriding procedure Reset (Option : access Option_T) is begin Option.Value := Option.Default; end Reset; overriding procedure Set ( Option : access Option_T; Value : in String) is Device : constant Devices.Device_Ref := Devices.Catalog.Device_By (Name => Value); -- The device named by the Value, or null if the Catalog -- knows of no such device. begin if Device = null then raise Constraint_Error; end if; Option.Value := Device; end Set; overriding function Enumerator (Option : Option_T) return Enumerator_T'Class is begin return Enumerator_T'Class (Enum_T'(Enumerator_T with Iter => <>)); end Enumerator; overriding function Current_Value (Enum : Enum_T) return String is Item : constant Devices.Catalog.Item_Ref := Devices.Catalog.Item (Enum.Iter); -- The current catalog item in the iteration (enumeration) -- of the device catalog. begin if Item /= null then return Devices.Catalog.Name_Of (Item.all); else return "(no devices available)"; end if; end Current_Value; overriding procedure Next ( Enum : in out Enum_T; Ended : out Boolean) is begin Devices.Catalog.Next (Enum.Iter); Ended := Devices.Catalog.Item (Enum.Iter) = null; end Next; end Options.Device_Valued;
onox/orka
Ada
4,662
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2016 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with GL.Objects.Textures; with GL.Types.Colors; package GL.Objects.Samplers is pragma Preelaborate; ----------------------------------------------------------------------------- -- Basic Types -- ----------------------------------------------------------------------------- type Minifying_Function is (Nearest, Linear, Nearest_Mipmap_Nearest, Linear_Mipmap_Nearest, Nearest_Mipmap_Linear, Linear_Mipmap_Linear); type Magnifying_Function is (Nearest, Linear); type Wrapping_Mode is (Repeat, Clamp_To_Border, Clamp_To_Edge, Mirrored_Repeat, Mirror_Clamp_To_Edge); ----------------------------------------------------------------------------- type Sampler is new GL_Object with private; type Sampler_Array is array (Positive range <>) of Sampler; procedure Bind (Object : Sampler; Unit : Textures.Texture_Unit); procedure Bind (Objects : Sampler_Array; First_Unit : Textures.Texture_Unit); overriding procedure Initialize_Id (Object : in out Sampler); overriding procedure Delete_Id (Object : in out Sampler); overriding function Identifier (Object : Sampler) return Types.Debug.Identifier is (Types.Debug.Sampler); ----------------------------------------------------------------------------- -- Sampler Parameters -- ----------------------------------------------------------------------------- procedure Set_Minifying_Filter (Object : Sampler; Filter : Minifying_Function); procedure Set_Magnifying_Filter (Object : Sampler; Filter : Magnifying_Function); procedure Set_Minimum_LoD (Object : Sampler; Level : Double); procedure Set_Maximum_LoD (Object : Sampler; Level : Double); procedure Set_LoD_Bias (Object : Sampler; Level : Double); -- Adjust the selection of a mipmap image. A positive level will -- cause larger mipmaps to be selected. A too large bias can -- result in visual aliasing, but if the bias is small enough it -- can make the texture look a bit sharper. procedure Set_Max_Anisotropy (Object : Sampler; Degree : Double) with Pre => Degree >= 1.0; -- Set the maximum amount of anisotropy filtering to reduce the blurring -- of textures (caused by mipmap filtering) that are viewed at an -- oblique angle. -- -- For best results, combine the use of anisotropy filtering with -- a Linear_Mipmap_Linear minification filter and a Linear maxification -- filter. procedure Set_X_Wrapping (Object : Sampler; Mode : Wrapping_Mode); procedure Set_Y_Wrapping (Object : Sampler; Mode : Wrapping_Mode); procedure Set_Z_Wrapping (Object : Sampler; Mode : Wrapping_Mode); procedure Set_Border_Color (Object : Sampler; Color : Colors.Border_Color); procedure Set_Compare_X_To_Texture (Object : Sampler; Enabled : Boolean); procedure Set_Compare_Function (Object : Sampler; Func : Compare_Function); private for Minifying_Function use (Nearest => 16#2600#, Linear => 16#2601#, Nearest_Mipmap_Nearest => 16#2700#, Linear_Mipmap_Nearest => 16#2701#, Nearest_Mipmap_Linear => 16#2702#, Linear_Mipmap_Linear => 16#2703#); for Minifying_Function'Size use Int'Size; for Magnifying_Function use (Nearest => 16#2600#, Linear => 16#2601#); for Magnifying_Function'Size use Int'Size; for Wrapping_Mode use (Repeat => 16#2901#, Clamp_To_Border => 16#812D#, Clamp_To_Edge => 16#812F#, Mirrored_Repeat => 16#8370#, Mirror_Clamp_To_Edge => 16#8743#); for Wrapping_Mode'Size use Int'Size; type Sampler is new GL_Object with null record; end GL.Objects.Samplers;
VitalijBondarenko/adanls
Ada
12,230
ads
------------------------------------------------------------------------------ -- -- -- Copyright (c) 2014-2022 Vitalii Bondarenko <[email protected]> -- -- -- ------------------------------------------------------------------------------ -- -- -- The MIT License (MIT) -- -- -- -- 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. -- ------------------------------------------------------------------------------ -- X/Open’s nl_langinfo. with Interfaces; use Interfaces; package L10n.Langinfo is type Locale_Item is (RADIXCHAR, -- Radix character (decimal point). -- The same as the value returned by Localeconv in the Decimal_Point -- element of the Lconv_Record. THOUSEP, -- Separator for thousands. -- The same as the value returned by Localeconv in the Thousands_Sep -- element of the Lconv_Record. CRNCYSTR, -- Local currency symbol, preceded by '-' if the symbol should appear -- before the value, '+' if the symbol should appear after the value, -- or '.' if the symbol should replace the radix character. If the local -- currency symbol is the empty string, implementations may return the -- empty string. D_FMT, -- Value can be used as a format string for represent date in a -- locale-specific way. AM_STR, PM_STR, -- Strings with appropriate ante-meridiem/post-meridiem affix. -- NOTE that in locales which do not use this time representation these -- strings might be empty, in which case the am/pm format cannot be -- used at all. DAY_1, DAY_2, DAY_3, DAY_4, DAY_5, DAY_6, DAY_7, -- DAY_{1-7} is full weekday names. -- DAY_1 corresponds to Sunday. ABDAY_1, ABDAY_2, ABDAY_3, ABDAY_4, ABDAY_5, ABDAY_6, ABDAY_7, -- ABDAY_{1-7} is abbreviated weekday names. -- ABDAY_1 corresponds to Sunday. MON_1, MON_2, MON_3, MON_4, MON_5, MON_6, MON_7, MON_8, MON_9, MON_10, MON_11, MON_12, -- MON_{1-12} is full month names. -- MON_1 corresponds to January. ABMON_1, ABMON_2, ABMON_3, ABMON_4, ABMON_5, ABMON_6, ABMON_7, ABMON_8, ABMON_9, ABMON_10, ABMON_11, ABMON_12, -- ABMON_{1-12} is abbreviated month names. -- ABMON_1 corresponds to January. T_FMT, -- Value can be used as a format string for represent time in a -- locale-specific way. CODESET, -- String with the name of the coded character set used in the selected -- locale. D_T_FMT, -- Value can be used as a format string for represent time and date in -- a locale-specific way. T_FMT_AMPM, -- Value can be used as a format string for represent time in the -- 12-hour clock format with AM_STR and PM_STR. -- NOTE that if the am/pm format does not make any sense for the -- selected locale, the return value might be the same as the one for -- T_FMT. ERA, -- Value represents the era used in the current locale. Most locales do -- not define this value. Normally it should not be necessary to use -- this value directly. ERA_D_FMT, -- Value can be used as a format string for represent a date in a -- locale-specific era-based way. ALT_DIGITS, -- Value is a representation of up to 100 values used to represent the -- values 0 to 99. As for ERA this value is not intended to be used -- directly. ERA_D_T_FMT, -- Value can be used as a format string for represent dates and times in -- a locale-specific era-based way. ERA_T_FMT, -- Value can be used as a format string for represent time in a -- locale-specific era-based way. ALTMON_1, ALTMON_2, ALTMON_3, ALTMON_4, ALTMON_5, ALTMON_6, ALTMON_7, ALTMON_8, ALTMON_9, ALTMON_10, ALTMON_11, ALTMON_12, -- Long month names, in the grammatical form used when the month -- is named by itself. ALTMON_1 corresponds to January. YESEXPR, -- Regular expression which can be used to recognize a positive response -- to a yes/no question. NOEXPR -- Regular expression which can be used to recognize a negative response -- to a yes/no question. ); pragma Convention (C, Locale_Item); -- Enumeration of locale items that can be queried with 'Nl_Langinfo'. function Nl_Langinfo (Item : Locale_Item) return String; -- The function shall return a string containing information relevant to -- the particular language or cultural area defined in the current locale. private LOCALE_SDECIMAL : constant := 16#000e#; LOCALE_STHOUSAND : constant := 16#000f#; LOCALE_SGROUPING : constant := 16#0010#; LOCALE_SCURRENCY : constant := 16#0014#; LOCALE_SMONDECIMALSEP : constant := 16#0016#; LOCALE_SMONTHOUSANDSEP : constant := 16#0017#; LOCALE_SMONGROUPING : constant := 16#0018#; LOCALE_SDATE : constant := 16#001d#; LOCALE_STIME : constant := 16#001e#; LOCALE_SSHORTDATE : constant := 16#001f#; LOCALE_SLONGDATE : constant := 16#0020#; LOCALE_S1159 : constant := 16#0028#; LOCALE_S2359 : constant := 16#0029#; LOCALE_SDAYNAME1 : constant := 16#002a#; LOCALE_SDAYNAME2 : constant := 16#002b#; LOCALE_SDAYNAME3 : constant := 16#002c#; LOCALE_SDAYNAME4 : constant := 16#002d#; LOCALE_SDAYNAME5 : constant := 16#002e#; LOCALE_SDAYNAME6 : constant := 16#002f#; LOCALE_SDAYNAME7 : constant := 16#0030#; LOCALE_SABBREVDAYNAME1 : constant := 16#0031#; LOCALE_SABBREVDAYNAME2 : constant := 16#0032#; LOCALE_SABBREVDAYNAME3 : constant := 16#0033#; LOCALE_SABBREVDAYNAME4 : constant := 16#0034#; LOCALE_SABBREVDAYNAME5 : constant := 16#0035#; LOCALE_SABBREVDAYNAME6 : constant := 16#0036#; LOCALE_SABBREVDAYNAME7 : constant := 16#0037#; LOCALE_SMONTHNAME1 : constant := 16#0038#; LOCALE_SMONTHNAME2 : constant := 16#0039#; LOCALE_SMONTHNAME3 : constant := 16#003a#; LOCALE_SMONTHNAME4 : constant := 16#003b#; LOCALE_SMONTHNAME5 : constant := 16#003c#; LOCALE_SMONTHNAME6 : constant := 16#003d#; LOCALE_SMONTHNAME7 : constant := 16#003e#; LOCALE_SMONTHNAME8 : constant := 16#003f#; LOCALE_SMONTHNAME9 : constant := 16#0040#; LOCALE_SMONTHNAME10 : constant := 16#0041#; LOCALE_SMONTHNAME11 : constant := 16#0042#; LOCALE_SMONTHNAME12 : constant := 16#0043#; LOCALE_SABBREVMONTHNAME1 : constant := 16#0044#; LOCALE_SABBREVMONTHNAME2 : constant := 16#0045#; LOCALE_SABBREVMONTHNAME3 : constant := 16#0046#; LOCALE_SABBREVMONTHNAME4 : constant := 16#0047#; LOCALE_SABBREVMONTHNAME5 : constant := 16#0048#; LOCALE_SABBREVMONTHNAME6 : constant := 16#0049#; LOCALE_SABBREVMONTHNAME7 : constant := 16#004a#; LOCALE_SABBREVMONTHNAME8 : constant := 16#004b#; LOCALE_SABBREVMONTHNAME9 : constant := 16#004c#; LOCALE_SABBREVMONTHNAME10 : constant := 16#004d#; LOCALE_SABBREVMONTHNAME11 : constant := 16#004e#; LOCALE_SABBREVMONTHNAME12 : constant := 16#004f#; LOCALE_STIMEFORMAT : constant := 16#1003#; LOCALE_IDEFAULTANSICODEPAGE : constant := 16#1004#; for Locale_Item use (RADIXCHAR => LOCALE_SDECIMAL, THOUSEP => LOCALE_STHOUSAND, CRNCYSTR => LOCALE_SCURRENCY, D_FMT => LOCALE_SSHORTDATE, AM_STR => LOCALE_S1159, PM_STR => LOCALE_S2359, DAY_1 => LOCALE_SDAYNAME1, DAY_2 => LOCALE_SDAYNAME2, DAY_3 => LOCALE_SDAYNAME3, DAY_4 => LOCALE_SDAYNAME4, DAY_5 => LOCALE_SDAYNAME5, DAY_6 => LOCALE_SDAYNAME6, DAY_7 => LOCALE_SDAYNAME7, ABDAY_1 => LOCALE_SABBREVDAYNAME1, ABDAY_2 => LOCALE_SABBREVDAYNAME2, ABDAY_3 => LOCALE_SABBREVDAYNAME3, ABDAY_4 => LOCALE_SABBREVDAYNAME4, ABDAY_5 => LOCALE_SABBREVDAYNAME5, ABDAY_6 => LOCALE_SABBREVDAYNAME6, ABDAY_7 => LOCALE_SABBREVDAYNAME7, MON_1 => LOCALE_SMONTHNAME1, MON_2 => LOCALE_SMONTHNAME2, MON_3 => LOCALE_SMONTHNAME3, MON_4 => LOCALE_SMONTHNAME4, MON_5 => LOCALE_SMONTHNAME5, MON_6 => LOCALE_SMONTHNAME6, MON_7 => LOCALE_SMONTHNAME7, MON_8 => LOCALE_SMONTHNAME8, MON_9 => LOCALE_SMONTHNAME9, MON_10 => LOCALE_SMONTHNAME10, MON_11 => LOCALE_SMONTHNAME11, MON_12 => LOCALE_SMONTHNAME12, ABMON_1 => LOCALE_SABBREVMONTHNAME1, ABMON_2 => LOCALE_SABBREVMONTHNAME2, ABMON_3 => LOCALE_SABBREVMONTHNAME3, ABMON_4 => LOCALE_SABBREVMONTHNAME4, ABMON_5 => LOCALE_SABBREVMONTHNAME5, ABMON_6 => LOCALE_SABBREVMONTHNAME6, ABMON_7 => LOCALE_SABBREVMONTHNAME7, ABMON_8 => LOCALE_SABBREVMONTHNAME8, ABMON_9 => LOCALE_SABBREVMONTHNAME9, ABMON_10 => LOCALE_SABBREVMONTHNAME10, ABMON_11 => LOCALE_SABBREVMONTHNAME11, ABMON_12 => LOCALE_SABBREVMONTHNAME12, T_FMT => LOCALE_STIMEFORMAT, CODESET => LOCALE_IDEFAULTANSICODEPAGE, D_T_FMT => 16#20028#, T_FMT_AMPM => 16#2002B#, ERA => 16#2002C#, ERA_D_FMT => 16#2002E#, ALT_DIGITS => 16#2002F#, ERA_D_T_FMT => 16#20030#, ERA_T_FMT => 16#20031#, ALTMON_1 => 16#2006F#, ALTMON_2 => 16#20070#, ALTMON_3 => 16#20071#, ALTMON_4 => 16#20072#, ALTMON_5 => 16#20073#, ALTMON_6 => 16#20074#, ALTMON_7 => 16#20075#, ALTMON_8 => 16#20076#, ALTMON_9 => 16#20077#, ALTMON_10 => 16#20078#, ALTMON_11 => 16#20079#, ALTMON_12 => 16#2007A#, YESEXPR => 16#50000#, NOEXPR => 16#50001#); end L10n.Langinfo;
reznikmm/matreshka
Ada
18,423
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with AMF.Elements; with AMF.Internals.Element_Collections; with AMF.Internals.Helpers; with AMF.Internals.Tables.UML_Attributes; with AMF.Visitors.UML_Iterators; with AMF.Visitors.UML_Visitors; with League.Strings.Internals; with Matreshka.Internals.Strings; package body AMF.Internals.UML_Component_Realizations is ------------------- -- Enter_Element -- ------------------- overriding procedure Enter_Element (Self : not null access constant UML_Component_Realization_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then AMF.Visitors.UML_Visitors.UML_Visitor'Class (Visitor).Enter_Component_Realization (AMF.UML.Component_Realizations.UML_Component_Realization_Access (Self), Control); end if; end Enter_Element; ------------------- -- Leave_Element -- ------------------- overriding procedure Leave_Element (Self : not null access constant UML_Component_Realization_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then AMF.Visitors.UML_Visitors.UML_Visitor'Class (Visitor).Leave_Component_Realization (AMF.UML.Component_Realizations.UML_Component_Realization_Access (Self), Control); end if; end Leave_Element; ------------------- -- Visit_Element -- ------------------- overriding procedure Visit_Element (Self : not null access constant UML_Component_Realization_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Iterator in AMF.Visitors.UML_Iterators.UML_Iterator'Class then AMF.Visitors.UML_Iterators.UML_Iterator'Class (Iterator).Visit_Component_Realization (Visitor, AMF.UML.Component_Realizations.UML_Component_Realization_Access (Self), Control); end if; end Visit_Element; --------------------- -- Get_Abstraction -- --------------------- overriding function Get_Abstraction (Self : not null access constant UML_Component_Realization_Proxy) return AMF.UML.Components.UML_Component_Access is begin return AMF.UML.Components.UML_Component_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Abstraction (Self.Element))); end Get_Abstraction; --------------------- -- Set_Abstraction -- --------------------- overriding procedure Set_Abstraction (Self : not null access UML_Component_Realization_Proxy; To : AMF.UML.Components.UML_Component_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Abstraction (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Abstraction; ------------------------------ -- Get_Realizing_Classifier -- ------------------------------ overriding function Get_Realizing_Classifier (Self : not null access constant UML_Component_Realization_Proxy) return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is begin return AMF.UML.Classifiers.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Realizing_Classifier (Self.Element))); end Get_Realizing_Classifier; ----------------- -- Get_Mapping -- ----------------- overriding function Get_Mapping (Self : not null access constant UML_Component_Realization_Proxy) return AMF.UML.Opaque_Expressions.UML_Opaque_Expression_Access is begin return AMF.UML.Opaque_Expressions.UML_Opaque_Expression_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Mapping (Self.Element))); end Get_Mapping; ----------------- -- Set_Mapping -- ----------------- overriding procedure Set_Mapping (Self : not null access UML_Component_Realization_Proxy; To : AMF.UML.Opaque_Expressions.UML_Opaque_Expression_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Mapping (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Mapping; ---------------- -- Get_Client -- ---------------- overriding function Get_Client (Self : not null access constant UML_Component_Realization_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is begin return AMF.UML.Named_Elements.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Client (Self.Element))); end Get_Client; ------------------ -- Get_Supplier -- ------------------ overriding function Get_Supplier (Self : not null access constant UML_Component_Realization_Proxy) return AMF.UML.Named_Elements.Collections.Set_Of_UML_Named_Element is begin return AMF.UML.Named_Elements.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Supplier (Self.Element))); end Get_Supplier; ---------------- -- Get_Source -- ---------------- overriding function Get_Source (Self : not null access constant UML_Component_Realization_Proxy) return AMF.UML.Elements.Collections.Set_Of_UML_Element is begin return AMF.UML.Elements.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Source (Self.Element))); end Get_Source; ---------------- -- Get_Target -- ---------------- overriding function Get_Target (Self : not null access constant UML_Component_Realization_Proxy) return AMF.UML.Elements.Collections.Set_Of_UML_Element is begin return AMF.UML.Elements.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Target (Self.Element))); end Get_Target; ------------------------- -- Get_Related_Element -- ------------------------- overriding function Get_Related_Element (Self : not null access constant UML_Component_Realization_Proxy) return AMF.UML.Elements.Collections.Set_Of_UML_Element is begin return AMF.UML.Elements.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Related_Element (Self.Element))); end Get_Related_Element; --------------------------- -- Get_Client_Dependency -- --------------------------- overriding function Get_Client_Dependency (Self : not null access constant UML_Component_Realization_Proxy) return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency is begin return AMF.UML.Dependencies.Collections.Wrap (AMF.Internals.Element_Collections.Wrap (AMF.Internals.Tables.UML_Attributes.Internal_Get_Client_Dependency (Self.Element))); end Get_Client_Dependency; ------------------------- -- Get_Name_Expression -- ------------------------- overriding function Get_Name_Expression (Self : not null access constant UML_Component_Realization_Proxy) return AMF.UML.String_Expressions.UML_String_Expression_Access is begin return AMF.UML.String_Expressions.UML_String_Expression_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Name_Expression (Self.Element))); end Get_Name_Expression; ------------------------- -- Set_Name_Expression -- ------------------------- overriding procedure Set_Name_Expression (Self : not null access UML_Component_Realization_Proxy; To : AMF.UML.String_Expressions.UML_String_Expression_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Name_Expression (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Name_Expression; ------------------- -- Get_Namespace -- ------------------- overriding function Get_Namespace (Self : not null access constant UML_Component_Realization_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access is begin return AMF.UML.Namespaces.UML_Namespace_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Namespace (Self.Element))); end Get_Namespace; ------------------------ -- Get_Qualified_Name -- ------------------------ overriding function Get_Qualified_Name (Self : not null access constant UML_Component_Realization_Proxy) return AMF.Optional_String is begin declare use type Matreshka.Internals.Strings.Shared_String_Access; Aux : constant Matreshka.Internals.Strings.Shared_String_Access := AMF.Internals.Tables.UML_Attributes.Internal_Get_Qualified_Name (Self.Element); begin if Aux = null then return (Is_Empty => True); else return (False, League.Strings.Internals.Create (Aux)); end if; end; end Get_Qualified_Name; ----------------------------------- -- Get_Owning_Template_Parameter -- ----------------------------------- overriding function Get_Owning_Template_Parameter (Self : not null access constant UML_Component_Realization_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is begin return AMF.UML.Template_Parameters.UML_Template_Parameter_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Owning_Template_Parameter (Self.Element))); end Get_Owning_Template_Parameter; ----------------------------------- -- Set_Owning_Template_Parameter -- ----------------------------------- overriding procedure Set_Owning_Template_Parameter (Self : not null access UML_Component_Realization_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Owning_Template_Parameter (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Owning_Template_Parameter; ---------------------------- -- Get_Template_Parameter -- ---------------------------- overriding function Get_Template_Parameter (Self : not null access constant UML_Component_Realization_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is begin return AMF.UML.Template_Parameters.UML_Template_Parameter_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Template_Parameter (Self.Element))); end Get_Template_Parameter; ---------------------------- -- Set_Template_Parameter -- ---------------------------- overriding procedure Set_Template_Parameter (Self : not null access UML_Component_Realization_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Template_Parameter (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Template_Parameter; ------------------------- -- All_Owning_Packages -- ------------------------- overriding function All_Owning_Packages (Self : not null access constant UML_Component_Realization_Proxy) return AMF.UML.Packages.Collections.Set_Of_UML_Package is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "All_Owning_Packages unimplemented"); raise Program_Error with "Unimplemented procedure UML_Component_Realization_Proxy.All_Owning_Packages"; return All_Owning_Packages (Self); end All_Owning_Packages; ----------------------------- -- Is_Distinguishable_From -- ----------------------------- overriding function Is_Distinguishable_From (Self : not null access constant UML_Component_Realization_Proxy; N : AMF.UML.Named_Elements.UML_Named_Element_Access; Ns : AMF.UML.Namespaces.UML_Namespace_Access) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented"); raise Program_Error with "Unimplemented procedure UML_Component_Realization_Proxy.Is_Distinguishable_From"; return Is_Distinguishable_From (Self, N, Ns); end Is_Distinguishable_From; --------------- -- Namespace -- --------------- overriding function Namespace (Self : not null access constant UML_Component_Realization_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Namespace unimplemented"); raise Program_Error with "Unimplemented procedure UML_Component_Realization_Proxy.Namespace"; return Namespace (Self); end Namespace; ------------------------ -- Is_Compatible_With -- ------------------------ overriding function Is_Compatible_With (Self : not null access constant UML_Component_Realization_Proxy; P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Is_Compatible_With unimplemented"); raise Program_Error with "Unimplemented procedure UML_Component_Realization_Proxy.Is_Compatible_With"; return Is_Compatible_With (Self, P); end Is_Compatible_With; --------------------------- -- Is_Template_Parameter -- --------------------------- overriding function Is_Template_Parameter (Self : not null access constant UML_Component_Realization_Proxy) return Boolean is begin -- Generated stub: replace with real body! pragma Compile_Time_Warning (Standard.True, "Is_Template_Parameter unimplemented"); raise Program_Error with "Unimplemented procedure UML_Component_Realization_Proxy.Is_Template_Parameter"; return Is_Template_Parameter (Self); end Is_Template_Parameter; end AMF.Internals.UML_Component_Realizations;
AdaCore/gpr
Ada
339
ads
-- -- Copyright (C) 2020-2023, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-Exception -- with GPR2.C.JSON; use GPR2.C.JSON; package GPR2.C.Source is procedure Update_Source_Infos (Request : JSON_Value; Result : JSON_Value); procedure Dependencies (Request : JSON_Value; Result : JSON_Value); end GPR2.C.Source;
reznikmm/matreshka
Ada
4,589
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_Fo.Border_Top_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Fo_Border_Top_Attribute_Node is begin return Self : Fo_Border_Top_Attribute_Node do Matreshka.ODF_Fo.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Fo_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Fo_Border_Top_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Border_Top_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Fo_URI, Matreshka.ODF_String_Constants.Border_Top_Attribute, Fo_Border_Top_Attribute_Node'Tag); end Matreshka.ODF_Fo.Border_Top_Attributes;
reznikmm/matreshka
Ada
4,772
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Visitors; with ODF.DOM.Text_Author_Initials_Elements; package Matreshka.ODF_Text.Author_Initials_Elements is type Text_Author_Initials_Element_Node is new Matreshka.ODF_Text.Abstract_Text_Element_Node and ODF.DOM.Text_Author_Initials_Elements.ODF_Text_Author_Initials with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_Author_Initials_Element_Node; overriding function Get_Local_Name (Self : not null access constant Text_Author_Initials_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Text_Author_Initials_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Leave_Node (Self : not null access Text_Author_Initials_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); overriding procedure Visit_Node (Self : not null access Text_Author_Initials_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control); end Matreshka.ODF_Text.Author_Initials_Elements;
AdaCore/training_material
Ada
280
ads
with Ada.Calendar; package Base_Types is type Meters_T is digits 6; type Time_T is new Ada.Calendar.Day_Duration; type Meters_Per_Second_T is digits 6; function Speed (Meters : Meters_T; Time : Time_T) return Meters_Per_Second_T; end Base_Types;
charlie5/cBound
Ada
1,620
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_query_colors_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; colors_len : aliased Interfaces.Unsigned_16; pad1 : aliased swig.int8_t_Array (0 .. 21); end record; -- Item_Array -- type Item_Array is array (Interfaces.C.size_t range <>) of aliased xcb.xcb_query_colors_reply_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_query_colors_reply_t.Item, Element_Array => xcb.xcb_query_colors_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_query_colors_reply_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_query_colors_reply_t.Pointer, Element_Array => xcb.xcb_query_colors_reply_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_query_colors_reply_t;
reznikmm/matreshka
Ada
4,099
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_Font_Size_Rel_Complex_Attributes; package Matreshka.ODF_Style.Font_Size_Rel_Complex_Attributes is type Style_Font_Size_Rel_Complex_Attribute_Node is new Matreshka.ODF_Style.Abstract_Style_Attribute_Node and ODF.DOM.Style_Font_Size_Rel_Complex_Attributes.ODF_Style_Font_Size_Rel_Complex_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Font_Size_Rel_Complex_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Style_Font_Size_Rel_Complex_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Style.Font_Size_Rel_Complex_Attributes;
simonjwright/Quaternions
Ada
1,493
adb
with Ada.Numerics.Generic_Elementary_Functions; package body Generic_Quaternions is package Elementary_Functions is new Ada.Numerics.Generic_Elementary_Functions (Real); use Elementary_Functions; function "-" (Q : Quaternion) return Quaternion is (-Q.W, -Q.X, -Q.Y, -Q.Z); function "+" (L, R : Quaternion) return Quaternion is (L.W + R.W, L.X + R.X, L.Y + R.Y, L.Z + R.Z); function "-" (L, R : Quaternion) return Quaternion is (L.W - R.W, L.X - R.X, L.Y - R.Y, L.Z - R.Z); function "*" (L : Quaternion; R : Real) return Quaternion is (L.W * R, L.X * R, L.Y * R, L.Z * R); function "*" (L : Real; R : Quaternion) return Quaternion is (L * R.W, L * R.X, L * R.Y, L * R.Z); -- See https://en.wikipedia.org/wiki/Quaternion#Hamilton_product function "*" (L : Quaternion; R : Quaternion) return Quaternion is (W => L.W * R.W - L.X * R.X - L.Y * R.Y - L.Z * R.Z, X => L.W * R.X + L.X * R.W + L.Y * R.Z - L.Z * R.Y, Y => L.W * R.Y - L.X * R.Z + L.Y * R.W + L.Z * R.X, Z => L.W * R.Z + L.X * R.Y - L.Y * R.X + L.Z * R.W); function "/" (L : Quaternion; R : Real) return Quaternion is (L.W / R, L.X / R, L.Y / R, L.Z / R); function Conjugate (Q : Quaternion) return Quaternion is (Q.W, -Q.X, -Q.Y, -Q.Z); function Norm (Q : Quaternion) return Real is (Sqrt (Q.W ** 2 + Q.X ** 2 + Q.Y**2 + Q.Z**2)); function Normalize (Q : Quaternion) return Quaternion is (Q / Norm (Q)); end Generic_Quaternions;
reznikmm/matreshka
Ada
4,695
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_Presentation.Mouse_As_Pen_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Presentation_Mouse_As_Pen_Attribute_Node is begin return Self : Presentation_Mouse_As_Pen_Attribute_Node do Matreshka.ODF_Presentation.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Presentation_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Presentation_Mouse_As_Pen_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Mouse_As_Pen_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Presentation_URI, Matreshka.ODF_String_Constants.Mouse_As_Pen_Attribute, Presentation_Mouse_As_Pen_Attribute_Node'Tag); end Matreshka.ODF_Presentation.Mouse_As_Pen_Attributes;
jhumphry/parse_args
Ada
2,632
adb
-- generic_example -- An example of the use of parse_args with generic option types -- Copyright (c) 2015, James Humphry -- -- Permission to use, copy, modify, and/or distribute this software for any -- purpose with or without fee is hereby granted, provided that the above -- copyright notice and this permission notice appear in all copies. -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -- PERFORMANCE OF THIS SOFTWARE. with Parse_Args; use Parse_Args; with Ada.Text_IO; use Ada.Text_IO; with Generic_Example_Options; use Generic_Example_Options; procedure Generic_Example is AP : Argument_Parser; begin AP.Add_Option(Make_Boolean_Option(False), "help", 'h', Usage => "Display this help text"); AP.Add_Option(Compass_Option.Make_Option, "compass", 'c', Usage => "A compass point (North (default), South, East or West)"); AP.Add_Option(Even_Option.Make_Option, "even", 'e', Usage => "An even natural number (default 0)"); AP.Add_Option(Float_Option.Make_Option, "float", 'f', Usage => "A floating-point number (default 0.0)"); AP.Add_Option(Float_Array_Option.Make_Option, "float-array", 'g', Usage => "An array of floating-point numbers"); AP.Set_Prologue("A demonstration of the Parse_Args library with generic types."); AP.Parse_Command_Line; if AP.Parse_Success and then AP.Boolean_Value("help") then AP.Usage; elsif AP.Parse_Success then Put_Line("Compass point specified: " & Compass'Image(Compass_Option.Value(AP, "compass"))); Put_Line("Even number specified: " & Natural'Image(Even_Option.Value(AP, "even"))); Put_Line("Floating-point number specified: " & Float'Image(Float_Option.Value(AP, "float"))); if Float_Array_Option.Value(AP, "float-array") /= null then Put_Line("Floating-point number array: "); for I of Float_Array_Option.Value(AP, "float-array").all loop Put(Float'Image(I) & ", "); end loop; else Put_Line("No floating-point array specified."); end if; else Put_Line("Error while parsing command-line arguments: " & AP.Parse_Message); end if; end Generic_Example;
damaki/SPARKNaCl
Ada
2,346
ads
package SPARKNaCl.Sign with Pure, SPARK_Mode => On is -- Limited, so no assignment or comparison, and always -- pass-by-reference. type Signing_PK is limited private; type Signing_SK is limited private; -------------------------------------------------------- -- Public key signatures -------------------------------------------------------- procedure Keypair (SK_Raw : in Bytes_32; -- random please! PK : out Signing_PK; SK : out Signing_SK) with Global => null; procedure PK_From_Bytes (PK_Raw : in Bytes_32; PK : out Signing_PK) with Global => null; function Serialize (K : in Signing_SK) return Bytes_64 with Global => null; function Serialize (K : in Signing_PK) return Bytes_32 with Global => null; procedure Sanitize (K : out Signing_PK) with Global => null; procedure Sanitize (K : out Signing_SK) with Global => null; -- The length of a signature block that is prepended to a message -- when signed. Sign_Bytes : constant := 64; procedure Sign (SM : out Byte_Seq; M : in Byte_Seq; SK : in Signing_SK) with Global => null, Relaxed_Initialization => SM, Pre => (M'First = 0 and SM'First = 0 and M'Last <= N32'Last - Sign_Bytes) and then (SM'Length = M'Length + Sign_Bytes and SM'Last = M'Last + Sign_Bytes), Post => SM'Initialized; procedure Open (M : out Byte_Seq; Status : out Boolean; MLen : out I32; SM : in Byte_Seq; PK : in Signing_PK) with Global => null, Pre => M'First = 0 and SM'First = 0 and SM'Length = M'Length and SM'Last = M'Last and SM'Length >= Sign_Bytes; private -- Note - also limited types here in the full view to ensure -- no assignment and pass-by-reference in the body. type Signing_PK is limited record F : Bytes_32; end record; type Signing_SK is limited record F : Bytes_64; end record; end SPARKNaCl.Sign;
Gabriel-Degret/adalib
Ada
519
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 is pragma Pure (Ada); end Ada;
Tim-Tom/project-euler
Ada
58
ads
package Problem_31 is procedure Solve; end Problem_31;