repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
persan/protobuf-ada
Ada
2,039
ads
with AUnit.Test_Cases; use AUnit; package Message_Tests is type Test_Case is new AUnit.Test_Cases.Test_Case with null record; procedure Register_Tests (T : in out Test_Case); -- Register routines to be run function Name (T : Test_Case) return Test_String; -- Returns name identifying the test case ------------------- -- Test Routines -- ------------------- procedure Test_Floating_Point_Defaults (T : in out Test_Cases.Test_Case'Class); -- Tests default values set for floating point fields. procedure Test_Extreme_Small_Integer_Defaults (T : in out Test_Cases.Test_Case'Class); -- Tests extreme default values set for integer fields. procedure Test_String_Defaults (T : in out Test_Cases.Test_Case'Class); -- Tests default values set for string fields. procedure Test_Required (T : in out Test_Cases.Test_Case'Class); -- Tests that Is_Initialized returns false when required fields are missing. procedure Test_Required_Foreign (T : in out Test_Cases.Test_Case'Class); -- Tests that Is_Initialized returns false when required fields are missing in -- nested messages. procedure Test_Really_Large_Tag_Number (T : in out Test_Cases.Test_Case'Class); -- Tests that really large tag numbers don't break anything. procedure Test_Mutual_Recursion (T : in out Test_Cases.Test_Case'Class); -- Tests that mutually recursive message works. procedure Test_Enumeration_Values_In_Case_Statement (T : in out Test_Cases.Test_Case'Class); -- Tests that nested enumeration values can be used in case statements. procedure Test_Accessors (T : in out Test_Cases.Test_Case'Class); -- Tests setting field values for all protocol buffer types. procedure Test_Clear (T : in out Test_Cases.Test_Case'Class); -- Tests clearing a message with all fields set. procedure Test_Clear_One_Field (T : in out Test_Cases.Test_Case'Class); -- Set every field to a unique value, then clear one value and insure that -- only that one value is cleared. end Message_Tests;
reznikmm/matreshka
Ada
3,714
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Table_Source_Cell_Range_Elements is pragma Preelaborate; type ODF_Table_Source_Cell_Range is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Table_Source_Cell_Range_Access is access all ODF_Table_Source_Cell_Range'Class with Storage_Size => 0; end ODF.DOM.Table_Source_Cell_Range_Elements;
reznikmm/matreshka
Ada
3,767
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ package Matreshka.ODF_Attributes.FO.Border_Bottom is type FO_Border_Bottom_Node is new Matreshka.ODF_Attributes.FO.FO_Node_Base with null record; type FO_Border_Bottom_Access is access all FO_Border_Bottom_Node'Class; overriding function Get_Local_Name (Self : not null access constant FO_Border_Bottom_Node) return League.Strings.Universal_String; end Matreshka.ODF_Attributes.FO.Border_Bottom;
Rodeo-McCabe/orka
Ada
2,767
adb
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2020 onox <[email protected]> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. package body Orka.Timers is function Create_Timer return Timer is begin return Timer'(others => <>); end Create_Timer; use GL.Types; function Get_Duration (Value : UInt64) return Duration is Seconds : constant UInt64 := Value / 1e9; Nanoseconds : constant UInt64 := Value - Seconds * 1e9; begin return Duration (Seconds) + Duration (Nanoseconds) / 1e9; end Get_Duration; procedure Record_GPU_Duration (Object : in out Timer) is begin declare Stop_Time : constant UInt64 := Object.Query_Stop.Result; Start_Time : constant UInt64 := Object.Query_Start.Result; begin if Stop_Time > Start_Time then Object.GPU_Duration := Get_Duration (Stop_Time - Start_Time); end if; end; end Record_GPU_Duration; procedure Start (Object : in out Timer) is use GL.Objects.Queries; begin if Object.State = Waiting and then Object.Query_Stop.Result_Available then Object.Record_GPU_Duration; Object.State := Idle; end if; if Object.State = Idle then Object.CPU_Start := Get_Current_Time; Object.Query_Start.Record_Current_Time; Object.State := Busy; end if; end Start; procedure Stop (Object : in out Timer) is use GL.Objects.Queries; begin if Object.State = Busy then declare Current_Time : constant Long := Get_Current_Time; begin if Current_Time > Object.CPU_Start then Object.CPU_Duration := Get_Duration (UInt64 (Current_Time - Object.CPU_Start)); end if; end; Object.Query_Stop.Record_Current_Time; Object.State := Waiting; end if; end Stop; procedure Wait_For_Result (Object : in out Timer) is begin Object.Record_GPU_Duration; Object.State := Idle; end Wait_For_Result; function CPU_Duration (Object : Timer) return Duration is (Object.CPU_Duration); function GPU_Duration (Object : Timer) return Duration is (Object.GPU_Duration); end Orka.Timers;
reznikmm/matreshka
Ada
3,724
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Fo_Keep_With_Next_Attributes is pragma Preelaborate; type ODF_Fo_Keep_With_Next_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Fo_Keep_With_Next_Attribute_Access is access all ODF_Fo_Keep_With_Next_Attribute'Class with Storage_Size => 0; end ODF.DOM.Fo_Keep_With_Next_Attributes;
stcarrez/ada-servlet
Ada
1,340
adb
----------------------------------------------------------------------- -- servlet-rest-operation -- REST API Operation Definition -- Copyright (C) 2017, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body Servlet.Rest.Operation is URI_Mapping : aliased String := URI; Desc : aliased Static_Descriptor := (Next => null, Method => Method, Handler => Handler, Pattern => URI_Mapping'Access, Mimes => Mimes, Permission => Permission); function Definition return Descriptor_Access is begin return Desc'Access; end Definition; end Servlet.Rest.Operation;
kevans91/synth
Ada
26,425
adb
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../License.txt with Ada.Directories; with Ada.Text_IO; with Ada.Characters.Latin_1; with GNAT.OS_Lib; with Unix; package body Parameters is package AD renames Ada.Directories; package TIO renames Ada.Text_IO; package LAT renames Ada.Characters.Latin_1; package OSL renames GNAT.OS_Lib; -------------------------- -- load_configuration -- -------------------------- function load_configuration (num_cores : cpu_range) return Boolean is fields_present : Boolean; global_present : Boolean; sel_profile : JT.Text; begin if not AD.Exists (conf_location) then declare test : String := determine_portsdirs; begin if test = "" then return False; end if; end; declare File_Handle : TIO.File_Type; begin mkdirp_from_file (conf_location); TIO.Create (File => File_Handle, Mode => TIO.Out_File, Name => conf_location); TIO.Put_Line (File_Handle, "; This Synth configuration file is " & "automatically generated"); TIO.Put_Line (File_Handle, "; Take care when hand editing!"); TIO.Close (File => File_Handle); exception when Error : others => TIO.Put_Line ("Failed to create " & conf_location); return False; end; end if; internal_config.Init (File_Name => conf_location, On_Type_Mismatch => Config.Be_Quiet); if section_exists (master_section, global_01) then global_present := all_global_present; else write_blank_section (master_section); global_present := False; end if; declare envprofile : String := OSL.Getenv ("SYNTHPROFILE").all; begin sel_profile := extract_string (master_section, global_01, live_system); if envprofile /= "" then if section_exists (envprofile, Field_01) then sel_profile := JT.SUS (envprofile); end if; end if; end; declare profile : constant String := JT.USS (sel_profile); begin if section_exists (profile, Field_01) then fields_present := all_params_present (profile); else write_blank_section (section => profile); fields_present := False; end if; configuration := load_specific_profile (profile, num_cores); end; if not fields_present then write_configuration (JT.USS (configuration.profile)); end if; if not global_present then write_master_section; end if; return True; exception when mishap : others => return False; end load_configuration; --------------------------- -- determine_portsdirs -- --------------------------- function determine_portsdirs return String is begin -- PORTSDIR in environment takes precedence declare portsdir : String := OSL.Getenv ("PORTSDIR").all; begin if portsdir /= "" then if AD.Exists (portsdir) then return portsdir; end if; end if; end; declare portsdir : String := query_portsdir; begin if portsdir = "" then TIO.Put_Line ("It seems that an invalid PORTSDIR is defined in " & "/etc/make.conf"); return ""; end if; if AD.Exists (portsdir) then return portsdir; end if; end; if AD.Exists (std_dports_loc) then return std_dports_loc; elsif AD.Exists (std_ports_loc) then return std_ports_loc; end if; TIO.Put_Line ("PORTSDIR cannot be determined."); TIO.Put_Line ("Please set it to a valid path in then environment or " & "/etc/make.conf"); return ""; end determine_portsdirs; ----------------------------- -- load_specific_profile -- ----------------------------- function load_specific_profile (profile : String; num_cores : cpu_range) return configuration_record is function opsys_ok return Boolean; def_builders : Integer; def_jlimit : Integer; res : configuration_record; function opsys_ok return Boolean is begin return (JT.equivalent (res.operating_sys, "FreeBSD") or else JT.equivalent (res.operating_sys, "DragonFly")); end opsys_ok; begin -- The profile *must* exist before this procedure is called! default_parallelism (num_cores => num_cores, num_builders => def_builders, jobs_per_builder => def_jlimit); res.dir_packages := extract_string (profile, Field_01, LS_Packages); if param_set (profile, Field_03) then -- We can only check determine_portsdirs when no synth.ini file -- exists. It's possible that it was configured with PORTSDIR -- set which can be removed later. Use the dummy std_ports_loc -- when we are sure the parameter is set (so dummy will NOT be used) res.dir_portsdir := extract_string (profile, Field_03, std_ports_loc); else res.dir_portsdir := extract_string (profile, Field_03, determine_portsdirs); end if; res.dir_repository := res.dir_packages; JT.SU.Append (res.dir_repository, "/All"); if param_set (profile, Field_04) then res.dir_distfiles := extract_string (profile, Field_04, std_distfiles); else res.dir_distfiles := extract_string (profile, Field_04, query_distfiles (JT.USS (res.dir_portsdir))); end if; res.dir_buildbase := extract_string (profile, Field_05, LS_Buildbase); res.dir_logs := extract_string (profile, Field_06, LS_Logs); res.dir_ccache := extract_string (profile, Field_07, no_ccache); res.num_builders := builders (extract_integer (profile, Field_08, def_builders)); res.jobs_limit := builders (extract_integer (profile, Field_09, def_jlimit)); if param_set (profile, Field_10) then res.tmpfs_workdir := extract_boolean (profile, Field_10, False); else res.tmpfs_workdir := extract_boolean (profile, Field_10, enough_memory (res.num_builders)); end if; if param_set (profile, Field_11) then res.tmpfs_localbase := extract_boolean (profile, Field_11, False); else res.tmpfs_localbase := extract_boolean (profile, Field_11, enough_memory (res.num_builders)); end if; if param_set (profile, Field_12) then res.operating_sys := extract_string (profile, Field_12, std_opsys); else res.operating_sys := extract_string (profile, Field_12, query_opsys (JT.USS (res.dir_portsdir))); end if; if not opsys_ok then TIO.Put_Line ("Unknown operating system: " & JT.USS (res.operating_sys)); TIO.Put_Line ("This configuration entry must be either 'FreeBSD' or 'DragonFly'"); TIO.Put_Line ("Manually edit " & Definitions.host_localbase & "/etc/synth/synth.ini file to remove the line of the"); TIO.Put_Line (profile & " profile starting with 'Operating_system='"); TIO.Put_Line ("The synth.ini file should regenerate properly on the next Synth command."); TIO.Put_Line (""); raise bad_opsys; end if; res.dir_options := extract_string (profile, Field_13, std_options); res.dir_system := extract_string (profile, Field_14, std_sysbase); res.avec_ncurses := extract_boolean (profile, Field_15, True); res.defer_prebuilt := extract_boolean (profile, Field_16, False); res.profile := JT.SUS (profile); return res; end load_specific_profile; --------------------------- -- write_configuration -- --------------------------- procedure write_configuration (profile : String := live_system) is contents : String := generated_section; begin internal_config.Replace_Section (profile, contents); exception when Error : others => raise update_config with "Failed to update [" & profile & "] at " & conf_location; end write_configuration; --------------------------- -- write_blank_section -- --------------------------- procedure write_blank_section (section : String) is File_Handle : TIO.File_Type; begin TIO.Open (File => File_Handle, Mode => TIO.Append_File, Name => conf_location); TIO.Put_Line (File_Handle, ""); TIO.Put_Line (File_Handle, "[" & section & "]"); TIO.Close (File_Handle); exception when Error : others => raise update_config with "Failed to append [" & section & "] at " & conf_location; end write_blank_section; --------------------------- -- default_parallelism -- --------------------------- procedure default_parallelism (num_cores : cpu_range; num_builders : out Integer; jobs_per_builder : out Integer) is begin case num_cores is when 1 => num_builders := 1; jobs_per_builder := 1; when 2 | 3 => num_builders := 2; jobs_per_builder := 2; when 4 | 5 => num_builders := 3; jobs_per_builder := 3; when 6 | 7 => num_builders := 4; jobs_per_builder := 3; when 8 | 9 => num_builders := 6; jobs_per_builder := 4; when 10 | 11 => num_builders := 8; jobs_per_builder := 4; when others => num_builders := (Integer (num_cores) * 3) / 4; jobs_per_builder := 5; end case; end default_parallelism; ---------------------- -- extract_string -- ---------------------- function extract_string (profile, mark, default : String) return JT.Text is begin return JT.SUS (internal_config.Value_Of (profile, mark, default)); end extract_string; ----------------------- -- extract_boolean -- ----------------------- function extract_boolean (profile, mark : String; default : Boolean) return Boolean is begin return internal_config.Value_Of (profile, mark, default); end extract_boolean; ----------------------- -- extract_integer -- ----------------------- function extract_integer (profile, mark : String; default : Integer) return Integer is begin return internal_config.Value_Of (profile, mark, default); end extract_integer; ----------------- -- param_set -- ----------------- function param_set (profile, field : String) return Boolean is garbage : constant String := "this-is-garbage"; begin return internal_config.Value_Of (profile, field, garbage) /= garbage; end param_set; ---------------------- -- section_exists -- ---------------------- function section_exists (profile, mark : String) return Boolean is begin return param_set (profile, mark); end section_exists; -------------------------- -- all_params_present -- -------------------------- function all_params_present (profile : String) return Boolean is begin return param_set (profile, Field_01) and then param_set (profile, Field_02) and then param_set (profile, Field_03) and then param_set (profile, Field_04) and then param_set (profile, Field_05) and then param_set (profile, Field_06) and then param_set (profile, Field_07) and then param_set (profile, Field_08) and then param_set (profile, Field_09) and then param_set (profile, Field_10) and then param_set (profile, Field_11) and then param_set (profile, Field_12) and then param_set (profile, Field_13) and then param_set (profile, Field_14) and then param_set (profile, Field_15) and then param_set (profile, Field_16); end all_params_present; -------------------------- -- all_global_present -- -------------------------- function all_global_present return Boolean is begin return param_set (master_section, global_01); end all_global_present; ------------------------- -- generated_section -- ------------------------- function generated_section return String is function USS (US : JT.Text) return String; function BDS (BD : builders) return String; function TFS (TF : Boolean) return String; function USS (US : JT.Text) return String is begin return "= " & JT.USS (US) & LAT.LF; end USS; function BDS (BD : builders) return String is BDI : constant String := Integer'Image (Integer (BD)); begin return LAT.Equals_Sign & BDI & LAT.LF; end BDS; function TFS (TF : Boolean) return String is begin if TF then return LAT.Equals_Sign & " true" & LAT.LF; else return LAT.Equals_Sign & " false" & LAT.LF; end if; end TFS; begin return Field_12 & USS (configuration.operating_sys) & Field_01 & USS (configuration.dir_packages) & Field_02 & USS (configuration.dir_repository) & Field_03 & USS (configuration.dir_portsdir) & Field_13 & USS (configuration.dir_options) & Field_04 & USS (configuration.dir_distfiles) & Field_05 & USS (configuration.dir_buildbase) & Field_06 & USS (configuration.dir_logs) & Field_07 & USS (configuration.dir_ccache) & Field_14 & USS (configuration.dir_system) & Field_08 & BDS (configuration.num_builders) & Field_09 & BDS (configuration.jobs_limit) & Field_10 & TFS (configuration.tmpfs_workdir) & Field_11 & TFS (configuration.tmpfs_localbase) & Field_15 & TFS (configuration.avec_ncurses) & Field_16 & TFS (configuration.defer_prebuilt); end generated_section; ----------------------- -- query_distfiles -- ----------------------- function query_distfiles (portsdir : String) return String is begin return query_generic (portsdir, "DISTDIR"); end query_distfiles; ------------------ -- query_opsys -- ------------------- function query_opsys (portsdir : String) return String is begin return query_generic (portsdir, "OPSYS"); end query_opsys; --------------------- -- query_generic -- --------------------- function query_generic (portsdir, value : String) return String is command : constant String := "/usr/bin/make -C " & portsdir & "/ports-mgmt/pkg -V " & value; begin return query_generic_core (command); end query_generic; -------------------------- -- query_generic_core -- -------------------------- function query_generic_core (command : String) return String is content : JT.Text; status : Integer; CR_loc : Integer; CR : constant String (1 .. 1) := (1 => Character'Val (10)); begin content := Unix.piped_command (command, status); if status /= 0 then raise make_query with command; end if; CR_loc := JT.SU.Index (Source => content, Pattern => CR); return JT.SU.Slice (Source => content, Low => 1, High => CR_loc - 1); end query_generic_core; ---------------------- -- query_portsdir -- ---------------------- function query_portsdir return String is command : constant String := "/usr/bin/make " & "-f /usr/share/mk/bsd.port.mk -V PORTSDIR"; begin return query_generic_core (command); exception when others => return ""; end query_portsdir; ----------------------------- -- query_physical_memory -- ----------------------------- procedure query_physical_memory is command : constant String := "/sbin/sysctl hw.physmem"; content : JT.Text; status : Integer; CR_loc : Integer; SP_loc : Integer; CR : constant String (1 .. 1) := (1 => Character'Val (10)); SP : constant String (1 .. 1) := (1 => LAT.Space); begin if memory_megs > 0 then return; end if; content := Unix.piped_command (command, status); if status /= 0 then raise make_query with command; end if; SP_loc := JT.SU.Index (Source => content, Pattern => SP); CR_loc := JT.SU.Index (Source => content, Pattern => CR); declare type memtype is mod 2**64; numbers : String := JT.USS (content)(SP_loc + 1 .. CR_loc - 1); bytes : constant memtype := memtype'Value (numbers); megs : constant memtype := bytes / 1024 / 1024; begin memory_megs := Natural (megs); end; end query_physical_memory; --------------------- -- enough_memory -- --------------------- function enough_memory (num_builders : builders) return Boolean is megs_per_slave : Natural; begin query_physical_memory; megs_per_slave := memory_megs / Positive (num_builders); return megs_per_slave >= 1280; end enough_memory; ---------------------------- -- write_master_section -- ---------------------------- procedure write_master_section is function USS (US : JT.Text) return String; function USS (US : JT.Text) return String is begin return "= " & JT.USS (US) & LAT.LF; end USS; contents : String := global_01 & USS (configuration.profile); begin internal_config.Replace_Section (master_section, contents); exception when Error : others => raise update_config with "Failed to update [" & master_section & "] at " & conf_location; end write_master_section; --------------------- -- sections_list -- --------------------- function sections_list return JT.Text is handle : TIO.File_Type; result : JT.Text; begin TIO.Open (File => handle, Mode => TIO.In_File, Name => conf_location); while not TIO.End_Of_File (handle) loop declare Line : String := TIO.Get_Line (handle); begin if Line'Length > 0 and then Line (1) = '[' and then Line /= "[" & master_section & "]" then JT.SU.Append (result, Line (2 .. Line'Last - 1) & LAT.LF); end if; end; end loop; TIO.Close (handle); return result; end sections_list; ----------------------- -- default_profile -- ----------------------- function default_profile (new_profile : String; num_cores : cpu_range) return configuration_record is result : configuration_record; def_builders : Integer; def_jlimit : Integer; begin default_parallelism (num_cores => num_cores, num_builders => def_builders, jobs_per_builder => def_jlimit); result.dir_portsdir := JT.SUS (std_ports_loc); result.operating_sys := JT.SUS (query_opsys (std_ports_loc)); result.profile := JT.SUS (new_profile); result.dir_system := JT.SUS (std_sysbase); result.dir_repository := JT.SUS (LS_Packages & "/All"); result.dir_packages := JT.SUS (LS_Packages); result.dir_distfiles := JT.SUS (std_distfiles); result.dir_buildbase := JT.SUS (LS_Buildbase); result.dir_logs := JT.SUS (LS_Logs); result.dir_ccache := JT.SUS (no_ccache); result.dir_options := JT.SUS (std_options); result.num_builders := builders (def_builders); result.jobs_limit := builders (def_jlimit); result.tmpfs_workdir := enough_memory (result.num_builders); result.tmpfs_localbase := enough_memory (result.num_builders); result.avec_ncurses := True; result.defer_prebuilt := False; write_blank_section (section => new_profile); return result; end default_profile; ------------------------ -- mkdirp_from_file -- ------------------------ procedure mkdirp_from_file (filename : String) is condir : String := AD.Containing_Directory (Name => filename); begin AD.Create_Path (New_Directory => condir); exception when others => raise update_config; end mkdirp_from_file; ----------------------- -- all_paths_valid -- ----------------------- function all_paths_valid return Boolean is use type AD.File_Kind; function invalid_directory (folder : JT.Text; desc : String) return Boolean; function invalid_directory (folder : JT.Text; desc : String) return Boolean is dossier : constant String := JT.USS (folder); errmsg : constant String := "Configuration invalid: "; begin if AD.Exists (dossier) and then AD.Kind (dossier) = AD.Directory then return False; else TIO.Put_Line (errmsg & desc & " directory: " & dossier); return True; end if; end invalid_directory; begin if invalid_directory (configuration.dir_system, "[G] System root") then return False; elsif invalid_directory (configuration.dir_packages, "[B] Packages") then return False; elsif invalid_directory (configuration.dir_portsdir, "[A] Ports") then return False; elsif invalid_directory (configuration.dir_distfiles, "[C] Distfiles") then if JT.equivalent (configuration.dir_distfiles, "/usr/ports/distfiles") then TIO.Put_Line ("Rather than manually creating a directory at this location, " & "consider" & LAT.LF & "using a location outside of the ports tree. Don't forget " & "to set" & LAT.LF & "'DISTDIR' to this new location in /etc/make.conf though."); end if; return False; elsif invalid_directory (configuration.dir_logs, "[E] Build logs") then return False; elsif invalid_directory (configuration.dir_options, "[D] Port options") then return False; end if; if JT.USS (configuration.dir_ccache) = no_ccache then return True; end if; return not invalid_directory (configuration.dir_ccache, "[H] Compiler cache"); end all_paths_valid; ---------------------- -- delete_profile -- ---------------------- procedure delete_profile (profile : String) is old_file : TIO.File_Type; new_file : TIO.File_Type; nextgen : constant String := synth_confdir & "/synth.ini.next"; pattern : constant String := "[" & profile & "]"; blocking : Boolean := False; begin if not AD.Exists (conf_location) then raise update_config with "The " & conf_location & " configuration file does not exist."; end if; if AD.Exists (nextgen) then AD.Delete_File (nextgen); end if; TIO.Create (File => new_file, Mode => TIO.Out_File, Name => nextgen); TIO.Open (File => old_file, Mode => TIO.In_File, Name => conf_location); while not TIO.End_Of_File (old_file) loop declare Line : constant String := TIO.Get_Line (old_file); bracket : Boolean := False; begin if not JT.IsBlank (Line) then bracket := Line (1) = '['; end if; if bracket and then blocking then blocking := False; end if; if not blocking and then Line = pattern then blocking := True; end if; if not blocking then TIO.Put_Line (new_file, Line); end if; end; end loop; TIO.Close (old_file); TIO.Close (new_file); AD.Delete_File (conf_location); AD.Rename (Old_Name => nextgen, New_Name => conf_location); exception when others => if TIO.Is_Open (new_file) then TIO.Close (new_file); end if; if AD.Exists (nextgen) then AD.Delete_File (nextgen); end if; if TIO.Is_Open (old_file) then TIO.Close (old_file); end if; raise update_config with "Failed to remove " & profile & " profile"; end delete_profile; ---------------------------------- -- alternative_profiles_exist -- ---------------------------------- function alternative_profiles_exist return Boolean is counter : Natural := 0; conf_file : TIO.File_Type; begin if not AD.Exists (conf_location) then return False; end if; TIO.Open (File => conf_file, Mode => TIO.In_File, Name => conf_location); while not TIO.End_Of_File (conf_file) loop declare Line : constant String := TIO.Get_Line (conf_file); bracket : Boolean := False; begin if not JT.IsBlank (Line) then bracket := Line (1) = '['; end if; if bracket and then Line /= "[" & master_section & "]" then counter := counter + 1; end if; end; end loop; TIO.Close (conf_file); return counter > 1; exception when others => if TIO.Is_Open (conf_file) then TIO.Close (conf_file); end if; return False; end alternative_profiles_exist; end Parameters;
AdaCore/training_material
Ada
3,708
adb
--$ line answer with Ada.Strings.Unbounded; package body Drawable_Chars is function Image (C : Drawable_Char_T) return String is begin return String (C); end Image; function Debug_Image (C : Sorted_Charset_T) return String is --$ begin answer use Chars_Sorted_By_Characteristic_Pkg; use Ada.Strings.Unbounded; It : Sorted_Charset_Cursor_T := C.First; S : Unbounded_String := Null_Unbounded_String; --$ end answer begin --$ begin question -- TODO return ""; --$ end question --$ begin answer while Has_Element (It) loop declare El : constant Char_With_Characteristic_T := Element (It); begin S := S & """" & Image (El.Char.all) & """ => " & El.Value'Image & " "; It := Next (It); end; end loop; return To_String (S); --$ end answer end Debug_Image; function Closest (Metric : Sorted_Charset_T; Value : Drawable_Char_Characteristic_T) return Drawable_Char_T is --$ begin answer use Chars_Sorted_By_Characteristic_Pkg; Has_Best : Boolean := False; Best : Char_With_Characteristic_T; Best_Dist : Natural; It : Sorted_Charset_Cursor_T := Metric.First; Continue : Boolean := Has_Element (It); --$ end answer begin --$ begin question -- TODO return ""; --$ end question --$ begin answer while Continue loop declare Curr : constant Char_With_Characteristic_T := Element (It); begin declare Curr_Dist : constant Natural := Natural (abs (Curr.Value - Value)); begin pragma Warnings (Off, """Best_Dist"" may be referenced before it has a value"); -- Best_Dist is set at the same time as Has_Best if not Has_Best or Curr_Dist < Best_Dist then Best_Dist := Curr_Dist; Best := Curr; Has_Best := True; end if; pragma Warnings (On, """Best_Dist"" may be referenced before it has a value"); end; if Curr.Value >= Value then Continue := False; else Best := Curr; It := Next (It); Continue := Has_Element (It); end if; end; end loop; pragma Assert (Has_Best); return Best.Char.all; --$ end answer end Closest; function Sort_By (Charset : Drawable_Charset_T; Characteristic : Drawable_Char_Caracteristics_List_T) return Sorted_Charset_T is begin --$ line question return (others => <>); --$ begin answer return SC : Sorted_Charset_T do for J in Charset'Range loop SC.Insert ((Char => Charset (J), Value => Characteristic (J))); end loop; end return; --$ end answer end Sort_By; function Reversed (SC : Sorted_Charset_T) return Sorted_Charset_T is --$ begin answer use Chars_Sorted_By_Characteristic_Pkg; It : Sorted_Charset_Cursor_T := SC.First; SC2 : Sorted_Charset_T; --$ end answer begin --$ begin question return (others => <>); --$ end question --$ begin answer while Has_Element (It) loop declare El : constant Char_With_Characteristic_T := Element (It); begin SC2.Insert ((El.Char, 255 - El.Value)); end; It := Next (It); end loop; return SC2; --$ end answer end Reversed; end Drawable_Chars;
msrLi/portingSources
Ada
834
adb
-- Copyright 2007-2014 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. package body Pck is procedure Do_Nothing (A : System.Address) is begin null; end Do_Nothing; end Pck;
GPUWorks/lumen2
Ada
4,946
ads
-- Lumen.GLU -- Lumen's own thin OpenGL utilities bindings -- -- Chip Richards, NiEstu, Phoenix AZ, Summer 2010 -- This code is covered by the ISC License: -- -- Copyright © 2010, NiEstu -- -- 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. -- Environment with Lumen.GL; use Lumen.GL; package Lumen.GLU is --------------------------------------------------------------------------- -- Build mipmaps function Build_1D_Mipmaps (Target : in Enum; Components : in Int; Width : in Int; Format : in Enum; Data_Type : in Enum; Data : in Pointer) return Int with Import => True, Convention => StdCall, External_Name => "gluBuild1DMipmaps"; function Build_2D_Mipmaps (Target : in Enum; Components : in Int; Width : in Int; Height : in Int; Format : in Enum; Data_Type : in Enum; Data : in Pointer) return Int with Import => True, Convention => StdCall, External_Name => "gluBuild2DMipmaps"; -- Projections procedure Ortho_2D (Left : in Double; Right : in Double; Bottom : in Double; Top : in Double) with Import => True, Convention => StdCall, External_Name => "gluOrtho2D"; procedure Perspective (FOV_Y_Angle, Aspect, Z_Near, Z_Far : in Double) with Import => True, Convention => StdCall, External_Name => "gluPerspective"; -- Quadrics type Quadric is new Pointer; function New_Quadric return Quadric with Import => True, Convention => StdCall, External_Name => "gluNewQuadric"; procedure Delete_Quadric (Quad : in Quadric) with Import => True, Convention => StdCall, External_Name => "gluDeleteQuadric"; procedure Quadric_Draw_Style (Quad : in Quadric; Draw : in Enum) with Import => True, Convention => StdCall, External_Name => "gluQuadricDrawStyle"; procedure Quadric_Normals (Quad : in Quadric; Normal : in Enum) with Import => True, Convention => StdCall, External_Name => "gluQuadricNormals"; procedure Quadric_Orientation (Quad : in Quadric; Orientation : in Enum) with Import => True, Convention => StdCall, External_Name => "gluQuadricOrientation"; procedure Quadric_Texture (Quad : in Quadric; Texture : in Bool) with Import => True, Convention => StdCall, External_Name => "gluQuadricTexture"; -- Shapes procedure Cylinder (Quad : in Quadric; Base : in Double; Top : in Double; Height : in Double; Slices : in Int; Stacks : in Int) with Import => True, Convention => StdCall, External_Name => "gluCylinder"; procedure Disk (Quad : in Quadric; Inner : in Double; Outer : in Double; Slices : in Int; Loops : in Int) with Import => True, Convention => StdCall, External_Name => "gluDisk"; procedure Partial_Disk (Quad : in Quadric; Inner : in Double; Outer : in Double; Slices : in Int; Loops : in Int; Start : in Double; Sweep : in Double) with Import => True, Convention => StdCall, External_Name => "gluPartialDisk"; procedure Sphere (Quad : in Quadric; Radius : in Double; Slices : in Int; Stacks : in Int) with Import => True, Convention => StdCall, External_Name => "gluSphere"; --------------------------------------------------------------------------- end Lumen.GLU;
riccardo-bernardini/eugen
Ada
1,810
adb
pragma Ada_2012; with Ada.Finalization; use Ada.Finalization; with Ada.Text_IO; use Ada.Text_IO; package body Eu_Projects.Nodes.Timed_Nodes.Project_Infos is ------------ -- Create -- ------------ function Create (Label : Node_Label; Name : String; Short_Name : String; Stop_At : String; Node_Dir : in out Node_Tables.Node_Table) return Info_Access is Result : Info_Access; begin Result := new Project_Info'(Controlled with Class => Info_Node, Label => Label, Name => To_Unbounded_String (Name), Short_Name => To_Unbounded_String (Short_Name), Index => No_Index, Description => Null_Unbounded_String, Attributes => Attribute_Maps.Empty_Map, Expected_Raw => To_Unbounded_String (Stop_At), Expected_Symbolic => <>, Expected_On => <>, Fixed => False, WPs => Node_Label_Lists.Empty_Vector); Node_Dir.Insert (ID => Label, Item => Node_Access (Result)); return Result; end Create; ------------ -- Add_WP -- ------------ procedure Add_WP (Info : in out Project_Info; WP : Node_Label) is begin Info.WPs.Append (WP); end Add_WP; end Eu_Projects.Nodes.Timed_Nodes.Project_Infos;
Letractively/ada-el
Ada
4,108
ads
----------------------------------------------------------------------- -- EL.Contexts -- Contexts for evaluating an expression -- Copyright (C) 2009, 2010, 2011, 2012 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- -- The expression context provides information to resolve runtime -- information when evaluating an expression. The context provides -- a resolver whose role is to find variables given their name. with EL.Objects; with Util.Beans.Basic; with Ada.Strings.Unbounded; with Ada.Exceptions; with EL.Functions; limited with EL.Variables; package EL.Contexts is pragma Preelaborate; use EL.Objects; use Ada.Strings.Unbounded; type ELContext; -- ------------------------------ -- Expression Resolver -- ------------------------------ -- Enables customization of variable and property resolution -- behavior for EL expression evaluation. type ELResolver is limited interface; type ELResolver_Access is access all ELResolver'Class; -- Get the value associated with a base object and a given property. function Get_Value (Resolver : ELResolver; Context : ELContext'Class; Base : access Util.Beans.Basic.Readonly_Bean'Class; Name : Unbounded_String) return EL.Objects.Object is abstract; -- Set the value associated with a base object and a given property. procedure Set_Value (Resolver : in out ELResolver; Context : in ELContext'Class; Base : access Util.Beans.Basic.Bean'Class; Name : in Unbounded_String; Value : in EL.Objects.Object) is abstract; -- ------------------------------ -- Expression Context -- ------------------------------ -- Context information for expression evaluation. type ELContext is limited interface; type ELContext_Access is access all ELContext'Class; -- Retrieves the ELResolver associated with this ELcontext. function Get_Resolver (Context : ELContext) return ELResolver_Access is abstract; -- Retrieves the VariableMapper associated with this ELContext. function Get_Variable_Mapper (Context : ELContext) return access EL.Variables.Variable_Mapper'Class is abstract; -- Set the variable mapper associated with this ELContext. procedure Set_Variable_Mapper (Context : in out ELContext; Mapper : access EL.Variables.Variable_Mapper'Class) is abstract; -- Retrieves the FunctionMapper associated with this ELContext. -- The FunctionMapper is only used when parsing an expression. function Get_Function_Mapper (Context : ELContext) return EL.Functions.Function_Mapper_Access is abstract; -- Set the function mapper associated with this ELContext. procedure Set_Function_Mapper (Context : in out ELContext; Mapper : access EL.Functions.Function_Mapper'Class) is abstract; -- Handle the exception during expression evaluation. The handler can ignore the -- exception or raise it. procedure Handle_Exception (Context : in ELContext; Ex : in Ada.Exceptions.Exception_Occurrence) is abstract; end EL.Contexts;
tum-ei-rcs/StratoX
Ada
6,716
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . T A S K I N G . P R O T E C T E D _ O B J E C T S -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2015, Free Software Foundation, Inc. -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNARL is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ -- This is the Ravenscar version of this package with System.Task_Primitives.Operations; -- Used for Set_Priority -- Get_Priority -- Self package body System.Tasking.Protected_Objects is use System.Task_Primitives.Operations; use System.Multiprocessors; Multiprocessor : constant Boolean := CPU'Range_Length /= 1; -- Set true if on multiprocessor (more than one CPU) --------------------------- -- Initialize_Protection -- --------------------------- procedure Initialize_Protection (Object : Protection_Access; Ceiling_Priority : Integer) is Init_Priority : Integer := Ceiling_Priority; begin if Init_Priority = Unspecified_Priority then Init_Priority := System.Priority'Last; end if; Object.Ceiling := System.Any_Priority (Init_Priority); Object.Caller_Priority := System.Any_Priority'First; Object.Owner := Null_Task; -- Only for multiprocessor if Multiprocessor then Multiprocessors.Fair_Locks.Initialize (Object.Lock); end if; end Initialize_Protection; ---------- -- Lock -- ---------- procedure Lock (Object : Protection_Access) is Self_Id : constant Task_Id := Self; Caller_Priority : constant Any_Priority := Get_Priority (Self_Id); begin -- For this run time, pragma Detect_Blocking is always active. As -- described in ARM 9.5.1, par. 15, an external call on a protected -- subprogram with the same target object as that of the protected -- action that is currently in progress (i.e., if the caller is -- already the protected object's owner) is a potentially blocking -- operation, and hence Program_Error must be raised. if Object.Owner = Self_Id then raise Program_Error; end if; -- Check ceiling locking violation. It is perfectly correct to stay at -- the same priority because a running task will never be preempted by -- another task at the same priority (no potentially blocking operation, -- no time slicing). if Caller_Priority > Object.Ceiling then raise Program_Error; end if; Set_Priority (Self_Id, Object.Ceiling); -- Locking for multiprocessor systems -- This lock ensure mutual exclusion of tasks from different processors, -- not for tasks on the same processors. But, because of the ceiling -- priority, this case never occurs. if Multiprocessor then -- Only for multiprocessor Multiprocessors.Fair_Locks.Lock (Object.Lock); end if; -- Update the protected object's owner Object.Owner := Self_Id; -- Store caller's active priority so that it can be later -- restored when finishing the protected action. Object.Caller_Priority := Caller_Priority; -- We are entering in a protected action, so that we increase the -- protected object nesting level. Self_Id.Common.Protected_Action_Nesting := Self_Id.Common.Protected_Action_Nesting + 1; end Lock; ------------ -- Unlock -- ------------ procedure Unlock (Object : Protection_Access) is Self_Id : constant Task_Id := Self; Caller_Priority : constant Any_Priority := Object.Caller_Priority; begin -- Calls to this procedure can only take place when being within a -- protected action and when the caller is the protected object's -- owner. pragma Assert (Self_Id.Common.Protected_Action_Nesting > 0 and then Object.Owner = Self_Id); -- Remove ownership of the protected object Object.Owner := Null_Task; -- We are exiting from a protected action, so that we decrease the -- protected object nesting level. Self_Id.Common.Protected_Action_Nesting := Self_Id.Common.Protected_Action_Nesting - 1; -- Locking for multiprocessor systems if Multiprocessor then -- Only for multiprocessor Multiprocessors.Fair_Locks.Unlock (Object.Lock); end if; Set_Priority (Self_Id, Caller_Priority); end Unlock; begin -- Ensure that tasking is initialized when using protected objects Tasking.Initialize; end System.Tasking.Protected_Objects;
MinimSecure/unum-sdk
Ada
800
ads
-- Copyright 2011-2016 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. with System; package Pck is procedure Do_Nothing (A : System.Address); end Pck;
reznikmm/matreshka
Ada
3,734
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Style_List_Level_Properties_Elements is pragma Preelaborate; type ODF_Style_List_Level_Properties is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Style_List_Level_Properties_Access is access all ODF_Style_List_Level_Properties'Class with Storage_Size => 0; end ODF.DOM.Style_List_Level_Properties_Elements;
zhmu/ananas
Ada
3,023
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- SYSTEM.TASK_PRIMITIVES.INTERRUPT_OPERATIONS -- -- -- -- S p e c -- -- -- -- Copyright (C) 1998-2022, Free Software Foundation, Inc. -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ with System.Interrupt_Management; with System.Tasking; package System.Task_Primitives.Interrupt_Operations is pragma Preelaborate; package IM renames System.Interrupt_Management; package ST renames System.Tasking; procedure Set_Interrupt_ID (Interrupt : IM.Interrupt_ID; T : ST.Task_Id); -- Associate an Interrupt_ID with a task function Get_Interrupt_ID (T : ST.Task_Id) return IM.Interrupt_ID; -- Return the Interrupt_ID associated with a task function Get_Task_Id (Interrupt : IM.Interrupt_ID) return ST.Task_Id; -- Return the Task_Id associated with an Interrupt end System.Task_Primitives.Interrupt_Operations;
AdaCore/langkit
Ada
1,302
adb
-- -- Copyright (C) 2014-2022, AdaCore -- SPDX-License-Identifier: Apache-2.0 -- with GNATCOLL.Strings; use GNATCOLL.Strings; package body Langkit_Support.Images is -------------------- -- Stripped_Image -- -------------------- function Stripped_Image (I : Integer) return String is Result : constant String := Integer'Image (I); begin return (if Result (Result'First) = ' ' then Result (Result'First + 1 .. Result'Last) else Result); end Stripped_Image; ----------------- -- Array_Image -- ----------------- function Array_Image (Self : Array_Type; Limit : Positive := 80) return String is Images : XString_Array (1 .. Self'Length); Len : Natural := 0; Sep : XString; Ret : XString; J : Positive := 1; begin for I in Self'Range loop Images (J) := To_XString (Image (Self (I))); Len := Len + Images (J).Length; J := J + 1; end loop; if Len > Limit then Sep := To_XString (ASCII.LF & " "); else Sep := To_XString (", "); end if; Ret.Append ("["); Ret.Append (Sep.Join (Images)); Ret.Append ("]"); return Ret.To_String; end Array_Image; end Langkit_Support.Images;
zhmu/ananas
Ada
589
adb
-- { dg-do run } -- { dg-options "-gnat12" } procedure Access6 is type Int_Ref is access all Integer; Ptr : Int_Ref; procedure update_ptr (X : access integer) is begin -- Failed accessibility test: supposed to raise a Program_Error Ptr := Int_Ref (X); end; procedure bar is ref : access integer := new integer; begin update_ptr (ref); end; begin bar; -- As the call to bar must raise a Program_Error, the following is not supposed to be executed: raise Constraint_Error; exception when Program_Error => null; end;
riccardo-bernardini/eugen
Ada
15,844
adb
---------------------------------------------------------------------------- -- Generic Command Line Parser (gclp) -- -- Copyright (C) 2012, Riccardo Bernardini -- -- This file is part of gclp. -- -- gclp is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 2 of the License, or -- (at your option) any later version. -- -- gclp 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 gclp. If not, see <http://www.gnu.org/licenses/>. ---------------------------------------------------------------------------- -- with Ada.Command_Line; with Ada.Strings.Fixed; with Ada.Strings.Maps.Constants; with Ada.Containers.Indefinite_Doubly_Linked_Lists; with Ada.Characters.Handling; use Ada; use Ada.Strings; use Ada.Strings.Fixed; with Ada.Directories; package body Line_Parsers is function To_S (X : Unbounded_String) return String renames To_String; function To_U (X : String) return Unbounded_String renames To_Unbounded_String; package Name_Lists is new Ada.Containers.Indefinite_Doubly_Linked_Lists (String); function Parse_Name (Name : String; Case_Sensitive : Boolean) return Name_Lists.List; procedure Add_Parameter (Parser : in out Line_Parser; Name : String; If_Missing : Missing_Action := Ignore; Default : String; Handler : Handler_Access) is Names : constant Name_Lists.List := Parse_Name (Name, Parser.Case_Sensitive); begin Parser.Parameters.Append (Parameter_Descriptor'(If_Missing => If_Missing, Name => To_U (Name), Handler => Handler, Standard_Name => To_U (Names.First_Element), Default => To_U (Default))); for Single_Name of Names loop if Parser.Name_Table.Contains (Single_Name) then raise Constraint_Error; end if; Parser.Name_Table.Insert (Single_Name, Parser.Parameters.Last_Index); end loop; end Add_Parameter; -- type Parameter_Descriptor_Array is -- array (Parameter_Index range <>) of Parameter_Descriptor; -------------------- -- Case_Normalize -- -------------------- -- If the user required case insensitive matching, force the -- name to lower case procedure Case_Normalize (Name : in out String; Case_Sensitive : Boolean) is begin if not Case_Sensitive then Translate (Name, Maps.Constants.Lower_Case_Map); end if; end Case_Normalize; function Parse_Name (Name : String; Case_Sensitive : Boolean) return Name_Lists.List is ------------------ -- Trimmed_Name -- ------------------ function Trimmed_Name (Name : String) return String is Trimmed : String := Fixed.Trim (Name, Both); begin if Trimmed = "" then raise Constraint_Error with "Empty alternative in label '" & Name & "'"; else Case_Normalize (Trimmed, Case_Sensitive); return Trimmed; end if; end Trimmed_Name; Result : Name_Lists.List; First : Natural; Comma_Pos : Natural; begin if Fixed.Index (Name, "=") /= 0 then raise Constraint_Error with "Option label '" & Name & "' has '='"; end if; if Name (Name'Last) = ',' then raise Constraint_Error with "Option label '" & Name & "' ends with ','"; end if; First := Name'First; loop pragma Assert (First <= Name'Last); Comma_Pos := Fixed.Index (Name (First .. Name'Last), ","); exit when Comma_Pos = 0; if First = Comma_Pos then -- First should always point to the beginning of a -- label, therefore it cannot be Buffer(First) = ',' raise Constraint_Error with "Wrong syntax in Option label '" & Name & "'"; end if; pragma Assert (Comma_Pos > First); Result.Append (Trimmed_Name (Name (First .. Comma_Pos - 1))); First := Comma_Pos + 1; -- It cannot be First > Buffer'Last since Buffer(Comma_Pos) = '=' -- and Buffer(Buffer'Last) /= ',' pragma Assert (First <= Name'Last); end loop; pragma Assert (First <= Name'Last); Result.Append (Trimmed_Name (Name (First .. Name'Last))); return Result; end Parse_Name; ------------ -- Create -- ------------ function Create (Case_Sensitive : Boolean := True; Normalize_Name : Boolean := True; Help_Line : String := "") return Line_Parser is begin return Line_Parser'(Case_Sensitive => Case_Sensitive, Normalize_Name => Normalize_Name, Help_Line => To_U (Help_Line), Parameters => Parameter_Vectors.Empty_Vector, Name_Table => Name_To_Index_Maps.Empty_Map); end Create; ----------- -- Slurp -- ----------- function Slurp (Filename : String; Skip_Comments : Boolean := True; Comment_Char : Character := '#'; Comment_Strict : Boolean := False) return String_Vectors.Vector is use Ada.Text_IO; use Ada.Directories; use Ada.Characters.Handling; function Is_Empty (X : String) return Boolean is (for all Ch of X => Is_Space(Ch)); ---------------- -- Is_Comment -- ---------------- function Is_Comment (X : String) return Boolean is Idx : constant Natural := Index (X, Comment_Char & ""); begin if Idx = 0 then return False; end if; if Comment_Strict then return Idx = X'First; else return (for all N in X'First .. Idx - 1 => Is_Space (X (N))); end if; end Is_Comment; Input : File_Type; Result : String_Vectors.Vector; begin if not Exists (Filename) or else Kind (Filename) /= Ordinary_File then return String_Vectors.Empty_Vector; end if; Open (File => input, Mode => In_File, Name => Filename); while not End_Of_File (Input) loop declare Line : constant String := Get_Line (Input); begin if not Is_Empty (Line) then if not Skip_Comments or not Is_Comment (Line) then Result.Append (Line); end if; end if; end; end loop; Close (Input); return Result; end Slurp; ------------------------ -- Parse_Command_Line -- ------------------------ procedure Parse_Command_Line (Parser : Line_Parser; Extend_By : String_Vectors.Vector := String_Vectors.Empty_Vector; Help_Output : Ada.Text_IO.File_Type := Ada.Text_IO.Standard_Error) is package String_Lists is new Ada.Containers.Indefinite_Doubly_Linked_Lists (String); --------------------- -- Split_Parameter -- --------------------- procedure Split_Parameter (Param : in String; Name : out Unbounded_String; Value : out Unbounded_String) is Idx : Natural; begin Idx := Index (Source => Param, Pattern => "="); if (Idx = 0) then Name := To_U (Param); Value := Null_Unbounded_String; else Name := To_U (Param (Param'First .. Idx - 1)); Value := To_U (Param (Idx + 1 .. Param'Last)); end if; end Split_Parameter; function Missing_Message (Missing : String_Lists.List) return String is function Join (Item : String_Lists.List) return String is Result : Unbounded_String; procedure Append (Pos : String_Lists.Cursor) is begin if Result /= Null_Unbounded_String then Result := Result & ", "; end if; Result := Result & "'" & String_Lists.Element (Pos) & "'"; end Append; begin Item.Iterate (Append'Access); return To_String (Result); end Join; use type Ada.Containers.Count_Type; begin if Missing.Length = 1 then return "Missing mandatory option " & Join (Missing); else return "Missing mandatory options: " & Join (Missing); end if; end Missing_Message; function Collect_Parameters (Extra : String_Vectors.Vector) return String_Vectors.Vector is Result : String_Vectors.Vector; begin for Idx in 1 .. Command_Line.Argument_Count loop Result.Append (Command_Line.Argument (Idx)); end loop; Result.Append (Extra); return Result; end Collect_Parameters; Name : Unbounded_String; Value : Unbounded_String; use Name_To_Index_Maps; Position : Name_To_Index_Maps.Cursor; Param_Idx : Parameter_Index; Arguments : constant String_Vectors.Vector := Collect_Parameters (Extend_By); begin for Pos in Arguments.First_Index .. Arguments.Last_Index loop Split_Parameter (Arguments (Pos), Name, Value); declare N : String := To_S (Name); V : constant String := To_S (Value); Handler : Handler_Access; This_Parameter : Parameter_Descriptor; begin Case_Normalize (N, Parser.Case_Sensitive); Position := Parser.Name_Table.Find (N); if Position = No_Element then raise Bad_Command with "Option '" & To_S (Name) & "' unknown"; end if; Param_Idx := Name_To_Index_Maps.Element (Position); This_Parameter := Parser.Parameters (Param_Idx); Handler := This_Parameter.Handler; if Handler.Is_Set and not Handler.Reusable then raise Bad_Command with "Option '" & N & "' given twice"; end if; Handler.Receive (Name => ( if Parser.Normalize_Name then To_S (This_Parameter.Standard_Name) else N ), Value => V, Position => Pos); end; end loop; declare Missing : String_Lists.List; begin for Parameter of Parser.Parameters loop if not Parameter.Handler.Is_Set then case Parameter.If_Missing is when Die => Missing.Append (To_S (Parameter.Standard_Name)); when Use_Default => Parameter.Handler.Receive (Name => To_S (Parameter.Standard_Name), Value => To_S (Parameter.Default), Position => No_Position); when Ignore => null; end case; end if; end loop; if not Missing.Is_Empty then raise Bad_Command with Missing_Message (Missing); end if; end; exception when Bad_Command => if Parser.Help_Line /= Null_Unbounded_String then Ada.Text_IO.Put_Line (File => Help_Output, Item => To_S (Parser.Help_Line)); end if; raise; end Parse_Command_Line; end Line_Parsers; -- -- --------------------- -- -- Normalized_Form -- -- --------------------- -- -- function Normalized_Form (Parser : Line_Parser; -- X : String) return String -- is -- Names : constant Name_Lists.List := Parse_Name (X, Parser.Case_Sensitive); -- Result : String := Names.First_Element; -- begin -- Case_Normalize (Result, Parser.Case_Sensitive); -- return Result; -- end Normalized_Form; -- -- --------------------- -- -- Fill_Name_Table -- -- --------------------- -- procedure Fill_Name_Table (Parameters : in Parameter_Descriptor_Array; -- Name_Table : in out Name_To_Index_Maps.Map; -- Standard_Names : out Name_Array) -- with -- Pre => -- Parameters'First = Standard_Names'First -- and -- Parameters'Last = Standard_Names'Last; -- -- -- Fill the Parameter Name -> parameter index table with the -- -- parameter names -- procedure Fill_Name_Table (Parser : Line_Parser; -- Parameters : in Parameter_Descriptor_Array; -- Name_Table : in out Name_To_Index_Maps.Map; -- Standard_Names : out Name_Array) -- is -- -- -- use Name_Lists; -- -- ---------------- -- -- Parse_Name -- -- ---------------- -- -- -- Option_Names : Name_Lists.List; -- Position : Name_Lists.Cursor; -- -- Name : Unbounded_String; -- begin -- for Idx in Parameters'Range loop -- Option_Names := Parse_Name (Parameters (Idx).Name); -- -- Position := Option_Names.First; -- Standard_Names (Idx) := Name_Lists.Element (Position); -- -- while Position /= No_Element loop -- Name := Name_Lists.Element (Position); -- Name_Lists.Next (Position); -- -- Case_Normalize (Parser, Name); -- -- if Name_Table.Contains (Name) then -- raise Constraint_Error -- with "Ambiguous label '" & To_S (Name) & "'"; -- end if; -- -- Name_Table.Insert (Name, Idx); -- end loop; -- end loop; -- end Fill_Name_Table; -- ---------------- -- -- To_Natural -- -- ---------------- -- -- function To_Natural (X : Unbounded_String) -- return Natural is -- begin -- if X = Null_Unbounded_String then -- raise Bad_Command with "Invalid integer '" & To_S (X) & "'"; -- end if; -- -- return Natural'Value (To_S (X)); -- end To_Natural; -- -- -------------- -- -- To_Float -- -- -------------- -- -- function To_Float (X : Unbounded_String) -- return Float is -- begin -- if X = Null_Unbounded_String then -- raise Bad_Command with "Invalid Float '" & To_S (X) & "'"; -- end if; -- -- return Float'Value (To_S (X)); -- end To_Float;
Fabien-Chouteau/GESTE
Ada
6,805
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_Config; use GESTE_Config; package GESTE is type Pix_Point is record X, Y : Integer; end record; type Pix_Rect is record TL : Pix_Point; -- Top Left BR : Pix_Point; -- Bottom right end record; -- Palette -- type Palette_Type is array (Color_Index) of Output_Color; type Palette_Ref is access constant Palette_Type; No_Palette : constant Palette_Ref := null; -- Tile -- type Tile is array (0 .. Tile_Size - 1, 0 .. Tile_Size - 1) of Color_Index; type Tile_Array is array (Tile_Index range <>) of Tile; type Tile_Array_Ref is access constant Tile_Array; -- Collisions -- type Tile_Collisions is array (0 .. Tile_Size - 1, 0 .. Tile_Size - 1) of Boolean; type Tile_Collisions_Array is array (Tile_Index range <>) of Tile_Collisions; type Tile_Collisions_Array_Ref is access constant Tile_Collisions_Array; No_Collisions : constant Tile_Collisions_Array_Ref := null; -- Layer -- type Layer_Type is abstract tagged limited private; function Position (This : Layer_Type) return Pix_Point; function Width (This : Layer_Type) return Natural; function Height (This : Layer_Type) return Natural; procedure Move (This : in out Layer_Type; Pt : Pix_Point); procedure Enable_Collisions (This : in out Layer_Type; Enable : Boolean := True); package Layer is subtype Instance is Layer_Type; subtype Class is Instance'Class; type Ref is access all Class; type Const_Ref is access constant Class; end Layer; -- Engine -- type Layer_Priority is new Natural; procedure Add (L : not null Layer.Ref; Priority : Layer_Priority); procedure Remove (L : not null Layer.Ref); procedure Remove_All; subtype Output_Buffer_Index is Natural; type Output_Buffer is array (Output_Buffer_Index range <>) of Output_Color; type Push_Pixels_Proc is access procedure (Buffer : Output_Buffer); type Set_Drawing_Area_Proc is access procedure (Area : Pix_Rect); procedure Render_Window (Window : Pix_Rect; Background : Output_Color; Buffer : in out Output_Buffer; Push_Pixels : Push_Pixels_Proc; Set_Drawing_Area : Set_Drawing_Area_Proc); procedure Render_All (Screen_Rect : Pix_Rect; Background : Output_Color; Buffer : in out Output_Buffer; Push_Pixels : Push_Pixels_Proc; Set_Drawing_Area : Set_Drawing_Area_Proc); procedure Render_Dirty (Screen_Rect : Pix_Rect; Background : Output_Color; Buffer : in out Output_Buffer; Push_Pixels : Push_Pixels_Proc; Set_Drawing_Area : Set_Drawing_Area_Proc); -- Collisions -- function Collides (Pt : Pix_Point) return Boolean; private subtype Coordinate is Integer; subtype Lenght is Natural; -- Layer -- type Layer_Type is abstract tagged limited record Next : Layer.Ref := null; Prev : Layer.Ref := null; Prio : Layer_Priority := 0; Pt : Pix_Point := (0, 0); A_Width : Natural := 0; A_Height : Natural := 0; Dirty : Boolean := True; Last_Pt : Pix_Point := (0, 0); Collisions_Enabled : Boolean := False; end record; function Pix (This : Layer_Type; Unused_X, Unused_Y : Integer) return Output_Color is (Transparent); function Collides (This : Layer_Type; Unused_X, Unused_Y : Integer) return Boolean is (False); procedure Update_Size (This : in out Layer_Type) is null; Layer_List : Layer.Ref := null; end GESTE;
charlie5/aShell
Ada
3,668
ads
with Ada.Iterator_Interfaces, Ada.Directories, Ada.Containers.Vectors; private with Ada.Finalization; package Shell.Directories -- -- Allows directories to be treated as a container using the new -- for Each of Container -- loop -- Operate_on (Each); -- end loop; -- -- See 'Test_Iterate_Directory' for a simple example. -- is type Directory is tagged private with Default_Iterator => Iterate, Iterator_Element => Constant_Reference_Type, Constant_Indexing => Element_Value; function To_Directory (Path : in String; Recurse : in Boolean := False) return Directory; function Path (Container : in Directory) return String; type Cursor is private; function Has_Element (Pos : Cursor) return Boolean; subtype Directory_Entry_Type is Ada.Directories.Directory_Entry_Type; type Constant_Reference_Type (Element : not null access constant Directory_Entry_Type) is private with Implicit_Dereference => Element; package Directory_Iterators is new Ada.Iterator_Interfaces (Cursor, Has_Element); function Iterate (Container : Directory) return Directory_Iterators.Forward_Iterator'Class; function Element_Value (Container : Directory; Pos : Cursor) return Constant_Reference_Type; private type Directory is tagged record Path : Unbounded_String; Recurse : Boolean; end record; type Constant_Reference_Type (Element : not null access constant Directory_Entry_Type) is null record; subtype Search_Type is Ada.Directories.Search_Type; type Search_Access is access all Search_Type; type Directory_Access is access all Directory; type Directory_Entry_Access is access all Directory_Entry_Type; -- Entries -- package Entry_Vectors is new ada.Containers.Vectors (Index_Type => Positive, Element_Type => Directory_Entry_Access); type Entries is new Entry_Vectors.Vector with null record; -- Cursor -- type Cursor is record Container : Directory_Access; Directory_Entry : Directory_Entry_Access; end record; No_Element : constant Cursor := Cursor' (Container => null, Directory_Entry => null); -- String Vectors -- package Strings_Vector is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Unbounded_String); -- Iterator -- type Iterator_State is record Prior : Directory_Entry_Access; -- Used to free expired directory entries. Subdirs : Strings_Vector.Vector; -- Used to recurse through sub-directories. end record; type Iterator_State_Access is access all Iterator_State; type Iterator is new Ada.Finalization.Controlled and Directory_Iterators.Forward_Iterator with record Container : Directory_Access; Search : Search_Access; -- Access is due to Search_Type being limited. State : Iterator_State_Access; -- Access allows modifying the Iterator state in functions. end record; overriding function First (Object : in Iterator) return Cursor; overriding function Next (Object : in Iterator; Position : in Cursor) return Cursor; overriding procedure Finalize (Object : in out Iterator); end Shell.Directories;
rveenker/sdlada
Ada
2,111
adb
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2013-2020, Luke A. Guest -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- -- 1. The origin of this software must not be misrepresented; you must not -- claim that you wrote the original software. If you use this software -- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- -- 3. This notice may not be removed or altered from any source -- distribution. -------------------------------------------------------------------------------------------------------------------- with Interfaces.C; package body SDL.Events.Joysticks is package C renames Interfaces.C; use type C.int; Query : constant C.int := -1; Ignore : constant C.int := 0; Enable : constant C.int := 1; function SDL_Joystick_Event_State (State : in C.int) return C.int with Import => True, Convention => C, External_Name => "SDL_JoystickEventState"; procedure SDL_Joystick_Event_State (State : in C.int) with Import => True, Convention => C, External_Name => "SDL_JoystickEventState"; function Is_Polling_Enabled return Boolean is begin return SDL_Joystick_Event_State (Query) = Enable; end Is_Polling_Enabled; procedure Enable_Polling is begin SDL_Joystick_Event_State (Enable); end Enable_Polling; procedure Disable_Polling is begin SDL_Joystick_Event_State (Ignore); end Disable_Polling; end SDL.Events.Joysticks;
sebsgit/textproc
Ada
15,982
adb
with opencl; use opencl; with cl_objects; use cl_objects; with NeuralNet; use NeuralNet; with Ada.Characters.Latin_1; with Ada.Unchecked_Deallocation; with System; with Ada.Text_IO; with Ada.Containers; use Ada.Containers; package body GpuInference is NL: constant Character := Ada.Characters.Latin_1.LF; multiply_weight_kernel_text: constant String := "__kernel void multiply_weights(__global float *input, __global float *output, __global float *weights, int weight_offset, int layer_size)" & NL & "{" & NL & " const int px_x = get_global_id(0);" & NL & " const int px_y = get_global_id(1);" & NL & " const int px_i = px_x + get_global_size(0) * px_y;" & NL & " output[px_i] = weights[px_i + weight_offset] * input[px_i % layer_size];" & NL & "}" & NL & "" & NL; reduce_sum_kernel_text: constant String := "__kernel void reduce_sum(__global float *input, __global float *output, __global float *bias, int bias_offset, int layer_size, int activator)" & NL & "{" & NL & " const int px_x = get_global_id(0);" & NL & " const int px_y = get_global_id(1);" & NL & " const int px_i = px_x + get_global_size(0) * px_y;" & NL & " float sum = 0.0f;" & NL & " for (int i=0 ; i<layer_size; ++i) {" & NL & " sum += input[px_i * layer_size + i];" & NL & " }" & NL & " const float res = sum + bias[px_i + bias_offset];" & NL & " output[px_i] = (activator == 0) ? (fmax(0.0f, res)) : (1.0f / (1.0f + exp(-res)));" & NL & "}" & NL & "" & NL; processing_program_text: constant String := multiply_weight_kernel_text & NL & reduce_sum_kernel_text & NL; function Get_Temp_Buffer_Size(nn: in NeuralNet.Net) return Positive is result: Positive := nn.conf.inputSize * nn.conf.sizes(1); current_size: Positive := 1; begin for n in 2 .. nn.conf.sizes'Length loop current_size := nn.conf.sizes(n) * nn.conf.sizes(n - 1); if current_size > result then result := current_size; end if; end loop; return result; end Get_Temp_Buffer_Size; function Get_Temp_Input_Buffer_Size(nn: in NeuralNet.Net) return Positive is result: Positive := nn.conf.sizes(1); begin for n in 2 .. nn.conf.sizes'Length loop if nn.conf.sizes(n) > result then result := nn.conf.sizes(n); end if; end loop; return result; end Get_Temp_Input_Buffer_Size; function Create(ctx: cl_objects.Context_Access; nn: in NeuralNet.Net; cl_code: out opencl.Status) return NNData is begin return res: NNData do res.ctx := ctx; res.nn_activator := nn.conf.act; res.nn_shape.Append(nn.conf.inputSize); for i in 1 .. nn.conf.sizes'Length loop res.nn_shape.Append(nn.conf.sizes(i)); end loop; res.processing_queue := new cl_objects.Command_Queue'(ctx.Create_Command_Queue(result_status => cl_code)); res.processing_prog := new cl_objects.Program'(ctx.Create_Program(source => processing_program_text, result_status => cl_code)); cl_code := ctx.Build(prog => res.processing_prog.all, options => "-w -Werror -cl-fast-relaxed-math -cl-strict-aliasing -cl-mad-enable"); res.multiply_weights_kernel := new cl_objects.Kernel'(res.processing_prog.Create_Kernel("multiply_weights", cl_code)); res.reduce_sum_kernel := new cl_objects.Kernel'(res.processing_prog.Create_Kernel("reduce_sum", cl_code)); res.nn_weights := new cl_objects.Buffer'(Upload_Weights(ctx => ctx.all, nn => nn, cl_code => cl_code)); res.nn_biases := new cl_objects.Buffer'(Upload_Biases(ctx => ctx.all, nn => nn, cl_code => cl_code)); res.temp_buffer := new cl_objects.Buffer'(cl_objects.Create_Buffer(ctx => ctx.all, flags => (opencl.ALLOC_HOST_PTR => True, others => False), size => Get_Temp_Buffer_Size(nn) * 4, host_ptr => System.Null_Address, result_status => cl_code)); res.temp_input_buffer := new cl_objects.Buffer'(cl_objects.Create_Buffer(ctx => ctx.all, flags => (opencl.ALLOC_HOST_PTR => True, others => False), size => Get_Temp_Input_Buffer_Size(nn) * 4, host_ptr => System.Null_Address, result_status => cl_code)); end return; end Create; procedure Finalize(This: in out NNData) is use cl_objects; begin Free(This.processing_queue); Free(This.reduce_sum_kernel); Free(This.multiply_weights_kernel); Free(This.processing_prog); Free(This.nn_weights); Free(This.nn_biases); Free(This.temp_buffer); Free(This.temp_input_buffer); end Finalize; type FlattenedWeights is array(Positive range <>) of aliased opencl.cl_float; type FlattenedBiases is array(Positive range <>) of aliased opencl.cl_float; function flatten_weights(nn: in NeuralNet.Net) return FlattenedWeights is total_size: Natural := 0; begin for layer of nn.layers loop for neuron of layer loop total_size := total_size + neuron.w'Length; end loop; end loop; return result: FlattenedWeights(1 .. total_size) do declare i: Positive := 1; begin for layer of nn.layers loop for neuron of layer loop for weight of neuron.w loop result(i) := opencl.cl_float(weight); i := i + 1; end loop; end loop; end loop; end; end return; end flatten_weights; function flatten_biases(nn: in NeuralNet.Net) return FlattenedBiases is total_size: Natural := 0; begin for layer of nn.layers loop total_size := total_size + Natural(layer.Length); end loop; return result: FlattenedBiases(1 .. total_size) do declare i: Positive := 1; begin for layer of nn.layers loop for neuron of layer loop result(i) := opencl.cl_float(neuron.bias); i := i + 1; end loop; end loop; end; end return; end flatten_biases; function Get_Local_Group_Size(global_size: in Positive) return Positive is type Sizes is array (Positive range <>) of Positive; preferred_sizes: constant Sizes := (64, 32, 16, 8, 4, 2, 1); begin for size of preferred_sizes loop if global_size mod size = 0 then return size; end if; end loop; return 1; end Get_Local_Group_Size; function Upload_Weights(ctx: in out cl_objects.Context; nn: in NeuralNet.Net; cl_code: out opencl.Status) return cl_objects.Buffer is host_buffer: aliased FlattenedWeights := flatten_weights(nn); begin return ctx.Create_Buffer(flags => (opencl.COPY_HOST_PTR => True, others => False), size => host_buffer'Length * 4, host_ptr => host_buffer'Address, result_status => cl_code); end Upload_Weights; function Upload_Biases(ctx: in out cl_objects.Context; nn: in NeuralNet.Net; cl_code: out opencl.Status) return cl_objects.Buffer is host_buffer: aliased FlattenedBiases := flatten_biases(nn); begin return ctx.Create_Buffer(flags => (opencl.COPY_HOST_PTR => True, others => False), size => host_buffer'Length * 4, host_ptr => host_buffer'Address, result_status => cl_code); end Upload_Biases; function Multiply_Weights(context: NNData; input, output: in System.Address; weight_offset: in Natural; layer_size, output_size: in Positive; events_to_wait: in opencl.Events; cl_code: out opencl.Status) return cl_objects.Event is layer_size_arg: aliased opencl.cl_int := opencl.cl_int(layer_size); weight_offset_arg: aliased opencl.cl_int := opencl.cl_int(weight_offset); begin cl_code := context.multiply_weights_kernel.Set_Arg(0, opencl.Raw_Address'Size / 8, input); cl_code := context.multiply_weights_kernel.Set_Arg(1, opencl.Raw_Address'Size / 8, output); cl_code := context.multiply_weights_kernel.Set_Arg(2, opencl.Raw_Address'Size / 8, context.nn_weights.Get_Address); cl_code := context.multiply_weights_kernel.Set_Arg(3, 4, weight_offset_arg'Address); cl_code := context.multiply_weights_kernel.Set_Arg(4, 4, layer_size_arg'Address); return context.processing_queue.Enqueue_Kernel(kern => context.multiply_weights_kernel.all, glob_ws => (1 => output_size), loc_ws => (1 => Get_Local_Group_Size(output_size)), events_to_wait_for => events_to_wait, code => cl_code); end Multiply_Weights; function Multiply_Weights(context: NNData; input, output: in out cl_objects.Buffer; weight_offset: in Natural; layer_size, output_size: in Positive; events_to_wait: in opencl.Events; cl_code: out opencl.Status) return cl_objects.Event is begin return Multiply_Weights(context, input.Get_Address, output.Get_Address, weight_offset, layer_size, output_size, events_to_wait, cl_code); end Multiply_Weights; function Reduce_Activate(context: NNData; input, output: in System.Address; bias_offset: in Natural; layer_size, output_size: in Positive; events_to_wait: in opencl.Events; cl_code: out opencl.Status) return cl_objects.Event is layer_size_arg: aliased opencl.cl_int := opencl.cl_int(layer_size); activator_arg: aliased opencl.cl_int := opencl.cl_int(if context.nn_activator = NeuralNet.RELU then 0 else 1); bias_offset_arg: aliased opencl.cl_int := opencl.cl_int(bias_offset); begin cl_code := context.reduce_sum_kernel.Set_Arg(0, opencl.Raw_Address'Size / 8, input); cl_code := context.reduce_sum_kernel.Set_Arg(1, opencl.Raw_Address'Size / 8, output); cl_code := context.reduce_sum_kernel.Set_Arg(2, opencl.Raw_Address'Size / 8, context.nn_biases.Get_Address); cl_code := context.reduce_sum_kernel.Set_Arg(3, 4, bias_offset_arg'Address); cl_code := context.reduce_sum_kernel.Set_Arg(4, 4, layer_size_arg'Address); cl_code := context.reduce_sum_kernel.Set_Arg(5, 4, activator_arg'Address); return context.processing_queue.Enqueue_Kernel(kern => context.reduce_sum_kernel.all, glob_ws => (1 => output_size), loc_ws => (1 => Get_Local_Group_Size(output_size)), events_to_wait_for => events_to_wait, code => cl_code); end Reduce_Activate; function Reduce_Activate(context: NNData; input, output: in out cl_objects.Buffer; bias_offset: in Natural; layer_size, output_size: in Positive; events_to_wait: in opencl.Events; cl_code: out opencl.Status) return cl_objects.Event is begin return Reduce_Activate(context, input.Get_Address, output.Get_Address, bias_offset, layer_size, output_size, events_to_wait, cl_code); end Reduce_Activate; function Forward(context: NNData; input, output: in out cl_objects.Buffer; events_to_wait: in opencl.Events; cl_code: out opencl.Status) return cl_objects.Event is curr_weight_off: Natural := 0; curr_bias_off: Natural := 0; curr_layer_size: Positive := 1; next_layer_size: Positive := 1; curr_output_size: Positive := 1; previous_ev: opencl.Events := (1 => 0); final_event: opencl.Event_ID := 0; begin for i in 1 .. context.nn_shape.Length - 1 loop curr_layer_size := context.nn_shape(Positive(i)); next_layer_size := context.nn_shape(Positive(i + 1)); curr_output_size := curr_layer_size * next_layer_size; declare mult_w_ev: constant cl_objects.Event := Multiply_Weights(context => context, input => (if i=1 then input.Get_Address else context.temp_input_buffer.Get_Address), output => context.temp_buffer.Get_Address, weight_offset => curr_weight_off, layer_size => curr_layer_size, output_size => curr_output_size, events_to_wait => (if i=1 then events_to_wait else previous_ev), cl_code => cl_code); reduce_ev: constant cl_objects.Event := Reduce_Activate(context => context, input => context.temp_buffer.Get_Address, output => (if i=context.nn_shape.Length - 1 then output.Get_Address else context.temp_input_buffer.Get_Address), bias_offset => curr_bias_off, layer_size => curr_layer_size, output_size => next_layer_size, events_to_wait => (1 => mult_w_ev.Get_Handle), cl_code => cl_code); begin if cl_code /= opencl.SUCCESS then return cl_objects.Create_Empty; end if; final_event := reduce_ev.Get_Handle; if i > 1 then cl_code := opencl.Release_Event(previous_ev(1)); end if; if i /= context.nn_shape.Length - 1 then cl_code := opencl.Retain_Event(final_event); else return cl_objects.Create_Event(final_event); end if; if cl_code /= opencl.SUCCESS then return cl_objects.Create_Empty; end if; previous_ev(1) := final_event; end; curr_bias_off := curr_bias_off + next_layer_size; curr_weight_off := curr_weight_off + curr_output_size; end loop; return cl_objects.Create_Empty; end Forward; end GpuInference;
zhmu/ananas
Ada
2,418
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- E X P _ C H 1 3 -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- Expand routines for chapter 13 constructs with Types; use Types; package Exp_Ch13 is procedure Expand_N_Attribute_Definition_Clause (N : Node_Id); procedure Expand_N_Free_Statement (N : Node_Id); procedure Expand_N_Freeze_Entity (N : Node_Id); -- Note: for GNATprove we have a minimal variant of this routine in -- Exp_SPARK.Expand_SPARK_N_Freeze_Entity. They need to be kept in sync. procedure Expand_N_Record_Representation_Clause (N : Node_Id); end Exp_Ch13;
yannickmoy/SPARKNaCl
Ada
1,258
adb
with SPARKNaCl; use SPARKNaCl; with SPARKNaCl.Debug; use SPARKNaCl.Debug; with SPARKNaCl.Sign; use SPARKNaCl.Sign; with Ada.Text_IO; use Ada.Text_IO; with Interfaces; use Interfaces; with Random; procedure Sign is Raw_SK : Bytes_32; PK : Signing_PK; SK : Signing_SK; M : constant Byte_Seq (0 .. 255) := (0 => 16#55#, others => 16#aa#); SM : Byte_Seq (0 .. 319) := (others => 0); M2 : Byte_Seq (0 .. 319) := (others => 0); M3 : Byte_Seq (0 .. 255); ML : I32; S : Boolean; -- I : I64 := 1; begin -- loop -- Put_Line ("Iteration " & I'Img); Random.Random_Bytes (Raw_SK); Keypair (Raw_SK, PK, SK); begin Sign (SM, M, SK); exception when Constraint_Error => Debug.DH ("In Sign, SK was ", Serialize (SK)); raise; end; begin Open (M2, S, ML, SM, PK); exception when Constraint_Error => Debug.DH ("In Open, PK was ", Serialize (PK)); Debug.DH ("In Open, SM was ", SM); raise; end; M3 := M2 (0 .. 255); -- I := I + 1; DH ("M3 is ", M3); Put_Line ("Status is " & S'Img); Put_Line ("ML is " & ML'Img); -- end loop; end Sign;
burratoo/Acton
Ada
3,844
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . F I N A L I Z A T I O N -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2014, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- -- apply solely to the contents of the part following the private keyword. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ pragma Warnings (Off); with System.Finalization_Root; pragma Warnings (On); package Ada.Finalization is pragma Pure; pragma Preelaborate; pragma Remote_Types; -- The above apply in versions of Ada before Ada 2012 type Controlled is abstract tagged private; pragma Preelaborable_Initialization (Controlled); procedure Initialize (Object : in out Controlled); procedure Adjust (Object : in out Controlled); procedure Finalize (Object : in out Controlled); type Limited_Controlled is abstract tagged limited private; pragma Preelaborable_Initialization (Limited_Controlled); procedure Initialize (Object : in out Limited_Controlled); procedure Finalize (Object : in out Limited_Controlled); private package SFR renames System.Finalization_Root; type Controlled is abstract new SFR.Root_Controlled with null record; -- In order to simplify the implementation, the mechanism in Process_Full_ -- View ensures that the full view is limited even though the parent type -- is not. type Limited_Controlled is abstract new SFR.Root_Controlled with null record; end Ada.Finalization;
optikos/oasis
Ada
4,447
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Lexical_Elements; with Program.Elements.Formal_Ordinary_Fixed_Point_Definitions; with Program.Element_Visitors; package Program.Nodes.Formal_Ordinary_Fixed_Point_Definitions is pragma Preelaborate; type Formal_Ordinary_Fixed_Point_Definition is new Program.Nodes.Node and Program.Elements.Formal_Ordinary_Fixed_Point_Definitions .Formal_Ordinary_Fixed_Point_Definition and Program.Elements.Formal_Ordinary_Fixed_Point_Definitions .Formal_Ordinary_Fixed_Point_Definition_Text with private; function Create (Delta_Token : not null Program.Lexical_Elements.Lexical_Element_Access; Box_Token : not null Program.Lexical_Elements.Lexical_Element_Access) return Formal_Ordinary_Fixed_Point_Definition; type Implicit_Formal_Ordinary_Fixed_Point_Definition is new Program.Nodes.Node and Program.Elements.Formal_Ordinary_Fixed_Point_Definitions .Formal_Ordinary_Fixed_Point_Definition with private; function Create (Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False) return Implicit_Formal_Ordinary_Fixed_Point_Definition with Pre => Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance; private type Base_Formal_Ordinary_Fixed_Point_Definition is abstract new Program.Nodes.Node and Program.Elements.Formal_Ordinary_Fixed_Point_Definitions .Formal_Ordinary_Fixed_Point_Definition with null record; procedure Initialize (Self : aliased in out Base_Formal_Ordinary_Fixed_Point_Definition'Class); overriding procedure Visit (Self : not null access Base_Formal_Ordinary_Fixed_Point_Definition; Visitor : in out Program.Element_Visitors.Element_Visitor'Class); overriding function Is_Formal_Ordinary_Fixed_Point_Definition_Element (Self : Base_Formal_Ordinary_Fixed_Point_Definition) return Boolean; overriding function Is_Formal_Type_Definition_Element (Self : Base_Formal_Ordinary_Fixed_Point_Definition) return Boolean; overriding function Is_Definition_Element (Self : Base_Formal_Ordinary_Fixed_Point_Definition) return Boolean; type Formal_Ordinary_Fixed_Point_Definition is new Base_Formal_Ordinary_Fixed_Point_Definition and Program.Elements.Formal_Ordinary_Fixed_Point_Definitions .Formal_Ordinary_Fixed_Point_Definition_Text with record Delta_Token : not null Program.Lexical_Elements.Lexical_Element_Access; Box_Token : not null Program.Lexical_Elements.Lexical_Element_Access; end record; overriding function To_Formal_Ordinary_Fixed_Point_Definition_Text (Self : aliased in out Formal_Ordinary_Fixed_Point_Definition) return Program.Elements.Formal_Ordinary_Fixed_Point_Definitions .Formal_Ordinary_Fixed_Point_Definition_Text_Access; overriding function Delta_Token (Self : Formal_Ordinary_Fixed_Point_Definition) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Box_Token (Self : Formal_Ordinary_Fixed_Point_Definition) return not null Program.Lexical_Elements.Lexical_Element_Access; type Implicit_Formal_Ordinary_Fixed_Point_Definition is new Base_Formal_Ordinary_Fixed_Point_Definition with record Is_Part_Of_Implicit : Boolean; Is_Part_Of_Inherited : Boolean; Is_Part_Of_Instance : Boolean; end record; overriding function To_Formal_Ordinary_Fixed_Point_Definition_Text (Self : aliased in out Implicit_Formal_Ordinary_Fixed_Point_Definition) return Program.Elements.Formal_Ordinary_Fixed_Point_Definitions .Formal_Ordinary_Fixed_Point_Definition_Text_Access; overriding function Is_Part_Of_Implicit (Self : Implicit_Formal_Ordinary_Fixed_Point_Definition) return Boolean; overriding function Is_Part_Of_Inherited (Self : Implicit_Formal_Ordinary_Fixed_Point_Definition) return Boolean; overriding function Is_Part_Of_Instance (Self : Implicit_Formal_Ordinary_Fixed_Point_Definition) return Boolean; end Program.Nodes.Formal_Ordinary_Fixed_Point_Definitions;
stcarrez/ada-awa
Ada
10,469
adb
----------------------------------------------------------------------- -- Util testsuite - Util Testsuite -- Copyright (C) 2009 - 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 AWA.Users.Services.Tests; with AWA.Users.Tests; with AWA.Blogs.Modules.Tests; with AWA.Blogs.Tests; with AWA.Helpers.Selectors.Tests; with AWA.Storages.Services.Tests; with AWA.Storages.Tests; with AWA.Events.Services.Tests; with AWA.Mail.Clients.Tests; with AWA.Mail.Modules.Tests; with AWA.Images.Modules.Tests; with AWA.Images.Tests; with AWA.Votes.Modules.Tests; with AWA.Tags.Modules.Tests; with AWA.Questions.Modules.Tests; with AWA.Questions.Tests; with AWA.Counters.Modules.Tests; with AWA.Workspaces.Tests; with AWA.Modules.Tests; with ASF.Converters.Dates; with ASF.Converters.Sizes; with AWA.Users.Modules; with AWA.Mail.Modules; with AWA.Blogs.Modules; with AWA.Workspaces.Modules; with AWA.Storages.Modules; with AWA.Images.Modules; with AWA.Questions.Modules; with AWA.Votes.Modules; with AWA.Tags.Modules; with AWA.Changelogs.Modules; with AWA.Counters.Modules; with AWA.Converters.Dates; with AWA.Tests; with AWA.Services.Contexts; with AWA.Jobs.Services.Tests; with AWA.Jobs.Modules.Tests; with AWA.Settings.Modules.Tests; with AWA.Comments.Modules.Tests; with AWA.Changelogs.Modules.Tests; with AWA.Wikis.Modules.Tests; with AWA.Wikis.Tests; with AWA.Commands.Tests; with ADO.Drivers; with Servlet.Server; with Security.Auth; with Security.Auth.Fake; package body AWA.Testsuite is function OAuth_Provider_Factory (Name : in String) return Security.Auth.Manager_Access; Users : aliased AWA.Users.Modules.User_Module; Workspaces : aliased AWA.Workspaces.Modules.Workspace_Module; Mail : aliased AWA.Mail.Modules.Mail_Module; Jobs : aliased AWA.Jobs.Modules.Job_Module; Comments : aliased AWA.Comments.Modules.Comment_Module; Blogs : aliased AWA.Blogs.Modules.Blog_Module; Storages : aliased AWA.Storages.Modules.Storage_Module; Images : aliased AWA.Images.Modules.Image_Module; Questions : aliased AWA.Questions.Modules.Question_Module; Votes : aliased AWA.Votes.Modules.Vote_Module; Tags : aliased AWA.Tags.Modules.Tag_Module; Settings : aliased AWA.Settings.Modules.Setting_Module; Changelogs : aliased AWA.Changelogs.Modules.Changelog_Module; Wikis : aliased AWA.Wikis.Modules.Wiki_Module; Counters : aliased AWA.Counters.Modules.Counter_Module; Date_Converter : aliased ASF.Converters.Dates.Date_Converter; Rel_Date_Converter : aliased AWA.Converters.Dates.Relative_Date_Converter; Size_Converter : aliased ASF.Converters.Sizes.Size_Converter; Tests : aliased Util.Tests.Test_Suite; function OAuth_Provider_Factory (Name : in String) return Security.Auth.Manager_Access is pragma Unreferenced (Name); begin return new Security.Auth.Fake.Manager; end OAuth_Provider_Factory; function Suite return Util.Tests.Access_Test_Suite is Ret : constant Util.Tests.Access_Test_Suite := Tests'Access; begin Security.Auth.Set_Default_Factory (OAuth_Provider_Factory'Access); AWA.Commands.Tests.Add_Tests (Ret); AWA.Jobs.Modules.Tests.Add_Tests (Ret); AWA.Jobs.Services.Tests.Add_Tests (Ret); AWA.Settings.Modules.Tests.Add_Tests (Ret); AWA.Comments.Modules.Tests.Add_Tests (Ret); AWA.Blogs.Modules.Tests.Add_Tests (Ret); AWA.Blogs.Tests.Add_Tests (Ret); AWA.Storages.Tests.Add_Tests (Ret); AWA.Storages.Services.Tests.Add_Tests (Ret); AWA.Images.Modules.Tests.Add_Tests (Ret); AWA.Images.Tests.Add_Tests (Ret); AWA.Changelogs.Modules.Tests.Add_Tests (Ret); AWA.Votes.Modules.Tests.Add_Tests (Ret); AWA.Tags.Modules.Tests.Add_Tests (Ret); AWA.Questions.Modules.Tests.Add_Tests (Ret); AWA.Questions.Tests.Add_Tests (Ret); AWA.Wikis.Modules.Tests.Add_Tests (Ret); AWA.Wikis.Tests.Add_Tests (Ret); AWA.Events.Services.Tests.Add_Tests (Ret); AWA.Mail.Clients.Tests.Add_Tests (Ret); AWA.Mail.Modules.Tests.Add_Tests (Ret); AWA.Workspaces.Tests.Add_Tests (Ret); AWA.Users.Services.Tests.Add_Tests (Ret); AWA.Users.Tests.Add_Tests (Ret); AWA.Counters.Modules.Tests.Add_Tests (Ret); AWA.Helpers.Selectors.Tests.Add_Tests (Ret); AWA.Modules.Tests.Add_Tests (Ret); return Ret; end Suite; procedure Initialize (Props : in Util.Properties.Manager) is begin Initialize (null, Props, True); end Initialize; -- ------------------------------ -- Initialize the AWA test framework mockup. -- ------------------------------ procedure Initialize (App : in AWA.Applications.Application_Access; Props : in Util.Properties.Manager; Add_Modules : in Boolean) is use AWA.Applications; begin ADO.Drivers.Initialize; AWA.Tests.Initialize (App, Props, Add_Modules); if Add_Modules then declare Application : constant Applications.Application_Access := AWA.Tests.Get_Application; Ctx : AWA.Services.Contexts.Service_Context; Users : constant AWA.Users.Modules.User_Module_Access := AWA.Testsuite.Users'Access; begin Ctx.Set_Context (Application, null); Register (App => Application.all'Access, Name => AWA.Users.Modules.NAME, URI => "user", Module => Users.all'Access); Register (App => Application.all'Access, Name => "mail", URI => "mail", Module => Mail'Access); Register (App => Application.all'Access, Name => "workspaces", URI => "workspaces", Module => Workspaces'Access); Register (App => Application.all'Access, Name => AWA.Counters.Modules.NAME, URI => "counters", Module => Counters'Access); Register (App => Application.all'Access, Name => AWA.Comments.Modules.NAME, URI => "comments", Module => Comments'Access); Register (App => Application.all'Access, Name => AWA.Storages.Modules.NAME, URI => "storages", Module => Storages'Access); Register (App => Application.all'Access, Name => AWA.Jobs.Modules.NAME, URI => "jobs", Module => Jobs'Access); Register (App => Application.all'Access, Name => AWA.Images.Modules.NAME, URI => "images", Module => Images'Access); Register (App => Application.all'Access, Name => AWA.Settings.Modules.NAME, URI => "settings", Module => Settings'Access); Register (App => Application.all'Access, Name => AWA.Votes.Modules.NAME, URI => "votes", Module => Votes'Access); Register (App => Application.all'Access, Name => AWA.Changelogs.Modules.NAME, URI => "changelogs", Module => Changelogs'Access); Register (App => Application.all'Access, Name => AWA.Tags.Modules.NAME, URI => "tags", Module => Tags'Access); Register (App => Application.all'Access, Name => AWA.Blogs.Modules.NAME, URI => "blogs", Module => Blogs'Access); Register (App => Application.all'Access, Name => AWA.Questions.Modules.NAME, URI => "questions", Module => Questions'Access); Register (App => Application.all'Access, Name => AWA.Wikis.Modules.NAME, URI => "wikis", Module => Wikis'Access); Application.Add_Converter (Name => "dateConverter", Converter => Date_Converter'Access); Application.Add_Converter (Name => "smartDateConverter", Converter => Rel_Date_Converter'Access); Application.Add_Converter (Name => "sizeConverter", Converter => Size_Converter'Access); Application.Start; -- if Props.Exists ("test.server") then -- declare -- WS : ASF.Server.Web.AWS_Container; -- begin -- Application.Add_Converter (Name => "dateConverter", -- Converter => Date_Converter'Access); -- Application.Add_Converter (Name => "smartDateConverter", -- Converter => Rel_Date_Converter'Access); -- -- WS.Register_Application ("/asfunit", Application.all'Access); -- -- WS.Start; -- delay 6000.0; -- end; -- end if; Servlet.Server.Set_Context (Application.all'Access); end; end if; end Initialize; end AWA.Testsuite;
stcarrez/ada-libsecret
Ada
3,578
ads
----------------------------------------------------------------------- -- secret-services -- Ada wrapper for Secret Service -- Copyright (C) 2017 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Secret.Attributes; with Secret.Values; -- === Secret Service === -- The <tt>Secret.Services</tt> package defines the <tt>Service_Type</tt> that gives -- access to the secret service provided by the desktop keyring manager. The service -- instance is declared as follows: -- -- Service : Secret.Services.Service_Type; -- -- The initialization is optional since the libsecret API will do the initialization itself -- if necessary. However, the initialization could be useful to indicate to open a session -- and/or to load the collections. In that case, the <tt>Initialize</tt> procedure is called: -- -- Service.Initialize (Open_Session => True); -- -- The list of attributes that allows to retrieve the secret value must be declared and -- initialized with the key/value pairs: -- -- Attr : Secret.Attributes.Map; -- -- and the key/value pairs are inserted as follows: -- -- Attr.Insert ("my-key", "my-value"); -- -- The secret value is represented by the <tt>Secret_Type</tt> and it is initialized as -- follows: -- -- Value : Secret.Values.Secret_Type := Secret.Values.Create ("my-password-to-protect"); -- -- Then, storing the secret value is done by the <tt>Store</tt> procedure and the label -- is given to help identifying the value from the keyring manager: -- -- Service.Store (Attr, "Application password", Value); -- package Secret.Services is Service_Error : exception; type Service_Type is new Object_Type with null record; -- Initialize the secret service instance by getting a secret service proxy and -- making sure the service has the service flags initialized. procedure Initialize (Service : out Service_Type; Open_Session : in Boolean := False; Load_Collections : in Boolean := False); -- Store the value in the secret service identified by the attributes and associate -- the value with the given label. procedure Store (Service : in Service_Type; Attr : in Secret.Attributes.Map; Label : in String; Value : in Secret.Values.Secret_Type) with Pre => not Attr.Is_Null and not Value.Is_Null; -- Lookup in the secret service the value identified by the attributes. function Lookup (Service : in Service_Type; Attr : in Secret.Attributes.Map) return Secret.Values.Secret_Type with Pre => not Attr.Is_Null; -- Remove from the secret service the value associated with the given attributes. procedure Remove (Service : in Service_Type; Attr : in Secret.Attributes.Map) with Pre => not Attr.Is_Null; end Secret.Services;
zhmu/ananas
Ada
53,742
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- G N A T . C O M M A N D _ L I N E -- -- -- -- S p e c -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ -- High level package for command line parsing and manipulation ---------------------------------------- -- Simple Parsing of the Command Line -- ---------------------------------------- -- This package provides an interface for parsing command line arguments, -- when they are either read from Ada.Command_Line or read from a string list. -- As shown in the example below, one should first retrieve the switches -- (special command line arguments starting with '-' by default) and their -- parameters, and then the rest of the command line arguments. -- -- While it may appear easy to parse the command line arguments with -- Ada.Command_Line, there are in fact lots of special cases to handle in some -- applications. Those are fully managed by GNAT.Command_Line. Among these are -- switches with optional parameters, grouping switches (for instance "-ab" -- might mean the same as "-a -b"), various characters to separate a switch -- and its parameter (or none: "-a 1" and "-a1" are generally the same, which -- can introduce confusion with grouped switches),... -- -- begin -- loop -- case Getopt ("a b: ad") is -- Accepts '-a', '-ad', or '-b argument' -- when ASCII.NUL => exit; -- when 'a' => -- if Full_Switch = "a" then -- Put_Line ("Got a"); -- else -- Put_Line ("Got ad"); -- end if; -- when 'b' => Put_Line ("Got b + " & Parameter); -- when others => -- raise Program_Error; -- cannot occur -- end case; -- end loop; -- loop -- declare -- S : constant String := Get_Argument (Do_Expansion => True); -- begin -- exit when S'Length = 0; -- Put_Line ("Got " & S); -- end; -- end loop; -- exception -- when Invalid_Switch => Put_Line ("Invalid Switch " & Full_Switch); -- when Invalid_Parameter => Put_Line ("No parameter for " & Full_Switch); -- end; -------------- -- Sections -- -------------- -- A more complicated example would involve the use of sections for the -- switches, as for instance in gnatmake. The same command line is used to -- provide switches for several tools. Each tool recognizes its switches by -- separating them with special switches that act as section separators. -- Each section acts as a command line of its own. -- begin -- Initialize_Option_Scan ('-', False, "largs bargs cargs"); -- loop -- -- Same loop as above to get switches and arguments -- end loop; -- Goto_Section ("bargs"); -- loop -- -- Same loop as above to get switches and arguments -- -- The supported switches in Getopt might be different -- end loop; -- Goto_Section ("cargs"); -- loop -- -- Same loop as above to get switches and arguments -- -- The supported switches in Getopt might be different -- end loop; -- end; ------------------------------- -- Parsing a List of Strings -- ------------------------------- -- The examples above show how to parse the command line when the arguments -- are read directly from Ada.Command_Line. However, these arguments can also -- be read from a list of strings. This can be useful in several contexts, -- either because your system does not support Ada.Command_Line, or because -- you are manipulating other tools and creating their command lines by hand, -- or for any other reason. -- To create the list of strings, it is recommended to use -- GNAT.OS_Lib.Argument_String_To_List. -- The example below shows how to get the parameters from such a list. Note -- also the use of '*' to get all the switches, and not report errors when an -- unexpected switch was used by the user -- declare -- Parser : Opt_Parser; -- Args : constant Argument_List_Access := -- GNAT.OS_Lib.Argument_String_To_List ("-g -O1 -Ipath"); -- begin -- Initialize_Option_Scan (Parser, Args); -- while Getopt ("* g O! I=", Parser) /= ASCII.NUL loop -- Put_Line ("Switch " & Full_Switch (Parser) -- & " param=" & Parameter (Parser)); -- end loop; -- Free (Parser); -- end; ------------------------------------------- -- High-Level Command Line Configuration -- ------------------------------------------- -- As shown above, the code is still relatively low-level. For instance, there -- is no way to indicate which switches are related (thus if "-l" and "--long" -- should have the same effect, your code will need to test for both cases). -- Likewise, it is difficult to handle more advanced constructs, like: -- * Specifying -gnatwa is the same as specifying -gnatwu -gnatwv, but -- shorter and more readable -- * All switches starting with -gnatw can be grouped, for instance one -- can write -gnatwcd instead of -gnatwc -gnatwd. -- Of course, this can be combined with the above and -gnatwacd is the -- same as -gnatwc -gnatwd -gnatwu -gnatwv -- * The switch -T is the same as -gnatwAB (same as -gnatwA -gnatwB) -- With the above form of Getopt, you would receive "-gnatwa", "-T" or -- "-gnatwcd" in the examples above, and thus you require additional manual -- parsing of the switch. -- Instead, this package provides the type Command_Line_Configuration, which -- stores all the knowledge above. For instance: -- Config : Command_Line_Configuration; -- Define_Alias (Config, "-gnatwa", "-gnatwu -gnatwv"); -- Define_Prefix (Config, "-gnatw"); -- Define_Alias (Config, "-T", "-gnatwAB"); -- You then need to specify all possible switches in your application by -- calling Define_Switch, for instance: -- Define_Switch (Config, "-gnatwu", Help => "warn on unused entities"); -- Define_Switch (Config, "-gnatwv", Help => "warn on unassigned var"); -- ... -- Specifying the help message is optional, but makes it easy to then call -- the function: -- Display_Help (Config); -- that will display a properly formatted help message for your application, -- listing all possible switches. That way you have a single place in which -- to maintain the list of switches and their meaning, rather than maintaining -- both the string to pass to Getopt and a subprogram to display the help. -- Both will properly stay synchronized. -- Once you have this Config, you just have to call: -- Getopt (Config, Callback'Access); -- to parse the command line. The Callback will be called for each switch -- found on the command line (in the case of our example, that is "-gnatwu" -- and then "-gnatwv", not "-gnatwa" itself). This simplifies command line -- parsing a lot. -- In fact, this can be further automated for the most command case where the -- parameter passed to a switch is stored in a variable in the application. -- When a switch is defined, you only have to indicate where to store the -- value, and let Getopt do the rest. For instance: -- Optimization : aliased Integer; -- Verbose : aliased Boolean; -- Define_Switch (Config, Verbose'Access, -- "-v", Long_Switch => "--verbose", -- Help => "Output extra verbose information"); -- Define_Switch (Config, Optimization'Access, -- "-O?", Help => "Optimization level"); -- Getopt (Config); -- No callback -- Since all switches are handled automatically, we don't even need to pass -- a callback to Getopt. Once getopt has been called, the two variables -- Optimization and Verbose have been properly initialized, either to the -- default value or to the value found on the command line. ------------------------------------------------ -- Creating and Manipulating the Command Line -- ------------------------------------------------ -- This package provides mechanisms to create and modify command lines by -- adding or removing arguments from them. The resulting command line is kept -- as short as possible by coalescing arguments whenever possible. -- Complex command lines can thus be constructed, for example from a GUI -- (although this package does not by itself depend upon any specific GUI -- toolkit). -- Using the configuration defined earlier, one can then construct a command -- line for the tool with: -- Cmd : Command_Line; -- Set_Configuration (Cmd, Config); -- Config created earlier -- Add_Switch (Cmd, "-bar"); -- Add_Switch (Cmd, "-gnatwu"); -- Add_Switch (Cmd, "-gnatwv"); -- will be grouped with the above -- Add_Switch (Cmd, "-T"); -- The resulting command line can be iterated over to get all its switches, -- There are two modes for this iteration: either you want to get the -- shortest possible command line, which would be: -- -bar -gnatwaAB -- or on the other hand you want each individual switch (so that your own -- tool does not have to do further complex processing), which would be: -- -bar -gnatwu -gnatwv -gnatwA -gnatwB -- Of course, we can assume that the tool you want to spawn would understand -- both of these, since they are both compatible with the description we gave -- above. However, the first result is useful if you want to show the user -- what you are spawning (since that keeps the output shorter), and the second -- output is more useful for a tool that would check whether -gnatwu was -- passed (which isn't obvious in the first output). Likewise, the second -- output is more useful if you have a graphical interface since each switch -- can be associated with a widget, and you immediately know whether -gnatwu -- was selected. -- -- Some command line arguments can have parameters, which on a command line -- appear as a separate argument that must immediately follow the switch. -- Since the subprograms in this package will reorganize the switches to group -- them, you need to indicate what is a command line parameter, and what is a -- switch argument. -- This is done by passing an extra argument to Add_Switch, as in: -- Add_Switch (Cmd, "-foo", Parameter => "arg1"); -- This ensures that "arg1" will always be treated as the argument to -foo, -- and will not be grouped with other parts of the command line. with Ada.Command_Line; with GNAT.Directory_Operations; with GNAT.OS_Lib; with GNAT.Regexp; with GNAT.Strings; package GNAT.Command_Line is ------------- -- Parsing -- ------------- type Opt_Parser is private; Command_Line_Parser : constant Opt_Parser; -- This object is responsible for parsing a list of arguments, which by -- default are the standard command line arguments from Ada.Command_Line. -- This is really a pointer to actual data, which must therefore be -- initialized through a call to Initialize_Option_Scan, and must be freed -- with a call to Free. -- -- As a special case, Command_Line_Parser does not need to be either -- initialized or free-ed. procedure Initialize_Option_Scan (Switch_Char : Character := '-'; Stop_At_First_Non_Switch : Boolean := False; Section_Delimiters : String := ""); procedure Initialize_Option_Scan (Parser : out Opt_Parser; Command_Line : GNAT.OS_Lib.Argument_List_Access; Switch_Char : Character := '-'; Stop_At_First_Non_Switch : Boolean := False; Section_Delimiters : String := ""); -- The first procedure resets the internal state of the package to prepare -- to rescan the parameters. It does not need to be called before the -- first use of Getopt (but it could be), but it must be called if you -- want to start rescanning the command line parameters from the start. -- The optional parameter Switch_Char can be used to reset the switch -- character, e.g. to '/' for use in DOS-like systems. -- -- The second subprogram initializes a parser that takes its arguments -- from an array of strings rather than directly from the command line. In -- this case, the parser is responsible for freeing the strings stored in -- Command_Line. If you pass null to Command_Line, this will in fact create -- a second parser for Ada.Command_Line, which doesn't share any data with -- the default parser. This parser must be free'ed. -- -- The optional parameter Stop_At_First_Non_Switch indicates if Getopt is -- to look for switches on the whole command line, or if it has to stop as -- soon as a non-switch argument is found. -- -- Example: -- -- Arguments: my_application file1 -c -- -- If Stop_At_First_Non_Switch is False, then -c will be considered -- as a switch (returned by getopt), otherwise it will be considered -- as a normal argument (returned by Get_Argument). -- -- If Section_Delimiters is set, then every following subprogram -- (Getopt and Get_Argument) will only operate within a section, which -- is delimited by any of these delimiters or the end of the command line. -- -- Example: -- Initialize_Option_Scan (Section_Delimiters => "largs bargs cargs"); -- -- Arguments on command line : my_application -c -bargs -d -e -largs -f -- This line contains three sections, the first one is the default one -- and includes only the '-c' switch, the second one is between -bargs -- and -largs and includes '-d -e' and the last one includes '-f'. procedure Free (Parser : in out Opt_Parser); -- Free the memory used by the parser. Calling this is not mandatory for -- the Command_Line_Parser procedure Goto_Section (Name : String := ""; Parser : Opt_Parser := Command_Line_Parser); -- Change the current section. The next Getopt or Get_Argument will start -- looking at the beginning of the section. An empty name ("") refers to -- the first section between the program name and the first section -- delimiter. If the section does not exist in Section_Delimiters, then -- Invalid_Section is raised. If the section does not appear on the command -- line, then it is treated as an empty section. function Full_Switch (Parser : Opt_Parser := Command_Line_Parser) return String; -- Returns the full name of the last switch found (Getopt only returns the -- first character). Does not include the Switch_Char ('-' by default), -- unless the "*" option of Getopt is used (see below). function Current_Section (Parser : Opt_Parser := Command_Line_Parser) return String; -- Return the name of the current section. -- The list of valid sections is defined through Initialize_Option_Scan function Getopt (Switches : String; Concatenate : Boolean := True; Parser : Opt_Parser := Command_Line_Parser) return Character; -- This function moves to the next switch on the command line (defined as -- switch character followed by a character within Switches, casing being -- significant). The result returned is the first character of the switch -- that is located. If there are no more switches in the current section, -- returns ASCII.NUL. If Concatenate is True (the default), the switches do -- not need to be separated by spaces (they can be concatenated if they do -- not require an argument, e.g. -ab is the same as two separate arguments -- -a -b). -- -- Switches is a string of all the possible switches, separated by -- spaces. A switch can be followed by one of the following characters: -- -- ':' The switch requires a parameter. There can optionally be a space -- on the command line between the switch and its parameter. -- -- '=' The switch requires a parameter. There can either be a '=' or a -- space on the command line between the switch and its parameter. -- -- '!' The switch requires a parameter, but there can be no space on the -- command line between the switch and its parameter. -- -- '?' The switch may have an optional parameter. There can be no space -- between the switch and its argument. -- -- e.g. if Switches has the following value : "a? b", -- The command line can be: -- -- -afoo : -a switch with 'foo' parameter -- -a foo : -a switch and another element on the -- command line 'foo', returned by Get_Argument -- -- Example: if Switches is "-a: -aO:", you can have the following -- command lines: -- -- -aarg : 'a' switch with 'arg' parameter -- -a arg : 'a' switch with 'arg' parameter -- -aOarg : 'aO' switch with 'arg' parameter -- -aO arg : 'aO' switch with 'arg' parameter -- -- Example: -- -- Getopt ("a b: ac ad?") -- -- accept either 'a' or 'ac' with no argument, -- accept 'b' with a required argument -- accept 'ad' with an optional argument -- -- If the first item in switches is '*', then Getopt will catch -- every element on the command line that was not caught by any other -- switch. The character returned by GetOpt is '*', but Full_Switch -- contains the full command line argument, including leading '-' if there -- is one. If this character was not returned, there would be no way of -- knowing whether it is there or not. -- -- Example -- Getopt ("* a b") -- If the command line is '-a -c toto.o -b', Getopt will return -- successively 'a', '*', '*' and 'b', with Full_Switch returning -- "a", "-c", "toto.o", and "b". -- -- When Getopt encounters an invalid switch, it raises the exception -- Invalid_Switch and sets Full_Switch to return the invalid switch. -- When Getopt cannot find the parameter associated with a switch, it -- raises Invalid_Parameter, and sets Full_Switch to return the invalid -- switch. -- -- Note: in case of ambiguity, e.g. switches a ab abc, then the longest -- matching switch is returned. -- -- Arbitrary characters are allowed for switches, although it is -- strongly recommended to use only letters and digits for portability -- reasons. -- -- When Concatenate is False, individual switches need to be separated by -- spaces. -- -- Example -- Getopt ("a b", Concatenate => False) -- If the command line is '-ab', exception Invalid_Switch will be -- raised and Full_Switch will return "ab". function Get_Argument (Do_Expansion : Boolean := False; Parser : Opt_Parser := Command_Line_Parser) return String; -- Returns the next element on the command line that is not a switch. This -- function should be called either after Getopt has returned ASCII.NUL or -- after Getopt procedure call. -- -- If Do_Expansion is True, then the parameter on the command line will -- be considered as a filename with wildcards, and will be expanded. The -- matching file names will be returned one at a time. This is useful in -- non-Unix systems for obtaining normal expansion of wildcard references. -- When there are no more arguments on the command line, this function -- returns an empty string. function Get_Argument (Do_Expansion : Boolean := False; Parser : Opt_Parser := Command_Line_Parser; End_Of_Arguments : out Boolean) return String; -- The same as above but able to distinguish empty element in argument list -- from end of arguments. -- End_Of_Arguments is True if the end of the command line has been reached -- (i.e. all available arguments have been returned by previous calls to -- Get_Argument). function Parameter (Parser : Opt_Parser := Command_Line_Parser) return String; -- Returns parameter associated with the last switch returned by Getopt. -- If no parameter was associated with the last switch, or no previous call -- has been made to Get_Argument, raises Invalid_Parameter. If the last -- switch was associated with an optional argument and this argument was -- not found on the command line, Parameter returns an empty string. function Separator (Parser : Opt_Parser := Command_Line_Parser) return Character; -- The separator that was between the switch and its parameter. This is -- useful if you want to know exactly what was on the command line. This -- is in general a single character, set to ASCII.NUL if the switch and -- the parameter were concatenated. A space is returned if the switch and -- its argument were in two separate arguments. Invalid_Section : exception; -- Raised when an invalid section is selected by Goto_Section Invalid_Switch : exception; -- Raised when an invalid switch is detected in the command line Invalid_Parameter : exception; -- Raised when a parameter is missing, or an attempt is made to obtain a -- parameter for a switch that does not allow a parameter. ----------------------------------------- -- Expansion of command line arguments -- ----------------------------------------- -- These subprograms take care of expanding globbing patterns on the -- command line. On Unix, such expansion is done by the shell before your -- application is called. But on Windows you must do this expansion -- yourself. type Expansion_Iterator is limited private; -- Type used during expansion of file names procedure Start_Expansion (Iterator : out Expansion_Iterator; Pattern : String; Directory : String := ""; Basic_Regexp : Boolean := True); -- Initialize a wildcard expansion. The next calls to Expansion will -- return the next file name in Directory which match Pattern (Pattern -- is a regular expression, using only the Unix shell and DOS syntax if -- Basic_Regexp is True). When Directory is an empty string, the current -- directory is searched. -- -- Pattern may contain directory separators (as in "src/*/*.ada"). -- Subdirectories of Directory will also be searched, up to one -- hundred levels deep. -- -- When Start_Expansion has been called, function Expansion should -- be called repeatedly until it returns an empty string, before -- Start_Expansion can be called again with the same Expansion_Iterator -- variable. function Expansion (Iterator : Expansion_Iterator) return String; -- Returns the next file in the directory matching the parameters given -- to Start_Expansion and updates Iterator to point to the next entry. -- Returns an empty string when there are no more files. -- -- If Expansion is called again after an empty string has been returned, -- then the exception GNAT.Directory_Operations.Directory_Error is raised. ----------------- -- Configuring -- ----------------- -- The following subprograms are used to manipulate a command line -- represented as a string (for instance "-g -O2"), as well as parsing -- the switches from such a string. They provide high-level configurations -- to define aliases (a switch is equivalent to one or more other switches) -- or grouping of switches ("-gnatyac" is equivalent to "-gnatya" and -- "-gnatyc"). -- See the top of this file for examples on how to use these subprograms type Command_Line_Configuration is private; procedure Define_Section (Config : in out Command_Line_Configuration; Section : String); -- Indicates a new switch section. All switches belonging to the same -- section are ordered together, preceded by the section. They are placed -- at the end of the command line (as in "gnatmake somefile.adb -cargs -g") -- -- The section name should not include the leading '-'. So for instance in -- the case of gnatmake we would use: -- -- Define_Section (Config, "cargs"); -- Define_Section (Config, "bargs"); procedure Define_Alias (Config : in out Command_Line_Configuration; Switch : String; Expanded : String; Section : String := ""); -- Indicates that whenever Switch appears on the command line, it should -- be expanded as Expanded. For instance, for the GNAT compiler switches, -- we would define "-gnatwa" as an alias for "-gnatwcfijkmopruvz", ie some -- default warnings to be activated. -- -- This expansion is only done within the specified section, which must -- have been defined first through a call to [Define_Section]. procedure Define_Prefix (Config : in out Command_Line_Configuration; Prefix : String); -- Indicates that all switches starting with the given prefix should be -- grouped. For instance, for the GNAT compiler we would define "-gnatw" as -- a prefix, so that "-gnatwu -gnatwv" can be grouped into "-gnatwuv" It is -- assumed that the remainder of the switch ("uv") is a set of characters -- whose order is irrelevant. In fact, this package will sort them -- alphabetically. -- -- When grouping switches that accept arguments (for instance "-gnatyL!" -- as the definition, and "-gnatyaL12b" as the command line), only -- numerical arguments are accepted. The above is equivalent to -- "-gnatya -gnatyL12 -gnatyb". procedure Define_Switch (Config : in out Command_Line_Configuration; Switch : String := ""; Long_Switch : String := ""; Help : String := ""; Section : String := ""; Argument : String := "ARG"); -- Indicates a new switch. The format of this switch follows the getopt -- format (trailing ':', '?', etc for defining a switch with parameters). -- -- Switch should also start with the leading '-' (or any other characters). -- If this character is not '-', you need to call Initialize_Option_Scan to -- set the proper character for the parser. -- -- The switches defined in the command_line_configuration object are used -- when ungrouping switches with more that one character after the prefix. -- -- Switch and Long_Switch (when specified) are aliases and can be used -- interchangeably. There is no check that they both take an argument or -- both take no argument. Switch can be set to "*" to indicate that any -- switch is supported (in which case Getopt will return '*', see its -- documentation). -- -- Help is used by the Display_Help procedure to describe the supported -- switches. -- -- In_Section indicates in which section the switch is valid (you need to -- first define the section through a call to Define_Section). -- -- Argument is the name of the argument, as displayed in the automatic -- help message. It is always capitalized for consistency. procedure Define_Switch (Config : in out Command_Line_Configuration; Output : access Boolean; Switch : String := ""; Long_Switch : String := ""; Help : String := ""; Section : String := ""; Value : Boolean := True); -- See Define_Switch for a description of the parameters. -- When the switch is found on the command line, Getopt will set -- Output.all to Value. -- -- Output is always initially set to "not Value", so that if the switch is -- not found on the command line, Output still has a valid value. -- The switch must not take any parameter. -- -- Output must exist at least as long as Config, otherwise an erroneous -- memory access may occur. procedure Define_Switch (Config : in out Command_Line_Configuration; Output : access Integer; Switch : String := ""; Long_Switch : String := ""; Help : String := ""; Section : String := ""; Initial : Integer := 0; Default : Integer := 1; Argument : String := "ARG"); -- See Define_Switch for a description of the parameters. When the -- switch is found on the command line, Getopt will set Output.all to the -- value of the switch's parameter. If the parameter is not an integer, -- Invalid_Parameter is raised. -- Output is always initialized to Initial. If the switch has an optional -- argument which isn't specified by the user, then Output will be set to -- Default. The switch must accept an argument. procedure Define_Switch (Config : in out Command_Line_Configuration; Output : access GNAT.Strings.String_Access; Switch : String := ""; Long_Switch : String := ""; Help : String := ""; Section : String := ""; Argument : String := "ARG"); -- Set Output to the value of the switch's parameter when the switch is -- found on the command line. Output is always initialized to the empty -- string if it does not have a value already (otherwise it is left as is -- so that you can specify the default value directly in the declaration -- of the variable). The switch must accept an argument. type Value_Callback is access procedure (Switch, Value : String); procedure Define_Switch (Config : in out Command_Line_Configuration; Callback : not null Value_Callback; Switch : String := ""; Long_Switch : String := ""; Help : String := ""; Section : String := ""; Argument : String := "ARG"); -- Call Callback for each instance of Switch. The callback is given the -- actual switch and the corresponding value. The switch must accept -- an argument. procedure Set_Usage (Config : in out Command_Line_Configuration; Usage : String := "[switches] [arguments]"; Help : String := ""; Help_Msg : String := ""); -- Defines the general format of the call to the application, and a short -- help text. These are both displayed by Display_Help. When a non-empty -- Help_Msg is given, it is used by Display_Help instead of the -- automatically generated list of supported switches. procedure Display_Help (Config : Command_Line_Configuration); -- Display the help for the tool (i.e. its usage, and its supported -- switches). function Get_Switches (Config : Command_Line_Configuration; Switch_Char : Character := '-'; Section : String := "") return String; -- Get the switches list as expected by Getopt, for a specific section of -- the command line. This list is built using all switches defined -- previously via Define_Switch above. function Section_Delimiters (Config : Command_Line_Configuration) return String; -- Return a string suitable for use in Initialize_Option_Scan procedure Free (Config : in out Command_Line_Configuration); -- Free the memory used by Config type Switch_Handler is access procedure (Switch : String; Parameter : String; Section : String); -- Called when a switch is found on the command line. Switch includes -- any leading '-' that was specified in Define_Switch. This is slightly -- different from the functional version of Getopt above, for which -- Full_Switch omits the first leading '-'. Exit_From_Command_Line : exception; -- Raised when the program should exit because Getopt below has seen -- a -h or --help switch. procedure Getopt (Config : Command_Line_Configuration; Callback : Switch_Handler := null; Parser : Opt_Parser := Command_Line_Parser; Concatenate : Boolean := True; Quiet : Boolean := False); -- Similar to the standard Getopt function. For each switch found on the -- command line, this calls Callback, if the switch is not handled -- automatically. -- -- The list of valid switches are the ones from the configuration. The -- switches that were declared through Define_Switch with an Output -- parameter are never returned (and result in a modification of the Output -- variable). This function will in fact never call [Callback] if all -- switches were handled automatically and there is nothing left to do. -- -- The option Concatenate is identical to the one of the standard Getopt -- function. -- -- This procedure automatically adds -h and --help to the valid switches, -- to display the help message and raises Exit_From_Command_Line. -- If an invalid switch is specified on the command line, this procedure -- will display an error message and raises Invalid_Switch again. -- If the Quiet parameter is True then the error message is not displayed. -- -- This function automatically expands switches: -- -- If Define_Prefix was called (for instance "-gnaty") and the user -- specifies "-gnatycb" on the command line, then Getopt returns -- "-gnatyc" and "-gnatyb" separately. -- -- If Define_Alias was called (for instance "-gnatya = -gnatycb") then -- the latter is returned (in this case it also expands -gnaty as per -- the above. -- -- The goal is to make handling as easy as possible by leaving as much -- work as possible to this package. -- -- As opposed to the standard Getopt, this one will analyze all sections -- as defined by Define_Section, and automatically jump from one section to -- the next. ------------------------------ -- Generating command lines -- ------------------------------ -- Once the command line configuration has been created, you can build your -- own command line. This will be done in general because you need to spawn -- external tools from your application. -- Although it could be done by concatenating strings, the following -- subprograms will properly take care of grouping switches when possible, -- so as to keep the command line as short as possible. They also provide a -- way to remove a switch from an existing command line. -- For instance: -- declare -- Config : Command_Line_Configuration; -- Line : Command_Line; -- Args : Argument_List_Access; -- begin -- Define_Switch (Config, "-gnatyc"); -- Define_Switch (Config, ...); -- for all valid switches -- Define_Prefix (Config, "-gnaty"); -- Set_Configuration (Line, Config); -- Add_Switch (Line, "-O2"); -- Add_Switch (Line, "-gnatyc"); -- Add_Switch (Line, "-gnatyd"); -- -- Build (Line, Args); -- -- Args is now ["-O2", "-gnatycd"] -- end; type Command_Line is private; procedure Set_Configuration (Cmd : in out Command_Line; Config : Command_Line_Configuration); function Get_Configuration (Cmd : Command_Line) return Command_Line_Configuration; -- Set or retrieve the configuration used for that command line. The Config -- must have been initialized first, by calling one of the Define_Switches -- subprograms. procedure Set_Command_Line (Cmd : in out Command_Line; Switches : String; Getopt_Description : String := ""; Switch_Char : Character := '-'); -- Set the new content of the command line, by replacing the current -- version with Switches. -- -- The parsing of Switches is done through calls to Getopt, by passing -- Getopt_Description as an argument. (A "*" is automatically prepended so -- that all switches and command line arguments are accepted). If a config -- was defined via Set_Configuration, the Getopt_Description parameter will -- be ignored. -- -- To properly handle switches that take parameters, you should document -- them in Getopt_Description. Otherwise, the switch and its parameter will -- be recorded as two separate command line arguments as returned by a -- Command_Line_Iterator (which might be fine depending on your -- application). -- -- If the command line has sections (such as -bargs -cargs), then they -- should be listed in the Sections parameter (as "-bargs -cargs"). -- -- This function can be used to reset Cmd by passing an empty string -- -- If an invalid switch is found on the command line (i.e. wasn't defined -- in the configuration via Define_Switch), and the configuration wasn't -- set to accept all switches (by defining "*" as a valid switch), then an -- exception Invalid_Switch is raised. The exception message indicates the -- invalid switch. procedure Add_Switch (Cmd : in out Command_Line; Switch : String; Parameter : String := ""; Separator : Character := ASCII.NUL; Section : String := ""; Add_Before : Boolean := False); -- Add a new switch to the command line, and combine/group it with existing -- switches if possible. Nothing is done if the switch already exists with -- the same parameter. -- -- If the Switch takes a parameter, the latter should be specified -- separately, so that the association between the two is always correctly -- recognized even if the order of switches on the command line changes. -- For instance, you should pass "--check=full" as ("--check", "full") so -- that Remove_Switch below can simply take "--check" in parameter. That -- will automatically remove "full" as well. The value of the parameter is -- never modified by this package. -- -- On the other hand, you could decide to simply pass "--check=full" as -- the Switch above, and then pass no parameter. This means that you need -- to pass "--check=full" to Remove_Switch as well. -- -- A Switch with a parameter will never be grouped with another switch to -- avoid ambiguities as to what the parameter applies to. -- -- If the switch is part of a section, then it should be specified so that -- the switch is correctly placed in the command line, and the section -- added if not already present. For example, to add the -g switch into the -- -cargs section, you need to call (Cmd, "-g", Section => "-cargs"). -- -- [Separator], if specified, overrides the separator that was defined -- through Define_Switch. For instance, if the switch was defined as -- "-from:", the separator defaults to a space. But if your application -- uses unusual separators not supported by GNAT.Command_Line (for instance -- it requires ":"), you can specify this separator here. -- -- For instance, -- Add_Switch(Cmd, "-from", "bar", ':') -- -- results in -- -from:bar -- -- rather than the default -- -from bar -- -- Note however that Getopt doesn't know how to handle ":" as a separator. -- So the recommendation is to declare the switch as "-from!" (i.e. no -- space between the switch and its parameter). Then Getopt will return -- ":bar" as the parameter, and you can trim the ":" in your application. -- -- Invalid_Section is raised if Section was not defined in the -- configuration of the command line. -- -- Add_Before allows insertion of the switch at the beginning of the -- command line. procedure Add_Switch (Cmd : in out Command_Line; Switch : String; Parameter : String := ""; Separator : Character := ASCII.NUL; Section : String := ""; Add_Before : Boolean := False; Success : out Boolean); -- Same as above, returning the status of the operation procedure Remove_Switch (Cmd : in out Command_Line; Switch : String; Remove_All : Boolean := False; Has_Parameter : Boolean := False; Section : String := ""); -- Remove Switch from the command line, and ungroup existing switches if -- necessary. -- -- The actual parameter to the switches are ignored. If for instance -- you are removing "-foo", then "-foo param1" and "-foo param2" can -- be removed. -- -- If Remove_All is True, then all matching switches are removed, otherwise -- only the first matching one is removed. -- -- If Has_Parameter is set to True, then only switches having a parameter -- are removed. -- -- If the switch belongs to a section, then this section should be -- specified: Remove_Switch (Cmd_Line, "-g", Section => "-cargs") called -- on the command line "-g -cargs -g" will result in "-g", while if -- called with (Cmd_Line, "-g") this will result in "-cargs -g". -- If Remove_All is set, then both "-g" will be removed. procedure Remove_Switch (Cmd : in out Command_Line; Switch : String; Remove_All : Boolean := False; Has_Parameter : Boolean := False; Section : String := ""; Success : out Boolean); -- Same as above, reporting the success of the operation (Success is False -- if no switch was removed). procedure Remove_Switch (Cmd : in out Command_Line; Switch : String; Parameter : String; Section : String := ""); -- Remove a switch with a specific parameter. If Parameter is the empty -- string, then only a switch with no parameter will be removed. procedure Free (Cmd : in out Command_Line); -- Free the memory used by Cmd --------------- -- Iteration -- --------------- -- When a command line was created with the above, you can then iterate -- over its contents using the following iterator. type Command_Line_Iterator is private; procedure Start (Cmd : in out Command_Line; Iter : in out Command_Line_Iterator; Expanded : Boolean := False); -- Start iterating over the command line arguments. If Expanded is true, -- then the arguments are not grouped and no alias is used. For instance, -- "-gnatwv" and "-gnatwu" would be returned instead of "-gnatwuv". -- -- The iterator becomes invalid if the command line is changed through a -- call to Add_Switch, Remove_Switch or Set_Command_Line. function Current_Switch (Iter : Command_Line_Iterator) return String; function Is_New_Section (Iter : Command_Line_Iterator) return Boolean; function Current_Section (Iter : Command_Line_Iterator) return String; function Current_Separator (Iter : Command_Line_Iterator) return String; function Current_Parameter (Iter : Command_Line_Iterator) return String; -- Return the current switch and its parameter (or the empty string if -- there is no parameter or the switch was added through Add_Switch -- without specifying the parameter. -- -- Separator is the string that goes between the switch and its separator. -- It could be the empty string if they should be concatenated, or a space -- for instance. When printing, you should not add any other character. function Has_More (Iter : Command_Line_Iterator) return Boolean; -- Return True if there are more switches to be returned procedure Next (Iter : in out Command_Line_Iterator); -- Move to the next switch procedure Build (Line : in out Command_Line; Args : out GNAT.OS_Lib.Argument_List_Access; Expanded : Boolean := False; Switch_Char : Character := '-'); -- This is a wrapper using the Command_Line_Iterator. It provides a simple -- way to get all switches (grouped as much as possible), and possibly -- create an Opt_Parser. -- -- Args must be freed by the caller. -- -- Expanded has the same meaning as in Start. procedure Try_Help; -- Output a message on standard error to indicate how to get the usage for -- the executable. This procedure should only be called when the executable -- accepts switch --help. When this procedure is called by executable xxx, -- the following message is displayed on standard error: -- try "xxx --help" for more information. private Max_Depth : constant := 100; -- Maximum depth of subdirectories Max_Path_Length : constant := 1024; -- Maximum length of relative path type Depth is range 1 .. Max_Depth; type Level is record Name_Last : Natural := 0; Dir : GNAT.Directory_Operations.Dir_Type; end record; type Level_Array is array (Depth) of Level; type Section_Number is new Natural range 0 .. 65534; for Section_Number'Size use 16; type Parameter_Type is record Arg_Num : Positive; First : Positive; Last : Natural; Extra : Character; end record; type Is_Switch_Type is array (Natural range <>) of Boolean; pragma Pack (Is_Switch_Type); type Section_Type is array (Natural range <>) of Section_Number; pragma Pack (Section_Type); type Expansion_Iterator is limited record Start : Positive := 1; -- Position of the first character of the relative path to check against -- the pattern. Dir_Name : String (1 .. Max_Path_Length); Current_Depth : Depth := 1; Levels : Level_Array; Regexp : GNAT.Regexp.Regexp; -- Regular expression built with the pattern Maximum_Depth : Depth := 1; -- The maximum depth of directories, reflecting the number of directory -- separators in the pattern. end record; type Opt_Parser_Data (Arg_Count : Natural) is record Arguments : GNAT.OS_Lib.Argument_List_Access; -- null if reading from the command line The_Parameter : Parameter_Type; The_Separator : Character; The_Switch : Parameter_Type; -- This type and this variable are provided to store the current switch -- and parameter. Is_Switch : Is_Switch_Type (1 .. Arg_Count) := [others => False]; -- Indicates wich arguments on the command line are considered not be -- switches or parameters to switches (leaving e.g. filenames,...) Section : Section_Type (1 .. Arg_Count) := [others => 1]; -- Contains the number of the section associated with the current -- switch. If this number is 0, then it is a section delimiter, which is -- never returned by GetOpt. Current_Argument : Natural := 1; -- Number of the current argument parsed on the command line Current_Index : Natural := 1; -- Index in the current argument of the character to be processed Current_Section : Section_Number := 1; Expansion_It : aliased Expansion_Iterator; -- When Get_Argument is expanding a file name, this is the iterator used In_Expansion : Boolean := False; -- True if we are expanding a file Switch_Character : Character := '-'; -- The character at the beginning of the command line arguments, -- indicating the beginning of a switch. Stop_At_First : Boolean := False; -- If it is True then Getopt stops at the first non-switch argument end record; Command_Line_Parser_Data : aliased Opt_Parser_Data (Ada.Command_Line.Argument_Count); -- The internal data used when parsing the command line type Opt_Parser is access all Opt_Parser_Data; Command_Line_Parser : constant Opt_Parser := Command_Line_Parser_Data'Access; type Switch_Type is (Switch_Untyped, Switch_Boolean, Switch_Integer, Switch_String, Switch_Callback); type Switch_Definition (Typ : Switch_Type := Switch_Untyped) is record Switch : GNAT.OS_Lib.String_Access; Long_Switch : GNAT.OS_Lib.String_Access; Section : GNAT.OS_Lib.String_Access; Help : GNAT.OS_Lib.String_Access; Argument : GNAT.OS_Lib.String_Access; -- null if "ARG". -- Name of the argument for this switch. case Typ is when Switch_Untyped => null; when Switch_Boolean => Boolean_Output : access Boolean; Boolean_Value : Boolean; -- will set Output to that value when Switch_Integer => Integer_Output : access Integer; Integer_Initial : Integer; Integer_Default : Integer; when Switch_String => String_Output : access GNAT.Strings.String_Access; when Switch_Callback => Callback : Value_Callback; end case; end record; type Switch_Definitions is array (Natural range <>) of Switch_Definition; type Switch_Definitions_List is access all Switch_Definitions; -- [Switch] includes the leading '-' type Alias_Definition is record Alias : GNAT.OS_Lib.String_Access; Expansion : GNAT.OS_Lib.String_Access; Section : GNAT.OS_Lib.String_Access; end record; type Alias_Definitions is array (Natural range <>) of Alias_Definition; type Alias_Definitions_List is access all Alias_Definitions; type Command_Line_Configuration_Record is record Prefixes : GNAT.OS_Lib.Argument_List_Access; -- The list of prefixes Sections : GNAT.OS_Lib.Argument_List_Access; -- The list of sections Star_Switch : Boolean := False; -- Whether switches not described in this configuration should be -- returned to the user (True). If False, an exception Invalid_Switch -- is raised. Aliases : Alias_Definitions_List; Usage : GNAT.OS_Lib.String_Access; Help : GNAT.OS_Lib.String_Access; Help_Msg : GNAT.OS_Lib.String_Access; Switches : Switch_Definitions_List; -- List of expected switches (Used when expanding switch groups) end record; type Command_Line_Configuration is access Command_Line_Configuration_Record; type Command_Line is record Config : Command_Line_Configuration; Expanded : GNAT.OS_Lib.Argument_List_Access; Params : GNAT.OS_Lib.Argument_List_Access; -- Parameter for the corresponding switch in Expanded. The first -- character is the separator (or ASCII.NUL if there is no separator). Sections : GNAT.OS_Lib.Argument_List_Access; -- The list of sections Coalesce : GNAT.OS_Lib.Argument_List_Access; Coalesce_Params : GNAT.OS_Lib.Argument_List_Access; Coalesce_Sections : GNAT.OS_Lib.Argument_List_Access; -- Cached version of the command line. This is recomputed every time -- the command line changes. Switches are grouped as much as possible, -- and aliases are used to reduce the length of the command line. The -- parameters are not allocated, they point into Params, so they must -- not be freed. end record; type Command_Line_Iterator is record List : GNAT.OS_Lib.Argument_List_Access; Sections : GNAT.OS_Lib.Argument_List_Access; Params : GNAT.OS_Lib.Argument_List_Access; Current : Natural; end record; end GNAT.Command_Line;
AdaCore/libadalang
Ada
421
adb
procedure Test is package Name is type Named is limited interface; function Get_Name (X : Named) return String is abstract; end Name; package Foo is use Name; type Has_Foo is limited interface and Named; end Foo; use Foo; function Bar (X : Has_Foo'Class) return String is begin return Get_Name (X); pragma Test_Statement; end Bar; begin null; end Test;
reznikmm/matreshka
Ada
4,866
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Generic_Collections; package AMF.UML.Features.Collections is pragma Preelaborate; package UML_Feature_Collections is new AMF.Generic_Collections (UML_Feature, UML_Feature_Access); type Set_Of_UML_Feature is new UML_Feature_Collections.Set with null record; Empty_Set_Of_UML_Feature : constant Set_Of_UML_Feature; type Ordered_Set_Of_UML_Feature is new UML_Feature_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_UML_Feature : constant Ordered_Set_Of_UML_Feature; type Bag_Of_UML_Feature is new UML_Feature_Collections.Bag with null record; Empty_Bag_Of_UML_Feature : constant Bag_Of_UML_Feature; type Sequence_Of_UML_Feature is new UML_Feature_Collections.Sequence with null record; Empty_Sequence_Of_UML_Feature : constant Sequence_Of_UML_Feature; private Empty_Set_Of_UML_Feature : constant Set_Of_UML_Feature := (UML_Feature_Collections.Set with null record); Empty_Ordered_Set_Of_UML_Feature : constant Ordered_Set_Of_UML_Feature := (UML_Feature_Collections.Ordered_Set with null record); Empty_Bag_Of_UML_Feature : constant Bag_Of_UML_Feature := (UML_Feature_Collections.Bag with null record); Empty_Sequence_Of_UML_Feature : constant Sequence_Of_UML_Feature := (UML_Feature_Collections.Sequence with null record); end AMF.UML.Features.Collections;
reznikmm/matreshka
Ada
3,660
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Testsuite 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$ ------------------------------------------------------------------------------ -- This test checks whether Empty_Holder is initialized properly and copy of -- Empty_Holder works right. ------------------------------------------------------------------------------ with League.Holders; procedure Test_139 is H : League.Holders.Holder; begin H := League.Holders.Empty_Holder; end Test_139;
reznikmm/matreshka
Ada
3,694
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Text_Sender_Company_Elements is pragma Preelaborate; type ODF_Text_Sender_Company is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Text_Sender_Company_Access is access all ODF_Text_Sender_Company'Class with Storage_Size => 0; end ODF.DOM.Text_Sender_Company_Elements;
persan/AdaYaml
Ada
1,097
adb
-- part of ParserTools, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "copying.txt" package body Lexer.Source.Text_IO is procedure Read_Data (S : in out Instance; Buffer : out String; Length : out Natural) is begin Length := Buffer'First; loop Ada.Text_IO.Get_Line (S.File_Pointer.all, Buffer (Length .. Buffer'Last - 1), Length); if Ada.Text_IO.End_Of_File (S.File_Pointer.all) then Buffer (Length) := Character'Val (4); exit; end if; Ada.Text_IO.Get_Line (S.File_Pointer.all, Buffer (Length .. Buffer'Last), Length); exit when Length = Buffer'Last; Buffer (Length + 1) := Character'Val (10); Length := Length + 2; exit when Length > Buffer'Last; end loop; end Read_Data; function As_Source (File : Ada.Text_IO.File_Access) return Pointer is (Pointer'(new Instance'(Source.Instance with File_Pointer => File))); end Lexer.Source.Text_IO;
reznikmm/matreshka
Ada
4,725
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_Db.Parameter_Name_Substitution_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Db_Parameter_Name_Substitution_Attribute_Node is begin return Self : Db_Parameter_Name_Substitution_Attribute_Node do Matreshka.ODF_Db.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Db_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Db_Parameter_Name_Substitution_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Parameter_Name_Substitution_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Db_URI, Matreshka.ODF_String_Constants.Parameter_Name_Substitution_Attribute, Db_Parameter_Name_Substitution_Attribute_Node'Tag); end Matreshka.ODF_Db.Parameter_Name_Substitution_Attributes;
dkm/atomic
Ada
114
ads
with Interfaces; with Atomic.Unsigned; package Atomic.Unsigned_8 is new Atomic.Unsigned (Interfaces.Unsigned_8);
AdaCore/libadalang
Ada
50
ads
package Foo is type X is null record; end Foo;
onox/orka
Ada
1,258
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 AUnit.Test_Suites; with AUnit.Test_Fixtures; package Test_SIMD_AVX_Swizzle is function Suite return AUnit.Test_Suites.Access_Test_Suite; private type Test is new AUnit.Test_Fixtures.Test_Fixture with null record; procedure Test_Shuffle (Object : in out Test); procedure Test_Shuffle_Across_Lanes (Object : in out Test); procedure Test_Permute_Lanes (Object : in out Test); procedure Test_Blend (Object : in out Test); procedure Test_Transpose_Function (Object : in out Test); procedure Test_Transpose_Procedure (Object : in out Test); end Test_SIMD_AVX_Swizzle;
SayCV/rtems-addon-packages
Ada
10,666
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- ncurses -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 2000-2006,2008 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$ -- $Date$ -- 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 : constant Boolean := (first = 128); last : constant 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 : constant Line_Position := Line_Position (4 + ((code - first) mod 16)); col : constant 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 : constant Line_Position := Line_Position (4 + (N mod height)); col : constant 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)); if n = 0 then raise Constraint_Error; end if; 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;
delphi-pascal-archive/adress_book
Ada
969
adb
Группа №1 Группа №2 Группа №3 Группа №4 Группа №5 Группа №6 Алексей Дмитриевич Алферов 123-45-67 888-55-22 916-333-44-55 000-000-000 0 [email protected] Москва Москва, ул. Якиманка www.alf.ru Россия Москва 01.01.1982 Нет комментариев... ***---***---(***)---***---*** Петр Потапович Меренков 567-12-73 906-55-22 926-453-44-55 111-222-555 2 [email protected] Москва, ул... Москва, ул. Новая none Россия Москва 01.02.1985 Нет комментариев... ***---***---(***)---***---*** Ирина Николаевна Васильева 941-44-12 676-56-98 нет 444-222-555 0 нет Москва, ул. Старая Москва, ул. ... none Россия Москва 11.02.1983 Нет комментариев... ***---***---(***)---***---***
tum-ei-rcs/StratoX
Ada
27,541
ads
-- This spec has been automatically generated from STM32F429x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; with HAL; with System; package STM32_SVD.ADC is pragma Preelaborate; --------------- -- Registers -- --------------- ----------------- -- SR_Register -- ----------------- -- status register type SR_Register is record -- Analog watchdog flag AWD : Boolean := False; -- Regular channel end of conversion EOC : Boolean := False; -- Injected channel end of conversion JEOC : Boolean := False; -- Injected channel start flag JSTRT : Boolean := False; -- Regular channel start flag STRT : Boolean := False; -- Overrun OVR : Boolean := False; -- unspecified Reserved_6_31 : HAL.UInt26 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SR_Register use record AWD at 0 range 0 .. 0; EOC at 0 range 1 .. 1; JEOC at 0 range 2 .. 2; JSTRT at 0 range 3 .. 3; STRT at 0 range 4 .. 4; OVR at 0 range 5 .. 5; Reserved_6_31 at 0 range 6 .. 31; end record; ------------------ -- CR1_Register -- ------------------ subtype CR1_AWDCH_Field is HAL.UInt5; subtype CR1_DISCNUM_Field is HAL.UInt3; subtype CR1_RES_Field is HAL.UInt2; -- control register 1 type CR1_Register is record -- Analog watchdog channel select bits AWDCH : CR1_AWDCH_Field := 16#0#; -- Interrupt enable for EOC EOCIE : Boolean := False; -- Analog watchdog interrupt enable AWDIE : Boolean := False; -- Interrupt enable for injected channels JEOCIE : Boolean := False; -- Scan mode SCAN : Boolean := False; -- Enable the watchdog on a single channel in scan mode AWDSGL : Boolean := False; -- Automatic injected group conversion JAUTO : Boolean := False; -- Discontinuous mode on regular channels DISCEN : Boolean := False; -- Discontinuous mode on injected channels JDISCEN : Boolean := False; -- Discontinuous mode channel count DISCNUM : CR1_DISCNUM_Field := 16#0#; -- unspecified Reserved_16_21 : HAL.UInt6 := 16#0#; -- Analog watchdog enable on injected channels JAWDEN : Boolean := False; -- Analog watchdog enable on regular channels AWDEN : Boolean := False; -- Resolution RES : CR1_RES_Field := 16#0#; -- Overrun interrupt enable OVRIE : 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 CR1_Register use record AWDCH at 0 range 0 .. 4; EOCIE at 0 range 5 .. 5; AWDIE at 0 range 6 .. 6; JEOCIE at 0 range 7 .. 7; SCAN at 0 range 8 .. 8; AWDSGL at 0 range 9 .. 9; JAUTO at 0 range 10 .. 10; DISCEN at 0 range 11 .. 11; JDISCEN at 0 range 12 .. 12; DISCNUM at 0 range 13 .. 15; Reserved_16_21 at 0 range 16 .. 21; JAWDEN at 0 range 22 .. 22; AWDEN at 0 range 23 .. 23; RES at 0 range 24 .. 25; OVRIE at 0 range 26 .. 26; Reserved_27_31 at 0 range 27 .. 31; end record; ------------------ -- CR2_Register -- ------------------ subtype CR2_JEXTSEL_Field is HAL.UInt4; subtype CR2_JEXTEN_Field is HAL.UInt2; subtype CR2_EXTSEL_Field is HAL.UInt4; subtype CR2_EXTEN_Field is HAL.UInt2; -- control register 2 type CR2_Register is record -- A/D Converter ON / OFF ADON : Boolean := False; -- Continuous conversion CONT : Boolean := False; -- unspecified Reserved_2_7 : HAL.UInt6 := 16#0#; -- Direct memory access mode (for single ADC mode) DMA : Boolean := False; -- DMA disable selection (for single ADC mode) DDS : Boolean := False; -- End of conversion selection EOCS : Boolean := False; -- Data alignment ALIGN : Boolean := False; -- unspecified Reserved_12_15 : HAL.UInt4 := 16#0#; -- External event select for injected group JEXTSEL : CR2_JEXTSEL_Field := 16#0#; -- External trigger enable for injected channels JEXTEN : CR2_JEXTEN_Field := 16#0#; -- Start conversion of injected channels JSWSTART : Boolean := False; -- unspecified Reserved_23_23 : HAL.Bit := 16#0#; -- External event select for regular group EXTSEL : CR2_EXTSEL_Field := 16#0#; -- External trigger enable for regular channels EXTEN : CR2_EXTEN_Field := 16#0#; -- Start conversion of regular channels SWSTART : Boolean := False; -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR2_Register use record ADON at 0 range 0 .. 0; CONT at 0 range 1 .. 1; Reserved_2_7 at 0 range 2 .. 7; DMA at 0 range 8 .. 8; DDS at 0 range 9 .. 9; EOCS at 0 range 10 .. 10; ALIGN at 0 range 11 .. 11; Reserved_12_15 at 0 range 12 .. 15; JEXTSEL at 0 range 16 .. 19; JEXTEN at 0 range 20 .. 21; JSWSTART at 0 range 22 .. 22; Reserved_23_23 at 0 range 23 .. 23; EXTSEL at 0 range 24 .. 27; EXTEN at 0 range 28 .. 29; SWSTART at 0 range 30 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; -------------------- -- SMPR1_Register -- -------------------- --------------- -- SMPR1.SMP -- --------------- -- SMPR1_SMP array element subtype SMPR1_SMP_Element is HAL.UInt3; -- SMPR1_SMP array type SMPR1_SMP_Field_Array is array (10 .. 18) of SMPR1_SMP_Element with Component_Size => 3, Size => 27; -- Type definition for SMPR1_SMP type SMPR1_SMP_Field (As_Array : Boolean := False) is record case As_Array is when False => -- SMP as a value Val : HAL.UInt27; when True => -- SMP as an array Arr : SMPR1_SMP_Field_Array; end case; end record with Unchecked_Union, Size => 27; for SMPR1_SMP_Field use record Val at 0 range 0 .. 26; Arr at 0 range 0 .. 26; end record; -- sample time register 1 type SMPR1_Register is record -- Sample time bits SMP : SMPR1_SMP_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_27_31 : HAL.UInt5 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SMPR1_Register use record SMP at 0 range 0 .. 26; Reserved_27_31 at 0 range 27 .. 31; end record; -------------------- -- SMPR2_Register -- -------------------- --------------- -- SMPR2.SMP -- --------------- -- SMPR2_SMP array element subtype SMPR2_SMP_Element is HAL.UInt3; -- SMPR2_SMP array type SMPR2_SMP_Field_Array is array (0 .. 9) of SMPR2_SMP_Element with Component_Size => 3, Size => 30; -- Type definition for SMPR2_SMP type SMPR2_SMP_Field (As_Array : Boolean := False) is record case As_Array is when False => -- SMP as a value Val : HAL.UInt30; when True => -- SMP as an array Arr : SMPR2_SMP_Field_Array; end case; end record with Unchecked_Union, Size => 30; for SMPR2_SMP_Field use record Val at 0 range 0 .. 29; Arr at 0 range 0 .. 29; end record; -- sample time register 2 type SMPR2_Register is record -- Sample time bits SMP : SMPR2_SMP_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_30_31 : HAL.UInt2 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SMPR2_Register use record SMP at 0 range 0 .. 29; Reserved_30_31 at 0 range 30 .. 31; end record; -------------------- -- JOFR1_Register -- -------------------- subtype JOFR1_JOFFSET1_Field is HAL.UInt12; -- injected channel data offset register x type JOFR1_Register is record -- Data offset for injected channel x JOFFSET1 : JOFR1_JOFFSET1_Field := 16#0#; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for JOFR1_Register use record JOFFSET1 at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; -------------------- -- JOFR2_Register -- -------------------- subtype JOFR2_JOFFSET2_Field is HAL.UInt12; -- injected channel data offset register x type JOFR2_Register is record -- Data offset for injected channel x JOFFSET2 : JOFR2_JOFFSET2_Field := 16#0#; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for JOFR2_Register use record JOFFSET2 at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; -------------------- -- JOFR3_Register -- -------------------- subtype JOFR3_JOFFSET3_Field is HAL.UInt12; -- injected channel data offset register x type JOFR3_Register is record -- Data offset for injected channel x JOFFSET3 : JOFR3_JOFFSET3_Field := 16#0#; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for JOFR3_Register use record JOFFSET3 at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; -------------------- -- JOFR4_Register -- -------------------- subtype JOFR4_JOFFSET4_Field is HAL.UInt12; -- injected channel data offset register x type JOFR4_Register is record -- Data offset for injected channel x JOFFSET4 : JOFR4_JOFFSET4_Field := 16#0#; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for JOFR4_Register use record JOFFSET4 at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; ------------------ -- HTR_Register -- ------------------ subtype HTR_HT_Field is HAL.UInt12; -- watchdog higher threshold register type HTR_Register is record -- Analog watchdog higher threshold HT : HTR_HT_Field := 16#FFF#; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for HTR_Register use record HT at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; ------------------ -- LTR_Register -- ------------------ subtype LTR_LT_Field is HAL.UInt12; -- watchdog lower threshold register type LTR_Register is record -- Analog watchdog lower threshold LT : LTR_LT_Field := 16#0#; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for LTR_Register use record LT at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; ------------------- -- SQR1_Register -- ------------------- ------------- -- SQR1.SQ -- ------------- -- SQR1_SQ array element subtype SQR1_SQ_Element is HAL.UInt5; -- SQR1_SQ array type SQR1_SQ_Field_Array is array (13 .. 16) of SQR1_SQ_Element with Component_Size => 5, Size => 20; -- Type definition for SQR1_SQ type SQR1_SQ_Field (As_Array : Boolean := False) is record case As_Array is when False => -- SQ as a value Val : HAL.UInt20; when True => -- SQ as an array Arr : SQR1_SQ_Field_Array; end case; end record with Unchecked_Union, Size => 20; for SQR1_SQ_Field use record Val at 0 range 0 .. 19; Arr at 0 range 0 .. 19; end record; subtype SQR1_L_Field is HAL.UInt4; -- regular sequence register 1 type SQR1_Register is record -- 13th conversion in regular sequence SQ : SQR1_SQ_Field := (As_Array => False, Val => 16#0#); -- Regular channel sequence length L : SQR1_L_Field := 16#0#; -- unspecified Reserved_24_31 : HAL.Byte := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SQR1_Register use record SQ at 0 range 0 .. 19; L at 0 range 20 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; ------------------- -- SQR2_Register -- ------------------- ------------- -- SQR2.SQ -- ------------- -- SQR2_SQ array element subtype SQR2_SQ_Element is HAL.UInt5; -- SQR2_SQ array type SQR2_SQ_Field_Array is array (7 .. 12) of SQR2_SQ_Element with Component_Size => 5, Size => 30; -- Type definition for SQR2_SQ type SQR2_SQ_Field (As_Array : Boolean := False) is record case As_Array is when False => -- SQ as a value Val : HAL.UInt30; when True => -- SQ as an array Arr : SQR2_SQ_Field_Array; end case; end record with Unchecked_Union, Size => 30; for SQR2_SQ_Field use record Val at 0 range 0 .. 29; Arr at 0 range 0 .. 29; end record; -- regular sequence register 2 type SQR2_Register is record -- 7th conversion in regular sequence SQ : SQR2_SQ_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_30_31 : HAL.UInt2 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SQR2_Register use record SQ at 0 range 0 .. 29; Reserved_30_31 at 0 range 30 .. 31; end record; ------------------- -- SQR3_Register -- ------------------- ------------- -- SQR3.SQ -- ------------- -- SQR3_SQ array element subtype SQR3_SQ_Element is HAL.UInt5; -- SQR3_SQ array type SQR3_SQ_Field_Array is array (1 .. 6) of SQR3_SQ_Element with Component_Size => 5, Size => 30; -- Type definition for SQR3_SQ type SQR3_SQ_Field (As_Array : Boolean := False) is record case As_Array is when False => -- SQ as a value Val : HAL.UInt30; when True => -- SQ as an array Arr : SQR3_SQ_Field_Array; end case; end record with Unchecked_Union, Size => 30; for SQR3_SQ_Field use record Val at 0 range 0 .. 29; Arr at 0 range 0 .. 29; end record; -- regular sequence register 3 type SQR3_Register is record -- 1st conversion in regular sequence SQ : SQR3_SQ_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_30_31 : HAL.UInt2 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SQR3_Register use record SQ at 0 range 0 .. 29; Reserved_30_31 at 0 range 30 .. 31; end record; ------------------- -- JSQR_Register -- ------------------- -------------- -- JSQR.JSQ -- -------------- -- JSQR_JSQ array element subtype JSQR_JSQ_Element is HAL.UInt5; -- JSQR_JSQ array type JSQR_JSQ_Field_Array is array (1 .. 4) of JSQR_JSQ_Element with Component_Size => 5, Size => 20; -- Type definition for JSQR_JSQ type JSQR_JSQ_Field (As_Array : Boolean := False) is record case As_Array is when False => -- JSQ as a value Val : HAL.UInt20; when True => -- JSQ as an array Arr : JSQR_JSQ_Field_Array; end case; end record with Unchecked_Union, Size => 20; for JSQR_JSQ_Field use record Val at 0 range 0 .. 19; Arr at 0 range 0 .. 19; end record; subtype JSQR_JL_Field is HAL.UInt2; -- injected sequence register type JSQR_Register is record -- 1st conversion in injected sequence JSQ : JSQR_JSQ_Field := (As_Array => False, Val => 16#0#); -- Injected sequence length JL : JSQR_JL_Field := 16#0#; -- unspecified Reserved_22_31 : HAL.UInt10 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for JSQR_Register use record JSQ at 0 range 0 .. 19; JL at 0 range 20 .. 21; Reserved_22_31 at 0 range 22 .. 31; end record; ------------------ -- JDR_Register -- ------------------ subtype JDR1_JDATA_Field is HAL.Short; -- injected data register x type JDR_Register is record -- Read-only. Injected data JDATA : JDR1_JDATA_Field; -- unspecified Reserved_16_31 : HAL.Short; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for JDR_Register use record JDATA at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; ----------------- -- DR_Register -- ----------------- subtype DR_DATA_Field is HAL.Short; -- regular data register type DR_Register is record -- Read-only. Regular data DATA : DR_DATA_Field; -- unspecified Reserved_16_31 : HAL.Short; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DR_Register use record DATA at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; ------------------ -- CSR_Register -- ------------------ -- ADC Common status register type CSR_Register is record -- Read-only. Analog watchdog flag of ADC 1 AWD1 : Boolean; -- Read-only. End of conversion of ADC 1 EOC1 : Boolean; -- Read-only. Injected channel end of conversion of ADC 1 JEOC1 : Boolean; -- Read-only. Injected channel Start flag of ADC 1 JSTRT1 : Boolean; -- Read-only. Regular channel Start flag of ADC 1 STRT1 : Boolean; -- Read-only. Overrun flag of ADC 1 OVR1 : Boolean; -- unspecified Reserved_6_7 : HAL.UInt2; -- Read-only. Analog watchdog flag of ADC 2 AWD2 : Boolean; -- Read-only. End of conversion of ADC 2 EOC2 : Boolean; -- Read-only. Injected channel end of conversion of ADC 2 JEOC2 : Boolean; -- Read-only. Injected channel Start flag of ADC 2 JSTRT2 : Boolean; -- Read-only. Regular channel Start flag of ADC 2 STRT2 : Boolean; -- Read-only. Overrun flag of ADC 2 OVR2 : Boolean; -- unspecified Reserved_14_15 : HAL.UInt2; -- Read-only. Analog watchdog flag of ADC 3 AWD3 : Boolean; -- Read-only. End of conversion of ADC 3 EOC3 : Boolean; -- Read-only. Injected channel end of conversion of ADC 3 JEOC3 : Boolean; -- Read-only. Injected channel Start flag of ADC 3 JSTRT3 : Boolean; -- Read-only. Regular channel Start flag of ADC 3 STRT3 : Boolean; -- Read-only. Overrun flag of ADC3 OVR3 : Boolean; -- unspecified Reserved_22_31 : HAL.UInt10; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CSR_Register use record AWD1 at 0 range 0 .. 0; EOC1 at 0 range 1 .. 1; JEOC1 at 0 range 2 .. 2; JSTRT1 at 0 range 3 .. 3; STRT1 at 0 range 4 .. 4; OVR1 at 0 range 5 .. 5; Reserved_6_7 at 0 range 6 .. 7; AWD2 at 0 range 8 .. 8; EOC2 at 0 range 9 .. 9; JEOC2 at 0 range 10 .. 10; JSTRT2 at 0 range 11 .. 11; STRT2 at 0 range 12 .. 12; OVR2 at 0 range 13 .. 13; Reserved_14_15 at 0 range 14 .. 15; AWD3 at 0 range 16 .. 16; EOC3 at 0 range 17 .. 17; JEOC3 at 0 range 18 .. 18; JSTRT3 at 0 range 19 .. 19; STRT3 at 0 range 20 .. 20; OVR3 at 0 range 21 .. 21; Reserved_22_31 at 0 range 22 .. 31; end record; ------------------ -- CCR_Register -- ------------------ subtype CCR_MULT_Field is HAL.UInt5; subtype CCR_DELAY_Field is HAL.UInt4; subtype CCR_DMA_Field is HAL.UInt2; subtype CCR_ADCPRE_Field is HAL.UInt2; -- ADC common control register type CCR_Register is record -- Multi ADC mode selection MULT : CCR_MULT_Field := 16#0#; -- unspecified Reserved_5_7 : HAL.UInt3 := 16#0#; -- Delay between 2 sampling phases DELAY_k : CCR_DELAY_Field := 16#0#; -- unspecified Reserved_12_12 : HAL.Bit := 16#0#; -- DMA disable selection for multi-ADC mode DDS : Boolean := False; -- Direct memory access mode for multi ADC mode DMA : CCR_DMA_Field := 16#0#; -- ADC prescaler ADCPRE : CCR_ADCPRE_Field := 16#0#; -- unspecified Reserved_18_21 : HAL.UInt4 := 16#0#; -- VBAT enable VBATE : Boolean := False; -- Temperature sensor and VREFINT enable TSVREFE : Boolean := False; -- unspecified Reserved_24_31 : HAL.Byte := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CCR_Register use record MULT at 0 range 0 .. 4; Reserved_5_7 at 0 range 5 .. 7; DELAY_k at 0 range 8 .. 11; Reserved_12_12 at 0 range 12 .. 12; DDS at 0 range 13 .. 13; DMA at 0 range 14 .. 15; ADCPRE at 0 range 16 .. 17; Reserved_18_21 at 0 range 18 .. 21; VBATE at 0 range 22 .. 22; TSVREFE at 0 range 23 .. 23; Reserved_24_31 at 0 range 24 .. 31; end record; ------------------ -- CDR_Register -- ------------------ -- CDR_DATA array element subtype CDR_DATA_Element is HAL.Short; -- CDR_DATA array type CDR_DATA_Field_Array is array (1 .. 2) of CDR_DATA_Element with Component_Size => 16, Size => 32; -- ADC common regular data register for dual and triple modes type CDR_Register (As_Array : Boolean := False) is record case As_Array is when False => -- DATA as a value Val : HAL.Word; when True => -- DATA as an array Arr : CDR_DATA_Field_Array; end case; end record with Unchecked_Union, Size => 32, Volatile_Full_Access, Bit_Order => System.Low_Order_First; for CDR_Register use record Val at 0 range 0 .. 31; Arr at 0 range 0 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Analog-to-digital converter type ADC1_Peripheral is record -- status register SR : SR_Register; -- control register 1 CR1 : CR1_Register; -- control register 2 CR2 : CR2_Register; -- sample time register 1 SMPR1 : SMPR1_Register; -- sample time register 2 SMPR2 : SMPR2_Register; -- injected channel data offset register x JOFR1 : JOFR1_Register; -- injected channel data offset register x JOFR2 : JOFR2_Register; -- injected channel data offset register x JOFR3 : JOFR3_Register; -- injected channel data offset register x JOFR4 : JOFR4_Register; -- watchdog higher threshold register HTR : HTR_Register; -- watchdog lower threshold register LTR : LTR_Register; -- regular sequence register 1 SQR1 : SQR1_Register; -- regular sequence register 2 SQR2 : SQR2_Register; -- regular sequence register 3 SQR3 : SQR3_Register; -- injected sequence register JSQR : JSQR_Register; -- injected data register x JDR1 : JDR_Register; -- injected data register x JDR2 : JDR_Register; -- injected data register x JDR3 : JDR_Register; -- injected data register x JDR4 : JDR_Register; -- regular data register DR : DR_Register; end record with Volatile; for ADC1_Peripheral use record SR at 0 range 0 .. 31; CR1 at 4 range 0 .. 31; CR2 at 8 range 0 .. 31; SMPR1 at 12 range 0 .. 31; SMPR2 at 16 range 0 .. 31; JOFR1 at 20 range 0 .. 31; JOFR2 at 24 range 0 .. 31; JOFR3 at 28 range 0 .. 31; JOFR4 at 32 range 0 .. 31; HTR at 36 range 0 .. 31; LTR at 40 range 0 .. 31; SQR1 at 44 range 0 .. 31; SQR2 at 48 range 0 .. 31; SQR3 at 52 range 0 .. 31; JSQR at 56 range 0 .. 31; JDR1 at 60 range 0 .. 31; JDR2 at 64 range 0 .. 31; JDR3 at 68 range 0 .. 31; JDR4 at 72 range 0 .. 31; DR at 76 range 0 .. 31; end record; -- Analog-to-digital converter ADC1_Periph : aliased ADC1_Peripheral with Import, Address => ADC1_Base; -- Analog-to-digital converter ADC2_Periph : aliased ADC1_Peripheral with Import, Address => ADC2_Base; -- Analog-to-digital converter ADC3_Periph : aliased ADC1_Peripheral with Import, Address => ADC3_Base; -- Common ADC registers type C_ADC_Peripheral is record -- ADC Common status register CSR : CSR_Register; -- ADC common control register CCR : CCR_Register; -- ADC common regular data register for dual and triple modes CDR : CDR_Register; end record with Volatile; for C_ADC_Peripheral use record CSR at 0 range 0 .. 31; CCR at 4 range 0 .. 31; CDR at 8 range 0 .. 31; end record; -- Common ADC registers C_ADC_Periph : aliased C_ADC_Peripheral with Import, Address => C_ADC_Base; end STM32_SVD.ADC;
chenrongchao/coinapi-sdk
Ada
34,425
adb
-- OEML _ REST API -- This section will provide necessary information about the `CoinAPI OEML REST API` protocol. This API is also available in the Postman application: <a href=\"https://postman.coinapi.io/\" target=\"_blank\">https://postman.coinapi.io/</a> -- -- The version of the OpenAPI document: v1 -- Contact: [email protected] -- -- NOTE: This package is auto generated by OpenAPI-Generator 5.0.1. -- https://openapi-generator.tech -- Do not edit the class manually. package body .Models is use Swagger.Streams; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Severity_Type) is begin Into.Start_Entity (Name); Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Severity_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Severity_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Severity_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : Severity_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Message_Type) is begin Into.Start_Entity (Name); Into.Write_Entity ("type", Value.P_Type); Serialize (Into, "severity", Value.Severity); Into.Write_Entity ("exchange_id", Value.Exchange_Id); Into.Write_Entity ("message", Value.Message); Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Message_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Message_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); Swagger.Streams.Deserialize (Object, "type", Value.P_Type); Deserialize (Object, "severity", Value.Severity); Swagger.Streams.Deserialize (Object, "exchange_id", Value.Exchange_Id); Swagger.Streams.Deserialize (Object, "message", Value.Message); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Message_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : Message_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in ValidationError_Type) is begin Into.Start_Entity (Name); Into.Write_Entity ("type", Value.P_Type); Into.Write_Entity ("title", Value.Title); Serialize (Into, "status", Value.Status); Into.Write_Entity ("traceId", Value.Trace_Id); Into.Write_Entity ("errors", Value.Errors); Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in ValidationError_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out ValidationError_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); Swagger.Streams.Deserialize (Object, "type", Value.P_Type); Swagger.Streams.Deserialize (Object, "title", Value.Title); Swagger.Streams.Deserialize (Object, "status", Value.Status); Swagger.Streams.Deserialize (Object, "traceId", Value.Trace_Id); Swagger.Streams.Deserialize (Object, "errors", Value.Errors); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out ValidationError_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : ValidationError_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in OrdType_Type) is begin Into.Start_Entity (Name); Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in OrdType_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out OrdType_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out OrdType_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : OrdType_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in OrdStatus_Type) is begin Into.Start_Entity (Name); Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in OrdStatus_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out OrdStatus_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out OrdStatus_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : OrdStatus_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in OrderCancelAllRequest_Type) is begin Into.Start_Entity (Name); Into.Write_Entity ("exchange_id", Value.Exchange_Id); Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in OrderCancelAllRequest_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out OrderCancelAllRequest_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); Swagger.Streams.Deserialize (Object, "exchange_id", Value.Exchange_Id); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out OrderCancelAllRequest_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : OrderCancelAllRequest_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in OrderCancelSingleRequest_Type) is begin Into.Start_Entity (Name); Into.Write_Entity ("exchange_id", Value.Exchange_Id); Into.Write_Entity ("exchange_order_id", Value.Exchange_Order_Id); Into.Write_Entity ("client_order_id", Value.Client_Order_Id); Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in OrderCancelSingleRequest_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out OrderCancelSingleRequest_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); Swagger.Streams.Deserialize (Object, "exchange_id", Value.Exchange_Id); Swagger.Streams.Deserialize (Object, "exchange_order_id", Value.Exchange_Order_Id); Swagger.Streams.Deserialize (Object, "client_order_id", Value.Client_Order_Id); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out OrderCancelSingleRequest_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : OrderCancelSingleRequest_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in OrdSide_Type) is begin Into.Start_Entity (Name); Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in OrdSide_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out OrdSide_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out OrdSide_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : OrdSide_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in TimeInForce_Type) is begin Into.Start_Entity (Name); Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in TimeInForce_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out TimeInForce_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out TimeInForce_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : TimeInForce_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in OrderNewSingleRequest_Type) is begin Into.Start_Entity (Name); Into.Write_Entity ("exchange_id", Value.Exchange_Id); Into.Write_Entity ("client_order_id", Value.Client_Order_Id); Into.Write_Entity ("symbol_id_exchange", Value.Symbol_Id_Exchange); Into.Write_Entity ("symbol_id_coinapi", Value.Symbol_Id_Coinapi); Serialize (Into, "amount_order", Value.Amount_Order); Serialize (Into, "price", Value.Price); Serialize (Into, "side", Value.Side); Serialize (Into, "order_type", Value.Order_Type); Serialize (Into, "time_in_force", Value.Time_In_Force); Serialize (Into, "expire_time", Value.Expire_Time); Serialize (Into, "exec_inst", Value.Exec_Inst); Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in OrderNewSingleRequest_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out OrderNewSingleRequest_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); Swagger.Streams.Deserialize (Object, "exchange_id", Value.Exchange_Id); Swagger.Streams.Deserialize (Object, "client_order_id", Value.Client_Order_Id); Swagger.Streams.Deserialize (Object, "symbol_id_exchange", Value.Symbol_Id_Exchange); Swagger.Streams.Deserialize (Object, "symbol_id_coinapi", Value.Symbol_Id_Coinapi); Swagger.Streams.Deserialize (Object, "amount_order", Value.Amount_Order); Swagger.Streams.Deserialize (Object, "price", Value.Price); Deserialize (Object, "side", Value.Side); Deserialize (Object, "order_type", Value.Order_Type); Deserialize (Object, "time_in_force", Value.Time_In_Force); Swagger.Streams.Deserialize (Object, "expire_time", Value.Expire_Time); Swagger.Streams.Deserialize (Object, "exec_inst", Value.Exec_Inst); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out OrderNewSingleRequest_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : OrderNewSingleRequest_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Fills_Type) is begin Into.Start_Entity (Name); Serialize (Into, "time", Value.Time); Serialize (Into, "price", Value.Price); Serialize (Into, "amount", Value.Amount); Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Fills_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Fills_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); Swagger.Streams.Deserialize (Object, "time", Value.Time); Swagger.Streams.Deserialize (Object, "price", Value.Price); Swagger.Streams.Deserialize (Object, "amount", Value.Amount); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Fills_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : Fills_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in OrderExecutionReport_Type) is begin Into.Start_Entity (Name); Into.Write_Entity ("exchange_id", Value.Exchange_Id); Into.Write_Entity ("client_order_id", Value.Client_Order_Id); Into.Write_Entity ("symbol_id_exchange", Value.Symbol_Id_Exchange); Into.Write_Entity ("symbol_id_coinapi", Value.Symbol_Id_Coinapi); Serialize (Into, "amount_order", Value.Amount_Order); Serialize (Into, "price", Value.Price); Serialize (Into, "side", Value.Side); Serialize (Into, "order_type", Value.Order_Type); Serialize (Into, "time_in_force", Value.Time_In_Force); Serialize (Into, "expire_time", Value.Expire_Time); Serialize (Into, "exec_inst", Value.Exec_Inst); Into.Write_Entity ("client_order_id_format_exchange", Value.Client_Order_Id_Format_Exchange); Into.Write_Entity ("exchange_order_id", Value.Exchange_Order_Id); Serialize (Into, "amount_open", Value.Amount_Open); Serialize (Into, "amount_filled", Value.Amount_Filled); Serialize (Into, "avg_px", Value.Avg_Px); Serialize (Into, "status", Value.Status); Serialize (Into, "status_history", Value.Status_History); Into.Write_Entity ("error_message", Value.Error_Message); Serialize (Into, "fills", Value.Fills); Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in OrderExecutionReport_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out OrderExecutionReport_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); Swagger.Streams.Deserialize (Object, "exchange_id", Value.Exchange_Id); Swagger.Streams.Deserialize (Object, "client_order_id", Value.Client_Order_Id); Swagger.Streams.Deserialize (Object, "symbol_id_exchange", Value.Symbol_Id_Exchange); Swagger.Streams.Deserialize (Object, "symbol_id_coinapi", Value.Symbol_Id_Coinapi); Swagger.Streams.Deserialize (Object, "amount_order", Value.Amount_Order); Swagger.Streams.Deserialize (Object, "price", Value.Price); Deserialize (Object, "side", Value.Side); Deserialize (Object, "order_type", Value.Order_Type); Deserialize (Object, "time_in_force", Value.Time_In_Force); Swagger.Streams.Deserialize (Object, "expire_time", Value.Expire_Time); Swagger.Streams.Deserialize (Object, "exec_inst", Value.Exec_Inst); Swagger.Streams.Deserialize (Object, "client_order_id_format_exchange", Value.Client_Order_Id_Format_Exchange); Swagger.Streams.Deserialize (Object, "exchange_order_id", Value.Exchange_Order_Id); Swagger.Streams.Deserialize (Object, "amount_open", Value.Amount_Open); Swagger.Streams.Deserialize (Object, "amount_filled", Value.Amount_Filled); Swagger.Streams.Deserialize (Object, "avg_px", Value.Avg_Px); Deserialize (Object, "status", Value.Status); Swagger.Streams.Deserialize (Object, "status_history", Value.Status_History); Swagger.Streams.Deserialize (Object, "error_message", Value.Error_Message); Deserialize (Object, "fills", Value.Fills); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out OrderExecutionReport_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : OrderExecutionReport_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in OrderExecutionReportAllOf_Type) is begin Into.Start_Entity (Name); Into.Write_Entity ("client_order_id_format_exchange", Value.Client_Order_Id_Format_Exchange); Into.Write_Entity ("exchange_order_id", Value.Exchange_Order_Id); Serialize (Into, "amount_open", Value.Amount_Open); Serialize (Into, "amount_filled", Value.Amount_Filled); Serialize (Into, "avg_px", Value.Avg_Px); Serialize (Into, "status", Value.Status); Serialize (Into, "status_history", Value.Status_History); Into.Write_Entity ("error_message", Value.Error_Message); Serialize (Into, "fills", Value.Fills); Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in OrderExecutionReportAllOf_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out OrderExecutionReportAllOf_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); Swagger.Streams.Deserialize (Object, "client_order_id_format_exchange", Value.Client_Order_Id_Format_Exchange); Swagger.Streams.Deserialize (Object, "exchange_order_id", Value.Exchange_Order_Id); Swagger.Streams.Deserialize (Object, "amount_open", Value.Amount_Open); Swagger.Streams.Deserialize (Object, "amount_filled", Value.Amount_Filled); Swagger.Streams.Deserialize (Object, "avg_px", Value.Avg_Px); Deserialize (Object, "status", Value.Status); Swagger.Streams.Deserialize (Object, "status_history", Value.Status_History); Swagger.Streams.Deserialize (Object, "error_message", Value.Error_Message); Deserialize (Object, "fills", Value.Fills); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out OrderExecutionReportAllOf_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : OrderExecutionReportAllOf_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in BalanceData_Type) is begin Into.Start_Entity (Name); Into.Write_Entity ("asset_id_exchange", Value.Asset_Id_Exchange); Into.Write_Entity ("asset_id_coinapi", Value.Asset_Id_Coinapi); Serialize (Into, "balance", Value.Balance); Serialize (Into, "available", Value.Available); Serialize (Into, "locked", Value.Locked); Into.Write_Entity ("last_updated_by", Value.Last_Updated_By); Serialize (Into, "rate_usd", Value.Rate_Usd); Serialize (Into, "traded", Value.Traded); Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in BalanceData_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out BalanceData_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); Swagger.Streams.Deserialize (Object, "asset_id_exchange", Value.Asset_Id_Exchange); Swagger.Streams.Deserialize (Object, "asset_id_coinapi", Value.Asset_Id_Coinapi); Swagger.Streams.Deserialize (Object, "balance", Value.Balance); Swagger.Streams.Deserialize (Object, "available", Value.Available); Swagger.Streams.Deserialize (Object, "locked", Value.Locked); Swagger.Streams.Deserialize (Object, "last_updated_by", Value.Last_Updated_By); Swagger.Streams.Deserialize (Object, "rate_usd", Value.Rate_Usd); Swagger.Streams.Deserialize (Object, "traded", Value.Traded); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out BalanceData_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : BalanceData_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Balance_Type) is begin Into.Start_Entity (Name); Into.Write_Entity ("exchange_id", Value.Exchange_Id); Serialize (Into, "data", Value.Data); Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Balance_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Balance_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); Swagger.Streams.Deserialize (Object, "exchange_id", Value.Exchange_Id); Deserialize (Object, "data", Value.Data); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Balance_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : Balance_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Position_Type) is begin Into.Start_Entity (Name); Into.Write_Entity ("exchange_id", Value.Exchange_Id); Serialize (Into, "data", Value.Data); Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in Position_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Position_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); Swagger.Streams.Deserialize (Object, "exchange_id", Value.Exchange_Id); Deserialize (Object, "data", Value.Data); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out Position_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : Position_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in PositionData_Type) is begin Into.Start_Entity (Name); Into.Write_Entity ("symbol_id_exchange", Value.Symbol_Id_Exchange); Into.Write_Entity ("symbol_id_coinapi", Value.Symbol_Id_Coinapi); Serialize (Into, "avg_entry_price", Value.Avg_Entry_Price); Serialize (Into, "quantity", Value.Quantity); Serialize (Into, "side", Value.Side); Serialize (Into, "unrealized_pnl", Value.Unrealized_Pnl); Serialize (Into, "leverage", Value.Leverage); Into.Write_Entity ("cross_margin", Value.Cross_Margin); Serialize (Into, "liquidation_price", Value.Liquidation_Price); Into.Write_Entity ("raw_data", Value.Raw_Data); Into.End_Entity (Name); end Serialize; procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class; Name : in String; Value : in PositionData_Type_Vectors.Vector) is begin Into.Start_Array (Name); for Item of Value loop Serialize (Into, "", Item); end loop; Into.End_Array (Name); end Serialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out PositionData_Type) is Object : Swagger.Value_Type; begin Swagger.Streams.Deserialize (From, Name, Object); Swagger.Streams.Deserialize (Object, "symbol_id_exchange", Value.Symbol_Id_Exchange); Swagger.Streams.Deserialize (Object, "symbol_id_coinapi", Value.Symbol_Id_Coinapi); Swagger.Streams.Deserialize (Object, "avg_entry_price", Value.Avg_Entry_Price); Swagger.Streams.Deserialize (Object, "quantity", Value.Quantity); Deserialize (Object, "side", Value.Side); Swagger.Streams.Deserialize (Object, "unrealized_pnl", Value.Unrealized_Pnl); Swagger.Streams.Deserialize (Object, "leverage", Value.Leverage); Swagger.Streams.Deserialize (Object, "cross_margin", Value.Cross_Margin); Swagger.Streams.Deserialize (Object, "liquidation_price", Value.Liquidation_Price); Deserialize (Object, "raw_data", Value.Raw_Data); end Deserialize; procedure Deserialize (From : in Swagger.Value_Type; Name : in String; Value : out PositionData_Type_Vectors.Vector) is List : Swagger.Value_Array_Type; Item : PositionData_Type; begin Value.Clear; Swagger.Streams.Deserialize (From, Name, List); for Data of List loop Deserialize (Data, "", Item); Value.Append (Item); end loop; end Deserialize; end .Models;
caqg/linux-home
Ada
1,179
ads
-- Abstract : -- -- Run the gpr parser standalone. Useful for debugging grammar issues. -- -- Copyright (C) 2017, 2018 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or -- modify it under terms of the GNU General Public License as -- published by the Free Software Foundation; either version 3, or (at -- your option) any later version. This 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 -- distributed with this program; see file COPYING. If not, write to -- the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, -- MA 02110-1335, USA. pragma License (GPL); with Gen_Run_Wisi_LR_Parse; with Gpr_Process_Actions; with Gpr_Process_LR1_Main; with Wisi.Gpr; procedure Run_Gpr_Parse is new Gen_Run_Wisi_LR_Parse (Wisi.Gpr.Parse_Data_Type, Gpr_Process_Actions.Descriptor, null, null, null, Gpr_Process_LR1_Main.Create_Parser);
HeisenbugLtd/open_weather_map_api
Ada
13,498
adb
-------------------------------------------------------------------------------- -- Copyright (C) 2020 by Heisenbug Ltd. ([email protected]) -- -- This work is free. You can redistribute it and/or modify it under the -- terms of the Do What The Fuck You Want To Public License, Version 2, -- as published by Sam Hocevar. See the LICENSE file for more details. -------------------------------------------------------------------------------- pragma License (Unrestricted); with Ada.Calendar.Formatting; with Ada.Text_IO; with Open_Weather_Map.City_Ids; with SI_Units.Metric.Scaling; with SI_Units.Names; with SI_Units.Sexagesimal; package body Open_Weather_Map.Application is My_Debug : constant not null GNATCOLL.Traces.Trace_Handle := GNATCOLL.Traces.Create (Unit_Name => "OWM.APP"); No_Break_Space : constant String := Character'Val (16#C2#) & Character'Val (16#A0#); Standard_Output : constant Ada.Text_IO.File_Type := Ada.Text_IO.Standard_Output; ----------------------------------------------------------------------------- -- Image ----------------------------------------------------------------------------- function Image is new SI_Units.Metric.Fixed_Image (Item => Types.Humidity, Default_Aft => 1, Unit => SI_Units.Names.Percent); ----------------------------------------------------------------------------- -- Image ----------------------------------------------------------------------------- function Image is new SI_Units.Metric.Fixed_Image (Item => Types.Pressure'Base, Default_Aft => 1, Unit => SI_Units.Names.Pascal); ----------------------------------------------------------------------------- -- Image ----------------------------------------------------------------------------- function Image is new SI_Units.Metric.Fixed_Image (Item => Types.Celsius, Default_Aft => 1, Unit => SI_Units.Names.Degree_Celsius); package Degrees is new SI_Units.Sexagesimal (Degree => Types.Degree, Default_Aft => 3); ----------------------------------------------------------------------------- -- Initialize ----------------------------------------------------------------------------- procedure Initialize (Self : in out T) is begin Standard_Application.T (Self).Initialize (Cycle_Time => Ada.Real_Time.Seconds (1), Application_Directory => Application_Directory, Log_Name => "owm"); My_Debug.all.Trace (Message => "Initialize"); Self.Configuration.Initialize; Self.Connection := Client.Create (Configuration => Self.Configuration.Values); Self.API_Calls.Append (New_Item => Query_Data_Set' (new API.API_Class' (API.Create_Current_By_Id (Id => City_Ids.Mexico.Xaltianguis, Configuration => Self.Configuration.Values, Connection => Self.Connection)), Data => (Valid => False), Previous_Data => (Valid => False))); Self.API_Calls.Append (New_Item => Query_Data_Set' (new API.API_Class' (API.Create_Current_By_Coordinates (Coordinates => Geo_Coordinates' (Latitude => Types.Latitude'Value ("67.292"), Longitude => Types.Longitude'Value ("28.150")), Configuration => Self.Configuration.Values, Connection => Self.Connection)), Data => (Valid => False), Previous_Data => (Valid => False))); Self.API_Calls.Append (New_Item => Query_Data_Set' (new API.API_Class' (API.Create_Current_By_Group (Ids => (1 => City_Ids.India.Giddalur, 2 => City_Ids.India.Nandyal), Configuration => Self.Configuration.Values, Connection => Self.Connection)), Data => (Valid => False), Previous_Data => (Valid => False))); end Initialize; ----------------------------------------------------------------------------- -- Print ----------------------------------------------------------------------------- procedure Print (City_Name : in String) is begin Ada.Text_IO.Put (File => Standard_Output, Item => ", data for """ & City_Name & """"); end Print; ----------------------------------------------------------------------------- -- Print ----------------------------------------------------------------------------- procedure Print (H : in Types.Humidity) is begin Ada.Text_IO.Put (File => Standard_Output, Item => ", humidity: " & Image (Value => H)); end Print; ----------------------------------------------------------------------------- -- Print ----------------------------------------------------------------------------- procedure Print (P : in Types.Pressure) is ----------------------------------------------------------------------------- -- Scale ----------------------------------------------------------------------------- function Scale is new SI_Units.Metric.Scaling.Fixed_Scale (Item => Types.Pressure'Base); use all type SI_Units.Metric.Scaling.Prefixes; begin Ada.Text_IO.Put (File => Standard_Output, Item => ", pressure: " & Image (Value => Scale (Value => P, From_Prefix => Hecto))); end Print; ----------------------------------------------------------------------------- -- Print ----------------------------------------------------------------------------- procedure Print (T : in Types.Celsius) is begin Ada.Text_IO.Put (File => Standard_Output, Item => ", temperature: " & Image (Value => T)); end Print; ----------------------------------------------------------------------------- -- Print_Last_Update_On_Server ----------------------------------------------------------------------------- procedure Print_Last_Update_On_Server (Value : in Ada.Calendar.Time; Time_Zone : in Ada.Calendar.Time_Zones.Time_Offset) is begin Ada.Text_IO.Put (File => Standard_Output, Item => ", data updated at "); Print_Time (Value => Value, Time_Zone => Time_Zone); end Print_Last_Update_On_Server; ----------------------------------------------------------------------------- -- Print_Location ----------------------------------------------------------------------------- procedure Print_Location (Loc : in Geo_Coordinates) is begin Ada.Text_IO.Put (File => Standard_Output, Item => " (" & Degrees.Latitude.Image (L => Loc.Latitude) & No_Break_Space & Degrees.Longitude.Image (L => Loc.Longitude) & ")"); end Print_Location; ----------------------------------------------------------------------------- -- Print_Seconds_Since_Last_Query ----------------------------------------------------------------------------- procedure Print_Seconds_Since_Last_Query (Elapsed_Time : in Ada.Real_Time.Time_Span) is Time_String : constant String := Ada.Calendar.Formatting.Image (Elapsed_Time => Ada.Real_Time.To_Duration (Elapsed_Time), Include_Time_Fraction => True); begin Ada.Text_IO.Put (File => Standard_Output, Item => "Last query: "); Ada.Text_IO.Put (File => Standard_Output, Item => Time_String (Time_String'Last - 4 .. Time_String'Last)); Ada.Text_IO.Put (File => Standard_Output, Item => " seconds ago"); end Print_Seconds_Since_Last_Query; ----------------------------------------------------------------------------- -- Print_Time ----------------------------------------------------------------------------- procedure Print_Time (Value : in Ada.Calendar.Time; Time_Zone : in Ada.Calendar.Time_Zones.Time_Offset) is begin Ada.Text_IO.Put (Ada.Calendar.Formatting.Image (Date => Value) & " (" & Ada.Calendar.Formatting.Image (Date => Value, Time_Zone => Time_Zone) & " local time)"); end Print_Time; ----------------------------------------------------------------------------- -- Print_Timestamp ----------------------------------------------------------------------------- procedure Print_Timestamp (Value : in Ada.Real_Time.Time_Span) is begin Ada.Text_IO.Put (File => Standard_Output, Item => "["); declare use type Ada.Real_Time.Time_Span; One_Day : constant Ada.Real_Time.Time_Span := Ada.Real_Time.Seconds (24 * 60 * 60); Temp_Value : Ada.Real_Time.Time_Span := Value; begin -- This is a bug in GNAT, according to ARM 9.6.1/85f Image should be -- able to support values up to 100 hours. The GNAT runtime chokes on -- a call to Split which only supports Day_Duration, so it raises -- Constraint_Error if the # of seconds exceeds 86400. while Temp_Value >= One_Day loop Temp_Value := Temp_Value - One_Day; end loop; Ada.Text_IO.Put (File => Standard_Output, Item => Ada.Calendar.Formatting.Image (Elapsed_Time => Ada.Real_Time.To_Duration (Temp_Value), Include_Time_Fraction => True)); end; Ada.Text_IO.Put (File => Standard_Output, Item => "] "); end Print_Timestamp; ----------------------------------------------------------------------------- -- Shutdown ----------------------------------------------------------------------------- overriding procedure Shutdown (Self : in out T) is begin My_Debug.all.Trace (Message => "Shutdown"); Client.Destroy (Self.Connection); Standard_Application.T (Self).Shutdown; end Shutdown; ----------------------------------------------------------------------------- -- Update_And_Report ----------------------------------------------------------------------------- procedure Update_And_Report (Self : in T; Q : in out Query_Data_Set) is use type Ada.Real_Time.Time; begin My_Debug.all.Trace (Message => "Update_And_Report"); Q.Previous_Data := Q.Data; Q.Query.all.Perform_Query (Current => Q.Data); if Q.Data.Valid and then Q.Data /= Q.Previous_Data then declare Now : constant Ada.Real_Time.Time := Ada.Real_Time.Clock; TS_Global : constant Ada.Real_Time.Time_Span := Now - Self.Epoch; TS_Query : constant Ada.Real_Time.Time_Span := Now - Q.Query.all.Last_Query; begin for I in 1 .. Natural (Q.Data.Cities.Length) loop declare City : constant City_Data := Q.Data.Cities.Element (Index => I); begin Print_Timestamp (Value => TS_Global); Print_Seconds_Since_Last_Query (Elapsed_Time => TS_Query); Print (City_Name => Ada.Strings.Unbounded.To_String (City.Name)); Print_Location (Loc => City.Location); Print (T => Types.To_Celsius (City.Temperature)); Print (H => City.Humidity); Print (P => City.Pressure); Ada.Text_IO.Put (File => Standard_Output, Item => ", sunrise at "); Print_Time (Value => City.Sunrise, Time_Zone => City.Time_Zone); Ada.Text_IO.Put (File => Standard_Output, Item => ", sunset at "); Print_Time (Value => City.Sunset, Time_Zone => City.Time_Zone); Print_Last_Update_On_Server (Value => City.Last_Update, Time_Zone => City.Time_Zone); Ada.Text_IO.Put_Line (File => Standard_Output, Item => "."); end; end loop; end; end if; end Update_And_Report; ----------------------------------------------------------------------------- -- Work ----------------------------------------------------------------------------- overriding procedure Work (Self : in out T) is begin My_Debug.all.Trace (Message => "Work"); Queries_Loop : for Call of Self.API_Calls loop Self.Update_And_Report (Q => Call); end loop Queries_Loop; end Work; end Open_Weather_Map.Application;
Fabien-Chouteau/Ada_Drivers_Library
Ada
2,649
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2019, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- This package provides procedures to draw symbols on the MicroBit 5x5 LED -- display. package MicroBit.Display.Symbols is procedure Left_Arrow; procedure Right_Arrow; procedure Up_Arrow; procedure Down_Arrow; procedure Smile; end MicroBit.Display.Symbols;
faelys/natools
Ada
2,891
ads
------------------------------------------------------------------------------ -- Copyright (c) 2011-2013, Natacha Porté -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Natools.Chunked_Strings.Tests is the test suite for Chunked_String. -- -- -- -- It also provides private helper functions used in more specialized test -- -- packages. -- ------------------------------------------------------------------------------ with Natools.Tests; generic package Natools.Chunked_Strings.Tests is pragma Preelaborate (Tests); procedure All_Blackbox_Tests (Report : in out Natools.Tests.Reporter'Class); procedure All_Greybox_Tests (Report : in out Natools.Tests.Reporter'Class); procedure All_Whitebox_Tests (Report : in out Natools.Tests.Reporter'Class); procedure All_Tests (Report : in out Natools.Tests.Reporter'Class); private procedure Dump (Report : in out Natools.Tests.Reporter'Class; Dumped : in Chunked_String); procedure Test (Report : in out Natools.Tests.Reporter'Class; Test_Name : in String; Computed : in Chunked_String; Reference : in String); procedure Test (Report : in out Natools.Tests.Reporter'Class; Test_Name : in String; Computed : in Chunked_String; Reference : in Chunked_String); procedure Test (Report : in out Natools.Tests.Reporter'Class; Test_Name : in String; Computed : in Natural; Reference : in Natural); end Natools.Chunked_Strings.Tests;
reznikmm/matreshka
Ada
8,188
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ package body AMF.Internals.Tables.DC_Metamodel is -------------- -- MM_DC_DC -- -------------- function MM_DC_DC return AMF.Internals.CMOF_Element is begin return Base + 1; end MM_DC_DC; -------------------------- -- MC_DC_Alignment_Kind -- -------------------------- function MC_DC_Alignment_Kind return AMF.Internals.CMOF_Element is begin return Base + 50; end MC_DC_Alignment_Kind; ------------------- -- MC_DC_Boolean -- ------------------- function MC_DC_Boolean return AMF.Internals.CMOF_Element is begin return Base + 3; end MC_DC_Boolean; ------------------ -- MC_DC_Bounds -- ------------------ function MC_DC_Bounds return AMF.Internals.CMOF_Element is begin return Base + 37; end MC_DC_Bounds; ----------------- -- MC_DC_Color -- ----------------- function MC_DC_Color return AMF.Internals.CMOF_Element is begin return Base + 11; end MC_DC_Color; --------------------- -- MC_DC_Dimension -- --------------------- function MC_DC_Dimension return AMF.Internals.CMOF_Element is begin return Base + 28; end MC_DC_Dimension; ------------------- -- MC_DC_Integer -- ------------------- function MC_DC_Integer return AMF.Internals.CMOF_Element is begin return Base + 5; end MC_DC_Integer; ----------------------- -- MC_DC_Known_Color -- ----------------------- function MC_DC_Known_Color return AMF.Internals.CMOF_Element is begin return Base + 58; end MC_DC_Known_Color; ----------------- -- MC_DC_Point -- ----------------- function MC_DC_Point return AMF.Internals.CMOF_Element is begin return Base + 22; end MC_DC_Point; ---------------- -- MC_DC_Real -- ---------------- function MC_DC_Real return AMF.Internals.CMOF_Element is begin return Base + 7; end MC_DC_Real; ------------------ -- MC_DC_String -- ------------------ function MC_DC_String return AMF.Internals.CMOF_Element is begin return Base + 9; end MC_DC_String; ------------------------- -- MP_DC_Bounds_Height -- ------------------------- function MP_DC_Bounds_Height return AMF.Internals.CMOF_Element is begin return Base + 48; end MP_DC_Bounds_Height; ------------------------ -- MP_DC_Bounds_Width -- ------------------------ function MP_DC_Bounds_Width return AMF.Internals.CMOF_Element is begin return Base + 46; end MP_DC_Bounds_Width; -------------------- -- MP_DC_Bounds_X -- -------------------- function MP_DC_Bounds_X return AMF.Internals.CMOF_Element is begin return Base + 42; end MP_DC_Bounds_X; -------------------- -- MP_DC_Bounds_Y -- -------------------- function MP_DC_Bounds_Y return AMF.Internals.CMOF_Element is begin return Base + 44; end MP_DC_Bounds_Y; ---------------------- -- MP_DC_Color_Blue -- ---------------------- function MP_DC_Color_Blue return AMF.Internals.CMOF_Element is begin return Base + 20; end MP_DC_Color_Blue; ----------------------- -- MP_DC_Color_Green -- ----------------------- function MP_DC_Color_Green return AMF.Internals.CMOF_Element is begin return Base + 18; end MP_DC_Color_Green; --------------------- -- MP_DC_Color_Red -- --------------------- function MP_DC_Color_Red return AMF.Internals.CMOF_Element is begin return Base + 16; end MP_DC_Color_Red; ---------------------------- -- MP_DC_Dimension_Height -- ---------------------------- function MP_DC_Dimension_Height return AMF.Internals.CMOF_Element is begin return Base + 35; end MP_DC_Dimension_Height; --------------------------- -- MP_DC_Dimension_Width -- --------------------------- function MP_DC_Dimension_Width return AMF.Internals.CMOF_Element is begin return Base + 33; end MP_DC_Dimension_Width; ------------------- -- MP_DC_Point_X -- ------------------- function MP_DC_Point_X return AMF.Internals.CMOF_Element is begin return Base + 24; end MP_DC_Point_X; ------------------- -- MP_DC_Point_Y -- ------------------- function MP_DC_Point_Y return AMF.Internals.CMOF_Element is begin return Base + 26; end MP_DC_Point_Y; ----------- -- MB_DC -- ----------- function MB_DC return AMF.Internals.AMF_Element is begin return Base; end MB_DC; ----------- -- MB_DC -- ----------- function ML_DC return AMF.Internals.AMF_Element is begin return Base + 98; end ML_DC; end AMF.Internals.Tables.DC_Metamodel;
reznikmm/matreshka
Ada
7,450
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. ------------------------------------------------------------------------------ -- An activity partition is a kind of activity group for identifying actions -- that have some characteristic in common. ------------------------------------------------------------------------------ limited with AMF.UML.Activity_Edges.Collections; with AMF.UML.Activity_Groups; limited with AMF.UML.Activity_Nodes.Collections; limited with AMF.UML.Activity_Partitions.Collections; limited with AMF.UML.Elements; package AMF.UML.Activity_Partitions is pragma Preelaborate; type UML_Activity_Partition is limited interface and AMF.UML.Activity_Groups.UML_Activity_Group; type UML_Activity_Partition_Access is access all UML_Activity_Partition'Class; for UML_Activity_Partition_Access'Storage_Size use 0; not overriding function Get_Edge (Self : not null access constant UML_Activity_Partition) return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge is abstract; -- Getter of ActivityPartition::edge. -- -- Edges immediately contained in the group. not overriding function Get_Is_Dimension (Self : not null access constant UML_Activity_Partition) return Boolean is abstract; -- Getter of ActivityPartition::isDimension. -- -- Tells whether the partition groups other partitions along a dimension. not overriding procedure Set_Is_Dimension (Self : not null access UML_Activity_Partition; To : Boolean) is abstract; -- Setter of ActivityPartition::isDimension. -- -- Tells whether the partition groups other partitions along a dimension. not overriding function Get_Is_External (Self : not null access constant UML_Activity_Partition) return Boolean is abstract; -- Getter of ActivityPartition::isExternal. -- -- Tells whether the partition represents an entity to which the -- partitioning structure does not apply. not overriding procedure Set_Is_External (Self : not null access UML_Activity_Partition; To : Boolean) is abstract; -- Setter of ActivityPartition::isExternal. -- -- Tells whether the partition represents an entity to which the -- partitioning structure does not apply. not overriding function Get_Node (Self : not null access constant UML_Activity_Partition) return AMF.UML.Activity_Nodes.Collections.Set_Of_UML_Activity_Node is abstract; -- Getter of ActivityPartition::node. -- -- Nodes immediately contained in the group. not overriding function Get_Represents (Self : not null access constant UML_Activity_Partition) return AMF.UML.Elements.UML_Element_Access is abstract; -- Getter of ActivityPartition::represents. -- -- An element constraining behaviors invoked by nodes in the partition. not overriding procedure Set_Represents (Self : not null access UML_Activity_Partition; To : AMF.UML.Elements.UML_Element_Access) is abstract; -- Setter of ActivityPartition::represents. -- -- An element constraining behaviors invoked by nodes in the partition. not overriding function Get_Subpartition (Self : not null access constant UML_Activity_Partition) return AMF.UML.Activity_Partitions.Collections.Set_Of_UML_Activity_Partition is abstract; -- Getter of ActivityPartition::subpartition. -- -- Partitions immediately contained in the partition. not overriding function Get_Super_Partition (Self : not null access constant UML_Activity_Partition) return AMF.UML.Activity_Partitions.UML_Activity_Partition_Access is abstract; -- Getter of ActivityPartition::superPartition. -- -- Partition immediately containing the partition. not overriding procedure Set_Super_Partition (Self : not null access UML_Activity_Partition; To : AMF.UML.Activity_Partitions.UML_Activity_Partition_Access) is abstract; -- Setter of ActivityPartition::superPartition. -- -- Partition immediately containing the partition. end AMF.UML.Activity_Partitions;
johnperry-math/hac
Ada
57,015
adb
with HAC_Sys.Compiler.PCode_Emit, HAC_Sys.Parser.Calls, HAC_Sys.Parser.Enter_Def, HAC_Sys.Parser.Expressions, HAC_Sys.Parser.Helpers, HAC_Sys.Parser.Ranges, HAC_Sys.Parser.Standard_Procedures, HAC_Sys.Parser.Tasking, HAC_Sys.Parser.Type_Def, HAC_Sys.Scanner, HAC_Sys.UErrors; package body HAC_Sys.Parser is ------------------------------------------------------------------ ------------------------------------------------------------Block- procedure Block ( CD : in out Compiler_Data; FSys : Defs.Symset; Is_a_function : Boolean; -- RETURN [Value] statement expected Is_a_block_statement : Boolean; -- 5.6 Block Statements Initial_Level : PCode.Nesting_level; Prt : Integer; Block_ID : Defs.Alfa; -- Name of this block (if any) Block_ID_with_case : Defs.Alfa ) is use Calls, Compiler, Defs, Enter_Def, Expressions, Helpers, PCode, Compiler.PCode_Emit, Type_Def, UErrors; -- Level : Nesting_level := Initial_Level; procedure InSymbol is begin Scanner.InSymbol (CD); end InSymbol; Dx : Integer; -- data allocation Index MaxDX : Integer; PRB : Integer; -- B-Index of this procedure ICode : Integer; -- Size of initialization ObjCode generated ------------------------------------------------------------------ --------------------------------------------Formal_Parameter_List- procedure Formal_Parameter_List is Sz, X, T0 : Integer; ValParam : Boolean; xTP : Exact_Typ := Type_Undefined; begin InSymbol; -- Consume '(' symbol. Sz := 0; Test (CD, IDent_Set, FSys + RParent, err_identifier_missing, stop_on_error => True); -- while CD.Sy = IDent loop T0 := CD.Id_Count; Enter_Variables (CD, Level); -- if CD.Sy = Colon then -- The ':' in "function F (x, y : in Real) return Real;" InSymbol; if CD.Sy = IN_Symbol then InSymbol; end if; if Is_a_function then -- If I am a function, no InOut parms allowed ValParam := True; elsif CD.Sy /= OUT_Symbol then ValParam := True; else InSymbol; ValParam := False; end if; if CD.Sy /= IDent then Error (CD, err_identifier_missing); else X := Locate_Identifier (CD, CD.Id, Level); InSymbol; if X /= No_Id then if CD.IdTab (X).Obj = TypeMark then xTP := CD.IdTab (X).xTyp; if ValParam then Sz := CD.IdTab (X).Adr_or_Sz; else Sz := 1; end if; else Error (CD, err_missing_a_type_identifier, stop => True); end if; end if; -- X /= No_Id end if; Test (CD, Comma_IDent_RParent_Semicolon, FSys, err_semicolon_missing, stop_on_error => True); while T0 < CD.Id_Count loop T0 := T0 + 1; declare r : IdTabEntry renames CD.IdTab (T0); begin r.xTyp := xTP; r.Normal := ValParam; r.Read_only := ValParam; r.Adr_or_Sz := Dx; r.LEV := Level; Dx := Dx + Sz; end; end loop; -- while T0 < CD.Id_Count else Error (CD, err_colon_missing, stop => True); end if; if CD.Sy /= RParent then Need (CD, Semicolon, err_semicolon_missing, Forgive => Comma); Ignore_Extra_Semicolons (CD); Test (CD, IDent_Set, FSys + RParent, err_incorrectly_used_symbol); end if; end loop; -- while Sy = IDent -- if CD.Sy = RParent then InSymbol; Test (CD, After_Subprogram_Parameters, FSys, err_incorrectly_used_symbol); else Error (CD, err_closing_parenthesis_missing); end if; end Formal_Parameter_List; ------------------------------------------------------------------ -------------------------------------------------------Assignment- procedure Assignment (I : Integer; Check_read_only : Boolean) is X, Y : Exact_Typ; F : Opcode; procedure Issue_Type_Mismatch_Error is begin Type_Mismatch (CD, err_types_of_assignment_must_match, Found => Y, Expected => X); end Issue_Type_Mismatch_Error; begin pragma Assert (CD.IdTab (I).Obj = Variable); X := CD.IdTab (I).xTyp; if CD.IdTab (I).Normal then F := k_Push_Address; else F := k_Push_Value; end if; Emit_2 (CD, F, CD.IdTab (I).LEV, Operand_2_Type (CD.IdTab (I).Adr_or_Sz)); if Selector_Symbol_Loose (CD.Sy) then -- '.' or '(' or (wrongly) '[' Selector (CD, Level, Becomes_EQL + FSys, X); end if; if CD.Sy = Becomes then InSymbol; elsif CD.Sy = EQL then -- Common mistake by BASIC or C programmers. Error (CD, err_EQUALS_instead_of_BECOMES); InSymbol; else Error (CD, err_BECOMES_missing); end if; if Check_read_only and then CD.IdTab (I).Read_only then Error (CD, err_cannot_modify_constant_or_in_parameter); end if; Expression (CD, Level, Semicolon_Set, Y); -- if X.TYP = Y.TYP and X.TYP /= NOTYP then if X.TYP in Standard_Typ then Emit (CD, k_Store); elsif X.Ref /= Y.Ref then Issue_Type_Mismatch_Error; -- E.g. different arrays, enums, ... else case X.TYP is when Arrays => Emit_1 (CD, k_Copy_Block, Operand_2_Type (CD.Arrays_Table (X.Ref).Array_Size)); when Records => Emit_1 (CD, k_Copy_Block, Operand_2_Type (CD.Blocks_Table (X.Ref).VSize)); when Enums => -- Behaves like a "Standard_Typ". -- We have checked that X.Ref = Y.Ref (same actual type). Emit (CD, k_Store); when others => raise Internal_error with "Assignment: X := Y on unsupported Typ ?"; end case; end if; elsif X.TYP = Floats and Y.TYP = Ints then Forbid_Type_Coercion (CD, Found => Y, Expected => X); Emit_1 (CD, k_Integer_to_Float, 0); -- Ghost of SmallAda. Emit's Emit (CD, k_Store); -- not needed: compilation error. elsif X.TYP = Durations and Y.TYP = Floats then -- Duration hack (see Delay_Statement for full explanation). Emit_Std_Funct (CD, SF_Float_to_Duration); Emit (CD, k_Store); elsif Is_Char_Array (CD, X) and Y.TYP = String_Literals then Emit_1 (CD, k_String_Literal_Assignment, Operand_2_Type (CD.Arrays_Table (X.Ref).Array_Size)); elsif X.TYP = VStrings and then (Y.TYP = String_Literals or else Is_Char_Array (CD, Y)) then Error (CD, err_string_to_vstring_assignment); elsif X.TYP = NOTYP then if CD.Err_Count = 0 then raise Internal_error with "Assignment: assigned variable (X) is typeless"; else null; -- All right, there were already enough compilation error messages... end if; elsif Y.TYP = NOTYP then if CD.Err_Count = 0 then raise Internal_error with "Assignment: assigned value (Y) is typeless"; else null; -- All right, there were already enough compilation error messages... end if; else Issue_Type_Mismatch_Error; -- NB: We are in the X.TYP /= Y.TYP case. end if; end Assignment; ------------------------------------------------------------------ --------------------------------------------------Var_Declaration- procedure Var_Declaration is -- This procedure processes both Variable and Constant declarations. procedure Single_Var_Declaration is procedure Initialized_Constant_or_Variable ( explicit : Boolean; Id_From, Id_To : Integer ) is LC0 : Integer := CD.LC; LC1 : Integer; begin -- Create constant or variable initialization ObjCode if explicit then -- The new variables Id's are in the range Id_From .. Id_To. -- We do an assignment to the last one. -- Example: for "a, b, c : Real := F (x);" we do "c := F (x)". Assignment (Id_To, Check_read_only => False); -- Id_To has been assigned; we copy the value of Id_To to Id_From .. Id_To - 1. -- In the example: "a := c" and "b := c". for Var_Id in Id_From .. Id_To - 1 loop Emit_2 (CD, k_Push_Address, Operand_1_Type (CD.IdTab (Var_Id).LEV), Operand_2_Type (CD.IdTab (Var_Id).Adr_or_Sz)); Emit_2 (CD, k_Push_Value, Operand_1_Type (CD.IdTab (Id_To).LEV), Operand_2_Type (CD.IdTab (Id_To).Adr_or_Sz)); Emit (CD, k_Store); -- !! O-o... can't work for composite types (arrays or records) !! end loop; else -- Implicit initialization (for instance, VString's and File_Type's). for Var_Id in Id_From .. Id_To loop declare Var : IdTabEntry renames CD.IdTab (Var_Id); begin if Auto_Init_Typ (Var.xTyp.TYP) then Emit_2 (CD, k_Push_Address, Operand_1_Type (Var.LEV), Operand_2_Type (Var.Adr_or_Sz)); Emit_1 (CD, k_Variable_Initialization, Typen'Pos (Var.xTyp.TYP)); end if; -- !! TBD: Must handle composite types (arrays or records) too... end; end loop; end if; -- LC1 := CD.LC; -- Reset ObjCode pointer as if ObjCode had not been generated -- !! Why is the whole double moving needed ?... -- The only possible usefulness if to preserve CD.LC for some reason. CD.LC := LC0; -- Copy ObjCode to end of ObjCode table in reverse order ICode := ICode + (LC1 - LC0); -- Size of initialization ObjCode if LC0 + ICode >= CD.CMax - ICode then Fatal (Object_Code); -- Collision during the copy (loop below). Garbage guaranteed. end if; while LC0 < LC1 loop CD.ObjCode (CD.CMax) := CD.ObjCode (LC0); CD.CMax := CD.CMax - 1; LC0 := LC0 + 1; end loop; end Initialized_Constant_or_Variable; -- T0, T1, Sz, T0i : Integer; xTyp : Exact_Typ; is_constant, is_typed, is_untyped_constant : Boolean; C : Constant_Rec; I_dummy : Integer; Dummy_First : HAC_Integer; Dummy_Last : HAC_Integer; begin T0 := CD.Id_Count; Enter_Variables (CD, Level); Need (CD, Colon, err_colon_missing); -- ':' in "x, y : Integer;" T1 := CD.Id_Count; -- if CD.Sy = IDent then I_dummy := Locate_Identifier (CD, CD.Id, Level, stop_on_error => True); end if; Test (CD, Type_Begin_Symbol + CONSTANT_Symbol, Semicolon_Set, err_incorrectly_used_symbol); -- is_constant := False; if CD.Sy = CONSTANT_Symbol then -- Consume "constant" in "x : constant ...;" is_constant := True; InSymbol; end if; -- is_typed := False; if Type_Begin_Symbol (CD.Sy) then -- Here, a type name or an anonymous type definition is_typed := True; Type_Definition ( CD, Level, Becomes_Comma_IDent_Semicolon + FSys, xTyp, Sz, Dummy_First, Dummy_Last ); end if; Test (CD, Becomes_EQL_Semicolon, Empty_Symset, err_incorrectly_used_symbol); -- if CD.Sy = EQL then -- Common mistake by BASIC or C programmers. Error (CD, err_EQUALS_instead_of_BECOMES); CD.Sy := Becomes; end if; -- is_untyped_constant := is_constant and not is_typed; -- if is_untyped_constant then -- Numeric constant: we parse the number here ("k : constant := 123.0"). if CD.Sy = Becomes then InSymbol; Number_Declaration_or_Enum_Item_or_Literal_Char (CD, Level, Comma_IDent_Semicolon + FSys, C); else Error (CD, err_BECOMES_missing); end if; end if; -- T0i := T0; if is_constant or is_typed then -- All correct cases: untyped variables were caught. -- Update identifier table while T0 < T1 loop T0 := T0 + 1; declare r : IdTabEntry renames CD.IdTab (T0); begin r.Read_only := is_constant; if is_untyped_constant then r.Obj := Declared_Number_or_Enum_Item; -- r was initially a Variable. r.xTyp := C.TP; case C.TP.TYP is when Floats => Enter_or_find_Float (CD, C.R, r.Adr_or_Sz); when Ints => r.Adr_or_Sz := Integer (C.I); when others => Error (CD, err_numeric_constant_expected); -- "boo : constant := True;" or "x: constant := 'a';" are wrong in Ada. r.Adr_or_Sz := Integer (C.I); end case; else -- A variable or a typed constant r.xTyp := xTyp; r.Adr_or_Sz := Dx; Dx := Dx + Sz; end if; end; end loop; -- While T0 < T1 end if; -- if CD.Sy = EQL and not is_untyped_constant then Error (CD, err_EQUALS_instead_of_BECOMES); CD.Sy := Becomes; end if; if is_constant and is_typed then -- For typed constants, the ":=" is required and consumed with the Assignment below. Test (CD, Becomes_Set, Empty_Symset, err_BECOMES_missing); end if; -- if not is_untyped_constant then Initialized_Constant_or_Variable ( explicit => CD.Sy = Becomes, Id_From => T0i + 1, Id_To => T1 ); end if; Test_Semicolon_in_Declaration (CD, FSys); end Single_Var_Declaration; begin while CD.Sy = IDent loop Single_Var_Declaration; end loop; end Var_Declaration; ------------------------------------------------------------------ --------------------------------------------Proc_Func_Declaration- procedure Proc_Func_Declaration is IsFun : constant Boolean := CD.Sy = FUNCTION_Symbol; begin InSymbol; if CD.Sy /= IDent then Error (CD, err_identifier_missing); CD.Id := Empty_Alfa; end if; declare Id_subprog_with_case : constant Alfa := CD.Id_with_case; begin if IsFun then Enter (CD, Level, CD.Id, CD.Id_with_case, Funktion); else Enter (CD, Level, CD.Id, CD.Id_with_case, Prozedure); end if; InSymbol; Block (CD, FSys, IsFun, False, Level + 1, CD.Id_Count, CD.IdTab (CD.Id_Count).Name, Id_subprog_with_case); end; if IsFun then Emit_1 (CD, k_Exit_Function, End_Function_without_Return); else Emit_1 (CD, k_Exit_Call, Normal_Procedure_Call); end if; end Proc_Func_Declaration; ------------------------------------------------------------------ --------------------------------------------------------Statement-- procedure Statement (FSys_St : Symset) is procedure Multi_Statement (Sentinal : Symset) is -- Hathorn nxtSym : Symset; begin if Sentinal (CD.Sy) then -- GdM 15-Aug-2014: there should be at least one statement. Error (CD, err_statement_expected); end if; nxtSym := Sentinal + Statement_Begin_Symbol; loop Statement (nxtSym); -- MRC,was: UNTIL (Sy IN Sentinal); exit when Sentinal (CD.Sy) or CD.Err_Count > 0; end loop; end Multi_Statement; procedure Accept_Statement is -- Hathorn procedure Accept_Call is begin -- !! Check to make sure parameters match with Entry Statement if CD.Sy = Semicolon then return; end if; if CD.Sy = LParent then -- <--- temporary while not (CD.Sy = DO_Symbol or CD.Sy = RParent) loop InSymbol; end loop; -- !! should check no. and end if; -- Types of parms. if CD.Sy = RParent then InSymbol; end if; end Accept_Call; I_Entry : Integer; begin -- Accept_Statement InSymbol; I_Entry := Locate_Identifier (CD, CD.Id, Level); if CD.IdTab (I_Entry).Obj /= aEntry then Error (CD, err_use_Small_Sp); end if; InSymbol; Accept_Call; Emit_1 (CD, k_Accept_Rendezvous, Operand_2_Type (I_Entry)); if CD.Sy = DO_Symbol then if Level = Nesting_Level_Max then Fatal (LEVELS); -- Exception is raised there. end if; Level := Level + 1; CD.Display (Level) := CD.IdTab (I_Entry).Block_Ref; InSymbol; Multi_Statement (END_Set); Test_END_Symbol (CD); if CD.Sy = IDent then if CD.Id /= CD.IdTab (I_Entry).Name then Error (CD, err_incorrect_block_name); end if; InSymbol; end if; Level := Level - 1; end if; Emit_1 (CD, k_End_Rendezvous, Operand_2_Type (I_Entry)); end Accept_Statement; procedure Exit_Statement is -- Generate an absolute branch statement with a dummy end loop address X : Exact_Typ; begin pragma Assert (CD.Sy = EXIT_Symbol); InSymbol; -- Consume EXIT symbol. if CD.Sy = WHEN_Symbol then -- Conditional Exit InSymbol; Boolean_Expression (CD, Level, Semicolon_Set, X); Emit_1 (CD, k_Conditional_Jump, Operand_2_Type (CD.LC + 2)); -- Conditional jump around Exit end if; Emit_1 (CD, k_Jump, dummy_address_loop); -- Unconditional jump with dummy address to be patched end Exit_Statement; procedure IF_Statement is X : Exact_Typ; LC0, LC1 : Integer; begin InSymbol; Boolean_Expression (CD, Level, FSys_St + DO_THEN, X); LC1 := CD.LC; Emit (CD, k_Conditional_Jump); Need (CD, THEN_Symbol, err_THEN_missing, Forgive => DO_Symbol); Multi_Statement (ELSE_ELSIF_END); LC0 := CD.LC; -- while CD.Sy = ELSIF_Symbol loop -- Added Hathorn InSymbol; Emit_1 (CD, k_Jump, dummy_address_if); -- Unconditional jump with dummy address to be patched CD.ObjCode (LC1).Y := Operand_2_Type (CD.LC); -- Patch the previous conditional jump Boolean_Expression (CD, Level, FSys_St + DO_THEN, X); LC1 := CD.LC; Emit (CD, k_Conditional_Jump); Need (CD, THEN_Symbol, err_THEN_missing, Forgive => DO_Symbol); Multi_Statement (ELSE_ELSIF_END); -- Statements after "ELSIF .. THEN". end loop; -- if CD.Sy = ELSE_Symbol then InSymbol; Emit_1 (CD, k_Jump, dummy_address_if); -- Jump to "END IF" - dummy address to be patched. CD.ObjCode (LC1).Y := Operand_2_Type (CD.LC); Multi_Statement (END_Set); -- Statements after "ELSE". else CD.ObjCode (LC1).Y := Operand_2_Type (CD.LC); end if; Need (CD, END_Symbol, err_END_missing); -- END (IF) Need (CD, IF_Symbol, err_missing_closing_IF); -- (END) IF -- Go back and patch the dummy addresses in unconditional jumps Patch_Addresses (CD.ObjCode (LC0 .. CD.LC), dummy_address_if); end IF_Statement; procedure LOOP_Statement (FCT_Loop_End : Opcode; B : Integer) is -- Hathorn LC0 : constant Integer := CD.LC; begin if CD.Sy = LOOP_Symbol then InSymbol; else Skip (CD, Statement_Begin_Symbol, err_missing_closing_IF); end if; Multi_Statement (END_Set); Emit_1 (CD, FCT_Loop_End, Operand_2_Type (B)); Need (CD, END_Symbol, err_END_missing); -- END (LOOP) Need (CD, LOOP_Symbol, err_closing_LOOP_missing); -- (END) LOOP -- Go back and patch the dummy addresses generated by Exit statements. Patch_Addresses (CD.ObjCode (LC0 .. CD.LC), dummy_address_loop); end LOOP_Statement; procedure RETURN_Statement is -- Hathorn -- Generate a procedure or function return Statement, calculate return value if req'D. X, Y : Exact_Typ; F : Opcode; Block_Idx : Integer; procedure Issue_Type_Mismatch_Error is begin Type_Mismatch (CD, err_type_of_return_statement_doesnt_match, Found => Y, Expected => X); end Issue_Type_Mismatch_Error; begin if Block_ID = CD.Main_Program_ID then Error (CD, err_illegal_return_statement_from_main); -- !! but... this is legal in Ada !! end if; Block_Idx := Locate_Identifier (CD, Block_ID, Level); InSymbol; if CD.Sy = Semicolon then if Is_a_function then Error (CD, err_functions_must_return_a_value); end if; else if not Is_a_function then Error (CD, err_procedures_cannot_return_a_value, stop => True); end if; -- Calculate return value (destination: X; expression: Y). if CD.IdTab (Block_Idx).Block_Ref = CD.Display (Level) then X := CD.IdTab (Block_Idx).xTyp; if CD.IdTab (Block_Idx).Normal then F := k_Push_Address; else F := k_Push_Value; end if; Emit_2 (CD, F, CD.IdTab (Block_Idx).LEV + 1, 0); -- Expression (CD, Level, Semicolon_Set, Y); if X.TYP = Y.TYP then if (X.TYP in Standard_Typ) or else (X.TYP = Enums and then X = Y) then Emit (CD, k_Store); elsif X.Ref /= Y.Ref then Issue_Type_Mismatch_Error; end if; elsif X.TYP = Floats and Y.TYP = Ints then Forbid_Type_Coercion (CD, Found => Y, Expected => X); Emit_1 (CD, k_Integer_to_Float, 0); Emit (CD, k_Store); elsif X.TYP /= NOTYP and Y.TYP /= NOTYP then Issue_Type_Mismatch_Error; end if; else Error (CD, err_illegal_return_statement_from_main); end if; -- !! but... this is legal in Ada !! end if; if Is_a_function then Emit_1 (CD, k_Exit_Function, Normal_Procedure_Call); else Emit_1 (CD, k_Exit_Call, Normal_Procedure_Call); end if; end RETURN_Statement; procedure Delay_Statement is -- Cramer. Generate a Task delay. Y : Exact_Typ; begin InSymbol; if CD.Sy = Semicolon then Skip (CD, Semicolon, err_missing_expression_for_delay); else Expression (CD, Level, Semicolon_Set, Y); if Y.TYP /= Floats and Y.TYP /= Durations then Error (CD, err_wrong_type_in_DELAY); end if; if Y.TYP = Floats then -- Duration hack: for expressions like 2.0 * 3600.0, we don't -- know in advance it's not a Duration. Check with a "full -- Ada" compiler the type conformity of the expression. Emit_Std_Funct (CD, SF_Float_to_Duration); end if; end if; Emit (CD, k_Delay); end Delay_Statement; procedure CASE_Statement is X : Exact_Typ; I, J, LC1 : Integer; CaseTab : array (1 .. Cases_Max) of CASE_Label_Value; ExitTab : array (1 .. Cases_Max) of Integer; others_flag : Boolean := False; procedure CASE_Label is Lab : Constant_Rec; K : Integer; use type HAC_Integer; begin Number_Declaration_or_Enum_Item_or_Literal_Char (CD, Level, FSys_St + Alt_Finger_THEN, Lab); if Lab.TP /= X then Type_Mismatch ( CD, err_case_label_not_same_type_as_case_clause, Found => Lab.TP, Expected => X ); elsif I = Cases_Max then Fatal (Case_Labels); -- Exception is raised there. else I := I + 1; CaseTab (I) := (Val => Lab.I, LC => CD.LC, Is_others => False); K := 0; loop K := K + 1; exit when CaseTab (K).Val = Lab.I; end loop; if K < I then Error (CD, err_duplicate_case_choice_value); end if; end if; end CASE_Label; procedure One_CASE is begin pragma Assert (CD.Sy = WHEN_Symbol); -- One_Case called only on WHEN_Symbol. InSymbol; if Constant_Definition_Begin_Symbol (CD.Sy) then if others_flag then -- Normal choice list *atfer* the "others" choice. Error (CD, err_case_others_alone_last); end if; CASE_Label; while CD.Sy = Alt loop InSymbol; -- Consume '|' symbol. if CD.Sy = OTHERS_Symbol then -- "others" mixed with normal choices. Error (CD, err_case_others_alone_last); else CASE_Label; end if; end loop; elsif CD.Sy = OTHERS_Symbol then -- Hathorn if others_flag then -- Duplicate "others". Error (CD, err_case_others_alone_last); end if; others_flag := True; if I = Cases_Max then Fatal (Case_Labels); -- Exception is raised there. end if; I := I + 1; CaseTab (I) := (Val => 0, LC => CD.LC, Is_others => True); InSymbol; end if; if CD.Sy = THEN_Symbol then -- Mistake happens when converting IF statements to CASE. Error (CD, err_THEN_instead_of_Arrow, stop => True); InSymbol; else Need (CD, Finger, err_FINGER_missing); end if; Multi_Statement (END_WHEN); J := J + 1; ExitTab (J) := CD.LC; Emit (CD, k_Jump); end One_CASE; begin -- CASE_Statement InSymbol; I := 0; J := 0; Expression (CD, Level, FSys_St + Colon_Comma_IS_OF, X); if not Discrete_Typ (X.TYP) then Error (CD, err_bad_type_for_a_case_statement); end if; LC1 := CD.LC; Emit (CD, k_CASE_Switch); if CD.Sy = IS_Symbol then -- Was OF_Symbol in SmallAda! I.e. "case x OF when 1 => ..." InSymbol; elsif CD.Sy = OF_Symbol then Error (CD, err_OF_instead_of_IS); -- Common mistake by Pascal programmers InSymbol; else Error (CD, err_IS_missing); end if; if CD.Sy /= WHEN_Symbol then Error (CD, err_WHEN_missing, stop => True); end if; loop -- All cases are parsed here. One_CASE; exit when CD.Sy /= WHEN_Symbol; end loop; CD.ObjCode (LC1).Y := Operand_2_Type (CD.LC); -- Set correct address for k_CASE_Switch above. -- This is the address of the following bunch of -- (k_CASE_Choice_Data, k_CASE_Match_Jump) pairs. for K in 1 .. I loop if CaseTab (K).Is_others then Emit_2 (CD, k_CASE_Choice_Data, Case_when_others, 0); else Emit_2 (CD, k_CASE_Choice_Data, Case_when_something, CaseTab (K).Val); end if; Emit_1 (CD, k_CASE_Match_Jump, Operand_2_Type (CaseTab (K).LC)); end loop; -- This is for having the interpreter exiting the k_CASE_Choice_Data loop. Emit (CD, k_CASE_No_Choice_Found); -- for K in 1 .. J loop CD.ObjCode (ExitTab (K)).Y := Operand_2_Type (CD.LC); -- Patch k_Jump addresses to after "END CASE;". end loop; Need (CD, END_Symbol, err_END_missing); -- END (CASE) Need (CD, CASE_Symbol, err_missing_closing_CASE); -- (END) CASE end CASE_Statement; procedure WHILE_Statement is -- RM 5.5 (8) X : Exact_Typ; LC_Cond_Eval, LC_Cond_Jump : Integer; begin InSymbol; -- Consume WHILE symbol. LC_Cond_Eval := CD.LC; Boolean_Expression (CD, Level, FSys_St + DO_LOOP, X); LC_Cond_Jump := CD.LC; Emit (CD, k_Conditional_Jump); LOOP_Statement (k_Jump, LC_Cond_Eval); CD.ObjCode (LC_Cond_Jump).Y := Operand_2_Type (CD.LC); end WHILE_Statement; procedure FOR_Statement is -- RM 5.5 (9) FOR_Begin : Opcode; -- Forward or Reverse LC_FOR_Begin, Previous_Last : Integer; begin -- -- Pushed on the stack: -- - address of the loop parameter (a temporary iterator variable) -- - lower bound value -- - upper bound value -- InSymbol; -- Consume FOR symbol. if CD.Sy = IDent then if CD.Id_Count = Id_Table_Max then Fatal (IDENTIFIERS); -- Exception is raised there. end if; -- Declare local loop control Variable -- added Hathorn Previous_Last := CD.Blocks_Table (CD.Display (Level)).Last_Id_Idx; CD.Id_Count := CD.Id_Count + 1; CD.IdTab (CD.Id_Count) := -- Loop parameter: the "i" in "for i in 1..10 loop" (Name => CD.Id, Name_with_case => CD.Id_with_case, Link => Previous_Last, Obj => Variable, Read_only => True, xTyp => Type_Undefined, Block_Ref => 0, Normal => True, LEV => Level, Adr_or_Sz => Dx, Discrete_First => 0, Discrete_Last => 0 ); CD.Blocks_Table (CD.Display (Level)).Last_Id_Idx := CD.Id_Count; Dx := Dx + 1; if Dx > MaxDX then MaxDX := Dx; end if; CD.Blocks_Table (CD.Display (Level)).VSize := MaxDX; else Skip (CD, Fail_after_FOR + FSys_St, err_identifier_missing); end if; -- Emit_2 (CD, k_Push_Address, CD.IdTab (CD.Id_Count).LEV, Operand_2_Type (CD.IdTab (CD.Id_Count).Adr_or_Sz)); InSymbol; FOR_Begin := k_FOR_Forward_Begin; if CD.Sy = IN_Symbol then -- "IN" in "for i in reverse 1 .. 10 loop" InSymbol; if CD.Sy = REVERSE_Symbol then -- "REVERSE" in "for i in reverse 1 .. 10 loop" FOR_Begin := k_FOR_Reverse_Begin; InSymbol; end if; Ranges.Dynamic_Range (CD, Level, FSys_St, err_control_variable_of_the_wrong_type, CD.IdTab (CD.Id_Count).xTyp -- Set the type of "C" in "for C in Red .. Blue loop" ); else Skip (CD, FSys_St + LOOP_Symbol, err_IN_missing); end if; LC_FOR_Begin := CD.LC; Emit (CD, FOR_Begin); LOOP_Statement (For_END (FOR_Begin), CD.LC); CD.ObjCode (LC_FOR_Begin).Y := Operand_2_Type (CD.LC); -- Address of the code just after the loop's end. -- Forget the loop parameter (the "iterator variable"): CD.Id_Count := CD.Id_Count - 1; CD.Blocks_Table (CD.Display (Level)).Last_Id_Idx := Previous_Last; Dx := Dx - 1; -- The VM must also de-stack the 3 data pushed on the stack for the FOR loop: Emit (CD, k_FOR_Release_Stack_After_End); end FOR_Statement; procedure Select_Statement is procedure Select_Error (N : Compile_Error) is begin Skip (CD, Semicolon, N); end Select_Error; -- Either a Timed or Conditional Entry Call. procedure Qualified_Entry_Call is I, J, IStart, IEnd : Integer; patch : array (0 .. 4) of Integer; O : Order; Y : Exact_Typ; begin I := Locate_Identifier (CD, CD.Id, Level); if CD.IdTab (I).Obj = aTask then InSymbol; Entry_Call (CD, Level, FSys_St, I, -1); if CD.ObjCode (CD.LC - 2).F = k_Call then -- Need to patch CallType later patch (0) := CD.LC - 2; else patch (0) := CD.LC - 3; end if; -- LC-1 must be OP=3, update Display patch (1) := CD.LC; -- Need to patch in JMPC address later Emit_1 (CD, k_Conditional_Jump, dummy_address_if); -- JMPC, address patched in after ELSE -- or OR if CD.Sy = Semicolon then InSymbol; else Skip (CD, Semicolon, err_semicolon_missing); end if; if not (CD.Sy = OR_Symbol or else CD.Sy = ELSE_Symbol) then Multi_Statement (ELSE_OR); end if; if CD.Sy = OR_Symbol then -- =====================> Timed Entry Call CD.ObjCode (patch (0)).X := Timed_Entry_Call; CD.ObjCode (patch (0) + 1).Y := Timed_Entry_Call; -- Exit type matches Entry type InSymbol; if CD.Sy = DELAY_Symbol then InSymbol; if CD.Sy = Semicolon then Select_Error (err_missing_expression_for_delay); else -- calculate delay value patch (2) := CD.LC; Expression (CD, Level, Semicolon_Set, Y); patch (3) := CD.LC - 1; if Y.TYP /= Floats then Select_Error (err_wrong_type_in_DELAY); else -- end of timed Entry select ObjCode, do patching CD.ObjCode (patch (1)).Y := Operand_2_Type (CD.LC); -- if Entry not made, Skip rest J := patch (3) - patch (2) + 1; IStart := patch (0); IEnd := CD.LC - 1; while J > 0 loop -- move delay time ObjCode To before O := CD.ObjCode (IEnd); -- opcodes kCall, k_Exit_Call for I in reverse IEnd - 1 .. IStart loop CD.ObjCode (I + 1) := CD.ObjCode (I); end loop; CD.ObjCode (IStart) := O; J := J - 1; end loop; InSymbol; end if; end if; else Select_Error (err_expecting_DELAY); end if; -- end Sy = OrSy else -- Sy = ELSE_Symbol, ===============> Conditional Entry Call CD.ObjCode (patch (0)).X := Conditional_Entry_Call; CD.ObjCode (patch (0) + 1).Y := Conditional_Entry_Call; patch (2) := CD.LC; Emit_1 (CD, k_Jump, dummy_address_if); -- JMP, address patched in after END SELECT patch (3) := CD.LC; InSymbol; Multi_Statement (END_Set); CD.ObjCode (patch (1)).Y := Operand_2_Type (patch (3)); CD.ObjCode (patch (2)).Y := Operand_2_Type (CD.LC); end if; if CD.Sy /= END_Symbol then Select_Error (err_END_missing); end if; InSymbol; if CD.Sy /= SELECT_Symbol then Select_Error (err_SELECT_missing); end if; else Select_Error (err_expecting_task_entry); end if; -- Task.Entry Call expected end Qualified_Entry_Call; procedure Selective_Wait is -- Kurtz <=================== -- Jay, this Buds for you !! JSD, Alt_Patch : Fixed_Size_Patch_Table; ISD, IAlt, StartSel : Integer; SelectDone : Boolean; Y, X : Exact_Typ; do_terminate : Boolean; procedure Accept_Statement_2 is -- Kurtz procedure Accept_Call_2 is begin -- Check to make sure parameters match with Entry Statement if CD.Sy = Semicolon then return; end if; if CD.Sy = LParent then -- should be modified -- To check no. and while not (CD.Sy = DO_Symbol or CD.Sy = RParent) loop InSymbol; end loop; end if; -- of parameters. if CD.Sy = RParent then InSymbol; end if; end Accept_Call_2; I : Integer; begin -- Accept_Statment_2 InSymbol; I := Locate_Identifier (CD, CD.Id, Level); if CD.IdTab (I).Obj /= aEntry then Select_Error (err_use_Small_Sp); end if; InSymbol; Accept_Call_2; Emit_2 (CD, k_Selective_Wait, 2, Operand_2_Type (I)); -- Retain Entry Index Feed_Patch_Table (Alt_Patch, IAlt, CD.LC); Emit_2 (CD, k_Selective_Wait, 3, Operand_2_Type (CD.LC)); -- ACCEPT IF Ready ELSE Skip To LC -- CONDITIONAL ACCEPT MUST BE ATOMIC if CD.Sy = DO_Symbol then if Level = Nesting_Level_Max then Fatal (LEVELS); -- Exception is raised there. end if; Level := Level + 1; CD.Display (Level) := CD.IdTab (I).Block_Ref; InSymbol; Multi_Statement (END_Set); Test_END_Symbol (CD); if CD.Sy = IDent then if CD.Id /= CD.IdTab (I).Name then Select_Error (err_incorrect_block_name); end if; end if; Level := Level - 1; InSymbol; end if; Emit_1 (CD, k_End_Rendezvous, Operand_2_Type (I)); end Accept_Statement_2; begin -- Selective_Wait ===============================> Kurtz ISD := 0; IAlt := 0; SelectDone := False; do_terminate := False; StartSel := CD.LC; Emit_2 (CD, k_Selective_Wait, 1, 0); -- START OF SELECT SELECTIVE Wait SEQUENCE loop case CD.Sy is when WHEN_Symbol => Patch_Addresses (CD.ObjCode (CD.ObjCode'First .. CD.LC), Alt_Patch, IAlt); InSymbol; -- Consume WHEN symbol. Boolean_Expression (CD, Level, FSys_St + Finger, X); InSymbol; if CD.Sy = ACCEPT_Symbol then Feed_Patch_Table (Alt_Patch, IAlt, CD.LC); Emit (CD, k_Conditional_Jump); Accept_Statement_2; elsif CD.Sy = DELAY_Symbol then Feed_Patch_Table (Alt_Patch, IAlt, CD.LC); Emit (CD, k_Conditional_Jump); InSymbol; Expression (CD, Level, FSys_St + Semicolon, Y); Emit_2 (CD, k_Selective_Wait, 4, Operand_2_Type (CD.LC + 2)); -- Update delay time if Y.TYP /= Floats then Select_Error (err_wrong_type_in_DELAY); end if; Feed_Patch_Table (Alt_Patch, IAlt, CD.LC); Emit (CD, k_Jump); else Select_Error (err_missing_a_procedure_declaration); end if; InSymbol; Multi_Statement (ELSE_END_OR); Feed_Patch_Table (JSD, ISD, CD.LC); Emit (CD, k_Jump); -- patch JMP ADDRESS AT EndSy -- end WHEN_Symbol when ACCEPT_Symbol => Patch_Addresses (CD.ObjCode (CD.ObjCode'First .. CD.LC), Alt_Patch, IAlt); Accept_Statement_2; InSymbol; Multi_Statement (ELSE_END_OR); Feed_Patch_Table (JSD, ISD, CD.LC); Emit (CD, k_Jump); when OR_Symbol => InSymbol; -- Consume OR symbol. when ELSE_Symbol => Patch_Addresses (CD.ObjCode (CD.ObjCode'First .. CD.LC), Alt_Patch, IAlt); InSymbol; Multi_Statement (END_Set); Feed_Patch_Table (JSD, ISD, CD.LC); Emit (CD, k_Jump); when DELAY_Symbol => Patch_Addresses (CD.ObjCode (CD.ObjCode'First .. CD.LC), Alt_Patch, IAlt); -- Generate a Task delay, calculate return value if req'D InSymbol; if CD.Sy = Semicolon then Skip (CD, Semicolon, err_missing_expression_for_delay); else -- calculate return value Expression (CD, Level, Semicolon_Set, Y); Emit_2 (CD, k_Selective_Wait, 4, Operand_2_Type (CD.LC + 2)); -- Update delay time if Y.TYP /= Floats then Select_Error (err_wrong_type_in_DELAY); end if; Feed_Patch_Table (Alt_Patch, IAlt, CD.LC); Emit (CD, k_Jump); end if; InSymbol; Multi_Statement (ELSE_END_OR); Feed_Patch_Table (JSD, ISD, CD.LC); Emit (CD, k_Jump); when TERMINATE_Symbol => InSymbol; if CD.Sy /= Semicolon then Select_Error (err_semicolon_missing); end if; do_terminate := True; -- Oguz InSymbol; when END_Symbol => InSymbol; if CD.Sy /= SELECT_Symbol then Select_Error (err_END_missing); end if; SelectDone := True; Patch_Addresses (CD.ObjCode (CD.ObjCode'First .. CD.LC), Alt_Patch, IAlt); if do_terminate then Emit_2 (CD, k_Selective_Wait, 5, Operand_2_Type (StartSel)); else Emit_2 (CD, k_Selective_Wait, 6, Operand_2_Type (StartSel)); end if; -- Suspend Patch_Addresses (CD.ObjCode (CD.ObjCode'First .. CD.LC), JSD, ISD); when others => SelectDone := True; end case; exit when SelectDone; end loop; end Selective_Wait; begin InSymbol; -- Consume SELECT symbol. if CD.Sy = ACCEPT_Symbol or CD.Sy = WHEN_Symbol then Selective_Wait; InSymbol; elsif CD.Sy = IDent then -- Task Entry objectName. Qualified_Entry_Call; InSymbol; -- Timed or Conditional Entry Call (?) else Select_Error (err_expecting_accept_when_or_entry_id); end if; end Select_Statement; procedure Block_Statement (block_name : Alfa) is -- RM: 5.6 begin Error ( CD, err_not_yet_implemented, hint => "Block statements don't work yet", stop => True ); -- Block (CD, FSys_St, Is_a_function, True, Level + 1, CD.Id_Count, block_name, block_name); -- !! up/low case -- -- !! to check: -- !! * stack management of variables when entering / quitting the block -- !! * object code and nesting... works on some cases at least (test.adb) !... -- !! Perhaps keep same level but have local declarations as for the -- variable in a FOR_Statement. -- !! Either both FOR and Block statements forget their definitions, or there -- is perhaps a problem with the stack (DX). -- !! Local bodies of subprograms surely mess the object code. end Block_Statement; procedure Named_Statement is -- Block_Statement or loop, named by "name: loop" new_ident_for_statement : constant Alfa := CD.Id; new_ident_for_statement_with_case : constant Alfa := CD.Id_with_case; -- procedure Check_ID_after_END_LOOP is -- RM 5.5 (5) begin if CD.Sy = IDent then if CD.Id /= new_ident_for_statement then Error (CD, err_END_LOOP_ident_wrong, hint => To_String (new_ident_for_statement_with_case)); end if; InSymbol; -- Consume identifier. else Error (CD, err_END_LOOP_ident_missing, hint => To_String (new_ident_for_statement_with_case)); end if; end Check_ID_after_END_LOOP; -- begin Enter (CD, Level, new_ident_for_statement, CD.Id_with_case, Label); Test (CD, Colon_Set, FSys_St, err_colon_missing_for_named_statement, stop_on_error => True ); InSymbol; -- Consume ':' symbol. case CD.Sy is when BEGIN_Symbol | DECLARE_Symbol => -- Named Block_Statement Block_Statement (new_ident_for_statement); when FOR_Symbol => FOR_Statement; Check_ID_after_END_LOOP; when LOOP_Symbol => LOOP_Statement (k_Jump, CD.LC); Check_ID_after_END_LOOP; when WHILE_Symbol => WHILE_Statement; Check_ID_after_END_LOOP; when others => Error (CD, err_syntax_error); end case; end Named_Statement; I_Statement : Integer; begin -- Statement if CD.Err_Count > 0 then return; end if; if Statement_Begin_Symbol (CD.Sy) then case CD.Sy is when IDent => I_Statement := Locate_Identifier (CD, CD.Id, Level, No_Id_Fail => False); InSymbol; if I_Statement = No_Id then -- New identifier: must be an identifier for a named Block_Statement or loop. Named_Statement; else case CD.IdTab (I_Statement).Obj is when Variable => Assignment (I_Statement, Check_read_only => True); when Declared_Number_or_Enum_Item => Error (CD, err_illegal_statement_start_symbol, "constant or an enumeration item", stop => True); when TypeMark => Error (CD, err_illegal_statement_start_symbol, "type name", stop => True); when Funktion => Error (CD, err_illegal_statement_start_symbol, "function name", stop => True); when aTask => Entry_Call (CD, Level, FSys_St, I_Statement, Normal_Entry_Call); when Prozedure => if CD.IdTab (I_Statement).LEV = 0 and then I_Statement /= CD.Main_Proc_Id_Index then -- We have a procedure name from HAC_Pack. Standard_Procedures.Standard_Procedure (CD, Level, FSys_St, SP_Code'Val (CD.IdTab (I_Statement).Adr_or_Sz)); else Subprogram_or_Entry_Call (CD, Level, FSys_St, I_Statement, Normal_Procedure_Call); end if; when Label => Error (CD, err_duplicate_label, To_String (CD.Id)); Test (CD, Colon_Set, FSys_St, err_colon_missing); InSymbol; when others => null; end case; end if; -- end IDent when ACCEPT_Symbol => Accept_Statement; when BEGIN_Symbol | DECLARE_Symbol => -- Anonymous Block Statement Block_Statement (Empty_Alfa); when CASE_Symbol => CASE_Statement; when DELAY_Symbol => Delay_Statement; when EXIT_Symbol => Exit_Statement; when FOR_Symbol => FOR_Statement; when IF_Symbol => IF_Statement; when LOOP_Symbol => LOOP_Statement (k_Jump, CD.LC); when NULL_Symbol => InSymbol; -- Just consume the NULL symbol. when RETURN_Symbol => RETURN_Statement; when SELECT_Symbol => Select_Statement; when WHILE_Symbol => WHILE_Statement; when others => null; end case; -- Need (CD, Semicolon, err_semicolon_missing); end if; -- CD.Sy in Statement_Begin_Symbol -- Test (CD, FSys_St - Semicolon, Semicolon_Set, err_incorrectly_used_symbol); end Statement; procedure Declarative_Part is begin loop Test ( -- Added 17-Apr-2018 to avoid infinite loop on erroneous code CD, Declaration_Symbol + BEGIN_Symbol, Empty_Symset, err_incorrectly_used_symbol, stop_on_error => True -- Exception is raised there if there is an error. ); if CD.Sy = IDent then Var_Declaration; end if; if CD.Sy = TYPE_Symbol or CD.Sy = SUBTYPE_Symbol then Type_Declaration (CD, Level, FSys); end if; if CD.Sy = TASK_Symbol then Tasking.Task_Declaration (CD, FSys, Level); end if; CD.Blocks_Table (PRB).VSize := Dx; -- ^ TBD: check if this is still correct for declarations that appear -- after subprograms !! while CD.Sy = PROCEDURE_Symbol or CD.Sy = FUNCTION_Symbol loop Proc_Func_Declaration; end loop; -- exit when CD.Sy = BEGIN_Symbol; end loop; end Declarative_Part; procedure Statements_Part_Setup is Init_Code_Idx : Integer; begin MaxDX := Dx; CD.IdTab (Prt).Adr_or_Sz := CD.LC; -- Copy initialization (elaboration) ObjCode from end of ObjCode table Init_Code_Idx := CD.CMax + ICode; while Init_Code_Idx > CD.CMax loop CD.ObjCode (CD.LC) := CD.ObjCode (Init_Code_Idx); CD.LC := CD.LC + 1; Init_Code_Idx := Init_Code_Idx - 1; end loop; CD.CMax := CD.CMax + ICode; -- Restore CMax to the initial max (=CDMax) end Statements_Part_Setup; procedure Statements_List is begin if CD.Sy = END_Symbol then -- GdM 15-Aug-2014: there should be at least one statement. Error (CD, err_statement_expected); end if; loop Statement (FSys + END_Symbol); exit when CD.Sy = END_Symbol or CD.Err_Count > 0; end loop; end Statements_List; procedure Statements_Part_Closing is begin CD.Blocks_Table (PRB).SrcTo := CD.Line_Count; end Statements_Part_Closing; procedure Function_Result_Profile is I_Res_Type : Integer; begin if CD.Sy = RETURN_Symbol then InSymbol; -- FUNCTION TYPE if CD.Sy = IDent then I_Res_Type := Locate_Identifier (CD, CD.Id, Level); InSymbol; if I_Res_Type /= 0 then if CD.IdTab (I_Res_Type).Obj /= TypeMark then Error (CD, err_missing_a_type_identifier, stop => True); elsif Standard_or_Enum_Typ (CD.IdTab (I_Res_Type).xTyp.TYP) then CD.IdTab (Prt).xTyp := CD.IdTab (I_Res_Type).xTyp; else Error (CD, err_bad_result_type_for_a_function, stop => True); end if; end if; else Error (CD, err_identifier_missing, stop => True); end if; else Error (CD, err_RETURN_missing, stop => True); end if; end Function_Result_Profile; Restore_Block_ID : constant VString := CD.Full_Block_Id; use VStrings_Pkg; begin -- Block if CD.Err_Count > 0 then return; end if; if CD.Full_Block_Id = Universe then CD.Full_Block_Id := To_VString (To_String (Block_ID_with_case)); else CD.Full_Block_Id := CD.Full_Block_Id & '.' & To_String (Block_ID_with_case); end if; Dx := 5; ICode := 0; if Is_a_block_statement then null; -- We should be here with Sy = BEGIN_Symbol or Sy = DECLARE_Symbol. else Test (CD, Symbols_after_Subprogram_Identifier, FSys, err_incorrectly_used_symbol); end if; if CD.IdTab (Prt).Block_Ref > 0 then PRB := CD.IdTab (Prt).Block_Ref; else Enter_Block (CD, Prt); PRB := CD.Blocks_Count; CD.IdTab (Prt).Block_Ref := PRB; end if; CD.Display (Level) := PRB; CD.IdTab (Prt).xTyp := Type_Undefined; if CD.Sy = LParent and Level > 1 then Formal_Parameter_List; end if; -- if CD.Err_Count > 0 then return; end if; -- CD.Blocks_Table (PRB).Last_Param_Id_Idx := CD.Id_Count; CD.Blocks_Table (PRB).PSize := Dx; -- if Is_a_function and not Is_a_block_statement then Function_Result_Profile; end if; -- if CD.Sy = Semicolon then -- end of specification part CD.Blocks_Table (PRB).VSize := Dx; CD.IdTab (Prt).Adr_or_Sz := -1; -- address of body TBD return; end if; -- if Is_a_block_statement then case CD.Sy is when DECLARE_Symbol => InSymbol; when BEGIN_Symbol => null; when others => raise Internal_error with "Unexpected " & KeyWSymbol'Image (CD.Sy); end case; elsif CD.Sy = IS_Symbol then -- The "IS" in "procedure ABC (param : T_Type) IS" InSymbol; else Error (CD, err_IS_missing); return; end if; -- if CD.Sy = NULL_Symbol and not Is_a_block_statement then -- RM 6.7 Null Procedures (Ada 2005) -- E.g.: "procedure Not_Yet_Done (a : Integer) is null;" InSymbol; -- Consume NULL symbol. Statements_Part_Setup; if Is_a_function then Error (CD, err_no_null_functions); -- There are no null functions: what would be the result? else null; -- No statement -> no instruction, like for the NULL statement. end if; Statements_Part_Closing; else Declarative_Part; InSymbol; -- Consume BEGIN symbol. Statements_Part_Setup; Statements_List; Statements_Part_Closing; -- if CD.Sy = END_Symbol then InSymbol; elsif CD.Err_Count > 0 then return; -- At this point the program is already FUBAR. else Error (CD, err_END_missing); return; end if; -- if CD.Sy = IDent then -- Verify that the name after "end" matches the unit name. if CD.Id /= Block_ID then Error (CD, err_incorrect_block_name, hint => To_String (Block_ID_with_case)); end if; InSymbol; elsif Is_a_block_statement and Block_ID /= Empty_Alfa then -- "end [label]" is required Error (CD, err_incorrect_block_name, hint => To_String (Block_ID_with_case)); end if; end if; -- if CD.Sy /= Semicolon then Error (CD, err_semicolon_missing); return; end if; -- if Block_ID /= CD.Main_Program_ID and not Is_a_block_statement then InSymbol; -- Consume ';' symbol after END [Subprogram_Id]. -- -- Now we have either another declaration, -- or BEGIN or, if it's a package, END. Test ( CD, FSys + Declaration_Symbol + BEGIN_Symbol + END_Symbol, Empty_Symset, err_incorrectly_used_symbol ); end if; CD.Full_Block_Id := Restore_Block_ID; if CD.Err_Count = 0 then pragma Assert (Level = Initial_Level); end if; end Block; end HAC_Sys.Parser;
jscparker/math_packages
Ada
1,074
ads
-- F defines a differential equation whose solution is Exp (i*t). -- dY/dt = F(Y). -- For testing. generic type Real is digits <>; package Sinu_2 is type Dyn_Index is range 0..1; -- the 2nd component is just ignored in the tests. type Dynamical_Variable is array(Dyn_Index) of Real; DynZero : constant Dynamical_Variable := (others => 0.0); function F (Time : Real; Y : Dynamical_Variable) return Dynamical_Variable; -- Defines the equation to be integrated, -- dY/dt = F (t, Y). Even if the equation is t or Y -- independent, it must be entered in this form. function "*" (Left : Real; Right : Dynamical_Variable) return Dynamical_Variable; function "+" (Left : Dynamical_Variable; Right : Dynamical_Variable) return Dynamical_Variable; function "-" (Left : Dynamical_Variable; Right : Dynamical_Variable) return Dynamical_Variable; function Norm (Y : Dynamical_Variable) return Real; pragma Inline (F, "*", "+", "-", Norm); end Sinu_2;
reznikmm/matreshka
Ada
4,682
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. ------------------------------------------------------------------------------ limited with AMF.UML.Dependencies; package AMF.Utp.Default_Applications is pragma Preelaborate; type Utp_Default_Application is limited interface; type Utp_Default_Application_Access is access all Utp_Default_Application'Class; for Utp_Default_Application_Access'Storage_Size use 0; not overriding function Get_Base_Dependency (Self : not null access constant Utp_Default_Application) return AMF.UML.Dependencies.UML_Dependency_Access is abstract; -- Getter of DefaultApplication::base_Dependency. -- not overriding procedure Set_Base_Dependency (Self : not null access Utp_Default_Application; To : AMF.UML.Dependencies.UML_Dependency_Access) is abstract; -- Setter of DefaultApplication::base_Dependency. -- not overriding function Get_Repetition (Self : not null access constant Utp_Default_Application) return AMF.Unlimited_Natural is abstract; -- Getter of DefaultApplication::repetition. -- not overriding procedure Set_Repetition (Self : not null access Utp_Default_Application; To : AMF.Unlimited_Natural) is abstract; -- Setter of DefaultApplication::repetition. -- end AMF.Utp.Default_Applications;
AdaCore/libadalang
Ada
349
ads
package Bar is type T is tagged private; generic type U is tagged private; with procedure Foo (X : T); --% node.p_subp_spec_or_null().p_primitive_subp_tagged_type() with procedure Foo (X : U); --% node.p_subp_spec_or_null().p_primitive_subp_tagged_type() package Pkg is end Pkg; procedure Foo; end Bar;
reznikmm/torrent
Ada
19,887
adb
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Ada.Containers.Vectors; with Ada.Streams.Stream_IO; with Ada.Unchecked_Deallocation; with GNAT.SHA1; with League.Stream_Element_Vectors; with League.Text_Codecs; package body Torrent.Metainfo_Files is procedure Free is new Ada.Unchecked_Deallocation (Metainfo, Metainfo_Access); -------------- -- Announce -- -------------- not overriding function Announce (Self : Metainfo_File) return League.IRIs.IRI is begin return Self.Data.Announce; end Announce; ------------------- -- Announce_List -- ------------------- not overriding function Announce_List (Self : Metainfo_File) return String_Vector_Array is begin return Self.Data.Announces; end Announce_List; ---------------- -- File_Count -- ---------------- not overriding function File_Count (Self : Metainfo_File) return Positive is begin return Self.Data.File_Count; end File_Count; ----------------- -- File_Length -- ----------------- not overriding function File_Length (Self : Metainfo_File; Index : Positive) return Ada.Streams.Stream_Element_Count is begin return Self.Data.Files (Index).Length; end File_Length; --------------- -- File_Path -- --------------- not overriding function File_Path (Self : Metainfo_File; Index : Positive) return League.String_Vectors.Universal_String_Vector is begin return Self.Data.Files (Index).Path; end File_Path; -------------- -- Finalize -- -------------- procedure Finalize (Self : in out Metainfo_File) is begin Free (Self.Data); end Finalize; --------------- -- Info_Hash -- --------------- not overriding function Info_Hash (Self : Metainfo_File) return SHA1 is begin return Self.Data.Info_Hash; end Info_Hash; ----------------------- -- Last_Piece_Length -- ----------------------- not overriding function Last_Piece_Length (Self : Metainfo_File) return Piece_Offset is begin return Self.Data.Last_Piece; end Last_Piece_Length; ---------- -- Name -- ---------- not overriding function Name (Self : Metainfo_File) return League.Strings.Universal_String is begin return Self.Data.Name; end Name; ----------------- -- Piece_Count -- ----------------- not overriding function Piece_Count (Self : Metainfo_File) return Piece_Index is begin return Self.Data.Piece_Count; end Piece_Count; ------------------ -- Piece_Length -- ------------------ not overriding function Piece_Length (Self : Metainfo_File) return Piece_Offset is begin return Self.Data.Piece_Length; end Piece_Length; ---------------- -- Piece_SHA1 -- ---------------- not overriding function Piece_SHA1 (Self : Metainfo_File; Index : Piece_Index) return SHA1 is begin return Self.Data.Hashes (Index); end Piece_SHA1; ---------- -- Read -- ---------- not overriding procedure Read (Self : in out Metainfo_File; File_Name : League.Strings.Universal_String) is use type Ada.Streams.Stream_Element; use type Ada.Streams.Stream_Element_Offset; use type League.Strings.Universal_String; package File_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => File_Information); package String_Vector_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => League.String_Vectors.Universal_String_Vector, "=" => League.String_Vectors."="); function "+" (Text : Wide_Wide_String) return League.Strings.Universal_String renames League.Strings.To_Universal_String; function Parse_Top_Dictionary return Metainfo; procedure Parse_Int (Value : out Ada.Streams.Stream_Element_Offset); procedure Parse_String (Value : out League.Strings.Universal_String); procedure Parse_Pieces (Value : out League.Stream_Element_Vectors.Stream_Element_Vector); procedure Parse_String_List (Value : out League.String_Vectors.Universal_String_Vector); procedure Parse_String_Vector_Vector (Value : out String_Vector_Vectors.Vector); procedure Skip_Value; procedure Skip_List; procedure Skip_Dictionary; procedure Skip_String; procedure Skip_Int; procedure Parse_Files (Value : out File_Vectors.Vector); procedure Expect (Char : Ada.Streams.Stream_Element); procedure Parse_File (Path : out League.String_Vectors.Universal_String_Vector; Length : out Ada.Streams.Stream_Element_Count); procedure Parse_Info (Name : out League.Strings.Universal_String; Piece_Len : out Ada.Streams.Stream_Element_Count; Files : out File_Vectors.Vector; Pieces : out League.Stream_Element_Vectors.Stream_Element_Vector); procedure Read_Buffer; subtype Digit is Ada.Streams.Stream_Element range Character'Pos ('0') .. Character'Pos ('9'); Input : Ada.Streams.Stream_IO.File_Type; Buffer : Ada.Streams.Stream_Element_Array (1 .. 1024); Last : Ada.Streams.Stream_Element_Count := 0; Next : Ada.Streams.Stream_Element_Count := 1; Error : constant String := "Can't parse torrent file."; SHA_From : Ada.Streams.Stream_Element_Count := Buffer'Last + 1; Context : GNAT.SHA1.Context := GNAT.SHA1.Initial_Context; Codec : constant League.Text_Codecs.Text_Codec := League.Text_Codecs.Codec (+"utf-8"); package Constants is Announce : constant League.Strings.Universal_String := +"announce"; Files : constant League.Strings.Universal_String := +"files"; Info : constant League.Strings.Universal_String := +"info"; Length : constant League.Strings.Universal_String := +"length"; Name : constant League.Strings.Universal_String := +"name"; Path : constant League.Strings.Universal_String := +"path"; Pieces : constant League.Strings.Universal_String := +"pieces"; Announce_List : constant League.Strings.Universal_String := +"announce-list"; Piece_Length : constant League.Strings.Universal_String := +"piece length"; end Constants; ----------------- -- Read_Buffer -- ----------------- procedure Read_Buffer is begin if SHA_From <= Last then GNAT.SHA1.Update (Context, Buffer (SHA_From .. Last)); SHA_From := 1; end if; Ada.Streams.Stream_IO.Read (Input, Buffer, Last); Next := 1; end Read_Buffer; ------------ -- Expect -- ------------ procedure Expect (Char : Ada.Streams.Stream_Element) is begin if Buffer (Next) = Char then Next := Next + 1; if Next > Last then Read_Buffer; end if; else raise Constraint_Error with Error; end if; end Expect; ---------------- -- Parse_File -- ---------------- procedure Parse_File (Path : out League.String_Vectors.Universal_String_Vector; Length : out Ada.Streams.Stream_Element_Count) is Key : League.Strings.Universal_String; begin Expect (Character'Pos ('d')); while Buffer (Next) /= Character'Pos ('e') loop Parse_String (Key); if Key = Constants.Length then Parse_Int (Length); elsif Key = Constants.Path then Parse_String_List (Path); else Skip_Value; end if; end loop; Expect (Character'Pos ('e')); end Parse_File; ----------------- -- Parse_Files -- ----------------- procedure Parse_Files (Value : out File_Vectors.Vector) is Path : League.String_Vectors.Universal_String_Vector; Length : Ada.Streams.Stream_Element_Count; begin Value.Clear; Expect (Character'Pos ('l')); while Buffer (Next) /= Character'Pos ('e') loop Parse_File (Path, Length); Value.Append ((Length, Path)); end loop; Expect (Character'Pos ('e')); end Parse_Files; ---------------- -- Parse_Info -- ---------------- procedure Parse_Info (Name : out League.Strings.Universal_String; Piece_Len : out Ada.Streams.Stream_Element_Count; Files : out File_Vectors.Vector; Pieces : out League.Stream_Element_Vectors.Stream_Element_Vector) is Key : League.Strings.Universal_String; Length : Ada.Streams.Stream_Element_Count := 0; begin Files.Clear; SHA_From := Next; -- Activate SHA1 calculation Expect (Character'Pos ('d')); while Buffer (Next) /= Character'Pos ('e') loop Parse_String (Key); if Key = Constants.Name then declare Path : League.String_Vectors.Universal_String_Vector; begin Parse_String (Name); if Length > 0 then -- There is a key length or a key files, but not both -- or neither. If length is present then the download -- represents a single file, otherwise it represents a -- set of files which go in a directory structure. Path.Append (Name); Files.Append ((Length, Path)); end if; end; elsif Key = Constants.Piece_Length then Parse_Int (Piece_Len); elsif Key = Constants.Length then Parse_Int (Length); elsif Key = Constants.Files then Parse_Files (Files); elsif Key = Constants.Pieces then Parse_Pieces (Pieces); else Skip_Value; end if; end loop; GNAT.SHA1.Update (Context, Buffer (SHA_From .. Next)); SHA_From := Buffer'Last + 1; -- Deactivate SHA1 calculation Expect (Character'Pos ('e')); end Parse_Info; --------------- -- Parse_Int -- --------------- procedure Parse_Int (Value : out Ada.Streams.Stream_Element_Offset) is begin Expect (Character'Pos ('i')); Value := 0; while Buffer (Next) in Digit loop Value := Value * 10 + Ada.Streams.Stream_Element_Offset (Buffer (Next)) - Character'Pos ('0'); Expect (Buffer (Next)); end loop; Expect (Character'Pos ('e')); end Parse_Int; -------------------------- -- Parse_Top_Dictionary -- -------------------------- function Parse_Top_Dictionary return Metainfo is Index : Ada.Streams.Stream_Element_Count; Key : League.Strings.Universal_String; Announce : League.Strings.Universal_String; Name : League.Strings.Universal_String; Files : File_Vectors.Vector; Announces : String_Vector_Vectors.Vector; Pieces : League.Stream_Element_Vectors.Stream_Element_Vector; Piece_Length : Ada.Streams.Stream_Element_Count; begin Expect (Character'Pos ('d')); while Buffer (Next) /= Character'Pos ('e') loop Parse_String (Key); if Key = Constants.Announce then Parse_String (Announce); elsif Key = Constants.Announce_List then Parse_String_Vector_Vector (Announces); elsif Key = Constants.Info then Parse_Info (Name, Piece_Length, Files, Pieces); else Skip_Value; end if; end loop; Expect (Character'Pos ('e')); if Last /= 0 then raise Constraint_Error with Error; end if; return Result : Metainfo := (Piece_Count => Piece_Index (Pieces.Length) / 20, File_Count => Files.Last_Index, Announce_Count => Announces.Last_Index, Announce => League.IRIs.From_Universal_String (Announce), Name => Name, Piece_Length => Piece_Length, Info_Hash => GNAT.SHA1.Digest (Context), others => <>) do for J in 1 .. Announces.Last_Index loop Result.Announces (J) := Announces (J); end loop; for J in Result.Hashes'Range loop for K in SHA1'Range loop Index := Ada.Streams.Stream_Element_Count (J - 1) * SHA1'Length + K; Result.Hashes (J) (K) := Pieces.Element (Index); end loop; Piece_Length := 0; for J in 1 .. Files.Last_Index loop Result.Files (J) := Files.Element (J); Piece_Length := Piece_Length + Files.Element (J).Length; end loop; Piece_Length := Piece_Length mod Result.Piece_Length; if Piece_Length = 0 then Result.Last_Piece := Result.Piece_Length; else Result.Last_Piece := Piece_Length; end if; end loop; end return; end Parse_Top_Dictionary; ------------------ -- Parse_Pieces -- ------------------ procedure Parse_Pieces (Value : out League.Stream_Element_Vectors.Stream_Element_Vector) is Len : Ada.Streams.Stream_Element_Count := 0; begin Value.Clear; while Buffer (Next) in Digit loop Len := Len * 10 + Ada.Streams.Stream_Element_Count (Buffer (Next)) - Character'Pos ('0'); Expect (Buffer (Next)); end loop; Expect (Character'Pos (':')); while Last - Next + 1 <= Len loop Value.Append (Buffer (Next .. Last)); Len := Len - (Last - Next + 1); Read_Buffer; end loop; if Len > 0 then Value.Append (Buffer (Next .. Next + Len - 1)); Next := Next + Len; end if; end Parse_Pieces; ------------------ -- Parse_String -- ------------------ procedure Parse_String (Value : out League.Strings.Universal_String) is Len : Ada.Streams.Stream_Element_Count := 0; begin while Buffer (Next) in Digit loop Len := Len * 10 + Ada.Streams.Stream_Element_Count (Buffer (Next)) - Character'Pos ('0'); Expect (Buffer (Next)); end loop; declare Data : Ada.Streams.Stream_Element_Array (1 .. Len); To : Ada.Streams.Stream_Element_Count := 0; begin Expect (Character'Pos (':')); while Last - Next + 1 <= Len loop Data (To + 1 .. To + Last - Next + 1) := Buffer (Next .. Last); To := To + Last - Next + 1; Len := Len - (Last - Next + 1); Read_Buffer; end loop; if Len > 0 then Data (To + 1 .. Data'Last) := Buffer (Next .. Next + Len - 1); Next := Next + Len; end if; Value := Codec.Decode (Data); end; end Parse_String; ----------------------- -- Parse_String_List -- ----------------------- procedure Parse_String_List (Value : out League.String_Vectors.Universal_String_Vector) is Text : League.Strings.Universal_String; begin Value.Clear; Expect (Character'Pos ('l')); while Buffer (Next) /= Character'Pos ('e') loop Parse_String (Text); Value.Append (Text); end loop; Expect (Character'Pos ('e')); end Parse_String_List; -------------------------------- -- Parse_String_Vector_Vector -- -------------------------------- procedure Parse_String_Vector_Vector (Value : out String_Vector_Vectors.Vector) is Item : League.String_Vectors.Universal_String_Vector; begin Value.Clear; Expect (Character'Pos ('l')); while Buffer (Next) /= Character'Pos ('e') loop Parse_String_List (Item); Value.Append (Item); end loop; Expect (Character'Pos ('e')); end Parse_String_Vector_Vector; --------------------- -- Skip_Dictionary -- --------------------- procedure Skip_Dictionary is Key : League.Strings.Universal_String; begin Expect (Character'Pos ('d')); while Buffer (Next) /= Character'Pos ('e') loop Parse_String (Key); Skip_Value; end loop; Expect (Character'Pos ('e')); end Skip_Dictionary; -------------- -- Skip_Int -- -------------- procedure Skip_Int is begin Expect (Character'Pos ('i')); if Buffer (Next) = Character'Pos ('-') then Expect (Buffer (Next)); end if; while Buffer (Next) in Digit loop Expect (Buffer (Next)); end loop; Expect (Character'Pos ('e')); end Skip_Int; --------------- -- Skip_List -- --------------- procedure Skip_List is begin Expect (Character'Pos ('l')); while Buffer (Next) /= Character'Pos ('e') loop Skip_Value; end loop; Expect (Character'Pos ('e')); end Skip_List; ----------------- -- Skip_String -- ----------------- procedure Skip_String is Len : Ada.Streams.Stream_Element_Count := 0; begin while Buffer (Next) in Digit loop Len := Len * 10 + Ada.Streams.Stream_Element_Count (Buffer (Next)) - Character'Pos ('0'); Expect (Buffer (Next)); end loop; declare To : Ada.Streams.Stream_Element_Count := 0; begin Expect (Character'Pos (':')); while Last - Next + 1 <= Len loop To := To + Last - Next + 1; Len := Len - (Last - Next + 1); Read_Buffer; end loop; if Len > 0 then Next := Next + Len; end if; end; end Skip_String; ---------------- -- Skip_Value -- ---------------- procedure Skip_Value is begin case Buffer (Next) is when Character'Pos ('l') => Skip_List; when Digit => Skip_String; when Character'Pos ('i') => Skip_Int; when Character'Pos ('d') => Skip_Dictionary; when others => raise Constraint_Error with Error; end case; end Skip_Value; begin Ada.Streams.Stream_IO.Open (Input, Ada.Streams.Stream_IO.In_File, File_Name.To_UTF_8_String); Ada.Streams.Stream_IO.Read (Input, Buffer, Last); Free (Self.Data); Self.Data := new Metainfo'(Parse_Top_Dictionary); Ada.Streams.Stream_IO.Close (Input); end Read; end Torrent.Metainfo_Files;
reznikmm/matreshka
Ada
4,606
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Svg.Ideographic_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Svg_Ideographic_Attribute_Node is begin return Self : Svg_Ideographic_Attribute_Node do Matreshka.ODF_Svg.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Svg_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Svg_Ideographic_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Ideographic_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Svg_URI, Matreshka.ODF_String_Constants.Ideographic_Attribute, Svg_Ideographic_Attribute_Node'Tag); end Matreshka.ODF_Svg.Ideographic_Attributes;
stcarrez/ada-awa
Ada
16,013
adb
----------------------------------------------------------------------- -- awa-users-servlets -- OpenID verification servlet for user authentication -- Copyright (C) 2011, 2012, 2013, 2014, 2015, 2018, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Beans.Objects; with Util.Beans.Objects.Records; with Util.Log.Loggers; with AWA.Users.Services; with AWA.Users.Modules; with AWA.Users.Filters; package body AWA.Users.Servlets is package UBO renames Util.Beans.Objects; -- Name of the session attribute which holds the URI to redirect after authentication. REDIRECT_ATTRIBUTE : constant String := "awa-redirect"; -- Name of the request attribute that contains the URI to redirect after authentication. REDIRECT_PARAM : constant String := "redirect"; -- Name of the session attribute which holds information about the active authentication. OPENID_ASSOC_ATTRIBUTE : constant String := "openid-assoc"; -- The logger Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Users.Servlets"); -- Make a package to store the Association in the session. package Association_Bean is new Util.Beans.Objects.Records (Security.Auth.Association); subtype Association_Access is Association_Bean.Element_Type_Access; function Get_Provider_URL (Server : in Request_Auth_Servlet; Request : in Servlet.Requests.Request'Class) return String; -- ------------------------------ -- Set the user principal on the session associated with the ASF request. -- ------------------------------ procedure Set_Session_Principal (Request : in out Servlet.Requests.Request'Class; Principal : in Principals.Principal_Access) is Session : Servlet.Sessions.Session := Request.Get_Session (Create => True); begin Session.Set_Principal (Principal.all'Access); end Set_Session_Principal; function Get_Provider_URL (Server : in Request_Auth_Servlet; Request : in Servlet.Requests.Request'Class) return String is pragma Unreferenced (Server); URI : constant String := Request.Get_Path_Info; begin if URI'Length = 0 then return ""; end if; Log.Info ("OpenID authentication with {0}", URI); return URI (URI'First + 1 .. URI'Last); end Get_Provider_URL; -- ------------------------------ -- Proceed to the OpenID authentication with an OpenID provider. -- Find the OpenID provider URL and starts the discovery, association phases -- during which a private key is obtained from the OpenID provider. -- After OpenID discovery and association, the user will be redirected to -- the OpenID provider. -- ------------------------------ overriding procedure Do_Get (Server : in Request_Auth_Servlet; Request : in out Servlet.Requests.Request'Class; Response : in out Servlet.Responses.Response'Class) is Ctx : constant Servlet.Core.Servlet_Registry_Access := Server.Get_Servlet_Context; Name : constant String := Get_Provider_URL (Server, Request); URL : constant String := Ctx.Get_Init_Parameter ("auth.url." & Name); Session : Servlet.Sessions.Session := Request.Get_Session (Create => True); begin Log.Info ("GET: request OpenId authentication to {0} - {1}", Name, URL); if Name'Length = 0 or else URL'Length = 0 then Session.Set_Attribute (AUTH_ERROR_ATTRIBUTE, UBO.To_Object (MESSAGE_BAD_CONFIGURATION)); Response.Set_Status (Servlet.Responses.SC_NOT_FOUND); return; end if; declare Mgr : Security.Auth.Manager; OP : Security.Auth.End_Point; Bean : constant Util.Beans.Objects.Object := Association_Bean.Create; Assoc : constant Association_Access := Association_Bean.To_Element_Access (Bean); Redirect : constant String := Request.Get_Parameter (REDIRECT_PARAM); begin Server.Initialize (Name, Mgr); -- Yadis discovery (get the XRDS file). This step does nothing for OAuth. Mgr.Discover (URL, OP); -- Associate to the OpenID provider and get an end-point with a key. Mgr.Associate (OP, Assoc.all); -- Save the association in the HTTP session and -- redirect the user to the OpenID provider. declare Auth_URL : constant String := Mgr.Get_Authentication_URL (OP, Assoc.all); begin Log.Info ("Redirect to auth URL: {0}", Auth_URL); Response.Send_Redirect (Location => Auth_URL); Session.Set_Attribute (Name => OPENID_ASSOC_ATTRIBUTE, Value => Bean); if Redirect'Length > 0 then Session.Set_Attribute (Name => REDIRECT_ATTRIBUTE, Value => Util.Beans.Objects.To_Object (Redirect)); AWA.Users.Filters.Clear_Redirect_Cookie (Request, Response); end if; end; end; end Do_Get; -- ------------------------------ -- Create a principal object that correspond to the authenticated user identified -- by the <b>Auth</b> information. The principal will be attached to the session -- and will be destroyed when the session is closed. -- ------------------------------ overriding procedure Create_Principal (Server : in Verify_Auth_Servlet; Auth : in Security.Auth.Authentication; Result : out Security.Principal_Access) is pragma Unreferenced (Server); use AWA.Users.Services; Manager : constant User_Service_Access := AWA.Users.Modules.Get_User_Manager; Principal : AWA.Users.Principals.Principal_Access; begin Manager.Authenticate (Auth => Auth, IpAddr => "", Principal => Principal); Result := Principal.all'Access; end Create_Principal; -- ------------------------------ -- Get the redirection URL that must be used after the authentication succeeded. -- ------------------------------ function Get_Redirect_URL (Server : in Verify_Auth_Servlet; Session : in Servlet.Sessions.Session'Class; Request : in Servlet.Requests.Request'Class) return String is Redir : constant Util.Beans.Objects.Object := Session.Get_Attribute (REDIRECT_ATTRIBUTE); Ctx : constant Servlet.Core.Servlet_Registry_Access := Server.Get_Servlet_Context; begin if not Util.Beans.Objects.Is_Null (Redir) then return Util.Beans.Objects.To_String (Redir); end if; declare URL : constant String := AWA.Users.Filters.Get_Redirect_Cookie (Request); begin if URL'Length > 0 then return URL; else return Ctx.Get_Init_Parameter ("openid.success_url"); end if; end; end Get_Redirect_URL; -- ------------------------------ -- Get the redirection URL that must be used after the authentication failed. -- ------------------------------ function Get_Error_URL (Server : in Verify_Auth_Servlet; Session : in Servlet.Sessions.Session'Class; Request : in Servlet.Requests.Request'Class) return String is pragma Unreferenced (Session, Request); Ctx : constant Servlet.Core.Servlet_Registry_Access := Server.Get_Servlet_Context; begin return Ctx.Get_Init_Parameter ("openid.error_url"); end Get_Error_URL; -- ------------------------------ -- Verify the authentication result that was returned by the OpenID provider. -- If the authentication succeeded and the signature was correct, sets a -- user principals on the session. -- ------------------------------ overriding procedure Do_Get (Server : in Verify_Auth_Servlet; Request : in out Servlet.Requests.Request'Class; Response : in out Servlet.Responses.Response'Class) is use type Security.Auth.Auth_Result; type Auth_Params is new Security.Auth.Parameters with null record; overriding function Get_Parameter (Params : in Auth_Params; Name : in String) return String; overriding function Get_Parameter (Params : in Auth_Params; Name : in String) return String is pragma Unreferenced (Params); begin return Request.Get_Parameter (Name); end Get_Parameter; Session : Servlet.Sessions.Session := Request.Get_Session (Create => False); Bean : Util.Beans.Objects.Object; Mgr : Security.Auth.Manager; Assoc : Association_Access; Credential : Security.Auth.Authentication; Params : Auth_Params; Error_URI : constant String := Verify_Auth_Servlet'Class (Server).Get_Error_URL (Session, Request); begin Log.Info ("GET: verify openid authentication"); if not Session.Is_Valid then Log.Warn ("Session has expired during OpenID authentication process, " & "redirect to {0}", Error_URI); Response.Send_Redirect (Error_URI); return; end if; Bean := Session.Get_Attribute (OPENID_ASSOC_ATTRIBUTE); -- Cleanup the session and drop the association end point. Session.Remove_Attribute (OPENID_ASSOC_ATTRIBUTE); if Util.Beans.Objects.Is_Null (Bean) then Log.Warn ("Verify openid request without active session, " & "redirect to {0}", Error_URI); Response.Send_Redirect (Error_URI); return; end if; Assoc := Association_Bean.To_Element_Access (Bean); Server.Initialize (Security.Auth.Get_Provider (Assoc.all), Mgr); -- Verify that what we receive through the callback matches the association key. Mgr.Verify (Assoc.all, Params, Credential); if Security.Auth.Get_Status (Credential) /= Security.Auth.AUTHENTICATED then Log.Info ("Authentication has failed, redirect to {0}", Error_URI); Session.Set_Attribute (AUTH_ERROR_ATTRIBUTE, UBO.To_Object (MESSAGE_AUTH_FAILED)); Response.Send_Redirect (Error_URI); return; end if; Log.Info ("Authentication succeeded for {0}", Security.Auth.Get_Email (Credential)); -- Get a user principal and set it on the session. declare User : Security.Principal_Access; Redirect : constant String := Verify_Auth_Servlet'Class (Server).Get_Redirect_URL (Session, Request); begin Verify_Auth_Servlet'Class (Server).Create_Principal (Credential, User); Session.Set_Principal (User); Session.Remove_Attribute (REDIRECT_ATTRIBUTE); Log.Info ("Redirect user to URL: {0}", Redirect); Response.Send_Redirect (Redirect); AWA.Users.Filters.Clear_Redirect_Cookie (Request, Response); exception when AWA.Users.Services.Registration_Disabled => Log.Info ("User registration is disabled, redirect to {0}", Error_URI); Session.Set_Attribute (AUTH_ERROR_ATTRIBUTE, UBO.To_Object (MESSAGE_REGISTRATION_DISABLED)); Response.Send_Redirect (Error_URI); end; end Do_Get; -- ------------------------------ -- Get the redirection URL that must be used after the authentication succeeded. -- ------------------------------ function Get_Redirect_URL (Server : in Verify_Key_Servlet; Request : in Servlet.Requests.Request'Class) return String is Ctx : constant Servlet.Core.Servlet_Registry_Access := Server.Get_Servlet_Context; URL : constant String := AWA.Users.Filters.Get_Redirect_Cookie (Request); begin if URL'Length > 0 then return URL; else return Ctx.Get_Init_Parameter ("openid.success_url"); end if; end Get_Redirect_URL; -- ------------------------------ -- Initialize the filter and configure the redirection URIs. -- ------------------------------ -- Called by the servlet container to indicate to a servlet that the servlet -- is being placed into service. overriding procedure Initialize (Server : in out Verify_Key_Servlet; Context : in Servlet.Core.Servlet_Registry'Class) is use Servlet.Core; use Ada.Strings.Unbounded; URI : constant String := Context.Get_Init_Parameter (VERIFY_FILTER_REDIRECT_PARAM); begin Server.Invalid_Key_URI := To_Unbounded_String (URI); if Uri'Length = 0 then Log.Error ("Missing configuration for {0}.{1}", Server.Get_Name, VERIFY_FILTER_REDIRECT_PARAM); end if; Server.Change_Password_Uri := Context.Get_Init_Parameter (VERIFY_FILTER_CHANGE_PASSWORD_PARAM); end Initialize; -- ------------------------------ -- Filter a request which contains an access key and verify that the -- key is valid and identifies a user. Once the user is known, create -- a session and setup the user principal. -- -- If the access key is missing or invalid, redirect to the -- <b>Invalid_Key_URI</b> associated with the filter. -- ------------------------------ overriding procedure Do_Get (Server : in Verify_Key_Servlet; Request : in out Servlet.Requests.Request'Class; Response : in out Servlet.Responses.Response'Class) is use type AWA.Users.Principals.Principal_Access; use Ada.Strings.Unbounded; Key : constant String := Request.Get_Path_Parameter (1); Manager : constant Users.Services.User_Service_Access := Users.Modules.Get_User_Manager; Principal : AWA.Users.Principals.Principal_Access; Session : Servlet.Sessions.Session := Request.Get_Session (Create => True); begin Log.Info ("Verify access key '{0}'", Key); Manager.Verify_User (Key => Key, IpAddr => "", Principal => Principal); if Principal = null then declare URI : constant String := To_String (Server.Change_Password_Uri) & Key; begin Log.Info ("Access key verified but no password, redirecting to {0}", URI); Response.Send_Redirect (Location => URI); return; end; end if; Session.Set_Principal (Principal.all'Access); -- Request is authorized, redirect to the final page. Response.Send_Redirect (Location => Server.Get_Redirect_URL (Request)); exception when AWA.Users.Services.Not_Found => declare URI : constant String := To_String (Server.Invalid_Key_URI); begin Log.Info ("Invalid access key '{0}', redirecting to {1}", Key, URI); Session.Set_Attribute (AUTH_ERROR_ATTRIBUTE, UBO.To_Object (MESSAGE_INVALID_KEY)); Response.Send_Redirect (Location => URI); end; end Do_Get; end AWA.Users.Servlets;
sparre/aShell
Ada
596
adb
with Shell, Ada.Text_IO; procedure Test_Pipe_Output_To_String is use Ada.Text_IO; begin Put_Line ("Start test."); New_Line (2); declare use Shell; ls_Pipe : constant Shell.Pipe := To_Pipe; ls : Shell.Process := Start (Program => "ls", Arguments => (1 => +"-alh"), Output => ls_Pipe); begin delay 1.0; Put_Line ("'" & To_String (ls_Pipe) & "'"); end; New_Line (2); Put_Line ("End test."); end Test_Pipe_Output_To_String;
reznikmm/matreshka
Ada
4,981
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- Testsuite Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2010-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 XML.SAX.Input_Sources.Strings is pragma Preelaborate; type String_Input_Source is limited new SAX_Input_Source with private; not overriding procedure Set_String (Self : in out String_Input_Source; String : League.Strings.Universal_String); overriding function Public_Id (Self : String_Input_Source) return League.Strings.Universal_String; overriding procedure Next (Self : in out String_Input_Source; Buffer : in out not null Matreshka.Internals.Strings.Shared_String_Access; End_Of_Data : out Boolean); overriding procedure Reset (Self : in out String_Input_Source; Version : League.Strings.Universal_String; Encoding : League.Strings.Universal_String; Rescan : out Boolean; Success : out Boolean); not overriding procedure Set_Public_Id (Self : in out String_Input_Source; Id : League.Strings.Universal_String); overriding procedure Set_System_Id (Self : in out String_Input_Source; Id : League.Strings.Universal_String); overriding procedure Set_Version (Self : in out String_Input_Source; Version : League.Strings.Universal_String); overriding function System_Id (Self : String_Input_Source) return League.Strings.Universal_String; private type String_Input_Source is limited new SAX_Input_Source with record String : League.Strings.Universal_String; Public_Id : League.Strings.Universal_String; System_Id : League.Strings.Universal_String; Version : League.Strings.Universal_String; end record; end XML.SAX.Input_Sources.Strings;
persan/protobuf-ada
Ada
4,473
ads
-- Generated by the protocol buffer compiler. DO NOT EDIT! -- source: message.proto pragma Ada_2012; with Protocol_Buffers.Message; with Protocol_Buffers.Wire_Format; with Protocol_Buffers.IO.Coded_Output_Stream; with Protocol_Buffers.IO.Coded_Input_Stream; with Protocol_Buffers.Generated_Message_Utilities; with Ada.Streams.Stream_IO; with Ada.Strings.Unbounded; package Message is use type Protocol_Buffers.Wire_Format.TMP_STRING; use type Protocol_Buffers.Wire_Format.TMP_UNSIGNED_BYTE; use type Protocol_Buffers.Wire_Format.TMP_UNSIGNED_INTEGER; use type Protocol_Buffers.Wire_Format.TMP_UNSIGNED_LONG; use type Protocol_Buffers.Wire_Format.TMP_DOUBLE; use type Protocol_Buffers.Wire_Format.TMP_FLOAT; use type Protocol_Buffers.Wire_Format.TMP_BOOLEAN; use type Protocol_Buffers.Wire_Format.TMP_INTEGER; use type Protocol_Buffers.Wire_Format.TMP_LONG; use type Protocol_Buffers.Wire_Format.TMP_FIELD_TYPE; use type Protocol_Buffers.Wire_Format.TMP_WIRE_TYPE; use type Protocol_Buffers.Wire_Format.TMP_OBJECT_SIZE; package Person is type Has_Bits_Array_Type is array (Protocol_Buffers.Wire_Format.TMP_UNSIGNED_INTEGER range <>) of Protocol_Buffers.Wire_Format.TMP_UNSIGNED_INTEGER; type Instance is new Protocol_Buffers.Message.Instance with private; --------------------------------------------------------------------------- -- Inherited functions and procedures from Protocol_Buffers.Message ------- --------------------------------------------------------------------------- overriding procedure Clear (The_Message : in out Person.Instance); overriding procedure Serialize_With_Cached_Sizes (The_Message : in Person.Instance; The_Coded_Output_Stream : in Protocol_Buffers.IO.Coded_Output_Stream.Instance); overriding procedure Merge_Partial_From_Coded_Input_Stream (The_Message : in out Person.Instance; The_Coded_Input_Stream : in Protocol_Buffers.IO.Coded_Input_Stream.Instance); overriding procedure Merge (To : in out Person.Instance; From : in Person.Instance); overriding procedure Copy (To : in out Person.Instance; From : in Person.Instance); overriding function Get_Type_Name (The_Message : in Person.Instance) return Protocol_Buffers.Wire_Format.TMP_STRING; overriding function Byte_Size (The_Message : in out Person.Instance) return Protocol_Buffers.Wire_Format.TMP_OBJECT_SIZE; overriding function Get_Cached_Size (The_Message : in Person.Instance) return Protocol_Buffers.Wire_Format.TMP_OBJECT_SIZE; overriding function Is_Initialized (The_Message : in Person.Instance) return Boolean; --------------------------------------------------------------------------- -- Field accessor declarations -------------------------------------------- --------------------------------------------------------------------------- -- required int32 id = 1; function Has_Id (The_Message : in Person.Instance) return Boolean; procedure Clear_Id (The_Message : in out Person.Instance); function Id (The_Message : in Person.Instance) return Protocol_Buffers.Wire_Format.TMP_INTEGER; procedure Set_Id (The_Message : in out Person.Instance; value : in Protocol_Buffers.Wire_Format.TMP_INTEGER); -- optional string name = 2; function Has_Name (The_Message : in Person.Instance) return Boolean; procedure Clear_Name (The_Message : in out Person.Instance); function Name (The_Message : in Person.Instance) return Protocol_Buffers.Wire_Format.TMP_STRING; procedure Set_Name (The_Message : in out Person.Instance; Value : in Protocol_Buffers.Wire_Format.TMP_STRING); private type Instance is new Protocol_Buffers.Message.Instance with record Id : Protocol_Buffers.Wire_Format.TMP_INTEGER := 0; Name : Ada.Strings.Unbounded.Unbounded_String; Has_Bits : Has_Bits_Array_Type (0 .. (2 + 31) / 32) := (others => 0); Cached_Size : Protocol_Buffers.Wire_Format.TMP_OBJECT_SIZE := 0; end record; procedure Set_Has_Id (The_Message : in out Person.Instance); procedure Clear_Has_Id (The_Message : in out Person.Instance); procedure Set_Has_Name (The_Message : in out Person.Instance); procedure Clear_Has_Name (The_Message : in out Person.Instance); end Person; end Message;
AdaCore/training_material
Ada
11,873
adb
------------------------------------------------------------------------------ -- -- -- Hardware Abstraction Layer for STM32 Targets -- -- -- -- Copyright (C) 2014, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- 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 STM32F4.RCC; use STM32F4.RCC; with Ada.Real_Time; use Ada.Real_Time; package body STM32F4.I2C is subtype I2C_SR1_Flag is I2C_Status_Flag range Start_Bit .. SMB_Alert; subtype I2C_SR2_Flag is I2C_Status_Flag range Master_Slave_Mode .. Dual_Flag; SR1_Flag_Pos : constant array (I2C_SR1_Flag) of Natural := (0, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 14, 15); SR2_Flag_Pos : constant array (I2C_SR2_Flag) of Natural := (0, 1, 2, 4, 5, 6, 7); --------------- -- Configure -- --------------- procedure Configure (Port : in out I2C_Port; Clock_Speed : Word; Mode : I2C_Device_Mode; Duty_Cycle : I2C_Duty_Cycle; Own_Address : Half_Word; Ack : I2C_Acknowledgement; Ack_Address : I2C_Acknowledge_Address) is CR2, CR1 : Half_Word; CCR : Half_Word := 0; PCLK1 : constant Word := System_Clock_Frequencies.PCLK1; Freq_Range : constant Half_Word := Half_Word (PCLK1 / 1_000_000); begin -- Load CR2 and clear FREQ CR2 := Port.CR2 and (not CR2_FREQ); Port.CR2 := CR2 or Freq_Range; Set_State (Port, Disabled); if Clock_Speed <= 100_000 then CCR := Half_Word (PCLK1 / (Clock_Speed * 2)); if CCR < 4 then CCR := 4; end if; Port.TRISE := Freq_Range + 1; else -- Fast mode if Duty_Cycle = DutyCycle_2 then CCR := Half_Word (PCLK1 / (Clock_Speed * 3)); else CCR := Half_Word (PCLK1 / (Clock_Speed * 25)); CCR := CCR or DutyCycle_16_9'Enum_Rep; end if; if (CCR and CCR_CCR) = 0 then CCR := 1; end if; CCR := CCR or CCR_FS; Port.TRISE := (Freq_Range * 300) / 1000 + 1; end if; Port.CCR := CCR; Set_State (Port, Enabled); CR1 := Port.CR1; CR1 := CR1 and CR1_Clear_Mask; CR1 := CR1 or Mode'Enum_Rep or Ack'Enum_Rep; Port.CR1 := CR1; Port.OAR1 := Ack_Address'Enum_Rep or Own_Address'Enum_Rep; end Configure; --------------- -- Set_State -- --------------- procedure Set_State (Port : in out I2C_Port; State : I2C_State) is begin if State = Enabled then Port.CR1 := Port.CR1 or CR1_PE; else Port.CR1 := Port.CR1 and (not CR1_PE); end if; end Set_State; ------------------ -- Port_Enabled -- ------------------ function Port_Enabled (Port : I2C_Port) return Boolean is begin return (Port.CR1 and CR1_PE) /= 0; end Port_Enabled; -------------------- -- Generate_Start -- -------------------- procedure Generate_Start (Port : in out I2C_Port; State : I2C_State) is begin if State = Enabled then Port.CR1 := Port.CR1 or CR1_START; else Port.CR1 := Port.CR1 and (not CR1_START); end if; end Generate_Start; ------------------- -- Generate_Stop -- ------------------- procedure Generate_Stop (Port : in out I2C_Port; State : I2C_State) is begin if State = Enabled then Port.CR1 := Port.CR1 or CR1_STOP; else Port.CR1 := Port.CR1 and (not CR1_STOP); end if; end Generate_Stop; -------------------- -- Send_7Bit_Addr -- -------------------- procedure Send_7Bit_Address (Port : in out I2C_Port; Address : Byte; Direction : I2C_Direction) is Destination : Half_Word := Half_Word (Address); begin if Direction = Receiver then Destination := Destination or I2C_OAR1_ADD0; else Destination := Destination and (not I2C_OAR1_ADD0); end if; Port.DR := Destination; end Send_7Bit_Address; -------------- -- Get_Flag -- -------------- function Status (Port : I2C_Port; Flag : I2C_Status_Flag) return Boolean is begin if Flag in I2C_SR1_Flag then return (Port.SR1 and (2**SR1_Flag_Pos (Flag))) /= 0; else return (Port.SR2 and (2**SR2_Flag_Pos (Flag))) /= 0; end if; end Status; ---------------- -- Clear_Flag -- ---------------- procedure Clear_Status (Port : in out I2C_Port; Target : Clearable_I2C_Status_Flag) is begin -- note that only a subset of the status flags can be cleared Port.SR1 := not (2 ** SR1_Flag_Pos (Target)); -- we do not logically AND status bits end Clear_Status; ------------------------------- -- Clear_Address_Sent_Status -- ------------------------------- procedure Clear_Address_Sent_Status (Port : in out I2C_Port) is Temp : Half_Word with Volatile; ADDR_Mask : constant Half_Word := 2 ** SR1_Flag_Pos (Address_Sent); STOP_Mask : constant Half_Word := 2 ** SR1_Flag_Pos (Stop_Detection); begin -- To clear the ADDR flag we have to read SR2 after reading SR1. -- However, per the RM, section 27.6.7, page 850, we should only read -- SR2 if the Address_Sent flag is set in SR1, or if the Stop_Detection -- flag is cleared, because the Address_Sent flag could be set in -- the middle of reading SR1 and SR2 but will be cleared by the -- read sequence nonetheless. Temp := Port.SR1; if ((Temp and ADDR_Mask) = 1) or ((Temp and STOP_Mask) = 0) then Temp := Port.SR2; end if; end Clear_Address_Sent_Status; --------------------------------- -- Clear_Stop_Detection_Status -- --------------------------------- procedure Clear_Stop_Detection_Status (Port : in out I2C_Port) is Temp : Half_Word with Volatile, Unreferenced; begin Temp := Port.SR1; Port.CR1 := Port.CR1 or CR1_PE; end Clear_Stop_Detection_Status; ------------------- -- Wait_For_Flag -- ------------------- procedure Wait_For_State (Port : I2C_Port; Queried : I2C_Status_Flag; State : I2C_State; Time_Out : Natural := 1_000_000) is Expected : constant Boolean := State = Enabled; Deadline : constant Time := Clock + Milliseconds (Time_Out); begin while Status (Port, Queried) /= Expected loop if Clock >= Deadline then raise I2C_Timeout; end if; end loop; end Wait_For_State; --------------- -- Send_Data -- --------------- procedure Send_Data (Port : in out I2C_Port; Data : Byte) is begin Port.DR := Half_Word (Data); end Send_Data; --------------- -- Read_Data -- --------------- function Read_Data (Port : I2C_Port) return Byte is begin return Byte (Port.DR); end Read_Data; -------------------- -- Set_Ack_Config -- -------------------- procedure Set_Ack_Config (Port : in out I2C_Port; State : I2C_State) is begin if State = Enabled then Port.CR1 := Port.CR1 or CR1_ACK; else Port.CR1 := Port.CR1 and (not CR1_ACK); end if; end Set_Ack_Config; --------------------- -- Set_Nack_Config -- --------------------- procedure Set_Nack_Config (Port : in out I2C_Port; Pos : I2C_Nack_Position) is begin if Pos = Next then Port.CR1 := Port.CR1 or CR1_POS; else Port.CR1 := Port.CR1 and (not CR1_POS); end if; end Set_Nack_Config; ----------- -- Start -- ----------- procedure Start (Port : in out I2C_Port; Address : Byte; Direction : I2C_Direction) is begin Generate_Start (Port, Enabled); Wait_For_State (Port, Start_Bit, Enabled); Set_Ack_Config (Port, Enabled); Send_7Bit_Address (Port, Address, Direction); while not Status (Port, Address_Sent) loop if Status (Port, Ack_Failure) then raise Program_Error; end if; end loop; Clear_Address_Sent_Status (Port); end Start; -------------- -- Read_Ack -- -------------- function Read_Ack (Port : in out I2C_Port) return Byte is begin Set_Ack_Config (Port, Enabled); Wait_For_State (Port, Rx_Data_Register_Not_Empty, Enabled); return Read_Data (Port); end Read_Ack; --------------- -- Read_Nack -- --------------- function Read_Nack (Port : in out I2C_Port) return Byte is begin Set_Ack_Config (Port, Disabled); Generate_Stop (Port, Enabled); Wait_For_State (Port, Rx_Data_Register_Not_Empty, Enabled); return Read_Data (Port); end Read_Nack; ----------- -- Write -- ----------- procedure Write (Port : in out I2C_Port; Data : Byte) is begin Wait_For_State (Port, Tx_Data_Register_Empty, Enabled); Send_Data (Port, Data); while not Status (Port, Tx_Data_Register_Empty) or else not Status (Port, Byte_Transfer_Finished) loop null; end loop; end Write; ---------- -- Stop -- ---------- procedure Stop (Port : in out I2C_Port) is begin Generate_Stop (Port, Enabled); end Stop; ---------------------- -- Enable_Interrupt -- ---------------------- procedure Enable_Interrupt (Port : in out I2C_Port; Source : I2C_Interrupt) is begin Port.CR2 := Port.CR2 or Source'Enum_Rep; end Enable_Interrupt; ----------------------- -- Disable_Interrupt -- ----------------------- procedure Disable_Interrupt (Port : in out I2C_Port; Source : I2C_Interrupt) is begin Port.CR2 := Port.CR2 and not Source'Enum_Rep; end Disable_Interrupt; ------------- -- Enabled -- ------------- function Enabled (Port : in out I2C_Port; Source : I2C_Interrupt) return Boolean is begin return (Port.CR2 and Source'Enum_Rep) = Source'Enum_Rep; end Enabled; end STM32F4.I2C;
tum-ei-rcs/StratoX
Ada
239
adb
with unav; with Units; use Units; with Text_IO; use Text_IO; procedure main with SPARK_Mode is distance : Length_Type; begin distance := unav.Get_Distance; Put_Line ("distance=" & Float'Image(Float(distance)) & " m"); end main;
reznikmm/matreshka
Ada
4,615
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Text.Select_Page_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Text_Select_Page_Attribute_Node is begin return Self : Text_Select_Page_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_Select_Page_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Select_Page_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Text_URI, Matreshka.ODF_String_Constants.Select_Page_Attribute, Text_Select_Page_Attribute_Node'Tag); end Matreshka.ODF_Text.Select_Page_Attributes;
ytomino/gnat4drake
Ada
319
ads
pragma License (Unrestricted); with Ada.Characters.Handling; package GNAT.Case_Util is pragma Preelaborate; -- Ada.Characters.Handling is not pure. function To_Lower (A : Character) return Character renames Ada.Characters.Handling.To_Lower; procedure To_Lower (A : in out String); end GNAT.Case_Util;
charlie5/cBound
Ada
1,410
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with xcb.xcb_glx_generic_error_t; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_glx_bad_current_window_error_t is -- Item -- subtype Item is xcb.xcb_glx_generic_error_t.Item; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_glx_bad_current_window_error_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_bad_current_window_error_t.Item, Element_Array => xcb.xcb_glx_bad_current_window_error_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_bad_current_window_error_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_bad_current_window_error_t.Pointer, Element_Array => xcb.xcb_glx_bad_current_window_error_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_glx_bad_current_window_error_t;
silky/synth
Ada
65,346
adb
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../License.txt with Ada.Command_Line; with Ada.Strings.Fixed; with PortScan.Ops; with PortScan.Packages; with PortScan.Buildcycle.Ports; with PortScan.Buildcycle.Pkgsrc; with Signals; with Unix; package body PortScan.Pilot is package CLI renames Ada.Command_Line; package ASF renames Ada.Strings.Fixed; package OPS renames PortScan.Ops; package PKG renames PortScan.Packages; package CYC renames PortScan.Buildcycle; package FPC renames PortScan.Buildcycle.Ports; package NPS renames PortScan.Buildcycle.Pkgsrc; package SIG renames Signals; --------------------- -- store_origins -- --------------------- function store_origins return Boolean is function trimmed_catport (S : String) return String; function trimmed_catport (S : String) return String is last : constant Natural := S'Last; begin if S (last) = '/' then return S (S'First .. last - 1); else return S (S'First .. last); end if; end trimmed_catport; begin if CLI.Argument_Count <= 1 then return False; end if; portlist.Clear; if CLI.Argument_Count = 2 then -- Check if this is a file declare Arg2 : constant String := trimmed_catport (CLI.Argument (2)); begin if AD.Exists (Arg2) then return valid_file (Arg2); end if; if valid_catport (catport => Arg2) then if Arg2 /= pkgng then plinsert (Arg2, 2); end if; return True; else TIO.Put_Line (badport & Arg2); return False; end if; end; end if; for k in 2 .. CLI.Argument_Count loop declare Argk : constant String := trimmed_catport (CLI.Argument (k)); begin if valid_catport (catport => Argk) then if Argk /= pkgng then plinsert (Argk, k); end if; else TIO.Put_Line (badport & "'" & Argk & "'" & k'Img); return False; end if; end; end loop; return True; end store_origins; ------------------------------- -- prerequisites_available -- ------------------------------- function prerequisites_available return Boolean is begin case software_framework is when ports_collection => return build_pkg8_as_necessary; when pkgsrc => return build_pkgsrc_prerequisites; end case; end prerequisites_available; ------------------------------- -- build_pkg8_as_necessary -- ------------------------------- function build_pkg8_as_necessary return Boolean is pkg_good : Boolean; good_scan : Boolean; stop_now : Boolean; selection : PortScan.port_id; result : Boolean := True; begin OPS.initialize_hooks; REP.initialize (testmode => False, num_cores => PortScan.cores_available); REP.launch_slave (id => PortScan.scan_slave, opts => noprocs); good_scan := PortScan.scan_single_port (catport => pkgng, always_build => False, fatal => stop_now); if good_scan then PortScan.set_build_priority; else TIO.Put_Line ("Unexpected pkg(8) scan failure!"); result := False; goto clean_exit; end if; PKG.limited_sanity_check (repository => JT.USS (PM.configuration.dir_repository), dry_run => False, suppress_remote => True); if SIG.graceful_shutdown_requested or else PKG.queue_is_empty then goto clean_exit; end if; CYC.initialize (test_mode => False, jail_env => REP.jail_environment); selection := OPS.top_buildable_port; if SIG.graceful_shutdown_requested or else selection = port_match_failed then goto clean_exit; end if; TIO.Put ("Stand by, building pkg(8) first ... "); pkg_good := FPC.build_package (id => PortScan.scan_slave, sequence_id => selection); OPS.run_hook_after_build (pkg_good, selection); if not pkg_good then TIO.Put_Line ("Failed!!" & bailing); result := False; goto clean_exit; end if; TIO.Put_Line ("done!"); <<clean_exit>> if SIG.graceful_shutdown_requested then TIO.Put_Line (shutreq); result := False; end if; REP.destroy_slave (id => PortScan.scan_slave, opts => noprocs); REP.finalize; reset_ports_tree; prescan_ports_tree (JT.USS (PM.configuration.dir_portsdir)); return result; end build_pkg8_as_necessary; ---------------------------------- -- build_pkgsrc_prerequisites -- ---------------------------------- function build_pkgsrc_prerequisites return Boolean is function scan_it (the_catport : String) return Boolean; function build_it (desc : String) return Boolean; mk_files : constant String := "pkgtools/bootstrap-mk-files"; cp_bmake : constant String := "devel/bmake"; cp_digest : constant String := "pkgtools/digest"; result : Boolean := True; function scan_it (the_catport : String) return Boolean is good_scan : Boolean; stop_now : Boolean; begin good_scan := PortScan.scan_single_port (catport => the_catport, always_build => False, fatal => stop_now); if good_scan then PortScan.set_build_priority; else TIO.Put_Line ("Unexpected " & the_catport & " scan failure!"); return False; end if; PKG.limited_sanity_check (repository => JT.USS (PM.configuration.dir_repository), dry_run => False, suppress_remote => True); if SIG.graceful_shutdown_requested then return False; end if; return True; end scan_it; function build_it (desc : String) return Boolean is pkg_good : Boolean; selection : PortScan.port_id; begin CYC.initialize (test_mode => False, jail_env => REP.jail_environment); selection := OPS.top_buildable_port; if SIG.graceful_shutdown_requested or else selection = port_match_failed then return False; end if; TIO.Put ("Stand by, building " & desc & " package ... "); pkg_good := NPS.build_package (id => PortScan.scan_slave, sequence_id => selection); OPS.run_hook_after_build (pkg_good, selection); if not pkg_good then TIO.Put_Line ("Failed!!" & bailing); return False; end if; TIO.Put_Line ("done!"); return True; end build_it; begin OPS.initialize_hooks; REP.initialize (testmode => False, num_cores => PortScan.cores_available); REP.launch_slave (id => PortScan.scan_slave, opts => npsboot); if not PLAT.host_pkgsrc_mk_install (id => PortScan.scan_slave) or else not PLAT.host_pkgsrc_bmake_install (id => PortScan.scan_slave) or else not PLAT.host_pkgsrc_pkg8_install (id => PortScan.scan_slave) then TIO.Put_Line ("Failed to install programs from host system."); result := False; goto clean_exit; end if; result := scan_it (mk_files); if not result then goto clean_exit; end if; if not PKG.queue_is_empty then -- the mk files package does not exist or requires rebuilding result := build_it ("mk files"); if not result then goto clean_exit; end if; end if; reset_ports_tree; result := scan_it (cp_bmake); if not result then goto clean_exit; end if; if not PKG.queue_is_empty then -- the bmake package does not exist or requires rebuilding result := build_it ("bmake"); if not result then goto clean_exit; end if; end if; reset_ports_tree; result := scan_it (cp_digest); if not result then goto clean_exit; end if; if not PKG.queue_is_empty then -- the digest package does not exist or requires rebuilding result := build_it ("digest"); if not result then goto clean_exit; end if; end if; reset_ports_tree; result := scan_it (pkgng); if not result then goto clean_exit; end if; if not PKG.queue_is_empty then -- the pkg(8) package does not exist or requires rebuilding result := build_it ("pkg(8)"); end if; <<clean_exit>> if SIG.graceful_shutdown_requested then TIO.Put_Line (shutreq); result := False; end if; REP.destroy_slave (id => PortScan.scan_slave, opts => noprocs); REP.finalize; reset_ports_tree; prescan_ports_tree (JT.USS (PM.configuration.dir_portsdir)); return result; end build_pkgsrc_prerequisites; ---------------------------------- -- scan_stack_of_single_ports -- ---------------------------------- function scan_stack_of_single_ports (testmode : Boolean; always_build : Boolean := False) return Boolean is procedure scan (plcursor : portkey_crate.Cursor); successful : Boolean := True; just_stop_now : Boolean; procedure scan (plcursor : portkey_crate.Cursor) is origin : constant String := JT.USS (portkey_crate.Key (plcursor)); begin if not successful then return; end if; if origin = pkgng then -- we've already built pkg(8) if we get here, just skip it return; end if; if SIG.graceful_shutdown_requested then successful := False; return; end if; if not PortScan.scan_single_port (origin, always_build, just_stop_now) then if just_stop_now then successful := False; else TIO.Put_Line ("Scan of " & origin & " failed" & PortScan.obvious_problem (JT.USS (PM.configuration.dir_portsdir), origin) & ", it will not be considered."); end if; end if; end scan; begin REP.initialize (testmode, PortScan.cores_available); REP.launch_slave (id => PortScan.scan_slave, opts => noprocs); if SIG.graceful_shutdown_requested then goto clean_exit; end if; if not PLAT.standalone_pkg8_install (PortScan.scan_slave) then TIO.Put_Line ("Failed to install pkg(8) scanner" & bailing); successful := False; goto clean_exit; end if; portlist.Iterate (Process => scan'Access); if successful then PortScan.set_build_priority; if PKG.queue_is_empty then successful := False; TIO.Put_Line ("There are no valid ports to build." & bailing); end if; end if; <<clean_exit>> if SIG.graceful_shutdown_requested then successful := False; TIO.Put_Line (shutreq); end if; REP.destroy_slave (id => PortScan.scan_slave, opts => noprocs); REP.finalize; return successful; end scan_stack_of_single_ports; --------------------------------- -- sanity_check_then_prefail -- --------------------------------- function sanity_check_then_prefail (delete_first : Boolean := False; dry_run : Boolean := False) return Boolean is procedure force_delete (plcursor : portkey_crate.Cursor); ptid : PortScan.port_id; num_skipped : Natural; block_remote : Boolean := True; update_external_repo : constant String := host_pkg8 & " update --quiet --repository "; no_packages : constant String := "No prebuilt packages will be used as a result."; procedure force_delete (plcursor : portkey_crate.Cursor) is origin : JT.Text := portkey_crate.Key (plcursor); pndx : constant port_index := ports_keys.Element (origin); tball : constant String := JT.USS (PM.configuration.dir_repository) & "/" & JT.USS (all_ports (pndx).package_name); begin if AD.Exists (tball) then AD.Delete_File (tball); end if; end force_delete; begin start_time := CAL.Clock; if delete_first and then not dry_run then portlist.Iterate (Process => force_delete'Access); end if; case software_framework is when ports_collection => if not PKG.limited_cached_options_check then -- Error messages emitted by function return False; end if; when pkgsrc => -- There's no analog to cached options on pkgsc. -- We could detect unused settings, but that's it. -- And maybe that should be detected by the framework itself null; end case; if PM.configuration.defer_prebuilt then -- Before any remote operations, find the external repo if PKG.located_external_repository then block_remote := False; -- We're going to use prebuilt packages if available, so let's -- prepare for that case by updating the external repository TIO.Put ("Stand by, updating external repository catalogs ... "); if not Unix.external_command (update_external_repo & PKG.top_external_repository) then TIO.Put_Line ("Failed!"); TIO.Put_Line ("The external repository could not be updated."); TIO.Put_Line (no_packages); block_remote := True; else TIO.Put_Line ("done."); end if; else TIO.Put_Line ("The external repository does not seem to be " & "configured."); TIO.Put_Line (no_packages); end if; end if; OPS.run_start_hook; PKG.limited_sanity_check (repository => JT.USS (PM.configuration.dir_repository), dry_run => dry_run, suppress_remote => block_remote); bld_counter := (OPS.queue_length, 0, 0, 0, 0); if dry_run then return True; end if; if SIG.graceful_shutdown_requested then TIO.Put_Line (shutreq); return False; end if; OPS.delete_existing_web_history_files; start_logging (total); start_logging (ignored); start_logging (skipped); start_logging (success); start_logging (failure); loop ptid := OPS.next_ignored_port; exit when ptid = PortScan.port_match_failed; exit when SIG.graceful_shutdown_requested; bld_counter (ignored) := bld_counter (ignored) + 1; TIO.Put_Line (Flog (total), CYC.elapsed_now & " " & OPS.port_name (ptid) & " has been ignored: " & OPS.ignore_reason (ptid)); TIO.Put_Line (Flog (ignored), CYC.elapsed_now & " " & OPS.port_name (ptid) & ": " & OPS.ignore_reason (ptid)); OPS.cascade_failed_build (id => ptid, numskipped => num_skipped, logs => Flog); OPS.record_history_ignored (elapsed => CYC.elapsed_now, origin => OPS.port_name (ptid), reason => OPS.ignore_reason (ptid), skips => num_skipped); bld_counter (skipped) := bld_counter (skipped) + num_skipped; end loop; stop_logging (ignored); TIO.Put_Line (Flog (total), CYC.elapsed_now & " Sanity check complete. " & "Ports remaining to build:" & OPS.queue_length'Img); TIO.Flush (Flog (total)); if SIG.graceful_shutdown_requested then TIO.Put_Line (shutreq); else if OPS.integrity_intact then return True; end if; end if; -- If here, we either got control-C or failed integrity check if not SIG.graceful_shutdown_requested then TIO.Put_Line ("Queue integrity lost! " & bailing); end if; stop_logging (total); stop_logging (skipped); stop_logging (success); stop_logging (failure); return False; end sanity_check_then_prefail; ------------------------ -- perform_bulk_run -- ------------------------ procedure perform_bulk_run (testmode : Boolean) is num_builders : constant builders := PM.configuration.num_builders; show_tally : Boolean := True; begin if PKG.queue_is_empty then TIO.Put_Line ("After inspection, it has been determined that there " & "are no packages that"); TIO.Put_Line ("require rebuilding; the task is therefore complete."); show_tally := False; else REP.initialize (testmode, PortScan.cores_available); CYC.initialize (testmode, REP.jail_environment); OPS.initialize_web_report (num_builders); OPS.initialize_display (num_builders); OPS.parallel_bulk_run (num_builders, Flog); REP.finalize; end if; stop_time := CAL.Clock; stop_logging (total); stop_logging (success); stop_logging (failure); stop_logging (skipped); if show_tally then TIO.Put_Line (LAT.LF & LAT.LF); TIO.Put_Line ("The task is complete. Final tally:"); TIO.Put_Line ("Initial queue size:" & bld_counter (total)'Img); TIO.Put_Line (" packages built:" & bld_counter (success)'Img); TIO.Put_Line (" ignored:" & bld_counter (ignored)'Img); TIO.Put_Line (" skipped:" & bld_counter (skipped)'Img); TIO.Put_Line (" failed:" & bld_counter (failure)'Img); TIO.Put_Line (""); TIO.Put_Line (CYC.log_duration (start_time, stop_time)); TIO.Put_Line ("The build logs can be found at: " & JT.USS (PM.configuration.dir_logs)); end if; end perform_bulk_run; ------------------------------------------- -- verify_desire_to_rebuild_repository -- ------------------------------------------- function verify_desire_to_rebuild_repository return Boolean is answer : Boolean; YN : Character; screen_present : constant Boolean := Unix.screen_attached; begin if not screen_present then return False; end if; if SIG.graceful_shutdown_requested then -- catch previous shutdown request return False; end if; Unix.cone_of_silence (deploy => False); TIO.Put ("Would you like to rebuild the local repository (Y/N)? "); loop TIO.Get_Immediate (YN); case YN is when 'Y' | 'y' => answer := True; exit; when 'N' | 'n' => answer := False; exit; when others => null; end case; end loop; TIO.Put (YN & LAT.LF); Unix.cone_of_silence (deploy => True); return answer; end verify_desire_to_rebuild_repository; ----------------------------------------- -- verify_desire_to_install_packages -- ----------------------------------------- function verify_desire_to_install_packages return Boolean is answer : Boolean; YN : Character; begin Unix.cone_of_silence (deploy => False); TIO.Put ("Would you like to upgrade your system with the new " & "packages now (Y/N)? "); loop TIO.Get_Immediate (YN); case YN is when 'Y' | 'y' => answer := True; exit; when 'N' | 'n' => answer := False; exit; when others => null; end case; end loop; TIO.Put (YN & LAT.LF); Unix.cone_of_silence (deploy => True); return answer; end verify_desire_to_install_packages; ----------------------------- -- fully_scan_ports_tree -- ----------------------------- function fully_scan_ports_tree return Boolean is goodresult : Boolean; begin PortScan.reset_ports_tree; REP.initialize (testmode => False, num_cores => PortScan.cores_available); REP.launch_slave (id => PortScan.scan_slave, opts => noprocs); case software_framework is when ports_collection => null; when pkgsrc => if not PLAT.standalone_pkg8_install (PortScan.scan_slave) then TIO.Put_Line ("Full Tree Scan: Failed to bootstrap builder"); end if; end case; goodresult := PortScan.scan_entire_ports_tree (JT.USS (PM.configuration.dir_portsdir)); REP.destroy_slave (id => PortScan.scan_slave, opts => noprocs); REP.finalize; if goodresult then PortScan.set_build_priority; return True; else if SIG.graceful_shutdown_requested then TIO.Put_Line (shutreq); else TIO.Put_Line ("Failed to scan ports tree " & bailing); end if; return False; end if; end fully_scan_ports_tree; --------------------------------- -- rebuild_local_respository -- --------------------------------- function rebuild_local_respository (remove_invalid_packages : Boolean) return Boolean is repo : constant String := JT.USS (PM.configuration.dir_repository); main : constant String := JT.USS (PM.configuration.dir_packages); xz_meta : constant String := main & "/meta.txz"; xz_digest : constant String := main & "/digests.txz"; xz_pkgsite : constant String := main & "/packagesite.txz"; bs_error : constant String := "Rebuild Repository: Failed to bootstrap builder"; build_res : Boolean; begin if SIG.graceful_shutdown_requested then -- In case it was previously requested return False; end if; if remove_invalid_packages then REP.initialize (testmode => False, num_cores => PortScan.cores_available); REP.launch_slave (id => PortScan.scan_slave, opts => noprocs); case software_framework is when ports_collection => null; when pkgsrc => if not PLAT.standalone_pkg8_install (PortScan.scan_slave) then TIO.Put_Line (bs_error); end if; end case; PKG.preclean_repository (repo); REP.destroy_slave (id => PortScan.scan_slave, opts => noprocs); REP.finalize; if SIG.graceful_shutdown_requested then TIO.Put_Line (shutreq); return False; end if; end if; TIO.Put ("Stand by, recursively scanning"); if Natural (portlist.Length) = 1 then TIO.Put (" 1 port"); else TIO.Put (portlist.Length'Img & " ports"); end if; TIO.Put_Line (" serially."); for k in dim_all_ports'Range loop all_ports (k).deletion_due := False; end loop; PortScan.reset_ports_tree; if scan_stack_of_single_ports (testmode => False) then PKG.limited_sanity_check (repository => repo, dry_run => False, suppress_remote => True); if SIG.graceful_shutdown_requested then TIO.Put_Line (shutreq); return False; end if; else return False; end if; if AD.Exists (xz_meta) then AD.Delete_File (xz_meta); end if; if AD.Exists (xz_digest) then AD.Delete_File (xz_digest); end if; if AD.Exists (xz_pkgsite) then AD.Delete_File (xz_pkgsite); end if; TIO.Put_Line ("Packages validated, rebuilding local repository."); REP.initialize (testmode => False, num_cores => PortScan.cores_available); REP.launch_slave (id => PortScan.scan_slave, opts => noprocs); case software_framework is when ports_collection => null; when pkgsrc => if not PLAT.standalone_pkg8_install (PortScan.scan_slave) then TIO.Put_Line (bs_error); end if; end case; if valid_signing_command then build_res := REP.build_repository (id => PortScan.scan_slave, sign_command => signing_command); elsif acceptable_RSA_signing_support then build_res := REP.build_repository (PortScan.scan_slave); else build_res := False; end if; REP.destroy_slave (id => PortScan.scan_slave, opts => noprocs); REP.finalize; if build_res then TIO.Put_Line ("Local repository successfully rebuilt"); return True; else TIO.Put_Line ("Failed to rebuild repository" & bailing); return False; end if; end rebuild_local_respository; ------------------ -- valid_file -- ------------------ function valid_file (path : String) return Boolean is handle : TIO.File_Type; good : Boolean; total : Natural := 0; begin TIO.Open (File => handle, Mode => TIO.In_File, Name => path); good := True; while not TIO.End_Of_File (handle) loop declare line : constant String := JT.trim (TIO.Get_Line (handle)); begin if not JT.IsBlank (line) then if valid_catport (line) then plinsert (line, total); total := total + 1; else TIO.Put_Line (badport & line); good := False; exit; end if; end if; end; end loop; TIO.Close (handle); return (total > 0) and then good; exception when others => return False; end valid_file; --------------------- -- valid_catport -- --------------------- function valid_catport (catport : String) return Boolean is use type AD.File_Kind; begin if catport'Length = 0 then return False; end if; if catport (catport'First) = '/' then -- Invalid case where catport starts with "/" will cause an -- exception later as "cat" would be unexpectedly empty. return False; end if; if JT.contains (catport, "/") then declare cat : constant String := JT.part_1 (catport); port : constant String := JT.part_2 (catport); path1 : constant String := JT.USS (PM.configuration.dir_portsdir) & "/" & cat; fpath : constant String := path1 & "/" & port; alpha : constant Character := cat (1); begin if not AD.Exists (path1) then return False; end if; if alpha in 'A' .. 'Z' then return False; end if; if path1 = "distfiles" or else path1 = "packages" then return False; end if; if JT.contains (port, "/") then return False; end if; if not AD.Exists (fpath) then return False; end if; if AD.Kind (fpath) = AD.Directory then return True; end if; end; end if; return False; end valid_catport; ---------------- -- plinsert -- ---------------- procedure plinsert (key : String; dummy : Natural) is key2 : JT.Text := JT.SUS (key); ptid : constant PortScan.port_id := PortScan.port_id (dummy); begin if not portlist.Contains (key2) then portlist.Insert (key2, ptid); duplist.Insert (key2, ptid); end if; end plinsert; --------------------- -- start_logging -- --------------------- procedure start_logging (flavor : count_type) is logpath : constant String := JT.USS (PM.configuration.dir_logs) & "/" & logname (flavor); begin if AD.Exists (logpath) then AD.Delete_File (logpath); end if; TIO.Create (File => Flog (flavor), Mode => TIO.Out_File, Name => logpath); if flavor = total then TIO.Put_Line (Flog (flavor), "-=> Chronology of last build <=-"); TIO.Put_Line (Flog (flavor), "Started: " & timestamp (start_time)); TIO.Put_Line (Flog (flavor), "Ports to build:" & PKG.original_queue_size'Img); TIO.Put_Line (Flog (flavor), ""); TIO.Put_Line (Flog (flavor), "Purging any ignored/broken ports " & "first ..."); TIO.Flush (Flog (flavor)); end if; exception when others => raise pilot_log with "Failed to create or delete " & logpath & bailing; end start_logging; -------------------- -- stop_logging -- -------------------- procedure stop_logging (flavor : count_type) is begin if flavor = total then TIO.Put_Line (Flog (flavor), "Finished: " & timestamp (stop_time)); TIO.Put_Line (Flog (flavor), CYC.log_duration (start => start_time, stop => stop_time)); TIO.Put_Line (Flog (flavor), LAT.LF & "---------------------------" & LAT.LF & "-- Final Statistics" & LAT.LF & "---------------------------" & LAT.LF & " Initial queue size:" & bld_counter (total)'Img & LAT.LF & " packages built:" & bld_counter (success)'Img & LAT.LF & " ignored:" & bld_counter (ignored)'Img & LAT.LF & " skipped:" & bld_counter (skipped)'Img & LAT.LF & " failed:" & bld_counter (failure)'Img); end if; TIO.Close (Flog (flavor)); end stop_logging; ----------------------- -- purge_distfiles -- ----------------------- procedure purge_distfiles is type disktype is mod 2**64; procedure scan (plcursor : portkey_crate.Cursor); procedure kill (plcursor : portkey_crate.Cursor); procedure walk (name : String); function display_kmg (number : disktype) return String; abort_purge : Boolean := False; bytes_purged : disktype := 0; distfiles : portkey_crate.Map; rmfiles : portkey_crate.Map; procedure scan (plcursor : portkey_crate.Cursor) is origin : JT.Text := portkey_crate.Key (plcursor); tracker : constant port_id := portkey_crate.Element (plcursor); pndx : constant port_index := ports_keys.Element (origin); distinfo : constant String := JT.USS (PM.configuration.dir_portsdir) & "/" & JT.USS (origin) & "/distinfo"; handle : TIO.File_Type; bookend : Natural; begin TIO.Open (File => handle, Mode => TIO.In_File, Name => distinfo); while not TIO.End_Of_File (handle) loop declare Line : String := TIO.Get_Line (handle); begin if Line (1 .. 4) = "SIZE" then bookend := ASF.Index (Line, ")"); declare S : JT.Text := JT.SUS (Line (7 .. bookend - 1)); begin if not distfiles.Contains (S) then distfiles.Insert (S, tracker); end if; exception when failed : others => TIO.Put_Line ("purge_distfiles::scan: " & JT.USS (S)); TIO.Put_Line (EX.Exception_Information (failed)); end; end if; end; end loop; TIO.Close (handle); exception when others => if TIO.Is_Open (handle) then TIO.Close (handle); end if; end scan; procedure walk (name : String) is procedure walkdir (item : AD.Directory_Entry_Type); procedure print (item : AD.Directory_Entry_Type); uniqid : port_id := 0; leftindent : Natural := JT.SU.Length (PM.configuration.dir_distfiles) + 2; procedure walkdir (item : AD.Directory_Entry_Type) is begin if AD.Simple_Name (item) /= "." and then AD.Simple_Name (item) /= ".." then walk (AD.Full_Name (item)); end if; exception when AD.Name_Error => abort_purge := True; TIO.Put_Line ("walkdir: " & name & " directory does not exist"); end walkdir; procedure print (item : AD.Directory_Entry_Type) is FN : constant String := AD.Full_Name (item); tball : JT.Text := JT.SUS (FN (leftindent .. FN'Last)); begin if not distfiles.Contains (tball) then if not rmfiles.Contains (tball) then uniqid := uniqid + 1; rmfiles.Insert (Key => tball, New_Item => uniqid); bytes_purged := bytes_purged + disktype (AD.Size (FN)); end if; end if; end print; begin AD.Search (name, "*", (AD.Ordinary_File => True, others => False), print'Access); AD.Search (name, "", (AD.Directory => True, others => False), walkdir'Access); exception when AD.Name_Error => abort_purge := True; TIO.Put_Line ("The " & name & " directory does not exist"); when AD.Use_Error => abort_purge := True; TIO.Put_Line ("Searching " & name & " directory is not supported"); when failed : others => abort_purge := True; TIO.Put_Line ("purge_distfiles: Unknown error - directory search"); TIO.Put_Line (EX.Exception_Information (failed)); end walk; function display_kmg (number : disktype) return String is type kmgtype is delta 0.01 digits 6; kilo : constant disktype := 1024; mega : constant disktype := kilo * kilo; giga : constant disktype := kilo * mega; XXX : kmgtype; begin if number > giga then XXX := kmgtype (number / giga); return XXX'Img & " gigabytes"; elsif number > mega then XXX := kmgtype (number / mega); return XXX'Img & " megabytes"; else XXX := kmgtype (number / kilo); return XXX'Img & " kilobytes"; end if; end display_kmg; procedure kill (plcursor : portkey_crate.Cursor) is tarball : String := JT.USS (portkey_crate.Key (plcursor)); path : JT.Text := PM.configuration.dir_distfiles; begin JT.SU.Append (path, "/" & tarball); TIO.Put_Line ("Deleting " & tarball); AD.Delete_File (JT.USS (path)); end kill; begin PortScan.prescan_ports_tree (JT.USS (PM.configuration.dir_portsdir)); TIO.Put ("Scanning the distinfo file of every port in the tree ... "); ports_keys.Iterate (Process => scan'Access); TIO.Put_Line ("done"); walk (name => JT.USS (PM.configuration.dir_distfiles)); if abort_purge then TIO.Put_Line ("Distfile purge operation aborted."); else rmfiles.Iterate (kill'Access); TIO.Put_Line ("Recovered" & display_kmg (bytes_purged)); end if; end purge_distfiles; ------------------------------------------ -- write_pkg_repos_configuration_file -- ------------------------------------------ function write_pkg_repos_configuration_file return Boolean is repdir : constant String := get_repos_dir; target : constant String := repdir & "/00_synth.conf"; pkgdir : constant String := JT.USS (PM.configuration.dir_packages); pubkey : constant String := PM.synth_confdir & "/" & JT.USS (PM.configuration.profile) & "-public.key"; keydir : constant String := PM.synth_confdir & "/keys"; tstdir : constant String := keydir & "/trusted"; autgen : constant String := "# Automatically generated." & LAT.LF; fpfile : constant String := tstdir & "/fingerprint." & JT.USS (PM.configuration.profile); handle : TIO.File_Type; vscmd : Boolean := False; begin if AD.Exists (target) then AD.Delete_File (target); elsif not AD.Exists (repdir) then AD.Create_Path (repdir); end if; TIO.Create (File => handle, Mode => TIO.Out_File, Name => target); TIO.Put_Line (handle, autgen); TIO.Put_Line (handle, "Synth: {"); TIO.Put_Line (handle, " url : file://" & pkgdir & ","); TIO.Put_Line (handle, " priority : 0,"); TIO.Put_Line (handle, " enabled : yes,"); if valid_signing_command then vscmd := True; TIO.Put_Line (handle, " signature_type : FINGERPRINTS,"); TIO.Put_Line (handle, " fingerprints : " & keydir); elsif set_synth_conf_with_RSA then TIO.Put_Line (handle, " signature_type : PUBKEY,"); TIO.Put_Line (handle, " pubkey : " & pubkey); end if; TIO.Put_Line (handle, "}"); TIO.Close (handle); if vscmd then if AD.Exists (fpfile) then AD.Delete_File (fpfile); elsif not AD.Exists (tstdir) then AD.Create_Path (tstdir); end if; TIO.Create (File => handle, Mode => TIO.Out_File, Name => fpfile); TIO.Put_Line (handle, autgen); TIO.Put_Line (handle, "function : sha256"); TIO.Put_Line (handle, "fingerprint : " & profile_fingerprint); TIO.Close (handle); end if; return True; exception when others => TIO.Put_Line ("Error: failed to create " & target); if TIO.Is_Open (handle) then TIO.Close (handle); end if; return False; end write_pkg_repos_configuration_file; --------------------------------- -- upgrade_system_everything -- --------------------------------- procedure upgrade_system_everything (skip_installation : Boolean := False; dry_run : Boolean := False) is command : constant String := host_pkg8 & " upgrade --yes --repository Synth"; query : constant String := host_pkg8 & " query -a %o"; sorry : constant String := "Unfortunately, the system upgrade failed."; begin portlist.Clear; TIO.Put_Line ("Querying system about current package installations."); declare comres : JT.Text; topline : JT.Text; crlen1 : Natural; crlen2 : Natural; uniqid : Natural := 0; begin comres := CYC.generic_system_command (query); crlen1 := JT.SU.Length (comres); loop JT.nextline (lineblock => comres, firstline => topline); crlen2 := JT.SU.Length (comres); exit when crlen1 = crlen2; crlen1 := crlen2; uniqid := uniqid + 1; plinsert (JT.USS (topline), uniqid); end loop; exception when others => TIO.Put_Line (sorry & " (system query)"); return; end; TIO.Put_Line ("Stand by, comparing installed packages against the " & "ports tree."); if prerequisites_available and then scan_stack_of_single_ports (testmode => False) and then sanity_check_then_prefail (delete_first => False, dry_run => dry_run) then if dry_run then display_results_of_dry_run; return; else perform_bulk_run (testmode => False); end if; else if not SIG.graceful_shutdown_requested then TIO.Put_Line (sorry); end if; return; end if; if SIG.graceful_shutdown_requested then return; end if; if rebuild_local_respository (remove_invalid_packages => True) then if not skip_installation then if not Unix.external_command (command) then TIO.Put_Line (sorry); end if; end if; end if; end upgrade_system_everything; ------------------------------ -- upgrade_system_exactly -- ------------------------------ procedure upgrade_system_exactly is procedure build_train (plcursor : portkey_crate.Cursor); base_command : constant String := host_pkg8 & " install --yes --repository Synth"; caboose : JT.Text; procedure build_train (plcursor : portkey_crate.Cursor) is begin JT.SU.Append (caboose, " "); JT.SU.Append (caboose, portkey_crate.Key (plcursor)); end build_train; begin duplist.Iterate (Process => build_train'Access); declare command : constant String := base_command & JT.USS (caboose); begin if not Unix.external_command (command) then TIO.Put_Line ("Unfortunately, the system upgraded failed."); end if; end; end upgrade_system_exactly; ------------------------------- -- insufficient_privileges -- ------------------------------- function insufficient_privileges return Boolean is command : constant String := "/usr/bin/id -u"; result : JT.Text := CYC.generic_system_command (command); topline : JT.Text; begin JT.nextline (lineblock => result, firstline => topline); declare resint : constant Integer := Integer'Value (JT.USS (topline)); begin return (resint /= 0); end; end insufficient_privileges; --------------- -- head_n1 -- --------------- function head_n1 (filename : String) return String is handle : TIO.File_Type; begin TIO.Open (File => handle, Mode => TIO.In_File, Name => filename); if TIO.End_Of_File (handle) then TIO.Close (handle); return ""; end if; declare line : constant String := TIO.Get_Line (handle); begin TIO.Close (handle); return line; end; end head_n1; ----------------------- -- already_running -- ----------------------- function already_running return Boolean is pid : Integer; comres : JT.Text; begin if AD.Exists (pidfile) then declare textpid : constant String := head_n1 (pidfile); command : constant String := "/bin/ps -p " & textpid; begin -- test if valid by converting it (exception if fails) pid := Integer'Value (textpid); -- exception raised by line below if pid not found. comres := CYC.generic_system_command (command); if JT.contains (comres, "synth") then return True; else -- pidfile is obsolete, remove it. AD.Delete_File (pidfile); return False; end if; exception when others => -- pidfile contains garbage, remove it AD.Delete_File (pidfile); return False; end; end if; return False; end already_running; ----------------------- -- destroy_pidfile -- ----------------------- procedure destroy_pidfile is begin if AD.Exists (pidfile) then AD.Delete_File (pidfile); end if; exception when others => null; end destroy_pidfile; ---------------------- -- create_pidfile -- ---------------------- procedure create_pidfile is pidtext : constant String := JT.int2str (Get_PID); handle : TIO.File_Type; begin TIO.Create (File => handle, Mode => TIO.Out_File, Name => pidfile); TIO.Put_Line (handle, pidtext); TIO.Close (handle); end create_pidfile; ------------------------------ -- set_replicant_platform -- ------------------------------ procedure set_replicant_platform is begin REP.set_platform; end set_replicant_platform; ------------------------------------ -- previous_run_mounts_detected -- ------------------------------------ function previous_run_mounts_detected return Boolean is begin return REP.synth_mounts_exist; end previous_run_mounts_detected; ------------------------------------- -- previous_realfs_work_detected -- ------------------------------------- function previous_realfs_work_detected return Boolean is begin return REP.disk_workareas_exist; end previous_realfs_work_detected; --------------------------------------- -- old_mounts_successfully_removed -- --------------------------------------- function old_mounts_successfully_removed return Boolean is begin if REP.clear_existing_mounts then TIO.Put_Line ("Dismounting successful!"); return True; end if; TIO.Put_Line ("The attempt failed. " & "Check for stuck or ongoing processes and kill them."); TIO.Put_Line ("After that, try running Synth again or just manually " & "unmount everything"); TIO.Put_Line ("still attached to " & JT.USS (PM.configuration.dir_buildbase)); return False; end old_mounts_successfully_removed; -------------------------------------------- -- old_realfs_work_successfully_removed -- -------------------------------------------- function old_realfs_work_successfully_removed return Boolean is begin if REP.clear_existing_workareas then TIO.Put_Line ("Directory removal successful!"); return True; end if; TIO.Put_Line ("The attempt to remove the work directories located at "); TIO.Put_Line (JT.USS (PM.configuration.dir_buildbase) & "failed."); TIO.Put_Line ("Please remove them manually before continuing"); return False; end old_realfs_work_successfully_removed; ------------------------- -- synthexec_missing -- ------------------------- function synthexec_missing return Boolean is synthexec : constant String := host_localbase & "/libexec/synthexec"; begin if AD.Exists (synthexec) then return False; end if; TIO.Put_Line (synthexec & " missing!" & bailing); return True; end synthexec_missing; ---------------------------------- -- display_results_of_dry_run -- ---------------------------------- procedure display_results_of_dry_run is procedure print (cursor : ranking_crate.Cursor); listlog : TIO.File_Type; filename : constant String := "/tmp/synth_status_results.txt"; max_lots : constant scanners := get_max_lots; elap_raw : constant String := CYC.log_duration (start => scan_start, stop => scan_stop); elapsed : constant String := elap_raw (elap_raw'First + 10 .. elap_raw'Last); goodlog : Boolean; procedure print (cursor : ranking_crate.Cursor) is id : port_id := ranking_crate.Element (cursor).ap_index; kind : verdiff; diff : constant String := version_difference (id, kind); origin : constant String := get_catport (all_ports (id)); begin case kind is when newbuild => TIO.Put_Line (" N => " & origin); when rebuild => TIO.Put_Line (" R => " & origin); when change => TIO.Put_Line (" U => " & origin & diff); end case; if goodlog then TIO.Put_Line (listlog, origin & diff); end if; end print; begin begin TIO.Create (File => listlog, Mode => TIO.Out_File, Name => filename); goodlog := True; exception when others => goodlog := False; end; TIO.Put_Line ("These are the ports that would be built ([N]ew, " & "[R]ebuild, [U]pgrade):"); rank_queue.Iterate (print'Access); TIO.Put_Line ("Total packages that would be built:" & rank_queue.Length'Img); if goodlog then TIO.Put_Line (listlog, LAT.LF & "------------------------------" & LAT.LF & "-- Statistics" & LAT.LF & "------------------------------" & LAT.LF & " Ports scanned :" & last_port'Img & LAT.LF & " Elapsed time : " & elapsed & LAT.LF & " Parallelism :" & max_lots'Img & " scanners" & LAT.LF & " ncpu :" & number_cores'Img); TIO.Close (listlog); TIO.Put_Line ("The complete build list can also be found at:" & LAT.LF & filename); end if; end display_results_of_dry_run; --------------------- -- get_repos_dir -- --------------------- function get_repos_dir return String is command : String := host_pkg8 & " config repos_dir"; content : JT.Text; topline : JT.Text; crlen1 : Natural; crlen2 : Natural; begin content := CYC.generic_system_command (command); crlen1 := JT.SU.Length (content); loop JT.nextline (lineblock => content, firstline => topline); crlen2 := JT.SU.Length (content); exit when crlen1 = crlen2; crlen1 := crlen2; if not JT.equivalent (topline, "/etc/pkg/") then return JT.USS (topline); end if; end loop; -- fallback, use default return host_localbase & "/etc/pkg/repos"; end get_repos_dir; ------------------------------------ -- interact_with_single_builder -- ------------------------------------ function interact_with_single_builder return Boolean is EA_defined : constant Boolean := Unix.env_variable_defined (brkname); begin if Natural (portlist.Length) /= 1 then return False; end if; if not EA_defined then return False; end if; return CYC.valid_test_phase (Unix.env_variable_value (brkname)); end interact_with_single_builder; ---------------------------------------------- -- bulk_run_then_interact_with_final_port -- ---------------------------------------------- procedure bulk_run_then_interact_with_final_port is uscatport : JT.Text := portkey_crate.Key (Position => portlist.First); brkphase : constant String := Unix.env_variable_value (brkname); buildres : Boolean; ptid : port_id; begin if ports_keys.Contains (Key => uscatport) then ptid := ports_keys.Element (Key => uscatport); end if; OPS.unlist_port (ptid); perform_bulk_run (testmode => True); if SIG.graceful_shutdown_requested then return; end if; if bld_counter (ignored) > 0 or else bld_counter (skipped) > 0 or else bld_counter (failure) > 0 then TIO.Put_Line ("It appears a prerequisite failed, so the interactive" & " build of"); TIO.Put_Line (JT.USS (uscatport) & " has been cancelled."); return; end if; TIO.Put_Line ("Starting interactive build of " & JT.USS (uscatport)); TIO.Put_Line ("Stand by, building up to the point requested ..."); REP.initialize (testmode => True, num_cores => PortScan.cores_available); CYC.initialize (test_mode => True, jail_env => REP.jail_environment); REP.launch_slave (id => PortScan.scan_slave, opts => noprocs); Unix.cone_of_silence (deploy => False); case software_framework is when ports_collection => buildres := FPC.build_package (id => PortScan.scan_slave, sequence_id => ptid, interactive => True, interphase => brkphase); when pkgsrc => if PLAT.standalone_pkg8_install (PortScan.scan_slave) then buildres := NPS.build_package (id => PortScan.scan_slave, sequence_id => ptid, interactive => True, interphase => brkphase); end if; end case; REP.destroy_slave (id => PortScan.scan_slave, opts => noprocs); REP.finalize; end bulk_run_then_interact_with_final_port; -------------------------- -- synth_launch_clash -- -------------------------- function synth_launch_clash return Boolean is function get_usrlocal return String; function get_usrlocal return String is begin if JT.equivalent (PM.configuration.dir_system, "/") then return host_localbase; end if; return JT.USS (PM.configuration.dir_system) & host_localbase; end get_usrlocal; cwd : constant String := AD.Current_Directory; usrlocal : constant String := get_usrlocal; portsdir : constant String := JT.USS (PM.configuration.dir_portsdir); ullen : constant Natural := usrlocal'Length; pdlen : constant Natural := portsdir'Length; begin if cwd = usrlocal or else cwd = portsdir then return True; end if; if cwd'Length > ullen and then cwd (1 .. ullen + 1) = usrlocal & "/" then return True; end if; if cwd'Length > pdlen and then cwd (1 .. pdlen + 1) = portsdir & "/" then return True; end if; return False; exception when others => return True; end synth_launch_clash; -------------------------- -- version_difference -- -------------------------- function version_difference (id : port_id; kind : out verdiff) return String is dir_pkg : constant String := JT.USS (PM.configuration.dir_repository); current : constant String := JT.USS (all_ports (id).package_name); version : constant String := JT.USS (all_ports (id).port_version); begin if AD.Exists (dir_pkg & "/" & current) then kind := rebuild; return " (rebuild " & version & ")"; end if; declare currlen : constant Natural := current'Length; finish : constant Natural := currlen - version'Length - 4; pattern : constant String := current (1 .. finish) & "*.txz"; origin : constant String := get_catport (all_ports (id)); upgrade : JT.Text := JT.blank; pkg_search : AD.Search_Type; dirent : AD.Directory_Entry_Type; begin AD.Start_Search (Search => pkg_search, Directory => dir_pkg, Filter => (AD.Ordinary_File => True, others => False), Pattern => pattern); while AD.More_Entries (Search => pkg_search) loop AD.Get_Next_Entry (Search => pkg_search, Directory_Entry => dirent); declare sname : String := AD.Simple_Name (dirent); verend : Natural := sname'Length - 4; testorigin : String := PKG.query_origin (dir_pkg & "/" & sname); begin if testorigin = origin then upgrade := JT.SUS (" (" & sname (finish + 1 .. verend) & " => " & version & ")"); end if; end; end loop; if not JT.IsBlank (upgrade) then kind := change; return JT.USS (upgrade); end if; end; kind := newbuild; return " (new " & version & ")"; end version_difference; ------------------------ -- file_permissions -- ------------------------ function file_permissions (full_path : String) return String is command : constant String := "/usr/bin/stat -f %Lp " & full_path; content : JT.Text; topline : JT.Text; status : Integer; begin content := Unix.piped_command (command, status); if status /= 0 then return "000"; end if; JT.nextline (lineblock => content, firstline => topline); return JT.USS (topline); end file_permissions; -------------------------------------- -- acceptable_RSA_signing_support -- -------------------------------------- function acceptable_RSA_signing_support return Boolean is file_prefix : constant String := PM.synth_confdir & "/" & JT.USS (PM.configuration.profile) & "-"; key_private : constant String := file_prefix & "private.key"; key_public : constant String := file_prefix & "public.key"; found_private : constant Boolean := AD.Exists (key_private); found_public : constant Boolean := AD.Exists (key_public); sorry : constant String := "The generated repository will not " & "be signed due to the misconfiguration."; repo_key : constant String := JT.USS (PM.configuration.dir_buildbase) & ss_base & "/etc/repo.key"; begin if not found_private and then not found_public then return True; end if; if found_public and then not found_private then TIO.Put_Line ("A public RSA key file has been found without a " & "corresponding private key file."); TIO.Put_Line (sorry); return True; end if; if found_private and then not found_public then TIO.Put_Line ("A private RSA key file has been found without a " & "corresponding public key file."); TIO.Put_Line (sorry); return True; end if; declare mode : constant String := file_permissions (key_private); begin if mode /= "400" then TIO.Put_Line ("The private RSA key file has insecure file " & "permissions (" & mode & ")"); TIO.Put_Line ("Please change the mode of " & key_private & " to 400 before continuing."); return False; end if; end; declare begin AD.Copy_File (Source_Name => key_private, Target_Name => repo_key); return True; exception when failed : others => TIO.Put_Line ("Failed to copy private RSA key to builder."); TIO.Put_Line (EX.Exception_Information (failed)); return False; end; end acceptable_RSA_signing_support; ---------------------------------- -- acceptable_signing_command -- ---------------------------------- function valid_signing_command return Boolean is file_prefix : constant String := PM.synth_confdir & "/" & JT.USS (PM.configuration.profile) & "-"; fingerprint : constant String := file_prefix & "fingerprint"; ext_command : constant String := file_prefix & "signing_command"; found_finger : constant Boolean := AD.Exists (fingerprint); found_command : constant Boolean := AD.Exists (ext_command); sorry : constant String := "The generated repository will not " & "be externally signed due to the misconfiguration."; begin if found_finger and then found_command then if JT.IsBlank (one_line_file_contents (fingerprint)) or else JT.IsBlank (one_line_file_contents (ext_command)) then TIO.Put_Line ("At least one of the profile signing command " & "files is blank"); TIO.Put_Line (sorry); return False; end if; return True; end if; if found_finger then TIO.Put_Line ("The profile fingerprint was found but not the " & "signing command"); TIO.Put_Line (sorry); elsif found_command then TIO.Put_Line ("The profile signing command was found but not " & "the fingerprint"); TIO.Put_Line (sorry); end if; return False; end valid_signing_command; ----------------------- -- signing_command -- ----------------------- function signing_command return String is filename : constant String := PM.synth_confdir & "/" & JT.USS (PM.configuration.profile) & "-signing_command"; begin return one_line_file_contents (filename); end signing_command; --------------------------- -- profile_fingerprint -- --------------------------- function profile_fingerprint return String is filename : constant String := PM.synth_confdir & "/" & JT.USS (PM.configuration.profile) & "-fingerprint"; begin return one_line_file_contents (filename); end profile_fingerprint; ------------------------------- -- set_synth_conf_with_RSA -- ------------------------------- function set_synth_conf_with_RSA return Boolean is file_prefix : constant String := PM.synth_confdir & "/" & JT.USS (PM.configuration.profile) & "-"; key_private : constant String := file_prefix & "private.key"; key_public : constant String := file_prefix & "public.key"; found_private : constant Boolean := AD.Exists (key_private); found_public : constant Boolean := AD.Exists (key_public); begin return found_public and then found_private and then file_permissions (key_private) = "400"; end set_synth_conf_with_RSA; ------------------------------ -- one_line_file_contents -- ------------------------------ function one_line_file_contents (filename : String) return String is target_file : TIO.File_Type; contents : JT.Text := JT.blank; begin TIO.Open (File => target_file, Mode => TIO.In_File, Name => filename); if not TIO.End_Of_File (target_file) then contents := JT.SUS (TIO.Get_Line (target_file)); end if; TIO.Close (target_file); return JT.USS (contents); end one_line_file_contents; ------------------------- -- valid_system_root -- ------------------------- function valid_system_root return Boolean is begin if REP.boot_modules_directory_missing then TIO.Put_Line ("The /boot directory is optional, but when it exists, " & "the /boot/modules directory must also exist."); TIO.Put ("Please create the "); if not JT.equivalent (PM.configuration.dir_system, "/") then TIO.Put (JT.USS (PM.configuration.dir_system)); end if; TIO.Put_Line ("/boot/modules directory and retry."); return False; end if; return True; end valid_system_root; ------------------------------------------ -- host_pkg8_conservative_upgrade_set -- ------------------------------------------ function host_pkg8_conservative_upgrade_set return Boolean is command : constant String := host_pkg8 & " config CONSERVATIVE_UPGRADE"; content : JT.Text; topline : JT.Text; begin content := CYC.generic_system_command (command); JT.nextline (lineblock => content, firstline => topline); return JT.equivalent (topline, "yes"); end host_pkg8_conservative_upgrade_set; ----------------------------------- -- TERM_defined_in_environment -- ----------------------------------- function TERM_defined_in_environment return Boolean is defined : constant Boolean := Unix.env_variable_defined ("TERM"); begin if not defined then TIO.Put_Line ("Please define TERM in environment first and retry."); end if; return defined; end TERM_defined_in_environment; end PortScan.Pilot;
RREE/ada-util
Ada
16,766
adb
----------------------------------------------------------------------- -- util-properties-tests -- Tests for properties -- Copyright (C) 2009, 2010, 2011, 2014, 2017, 2018, 2020, 2021 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Test_Caller; with Ada.Text_IO; with Ada.Containers; with Util.Properties; with Util.Properties.Basic; package body Util.Properties.Tests is use Ada.Text_IO; use type Ada.Containers.Count_Type; use Util.Properties.Basic; -- Test -- Properties.Set -- Properties.Exists -- Properties.Get procedure Test_Property (T : in out Test) is Props : Properties.Manager; begin T.Assert (Exists (Props, "test") = False, "Invalid properties"); T.Assert (Exists (Props, +("test")) = False, "Invalid properties"); T.Assert (Props.Is_Empty, "Property manager should be empty"); Props.Set ("test", "toto"); T.Assert (Exists (Props, "test"), "Property was not inserted"); declare V : constant String := Props.Get ("test"); begin T.Assert (V = "toto", "Property was not set correctly"); end; declare V : constant String := Props.Get (+("test")); begin T.Assert (V = "toto", "Property was not set correctly"); end; declare V : constant Unbounded_String := Props.Get (+("test")); begin T.Assert (V = "toto", "Property was not set correctly"); end; end Test_Property; -- Test basic properties -- Get -- Set procedure Test_Integer_Property (T : in out Test) is Props : Properties.Manager; V : Integer := 23; begin Integer_Property.Set (Props, "test-integer", V); T.Assert (Props.Exists ("test-integer"), "Invalid properties"); V := Integer_Property.Get (Props, "test-integer"); T.Assert (V = 23, "Property was not inserted"); Integer_Property.Set (Props, "test-integer", 24); V := Integer_Property.Get (Props, "test-integer"); T.Assert (V = 24, "Property was not inserted"); V := Integer_Property.Get (Props, "unknown", 25); T.Assert (V = 25, "Default value must be returned for a Get"); end Test_Integer_Property; -- Test loading of property files procedure Test_Load_Property (T : in out Test) is Props : Properties.Manager; F : File_Type; begin Open (F, In_File, "regtests/test.properties"); Load_Properties (Props, F); Close (F); declare Names : Util.Strings.Vectors.Vector; begin Props.Get_Names (Names); T.Assert (Names.Length > 30, "Loading the test properties returned too few properties"); T.Assert (To_String (Props.Get ("root.dir")) = ".", "Invalid property 'root.dir'"); T.Assert (To_String (Props.Get ("console.lib")) = "${dist.lib.dir}/console.jar", "Invalid property 'console.lib'"); end; exception when Ada.Text_IO.Name_Error => Ada.Text_IO.Put_Line ("Cannot find test file: regtests/test.properties"); raise; end Test_Load_Property; -- ------------------------------ -- Test loading of property files -- ------------------------------ procedure Test_Load_Strip_Property (T : in out Test) is Props : Properties.Manager; F : File_Type; begin -- Load, filter and strip properties Open (F, In_File, "regtests/test.properties"); Load_Properties (Props, F, "tomcat.", True); Close (F); declare Names : Util.Strings.Vectors.Vector; begin Props.Get_Names (Names); T.Assert (Names.Length > 3, "Loading the test properties returned too few properties"); T.Assert (To_String (Props.Get ("version")) = "0.6", "Invalid property 'root.dir'"); end; exception when Ada.Text_IO.Name_Error => Ada.Text_IO.Put_Line ("Cannot find test file: regtests/test.properties"); raise; end Test_Load_Strip_Property; -- ------------------------------ -- Test copy of properties -- ------------------------------ procedure Test_Copy_Property (T : in out Test) is Props : Properties.Manager; begin Props.Set ("prefix.one", "1"); Props.Set ("prefix.two", "2"); Props.Set ("prefix", "Not copied"); Props.Set ("prefix.", "Copied"); declare Copy : Properties.Manager; begin Copy.Copy (From => Props); T.Assert (Copy.Exists ("prefix.one"), "Property one not found"); T.Assert (Copy.Exists ("prefix.two"), "Property two not found"); T.Assert (Copy.Exists ("prefix"), "Property '' does not exist."); T.Assert (Copy.Exists ("prefix."), "Property '' does not exist."); end; declare Copy : Properties.Manager; begin Copy.Copy (From => Props, Prefix => "prefix.", Strip => True); T.Assert (Copy.Exists ("one"), "Property one not found"); T.Assert (Copy.Exists ("two"), "Property two not found"); T.Assert (Copy.Exists (""), "Property '' does not exist."); end; end Test_Copy_Property; procedure Test_Set_Preserve_Original (T : in out Test) is Props1 : Properties.Manager; begin Props1.Set ("a", "b"); Props1.Set ("c", "d"); declare Props2 : Properties.Manager; begin Props2 := Props1; T.Assert (Props2.Exists ("a"), "Property a not found in props2 after assignment"); T.Assert (Props2.Exists ("c"), "Property b not found in props2 after assignment"); Util.Tests.Assert_Equals (T, "b", String '(Props2.Get ("a")), "Invalid property a"); Props1.Set ("a", "d"); Util.Tests.Assert_Equals (T, "d", String '(Props1.Get ("a")), "Wrong property a in props1"); Util.Tests.Assert_Equals (T, "b", String '(Props2.Get ("a")), "Wrong property a in props2"); Props2 := Props1; Util.Tests.Assert_Equals (T, "d", String '(Props2.Get ("a")), "Wrong property a in props2"); Props2.Set ("e", "f"); Props2.Set ("c", "g"); Props1 := Props2; -- Release Props2 but the property manager is internally shared so the Props1 is -- not changed. end; T.Assert (Props1.Exists ("e"), "Property e not found in props1 after assignment"); T.Assert (Props1.Exists ("c"), "Property c not found in props1 after assignment"); Util.Tests.Assert_Equals (T, "g", String '(Props1.Get ("c")), "Wrong property c in props1"); end Test_Set_Preserve_Original; procedure Test_Remove_Preserve_Original (T : in out Test) is Props1 : Properties.Manager; begin Props1.Set ("a", "b"); Props1.Set ("c", "d"); declare Props2 : Properties.Manager; begin Props2 := Props1; T.Assert (Props2.Exists ("a"), "Property a not found in props2 after assignment"); T.Assert (Props2.Exists ("c"), "Property b not found in props2 after assignment"); Props1.Remove ("a"); T.Assert (not Props1.Exists ("a"), "Property a was not removed from props1"); T.Assert (Props2.Exists ("a"), "Property a was removed from props2"); Props1 := Props2; -- Release Props2 but the property manager is internally shared so the Props1 is -- not changed. end; Util.Tests.Assert_Equals (T, "b", String '(Props1.Get ("a")), "Wrong property a in props1"); end Test_Remove_Preserve_Original; procedure Test_Missing_Property (T : in out Test) is Props : Properties.Manager; V : Unbounded_String; begin for Pass in 1 .. 2 loop T.Assert (Util.Beans.Objects.Is_Null (Props.Get_Value ("missing")), "The Get_Value operation must return a null object"); begin V := Props.Get ("missing"); T.Fail ("Exception NO_PROPERTY was not raised"); exception when NO_PROPERTY => null; end; begin V := Props.Get (+("missing")); T.Fail ("Exception NO_PROPERTY was not raised"); exception when NO_PROPERTY => null; end; T.Assert (Ada.Strings.Unbounded.Length (V) = 0, "Variable get's corrupted"); -- Check exception on Get returning a String. begin declare S : constant String := Props.Get ("missing"); pragma Unreferenced (S); begin T.Fail ("Exception NO_PROPERTY was not raised"); end; exception when NO_PROPERTY => null; end; -- Check exception on Get returning a String. begin declare S : constant String := Props.Get (+("missing")); pragma Unreferenced (S); begin T.Fail ("Exception NO_PROPERTY was not raised"); end; exception when NO_PROPERTY => null; end; Props.Set ("a", "b"); T.Assert (Util.Beans.Objects.Is_Null (Props.Get_Value ("missing")), "The Get_Value operation must return a null object"); begin V := Props.Get ("missing"); T.Fail ("Exception NO_PROPERTY was not raised"); exception when NO_PROPERTY => null; end; Props.Set ("c", "d"); end loop; end Test_Missing_Property; procedure Test_Load_Ini_Property (T : in out Test) is Props : Properties.Manager; F : File_Type; begin Open (F, In_File, "regtests/files/my.cnf"); Load_Properties (Props, F); Close (F); declare V : Util.Properties.Value; P : Properties.Manager; begin V := Props.Get_Value ("mysqld"); T.Assert (Util.Properties.Is_Manager (V), "Value 'mysqld' must be a property manager"); P := Util.Properties.To_Manager (V); T.Assert (P.Exists ("user"), "The [mysqld] property manager should contain a 'user' property"); V := Props.Get_Value ("mysqld_safe"); T.Assert (Util.Properties.Is_Manager (V), "Value 'mysqld_safe' must be a property manager"); P := Util.Properties.To_Manager (V); T.Assert (P.Exists ("socket"), "The [mysqld] property manager should contain a 'socket' property"); end; declare P : Properties.Manager; begin P := Props.Get ("mysqld"); T.Assert (P.Exists ("user"), "The [mysqld] property manager should contain a 'user' property"); P := Props.Get ("mysqld_safe"); T.Assert (P.Exists ("socket"), "The [mysqld] property manager should contain a 'socket' property"); end; declare P : Properties.Manager with Unreferenced; begin P := Props.Get ("bad"); T.Fail ("No exception raised for Get()"); exception when NO_PROPERTY => null; end; exception when Ada.Text_IO.Name_Error => Ada.Text_IO.Put_Line ("Cannot find test file: regtests/files/my.cnf"); raise; end Test_Load_Ini_Property; procedure Test_Save_Properties (T : in out Test) is Path : constant String := Util.Tests.Get_Test_Path ("save-props.properties"); begin declare Props : Properties.Manager; F : File_Type; begin Open (F, In_File, "regtests/files/my.cnf"); Load_Properties (Props, F); Close (F); Props.Set ("New-Property", "Some-Value"); Props.Remove ("mysqld"); T.Assert (not Props.Exists ("mysqld"), "mysqld property was not removed"); Props.Save_Properties (Path); end; declare Props : Properties.Manager; V : Util.Properties.Value; P : Properties.Manager; begin Props.Load_Properties (Path => Path); T.Assert (not Props.Exists ("mysqld"), "mysqld property was not removed (2)"); T.Assert (Props.Exists ("New-Property"), "Invalid Save_Properties"); V := Props.Get_Value ("mysqld_safe"); T.Assert (Util.Properties.Is_Manager (V), "Value 'mysqld_safe' must be a property manager"); P := Util.Properties.To_Manager (V); T.Assert (P.Exists ("socket"), "The [mysqld] property manager should contain a 'socket' property"); end; declare V : Util.Properties.Value; P : Properties.Manager with Unreferenced; begin P := Util.Properties.To_Manager (V); T.Fail ("No exception raised by To_Manager"); exception when Util.Beans.Objects.Conversion_Error => null; end; end Test_Save_Properties; procedure Test_Remove_Property (T : in out Test) is Props : Properties.Manager; begin begin Props.Remove ("missing"); T.Fail ("Remove should raise exception"); exception when NO_PROPERTY => null; end; begin Props.Remove (+("missing")); T.Fail ("Remove should raise exception"); exception when NO_PROPERTY => null; end; Props.Set ("a", "b"); T.Assert (Props.Exists ("a"), "Property not inserted"); Props.Remove ("a"); T.Assert (not Props.Exists ("a"), "Property not removed"); Props.Set ("a", +("b")); T.Assert (Props.Exists ("a"), "Property not inserted"); Props.Remove (+("a")); T.Assert (not Props.Exists ("a"), "Property not removed"); end Test_Remove_Property; package Caller is new Util.Test_Caller (Test, "Properties.Main"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test Util.Properties.Set", Test_Property'Access); Caller.Add_Test (Suite, "Test Util.Properties.Get", Test_Property'Access); Caller.Add_Test (Suite, "Test Util.Properties.Exists", Test_Property'Access); Caller.Add_Test (Suite, "Test Util.Properties.Remove", Test_Remove_Property'Access); Caller.Add_Test (Suite, "Test Util.Properties.Get (NO_PROPERTY)", Test_Missing_Property'Access); Caller.Add_Test (Suite, "Test Util.Properties.Discrete.Get", Test_Integer_Property'Access); Caller.Add_Test (Suite, "Test Util.Properties.Discrete.Set", Test_Integer_Property'Access); Caller.Add_Test (Suite, "Test Util.Properties.Load_Properties", Test_Load_Property'Access); Caller.Add_Test (Suite, "Test Util.Properties.Load_Properties (INI)", Test_Load_Ini_Property'Access); Caller.Add_Test (Suite, "Test Util.Properties.Load_Strip_Properties", Test_Load_Strip_Property'Access); Caller.Add_Test (Suite, "Test Util.Properties.Copy", Test_Copy_Property'Access); Caller.Add_Test (Suite, "Test Util.Properties.Set+Assign", Test_Set_Preserve_Original'Access); Caller.Add_Test (Suite, "Test Util.Properties.Set+Assign+Remove", Test_Remove_Preserve_Original'Access); Caller.Add_Test (Suite, "Test Util.Properties.Save_Properties", Test_Save_Properties'Access); end Add_Tests; end Util.Properties.Tests;
reznikmm/matreshka
Ada
4,631
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_Form.Allow_Deletes_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Form_Allow_Deletes_Attribute_Node is begin return Self : Form_Allow_Deletes_Attribute_Node do Matreshka.ODF_Form.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Form_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Form_Allow_Deletes_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Allow_Deletes_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Form_URI, Matreshka.ODF_String_Constants.Allow_Deletes_Attribute, Form_Allow_Deletes_Attribute_Node'Tag); end Matreshka.ODF_Form.Allow_Deletes_Attributes;
zhmu/ananas
Ada
444
ads
package Expr_Func7 is type Abstract_Food is tagged null record; type Abstract_Food_Access is access Abstract_Food'Class; type Fruit is new Abstract_Food with record Worm : Boolean; end record; type Bananas is tagged record Inside : Abstract_Food_Access; end record; function Has_Worm (B : Bananas) return Boolean is (Fruit (B.Inside.all).Worm); Cool : Bananas; procedure Dummy; end Expr_Func7;
reznikmm/matreshka
Ada
6,515
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- SQL Database Access -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This package provides implementation of Query abstraction for Firebird. ------------------------------------------------------------------------------ with League.Text_Codecs; with Matreshka.Internals.SQL_Drivers.Firebird.Databases; private with Matreshka.Internals.SQL_Drivers.Firebird.Records; private with Matreshka.Internals.SQL_Parameter_Sets; package Matreshka.Internals.SQL_Drivers.Firebird.Queries is type Firebird_Query is new Abstract_Query with private; procedure Initialize (Self : not null access Firebird_Query'Class; Database : not null access Databases.Firebird_Database'Class; Codec : access League.Text_Codecs.Text_Codec; Utf : Boolean); private type Query_State is (Active, Inactive); type Query_Sql_Type is (Unknown, Simple_Select, Insert, Update, Delete, DDL, Get_Segment, Put_Segment, Exec_Procedure, Start_Transaction, Commit, Rollback, Select_For_Update, Set_Generator, Save_Point_Operation); type Firebird_Query is new Abstract_Query with record State : Query_State := Inactive; Sql_Type : Query_Sql_Type := Unknown; Stmt_Handle : aliased Isc_Stmt_Handle := Null_Isc_Stmt_Handle; Sql_Record : Records.Sql_Record; Sql_Params : Records.Sql_Record; Sql_Text : League.Strings.Universal_String; Parameters : Matreshka.Internals.SQL_Parameter_Sets.Parameter_Set; Cursor_Name : Isc_String (1 .. 10); Status : aliased Isc_Results := (others => 0); Error : League.Strings.Universal_String; Is_Valid : Boolean := False; end record; overriding procedure Bind_Value (Self : not null access Firebird_Query; Name : League.Strings.Universal_String; Value : League.Holders.Holder; Direction : SQL.Parameter_Directions); overriding function Bound_Value (Self : not null access Firebird_Query; Name : League.Strings.Universal_String) return League.Holders.Holder; overriding function Error_Message (Self : not null access Firebird_Query) return League.Strings.Universal_String; overriding function Execute (Self : not null access Firebird_Query) return Boolean; overriding procedure Finish (Self : not null access Firebird_Query); overriding procedure Invalidate (Self : not null access Firebird_Query); overriding function Is_Active (Self : not null access Firebird_Query) return Boolean; overriding function Next (Self : not null access Firebird_Query) return Boolean; overriding function Is_Valid (Self : not null access Firebird_Query) return Boolean; overriding function Prepare (Self : not null access Firebird_Query; Query : League.Strings.Universal_String) return Boolean; overriding function Value (Self : not null access Firebird_Query; Index : Positive) return League.Holders.Holder; procedure Free_Handle (Self : not null access Firebird_Query); function Execute_Immediate (Self : not null access Firebird_Query) return Boolean; end Matreshka.Internals.SQL_Drivers.Firebird.Queries;
msrLi/portingSources
Ada
831
adb
-- Copyright 2009-2014 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. package body Pck is procedure Do_Nothing (A : System.Address) is begin null; end Do_Nothing; end Pck;
afrl-rq/OpenUxAS
Ada
3,171
adb
with AVTAS.LMCP.Types; with LMCP_Message_Conversions; use LMCP_Message_Conversions; with UxAS.Common.String_Constant.Message_Group; package body Route_Aggregator_Communication is ---------------------------------------- -- Get_Next_Unique_Sending_Message_Id -- ---------------------------------------- procedure Get_Next_Unique_Sending_Message_Id (This : in out Route_Aggregator_Mailbox; Value : out Int64) is begin This.Unique_Entity_Send_Message_Id := This.Unique_Entity_Send_Message_Id + 1; Value := This.Unique_Entity_Send_Message_Id; end Get_Next_Unique_Sending_Message_Id; ---------------- -- Initialize -- ---------------- procedure Initialize (This : out Route_Aggregator_Mailbox; Source_Group : String; Unique_Id : Int64; Entity_Id : UInt32; Service_Id : UInt32) is begin -- The procedure UxAS.Comms.LMCP_Net_Client.Initialize_Network_Client() -- will also initialize its Message_Sender_Pipe component but will not -- use it for sending: -- -- This.Message_Sender_Pipe.Initialize_Push -- (Source_Group => Value (This.Message_Source_Group), -- Entity_Id => This.Entity_Id, -- Service_Id => UInt32 (This.Network_Id)); This.Message_Sender_Pipe.Initialize_Push (Source_Group => Source_Group, Entity_Id => AVTAS.LMCP.Types.UInt32 (Entity_Id), Service_Id => AVTAS.LMCP.Types.UInt32 (Service_Id)); This.Unique_Entity_Send_Message_Id := Unique_Id; end Initialize; -------------------------- -- sendBroadcastMessage -- -------------------------- -- this is sendSharedLMCPObjectBroadcastMessage(), in our code Send_Shared_LMCP_Object_Broadcast_Message procedure sendBroadcastMessage (This : in out Route_Aggregator_Mailbox; Msg : Message_Root'Class) is begin This.Unique_Entity_Send_Message_Id := This.Unique_Entity_Send_Message_Id + 1; -- This.Message_Sender_Pipe.Send_Shared_Broadcast_Message (Msg); This.Message_Sender_Pipe.Send_Shared_Broadcast_Message (As_Object_Any (Msg)); end sendBroadcastMessage; ---------------------------- -- sendLimitedCastMessage -- ---------------------------- -- this is sendSharedLMCPObjectLimitedCastMessage(), in our code Send_Shared_LMCP_Object_Limited_Cast_Message procedure sendLimitedCastMessage (This : in out Route_Aggregator_Mailbox; Group : MessageGroup; Msg : Message_Root'Class) is use UxAS.Common.String_Constant; begin This.Unique_Entity_Send_Message_Id := This.Unique_Entity_Send_Message_Id + 1; -- This.Message_Sender_Pipe.Send_Shared_LimitedCast_Message (Cast_Address, Msg); This.Message_Sender_Pipe.Send_Shared_LimitedCast_Message (Cast_Address => (case Group is when GroundPathPlanner => Message_Group.GroundPathPlanner, when AircraftPathPlanner => Message_Group.AircraftPathPlanner), Message => As_Object_Any (Msg)); end sendLimitedCastMessage; end Route_Aggregator_Communication;
redparavoz/ada-wiki
Ada
2,846
ads
----------------------------------------------------------------------- -- wiki-streams-html-builders -- Wiki writer to a string builder -- Copyright (C) 2011, 2012, 2013, 2015, 2016 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Wiki.Streams.Builders; -- === HTML Output Builder Stream === -- The <tt>Html_Output_Builder_Stream</tt> type defines a HTML output stream that collects the -- HTML into expandable buffers. Once the complete HTML document is rendered, the content is -- retrieved either by the <tt>To_String</tt> or the <tt>Iterate</tt> operations. -- package Wiki.Streams.Html.Builders is type Html_Output_Builder_Stream is limited new Wiki.Streams.Builders.Output_Builder_Stream and Wiki.Streams.Html.Html_Output_Stream with private; type Html_Output_Builder_Stream_Access is access all Html_Output_Builder_Stream'Class; overriding procedure Write_Wide_Attribute (Stream : in out Html_Output_Builder_Stream; Name : in String; Content : in Wiki.Strings.UString); -- Write an XML attribute within an XML element. -- The attribute value is escaped according to the XML escape rules. overriding procedure Write_Wide_Attribute (Stream : in out Html_Output_Builder_Stream; Name : in String; Content : in Wiki.Strings.WString); overriding procedure Start_Element (Stream : in out Html_Output_Builder_Stream; Name : in String); overriding procedure End_Element (Stream : in out Html_Output_Builder_Stream; Name : in String); overriding procedure Write_Wide_Text (Stream : in out Html_Output_Builder_Stream; Content : in Wiki.Strings.WString); private type Html_Output_Builder_Stream is limited new Wiki.Streams.Builders.Output_Builder_Stream and Wiki.Streams.Html.Html_Output_Stream with record -- Whether an XML element must be closed (that is a '>' is necessary) Close_Start : Boolean := False; end record; end Wiki.Streams.Html.Builders;
zhmu/ananas
Ada
188
ads
package Max_Size_Pkg is type Index is range 1 .. 5; type Arr1 is array (Index range <>) of Short_Short_Integer; type Arr2 is array (Index range <>) of Integer; end Max_Size_Pkg;
reznikmm/matreshka
Ada
4,728
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_Placeholder_Elements; package Matreshka.ODF_Text.Placeholder_Elements is type Text_Placeholder_Element_Node is new Matreshka.ODF_Text.Abstract_Text_Element_Node and ODF.DOM.Text_Placeholder_Elements.ODF_Text_Placeholder with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Text_Placeholder_Element_Node; overriding function Get_Local_Name (Self : not null access constant Text_Placeholder_Element_Node) return League.Strings.Universal_String; overriding procedure Enter_Node (Self : not null access Text_Placeholder_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_Placeholder_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_Placeholder_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.Placeholder_Elements;
reznikmm/matreshka
Ada
4,011
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Table_Table_Name_Attributes; package Matreshka.ODF_Table.Table_Name_Attributes is type Table_Table_Name_Attribute_Node is new Matreshka.ODF_Table.Abstract_Table_Attribute_Node and ODF.DOM.Table_Table_Name_Attributes.ODF_Table_Table_Name_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Table_Table_Name_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Table_Table_Name_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Table.Table_Name_Attributes;
AdaCore/Ada_Drivers_Library
Ada
2,590
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2017, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with STM32_SVD.SDIO; -- SVD files for the STM32F4 and STM32F7 have different names for the SDMMC -- device (SDIO or SDMMC). This provides a common name for the SVD package. package SDMMC_SVD renames STM32_SVD.SDIO;
reznikmm/matreshka
Ada
4,778
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- XML Processor -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ package body XML.SAX.Input_Sources.Streams.Element_Arrays is ---------- -- Read -- ---------- overriding procedure Read (Self : in out Stream_Element_Array_Input_Source; Buffer : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset; End_Of_Data : out Boolean) is pragma Unreferenced (Self); pragma Warnings (Off, Buffer); begin Last := Buffer'First - 1; End_Of_Data := True; end Read; ------------------------------ -- Set_Stream_Element_Array -- ------------------------------ procedure Set_Stream_Element_Array (Self : in out Stream_Element_Array_Input_Source'Class; Data : Ada.Streams.Stream_Element_Array) is begin Free (Self.Buffer); Self.Buffer := new Ada.Streams.Stream_Element_Array (0 .. Data'Length - 1); Self.Buffer.all := Data; Self.First := 0; Self.Last := Data'Length - 1; end Set_Stream_Element_Array; ------------------------------- -- Set_Stream_Element_Vector -- ------------------------------- procedure Set_Stream_Element_Vector (Self : in out Stream_Element_Array_Input_Source'Class; Data : League.Stream_Element_Vectors.Stream_Element_Vector) is begin Self.Set_Stream_Element_Array (Data.To_Stream_Element_Array); end Set_Stream_Element_Vector; end XML.SAX.Input_Sources.Streams.Element_Arrays;
shintakezou/drake
Ada
9,190
adb
with System.Formatting; with System.Long_Long_Integer_Types; with System.Random_Initiators; with System.Storage_Elements; package body Ada.Numerics.MT19937 is use type Interfaces.Unsigned_32; use type System.Storage_Elements.Storage_Count; subtype Word_Unsigned is System.Long_Long_Integer_Types.Word_Unsigned; MATRIX_A : constant := 16#9908b0df#; UPPER_MASK : constant := 16#80000000#; -- 2 ** (32 - 1) LOWER_MASK : constant := 16#7fffffff#; -- not UPPER_MASK -- implementation function Random_32 (Gen : aliased in out Generator) return Unsigned_32 is pragma Suppress (Index_Check); pragma Suppress (Range_Check); mag01 : constant array (Unsigned_32 range 0 .. 1) of Unsigned_32 := (0, MATRIX_A); y : Unsigned_32; S : State renames Gen.State; begin if S.Condition >= N then for kk in 0 .. (N - M - 1) loop y := (S.Vector (kk) and UPPER_MASK) or (S.Vector (kk + 1) and LOWER_MASK); S.Vector (kk) := S.Vector (kk + M) xor Interfaces.Shift_Right (y, 1) xor mag01 (y and 1); end loop; for kk in (N - M) .. (N - 2) loop y := (S.Vector (kk) and UPPER_MASK) or (S.Vector (kk + 1) and LOWER_MASK); S.Vector (kk) := S.Vector (kk + (M - N)) xor Interfaces.Shift_Right (y, 1) xor mag01 (y and 1); end loop; y := (S.Vector (N - 1) and UPPER_MASK) or (S.Vector (0) and LOWER_MASK); S.Vector (N - 1) := S.Vector (M - 1) xor Interfaces.Shift_Right (y, 1) xor mag01 (y and 1); S.Condition := 0; end if; y := S.Vector (Integer (S.Condition)); S.Condition := S.Condition + 1; y := y xor Interfaces.Shift_Right (y, 11); y := y xor (Interfaces.Shift_Left (y, 7) and 16#9d2c5680#); y := y xor (Interfaces.Shift_Left (y, 15) and 16#efc60000#); y := y xor Interfaces.Shift_Right (y, 18); return y; end Random_32; function Initialize return Generator is begin return (State => Initialize); end Initialize; function Initialize (Initiator : Unsigned_32) return Generator is begin return (State => Initialize (Initiator)); end Initialize; function Initialize (Initiator : Unsigned_32_Array) return Generator is begin return (State => Initialize (Initiator)); end Initialize; procedure Reset (Gen : in out Generator) is begin Gen.State := Initialize; end Reset; procedure Reset (Gen : in out Generator; Initiator : Integer) is begin Gen.State := Initialize (Unsigned_32'Mod (Initiator)); end Reset; function Initialize return State is Init : Unsigned_32_Array_N; begin System.Random_Initiators.Get ( Init'Address, Init'Size / Standard'Storage_Unit); return Initialize (Init); end Initialize; function Initialize (Initiator : Unsigned_32) return State is V : Unsigned_32 := Initiator; begin return Result : State do Result.Vector (0) := V; for I in 1 .. (N - 1) loop V := 1812433253 * (V xor Interfaces.Shift_Right (V, 30)) + Unsigned_32 (I); Result.Vector (I) := V; end loop; Result.Condition := N; end return; end Initialize; function Initialize (Initiator : Unsigned_32_Array) return State is Initiator_Length : constant Natural := Initiator'Length; i : Integer := 1; j : Integer := 0; begin return Result : State := Initialize (19650218) do if Initiator_Length > 0 then for K in reverse 1 .. Integer'Max (N, Initiator_Length) loop declare P : constant Unsigned_32 := Result.Vector (i - 1); begin Result.Vector (i) := (Result.Vector (i) xor ((P xor Interfaces.Shift_Right (P, 30)) * 1664525)) + Initiator (Initiator'First + j) + Unsigned_32 (j); end; i := i + 1; if i >= N then Result.Vector (0) := Result.Vector (N - 1); i := 1; end if; j := (j + 1) rem Positive'(Initiator_Length); end loop; for K in reverse 1 .. (N - 1) loop declare P : constant Unsigned_32 := Result.Vector (i - 1); begin Result.Vector (i) := (Result.Vector (i) xor ((P xor Interfaces.Shift_Right (P, 30)) * 1566083941)) - Unsigned_32 (i); end; i := i + 1; if i >= N then Result.Vector (0) := Result.Vector (N - 1); i := 1; end if; end loop; Result.Vector (0) := 16#80000000#; end if; end return; end Initialize; procedure Save (Gen : Generator; To_State : out State) is begin To_State := Gen.State; end Save; procedure Reset (Gen : in out Generator; From_State : State) is begin Gen.State := From_State; end Reset; function Reset (From_State : State) return Generator is begin return (State => From_State); end Reset; function Image (Of_State : State) return String is procedure Hex (Result : in out String; Value : Unsigned_32); procedure Hex (Result : in out String; Value : Unsigned_32) is Error : Boolean; Last : Natural; begin pragma Compile_Time_Error (Standard'Word_Size < 32, "word size < 32"); System.Formatting.Image ( Word_Unsigned (Value), Result, Last, Base => 16, Width => 32 / 4, Error => Error); pragma Assert (not Error and then Last = Result'Last); end Hex; Last : Natural := 0; begin return Result : String (1 .. Max_Image_Width) do for I in Unsigned_32_Array_N'Range loop declare Previous_Last : constant Natural := Last; begin Last := Last + 32 / 4; Hex (Result (Previous_Last + 1 .. Last), Of_State.Vector (I)); Last := Last + 1; Result (Last) := ':'; end; end loop; Hex (Result (Last + 1 .. Result'Last), Of_State.Condition); end return; end Image; function Value (Coded_State : String) return State is procedure Hex (Item : String; Value : out Unsigned_32); procedure Hex (Item : String; Value : out Unsigned_32) is Last : Positive; Error : Boolean; begin System.Formatting.Value ( Item, Last, Word_Unsigned (Value), Base => 16, Error => Error); if Error or else Last /= Item'Last then raise Constraint_Error; end if; end Hex; Last : Natural := Coded_State'First - 1; begin if Coded_State'Length /= Max_Image_Width then raise Constraint_Error; end if; return Result : State do for I in Unsigned_32_Array_N'Range loop declare Previous_Last : constant Natural := Last; begin Last := Last + 32 / 4; Hex ( Coded_State (Previous_Last + 1 .. Last), Result.Vector (I)); Last := Last + 1; if Coded_State (Last) /= ':' then raise Constraint_Error; end if; end; end loop; Hex (Coded_State (Last + 1 .. Coded_State'Last), Result.Condition); end return; end Value; function Random_0_To_1 (Gen : aliased in out Generator) return Uniformly_Distributed is begin return Uniformly_Distributed'Base (Random_32 (Gen)) * (1.0 / 4294967295.0); end Random_0_To_1; function Random_0_To_Less_Than_1 (Gen : aliased in out Generator) return Uniformly_Distributed is begin return Uniformly_Distributed'Base (Random_32 (Gen)) * (1.0 / 4294967296.0); end Random_0_To_Less_Than_1; function Random_Greater_Than_0_To_Less_Than_1 ( Gen : aliased in out Generator) return Uniformly_Distributed is begin return (Uniformly_Distributed'Base (Random_32 (Gen)) + 0.5) * (1.0 / 4294967296.0); end Random_Greater_Than_0_To_Less_Than_1; function Random_53_0_To_Less_Than_1 (Gen : aliased in out Generator) return Uniformly_Distributed is A : constant Unsigned_32 := Interfaces.Shift_Right (Random_32 (Gen), 5); B : constant Unsigned_32 := Interfaces.Shift_Right (Random_32 (Gen), 6); Float_A : constant Long_Long_Float := Uniformly_Distributed'Base (A); Float_B : constant Long_Long_Float := Uniformly_Distributed'Base (B); begin return (Float_A * 67108864.0 + Float_B) * (1.0 / 9007199254740992.0); end Random_53_0_To_Less_Than_1; end Ada.Numerics.MT19937;
AdaCore/Ada_Drivers_Library
Ada
102,224
ads
-- This spec has been automatically generated from STM32F40x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.USB_OTG_HS is pragma Preelaborate; --------------- -- Registers -- --------------- subtype OTG_HS_DCFG_DSPD_Field is HAL.UInt2; subtype OTG_HS_DCFG_DAD_Field is HAL.UInt7; subtype OTG_HS_DCFG_PFIVL_Field is HAL.UInt2; subtype OTG_HS_DCFG_PERSCHIVL_Field is HAL.UInt2; -- OTG_HS device configuration register type OTG_HS_DCFG_Register is record -- Device speed DSPD : OTG_HS_DCFG_DSPD_Field := 16#0#; -- Nonzero-length status OUT handshake NZLSOHSK : Boolean := False; -- unspecified Reserved_3_3 : HAL.Bit := 16#0#; -- Device address DAD : OTG_HS_DCFG_DAD_Field := 16#0#; -- Periodic (micro)frame interval PFIVL : OTG_HS_DCFG_PFIVL_Field := 16#0#; -- unspecified Reserved_13_23 : HAL.UInt11 := 16#100#; -- Periodic scheduling interval PERSCHIVL : OTG_HS_DCFG_PERSCHIVL_Field := 16#2#; -- unspecified Reserved_26_31 : HAL.UInt6 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_DCFG_Register use record DSPD at 0 range 0 .. 1; NZLSOHSK at 0 range 2 .. 2; Reserved_3_3 at 0 range 3 .. 3; DAD at 0 range 4 .. 10; PFIVL at 0 range 11 .. 12; Reserved_13_23 at 0 range 13 .. 23; PERSCHIVL at 0 range 24 .. 25; Reserved_26_31 at 0 range 26 .. 31; end record; subtype OTG_HS_DCTL_TCTL_Field is HAL.UInt3; -- OTG_HS device control register type OTG_HS_DCTL_Register is record -- Remote wakeup signaling RWUSIG : Boolean := False; -- Soft disconnect SDIS : Boolean := False; -- Read-only. Global IN NAK status GINSTS : Boolean := False; -- Read-only. Global OUT NAK status GONSTS : Boolean := False; -- Test control TCTL : OTG_HS_DCTL_TCTL_Field := 16#0#; -- Write-only. Set global IN NAK SGINAK : Boolean := False; -- Write-only. Clear global IN NAK CGINAK : Boolean := False; -- Write-only. Set global OUT NAK SGONAK : Boolean := False; -- Write-only. Clear global OUT NAK CGONAK : Boolean := False; -- Power-on programming done POPRGDNE : Boolean := False; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_DCTL_Register use record RWUSIG at 0 range 0 .. 0; SDIS at 0 range 1 .. 1; GINSTS at 0 range 2 .. 2; GONSTS at 0 range 3 .. 3; TCTL at 0 range 4 .. 6; SGINAK at 0 range 7 .. 7; CGINAK at 0 range 8 .. 8; SGONAK at 0 range 9 .. 9; CGONAK at 0 range 10 .. 10; POPRGDNE at 0 range 11 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; subtype OTG_HS_DSTS_ENUMSPD_Field is HAL.UInt2; subtype OTG_HS_DSTS_FNSOF_Field is HAL.UInt14; -- OTG_HS device status register type OTG_HS_DSTS_Register is record -- Read-only. Suspend status SUSPSTS : Boolean; -- Read-only. Enumerated speed ENUMSPD : OTG_HS_DSTS_ENUMSPD_Field; -- Read-only. Erratic error EERR : Boolean; -- unspecified Reserved_4_7 : HAL.UInt4; -- Read-only. Frame number of the received SOF FNSOF : OTG_HS_DSTS_FNSOF_Field; -- unspecified Reserved_22_31 : HAL.UInt10; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_DSTS_Register use record SUSPSTS at 0 range 0 .. 0; ENUMSPD at 0 range 1 .. 2; EERR at 0 range 3 .. 3; Reserved_4_7 at 0 range 4 .. 7; FNSOF at 0 range 8 .. 21; Reserved_22_31 at 0 range 22 .. 31; end record; -- OTG_HS device IN endpoint common interrupt mask register type OTG_HS_DIEPMSK_Register is record -- Transfer completed interrupt mask XFRCM : Boolean := False; -- Endpoint disabled interrupt mask EPDM : Boolean := False; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- Timeout condition mask (nonisochronous endpoints) TOM : Boolean := False; -- IN token received when TxFIFO empty mask ITTXFEMSK : Boolean := False; -- IN token received with EP mismatch mask INEPNMM : Boolean := False; -- IN endpoint NAK effective mask INEPNEM : Boolean := False; -- unspecified Reserved_7_7 : HAL.Bit := 16#0#; -- FIFO underrun mask TXFURM : Boolean := False; -- BNA interrupt mask BIM : Boolean := False; -- unspecified Reserved_10_31 : HAL.UInt22 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_DIEPMSK_Register use record XFRCM at 0 range 0 .. 0; EPDM at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; TOM at 0 range 3 .. 3; ITTXFEMSK at 0 range 4 .. 4; INEPNMM at 0 range 5 .. 5; INEPNEM at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; TXFURM at 0 range 8 .. 8; BIM at 0 range 9 .. 9; Reserved_10_31 at 0 range 10 .. 31; end record; -- OTG_HS device OUT endpoint common interrupt mask register type OTG_HS_DOEPMSK_Register is record -- Transfer completed interrupt mask XFRCM : Boolean := False; -- Endpoint disabled interrupt mask EPDM : Boolean := False; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- SETUP phase done mask STUPM : Boolean := False; -- OUT token received when endpoint disabled mask OTEPDM : Boolean := False; -- unspecified Reserved_5_5 : HAL.Bit := 16#0#; -- Back-to-back SETUP packets received mask B2BSTUP : Boolean := False; -- unspecified Reserved_7_7 : HAL.Bit := 16#0#; -- OUT packet error mask OPEM : Boolean := False; -- BNA interrupt mask BOIM : Boolean := False; -- unspecified Reserved_10_31 : HAL.UInt22 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_DOEPMSK_Register use record XFRCM at 0 range 0 .. 0; EPDM at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; STUPM at 0 range 3 .. 3; OTEPDM at 0 range 4 .. 4; Reserved_5_5 at 0 range 5 .. 5; B2BSTUP at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; OPEM at 0 range 8 .. 8; BOIM at 0 range 9 .. 9; Reserved_10_31 at 0 range 10 .. 31; end record; subtype OTG_HS_DAINT_IEPINT_Field is HAL.UInt16; subtype OTG_HS_DAINT_OEPINT_Field is HAL.UInt16; -- OTG_HS device all endpoints interrupt register type OTG_HS_DAINT_Register is record -- Read-only. IN endpoint interrupt bits IEPINT : OTG_HS_DAINT_IEPINT_Field; -- Read-only. OUT endpoint interrupt bits OEPINT : OTG_HS_DAINT_OEPINT_Field; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_DAINT_Register use record IEPINT at 0 range 0 .. 15; OEPINT at 0 range 16 .. 31; end record; subtype OTG_HS_DAINTMSK_IEPM_Field is HAL.UInt16; subtype OTG_HS_DAINTMSK_OEPM_Field is HAL.UInt16; -- OTG_HS all endpoints interrupt mask register type OTG_HS_DAINTMSK_Register is record -- IN EP interrupt mask bits IEPM : OTG_HS_DAINTMSK_IEPM_Field := 16#0#; -- OUT EP interrupt mask bits OEPM : OTG_HS_DAINTMSK_OEPM_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_DAINTMSK_Register use record IEPM at 0 range 0 .. 15; OEPM at 0 range 16 .. 31; end record; subtype OTG_HS_DVBUSDIS_VBUSDT_Field is HAL.UInt16; -- OTG_HS device VBUS discharge time register type OTG_HS_DVBUSDIS_Register is record -- Device VBUS discharge time VBUSDT : OTG_HS_DVBUSDIS_VBUSDT_Field := 16#17D7#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_DVBUSDIS_Register use record VBUSDT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype OTG_HS_DVBUSPULSE_DVBUSP_Field is HAL.UInt12; -- OTG_HS device VBUS pulsing time register type OTG_HS_DVBUSPULSE_Register is record -- Device VBUS pulsing time DVBUSP : OTG_HS_DVBUSPULSE_DVBUSP_Field := 16#5B8#; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_DVBUSPULSE_Register use record DVBUSP at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; subtype OTG_HS_DTHRCTL_TXTHRLEN_Field is HAL.UInt9; subtype OTG_HS_DTHRCTL_RXTHRLEN_Field is HAL.UInt9; -- OTG_HS Device threshold control register type OTG_HS_DTHRCTL_Register is record -- Nonisochronous IN endpoints threshold enable NONISOTHREN : Boolean := False; -- ISO IN endpoint threshold enable ISOTHREN : Boolean := False; -- Transmit threshold length TXTHRLEN : OTG_HS_DTHRCTL_TXTHRLEN_Field := 16#0#; -- unspecified Reserved_11_15 : HAL.UInt5 := 16#0#; -- Receive threshold enable RXTHREN : Boolean := False; -- Receive threshold length RXTHRLEN : OTG_HS_DTHRCTL_RXTHRLEN_Field := 16#0#; -- unspecified Reserved_26_26 : HAL.Bit := 16#0#; -- Arbiter parking enable ARPEN : Boolean := False; -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_DTHRCTL_Register use record NONISOTHREN at 0 range 0 .. 0; ISOTHREN at 0 range 1 .. 1; TXTHRLEN at 0 range 2 .. 10; Reserved_11_15 at 0 range 11 .. 15; RXTHREN at 0 range 16 .. 16; RXTHRLEN at 0 range 17 .. 25; Reserved_26_26 at 0 range 26 .. 26; ARPEN at 0 range 27 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; subtype OTG_HS_DIEPEMPMSK_INEPTXFEM_Field is HAL.UInt16; -- OTG_HS device IN endpoint FIFO empty interrupt mask register type OTG_HS_DIEPEMPMSK_Register is record -- IN EP Tx FIFO empty interrupt mask bits INEPTXFEM : OTG_HS_DIEPEMPMSK_INEPTXFEM_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_DIEPEMPMSK_Register use record INEPTXFEM at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -- OTG_HS device each endpoint interrupt register type OTG_HS_DEACHINT_Register is record -- unspecified Reserved_0_0 : HAL.Bit := 16#0#; -- IN endpoint 1interrupt bit IEP1INT : Boolean := False; -- unspecified Reserved_2_16 : HAL.UInt15 := 16#0#; -- OUT endpoint 1 interrupt bit OEP1INT : Boolean := False; -- unspecified Reserved_18_31 : HAL.UInt14 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_DEACHINT_Register use record Reserved_0_0 at 0 range 0 .. 0; IEP1INT at 0 range 1 .. 1; Reserved_2_16 at 0 range 2 .. 16; OEP1INT at 0 range 17 .. 17; Reserved_18_31 at 0 range 18 .. 31; end record; -- OTG_HS device each endpoint interrupt register mask type OTG_HS_DEACHINTMSK_Register is record -- unspecified Reserved_0_0 : HAL.Bit := 16#0#; -- IN Endpoint 1 interrupt mask bit IEP1INTM : Boolean := False; -- unspecified Reserved_2_16 : HAL.UInt15 := 16#0#; -- OUT Endpoint 1 interrupt mask bit OEP1INTM : Boolean := False; -- unspecified Reserved_18_31 : HAL.UInt14 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_DEACHINTMSK_Register use record Reserved_0_0 at 0 range 0 .. 0; IEP1INTM at 0 range 1 .. 1; Reserved_2_16 at 0 range 2 .. 16; OEP1INTM at 0 range 17 .. 17; Reserved_18_31 at 0 range 18 .. 31; end record; -- OTG_HS device each in endpoint-1 interrupt register type OTG_HS_DIEPEACHMSK1_Register is record -- Transfer completed interrupt mask XFRCM : Boolean := False; -- Endpoint disabled interrupt mask EPDM : Boolean := False; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- Timeout condition mask (nonisochronous endpoints) TOM : Boolean := False; -- IN token received when TxFIFO empty mask ITTXFEMSK : Boolean := False; -- IN token received with EP mismatch mask INEPNMM : Boolean := False; -- IN endpoint NAK effective mask INEPNEM : Boolean := False; -- unspecified Reserved_7_7 : HAL.Bit := 16#0#; -- FIFO underrun mask TXFURM : Boolean := False; -- BNA interrupt mask BIM : Boolean := False; -- unspecified Reserved_10_12 : HAL.UInt3 := 16#0#; -- NAK interrupt mask NAKM : Boolean := False; -- unspecified Reserved_14_31 : HAL.UInt18 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_DIEPEACHMSK1_Register use record XFRCM at 0 range 0 .. 0; EPDM at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; TOM at 0 range 3 .. 3; ITTXFEMSK at 0 range 4 .. 4; INEPNMM at 0 range 5 .. 5; INEPNEM at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; TXFURM at 0 range 8 .. 8; BIM at 0 range 9 .. 9; Reserved_10_12 at 0 range 10 .. 12; NAKM at 0 range 13 .. 13; Reserved_14_31 at 0 range 14 .. 31; end record; -- OTG_HS device each OUT endpoint-1 interrupt register type OTG_HS_DOEPEACHMSK1_Register is record -- Transfer completed interrupt mask XFRCM : Boolean := False; -- Endpoint disabled interrupt mask EPDM : Boolean := False; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- Timeout condition mask TOM : Boolean := False; -- IN token received when TxFIFO empty mask ITTXFEMSK : Boolean := False; -- IN token received with EP mismatch mask INEPNMM : Boolean := False; -- IN endpoint NAK effective mask INEPNEM : Boolean := False; -- unspecified Reserved_7_7 : HAL.Bit := 16#0#; -- OUT packet error mask TXFURM : Boolean := False; -- BNA interrupt mask BIM : Boolean := False; -- unspecified Reserved_10_11 : HAL.UInt2 := 16#0#; -- Bubble error interrupt mask BERRM : Boolean := False; -- NAK interrupt mask NAKM : Boolean := False; -- NYET interrupt mask NYETM : Boolean := False; -- unspecified Reserved_15_31 : HAL.UInt17 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_DOEPEACHMSK1_Register use record XFRCM at 0 range 0 .. 0; EPDM at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; TOM at 0 range 3 .. 3; ITTXFEMSK at 0 range 4 .. 4; INEPNMM at 0 range 5 .. 5; INEPNEM at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; TXFURM at 0 range 8 .. 8; BIM at 0 range 9 .. 9; Reserved_10_11 at 0 range 10 .. 11; BERRM at 0 range 12 .. 12; NAKM at 0 range 13 .. 13; NYETM at 0 range 14 .. 14; Reserved_15_31 at 0 range 15 .. 31; end record; subtype OTG_HS_DIEPCTL_MPSIZ_Field is HAL.UInt11; subtype OTG_HS_DIEPCTL_EPTYP_Field is HAL.UInt2; subtype OTG_HS_DIEPCTL_TXFNUM_Field is HAL.UInt4; -- OTG device endpoint-0 control register type OTG_HS_DIEPCTL_Register is record -- Maximum packet size MPSIZ : OTG_HS_DIEPCTL_MPSIZ_Field := 16#0#; -- unspecified Reserved_11_14 : HAL.UInt4 := 16#0#; -- USB active endpoint USBAEP : Boolean := False; -- Read-only. Even/odd frame EONUM_DPID : Boolean := False; -- Read-only. NAK status NAKSTS : Boolean := False; -- Endpoint type EPTYP : OTG_HS_DIEPCTL_EPTYP_Field := 16#0#; -- unspecified Reserved_20_20 : HAL.Bit := 16#0#; -- STALL handshake Stall : Boolean := False; -- TxFIFO number TXFNUM : OTG_HS_DIEPCTL_TXFNUM_Field := 16#0#; -- Write-only. Clear NAK CNAK : Boolean := False; -- Write-only. Set NAK SNAK : Boolean := False; -- Write-only. Set DATA0 PID SD0PID_SEVNFRM : Boolean := False; -- Write-only. Set odd frame SODDFRM : Boolean := False; -- Endpoint disable EPDIS : Boolean := False; -- Endpoint enable EPENA : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_DIEPCTL_Register use record MPSIZ at 0 range 0 .. 10; Reserved_11_14 at 0 range 11 .. 14; USBAEP at 0 range 15 .. 15; EONUM_DPID at 0 range 16 .. 16; NAKSTS at 0 range 17 .. 17; EPTYP at 0 range 18 .. 19; Reserved_20_20 at 0 range 20 .. 20; Stall at 0 range 21 .. 21; TXFNUM at 0 range 22 .. 25; CNAK at 0 range 26 .. 26; SNAK at 0 range 27 .. 27; SD0PID_SEVNFRM at 0 range 28 .. 28; SODDFRM at 0 range 29 .. 29; EPDIS at 0 range 30 .. 30; EPENA at 0 range 31 .. 31; end record; -- OTG device endpoint-0 interrupt register type OTG_HS_DIEPINT_Register is record -- Transfer completed interrupt XFRC : Boolean := False; -- Endpoint disabled interrupt EPDISD : Boolean := False; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- Timeout condition TOC : Boolean := False; -- IN token received when TxFIFO is empty ITTXFE : Boolean := False; -- unspecified Reserved_5_5 : HAL.Bit := 16#0#; -- IN endpoint NAK effective INEPNE : Boolean := False; -- Read-only. Transmit FIFO empty TXFE : Boolean := True; -- Transmit Fifo Underrun TXFIFOUDRN : Boolean := False; -- Buffer not available interrupt BNA : Boolean := False; -- unspecified Reserved_10_10 : HAL.Bit := 16#0#; -- Packet dropped status PKTDRPSTS : Boolean := False; -- Babble error interrupt BERR : Boolean := False; -- NAK interrupt NAK : Boolean := False; -- unspecified Reserved_14_31 : HAL.UInt18 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_DIEPINT_Register use record XFRC at 0 range 0 .. 0; EPDISD at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; TOC at 0 range 3 .. 3; ITTXFE at 0 range 4 .. 4; Reserved_5_5 at 0 range 5 .. 5; INEPNE at 0 range 6 .. 6; TXFE at 0 range 7 .. 7; TXFIFOUDRN at 0 range 8 .. 8; BNA at 0 range 9 .. 9; Reserved_10_10 at 0 range 10 .. 10; PKTDRPSTS at 0 range 11 .. 11; BERR at 0 range 12 .. 12; NAK at 0 range 13 .. 13; Reserved_14_31 at 0 range 14 .. 31; end record; subtype OTG_HS_DIEPTSIZ0_XFRSIZ_Field is HAL.UInt7; subtype OTG_HS_DIEPTSIZ0_PKTCNT_Field is HAL.UInt2; -- OTG_HS device IN endpoint 0 transfer size register type OTG_HS_DIEPTSIZ0_Register is record -- Transfer size XFRSIZ : OTG_HS_DIEPTSIZ0_XFRSIZ_Field := 16#0#; -- unspecified Reserved_7_18 : HAL.UInt12 := 16#0#; -- Packet count PKTCNT : OTG_HS_DIEPTSIZ0_PKTCNT_Field := 16#0#; -- unspecified Reserved_21_31 : HAL.UInt11 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_DIEPTSIZ0_Register use record XFRSIZ at 0 range 0 .. 6; Reserved_7_18 at 0 range 7 .. 18; PKTCNT at 0 range 19 .. 20; Reserved_21_31 at 0 range 21 .. 31; end record; subtype OTG_HS_DTXFSTS_INEPTFSAV_Field is HAL.UInt16; -- OTG_HS device IN endpoint transmit FIFO status register type OTG_HS_DTXFSTS_Register is record -- Read-only. IN endpoint TxFIFO space avail INEPTFSAV : OTG_HS_DTXFSTS_INEPTFSAV_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_DTXFSTS_Register use record INEPTFSAV at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype OTG_HS_DIEPTSIZ_XFRSIZ_Field is HAL.UInt19; subtype OTG_HS_DIEPTSIZ_PKTCNT_Field is HAL.UInt10; subtype OTG_HS_DIEPTSIZ_MCNT_Field is HAL.UInt2; -- OTG_HS device endpoint transfer size register type OTG_HS_DIEPTSIZ_Register is record -- Transfer size XFRSIZ : OTG_HS_DIEPTSIZ_XFRSIZ_Field := 16#0#; -- Packet count PKTCNT : OTG_HS_DIEPTSIZ_PKTCNT_Field := 16#0#; -- Multi count MCNT : OTG_HS_DIEPTSIZ_MCNT_Field := 16#0#; -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_DIEPTSIZ_Register use record XFRSIZ at 0 range 0 .. 18; PKTCNT at 0 range 19 .. 28; MCNT at 0 range 29 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; subtype OTG_HS_DOEPCTL0_MPSIZ_Field is HAL.UInt2; subtype OTG_HS_DOEPCTL0_EPTYP_Field is HAL.UInt2; -- OTG_HS device control OUT endpoint 0 control register type OTG_HS_DOEPCTL0_Register is record -- Read-only. Maximum packet size MPSIZ : OTG_HS_DOEPCTL0_MPSIZ_Field := 16#0#; -- unspecified Reserved_2_14 : HAL.UInt13 := 16#0#; -- Read-only. USB active endpoint USBAEP : Boolean := True; -- unspecified Reserved_16_16 : HAL.Bit := 16#0#; -- Read-only. NAK status NAKSTS : Boolean := False; -- Read-only. Endpoint type EPTYP : OTG_HS_DOEPCTL0_EPTYP_Field := 16#0#; -- Snoop mode SNPM : Boolean := False; -- STALL handshake Stall : Boolean := False; -- unspecified Reserved_22_25 : HAL.UInt4 := 16#0#; -- Write-only. Clear NAK CNAK : Boolean := False; -- Write-only. Set NAK SNAK : Boolean := False; -- unspecified Reserved_28_29 : HAL.UInt2 := 16#0#; -- Read-only. Endpoint disable EPDIS : Boolean := False; -- Write-only. Endpoint enable EPENA : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_DOEPCTL0_Register use record MPSIZ at 0 range 0 .. 1; Reserved_2_14 at 0 range 2 .. 14; USBAEP at 0 range 15 .. 15; Reserved_16_16 at 0 range 16 .. 16; NAKSTS at 0 range 17 .. 17; EPTYP at 0 range 18 .. 19; SNPM at 0 range 20 .. 20; Stall at 0 range 21 .. 21; Reserved_22_25 at 0 range 22 .. 25; CNAK at 0 range 26 .. 26; SNAK at 0 range 27 .. 27; Reserved_28_29 at 0 range 28 .. 29; EPDIS at 0 range 30 .. 30; EPENA at 0 range 31 .. 31; end record; -- OTG_HS device endpoint-0 interrupt register type OTG_HS_DOEPINT_Register is record -- Transfer completed interrupt XFRC : Boolean := False; -- Endpoint disabled interrupt EPDISD : Boolean := False; -- unspecified Reserved_2_2 : HAL.Bit := 16#0#; -- SETUP phase done STUP : Boolean := False; -- OUT token received when endpoint disabled OTEPDIS : Boolean := False; -- unspecified Reserved_5_5 : HAL.Bit := 16#0#; -- Back-to-back SETUP packets received B2BSTUP : Boolean := False; -- unspecified Reserved_7_13 : HAL.UInt7 := 16#1#; -- NYET interrupt NYET : Boolean := False; -- unspecified Reserved_15_31 : HAL.UInt17 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_DOEPINT_Register use record XFRC at 0 range 0 .. 0; EPDISD at 0 range 1 .. 1; Reserved_2_2 at 0 range 2 .. 2; STUP at 0 range 3 .. 3; OTEPDIS at 0 range 4 .. 4; Reserved_5_5 at 0 range 5 .. 5; B2BSTUP at 0 range 6 .. 6; Reserved_7_13 at 0 range 7 .. 13; NYET at 0 range 14 .. 14; Reserved_15_31 at 0 range 15 .. 31; end record; subtype OTG_HS_DOEPTSIZ0_XFRSIZ_Field is HAL.UInt7; subtype OTG_HS_DOEPTSIZ0_STUPCNT_Field is HAL.UInt2; -- OTG_HS device endpoint-1 transfer size register type OTG_HS_DOEPTSIZ0_Register is record -- Transfer size XFRSIZ : OTG_HS_DOEPTSIZ0_XFRSIZ_Field := 16#0#; -- unspecified Reserved_7_18 : HAL.UInt12 := 16#0#; -- Packet count PKTCNT : Boolean := False; -- unspecified Reserved_20_28 : HAL.UInt9 := 16#0#; -- SETUP packet count STUPCNT : OTG_HS_DOEPTSIZ0_STUPCNT_Field := 16#0#; -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_DOEPTSIZ0_Register use record XFRSIZ at 0 range 0 .. 6; Reserved_7_18 at 0 range 7 .. 18; PKTCNT at 0 range 19 .. 19; Reserved_20_28 at 0 range 20 .. 28; STUPCNT at 0 range 29 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; subtype OTG_HS_DOEPCTL_MPSIZ_Field is HAL.UInt11; subtype OTG_HS_DOEPCTL_EPTYP_Field is HAL.UInt2; -- OTG device endpoint-1 control register type OTG_HS_DOEPCTL_Register is record -- Maximum packet size MPSIZ : OTG_HS_DOEPCTL_MPSIZ_Field := 16#0#; -- unspecified Reserved_11_14 : HAL.UInt4 := 16#0#; -- USB active endpoint USBAEP : Boolean := False; -- Read-only. Even odd frame/Endpoint data PID EONUM_DPID : Boolean := False; -- Read-only. NAK status NAKSTS : Boolean := False; -- Endpoint type EPTYP : OTG_HS_DOEPCTL_EPTYP_Field := 16#0#; -- Snoop mode SNPM : Boolean := False; -- STALL handshake Stall : Boolean := False; -- unspecified Reserved_22_25 : HAL.UInt4 := 16#0#; -- Write-only. Clear NAK CNAK : Boolean := False; -- Write-only. Set NAK SNAK : Boolean := False; -- Write-only. Set DATA0 PID/Set even frame SD0PID_SEVNFRM : Boolean := False; -- Write-only. Set odd frame SODDFRM : Boolean := False; -- Endpoint disable EPDIS : Boolean := False; -- Endpoint enable EPENA : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_DOEPCTL_Register use record MPSIZ at 0 range 0 .. 10; Reserved_11_14 at 0 range 11 .. 14; USBAEP at 0 range 15 .. 15; EONUM_DPID at 0 range 16 .. 16; NAKSTS at 0 range 17 .. 17; EPTYP at 0 range 18 .. 19; SNPM at 0 range 20 .. 20; Stall at 0 range 21 .. 21; Reserved_22_25 at 0 range 22 .. 25; CNAK at 0 range 26 .. 26; SNAK at 0 range 27 .. 27; SD0PID_SEVNFRM at 0 range 28 .. 28; SODDFRM at 0 range 29 .. 29; EPDIS at 0 range 30 .. 30; EPENA at 0 range 31 .. 31; end record; subtype OTG_HS_DOEPTSIZ_XFRSIZ_Field is HAL.UInt19; subtype OTG_HS_DOEPTSIZ_PKTCNT_Field is HAL.UInt10; subtype OTG_HS_DOEPTSIZ_RXDPID_STUPCNT_Field is HAL.UInt2; -- OTG_HS device endpoint-2 transfer size register type OTG_HS_DOEPTSIZ_Register is record -- Transfer size XFRSIZ : OTG_HS_DOEPTSIZ_XFRSIZ_Field := 16#0#; -- Packet count PKTCNT : OTG_HS_DOEPTSIZ_PKTCNT_Field := 16#0#; -- Received data PID/SETUP packet count RXDPID_STUPCNT : OTG_HS_DOEPTSIZ_RXDPID_STUPCNT_Field := 16#0#; -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_DOEPTSIZ_Register use record XFRSIZ at 0 range 0 .. 18; PKTCNT at 0 range 19 .. 28; RXDPID_STUPCNT at 0 range 29 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; -- OTG_HS control and status register type OTG_HS_GOTGCTL_Register is record -- Read-only. Session request success SRQSCS : Boolean := False; -- Session request SRQ : Boolean := False; -- unspecified Reserved_2_7 : HAL.UInt6 := 16#0#; -- Read-only. Host negotiation success HNGSCS : Boolean := False; -- HNP request HNPRQ : Boolean := False; -- Host set HNP enable HSHNPEN : Boolean := False; -- Device HNP enabled DHNPEN : Boolean := True; -- unspecified Reserved_12_15 : HAL.UInt4 := 16#0#; -- Read-only. Connector ID status CIDSTS : Boolean := False; -- Read-only. Long/short debounce time DBCT : Boolean := False; -- Read-only. A-session valid ASVLD : Boolean := False; -- Read-only. B-session valid BSVLD : Boolean := False; -- unspecified Reserved_20_31 : HAL.UInt12 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_GOTGCTL_Register use record SRQSCS at 0 range 0 .. 0; SRQ at 0 range 1 .. 1; Reserved_2_7 at 0 range 2 .. 7; HNGSCS at 0 range 8 .. 8; HNPRQ at 0 range 9 .. 9; HSHNPEN at 0 range 10 .. 10; DHNPEN at 0 range 11 .. 11; Reserved_12_15 at 0 range 12 .. 15; CIDSTS at 0 range 16 .. 16; DBCT at 0 range 17 .. 17; ASVLD at 0 range 18 .. 18; BSVLD at 0 range 19 .. 19; Reserved_20_31 at 0 range 20 .. 31; end record; -- OTG_HS interrupt register type OTG_HS_GOTGINT_Register is record -- unspecified Reserved_0_1 : HAL.UInt2 := 16#0#; -- Session end detected SEDET : Boolean := False; -- unspecified Reserved_3_7 : HAL.UInt5 := 16#0#; -- Session request success status change SRSSCHG : Boolean := False; -- Host negotiation success status change HNSSCHG : Boolean := False; -- unspecified Reserved_10_16 : HAL.UInt7 := 16#0#; -- Host negotiation detected HNGDET : Boolean := False; -- A-device timeout change ADTOCHG : Boolean := False; -- Debounce done DBCDNE : Boolean := False; -- unspecified Reserved_20_31 : HAL.UInt12 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_GOTGINT_Register use record Reserved_0_1 at 0 range 0 .. 1; SEDET at 0 range 2 .. 2; Reserved_3_7 at 0 range 3 .. 7; SRSSCHG at 0 range 8 .. 8; HNSSCHG at 0 range 9 .. 9; Reserved_10_16 at 0 range 10 .. 16; HNGDET at 0 range 17 .. 17; ADTOCHG at 0 range 18 .. 18; DBCDNE at 0 range 19 .. 19; Reserved_20_31 at 0 range 20 .. 31; end record; subtype OTG_HS_GAHBCFG_HBSTLEN_Field is HAL.UInt4; -- OTG_HS AHB configuration register type OTG_HS_GAHBCFG_Register is record -- Global interrupt mask GINT : Boolean := False; -- Burst length/type HBSTLEN : OTG_HS_GAHBCFG_HBSTLEN_Field := 16#0#; -- DMA enable DMAEN : Boolean := False; -- unspecified Reserved_6_6 : HAL.Bit := 16#0#; -- TxFIFO empty level TXFELVL : Boolean := False; -- Periodic TxFIFO empty level PTXFELVL : Boolean := False; -- unspecified Reserved_9_31 : HAL.UInt23 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_GAHBCFG_Register use record GINT at 0 range 0 .. 0; HBSTLEN at 0 range 1 .. 4; DMAEN at 0 range 5 .. 5; Reserved_6_6 at 0 range 6 .. 6; TXFELVL at 0 range 7 .. 7; PTXFELVL at 0 range 8 .. 8; Reserved_9_31 at 0 range 9 .. 31; end record; subtype OTG_HS_GUSBCFG_TOCAL_Field is HAL.UInt3; subtype OTG_HS_GUSBCFG_TRDT_Field is HAL.UInt4; -- OTG_HS USB configuration register type OTG_HS_GUSBCFG_Register is record -- FS timeout calibration TOCAL : OTG_HS_GUSBCFG_TOCAL_Field := 16#0#; -- unspecified Reserved_3_5 : HAL.UInt3 := 16#0#; -- Write-only. USB 2.0 high-speed ULPI PHY or USB 1.1 full-speed serial -- transceiver select PHYSEL : Boolean := False; -- unspecified Reserved_7_7 : HAL.Bit := 16#0#; -- SRP-capable SRPCAP : Boolean := False; -- HNP-capable HNPCAP : Boolean := True; -- USB turnaround time TRDT : OTG_HS_GUSBCFG_TRDT_Field := 16#2#; -- unspecified Reserved_14_14 : HAL.Bit := 16#0#; -- PHY Low-power clock select PHYLPCS : Boolean := False; -- unspecified Reserved_16_16 : HAL.Bit := 16#0#; -- ULPI FS/LS select ULPIFSLS : Boolean := False; -- ULPI Auto-resume ULPIAR : Boolean := False; -- ULPI Clock SuspendM ULPICSM : Boolean := False; -- ULPI External VBUS Drive ULPIEVBUSD : Boolean := False; -- ULPI external VBUS indicator ULPIEVBUSI : Boolean := False; -- TermSel DLine pulsing selection TSDPS : Boolean := False; -- Indicator complement PCCI : Boolean := False; -- Indicator pass through PTCI : Boolean := False; -- ULPI interface protect disable ULPIIPD : Boolean := False; -- unspecified Reserved_26_28 : HAL.UInt3 := 16#0#; -- Forced host mode FHMOD : Boolean := False; -- Forced peripheral mode FDMOD : Boolean := False; -- Corrupt Tx packet CTXPKT : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_GUSBCFG_Register use record TOCAL at 0 range 0 .. 2; Reserved_3_5 at 0 range 3 .. 5; PHYSEL at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; SRPCAP at 0 range 8 .. 8; HNPCAP at 0 range 9 .. 9; TRDT at 0 range 10 .. 13; Reserved_14_14 at 0 range 14 .. 14; PHYLPCS at 0 range 15 .. 15; Reserved_16_16 at 0 range 16 .. 16; ULPIFSLS at 0 range 17 .. 17; ULPIAR at 0 range 18 .. 18; ULPICSM at 0 range 19 .. 19; ULPIEVBUSD at 0 range 20 .. 20; ULPIEVBUSI at 0 range 21 .. 21; TSDPS at 0 range 22 .. 22; PCCI at 0 range 23 .. 23; PTCI at 0 range 24 .. 24; ULPIIPD at 0 range 25 .. 25; Reserved_26_28 at 0 range 26 .. 28; FHMOD at 0 range 29 .. 29; FDMOD at 0 range 30 .. 30; CTXPKT at 0 range 31 .. 31; end record; subtype OTG_HS_GRSTCTL_TXFNUM_Field is HAL.UInt5; -- OTG_HS reset register type OTG_HS_GRSTCTL_Register is record -- Core soft reset CSRST : Boolean := False; -- HCLK soft reset HSRST : Boolean := False; -- Host frame counter reset FCRST : Boolean := False; -- unspecified Reserved_3_3 : HAL.Bit := 16#0#; -- RxFIFO flush RXFFLSH : Boolean := False; -- TxFIFO flush TXFFLSH : Boolean := False; -- TxFIFO number TXFNUM : OTG_HS_GRSTCTL_TXFNUM_Field := 16#0#; -- unspecified Reserved_11_29 : HAL.UInt19 := 16#40000#; -- Read-only. DMA request signal DMAREQ : Boolean := False; -- Read-only. AHB master idle AHBIDL : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_GRSTCTL_Register use record CSRST at 0 range 0 .. 0; HSRST at 0 range 1 .. 1; FCRST at 0 range 2 .. 2; Reserved_3_3 at 0 range 3 .. 3; RXFFLSH at 0 range 4 .. 4; TXFFLSH at 0 range 5 .. 5; TXFNUM at 0 range 6 .. 10; Reserved_11_29 at 0 range 11 .. 29; DMAREQ at 0 range 30 .. 30; AHBIDL at 0 range 31 .. 31; end record; -- OTG_HS core interrupt register type OTG_HS_GINTSTS_Register is record -- Read-only. Current mode of operation CMOD : Boolean := False; -- Mode mismatch interrupt MMIS : Boolean := False; -- Read-only. OTG interrupt OTGINT : Boolean := False; -- Start of frame SOF : Boolean := False; -- Read-only. RxFIFO nonempty RXFLVL : Boolean := False; -- Read-only. Nonperiodic TxFIFO empty NPTXFE : Boolean := True; -- Read-only. Global IN nonperiodic NAK effective GINAKEFF : Boolean := False; -- Read-only. Global OUT NAK effective BOUTNAKEFF : Boolean := False; -- unspecified Reserved_8_9 : HAL.UInt2 := 16#0#; -- Early suspend ESUSP : Boolean := False; -- USB suspend USBSUSP : Boolean := False; -- USB reset USBRST : Boolean := False; -- Enumeration done ENUMDNE : Boolean := False; -- Isochronous OUT packet dropped interrupt ISOODRP : Boolean := False; -- End of periodic frame interrupt EOPF : Boolean := False; -- unspecified Reserved_16_17 : HAL.UInt2 := 16#0#; -- Read-only. IN endpoint interrupt IEPINT : Boolean := False; -- Read-only. OUT endpoint interrupt OEPINT : Boolean := False; -- Incomplete isochronous IN transfer IISOIXFR : Boolean := False; -- Incomplete periodic transfer PXFR_INCOMPISOOUT : Boolean := False; -- Data fetch suspended DATAFSUSP : Boolean := False; -- unspecified Reserved_23_23 : HAL.Bit := 16#0#; -- Read-only. Host port interrupt HPRTINT : Boolean := False; -- Read-only. Host channels interrupt HCINT : Boolean := False; -- Read-only. Periodic TxFIFO empty PTXFE : Boolean := True; -- unspecified Reserved_27_27 : HAL.Bit := 16#0#; -- Connector ID status change CIDSCHG : Boolean := False; -- Disconnect detected interrupt DISCINT : Boolean := False; -- Session request/new session detected interrupt SRQINT : Boolean := False; -- Resume/remote wakeup detected interrupt WKUINT : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_GINTSTS_Register use record CMOD at 0 range 0 .. 0; MMIS at 0 range 1 .. 1; OTGINT at 0 range 2 .. 2; SOF at 0 range 3 .. 3; RXFLVL at 0 range 4 .. 4; NPTXFE at 0 range 5 .. 5; GINAKEFF at 0 range 6 .. 6; BOUTNAKEFF at 0 range 7 .. 7; Reserved_8_9 at 0 range 8 .. 9; ESUSP at 0 range 10 .. 10; USBSUSP at 0 range 11 .. 11; USBRST at 0 range 12 .. 12; ENUMDNE at 0 range 13 .. 13; ISOODRP at 0 range 14 .. 14; EOPF at 0 range 15 .. 15; Reserved_16_17 at 0 range 16 .. 17; IEPINT at 0 range 18 .. 18; OEPINT at 0 range 19 .. 19; IISOIXFR at 0 range 20 .. 20; PXFR_INCOMPISOOUT at 0 range 21 .. 21; DATAFSUSP at 0 range 22 .. 22; Reserved_23_23 at 0 range 23 .. 23; HPRTINT at 0 range 24 .. 24; HCINT at 0 range 25 .. 25; PTXFE at 0 range 26 .. 26; Reserved_27_27 at 0 range 27 .. 27; CIDSCHG at 0 range 28 .. 28; DISCINT at 0 range 29 .. 29; SRQINT at 0 range 30 .. 30; WKUINT at 0 range 31 .. 31; end record; -- OTG_HS interrupt mask register type OTG_HS_GINTMSK_Register is record -- unspecified Reserved_0_0 : HAL.Bit := 16#0#; -- Mode mismatch interrupt mask MMISM : Boolean := False; -- OTG interrupt mask OTGINT : Boolean := False; -- Start of frame mask SOFM : Boolean := False; -- Receive FIFO nonempty mask RXFLVLM : Boolean := False; -- Nonperiodic TxFIFO empty mask NPTXFEM : Boolean := False; -- Global nonperiodic IN NAK effective mask GINAKEFFM : Boolean := False; -- Global OUT NAK effective mask GONAKEFFM : Boolean := False; -- unspecified Reserved_8_9 : HAL.UInt2 := 16#0#; -- Early suspend mask ESUSPM : Boolean := False; -- USB suspend mask USBSUSPM : Boolean := False; -- USB reset mask USBRST : Boolean := False; -- Enumeration done mask ENUMDNEM : Boolean := False; -- Isochronous OUT packet dropped interrupt mask ISOODRPM : Boolean := False; -- End of periodic frame interrupt mask EOPFM : Boolean := False; -- unspecified Reserved_16_16 : HAL.Bit := 16#0#; -- Endpoint mismatch interrupt mask EPMISM : Boolean := False; -- IN endpoints interrupt mask IEPINT : Boolean := False; -- OUT endpoints interrupt mask OEPINT : Boolean := False; -- Incomplete isochronous IN transfer mask IISOIXFRM : Boolean := False; -- Incomplete periodic transfer mask PXFRM_IISOOXFRM : Boolean := False; -- Data fetch suspended mask FSUSPM : Boolean := False; -- unspecified Reserved_23_23 : HAL.Bit := 16#0#; -- Read-only. Host port interrupt mask PRTIM : Boolean := False; -- Host channels interrupt mask HCIM : Boolean := False; -- Periodic TxFIFO empty mask PTXFEM : Boolean := False; -- unspecified Reserved_27_27 : HAL.Bit := 16#0#; -- Connector ID status change mask CIDSCHGM : Boolean := False; -- Disconnect detected interrupt mask DISCINT : Boolean := False; -- Session request/new session detected interrupt mask SRQIM : Boolean := False; -- Resume/remote wakeup detected interrupt mask WUIM : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_GINTMSK_Register use record Reserved_0_0 at 0 range 0 .. 0; MMISM at 0 range 1 .. 1; OTGINT at 0 range 2 .. 2; SOFM at 0 range 3 .. 3; RXFLVLM at 0 range 4 .. 4; NPTXFEM at 0 range 5 .. 5; GINAKEFFM at 0 range 6 .. 6; GONAKEFFM at 0 range 7 .. 7; Reserved_8_9 at 0 range 8 .. 9; ESUSPM at 0 range 10 .. 10; USBSUSPM at 0 range 11 .. 11; USBRST at 0 range 12 .. 12; ENUMDNEM at 0 range 13 .. 13; ISOODRPM at 0 range 14 .. 14; EOPFM at 0 range 15 .. 15; Reserved_16_16 at 0 range 16 .. 16; EPMISM at 0 range 17 .. 17; IEPINT at 0 range 18 .. 18; OEPINT at 0 range 19 .. 19; IISOIXFRM at 0 range 20 .. 20; PXFRM_IISOOXFRM at 0 range 21 .. 21; FSUSPM at 0 range 22 .. 22; Reserved_23_23 at 0 range 23 .. 23; PRTIM at 0 range 24 .. 24; HCIM at 0 range 25 .. 25; PTXFEM at 0 range 26 .. 26; Reserved_27_27 at 0 range 27 .. 27; CIDSCHGM at 0 range 28 .. 28; DISCINT at 0 range 29 .. 29; SRQIM at 0 range 30 .. 30; WUIM at 0 range 31 .. 31; end record; subtype OTG_HS_GRXSTSR_Host_CHNUM_Field is HAL.UInt4; subtype OTG_HS_GRXSTSR_Host_BCNT_Field is HAL.UInt11; subtype OTG_HS_GRXSTSR_Host_DPID_Field is HAL.UInt2; subtype OTG_HS_GRXSTSR_Host_PKTSTS_Field is HAL.UInt4; -- OTG_HS Receive status debug read register (host mode) type OTG_HS_GRXSTSR_Host_Register is record -- Read-only. Channel number CHNUM : OTG_HS_GRXSTSR_Host_CHNUM_Field; -- Read-only. Byte count BCNT : OTG_HS_GRXSTSR_Host_BCNT_Field; -- Read-only. Data PID DPID : OTG_HS_GRXSTSR_Host_DPID_Field; -- Read-only. Packet status PKTSTS : OTG_HS_GRXSTSR_Host_PKTSTS_Field; -- unspecified Reserved_21_31 : HAL.UInt11; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_GRXSTSR_Host_Register use record CHNUM at 0 range 0 .. 3; BCNT at 0 range 4 .. 14; DPID at 0 range 15 .. 16; PKTSTS at 0 range 17 .. 20; Reserved_21_31 at 0 range 21 .. 31; end record; subtype OTG_HS_GRXSTSR_Peripheral_EPNUM_Field is HAL.UInt4; subtype OTG_HS_GRXSTSR_Peripheral_BCNT_Field is HAL.UInt11; subtype OTG_HS_GRXSTSR_Peripheral_DPID_Field is HAL.UInt2; subtype OTG_HS_GRXSTSR_Peripheral_PKTSTS_Field is HAL.UInt4; subtype OTG_HS_GRXSTSR_Peripheral_FRMNUM_Field is HAL.UInt4; -- OTG_HS Receive status debug read register (peripheral mode mode) type OTG_HS_GRXSTSR_Peripheral_Register is record -- Read-only. Endpoint number EPNUM : OTG_HS_GRXSTSR_Peripheral_EPNUM_Field; -- Read-only. Byte count BCNT : OTG_HS_GRXSTSR_Peripheral_BCNT_Field; -- Read-only. Data PID DPID : OTG_HS_GRXSTSR_Peripheral_DPID_Field; -- Read-only. Packet status PKTSTS : OTG_HS_GRXSTSR_Peripheral_PKTSTS_Field; -- Read-only. Frame number FRMNUM : OTG_HS_GRXSTSR_Peripheral_FRMNUM_Field; -- unspecified Reserved_25_31 : HAL.UInt7; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_GRXSTSR_Peripheral_Register use record EPNUM at 0 range 0 .. 3; BCNT at 0 range 4 .. 14; DPID at 0 range 15 .. 16; PKTSTS at 0 range 17 .. 20; FRMNUM at 0 range 21 .. 24; Reserved_25_31 at 0 range 25 .. 31; end record; subtype OTG_HS_GRXSTSP_Host_CHNUM_Field is HAL.UInt4; subtype OTG_HS_GRXSTSP_Host_BCNT_Field is HAL.UInt11; subtype OTG_HS_GRXSTSP_Host_DPID_Field is HAL.UInt2; subtype OTG_HS_GRXSTSP_Host_PKTSTS_Field is HAL.UInt4; -- OTG_HS status read and pop register (host mode) type OTG_HS_GRXSTSP_Host_Register is record -- Read-only. Channel number CHNUM : OTG_HS_GRXSTSP_Host_CHNUM_Field; -- Read-only. Byte count BCNT : OTG_HS_GRXSTSP_Host_BCNT_Field; -- Read-only. Data PID DPID : OTG_HS_GRXSTSP_Host_DPID_Field; -- Read-only. Packet status PKTSTS : OTG_HS_GRXSTSP_Host_PKTSTS_Field; -- unspecified Reserved_21_31 : HAL.UInt11; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_GRXSTSP_Host_Register use record CHNUM at 0 range 0 .. 3; BCNT at 0 range 4 .. 14; DPID at 0 range 15 .. 16; PKTSTS at 0 range 17 .. 20; Reserved_21_31 at 0 range 21 .. 31; end record; subtype OTG_HS_GRXSTSP_Peripheral_EPNUM_Field is HAL.UInt4; subtype OTG_HS_GRXSTSP_Peripheral_BCNT_Field is HAL.UInt11; subtype OTG_HS_GRXSTSP_Peripheral_DPID_Field is HAL.UInt2; subtype OTG_HS_GRXSTSP_Peripheral_PKTSTS_Field is HAL.UInt4; subtype OTG_HS_GRXSTSP_Peripheral_FRMNUM_Field is HAL.UInt4; -- OTG_HS status read and pop register (peripheral mode) type OTG_HS_GRXSTSP_Peripheral_Register is record -- Read-only. Endpoint number EPNUM : OTG_HS_GRXSTSP_Peripheral_EPNUM_Field; -- Read-only. Byte count BCNT : OTG_HS_GRXSTSP_Peripheral_BCNT_Field; -- Read-only. Data PID DPID : OTG_HS_GRXSTSP_Peripheral_DPID_Field; -- Read-only. Packet status PKTSTS : OTG_HS_GRXSTSP_Peripheral_PKTSTS_Field; -- Read-only. Frame number FRMNUM : OTG_HS_GRXSTSP_Peripheral_FRMNUM_Field; -- unspecified Reserved_25_31 : HAL.UInt7; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_GRXSTSP_Peripheral_Register use record EPNUM at 0 range 0 .. 3; BCNT at 0 range 4 .. 14; DPID at 0 range 15 .. 16; PKTSTS at 0 range 17 .. 20; FRMNUM at 0 range 21 .. 24; Reserved_25_31 at 0 range 25 .. 31; end record; subtype OTG_HS_GRXFSIZ_RXFD_Field is HAL.UInt16; -- OTG_HS Receive FIFO size register type OTG_HS_GRXFSIZ_Register is record -- RxFIFO depth RXFD : OTG_HS_GRXFSIZ_RXFD_Field := 16#200#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_GRXFSIZ_Register use record RXFD at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype OTG_HS_GNPTXFSIZ_Host_NPTXFSA_Field is HAL.UInt16; subtype OTG_HS_GNPTXFSIZ_Host_NPTXFD_Field is HAL.UInt16; -- OTG_HS nonperiodic transmit FIFO size register (host mode) type OTG_HS_GNPTXFSIZ_Host_Register is record -- Nonperiodic transmit RAM start address NPTXFSA : OTG_HS_GNPTXFSIZ_Host_NPTXFSA_Field := 16#200#; -- Nonperiodic TxFIFO depth NPTXFD : OTG_HS_GNPTXFSIZ_Host_NPTXFD_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_GNPTXFSIZ_Host_Register use record NPTXFSA at 0 range 0 .. 15; NPTXFD at 0 range 16 .. 31; end record; subtype OTG_HS_TX0FSIZ_Peripheral_TX0FSA_Field is HAL.UInt16; subtype OTG_HS_TX0FSIZ_Peripheral_TX0FD_Field is HAL.UInt16; -- Endpoint 0 transmit FIFO size (peripheral mode) type OTG_HS_TX0FSIZ_Peripheral_Register is record -- Endpoint 0 transmit RAM start address TX0FSA : OTG_HS_TX0FSIZ_Peripheral_TX0FSA_Field := 16#200#; -- Endpoint 0 TxFIFO depth TX0FD : OTG_HS_TX0FSIZ_Peripheral_TX0FD_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_TX0FSIZ_Peripheral_Register use record TX0FSA at 0 range 0 .. 15; TX0FD at 0 range 16 .. 31; end record; subtype OTG_HS_GNPTXSTS_NPTXFSAV_Field is HAL.UInt16; subtype OTG_HS_GNPTXSTS_NPTQXSAV_Field is HAL.UInt8; subtype OTG_HS_GNPTXSTS_NPTXQTOP_Field is HAL.UInt7; -- OTG_HS nonperiodic transmit FIFO/queue status register type OTG_HS_GNPTXSTS_Register is record -- Read-only. Nonperiodic TxFIFO space available NPTXFSAV : OTG_HS_GNPTXSTS_NPTXFSAV_Field; -- Read-only. Nonperiodic transmit request queue space available NPTQXSAV : OTG_HS_GNPTXSTS_NPTQXSAV_Field; -- Read-only. Top of the nonperiodic transmit request queue NPTXQTOP : OTG_HS_GNPTXSTS_NPTXQTOP_Field; -- unspecified Reserved_31_31 : HAL.Bit; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_GNPTXSTS_Register use record NPTXFSAV at 0 range 0 .. 15; NPTQXSAV at 0 range 16 .. 23; NPTXQTOP at 0 range 24 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; -- OTG_HS general core configuration register type OTG_HS_GCCFG_Register is record -- unspecified Reserved_0_15 : HAL.UInt16 := 16#0#; -- Power down PWRDWN : Boolean := False; -- Enable I2C bus connection for the external I2C PHY interface I2CPADEN : Boolean := False; -- Enable the VBUS sensing device VBUSASEN : Boolean := False; -- Enable the VBUS sensing device VBUSBSEN : Boolean := False; -- SOF output enable SOFOUTEN : Boolean := False; -- VBUS sensing disable option NOVBUSSENS : Boolean := False; -- unspecified Reserved_22_31 : HAL.UInt10 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_GCCFG_Register use record Reserved_0_15 at 0 range 0 .. 15; PWRDWN at 0 range 16 .. 16; I2CPADEN at 0 range 17 .. 17; VBUSASEN at 0 range 18 .. 18; VBUSBSEN at 0 range 19 .. 19; SOFOUTEN at 0 range 20 .. 20; NOVBUSSENS at 0 range 21 .. 21; Reserved_22_31 at 0 range 22 .. 31; end record; subtype OTG_HS_HPTXFSIZ_PTXSA_Field is HAL.UInt16; subtype OTG_HS_HPTXFSIZ_PTXFD_Field is HAL.UInt16; -- OTG_HS Host periodic transmit FIFO size register type OTG_HS_HPTXFSIZ_Register is record -- Host periodic TxFIFO start address PTXSA : OTG_HS_HPTXFSIZ_PTXSA_Field := 16#600#; -- Host periodic TxFIFO depth PTXFD : OTG_HS_HPTXFSIZ_PTXFD_Field := 16#200#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_HPTXFSIZ_Register use record PTXSA at 0 range 0 .. 15; PTXFD at 0 range 16 .. 31; end record; subtype OTG_HS_DIEPTXF_INEPTXSA_Field is HAL.UInt16; subtype OTG_HS_DIEPTXF_INEPTXFD_Field is HAL.UInt16; -- OTG_HS device IN endpoint transmit FIFO size register type OTG_HS_DIEPTXF_Register is record -- IN endpoint FIFOx transmit RAM start address INEPTXSA : OTG_HS_DIEPTXF_INEPTXSA_Field := 16#400#; -- IN endpoint TxFIFO depth INEPTXFD : OTG_HS_DIEPTXF_INEPTXFD_Field := 16#200#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_DIEPTXF_Register use record INEPTXSA at 0 range 0 .. 15; INEPTXFD at 0 range 16 .. 31; end record; subtype OTG_HS_HCFG_FSLSPCS_Field is HAL.UInt2; -- OTG_HS host configuration register type OTG_HS_HCFG_Register is record -- FS/LS PHY clock select FSLSPCS : OTG_HS_HCFG_FSLSPCS_Field := 16#0#; -- Read-only. FS- and LS-only support FSLSS : Boolean := False; -- unspecified Reserved_3_31 : HAL.UInt29 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_HCFG_Register use record FSLSPCS at 0 range 0 .. 1; FSLSS at 0 range 2 .. 2; Reserved_3_31 at 0 range 3 .. 31; end record; subtype OTG_HS_HFIR_FRIVL_Field is HAL.UInt16; -- OTG_HS Host frame interval register type OTG_HS_HFIR_Register is record -- Frame interval FRIVL : OTG_HS_HFIR_FRIVL_Field := 16#EA60#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_HFIR_Register use record FRIVL at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype OTG_HS_HFNUM_FRNUM_Field is HAL.UInt16; subtype OTG_HS_HFNUM_FTREM_Field is HAL.UInt16; -- OTG_HS host frame number/frame time remaining register type OTG_HS_HFNUM_Register is record -- Read-only. Frame number FRNUM : OTG_HS_HFNUM_FRNUM_Field; -- Read-only. Frame time remaining FTREM : OTG_HS_HFNUM_FTREM_Field; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_HFNUM_Register use record FRNUM at 0 range 0 .. 15; FTREM at 0 range 16 .. 31; end record; subtype OTG_HS_HPTXSTS_PTXFSAVL_Field is HAL.UInt16; subtype OTG_HS_HPTXSTS_PTXQSAV_Field is HAL.UInt8; subtype OTG_HS_HPTXSTS_PTXQTOP_Field is HAL.UInt8; -- OTG_HS_Host periodic transmit FIFO/queue status register type OTG_HS_HPTXSTS_Register is record -- Periodic transmit data FIFO space available PTXFSAVL : OTG_HS_HPTXSTS_PTXFSAVL_Field := 16#100#; -- Read-only. Periodic transmit request queue space available PTXQSAV : OTG_HS_HPTXSTS_PTXQSAV_Field := 16#8#; -- Read-only. Top of the periodic transmit request queue PTXQTOP : OTG_HS_HPTXSTS_PTXQTOP_Field := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_HPTXSTS_Register use record PTXFSAVL at 0 range 0 .. 15; PTXQSAV at 0 range 16 .. 23; PTXQTOP at 0 range 24 .. 31; end record; subtype OTG_HS_HAINT_HAINT_Field is HAL.UInt16; -- OTG_HS Host all channels interrupt register type OTG_HS_HAINT_Register is record -- Read-only. Channel interrupts HAINT : OTG_HS_HAINT_HAINT_Field; -- unspecified Reserved_16_31 : HAL.UInt16; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_HAINT_Register use record HAINT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype OTG_HS_HAINTMSK_HAINTM_Field is HAL.UInt16; -- OTG_HS host all channels interrupt mask register type OTG_HS_HAINTMSK_Register is record -- Channel interrupt mask HAINTM : OTG_HS_HAINTMSK_HAINTM_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_HAINTMSK_Register use record HAINTM at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype OTG_HS_HPRT_PLSTS_Field is HAL.UInt2; subtype OTG_HS_HPRT_PTCTL_Field is HAL.UInt4; subtype OTG_HS_HPRT_PSPD_Field is HAL.UInt2; -- OTG_HS host port control and status register type OTG_HS_HPRT_Register is record -- Read-only. Port connect status PCSTS : Boolean := False; -- Port connect detected PCDET : Boolean := False; -- Port enable PENA : Boolean := False; -- Port enable/disable change PENCHNG : Boolean := False; -- Read-only. Port overcurrent active POCA : Boolean := False; -- Port overcurrent change POCCHNG : Boolean := False; -- Port resume PRES : Boolean := False; -- Port suspend PSUSP : Boolean := False; -- Port reset PRST : Boolean := False; -- unspecified Reserved_9_9 : HAL.Bit := 16#0#; -- Read-only. Port line status PLSTS : OTG_HS_HPRT_PLSTS_Field := 16#0#; -- Port power PPWR : Boolean := False; -- Port test control PTCTL : OTG_HS_HPRT_PTCTL_Field := 16#0#; -- Read-only. Port speed PSPD : OTG_HS_HPRT_PSPD_Field := 16#0#; -- unspecified Reserved_19_31 : HAL.UInt13 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_HPRT_Register use record PCSTS at 0 range 0 .. 0; PCDET at 0 range 1 .. 1; PENA at 0 range 2 .. 2; PENCHNG at 0 range 3 .. 3; POCA at 0 range 4 .. 4; POCCHNG at 0 range 5 .. 5; PRES at 0 range 6 .. 6; PSUSP at 0 range 7 .. 7; PRST at 0 range 8 .. 8; Reserved_9_9 at 0 range 9 .. 9; PLSTS at 0 range 10 .. 11; PPWR at 0 range 12 .. 12; PTCTL at 0 range 13 .. 16; PSPD at 0 range 17 .. 18; Reserved_19_31 at 0 range 19 .. 31; end record; subtype OTG_HS_HCCHAR_MPSIZ_Field is HAL.UInt11; subtype OTG_HS_HCCHAR_EPNUM_Field is HAL.UInt4; subtype OTG_HS_HCCHAR_EPTYP_Field is HAL.UInt2; subtype OTG_HS_HCCHAR_MC_Field is HAL.UInt2; subtype OTG_HS_HCCHAR_DAD_Field is HAL.UInt7; -- OTG_HS host channel-0 characteristics register type OTG_HS_HCCHAR_Register is record -- Maximum packet size MPSIZ : OTG_HS_HCCHAR_MPSIZ_Field := 16#0#; -- Endpoint number EPNUM : OTG_HS_HCCHAR_EPNUM_Field := 16#0#; -- Endpoint direction EPDIR : Boolean := False; -- unspecified Reserved_16_16 : HAL.Bit := 16#0#; -- Low-speed device LSDEV : Boolean := False; -- Endpoint type EPTYP : OTG_HS_HCCHAR_EPTYP_Field := 16#0#; -- Multi Count (MC) / Error Count (EC) MC : OTG_HS_HCCHAR_MC_Field := 16#0#; -- Device address DAD : OTG_HS_HCCHAR_DAD_Field := 16#0#; -- Odd frame ODDFRM : Boolean := False; -- Channel disable CHDIS : Boolean := False; -- Channel enable CHENA : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_HCCHAR_Register use record MPSIZ at 0 range 0 .. 10; EPNUM at 0 range 11 .. 14; EPDIR at 0 range 15 .. 15; Reserved_16_16 at 0 range 16 .. 16; LSDEV at 0 range 17 .. 17; EPTYP at 0 range 18 .. 19; MC at 0 range 20 .. 21; DAD at 0 range 22 .. 28; ODDFRM at 0 range 29 .. 29; CHDIS at 0 range 30 .. 30; CHENA at 0 range 31 .. 31; end record; subtype OTG_HS_HCSPLT_PRTADDR_Field is HAL.UInt7; subtype OTG_HS_HCSPLT_HUBADDR_Field is HAL.UInt7; subtype OTG_HS_HCSPLT_XACTPOS_Field is HAL.UInt2; -- OTG_HS host channel-0 split control register type OTG_HS_HCSPLT_Register is record -- Port address PRTADDR : OTG_HS_HCSPLT_PRTADDR_Field := 16#0#; -- Hub address HUBADDR : OTG_HS_HCSPLT_HUBADDR_Field := 16#0#; -- XACTPOS XACTPOS : OTG_HS_HCSPLT_XACTPOS_Field := 16#0#; -- Do complete split COMPLSPLT : Boolean := False; -- unspecified Reserved_17_30 : HAL.UInt14 := 16#0#; -- Split enable SPLITEN : Boolean := False; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_HCSPLT_Register use record PRTADDR at 0 range 0 .. 6; HUBADDR at 0 range 7 .. 13; XACTPOS at 0 range 14 .. 15; COMPLSPLT at 0 range 16 .. 16; Reserved_17_30 at 0 range 17 .. 30; SPLITEN at 0 range 31 .. 31; end record; -- OTG_HS host channel-11 interrupt register type OTG_HS_HCINT_Register is record -- Transfer completed XFRC : Boolean := False; -- Channel halted CHH : Boolean := False; -- AHB error AHBERR : Boolean := False; -- STALL response received interrupt STALL : Boolean := False; -- NAK response received interrupt NAK : Boolean := False; -- ACK response received/transmitted interrupt ACK : Boolean := False; -- Response received interrupt NYET : Boolean := False; -- Transaction error TXERR : Boolean := False; -- Babble error BBERR : Boolean := False; -- Frame overrun FRMOR : Boolean := False; -- Data toggle error DTERR : Boolean := False; -- unspecified Reserved_11_31 : HAL.UInt21 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_HCINT_Register use record XFRC at 0 range 0 .. 0; CHH at 0 range 1 .. 1; AHBERR at 0 range 2 .. 2; STALL at 0 range 3 .. 3; NAK at 0 range 4 .. 4; ACK at 0 range 5 .. 5; NYET at 0 range 6 .. 6; TXERR at 0 range 7 .. 7; BBERR at 0 range 8 .. 8; FRMOR at 0 range 9 .. 9; DTERR at 0 range 10 .. 10; Reserved_11_31 at 0 range 11 .. 31; end record; -- OTG_HS host channel-11 interrupt mask register type OTG_HS_HCINTMSK_Register is record -- Transfer completed mask XFRCM : Boolean := False; -- Channel halted mask CHHM : Boolean := False; -- AHB error AHBERR : Boolean := False; -- STALL response received interrupt mask STALLM : Boolean := False; -- NAK response received interrupt mask NAKM : Boolean := False; -- ACK response received/transmitted interrupt mask ACKM : Boolean := False; -- response received interrupt mask NYET : Boolean := False; -- Transaction error mask TXERRM : Boolean := False; -- Babble error mask BBERRM : Boolean := False; -- Frame overrun mask FRMORM : Boolean := False; -- Data toggle error mask DTERRM : Boolean := False; -- unspecified Reserved_11_31 : HAL.UInt21 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_HCINTMSK_Register use record XFRCM at 0 range 0 .. 0; CHHM at 0 range 1 .. 1; AHBERR at 0 range 2 .. 2; STALLM at 0 range 3 .. 3; NAKM at 0 range 4 .. 4; ACKM at 0 range 5 .. 5; NYET at 0 range 6 .. 6; TXERRM at 0 range 7 .. 7; BBERRM at 0 range 8 .. 8; FRMORM at 0 range 9 .. 9; DTERRM at 0 range 10 .. 10; Reserved_11_31 at 0 range 11 .. 31; end record; subtype OTG_HS_HCTSIZ_XFRSIZ_Field is HAL.UInt19; subtype OTG_HS_HCTSIZ_PKTCNT_Field is HAL.UInt10; subtype OTG_HS_HCTSIZ_DPID_Field is HAL.UInt2; -- OTG_HS host channel-11 transfer size register type OTG_HS_HCTSIZ_Register is record -- Transfer size XFRSIZ : OTG_HS_HCTSIZ_XFRSIZ_Field := 16#0#; -- Packet count PKTCNT : OTG_HS_HCTSIZ_PKTCNT_Field := 16#0#; -- Data PID DPID : OTG_HS_HCTSIZ_DPID_Field := 16#0#; -- unspecified Reserved_31_31 : HAL.Bit := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_HCTSIZ_Register use record XFRSIZ at 0 range 0 .. 18; PKTCNT at 0 range 19 .. 28; DPID at 0 range 29 .. 30; Reserved_31_31 at 0 range 31 .. 31; end record; -- Power and clock gating control register type OTG_HS_PCGCR_Register is record -- Stop PHY clock STPPCLK : Boolean := False; -- Gate HCLK GATEHCLK : Boolean := False; -- unspecified Reserved_2_3 : HAL.UInt2 := 16#0#; -- PHY suspended PHYSUSP : Boolean := False; -- unspecified Reserved_5_31 : HAL.UInt27 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OTG_HS_PCGCR_Register use record STPPCLK at 0 range 0 .. 0; GATEHCLK at 0 range 1 .. 1; Reserved_2_3 at 0 range 2 .. 3; PHYSUSP at 0 range 4 .. 4; Reserved_5_31 at 0 range 5 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- USB on the go high speed type OTG_HS_DEVICE_Peripheral is record -- OTG_HS device configuration register OTG_HS_DCFG : aliased OTG_HS_DCFG_Register; -- OTG_HS device control register OTG_HS_DCTL : aliased OTG_HS_DCTL_Register; -- OTG_HS device status register OTG_HS_DSTS : aliased OTG_HS_DSTS_Register; -- OTG_HS device IN endpoint common interrupt mask register OTG_HS_DIEPMSK : aliased OTG_HS_DIEPMSK_Register; -- OTG_HS device OUT endpoint common interrupt mask register OTG_HS_DOEPMSK : aliased OTG_HS_DOEPMSK_Register; -- OTG_HS device all endpoints interrupt register OTG_HS_DAINT : aliased OTG_HS_DAINT_Register; -- OTG_HS all endpoints interrupt mask register OTG_HS_DAINTMSK : aliased OTG_HS_DAINTMSK_Register; -- OTG_HS device VBUS discharge time register OTG_HS_DVBUSDIS : aliased OTG_HS_DVBUSDIS_Register; -- OTG_HS device VBUS pulsing time register OTG_HS_DVBUSPULSE : aliased OTG_HS_DVBUSPULSE_Register; -- OTG_HS Device threshold control register OTG_HS_DTHRCTL : aliased OTG_HS_DTHRCTL_Register; -- OTG_HS device IN endpoint FIFO empty interrupt mask register OTG_HS_DIEPEMPMSK : aliased OTG_HS_DIEPEMPMSK_Register; -- OTG_HS device each endpoint interrupt register OTG_HS_DEACHINT : aliased OTG_HS_DEACHINT_Register; -- OTG_HS device each endpoint interrupt register mask OTG_HS_DEACHINTMSK : aliased OTG_HS_DEACHINTMSK_Register; -- OTG_HS device each in endpoint-1 interrupt register OTG_HS_DIEPEACHMSK1 : aliased OTG_HS_DIEPEACHMSK1_Register; -- OTG_HS device each OUT endpoint-1 interrupt register OTG_HS_DOEPEACHMSK1 : aliased OTG_HS_DOEPEACHMSK1_Register; -- OTG device endpoint-0 control register OTG_HS_DIEPCTL0 : aliased OTG_HS_DIEPCTL_Register; -- OTG device endpoint-0 interrupt register OTG_HS_DIEPINT0 : aliased OTG_HS_DIEPINT_Register; -- OTG_HS device IN endpoint 0 transfer size register OTG_HS_DIEPTSIZ0 : aliased OTG_HS_DIEPTSIZ0_Register; -- OTG_HS device endpoint-1 DMA address register OTG_HS_DIEPDMA1 : aliased HAL.UInt32; -- OTG_HS device IN endpoint transmit FIFO status register OTG_HS_DTXFSTS0 : aliased OTG_HS_DTXFSTS_Register; -- OTG device endpoint-1 control register OTG_HS_DIEPCTL1 : aliased OTG_HS_DIEPCTL_Register; -- OTG device endpoint-1 interrupt register OTG_HS_DIEPINT1 : aliased OTG_HS_DIEPINT_Register; -- OTG_HS device endpoint transfer size register OTG_HS_DIEPTSIZ1 : aliased OTG_HS_DIEPTSIZ_Register; -- OTG_HS device endpoint-2 DMA address register OTG_HS_DIEPDMA2 : aliased HAL.UInt32; -- OTG_HS device IN endpoint transmit FIFO status register OTG_HS_DTXFSTS1 : aliased OTG_HS_DTXFSTS_Register; -- OTG device endpoint-2 control register OTG_HS_DIEPCTL2 : aliased OTG_HS_DIEPCTL_Register; -- OTG device endpoint-2 interrupt register OTG_HS_DIEPINT2 : aliased OTG_HS_DIEPINT_Register; -- OTG_HS device endpoint transfer size register OTG_HS_DIEPTSIZ2 : aliased OTG_HS_DIEPTSIZ_Register; -- OTG_HS device endpoint-3 DMA address register OTG_HS_DIEPDMA3 : aliased HAL.UInt32; -- OTG_HS device IN endpoint transmit FIFO status register OTG_HS_DTXFSTS2 : aliased OTG_HS_DTXFSTS_Register; -- OTG device endpoint-3 control register OTG_HS_DIEPCTL3 : aliased OTG_HS_DIEPCTL_Register; -- OTG device endpoint-3 interrupt register OTG_HS_DIEPINT3 : aliased OTG_HS_DIEPINT_Register; -- OTG_HS device endpoint transfer size register OTG_HS_DIEPTSIZ3 : aliased OTG_HS_DIEPTSIZ_Register; -- OTG_HS device endpoint-4 DMA address register OTG_HS_DIEPDMA4 : aliased HAL.UInt32; -- OTG_HS device IN endpoint transmit FIFO status register OTG_HS_DTXFSTS3 : aliased OTG_HS_DTXFSTS_Register; -- OTG device endpoint-4 control register OTG_HS_DIEPCTL4 : aliased OTG_HS_DIEPCTL_Register; -- OTG device endpoint-4 interrupt register OTG_HS_DIEPINT4 : aliased OTG_HS_DIEPINT_Register; -- OTG_HS device endpoint transfer size register OTG_HS_DIEPTSIZ4 : aliased OTG_HS_DIEPTSIZ_Register; -- OTG_HS device endpoint-5 DMA address register OTG_HS_DIEPDMA5 : aliased HAL.UInt32; -- OTG_HS device IN endpoint transmit FIFO status register OTG_HS_DTXFSTS4 : aliased OTG_HS_DTXFSTS_Register; -- OTG device endpoint-5 control register OTG_HS_DIEPCTL5 : aliased OTG_HS_DIEPCTL_Register; -- OTG device endpoint-5 interrupt register OTG_HS_DIEPINT5 : aliased OTG_HS_DIEPINT_Register; -- OTG_HS device endpoint transfer size register OTG_HS_DIEPTSIZ5 : aliased OTG_HS_DIEPTSIZ_Register; -- OTG_HS device IN endpoint transmit FIFO status register OTG_HS_DTXFSTS5 : aliased OTG_HS_DTXFSTS_Register; -- OTG device endpoint-6 control register OTG_HS_DIEPCTL6 : aliased OTG_HS_DIEPCTL_Register; -- OTG device endpoint-6 interrupt register OTG_HS_DIEPINT6 : aliased OTG_HS_DIEPINT_Register; -- OTG device endpoint-7 control register OTG_HS_DIEPCTL7 : aliased OTG_HS_DIEPCTL_Register; -- OTG device endpoint-7 interrupt register OTG_HS_DIEPINT7 : aliased OTG_HS_DIEPINT_Register; -- OTG_HS device control OUT endpoint 0 control register OTG_HS_DOEPCTL0 : aliased OTG_HS_DOEPCTL0_Register; -- OTG_HS device endpoint-0 interrupt register OTG_HS_DOEPINT0 : aliased OTG_HS_DOEPINT_Register; -- OTG_HS device endpoint-1 transfer size register OTG_HS_DOEPTSIZ0 : aliased OTG_HS_DOEPTSIZ0_Register; -- OTG device endpoint-1 control register OTG_HS_DOEPCTL1 : aliased OTG_HS_DOEPCTL_Register; -- OTG_HS device endpoint-1 interrupt register OTG_HS_DOEPINT1 : aliased OTG_HS_DOEPINT_Register; -- OTG_HS device endpoint-2 transfer size register OTG_HS_DOEPTSIZ1 : aliased OTG_HS_DOEPTSIZ_Register; -- OTG device endpoint-2 control register OTG_HS_DOEPCTL2 : aliased OTG_HS_DOEPCTL_Register; -- OTG_HS device endpoint-2 interrupt register OTG_HS_DOEPINT2 : aliased OTG_HS_DOEPINT_Register; -- OTG_HS device endpoint-3 transfer size register OTG_HS_DOEPTSIZ2 : aliased OTG_HS_DOEPTSIZ_Register; -- OTG device endpoint-3 control register OTG_HS_DOEPCTL3 : aliased OTG_HS_DOEPCTL_Register; -- OTG_HS device endpoint-3 interrupt register OTG_HS_DOEPINT3 : aliased OTG_HS_DOEPINT_Register; -- OTG_HS device endpoint-4 transfer size register OTG_HS_DOEPTSIZ3 : aliased OTG_HS_DOEPTSIZ_Register; -- OTG_HS device endpoint-4 interrupt register OTG_HS_DOEPINT4 : aliased OTG_HS_DOEPINT_Register; -- OTG_HS device endpoint-5 transfer size register OTG_HS_DOEPTSIZ4 : aliased OTG_HS_DOEPTSIZ_Register; -- OTG_HS device endpoint-5 interrupt register OTG_HS_DOEPINT5 : aliased OTG_HS_DOEPINT_Register; -- OTG_HS device endpoint-6 interrupt register OTG_HS_DOEPINT6 : aliased OTG_HS_DOEPINT_Register; -- OTG_HS device endpoint-7 interrupt register OTG_HS_DOEPINT7 : aliased OTG_HS_DOEPINT_Register; end record with Volatile; for OTG_HS_DEVICE_Peripheral use record OTG_HS_DCFG at 16#0# range 0 .. 31; OTG_HS_DCTL at 16#4# range 0 .. 31; OTG_HS_DSTS at 16#8# range 0 .. 31; OTG_HS_DIEPMSK at 16#10# range 0 .. 31; OTG_HS_DOEPMSK at 16#14# range 0 .. 31; OTG_HS_DAINT at 16#18# range 0 .. 31; OTG_HS_DAINTMSK at 16#1C# range 0 .. 31; OTG_HS_DVBUSDIS at 16#28# range 0 .. 31; OTG_HS_DVBUSPULSE at 16#2C# range 0 .. 31; OTG_HS_DTHRCTL at 16#30# range 0 .. 31; OTG_HS_DIEPEMPMSK at 16#34# range 0 .. 31; OTG_HS_DEACHINT at 16#38# range 0 .. 31; OTG_HS_DEACHINTMSK at 16#3C# range 0 .. 31; OTG_HS_DIEPEACHMSK1 at 16#40# range 0 .. 31; OTG_HS_DOEPEACHMSK1 at 16#80# range 0 .. 31; OTG_HS_DIEPCTL0 at 16#100# range 0 .. 31; OTG_HS_DIEPINT0 at 16#108# range 0 .. 31; OTG_HS_DIEPTSIZ0 at 16#110# range 0 .. 31; OTG_HS_DIEPDMA1 at 16#114# range 0 .. 31; OTG_HS_DTXFSTS0 at 16#118# range 0 .. 31; OTG_HS_DIEPCTL1 at 16#120# range 0 .. 31; OTG_HS_DIEPINT1 at 16#128# range 0 .. 31; OTG_HS_DIEPTSIZ1 at 16#130# range 0 .. 31; OTG_HS_DIEPDMA2 at 16#134# range 0 .. 31; OTG_HS_DTXFSTS1 at 16#138# range 0 .. 31; OTG_HS_DIEPCTL2 at 16#140# range 0 .. 31; OTG_HS_DIEPINT2 at 16#148# range 0 .. 31; OTG_HS_DIEPTSIZ2 at 16#150# range 0 .. 31; OTG_HS_DIEPDMA3 at 16#154# range 0 .. 31; OTG_HS_DTXFSTS2 at 16#158# range 0 .. 31; OTG_HS_DIEPCTL3 at 16#160# range 0 .. 31; OTG_HS_DIEPINT3 at 16#168# range 0 .. 31; OTG_HS_DIEPTSIZ3 at 16#170# range 0 .. 31; OTG_HS_DIEPDMA4 at 16#174# range 0 .. 31; OTG_HS_DTXFSTS3 at 16#178# range 0 .. 31; OTG_HS_DIEPCTL4 at 16#180# range 0 .. 31; OTG_HS_DIEPINT4 at 16#188# range 0 .. 31; OTG_HS_DIEPTSIZ4 at 16#190# range 0 .. 31; OTG_HS_DIEPDMA5 at 16#194# range 0 .. 31; OTG_HS_DTXFSTS4 at 16#198# range 0 .. 31; OTG_HS_DIEPCTL5 at 16#1A0# range 0 .. 31; OTG_HS_DIEPINT5 at 16#1A8# range 0 .. 31; OTG_HS_DIEPTSIZ5 at 16#1B0# range 0 .. 31; OTG_HS_DTXFSTS5 at 16#1B8# range 0 .. 31; OTG_HS_DIEPCTL6 at 16#1C0# range 0 .. 31; OTG_HS_DIEPINT6 at 16#1C8# range 0 .. 31; OTG_HS_DIEPCTL7 at 16#1E0# range 0 .. 31; OTG_HS_DIEPINT7 at 16#1E8# range 0 .. 31; OTG_HS_DOEPCTL0 at 16#300# range 0 .. 31; OTG_HS_DOEPINT0 at 16#308# range 0 .. 31; OTG_HS_DOEPTSIZ0 at 16#310# range 0 .. 31; OTG_HS_DOEPCTL1 at 16#320# range 0 .. 31; OTG_HS_DOEPINT1 at 16#328# range 0 .. 31; OTG_HS_DOEPTSIZ1 at 16#330# range 0 .. 31; OTG_HS_DOEPCTL2 at 16#340# range 0 .. 31; OTG_HS_DOEPINT2 at 16#348# range 0 .. 31; OTG_HS_DOEPTSIZ2 at 16#350# range 0 .. 31; OTG_HS_DOEPCTL3 at 16#360# range 0 .. 31; OTG_HS_DOEPINT3 at 16#368# range 0 .. 31; OTG_HS_DOEPTSIZ3 at 16#370# range 0 .. 31; OTG_HS_DOEPINT4 at 16#388# range 0 .. 31; OTG_HS_DOEPTSIZ4 at 16#390# range 0 .. 31; OTG_HS_DOEPINT5 at 16#3A8# range 0 .. 31; OTG_HS_DOEPINT6 at 16#3C8# range 0 .. 31; OTG_HS_DOEPINT7 at 16#3E8# range 0 .. 31; end record; -- USB on the go high speed OTG_HS_DEVICE_Periph : aliased OTG_HS_DEVICE_Peripheral with Import, Address => System'To_Address (16#40040800#); type OTG_HS_GLOBAL_Disc is ( Host, Peripheral, Gnptxfsiz_Host, Tx0Fsiz_Peripheral); -- USB on the go high speed type OTG_HS_GLOBAL_Peripheral (Discriminent : OTG_HS_GLOBAL_Disc := Host) is record -- OTG_HS control and status register OTG_HS_GOTGCTL : aliased OTG_HS_GOTGCTL_Register; -- OTG_HS interrupt register OTG_HS_GOTGINT : aliased OTG_HS_GOTGINT_Register; -- OTG_HS AHB configuration register OTG_HS_GAHBCFG : aliased OTG_HS_GAHBCFG_Register; -- OTG_HS USB configuration register OTG_HS_GUSBCFG : aliased OTG_HS_GUSBCFG_Register; -- OTG_HS reset register OTG_HS_GRSTCTL : aliased OTG_HS_GRSTCTL_Register; -- OTG_HS core interrupt register OTG_HS_GINTSTS : aliased OTG_HS_GINTSTS_Register; -- OTG_HS interrupt mask register OTG_HS_GINTMSK : aliased OTG_HS_GINTMSK_Register; -- OTG_HS Receive FIFO size register OTG_HS_GRXFSIZ : aliased OTG_HS_GRXFSIZ_Register; -- OTG_HS nonperiodic transmit FIFO/queue status register OTG_HS_GNPTXSTS : aliased OTG_HS_GNPTXSTS_Register; -- OTG_HS general core configuration register OTG_HS_GCCFG : aliased OTG_HS_GCCFG_Register; -- OTG_HS core ID register OTG_HS_CID : aliased HAL.UInt32; -- OTG_HS Host periodic transmit FIFO size register OTG_HS_HPTXFSIZ : aliased OTG_HS_HPTXFSIZ_Register; -- OTG_HS device IN endpoint transmit FIFO size register OTG_HS_DIEPTXF1 : aliased OTG_HS_DIEPTXF_Register; -- OTG_HS device IN endpoint transmit FIFO size register OTG_HS_DIEPTXF2 : aliased OTG_HS_DIEPTXF_Register; -- OTG_HS device IN endpoint transmit FIFO size register OTG_HS_DIEPTXF3 : aliased OTG_HS_DIEPTXF_Register; -- OTG_HS device IN endpoint transmit FIFO size register OTG_HS_DIEPTXF4 : aliased OTG_HS_DIEPTXF_Register; -- OTG_HS device IN endpoint transmit FIFO size register OTG_HS_DIEPTXF5 : aliased OTG_HS_DIEPTXF_Register; -- OTG_HS device IN endpoint transmit FIFO size register OTG_HS_DIEPTXF6 : aliased OTG_HS_DIEPTXF_Register; -- OTG_HS device IN endpoint transmit FIFO size register OTG_HS_DIEPTXF7 : aliased OTG_HS_DIEPTXF_Register; case Discriminent is when Host => -- OTG_HS Receive status debug read register (host mode) OTG_HS_GRXSTSR_Host : aliased OTG_HS_GRXSTSR_Host_Register; -- OTG_HS status read and pop register (host mode) OTG_HS_GRXSTSP_Host : aliased OTG_HS_GRXSTSP_Host_Register; when Peripheral => -- OTG_HS Receive status debug read register (peripheral mode -- mode) OTG_HS_GRXSTSR_Peripheral : aliased OTG_HS_GRXSTSR_Peripheral_Register; -- OTG_HS status read and pop register (peripheral mode) OTG_HS_GRXSTSP_Peripheral : aliased OTG_HS_GRXSTSP_Peripheral_Register; when Gnptxfsiz_Host => -- OTG_HS nonperiodic transmit FIFO size register (host mode) OTG_HS_GNPTXFSIZ_Host : aliased OTG_HS_GNPTXFSIZ_Host_Register; when Tx0Fsiz_Peripheral => -- Endpoint 0 transmit FIFO size (peripheral mode) OTG_HS_TX0FSIZ_Peripheral : aliased OTG_HS_TX0FSIZ_Peripheral_Register; end case; end record with Unchecked_Union, Volatile; for OTG_HS_GLOBAL_Peripheral use record OTG_HS_GOTGCTL at 16#0# range 0 .. 31; OTG_HS_GOTGINT at 16#4# range 0 .. 31; OTG_HS_GAHBCFG at 16#8# range 0 .. 31; OTG_HS_GUSBCFG at 16#C# range 0 .. 31; OTG_HS_GRSTCTL at 16#10# range 0 .. 31; OTG_HS_GINTSTS at 16#14# range 0 .. 31; OTG_HS_GINTMSK at 16#18# range 0 .. 31; OTG_HS_GRXFSIZ at 16#24# range 0 .. 31; OTG_HS_GNPTXSTS at 16#2C# range 0 .. 31; OTG_HS_GCCFG at 16#38# range 0 .. 31; OTG_HS_CID at 16#3C# range 0 .. 31; OTG_HS_HPTXFSIZ at 16#100# range 0 .. 31; OTG_HS_DIEPTXF1 at 16#104# range 0 .. 31; OTG_HS_DIEPTXF2 at 16#108# range 0 .. 31; OTG_HS_DIEPTXF3 at 16#11C# range 0 .. 31; OTG_HS_DIEPTXF4 at 16#120# range 0 .. 31; OTG_HS_DIEPTXF5 at 16#124# range 0 .. 31; OTG_HS_DIEPTXF6 at 16#128# range 0 .. 31; OTG_HS_DIEPTXF7 at 16#12C# range 0 .. 31; OTG_HS_GRXSTSR_Host at 16#1C# range 0 .. 31; OTG_HS_GRXSTSP_Host at 16#20# range 0 .. 31; OTG_HS_GRXSTSR_Peripheral at 16#1C# range 0 .. 31; OTG_HS_GRXSTSP_Peripheral at 16#20# range 0 .. 31; OTG_HS_GNPTXFSIZ_Host at 16#28# range 0 .. 31; OTG_HS_TX0FSIZ_Peripheral at 16#28# range 0 .. 31; end record; -- USB on the go high speed OTG_HS_GLOBAL_Periph : aliased OTG_HS_GLOBAL_Peripheral with Import, Address => System'To_Address (16#40040000#); -- USB on the go high speed type OTG_HS_HOST_Peripheral is record -- OTG_HS host configuration register OTG_HS_HCFG : aliased OTG_HS_HCFG_Register; -- OTG_HS Host frame interval register OTG_HS_HFIR : aliased OTG_HS_HFIR_Register; -- OTG_HS host frame number/frame time remaining register OTG_HS_HFNUM : aliased OTG_HS_HFNUM_Register; -- OTG_HS_Host periodic transmit FIFO/queue status register OTG_HS_HPTXSTS : aliased OTG_HS_HPTXSTS_Register; -- OTG_HS Host all channels interrupt register OTG_HS_HAINT : aliased OTG_HS_HAINT_Register; -- OTG_HS host all channels interrupt mask register OTG_HS_HAINTMSK : aliased OTG_HS_HAINTMSK_Register; -- OTG_HS host port control and status register OTG_HS_HPRT : aliased OTG_HS_HPRT_Register; -- OTG_HS host channel-0 characteristics register OTG_HS_HCCHAR0 : aliased OTG_HS_HCCHAR_Register; -- OTG_HS host channel-0 split control register OTG_HS_HCSPLT0 : aliased OTG_HS_HCSPLT_Register; -- OTG_HS host channel-11 interrupt register OTG_HS_HCINT0 : aliased OTG_HS_HCINT_Register; -- OTG_HS host channel-11 interrupt mask register OTG_HS_HCINTMSK0 : aliased OTG_HS_HCINTMSK_Register; -- OTG_HS host channel-11 transfer size register OTG_HS_HCTSIZ0 : aliased OTG_HS_HCTSIZ_Register; -- OTG_HS host channel-0 DMA address register OTG_HS_HCDMA0 : aliased HAL.UInt32; -- OTG_HS host channel-1 characteristics register OTG_HS_HCCHAR1 : aliased OTG_HS_HCCHAR_Register; -- OTG_HS host channel-1 split control register OTG_HS_HCSPLT1 : aliased OTG_HS_HCSPLT_Register; -- OTG_HS host channel-1 interrupt register OTG_HS_HCINT1 : aliased OTG_HS_HCINT_Register; -- OTG_HS host channel-1 interrupt mask register OTG_HS_HCINTMSK1 : aliased OTG_HS_HCINTMSK_Register; -- OTG_HS host channel-1 transfer size register OTG_HS_HCTSIZ1 : aliased OTG_HS_HCTSIZ_Register; -- OTG_HS host channel-1 DMA address register OTG_HS_HCDMA1 : aliased HAL.UInt32; -- OTG_HS host channel-2 characteristics register OTG_HS_HCCHAR2 : aliased OTG_HS_HCCHAR_Register; -- OTG_HS host channel-2 split control register OTG_HS_HCSPLT2 : aliased OTG_HS_HCSPLT_Register; -- OTG_HS host channel-2 interrupt register OTG_HS_HCINT2 : aliased OTG_HS_HCINT_Register; -- OTG_HS host channel-2 interrupt mask register OTG_HS_HCINTMSK2 : aliased OTG_HS_HCINTMSK_Register; -- OTG_HS host channel-2 transfer size register OTG_HS_HCTSIZ2 : aliased OTG_HS_HCTSIZ_Register; -- OTG_HS host channel-2 DMA address register OTG_HS_HCDMA2 : aliased HAL.UInt32; -- OTG_HS host channel-3 characteristics register OTG_HS_HCCHAR3 : aliased OTG_HS_HCCHAR_Register; -- OTG_HS host channel-3 split control register OTG_HS_HCSPLT3 : aliased OTG_HS_HCSPLT_Register; -- OTG_HS host channel-3 interrupt register OTG_HS_HCINT3 : aliased OTG_HS_HCINT_Register; -- OTG_HS host channel-3 interrupt mask register OTG_HS_HCINTMSK3 : aliased OTG_HS_HCINTMSK_Register; -- OTG_HS host channel-3 transfer size register OTG_HS_HCTSIZ3 : aliased OTG_HS_HCTSIZ_Register; -- OTG_HS host channel-3 DMA address register OTG_HS_HCDMA3 : aliased HAL.UInt32; -- OTG_HS host channel-4 characteristics register OTG_HS_HCCHAR4 : aliased OTG_HS_HCCHAR_Register; -- OTG_HS host channel-4 split control register OTG_HS_HCSPLT4 : aliased OTG_HS_HCSPLT_Register; -- OTG_HS host channel-4 interrupt register OTG_HS_HCINT4 : aliased OTG_HS_HCINT_Register; -- OTG_HS host channel-4 interrupt mask register OTG_HS_HCINTMSK4 : aliased OTG_HS_HCINTMSK_Register; -- OTG_HS host channel-4 transfer size register OTG_HS_HCTSIZ4 : aliased OTG_HS_HCTSIZ_Register; -- OTG_HS host channel-4 DMA address register OTG_HS_HCDMA4 : aliased HAL.UInt32; -- OTG_HS host channel-5 characteristics register OTG_HS_HCCHAR5 : aliased OTG_HS_HCCHAR_Register; -- OTG_HS host channel-5 split control register OTG_HS_HCSPLT5 : aliased OTG_HS_HCSPLT_Register; -- OTG_HS host channel-5 interrupt register OTG_HS_HCINT5 : aliased OTG_HS_HCINT_Register; -- OTG_HS host channel-5 interrupt mask register OTG_HS_HCINTMSK5 : aliased OTG_HS_HCINTMSK_Register; -- OTG_HS host channel-5 transfer size register OTG_HS_HCTSIZ5 : aliased OTG_HS_HCTSIZ_Register; -- OTG_HS host channel-5 DMA address register OTG_HS_HCDMA5 : aliased HAL.UInt32; -- OTG_HS host channel-6 characteristics register OTG_HS_HCCHAR6 : aliased OTG_HS_HCCHAR_Register; -- OTG_HS host channel-6 split control register OTG_HS_HCSPLT6 : aliased OTG_HS_HCSPLT_Register; -- OTG_HS host channel-6 interrupt register OTG_HS_HCINT6 : aliased OTG_HS_HCINT_Register; -- OTG_HS host channel-6 interrupt mask register OTG_HS_HCINTMSK6 : aliased OTG_HS_HCINTMSK_Register; -- OTG_HS host channel-6 transfer size register OTG_HS_HCTSIZ6 : aliased OTG_HS_HCTSIZ_Register; -- OTG_HS host channel-6 DMA address register OTG_HS_HCDMA6 : aliased HAL.UInt32; -- OTG_HS host channel-7 characteristics register OTG_HS_HCCHAR7 : aliased OTG_HS_HCCHAR_Register; -- OTG_HS host channel-7 split control register OTG_HS_HCSPLT7 : aliased OTG_HS_HCSPLT_Register; -- OTG_HS host channel-7 interrupt register OTG_HS_HCINT7 : aliased OTG_HS_HCINT_Register; -- OTG_HS host channel-7 interrupt mask register OTG_HS_HCINTMSK7 : aliased OTG_HS_HCINTMSK_Register; -- OTG_HS host channel-7 transfer size register OTG_HS_HCTSIZ7 : aliased OTG_HS_HCTSIZ_Register; -- OTG_HS host channel-7 DMA address register OTG_HS_HCDMA7 : aliased HAL.UInt32; -- OTG_HS host channel-8 characteristics register OTG_HS_HCCHAR8 : aliased OTG_HS_HCCHAR_Register; -- OTG_HS host channel-8 split control register OTG_HS_HCSPLT8 : aliased OTG_HS_HCSPLT_Register; -- OTG_HS host channel-8 interrupt register OTG_HS_HCINT8 : aliased OTG_HS_HCINT_Register; -- OTG_HS host channel-8 interrupt mask register OTG_HS_HCINTMSK8 : aliased OTG_HS_HCINTMSK_Register; -- OTG_HS host channel-8 transfer size register OTG_HS_HCTSIZ8 : aliased OTG_HS_HCTSIZ_Register; -- OTG_HS host channel-8 DMA address register OTG_HS_HCDMA8 : aliased HAL.UInt32; -- OTG_HS host channel-9 characteristics register OTG_HS_HCCHAR9 : aliased OTG_HS_HCCHAR_Register; -- OTG_HS host channel-9 split control register OTG_HS_HCSPLT9 : aliased OTG_HS_HCSPLT_Register; -- OTG_HS host channel-9 interrupt register OTG_HS_HCINT9 : aliased OTG_HS_HCINT_Register; -- OTG_HS host channel-9 interrupt mask register OTG_HS_HCINTMSK9 : aliased OTG_HS_HCINTMSK_Register; -- OTG_HS host channel-9 transfer size register OTG_HS_HCTSIZ9 : aliased OTG_HS_HCTSIZ_Register; -- OTG_HS host channel-9 DMA address register OTG_HS_HCDMA9 : aliased HAL.UInt32; -- OTG_HS host channel-10 characteristics register OTG_HS_HCCHAR10 : aliased OTG_HS_HCCHAR_Register; -- OTG_HS host channel-10 split control register OTG_HS_HCSPLT10 : aliased OTG_HS_HCSPLT_Register; -- OTG_HS host channel-10 interrupt register OTG_HS_HCINT10 : aliased OTG_HS_HCINT_Register; -- OTG_HS host channel-10 interrupt mask register OTG_HS_HCINTMSK10 : aliased OTG_HS_HCINTMSK_Register; -- OTG_HS host channel-10 transfer size register OTG_HS_HCTSIZ10 : aliased OTG_HS_HCTSIZ_Register; -- OTG_HS host channel-10 DMA address register OTG_HS_HCDMA10 : aliased HAL.UInt32; -- OTG_HS host channel-11 characteristics register OTG_HS_HCCHAR11 : aliased OTG_HS_HCCHAR_Register; -- OTG_HS host channel-11 split control register OTG_HS_HCSPLT11 : aliased OTG_HS_HCSPLT_Register; -- OTG_HS host channel-11 interrupt register OTG_HS_HCINT11 : aliased OTG_HS_HCINT_Register; -- OTG_HS host channel-11 interrupt mask register OTG_HS_HCINTMSK11 : aliased OTG_HS_HCINTMSK_Register; -- OTG_HS host channel-11 transfer size register OTG_HS_HCTSIZ11 : aliased OTG_HS_HCTSIZ_Register; -- OTG_HS host channel-11 DMA address register OTG_HS_HCDMA11 : aliased HAL.UInt32; end record with Volatile; for OTG_HS_HOST_Peripheral use record OTG_HS_HCFG at 16#0# range 0 .. 31; OTG_HS_HFIR at 16#4# range 0 .. 31; OTG_HS_HFNUM at 16#8# range 0 .. 31; OTG_HS_HPTXSTS at 16#10# range 0 .. 31; OTG_HS_HAINT at 16#14# range 0 .. 31; OTG_HS_HAINTMSK at 16#18# range 0 .. 31; OTG_HS_HPRT at 16#40# range 0 .. 31; OTG_HS_HCCHAR0 at 16#100# range 0 .. 31; OTG_HS_HCSPLT0 at 16#104# range 0 .. 31; OTG_HS_HCINT0 at 16#108# range 0 .. 31; OTG_HS_HCINTMSK0 at 16#10C# range 0 .. 31; OTG_HS_HCTSIZ0 at 16#110# range 0 .. 31; OTG_HS_HCDMA0 at 16#114# range 0 .. 31; OTG_HS_HCCHAR1 at 16#120# range 0 .. 31; OTG_HS_HCSPLT1 at 16#124# range 0 .. 31; OTG_HS_HCINT1 at 16#128# range 0 .. 31; OTG_HS_HCINTMSK1 at 16#12C# range 0 .. 31; OTG_HS_HCTSIZ1 at 16#130# range 0 .. 31; OTG_HS_HCDMA1 at 16#134# range 0 .. 31; OTG_HS_HCCHAR2 at 16#140# range 0 .. 31; OTG_HS_HCSPLT2 at 16#144# range 0 .. 31; OTG_HS_HCINT2 at 16#148# range 0 .. 31; OTG_HS_HCINTMSK2 at 16#14C# range 0 .. 31; OTG_HS_HCTSIZ2 at 16#150# range 0 .. 31; OTG_HS_HCDMA2 at 16#154# range 0 .. 31; OTG_HS_HCCHAR3 at 16#160# range 0 .. 31; OTG_HS_HCSPLT3 at 16#164# range 0 .. 31; OTG_HS_HCINT3 at 16#168# range 0 .. 31; OTG_HS_HCINTMSK3 at 16#16C# range 0 .. 31; OTG_HS_HCTSIZ3 at 16#170# range 0 .. 31; OTG_HS_HCDMA3 at 16#174# range 0 .. 31; OTG_HS_HCCHAR4 at 16#180# range 0 .. 31; OTG_HS_HCSPLT4 at 16#184# range 0 .. 31; OTG_HS_HCINT4 at 16#188# range 0 .. 31; OTG_HS_HCINTMSK4 at 16#18C# range 0 .. 31; OTG_HS_HCTSIZ4 at 16#190# range 0 .. 31; OTG_HS_HCDMA4 at 16#194# range 0 .. 31; OTG_HS_HCCHAR5 at 16#1A0# range 0 .. 31; OTG_HS_HCSPLT5 at 16#1A4# range 0 .. 31; OTG_HS_HCINT5 at 16#1A8# range 0 .. 31; OTG_HS_HCINTMSK5 at 16#1AC# range 0 .. 31; OTG_HS_HCTSIZ5 at 16#1B0# range 0 .. 31; OTG_HS_HCDMA5 at 16#1B4# range 0 .. 31; OTG_HS_HCCHAR6 at 16#1C0# range 0 .. 31; OTG_HS_HCSPLT6 at 16#1C4# range 0 .. 31; OTG_HS_HCINT6 at 16#1C8# range 0 .. 31; OTG_HS_HCINTMSK6 at 16#1CC# range 0 .. 31; OTG_HS_HCTSIZ6 at 16#1D0# range 0 .. 31; OTG_HS_HCDMA6 at 16#1D4# range 0 .. 31; OTG_HS_HCCHAR7 at 16#1E0# range 0 .. 31; OTG_HS_HCSPLT7 at 16#1E4# range 0 .. 31; OTG_HS_HCINT7 at 16#1E8# range 0 .. 31; OTG_HS_HCINTMSK7 at 16#1EC# range 0 .. 31; OTG_HS_HCTSIZ7 at 16#1F0# range 0 .. 31; OTG_HS_HCDMA7 at 16#1F4# range 0 .. 31; OTG_HS_HCCHAR8 at 16#200# range 0 .. 31; OTG_HS_HCSPLT8 at 16#204# range 0 .. 31; OTG_HS_HCINT8 at 16#208# range 0 .. 31; OTG_HS_HCINTMSK8 at 16#20C# range 0 .. 31; OTG_HS_HCTSIZ8 at 16#210# range 0 .. 31; OTG_HS_HCDMA8 at 16#214# range 0 .. 31; OTG_HS_HCCHAR9 at 16#220# range 0 .. 31; OTG_HS_HCSPLT9 at 16#224# range 0 .. 31; OTG_HS_HCINT9 at 16#228# range 0 .. 31; OTG_HS_HCINTMSK9 at 16#22C# range 0 .. 31; OTG_HS_HCTSIZ9 at 16#230# range 0 .. 31; OTG_HS_HCDMA9 at 16#234# range 0 .. 31; OTG_HS_HCCHAR10 at 16#240# range 0 .. 31; OTG_HS_HCSPLT10 at 16#244# range 0 .. 31; OTG_HS_HCINT10 at 16#248# range 0 .. 31; OTG_HS_HCINTMSK10 at 16#24C# range 0 .. 31; OTG_HS_HCTSIZ10 at 16#250# range 0 .. 31; OTG_HS_HCDMA10 at 16#254# range 0 .. 31; OTG_HS_HCCHAR11 at 16#260# range 0 .. 31; OTG_HS_HCSPLT11 at 16#264# range 0 .. 31; OTG_HS_HCINT11 at 16#268# range 0 .. 31; OTG_HS_HCINTMSK11 at 16#26C# range 0 .. 31; OTG_HS_HCTSIZ11 at 16#270# range 0 .. 31; OTG_HS_HCDMA11 at 16#274# range 0 .. 31; end record; -- USB on the go high speed OTG_HS_HOST_Periph : aliased OTG_HS_HOST_Peripheral with Import, Address => System'To_Address (16#40040400#); -- USB on the go high speed type OTG_HS_PWRCLK_Peripheral is record -- Power and clock gating control register OTG_HS_PCGCR : aliased OTG_HS_PCGCR_Register; end record with Volatile; for OTG_HS_PWRCLK_Peripheral use record OTG_HS_PCGCR at 0 range 0 .. 31; end record; -- USB on the go high speed OTG_HS_PWRCLK_Periph : aliased OTG_HS_PWRCLK_Peripheral with Import, Address => System'To_Address (16#40040E00#); end STM32_SVD.USB_OTG_HS;
reznikmm/matreshka
Ada
3,995
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_Volatile_Attributes; package Matreshka.ODF_Style.Volatile_Attributes is type Style_Volatile_Attribute_Node is new Matreshka.ODF_Style.Abstract_Style_Attribute_Node and ODF.DOM.Style_Volatile_Attributes.ODF_Style_Volatile_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Volatile_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Style_Volatile_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Style.Volatile_Attributes;
leo-brewin/adm-bssn-numerical
Ada
2,202
ads
package Support.RegEx is -- re_intg : String := "([-+]?[0-9]+)"; -- re_real : String := "([-+]?[0-9]*[.]?[0-9]+([eE][-+]?[0-9]+)?)"; -- note counts as 2 groups (1.234(e+56)) -- re_text : String := "([a-zA-Z0-9 .-]+)"; -- re_space : String := "( |\t)+"; -- re_email : String := "([a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,})"; -- note: if the_line = "foo bah moo cow" and the_regex = "moo" then -- result = grep (the_line,the_regex,1) will return result = "moo" -- *but* the range of result will be based on where the target was found -- thus result'first = 9 and result'last = 11 -- find a sub-string within a string function grep (the_line : String; the_regex : String; the_group : Integer; the_match : Integer := 1; fail : String := "<no match>") return String; -- find an integer within a string function grep (the_line : String; the_regex : String; the_group : Integer; the_match : Integer := 1; fail : Integer := -333) return Integer; -- find a real number within a string function grep (the_line : String; the_regex : String; the_group : Integer; the_match : Integer := 1; fail : Real := -333.3e33) return Real; function grep (the_line : String; the_regex : String; the_group : Integer := 1; the_match : Integer := 1) return Boolean; function regex_match (the_line : String; the_regex : String) return Boolean; procedure grep (the_match : out String; found : out Boolean; the_line : String; the_regex : String; the_group : Integer); procedure grep (the_beg : out Integer; the_end : out Integer; found : out Boolean; the_line : String; the_regex : String; the_group : Integer := 0); end Support.RegEx;
zhmu/ananas
Ada
126
ads
generic Elaborate : Boolean := True; with procedure Proc; package Elab3_Pkg is procedure Elaborator; end Elab3_Pkg;
AdaCore/training_material
Ada
15,151
ads
pragma Ada_2005; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; package intrin_impl_h is --* -- * This file has no copyright assigned and is placed in the Public Domain. -- * This file is part of the mingw-w64 runtime package. -- * No warranty is given; refer to the file DISCLAIMER.PD within this package. -- -- There are 3 separate ways this file is intended to be used: -- 1) Included from intrin.h. In this case, all intrinsics in this file get declarations and -- implementations. No special #defines are needed for this case. -- 2) Included from the library versions of these functions (ie mingw-w64-crt\intrincs\*.c). All -- intrinsics in this file must also be included in the library. In this case, only the -- specific functions requested will get defined, and they will not be defined as inline. If -- you have followed the instructions (below) for adding functions to this file, then all you -- need to have in the .c file is the following: -- #define __INTRINSIC_ONLYSPECIAL -- #define __INTRINSIC_SPECIAL___stosb // Causes code generation in intrin-impl.h -- #include <intrin.h> -- 3) Included from various platform sdk headers. Some platform sdk headers (such as winnt.h) -- define a subset of intrinsics. To avoid potential conflicts, this file is designed to -- allow for specific subsets of functions to be defined. This is done by defining the -- appropriate variable before including this file: -- #define __INTRINSIC_GROUP_WINNT -- #include <psdk_inc/intrin-impl.h> -- In all cases, it is acceptable to include this file multiple times in any order (ie include -- winnt.h to get its subset, then include intrin.h to get everything, or vice versa). -- See also the comments at the top of intrin.h. -- -- To add an implementation for a new intrinsic to this file, you should comment out the current prototype in intrin.h. -- If the function you are adding is not in intrin.h, you should not be adding it to this file. This file is only -- for MSVC intrinsics. -- Make sure you put your definition in the right section (x86 vs x64), and use this outline when adding definitions -- to this file: --#if __INTRINSIC_PROLOG(__int2c) --<prototype goes here> --__INTRINSICS_USEINLINE --<code goes here> --#define __INTRINSIC_DEFINED___int2c --#endif -- -- Note that there is no file-wide #if to prevent intrin-impl.h from being -- included multiple times. This is because this file might be included multiple -- times to define various subsets of the functions it contains. -- However we do check for __MINGW_INTRIN_INLINE. In theory this means we -- can work with other compilers. -- These macros are used by the routines below. While this file may be included -- multiple times, these macros only need to be defined once. -- This macro is used by __stosb, __stosw, __stosd, __stosq -- Parameters: (FunctionName, DataType, Operator) -- FunctionName: Any valid function name -- DataType: BYTE, WORD, DWORD or DWORD64 -- InstructionSizeIntel: b, w, d, q (not b,w,l,q) -- While we don't need the output values for Dest or Count, we -- must still inform the compiler the asm changes them. -- This macro is used by InterlockedAnd, InterlockedOr, InterlockedXor, InterlockedAnd64, InterlockedOr64, InterlockedXor64 -- Parameters: (FunctionName, DataType, Operator) -- FunctionName: Any valid function name -- DataType: __LONG32 or __int64 -- Operator: One of xor, or, and -- This macro is used by InterlockedBitTestAndSet, InterlockedBitTestAndReset, InterlockedBitTestAndComplement, -- InterlockedBitTestAndSet64, InterlockedBitTestAndReset64, InterlockedBitTestAndComplement64 -- _interlockedbittestandset, _interlockedbittestandreset, _interlockedbittestandcomplement -- _interlockedbittestandset64, _interlockedbittestandreset64, _interlockedbittestandcomplement64 -- Parameters: (FunctionName, DataType, AsmCode, OffsetConstraint, Volatile) -- FunctionName: Any valid function name -- DataType: __LONG32 or __int64 -- OffsetConstraint: either "I" for 32bit data types or "J" for 64. -- Volatile: either volatile or blank. -- This macro is used by YieldProcessor when compiling x86 w/o SSE2. --It generates the same opcodes as _mm_pause. -- This macro is used by DbgRaiseAssertionFailure and __int2c --Parameters: (IntNum) --IntNum: Interrupt number in hex -- This macro is used by MemoryBarrier when compiling x86 w/o SSE2. --Note that on i386, xchg performs an implicit lock. -- This macro is used by __readfsbyte, __readfsword, __readfsdword -- __readgsbyte, __readgsword, __readgsdword, __readgsqword --Parameters: (FunctionName, DataType, Segment) -- FunctionName: Any valid function name -- DataType: char, short, __LONG32 or __int64 -- Segment: fs or gs -- This macro is used by __writefsbyte, __writefsword, __writefsdword -- __writegsbyte, __writegsword, __writegsdword, __writegsqword --Parameters: (FunctionName, DataType, Segment) -- FunctionName: Any valid function name -- DataType: char, short, __LONG32 or __int64 -- Segment: fs or gs -- This macro is used by _BitScanForward, _BitScanForward64, _BitScanReverse _BitScanReverse64 --Parameters: (FunctionName, DataType, Segment) -- FunctionName: Any valid function name -- DataType: unsigned __LONG32 or unsigned __int64 -- Statement: BSF or BSR -- This macro is used by _bittest & _bittest64 --Parameters: (FunctionName, DataType, OffsetConstraint) -- FunctionName: Any valid function name -- DataType: __LONG32 or __int64 -- OffsetConstraint: either "I" for 32bit data types or "J" for 64. -- -- This macro is used by _bittestandset, _bittestandreset, _bittestandcomplement, -- _bittestandset64, _bittestandreset64, _bittestandcomplement64 --Parameters: (FunctionName, DataType, Statement, OffsetConstraint) -- FunctionName: Any valid function name -- DataType: __LONG32 or __int64 -- Statement: asm statement (bts, btr, btc) -- OffsetConstraint: either "I" for 32bit data types or "J" for 64. -- -- This macro is used by __inbyte, __inword, __indword --Parameters: (FunctionName, DataType) -- FunctionName: Any valid function name -- DataType: unsigned char, unsigned short, unsigned __LONG32 -- -- This macro is used by __outbyte, __outword, __outdword --Parameters: (FunctionName, DataType) -- FunctionName: Any valid function name -- DataType: unsigned char, unsigned short, unsigned __LONG32 -- -- This macro is used by __inbytestring, __inwordstring, __indwordstring --Parameters: (FunctionName, DataType, InstructionSizeAtt, InstructionSizeIntel) -- FunctionName: Any valid function name -- DataType: unsigned char, unsigned short, unsigned __LONG32 -- InstructionSizeAtt: b, w, l -- InstructionSizeIntel: b, w, d (not b,w,l) -- -- This macro is used by __outbytestring, __outwordstring, __outdwordstring --Parameters: (FunctionName, DataType, InstructionSizeAtt, InstructionSizeIntel) -- FunctionName: Any valid function name -- DataType: unsigned char, unsigned short, unsigned __LONG32 -- InstructionSizeAtt: b, w, l -- InstructionSizeIntel: b, w, d (not b,w,l) -- -- This macro is used by __readcr0, __readcr2, __readcr3, __readcr4, __readcr8 --Parameters: (FunctionName, DataType, RegisterNumber) -- FunctionName: Any valid function name -- DataType: unsigned __LONG32, unsigned __int64 -- RegisterNumber: 0, 2, 3, 4, 8 -- -- This macro is used by __writecr0, __writecr2, __writecr3, __writecr4, __writecr8 --Parameters: (FunctionName, DataType, RegisterNumber) -- FunctionName: Any valid function name -- DataType: unsigned __LONG32, unsigned __int64 -- RegisterNumber: 0, 2, 3, 4, 8 -- -- This macro is used by __movsb, __movsd, __movsq, __movsw --Parameters: (FunctionName, DataType, RegisterNumber) -- FunctionName: Any valid function name -- DataType: unsigned char, unsigned short, unsigned __LONG32, unsigned __int64 -- InstructionSize: b, w, d, q -- -- The Barrier functions can never be in the library. Since gcc only --supports ReadWriteBarrier, map all 3 to do the same. -- The logic for this macro is: -- if the function is not yet defined AND -- ( -- (if we are not just defining special OR -- (we are defining special AND this is one of the ones we are defining) -- ) -- ) -- -- Normally __INTRINSIC_ONLYSPECIAL is used to indicate that we are -- being included in the library version of the intrinsic (case 2). However, -- that really only affects the definition of __INTRINSICS_USEINLINE. -- So here we are letting it serve an additional purpose of only defining -- the intrinsics for a certain file (case 3). For example, to create the -- intrinsics for the functions in winnt.h, define __INTRINSIC_GROUP_WINNT. -- Note that this file can be included multiple times, and as a result -- there can be overlap (definitions that appear in more than one -- file). This is handled by __INTRINSIC_DEFINED_* -- If no groups are defined (such as what happens when including intrin.h), -- all intrinsics are defined. -- If __INTRINSIC_ONLYSPECIAL is defined at this point, we are processing case 2. In -- that case, don't go looking for groups -- Note that this gets undefined at the end of this file -- Note that this gets undefined at the end of this file -- To add an additional group, put the #ifdef and definitions here. -- skipped func __faststorefence -- Turns out this is actually faster than MS's "trick" on newer cpus. Note -- that this builtin performs an implicit ReadWriteBarrier. -- skipped func __stosq -- unused param -- skipped func _interlockedbittestandset64 -- unused param -- skipped func _interlockedbittestandreset64 -- unused param -- skipped func _interlockedbittestandcomplement64 function InterlockedBitTestAndSet64 (Base : access Long_Long_Integer; Offset : Long_Long_Integer) return unsigned_char; -- d:\install\gpl2018\x86_64-pc-mingw32\include\psdk_inc\intrin-impl.h:526 pragma Import (C, InterlockedBitTestAndSet64, "InterlockedBitTestAndSet64"); function InterlockedBitTestAndReset64 (Base : access Long_Long_Integer; Offset : Long_Long_Integer) return unsigned_char; -- d:\install\gpl2018\x86_64-pc-mingw32\include\psdk_inc\intrin-impl.h:533 pragma Import (C, InterlockedBitTestAndReset64, "InterlockedBitTestAndReset64"); function InterlockedBitTestAndComplement64 (Base : access Long_Long_Integer; Offset : Long_Long_Integer) return unsigned_char; -- d:\install\gpl2018\x86_64-pc-mingw32\include\psdk_inc\intrin-impl.h:540 pragma Import (C, InterlockedBitTestAndComplement64, "InterlockedBitTestAndComplement64"); -- skipped func _InterlockedAnd64 -- skipped func _InterlockedOr64 -- skipped func _InterlockedXor64 -- skipped func _InterlockedIncrement64 -- skipped func _InterlockedDecrement64 -- skipped func _InterlockedExchange64 -- skipped func _InterlockedExchangeAdd64 -- skipped func __readgsbyte -- skipped func __readgsword -- skipped func __readgsdword -- skipped func __readgsqword -- skipped func __writegsbyte -- skipped func __writegsword -- skipped func __writegsdword -- skipped func __writegsqword -- skipped func _BitScanForward64 -- skipped func _BitScanReverse64 -- skipped func _bittest64 -- skipped func _bittestandset64 -- skipped func _bittestandreset64 -- skipped func _bittestandcomplement64 -- skipped func __readcr0 -- skipped func __readcr2 -- skipped func __readcr3 -- skipped func __readcr4 -- skipped func __readcr8 -- skipped func __writecr0 -- skipped func __writecr3 -- skipped func __writecr4 -- skipped func __writecr8 -- skipped func __movsq -- skipped func _umul128 -- skipped func _mul128 -- skipped func __shiftleft128 -- skipped func __shiftright128 -- ***************************************************** -- skipped func __int2c -- skipped func __stosb -- skipped func __stosw -- skipped func __stosd -- unused param -- skipped func _interlockedbittestandset -- unused param -- skipped func _interlockedbittestandreset -- unused param -- skipped func _interlockedbittestandcomplement function InterlockedBitTestAndSet (Base : access long; Offset : long) return unsigned_char; -- d:\install\gpl2018\x86_64-pc-mingw32\include\psdk_inc\intrin-impl.h:891 pragma Import (C, InterlockedBitTestAndSet, "InterlockedBitTestAndSet"); function InterlockedBitTestAndReset (Base : access long; Offset : long) return unsigned_char; -- d:\install\gpl2018\x86_64-pc-mingw32\include\psdk_inc\intrin-impl.h:898 pragma Import (C, InterlockedBitTestAndReset, "InterlockedBitTestAndReset"); function InterlockedBitTestAndComplement (Base : access long; Offset : long) return unsigned_char; -- d:\install\gpl2018\x86_64-pc-mingw32\include\psdk_inc\intrin-impl.h:905 pragma Import (C, InterlockedBitTestAndComplement, "InterlockedBitTestAndComplement"); -- skipped func _InterlockedAnd -- skipped func _InterlockedOr -- skipped func _InterlockedXor -- skipped func _InterlockedIncrement16 -- skipped func _InterlockedDecrement16 -- skipped func _InterlockedCompareExchange16 -- skipped func _InterlockedExchangeAdd -- skipped func _InterlockedCompareExchange -- skipped func _InterlockedIncrement -- skipped func _InterlockedDecrement -- skipped func _InterlockedExchange -- skipped func _InterlockedCompareExchange64 -- skipped func _InterlockedCompareExchangePointer -- skipped func _InterlockedExchangePointer -- skipped func _BitScanForward -- skipped func _BitScanReverse -- skipped func _bittest -- skipped func _bittestandset -- skipped func _bittestandreset -- skipped func _bittestandcomplement -- skipped func __inbyte -- skipped func __inword -- skipped func __indword -- skipped func __outbyte -- skipped func __outword -- skipped func __outdword -- skipped func __inbytestring -- skipped func __inwordstring -- skipped func __indwordstring -- skipped func __outbytestring -- skipped func __outwordstring -- skipped func __outdwordstring -- skipped func __cpuid -- skipped func __readmsr -- skipped func __writemsr -- skipped func __movsb -- skipped func __movsw -- skipped func __movsd -- ***************************************************** end intrin_impl_h;
KLOC-Karsten/adaoled
Ada
833
ads
with Interfaces; use Interfaces; package Bitmap_Graphics is type Color is (Black, White); for Color use (Black => 0, White => 255); type Point is record X : Natural; Y : Natural; end record; type Size is record Width : Natural; Height : Natural; end record; type Byte_Array is array (Natural range <>) of Unsigned_8; type Byte_Array_Access is access all Byte_Array; type Bitmap_Icon is (Signal, Message, Battery, Bluetooth, GPRS, Alarm); procedure Get_Icon (Icon : Bitmap_Icon; Width : out Natural; Height: out Natural; Data : out Byte_Array_Access); type Font is record Width, Height : Natural; Data : Byte_Array_Access; end record; type Font_Access is access all Font; function Get_Font(Size: Positive) return Font_Access; end Bitmap_Graphics;
reznikmm/matreshka
Ada
3,689
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Style_Type_Attributes is pragma Preelaborate; type ODF_Style_Type_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Style_Type_Attribute_Access is access all ODF_Style_Type_Attribute'Class with Storage_Size => 0; end ODF.DOM.Style_Type_Attributes;
Componolit/libsparkcrypto
Ada
986
ads
with LSC.Types; with LSC.Internal.Types; with LSC.Internal.Byteorder32; with LSC.Internal.Byteorder64; package Util is function N (Item : LSC.Internal.Types.Word64) return LSC.Internal.Types.Word64 is (LSC.Internal.Byteorder64.BE_To_Native (Item)); function M (Item : LSC.Internal.Types.Word32) return LSC.Internal.Types.Word32 is (LSC.Internal.Byteorder32.BE_To_Native (Item)); -- Convert byte array to hex string function B2S (Data : LSC.Types.Bytes) return String; -- Convert hex string to byte array function S2B (Data : String) return LSC.Types.Bytes; -- Convert text to equivalent byte array representation function T2B (Data : String) return LSC.Types.Bytes; procedure T2B (Input : String; Output : out LSC.Types.Bytes; Last : out LSC.Types.Natural_Index); -- Convert byte array to equivalent string representation function B2T (Data : LSC.Types.Bytes) return String; end Util;
godunko/adawebpack
Ada
4,133
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Web API Definition -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2021, 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: 5518 $ $Date: 2015-12-20 14:25:24 +0300 (Sun, 20 Dec 2015) $ ------------------------------------------------------------------------------ -- This package provides binding to interface DocumentFragment. ------------------------------------------------------------------------------ with Web.DOM.Elements; with Web.DOM.Nodes; with Web.DOM.Non_Element_Parent_Nodes; with Web.DOM.Texts; with Web.Strings; package Web.DOM.Document_Fragments is pragma Preelaborate; type Document_Fragment is new Web.DOM.Nodes.Node and Web.DOM.Non_Element_Parent_Nodes.Non_Element_Parent_Node with null record; -- interface DocumentFragment : Node { -- constructor(); -- }; overriding function Get_Element_By_Id (Self : Document_Fragment; Element_Id : Web.Strings.Web_String) return Web.DOM.Elements.Element; end Web.DOM.Document_Fragments;
reznikmm/matreshka
Ada
3,961
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Text_Value_Attributes; package Matreshka.ODF_Text.Value_Attributes is type Text_Value_Attribute_Node is new Matreshka.ODF_Text.Abstract_Text_Attribute_Node and ODF.DOM.Text_Value_Attributes.ODF_Text_Value_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Text_Value_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Text_Value_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Text.Value_Attributes;
MinimSecure/unum-sdk
Ada
848
adb
-- Copyright 2008-2019 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. with System; package body Pck is procedure Do_Nothing (A : System.Address) is begin null; end Do_Nothing; end Pck;
MinimSecure/unum-sdk
Ada
801
ads
-- Copyright 2008-2016 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. with System; package Pck is procedure Do_Nothing (A : System.Address); end Pck;
Rodeo-McCabe/orka
Ada
2,064
adb
-- 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 Orka.SIMD.SSE2.Doubles.Compare; with Orka.SIMD.SSE2.Doubles.Logical; with Orka.SIMD.SSE2.Doubles.Swizzle; package body Orka.SIMD.SSE2.Doubles.Arithmetic is function Divide_Or_Zero (Left, Right : m128d) return m128d is use SIMD.SSE2.Doubles.Compare; use SIMD.SSE2.Doubles.Logical; -- Create a mask with all 1's for each element that is non-zero Zero : constant m128d := (0.0, 0.0); Mask : constant m128d := Zero /= Right; Normalized : constant m128d := Left / Right; begin -- Any element in Right that is zero will result in a -- corresponding element consisting of all 0's in the Mask. -- This will avoid the divide-by-zero exception when dividing. return Mask and Normalized; end Divide_Or_Zero; function "abs" (Elements : m128d) return m128d is use SIMD.SSE2.Doubles.Logical; use type GL.Types.Double; begin return And_Not ((-0.0, -0.0), Elements); end "abs"; function Sum (Elements : m128d) return GL.Types.Double is use SIMD.SSE2.Doubles.Swizzle; -- Based on SIMD.SSE.Singles.Arithmetic.Sum Mask_1_0 : constant Unsigned_32 := 1 or 0 * 2; Shuffled : constant m128d := Shuffle (Elements, Elements, Mask_1_0); Sum : constant m128d := Elements + Shuffled; begin return Extract_X (Sum, 0); end Sum; end Orka.SIMD.SSE2.Doubles.Arithmetic;
fnarenji/BezierToSTL
Ada
3,258
adb
package body Iterateur_Mots is function Initialiser( Chaine : String; Separateur : Character) return Iterateur_Mot is begin return (Chaine => To_Unbounded_String(Chaine), Curseur => 1, Separateur => Separateur); end; function Fin(Iterateur : Iterateur_Mot) return Boolean is begin return Iterateur.Curseur > Length(Iterateur.Chaine); end; -- Obtient le texte entre le séparateur courant et le suivant -- Sans avancer le curseur -- Requiert Curseur = 1 ou Chaine (Curseur) = Separateur function Lire_Mot_Suivant(Iterateur : Iterateur_Mot) return String is Car_Lus : Natural; begin return Lire_Mot_Suivant_Interne(Iterateur, Car_Lus); end; -- Avance jusqu'au prochain séparateur et récupère le contenu -- Requiert Curseur = 1 ou Chaine (Curseur) = Separateur function Avancer_Mot_Suivant(Iterateur : in out Iterateur_Mot) return String is Caracteres_Lus : Natural := 0; Contenu : constant String := Lire_Mot_Suivant_Interne (Iterateur, Caracteres_Lus); begin Iterateur.Curseur := Caracteres_Lus; return Contenu; end; function Lire_Mot_Suivant_Interne(Iterateur : Iterateur_Mot; Caracteres_Lus : out Natural) return String is Contenu_Deb, Contenu_Fin : Positive := 1; begin if Iterateur.Curseur > Length(Iterateur.Chaine) then return ""; end if; Caracteres_Lus := Iterateur.Curseur + 1; -- On vérifie que le car. courant est bien un séparateur -- On traite la chaine de séparateur en séparateur -- Cas particulier: quand Curseur = début, on ignore ce test if Iterateur.Curseur /= 1 and then Element(Iterateur.Chaine, Iterateur.Curseur) /= Iterateur.Separateur then raise Erreur_Syntaxe with "Carac. inattendu (courant /= séparateur): L(" & Positive'Image(Iterateur.Curseur) & ") = " & Element(Iterateur.Chaine, Iterateur.Curseur) & " /= " & Iterateur.Separateur; end if; -- On avance jusqu'à trouver le prochain séparateur -- ou jusqu'à la fin de la chaine while Caracteres_Lus <= Length(Iterateur.Chaine) and then Element(Iterateur.Chaine, Caracteres_Lus) /= Iterateur.Separateur loop Caracteres_Lus := Caracteres_Lus + 1; end loop; Contenu_Deb := Iterateur.Curseur; Contenu_Fin := Caracteres_Lus; -- Si on n'est pas à la fin de la chaîne -- alors la fin du contenu est -- 1 car. avant le séparateur suivant if Caracteres_Lus /= Length(Iterateur.Chaine) then Contenu_Fin := Contenu_Fin - 1; end if; -- Si on n'est pas au début de la chaîne -- alors le début du contenu est -- 1 car. après le séparateur précedent if Iterateur.Curseur /= 1 then Contenu_Deb := Contenu_Deb + 1; end if; if Contenu_Fin > Length(Iterateur.Chaine) then return ""; end if; return Slice(Iterateur.Chaine, Contenu_Deb, Contenu_Fin); end; end;
charlie5/lace
Ada
968
adb
with gel.Window.setup, gel.Applet.gui_world, gel.Forge, gel.World, gel.Camera, Physics; pragma Unreferenced (gel.Window.setup); procedure launch_Pong_Tute -- -- Basic pong game. -- is use gel.Applet, gel.Applet.gui_world; --- Applet -- the_Applet : gel.Applet.gui_world.view := gel.Forge.new_gui_Applet (Named => "Pong Tutorial", window_Width => 800, window_Height => 600, space_Kind => physics.Box2d); --- Controls -- Cycle : Natural := 0; begin the_Applet.Camera.Site_is ([0.0, 0.0, 20.0]); --- Main loop. -- while the_Applet.is_open loop Cycle := Cycle + 1; the_Applet.World.evolve; -- Advance the world. the_Applet.freshen; -- Handle any new events and update the screen. end loop; free (the_Applet); end launch_Pong_Tute;
AdaCore/gpr
Ada
2,012
adb
-- -- Copyright (C) 2019-2023, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 -- with Ada.Directories; with Ada.Text_IO; with Ada.Strings.Fixed; with GPR2.Context; with GPR2.Log; with GPR2.Message; with GPR2.Path_Name; with GPR2.Project.Tree; procedure Main is use Ada; use GPR2; use GPR2.Project; procedure Load (Tree : in out Project.Tree.Object); ---------- -- Load -- ---------- procedure Load (Tree : in out Project.Tree.Object) is Ctx : Context.Object; begin Project.Tree.Load (Tree, Create ("demo.gpr"), Ctx); exception when GPR2.Project_Error => if Tree.Has_Messages then Text_IO.Put_Line ("Messages found:"); for C in Tree.Log_Messages.Iterate (False, False, True, True, True) loop declare M : constant Message.Object := Log.Element (C); Mes : constant String := M.Format; L : constant Natural := Strings.Fixed.Index (Mes, "project-paths"); begin if L /= 0 then Text_IO.Put_Line (Mes (L .. Mes'Last)); else Text_IO.Put_Line (Mes); end if; end; end loop; end if; end Load; Current_Directory : Filename_Type := Filename_Type (Directories.Current_Directory); Prj1, Prj2, Prj3 : Project.Tree.Object; begin -- Prj1 Text_IO.Put_Line ("=== Prj1"); Load (Prj1); -- Prj2 Text_IO.Put_Line ("=== Prj2"); Prj2.Register_Project_Search_Path (Path_Name.Create_Directory ("one", Current_Directory)); Load (Prj2); -- Prj3 Text_IO.Put_Line ("=== Prj3"); Prj3.Register_Project_Search_Path (Path_Name.Create_Directory ("one", Current_Directory)); Prj3.Register_Project_Search_Path (Path_Name.Create_Directory ("two", Current_Directory)); Load (Prj3); end Main;
sungyeon/drake
Ada
4,107
ads
pragma License (Unrestricted); -- implementation unit required by compiler package System.Fat_LLF is pragma Pure; package Attr_Long_Long_Float is -- required for Long_Long_Float'Adjacent by compiler (s-fatgen.ads) function Adjacent (X, Towards : Long_Long_Float) return Long_Long_Float with Import, Convention => Intrinsic, External_Name => "__builtin_nextafterl"; -- required for Long_Long_Float'Ceiling by compiler (s-fatgen.ads) function Ceiling (X : Long_Long_Float) return Long_Long_Float with Import, Convention => Intrinsic, External_Name => "__builtin_ceill"; -- required for Long_Long_Float'Compose by compiler (s-fatgen.ads) function Compose (Fraction : Long_Long_Float; Exponent : Integer) return Long_Long_Float; -- required for Long_Long_Float'Copy_Sign by compiler (s-fatgen.ads) function Copy_Sign (X, Y : Long_Long_Float) return Long_Long_Float with Import, Convention => Intrinsic, External_Name => "__builtin_copysignl"; -- required for Long_Long_Float'Exponent by compiler (s-fatgen.ads) function Exponent (X : Long_Long_Float) return Integer; -- required for Long_Long_Float'Floor by compiler (s-fatgen.ads) function Floor (X : Long_Long_Float) return Long_Long_Float with Import, Convention => Intrinsic, External_Name => "__builtin_floorl"; -- required for Long_Long_Float'Fraction by compiler (s-fatgen.ads) function Fraction (X : Long_Long_Float) return Long_Long_Float; -- required for Long_Long_Float'Leading_Part by compiler (s-fatgen.ads) function Leading_Part (X : Long_Long_Float; Radix_Digits : Integer) return Long_Long_Float; -- required for Long_Long_Float'Machine by compiler (s-fatgen.ads) function Machine (X : Long_Long_Float) return Long_Long_Float; -- required for LLF'Machine_Rounding by compiler (s-fatgen.ads) function Machine_Rounding (X : Long_Long_Float) return Long_Long_Float with Import, Convention => Intrinsic, External_Name => "__builtin_nearbyintl"; -- required for Long_Long_Float'Model by compiler (s-fatgen.ads) function Model (X : Long_Long_Float) return Long_Long_Float renames Machine; -- required for Long_Long_Float'Pred by compiler (s-fatgen.ads) function Pred (X : Long_Long_Float) return Long_Long_Float; -- required for Long_Long_Float'Remainder by compiler (s-fatgen.ads) function Remainder (X, Y : Long_Long_Float) return Long_Long_Float with Import, Convention => Intrinsic, External_Name => "__builtin_remainderl"; -- required for Long_Long_Float'Rounding by compiler (s-fatgen.ads) function Rounding (X : Long_Long_Float) return Long_Long_Float with Import, Convention => Intrinsic, External_Name => "__builtin_roundl"; -- required for Long_Long_Float'Scaling by compiler (s-fatgen.ads) function Scaling (X : Long_Long_Float; Adjustment : Integer) return Long_Long_Float with Import, Convention => Intrinsic, External_Name => "__builtin_ldexpl"; -- required for Long_Long_Float'Succ by compiler (s-fatgen.ads) function Succ (X : Long_Long_Float) return Long_Long_Float; -- required for Long_Long_Float'Truncation by compiler (s-fatgen.ads) function Truncation (X : Long_Long_Float) return Long_Long_Float with Import, Convention => Intrinsic, External_Name => "__builtin_truncl"; -- required for LLF'Unbiased_Rounding by compiler (s-fatgen.ads) function Unbiased_Rounding (X : Long_Long_Float) return Long_Long_Float; -- required for Long_Long_Float'Valid by compiler (s-fatgen.ads) function Valid (X : not null access Long_Long_Float) return Boolean; type S is new String (1 .. Long_Long_Float'Size / Character'Size); type P is access all S; for P'Storage_Size use 0; end Attr_Long_Long_Float; end System.Fat_LLF;
1Crazymoney/LearnAda
Ada
1,781
adb
with Ada.Numerics.Discrete_Random; with Ada.Text_IO; use Ada.Text_IO; procedure Saskas is subtype Rand1_10 is Integer range 1..10; package RandomPos is new Ada.Numerics.Discrete_Random(Rand1_10); seed: RandomPos.Generator; protected Kiiro is entry Kiir(mit: String); end Kiiro; protected body Kiiro is entry Kiir(mit: String) when true is begin Put_Line(mit); end Kiir; end Kiiro; type KertParcella is array(Integer range <>) of Boolean; protected Kert is procedure Ugrik(pos: Integer; elet: in out integer); procedure Permetez(pos: Integer); procedure Felszivodik; private K: KertParcella(1..10) := (1..10 => false); end Kert; protected body Kert is procedure Ugrik(pos: Integer; elet: in out integer) is begin if(K(pos) = true) then elet := elet -1; Kiiro.Kiir("Saska: Meghaltam"); end if; end Ugrik; procedure Permetez(pos: Integer) is begin Felszivodik; K(pos) := true; end Permetez; procedure Felszivodik is begin K := (1..10 => false); end Felszivodik; end Kert; task Saska is end Saska; task body Saska is Pozicio: Integer; Elet: Natural := 1; begin while Elet > 0 loop Pozicio := RandomPos.Random(seed); Kiiro.Kiir("Saska: Ugrok egyet ide: " & Integer'Image(Pozicio)); Kert.Ugrik(Pozicio,Elet); delay 1.0; end loop; end Saska; task Kertesz is end Kertesz; task body Kertesz is PermetPos: Integer; begin while Saska'Callable loop PermetPos := RandomPos.Random(seed); Kiiro.Kiir("Kertesz: Permetezek egyet itt: " & Integer'Image(PermetPos)); Kert.Permetez(PermetPos); delay 1.0; end loop; end Kertesz; begin RandomPos.Reset(seed); end Saskas;
charlie5/aIDE
Ada
1,858
ads
with AdaM.Entity, AdaM.Block, gtk.Widget; private with aIDE.Editor.of_exception_Handler, gtk.Text_View, gtk.Box, gtk.Label, gtk.Frame, gtk.Expander; package aIDE.Editor.of_block is type Item is new Editor.item with private; type View is access all Item'Class; package Forge is function to_block_Editor (the_Block : in AdaM.Block.view) return View; end Forge; overriding function top_Widget (Self : in Item) return gtk.Widget.Gtk_Widget; procedure Target_is (Self : in out Item; Now : in AdaM.Block.view); function Target (Self : in Item) return AdaM.Block.view; private use gtk.Text_View, gtk.Expander, gtk.Box, gtk.Label, gtk.Frame; type my_Expander_Record is new Gtk_Expander_Record with record -- Target : AdaM.Source.Entities_View; Target : AdaM.Entity.Entities_View; Editor : aIDE.Editor.of_block.view; end record; type my_Expander is access all my_Expander_Record'Class; type Item is new Editor.item with record Block : AdaM.Block.view; block_editor_Frame : Gtk_Frame; top_Box : gtk_Box; declare_Label : Gtk_Label; declare_Expander : my_Expander; declare_Box : gtk_Box; begin_Label : Gtk_Label; begin_Expander : my_Expander; begin_Box : gtk_Box; exception_Label : Gtk_Label; exception_Expander : my_Expander; exception_Box : gtk_Box; begin_Text, exception_Text : Gtk_Text_View; exception_Handler : aIDE.Editor.of_exception_Handler.view; end record; overriding procedure freshen (Self : in out Item); end aIDE.Editor.of_block;
Rodeo-McCabe/orka
Ada
9,670
ads
-- SPDX-License-Identifier: BSD-3-Clause -- -- Copyright (c) 2017 Eric Bruneton -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions -- are met: -- 1. Redistributions of source code must retain the above copyright -- notice, this list of conditions and the following disclaimer. -- 2. Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- 3. Neither the name of the copyright holders nor the names of its -- contributors may be used to endorse or promote products derived from -- this software without specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -- THE POSSIBILITY OF SUCH DAMAGE. -- This file defines the size of the precomputed texures used in our -- atmosphere model. It also provides tabulated values of the CIE color -- matching functions [1] and the conversion matrix from the XYZ [2] to -- the sRGB [3] color spaces (which are needed to convert the spectral -- radiance samples computed by our algorithm to sRGB luminance values). -- -- [1] https://en.wikipedia.org/wiki/CIE_1931_color_space#Color_matching_functions -- [2] https://en.wikipedia.org/wiki/CIE_1931_color_space -- [3] https://en.wikipedia.org/wiki/SRGB private package Orka.Features.Atmosphere.Constants is pragma Preelaborate; Transmittance_Texture_Width : constant := 256; Transmittance_Texture_Height : constant := 64; Scattering_Texture_R_Size : constant := 32; Scattering_Texture_Mu_Size : constant := 128; Scattering_Texture_Mu_S_Size : constant := 32; Scattering_Texture_Nu_Size : constant := 8; Scattering_Texture_Width : constant := Scattering_Texture_Nu_Size * Scattering_Texture_Mu_S_Size; Scattering_Texture_Height : constant := Scattering_Texture_Mu_Size; Scattering_Texture_Depth : constant := Scattering_Texture_R_Size; Irradiance_Texture_Width : constant := 64; Irradiance_Texture_Height : constant := 16; Max_Luminous_Efficacy : constant Double := 683.0; -- Conversion factor between watts and lumens CIE_2_Deg_Color_Matching_Functions : constant GL.Types.Double_Array := (360.0, 0.000129900000, 0.000003917000, 0.000606100000, 365.0, 0.000232100000, 0.000006965000, 0.001086000000, 370.0, 0.000414900000, 0.000012390000, 0.001946000000, 375.0, 0.000741600000, 0.000022020000, 0.003486000000, 380.0, 0.001368000000, 0.000039000000, 0.006450001000, 385.0, 0.002236000000, 0.000064000000, 0.010549990000, 390.0, 0.004243000000, 0.000120000000, 0.020050010000, 395.0, 0.007650000000, 0.000217000000, 0.036210000000, 400.0, 0.014310000000, 0.000396000000, 0.067850010000, 405.0, 0.023190000000, 0.000640000000, 0.110200000000, 410.0, 0.043510000000, 0.001210000000, 0.207400000000, 415.0, 0.077630000000, 0.002180000000, 0.371300000000, 420.0, 0.134380000000, 0.004000000000, 0.645600000000, 425.0, 0.214770000000, 0.007300000000, 1.039050100000, 430.0, 0.283900000000, 0.011600000000, 1.385600000000, 435.0, 0.328500000000, 0.016840000000, 1.622960000000, 440.0, 0.348280000000, 0.023000000000, 1.747060000000, 445.0, 0.348060000000, 0.029800000000, 1.782600000000, 450.0, 0.336200000000, 0.038000000000, 1.772110000000, 455.0, 0.318700000000, 0.048000000000, 1.744100000000, 460.0, 0.290800000000, 0.060000000000, 1.669200000000, 465.0, 0.251100000000, 0.073900000000, 1.528100000000, 470.0, 0.195360000000, 0.090980000000, 1.287640000000, 475.0, 0.142100000000, 0.112600000000, 1.041900000000, 480.0, 0.095640000000, 0.139020000000, 0.812950100000, 485.0, 0.057950010000, 0.169300000000, 0.616200000000, 490.0, 0.032010000000, 0.208020000000, 0.465180000000, 495.0, 0.014700000000, 0.258600000000, 0.353300000000, 500.0, 0.004900000000, 0.323000000000, 0.272000000000, 505.0, 0.002400000000, 0.407300000000, 0.212300000000, 510.0, 0.009300000000, 0.503000000000, 0.158200000000, 515.0, 0.029100000000, 0.608200000000, 0.111700000000, 520.0, 0.063270000000, 0.710000000000, 0.078249990000, 525.0, 0.109600000000, 0.793200000000, 0.057250010000, 530.0, 0.165500000000, 0.862000000000, 0.042160000000, 535.0, 0.225749900000, 0.914850100000, 0.029840000000, 540.0, 0.290400000000, 0.954000000000, 0.020300000000, 545.0, 0.359700000000, 0.980300000000, 0.013400000000, 550.0, 0.433449900000, 0.994950100000, 0.008749999000, 555.0, 0.512050100000, 1.000000000000, 0.005749999000, 560.0, 0.594500000000, 0.995000000000, 0.003900000000, 565.0, 0.678400000000, 0.978600000000, 0.002749999000, 570.0, 0.762100000000, 0.952000000000, 0.002100000000, 575.0, 0.842500000000, 0.915400000000, 0.001800000000, 580.0, 0.916300000000, 0.870000000000, 0.001650001000, 585.0, 0.978600000000, 0.816300000000, 0.001400000000, 590.0, 1.026300000000, 0.757000000000, 0.001100000000, 595.0, 1.056700000000, 0.694900000000, 0.001000000000, 600.0, 1.062200000000, 0.631000000000, 0.000800000000, 605.0, 1.045600000000, 0.566800000000, 0.000600000000, 610.0, 1.002600000000, 0.503000000000, 0.000340000000, 615.0, 0.938400000000, 0.441200000000, 0.000240000000, 620.0, 0.854449900000, 0.381000000000, 0.000190000000, 625.0, 0.751400000000, 0.321000000000, 0.000100000000, 630.0, 0.642400000000, 0.265000000000, 0.000049999990, 635.0, 0.541900000000, 0.217000000000, 0.000030000000, 640.0, 0.447900000000, 0.175000000000, 0.000020000000, 645.0, 0.360800000000, 0.138200000000, 0.000010000000, 650.0, 0.283500000000, 0.107000000000, 0.000000000000, 655.0, 0.218700000000, 0.081600000000, 0.000000000000, 660.0, 0.164900000000, 0.061000000000, 0.000000000000, 665.0, 0.121200000000, 0.044580000000, 0.000000000000, 670.0, 0.087400000000, 0.032000000000, 0.000000000000, 675.0, 0.063600000000, 0.023200000000, 0.000000000000, 680.0, 0.046770000000, 0.017000000000, 0.000000000000, 685.0, 0.032900000000, 0.011920000000, 0.000000000000, 690.0, 0.022700000000, 0.008210000000, 0.000000000000, 695.0, 0.015840000000, 0.005723000000, 0.000000000000, 700.0, 0.011359160000, 0.004102000000, 0.000000000000, 705.0, 0.008110916000, 0.002929000000, 0.000000000000, 710.0, 0.005790346000, 0.002091000000, 0.000000000000, 715.0, 0.004109457000, 0.001484000000, 0.000000000000, 720.0, 0.002899327000, 0.001047000000, 0.000000000000, 725.0, 0.002049190000, 0.000740000000, 0.000000000000, 730.0, 0.001439971000, 0.000520000000, 0.000000000000, 735.0, 0.000999949300, 0.000361100000, 0.000000000000, 740.0, 0.000690078600, 0.000249200000, 0.000000000000, 745.0, 0.000476021300, 0.000171900000, 0.000000000000, 750.0, 0.000332301100, 0.000120000000, 0.000000000000, 755.0, 0.000234826100, 0.000084800000, 0.000000000000, 760.0, 0.000166150500, 0.000060000000, 0.000000000000, 765.0, 0.000117413000, 0.000042400000, 0.000000000000, 770.0, 0.000083075270, 0.000030000000, 0.000000000000, 775.0, 0.000058706520, 0.000021200000, 0.000000000000, 780.0, 0.000041509940, 0.000014990000, 0.000000000000, 785.0, 0.000029353260, 0.000010600000, 0.000000000000, 790.0, 0.000020673830, 0.000007465700, 0.000000000000, 795.0, 0.000014559770, 0.000005257800, 0.000000000000, 800.0, 0.000010253980, 0.000003702900, 0.000000000000, 805.0, 0.000007221456, 0.000002607800, 0.000000000000, 810.0, 0.000005085868, 0.000001836600, 0.000000000000, 815.0, 0.000003581652, 0.000001293400, 0.000000000000, 820.0, 0.000002522525, 0.000000910930, 0.000000000000, 825.0, 0.000001776509, 0.000000641530, 0.000000000000, 830.0, 0.000001251141, 0.000000451810, 0.000000000000); -- Values from "CIE (1931) 2-deg color matching functions", see -- http://web.archive.org/web/20081228084047/ -- http://www.cvrl.org/database/data/cmfs/ciexyz31.txt XYZ_To_SRGB : constant GL.Types.Double_Array := (+3.2406, -1.5372, -0.4986, -0.9689, +1.8758, +0.0415, +0.0557, -0.2040, +1.0570); -- Conversion matrix from XYZ to linear sRGB color spaces. -- Values from https://en.wikipedia.org/wiki/SRGB end Orka.Features.Atmosphere.Constants;
stcarrez/ada-ado
Ada
5,146
ads
----------------------------------------------------------------------- -- ado-connections-sqlite -- SQLite Database connections -- Copyright (C) 2009 - 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Sqlite3_H; private with Ada.Strings.Unbounded; private with Util.Concurrent.Counters; package ADO.Connections.Sqlite is -- Create database option. CREATE_NAME : constant String := "create"; subtype Sqlite3 is Sqlite3_H.sqlite3; -- The database connection manager type Sqlite_Driver is limited private; -- Initialize the SQLite driver. procedure Initialize; private use Ada.Strings.Unbounded; -- Database connection implementation type Database_Connection is new Connections.Database_Connection with record Server : aliased access Sqlite3_H.sqlite3; Name : Unbounded_String; URI : Unbounded_String; Transactions : Util.Concurrent.Counters.Counter; end record; type Database_Connection_Access is access all Database_Connection'Class; -- Get the database driver which manages this connection. overriding function Get_Driver (Database : in Database_Connection) return Driver_Access; overriding function Create_Statement (Database : in Database_Connection; Table : in ADO.Schemas.Class_Mapping_Access) return Query_Statement_Access; overriding function Create_Statement (Database : in Database_Connection; Query : in String) return Query_Statement_Access; -- Create a delete statement. overriding function Create_Statement (Database : in Database_Connection; Table : in ADO.Schemas.Class_Mapping_Access) return Delete_Statement_Access; -- Create an insert statement. overriding function Create_Statement (Database : in Database_Connection; Table : in ADO.Schemas.Class_Mapping_Access) return Insert_Statement_Access; -- Create an update statement. overriding function Create_Statement (Database : in Database_Connection; Table : in ADO.Schemas.Class_Mapping_Access) return Update_Statement_Access; -- Start a transaction. overriding procedure Begin_Transaction (Database : in out Database_Connection); -- Commit the current transaction. overriding procedure Commit (Database : in out Database_Connection); -- Rollback the current transaction. overriding procedure Rollback (Database : in out Database_Connection); -- Load the database schema definition for the current database. overriding procedure Load_Schema (Database : in Database_Connection; Schema : out ADO.Schemas.Schema_Definition); -- Check if the table with the given name exists in the database. overriding function Has_Table (Database : in Database_Connection; Name : in String) return Boolean; -- Closes the database connection overriding procedure Close (Database : in out Database_Connection); type Sqlite_Driver is new ADO.Connections.Driver with null record; -- Create a new SQLite connection using the configuration parameters. overriding procedure Create_Connection (D : in out Sqlite_Driver; Config : in Configuration'Class; Result : in out Ref.Ref'Class); overriding function Has_Limited_Transactions (Config : in Sqlite_Driver) return Boolean is (True); -- Create the database and initialize it with the schema SQL file. -- The `Admin` parameter describes the database connection with -- administrator access. The `Config` parameter describes the target -- database connection. overriding procedure Create_Database (D : in out Sqlite_Driver; Admin : in Configs.Configuration'Class; Config : in Configs.Configuration'Class; Schema_Path : in String; Messages : out Util.Strings.Vectors.Vector); -- Deletes the SQLite driver. overriding procedure Finalize (D : in out Sqlite_Driver); end ADO.Connections.Sqlite;
zhmu/ananas
Ada
211
ads
with Unroll4_Pkg; use Unroll4_Pkg; package Unroll4 is type Sarray is array (1 .. N) of Float; function "+" (X, Y : Sarray) return Sarray; procedure Add (X, Y : Sarray; R : out Sarray); end Unroll4;