repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
onox/inotify-ada | Ada | 2,085 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2019 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ada.Command_Line;
with Ada.Text_IO;
with Inotify.Recursive;
procedure Monitor is
Instance : Inotify.Recursive.Recursive_Instance;
procedure Handle_Event
(Subject : Inotify.Watch;
Event : Inotify.Event_Kind;
Is_Directory : Boolean;
Name : String)
is
Kind : constant String := (if Is_Directory then "directory" else "file");
begin
Ada.Text_IO.Put_Line (Event'Image & " " & Instance.Name (Subject));
Ada.Text_IO.Put_Line (" [" & Kind & "] '" & Name & "'");
end Handle_Event;
procedure Handle_Move_Event
(Unused_Subject : Inotify.Watch;
Is_Directory : Boolean;
From, To : String)
is
Kind : constant String := (if Is_Directory then "directory" else "file");
begin
if From /= "" then
Ada.Text_IO.Put_Line ("moved " & Kind & " '" & From & "' to '" & To & "'");
else
Ada.Text_IO.Put_Line ("moved new " & Kind & " to '" & To & "'");
end if;
end Handle_Move_Event;
begin
if Ada.Command_Line.Argument_Count /= 1 then
Ada.Text_IO.Put_Line ("Usage: monitor <path>");
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
return;
end if;
Instance.Add_Watch (Path => Ada.Command_Line.Argument (1));
while Instance.Has_Watches loop
Instance.Process_Events (Handle_Event'Access, Handle_Move_Event'Access);
end loop;
end Monitor;
|
reznikmm/matreshka | Ada | 3,793 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Ada.Strings.Wide_Wide_Fixed;
with AMF.Holders.Reals;
separate (AMF.Internals.Factories.Primitive_Types_Factories)
function Convert_Real_To_String
(Value : League.Holders.Holder) return League.Strings.Universal_String is
begin
return
League.Strings.To_Universal_String
(Ada.Strings.Wide_Wide_Fixed.Trim
(AMF.Real'Wide_Wide_Image (AMF.Holders.Reals.Element (Value)),
Ada.Strings.Both));
end Convert_Real_To_String;
|
AdaCore/libadalang | Ada | 224 | ads | package Invalid is
type Enum is ('A', 'B');
Value : constant Enum := 'C';
--% node.f_default_expr.p_eval_as_int
C1 : constant Character := No_Such_Entity;
--% node.f_default_expr.p_eval_as_int
end Invalid;
|
Fabien-Chouteau/Ada_Drivers_Library | Ada | 11,520 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with NRF51_SVD.RADIO; use NRF51_SVD.RADIO;
with System.Storage_Elements; use System.Storage_Elements;
package body nRF51.Radio is
------------------------------------
-- Setup_For_Bluetooth_Low_Energy --
------------------------------------
procedure Setup_For_Bluetooth_Low_Energy is
begin
Set_Mode (BLE_1MBIT);
Configure_Packet (S0_Field_Size_In_Byte => 1,
S1_Field_Size_In_Bit => 0,
Length_Field_Size_In_Bit => 8,
Max_Packet_Length_In_Byte => 1 + 1 + 37,
Static_Packet_Length_In_Byte => 0,
On_Air_Endianness => Little_Endian);
Configure_CRC (Enable => True,
Length => 3,
Skip_Address => True,
Polynomial => 16#00_065B#,
Initial_Value => 16#55_5555#);
Configure_Whitening (True);
end Setup_For_Bluetooth_Low_Energy;
-----------
-- State --
-----------
function State return Radio_State is
begin
-- return Radio_State'Enum_Val (RADIO_Periph.STATE.STATE'Enum_Rep);
case RADIO_Periph.STATE.STATE is
when Disabled => return Disabled;
when Rxru => return Rx_Ramp_Up;
when Rxidle => return Rx_Idle;
when Rx => return Rx_State;
when Rxdisable => return Rx_Disabled;
when Txru => return Tx_Ramp_Up;
when Txidle => return Tx_Idle;
when Tx => return Tx_State;
when Txdisable => return Tx_Disabled;
end case;
end State;
---------------------
-- Enable_Shortcut --
---------------------
procedure Enable_Shortcut (Short : Shortcut) is
begin
case Short is
when Ready_To_Start =>
RADIO_Periph.SHORTS.READY_START := Enabled;
when End_To_Disable =>
RADIO_Periph.SHORTS.END_DISABLE := Enabled;
when Disabled_To_TXen =>
RADIO_Periph.SHORTS.DISABLED_TXEN := Enabled;
when Disabled_To_RXen =>
RADIO_Periph.SHORTS.DISABLED_RXEN := Enabled;
when Address_To_RSSIstart =>
RADIO_Periph.SHORTS.ADDRESS_RSSISTART := Enabled;
when End_To_Start =>
RADIO_Periph.SHORTS.END_START := Enabled;
when Address_To_BCstart =>
RADIO_Periph.SHORTS.ADDRESS_BCSTART := Enabled;
end case;
end Enable_Shortcut;
----------------------
-- Disable_Shortcut --
----------------------
procedure Disable_Shortcut (Short : Shortcut) is
begin
case Short is
when Ready_To_Start =>
RADIO_Periph.SHORTS.READY_START := Disabled;
when End_To_Disable =>
RADIO_Periph.SHORTS.END_DISABLE := Disabled;
when Disabled_To_TXen =>
RADIO_Periph.SHORTS.DISABLED_TXEN := Disabled;
when Disabled_To_RXen =>
RADIO_Periph.SHORTS.DISABLED_RXEN := Disabled;
when Address_To_RSSIstart =>
RADIO_Periph.SHORTS.ADDRESS_RSSISTART := Disabled;
when End_To_Start =>
RADIO_Periph.SHORTS.END_START := Disabled;
when Address_To_BCstart =>
RADIO_Periph.SHORTS.ADDRESS_BCSTART := Disabled;
end case;
end Disable_Shortcut;
----------------
-- Set_Packet --
----------------
procedure Set_Packet
(Address : System.Address)
is
begin
RADIO_Periph.PACKETPTR := UInt32 (To_Integer (Address));
end Set_Packet;
-------------------
-- Set_Frequency --
-------------------
procedure Set_Frequency (F : Radio_Frequency_MHz) is
begin
RADIO_Periph.FREQUENCY.FREQUENCY :=
UInt7 (F - Radio_Frequency_MHz'First);
end Set_Frequency;
---------------
-- Set_Power --
---------------
procedure Set_Power (P : Radio_Power) is
begin
RADIO_Periph.TXPOWER.TXPOWER :=
TXPOWER_TXPOWER_Field'Enum_Val (P'Enum_Rep);
end Set_Power;
--------------
-- Set_Mode --
--------------
procedure Set_Mode (Mode : Radio_Mode) is
begin
RADIO_Periph.MODE.MODE := (case Mode is
when Nordic_1MBIT => Nrf_1Mbit,
when Nordic_2MBIT => Nrf_2Mbit,
when Nordic_250KBIT => Nrf_250Kbit,
when BLE_1MBIT => Ble_1Mbit);
end Set_Mode;
-------------------------
-- Set_Logic_Addresses --
-------------------------
procedure Set_Logic_Addresses
(Base0, Base1 : HAL.UInt32;
Base_Length_In_Byte : Base_Address_Lenght;
AP0, AP1, AP2, AP3, AP4, AP5, AP6, AP7 : HAL.UInt8)
is
begin
RADIO_Periph.BASE0 := Base0;
RADIO_Periph.BASE1 := Base1;
RADIO_Periph.PCNF1.BALEN := UInt3 (Base_Length_In_Byte);
RADIO_Periph.PREFIX0.Arr := (AP0, AP1, AP2, AP3);
RADIO_Periph.PREFIX1.Arr := (AP4, AP5, AP6, AP7);
end Set_Logic_Addresses;
-----------------------------
-- Translate_Logic_Address --
-----------------------------
procedure Translate_Logic_Address (Logic_Addr : Radio_Logic_Address;
Base : out HAL.UInt32;
Prefix : out HAL.UInt8)
is
begin
case Logic_Addr is
when 0 =>
Base := RADIO_Periph.BASE0;
when 1 .. 7 =>
Base := RADIO_Periph.BASE1;
end case;
case Logic_Addr is
when 0 .. 3 =>
Prefix := RADIO_Periph.PREFIX0.Arr (Integer (Logic_Addr));
when 4 .. 7 =>
Prefix := RADIO_Periph.PREFIX1.Arr (Integer (Logic_Addr));
end case;
end Translate_Logic_Address;
--------------------
-- Set_TX_Address --
--------------------
procedure Set_TX_Address (Logic_Addr : Radio_Logic_Address) is
begin
RADIO_Periph.TXADDRESS.TXADDRESS := UInt3 (Logic_Addr);
end Set_TX_Address;
--------------------------
-- Get_RX_Match_Address --
--------------------------
function RX_Match_Address return Radio_Logic_Address is
begin
return Radio_Logic_Address (RADIO_Periph.RXMATCH.RXMATCH);
end RX_Match_Address;
----------------------
-- Set_RX_Addresses --
----------------------
procedure Set_RX_Addresses (Enable_Mask : Logic_Address_Mask) is
begin
for Index in Enable_Mask'Range loop
RADIO_Periph.RXADDRESSES.ADDR.Arr (Integer (Index)) :=
(if Enable_Mask (Index) then Enabled else Disabled);
end loop;
end Set_RX_Addresses;
-------------------
-- Configure_CRC --
-------------------
procedure Configure_CRC (Enable : Boolean;
Length : UInt2;
Skip_Address : Boolean;
Polynomial : UInt24;
Initial_Value : UInt24)
is
begin
if Enable then
case Length is
when 0 =>
RADIO_Periph.CRCCNF.LEN := Disabled;
when 1 =>
RADIO_Periph.CRCCNF.LEN := One;
when 2 =>
RADIO_Periph.CRCCNF.LEN := Two;
when 3 =>
RADIO_Periph.CRCCNF.LEN := Three;
end case;
else
RADIO_Periph.CRCCNF.LEN := Disabled;
end if;
RADIO_Periph.CRCCNF.SKIPADDR := (if Skip_Address then Skip else Include);
RADIO_Periph.CRCPOLY.CRCPOLY := Polynomial;
RADIO_Periph.CRCINIT.CRCINIT := Initial_Value;
end Configure_CRC;
---------------
-- CRC_Error --
---------------
function CRC_Error return Boolean is
begin
return RADIO_Periph.CRCSTATUS.CRCSTATUS = Crcerror;
end CRC_Error;
-------------------------
-- Configure_Whitening --
-------------------------
procedure Configure_Whitening (Enable : Boolean;
Initial_Value : UInt6 := 0)
is
begin
RADIO_Periph.PCNF1.WHITEEN := (if Enable then Enabled else Disabled);
RADIO_Periph.DATAWHITEIV.DATAWHITEIV :=
2#0100_0000# or UInt7 (Initial_Value);
end Configure_Whitening;
----------------------
-- Configure_Packet --
----------------------
procedure Configure_Packet
(S0_Field_Size_In_Byte : Bit;
S1_Field_Size_In_Bit : UInt4;
Length_Field_Size_In_Bit : UInt4;
Max_Packet_Length_In_Byte : Packet_Len;
Static_Packet_Length_In_Byte : Packet_Len;
On_Air_Endianness : Length_Field_Endianness)
is
begin
RADIO_Periph.PCNF0.LFLEN := Length_Field_Size_In_Bit;
RADIO_Periph.PCNF0.S0LEN := S0_Field_Size_In_Byte = 1;
RADIO_Periph.PCNF0.S1LEN := S1_Field_Size_In_Bit;
RADIO_Periph.PCNF1.MAXLEN := Max_Packet_Length_In_Byte;
RADIO_Periph.PCNF1.STATLEN := Static_Packet_Length_In_Byte;
RADIO_Periph.PCNF1.ENDIAN := (if On_Air_Endianness = Little_Endian then
Little
else
Big);
end Configure_Packet;
end nRF51.Radio;
|
AdaCore/Ada_Drivers_Library | Ada | 1,925 | ads | -- This package was generated by the Ada_Drivers_Library project wizard script
package ADL_Config is
Architecture : constant String := "ARM"; -- From board definition
Board : constant String := "STM32_H405"; -- From command line
CPU_Core : constant String := "ARM Cortex-M4F"; -- From mcu definition
Device_Family : constant String := "STM32F4"; -- From board definition
Device_Name : constant String := "STM32F405RGTx"; -- From board definition
Has_Ravenscar_Full_Runtime : constant String := "True"; -- From board definition
Has_Ravenscar_SFP_Runtime : constant String := "True"; -- From board definition
Has_ZFP_Runtime : constant String := "False"; -- From board definition
High_Speed_External_Clock : constant := 8_000_000; -- From board definition
Max_Mount_Name_Length : constant := 128; -- From default value
Max_Mount_Points : constant := 2; -- From default value
Max_Path_Length : constant := 1024; -- From default value
Number_Of_Interrupts : constant := 0; -- From default value
Runtime_Name : constant String := "embedded-stm32f4"; -- From default value
Runtime_Name_Suffix : constant String := "stm32f4"; -- From board definition
Runtime_Profile : constant String := "embedded"; -- From command line
Use_Startup_Gen : constant Boolean := False; -- From command line
Vendor : constant String := "STMicro"; -- From board definition
end ADL_Config;
|
dan76/Amass | Ada | 447 | ads | -- Copyright © by Jeff Foley 2017-2023. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
-- SPDX-License-Identifier: Apache-2.0
name = "AnubisDB"
type = "api"
function start()
set_rate_limit(1)
end
function vertical(ctx, domain)
scrape(ctx, {['url']=build_url(domain)})
end
function build_url(domain)
return "https://jonlu.ca/anubis/subdomains/" .. domain
end
|
reznikmm/matreshka | Ada | 5,097 | 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.Expansion_Nodes.Collections is
pragma Preelaborate;
package UML_Expansion_Node_Collections is
new AMF.Generic_Collections
(UML_Expansion_Node,
UML_Expansion_Node_Access);
type Set_Of_UML_Expansion_Node is
new UML_Expansion_Node_Collections.Set with null record;
Empty_Set_Of_UML_Expansion_Node : constant Set_Of_UML_Expansion_Node;
type Ordered_Set_Of_UML_Expansion_Node is
new UML_Expansion_Node_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_UML_Expansion_Node : constant Ordered_Set_Of_UML_Expansion_Node;
type Bag_Of_UML_Expansion_Node is
new UML_Expansion_Node_Collections.Bag with null record;
Empty_Bag_Of_UML_Expansion_Node : constant Bag_Of_UML_Expansion_Node;
type Sequence_Of_UML_Expansion_Node is
new UML_Expansion_Node_Collections.Sequence with null record;
Empty_Sequence_Of_UML_Expansion_Node : constant Sequence_Of_UML_Expansion_Node;
private
Empty_Set_Of_UML_Expansion_Node : constant Set_Of_UML_Expansion_Node
:= (UML_Expansion_Node_Collections.Set with null record);
Empty_Ordered_Set_Of_UML_Expansion_Node : constant Ordered_Set_Of_UML_Expansion_Node
:= (UML_Expansion_Node_Collections.Ordered_Set with null record);
Empty_Bag_Of_UML_Expansion_Node : constant Bag_Of_UML_Expansion_Node
:= (UML_Expansion_Node_Collections.Bag with null record);
Empty_Sequence_Of_UML_Expansion_Node : constant Sequence_Of_UML_Expansion_Node
:= (UML_Expansion_Node_Collections.Sequence with null record);
end AMF.UML.Expansion_Nodes.Collections;
|
FrankBuss/Ada_Synth | Ada | 3,121 | adb |
with HAL; use HAL;
with STM32; use STM32;
with STM32.GPIO; use STM32.GPIO;
with STM32.Device; use STM32.Device;
package body Serial_IO is
protected body Serial_Port_Controller is
procedure Init (Baud_Rate : Baud_Rates) is
Tx_Pin : constant GPIO_Point := PB6;
Rx_Pin : constant GPIO_Point := PB7;
Device_Pins : constant GPIO_Points := Rx_Pin & Tx_Pin;
Configuration : GPIO_Port_Configuration;
begin
-- configure UART 1
Enable_Clock (USART_1);
Disable (USART_1);
Set_Baud_Rate (USART_1, Baud_Rate);
Set_Mode (USART_1, Tx_Rx_Mode);
Set_Stop_Bits (USART_1, Stopbits_1);
Set_Word_Length (USART_1, Word_Length_8);
Set_Parity (USART_1, No_Parity);
Set_Flow_Control (USART_1, No_Flow_Control);
Enable (USART_1);
-- configure pins
Enable_Clock (Device_Pins);
Configuration.Mode := Mode_AF;
Configuration.Speed := Speed_50MHz;
Configuration.Output_Type := Push_Pull;
Configuration.Resistors := Pull_Up;
Configure_IO (Device_Pins, Configuration);
Configure_Alternate_Function (Device_Pins, GPIO_AF_USART1_7);
-- enable interrupt
Enable_Interrupts (USART_1, Received_Data_Not_Empty);
Enable_Interrupts (USART_1, Transmission_Complete);
Initialized := True;
end Init;
function Available return Boolean is
begin
return not Input.Is_Empty;
end Available;
procedure Read (Result : out Unsigned_8) is
begin
Result := Input.Read;
end Read;
-- doesn't work, because in protected functions I can't modify variables
-- function Read return Unsigned_8 is
-- begin
-- return Input.Read;
-- end;
procedure Write (Data : Unsigned_8) is
begin
if Output.Is_Empty then
-- if the output FIFO is empty, start transfer
Transmit (USART_1, UInt9 (Data));
else
-- else add to the FIFO: TODO: possible race condition?
output.Write (Data);
end if;
end Write;
procedure Interrupt_Handler is
Received_Char : Unsigned_8;
begin
-- check for data arrival
if Status (USART_1, Read_Data_Register_Not_Empty) and
Interrupt_Enabled (USART_1, Received_Data_Not_Empty)
then
Received_Char := Unsigned_8 (Current_Input (USART_1) and 255);
Input.Write (Received_Char);
end if;
-- check for transmission ready
if Status (USART_1, Transmission_Complete_Indicated) and
Interrupt_Enabled (USART_1, Transmission_Complete)
then
if not Output.Is_Empty then
Transmit (USART_1, UInt9 (Output.Read));
end if;
Clear_Status (USART_1, Transmission_Complete_Indicated);
end if;
end Interrupt_Handler;
end Serial_Port_Controller;
end Serial_IO;
|
reznikmm/matreshka | Ada | 14,757 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014-2017, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Matreshka.Internals.Unicode.Ucd;
package body Matreshka.CLDR.Collation_Compiler is
type Collation_Element_Sequence_Access is
access all Matreshka.Internals.Unicode.Ucd.Collation_Element_Sequence;
type Collation_Second_Stage_Access is
access Matreshka.Internals.Unicode.Ucd.Collation_Second_Stage;
type Collation_First_Stage is
array (Matreshka.Internals.Unicode.Ucd.First_Stage_Index)
of Collation_Second_Stage_Access;
type Contractor_Array_Access is
access all Matreshka.Internals.Unicode.Ucd.Contractor_Array;
procedure Free is
new Ada.Unchecked_Deallocation
(Matreshka.Internals.Unicode.Ucd.Collation_Second_Stage,
Collation_Second_Stage_Access);
procedure Free is
new Ada.Unchecked_Deallocation
(Matreshka.Internals.Unicode.Ucd.Collation_Element_Sequence,
Collation_Element_Sequence_Access);
procedure Free is
new Ada.Unchecked_Deallocation
(Matreshka.Internals.Unicode.Ucd.Contractor_Array,
Contractor_Array_Access);
-------------------------------------
-- Construct_Collation_Information --
-------------------------------------
procedure Construct_Collation_Information
(Data : Matreshka.CLDR.Collation_Data.Collation_Information;
Locale : not null access Matreshka.Internals.Locales.Locale_Data)
is
use type Matreshka.CLDR.Collation_Data.Collation_Record_Access;
use type Matreshka.Internals.Unicode.Code_Point;
use type Matreshka.Internals.Unicode.Ucd.Sequence_Index;
Expansion : Collation_Element_Sequence_Access;
Expansion_Last : Matreshka.Internals.Unicode.Ucd.Sequence_Index;
Contraction : Contractor_Array_Access;
Contraction_Last : Matreshka.Internals.Unicode.Ucd.Sequence_Index;
Mapping : Collation_First_Stage := (others => null);
Last_Variable : Matreshka.Internals.Unicode.Ucd.Collation_Weight := 0;
procedure Append_Expansion
(Sequence : Matreshka.CLDR.Collation_Data.Collation_Element_Array;
First : out Matreshka.Internals.Unicode.Ucd.Sequence_Index;
Last : out Matreshka.Internals.Unicode.Ucd.Sequence_Index);
-- Appends specified expansion sequence to collectd set of expansion
-- sequences.
procedure Process_Contractors
(Start : Matreshka.CLDR.Collation_Data.Collation_Record_Access;
Prefix : Matreshka.CLDR.Collation_Data.Code_Point_Array;
First : out Matreshka.Internals.Unicode.Ucd.Sequence_Count;
Last : out Matreshka.Internals.Unicode.Ucd.Sequence_Count);
-- Process contractors recursively.
----------------------
-- Append_Expansion --
----------------------
procedure Append_Expansion
(Sequence : Matreshka.CLDR.Collation_Data.Collation_Element_Array;
First : out Matreshka.Internals.Unicode.Ucd.Sequence_Index;
Last : out Matreshka.Internals.Unicode.Ucd.Sequence_Index)
is
Internal :
Matreshka.Internals.Unicode.Ucd.Collation_Element_Sequence
(1 .. Sequence'Length);
Internal_Last : Matreshka.Internals.Unicode.Ucd.Sequence_Index
:= Internal'First;
Expansion_First : Matreshka.Internals.Unicode.Ucd.Sequence_Index;
begin
-- Convert sequence of collation elements into format used by
-- internal database and update greatest weight of variable
-- character.
for Element of Sequence loop
Internal (Internal_Last) :=
(Primary => Element.Primary,
Secondary => Element.Secondary,
Trinary => Element.Trinary);
Internal_Last := Internal_Last + 1;
if Element.Is_Variable then
Last_Variable :=
Matreshka.Internals.Unicode.Ucd.Collation_Weight'Max
(Last_Variable, Element.Primary);
end if;
end loop;
if Expansion = null then
Expansion :=
new Matreshka.Internals.Unicode.Ucd.Collation_Element_Sequence
(Matreshka.Internals.Unicode.Ucd.Sequence_Index'Range);
Expansion_First := Expansion'First;
Expansion_Last := Expansion'First + Internal'Length - 1;
Expansion (Expansion'First .. Expansion_Last) := Internal;
else
-- Lookup to reuse of existent sequences in the table is not time
-- efficient, thus it is not used here.
Expansion_First := Expansion_Last + 1;
Expansion_Last := Expansion_Last + Internal'Length;
Expansion (Expansion_First .. Expansion_Last) := Internal;
end if;
First := Expansion_First;
Last := Expansion_Last;
end Append_Expansion;
------------------------------
-- Process_Code_Point_Chain --
------------------------------
procedure Process_Code_Point_Chain
(Starter : Matreshka.Internals.Unicode.Code_Point)
is
First : constant Matreshka.Internals.Unicode.Ucd.First_Stage_Index
:= Matreshka.Internals.Unicode.Ucd.First_Stage_Index
(Starter / Internals.Unicode.Ucd.Second_Stage_Index'Modulus);
Second : constant Matreshka.Internals.Unicode.Ucd.Second_Stage_Index
:= Matreshka.Internals.Unicode.Ucd.Second_Stage_Index
(Starter mod Internals.Unicode.Ucd.Second_Stage_Index'Modulus);
Current_Record : Matreshka.CLDR.Collation_Data.Collation_Record_Access
:= Data.Collations (Starter);
begin
-- Allocate block when it wasn't allocated.
if Mapping (First) = null then
Mapping (First) :=
new Matreshka.Internals.Unicode.Ucd.Collation_Second_Stage'
(others => (0, 0, 0, 0));
end if;
-- Lookup for collation record of code point itself (without
-- contractors) and process it.
while Current_Record /= null loop
-- XXX Loop can be removed if collations chain will be sorted in
-- contractors order (single character will be first element).
if Current_Record.Contractors'Length = 1 then
Append_Expansion
(Current_Record.Collations.all,
Mapping (First) (Second).Expansion_First,
Mapping (First) (Second).Expansion_Last);
exit;
end if;
Current_Record := Current_Record.Next;
end loop;
Process_Contractors
(Data.Collations (Starter),
(1 => Starter),
Mapping (First) (Second).Contractor_First,
Mapping (First) (Second).Contractor_Last);
end Process_Code_Point_Chain;
-------------------------
-- Process_Contractors --
-------------------------
procedure Process_Contractors
(Start : Matreshka.CLDR.Collation_Data.Collation_Record_Access;
Prefix : Matreshka.CLDR.Collation_Data.Code_Point_Array;
First : out Matreshka.Internals.Unicode.Ucd.Sequence_Count;
Last : out Matreshka.Internals.Unicode.Ucd.Sequence_Count)
is
use type Matreshka.CLDR.Collation_Data.Code_Point_Array;
Current_Record : Matreshka.CLDR.Collation_Data.Collation_Record_Access
:= Start;
begin
First := 0;
Last := 0;
-- Process all contractors with currently processed length and
-- started from given prefix.
while Current_Record /= null loop
if Current_Record.Contractors'Length = Prefix'Length + 1
and Current_Record.Contractors
(Current_Record.Contractors'First
.. Current_Record.Contractors'Last - 1) = Prefix
then
if Contraction = null then
Contraction :=
new Matreshka.Internals.Unicode.Ucd.Contractor_Array
(Matreshka.Internals.Unicode.Ucd.Sequence_Index);
Contraction_Last := Contraction'First;
else
Contraction_Last := Contraction_Last + 1;
end if;
if First = 0 then
First := Contraction_Last;
end if;
Last := Contraction_Last;
Contraction (Contraction_Last).Code :=
Current_Record.Contractors (Current_Record.Contractors'Last);
Append_Expansion
(Current_Record.Collations.all,
Contraction (Contraction_Last).Expansion_First,
Contraction (Contraction_Last).Expansion_Last);
end if;
Current_Record := Current_Record.Next;
end loop;
if First /= 0 then
for C in First .. Last loop
Process_Contractors
(Start,
Prefix & Contraction (C).Code,
Contraction (C).Contractor_First,
Contraction (C).Contractor_Last);
end loop;
end if;
end Process_Contractors;
use type Matreshka.Internals.Unicode.Ucd.First_Stage_Index;
use type Matreshka.Internals.Unicode.Ucd.Collation_Second_Stage;
Replaced :
array (Matreshka.Internals.Unicode.Ucd.First_Stage_Index) of Boolean
:= (others => False);
begin
-- Collect expansion and constraction information.
for Starting_Code in Data.Collations'Range loop
Process_Code_Point_Chain (Starting_Code);
end loop;
-- Remove duplicate tables and share one copy each time it duplicates.
for J in Mapping'Range loop
if not Replaced (J) then
for K in J + 1 .. Mapping'Last loop
if Mapping (J).all = Mapping (K).all then
Free (Mapping (K));
Mapping (K) := Mapping (J);
Replaced (K) := True;
end if;
end loop;
end if;
end loop;
-- Construct collation information for locale finally.
Locale.Collation.Expansion :=
new Matreshka.Internals.Unicode.Ucd.Collation_Element_Sequence'
(Expansion (Expansion'First .. Expansion_Last));
Locale.Collation.Contraction :=
new Matreshka.Internals.Unicode.Ucd.Contractor_Array'
(Contraction (Contraction'First .. Contraction_Last));
declare
Aux : Matreshka.Internals.Unicode.Ucd.Collation_First_Stage
:= (others =>
Matreshka.Internals.Unicode.Ucd.Collation_Second_Stage_Access
(Mapping (1)));
begin
for J in Mapping'Range loop
Aux (J) :=
Matreshka.Internals.Unicode.Ucd.Collation_Second_Stage_Access
(Mapping (J));
end loop;
Locale.Collation.Mapping :=
new Matreshka.Internals.Unicode.Ucd.Collation_First_Stage'(Aux);
end;
Locale.Collation.Last_Variable := Last_Variable;
Locale.Collation.Backwards := False;
-- XXX 'backward' must be taken from collation data.
-- Release auxiliary data.
Free (Expansion);
Free (Contraction);
end Construct_Collation_Information;
end Matreshka.CLDR.Collation_Compiler;
|
reznikmm/matreshka | Ada | 4,516 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014-2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- Provides a convenient implementation of the ServletResponse interface that
-- can be subclassed by developers wishing to adapt the response from a
-- Servlet. This class implements the Wrapper or Decorator pattern. Methods
-- default to calling through to the wrapped response object.
------------------------------------------------------------------------------
with League.Strings;
with Servlet.Output_Streams;
with Servlet.Responses;
package Servlet.Response_Wrappers is
pragma Preelaborate;
type Servlet_Response_Wrapper
(Response : not null access Servlet.Responses.Servlet_Response'Class) is
limited new Servlet.Responses.Servlet_Response with null record;
overriding function Get_Output_Stream
(Self : Servlet_Response_Wrapper)
return
not null access Servlet.Output_Streams.Servlet_Output_Stream'Class;
overriding procedure Set_Character_Encoding
(Self : in out Servlet_Response_Wrapper;
Encoding : League.Strings.Universal_String);
overriding procedure Set_Content_Type
(Self : in out Servlet_Response_Wrapper;
To : League.Strings.Universal_String);
end Servlet.Response_Wrappers;
|
Rodeo-McCabe/orka | Ada | 3,823 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2017 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Orka.Transforms.Doubles.Quaternions;
package body Orka.Cameras is
procedure Set_FOV (Object : in out Camera_Lens; FOV : GL.Types.Single) is
begin
Object.FOV := FOV;
end Set_FOV;
function FOV (Object : Camera_Lens) return GL.Types.Single is
(Object.FOV);
function Projection_Matrix (Object : Camera_Lens) return Transforms.Matrix4 is
Width : constant GL.Types.Single := GL.Types.Single (Object.Width);
Height : constant GL.Types.Single := GL.Types.Single (Object.Height);
use type GL.Types.Single;
begin
if Object.Reversed_Z then
return Transforms.Infinite_Perspective_Reversed_Z (Object.FOV, Width / Height, 0.1);
else
return Transforms.Infinite_Perspective (Object.FOV, Width / Height, 0.1);
end if;
end Projection_Matrix;
-----------------------------------------------------------------------------
procedure Set_Input_Scale
(Object : in out Camera;
X, Y, Z : GL.Types.Double) is
begin
Object.Scale := (X, Y, Z, 0.0);
end Set_Input_Scale;
procedure Set_Up_Direction
(Object : in out Camera;
Direction : Vector4) is
begin
Object.Up := Direction;
end Set_Up_Direction;
procedure Set_Position
(Object : in out First_Person_Camera;
Position : Vector4) is
begin
Object.Position := Position;
end Set_Position;
overriding
procedure Look_At
(Object : in out Third_Person_Camera;
Target : Behaviors.Behavior_Ptr) is
begin
Object.Target := Target;
end Look_At;
-----------------------------------------------------------------------------
overriding
function View_Position (Object : First_Person_Camera) return Vector4 is
(Object.Position);
overriding
function Target_Position (Object : Third_Person_Camera) return Vector4 is
(Object.Target.Position);
-----------------------------------------------------------------------------
function Create_Lens
(Width, Height : Positive;
FOV : GL.Types.Single;
Context : Contexts.Context'Class) return Camera_Lens'Class is
begin
return Result : Camera_Lens (Width, Height) do
Result.FOV := FOV;
Result.Reversed_Z := Context.Enabled (Contexts.Reversed_Z);
end return;
end Create_Lens;
function Look_At (Target, Camera, Up_World : Vector4) return Matrix4 is
use Orka.Transforms.Doubles.Vectors;
Forward : constant Vector4
:= Normalize ((Target - Camera));
Side : constant Vector4 := Normalize (Cross (Forward, Up_World));
Up : constant Vector4 := Cross (Side, Forward);
begin
return
((Side (X), Up (X), -Forward (X), 0.0),
(Side (Y), Up (Y), -Forward (Y), 0.0),
(Side (Z), Up (Z), -Forward (Z), 0.0),
(0.0, 0.0, 0.0, 1.0));
end Look_At;
function Rotate_To_Up (Object : Camera'Class) return Matrix4 is
package Quaternions renames Orka.Transforms.Doubles.Quaternions;
use Orka.Transforms.Doubles.Matrices;
begin
return R (Vector4 (Quaternions.R (Y_Axis, Object.Up)));
end Rotate_To_Up;
end Orka.Cameras;
|
damaki/libkeccak | Ada | 13,547 | adb | -------------------------------------------------------------------------------
-- Copyright (c) 2019, Daniel King
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
-- * Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * The name of the copyright holder may not be used to endorse or promote
-- Products derived from this software without specific prior written
-- permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
package body Keccak.Generic_KeccakF.Byte_Lanes
is
---------------------------
-- XOR_Bits_Into_State --
---------------------------
procedure XOR_Bits_Into_State (A : in out State;
Data : in Keccak.Types.Byte_Array;
Bit_Len : in Natural)
is
Remaining_Bits : Natural := Bit_Len;
Offset : Natural := 0;
begin
-- Process whole lanes (64 bits).
Outer_Loop :
for Y in Y_Coord loop
pragma Loop_Invariant ((Offset * 8) + Remaining_Bits = Bit_Len);
pragma Loop_Invariant (Offset mod (Lane_Size_Bits / 8) = 0);
pragma Loop_Invariant (Offset = Natural (Y) * (Lane_Size_Bits / 8) * 5);
for X in X_Coord loop
pragma Loop_Invariant ((Offset * 8) + Remaining_Bits = Bit_Len);
pragma Loop_Invariant (Offset mod (Lane_Size_Bits / 8) = 0);
pragma Loop_Invariant (Offset = (Natural (Y) * (Lane_Size_Bits / 8) * 5) +
(Natural (X) * (Lane_Size_Bits / 8)));
exit Outer_Loop when Remaining_Bits < Lane_Size_Bits;
declare
Lane : Lane_Type := 0;
begin
for I in Natural range 0 .. (Lane_Size_Bits / 8) - 1 loop
Lane := Lane or Shift_Left (Lane_Type (Data (Data'First + Offset + I)),
I * 8);
end loop;
A (X, Y) := A (X, Y) xor Lane;
end;
Offset := Offset + Lane_Size_Bits / 8;
Remaining_Bits := Remaining_Bits - Lane_Size_Bits;
end loop;
end loop Outer_Loop;
-- Process any remaining data (smaller than 1 lane - 64 bits)
if Remaining_Bits > 0 then
declare
X : constant X_Coord := X_Coord ((Bit_Len / Lane_Size_Bits) mod 5);
Y : constant Y_Coord := Y_Coord ((Bit_Len / Lane_Size_Bits) / 5);
Word : Lane_Type := 0;
Remaining_Bytes : constant Natural := (Remaining_Bits + 7) / 8;
begin
for I in Natural range 0 .. Remaining_Bytes - 1 loop
Word := Word or Shift_Left (Lane_Type (Data (Data'First + Offset + I)), I * 8);
end loop;
A (X, Y) := A (X, Y) xor (Word and (2**Remaining_Bits) - 1);
end;
end if;
end XOR_Bits_Into_State;
---------------------------
-- XOR_Bits_Into_State --
---------------------------
procedure XOR_Bits_Into_State (A : in out Lane_Complemented_State;
Data : in Keccak.Types.Byte_Array;
Bit_Len : in Natural)
is
begin
XOR_Bits_Into_State
(A => State (A),
Data => Data,
Bit_Len => Bit_Len);
end XOR_Bits_Into_State;
---------------------------
-- XOR_Byte_Into_State --
---------------------------
procedure XOR_Byte_Into_State (A : in out State;
Offset : in Natural;
Value : in Keccak.Types.Byte)
is
Lane_Size_Bytes : constant Positive := Lane_Size_Bits / 8;
X : constant X_Coord := X_Coord ((Offset / Lane_Size_Bytes) mod 5);
Y : constant Y_Coord := Y_Coord (Offset / (Lane_Size_Bytes * 5));
begin
A (X, Y) := A (X, Y) xor Shift_Left (Lane_Type (Value), Offset mod (Lane_Size_Bits / 8));
end XOR_Byte_Into_State;
---------------------------
-- XOR_Byte_Into_State --
---------------------------
procedure XOR_Byte_Into_State (A : in out Lane_Complemented_State;
Offset : in Natural;
Value : in Keccak.Types.Byte)
is
begin
XOR_Byte_Into_State (State (A), Offset, Value);
end XOR_Byte_Into_State;
---------------------
-- Extract_Bytes --
---------------------
procedure Extract_Bytes (A : in State;
Data : out Keccak.Types.Byte_Array)
is
X : X_Coord := 0;
Y : Y_Coord := 0;
Remaining_Bytes : Natural := Data'Length;
Offset : Natural := 0;
Lane : Lane_Type;
begin
-- Case when each lane is at least 1 byte (i.e. 8, 16, 32, or 64 bits)
-- Process whole lanes
Outer_Loop :
for Y2 in Y_Coord loop
pragma Loop_Invariant (Offset mod (Lane_Size_Bits / 8) = 0
and Offset + Remaining_Bytes = Data'Length);
for X2 in X_Coord loop
pragma Loop_Variant (Increases => Offset,
Decreases => Remaining_Bytes);
pragma Loop_Invariant (Offset mod (Lane_Size_Bits / 8) = 0
and Offset + Remaining_Bytes = Data'Length);
if Remaining_Bytes < Lane_Size_Bits / 8 then
X := X2;
Y := Y2;
exit Outer_Loop;
end if;
Lane := A (X2, Y2);
for I in Natural range 0 .. (Lane_Size_Bits / 8) - 1 loop
Data (Data'First + Offset + I)
:= Keccak.Types.Byte (Shift_Right (Lane, I * 8) and 16#FF#);
end loop;
Remaining_Bytes := Remaining_Bytes - Lane_Size_Bits / 8;
Offset := Offset + Lane_Size_Bits / 8;
end loop;
end loop Outer_Loop;
-- Process any remaining data (smaller than 1 lane)
if Remaining_Bytes > 0 then
Lane := A (X, Y);
declare
Initial_Offset : constant Natural := Offset with Ghost;
Shift : Natural := 0;
begin
while Remaining_Bytes > 0 loop
pragma Loop_Variant (Increases => Offset,
Increases => Shift,
Decreases => Remaining_Bytes);
pragma Loop_Invariant (Offset + Remaining_Bytes = Data'Length
and Shift mod 8 = 0
and Shift = (Offset - Initial_Offset) * 8);
Data (Data'First + Offset)
:= Keccak.Types.Byte (Shift_Right (Lane, Shift) and 16#FF#);
Shift := Shift + 8;
Offset := Offset + 1;
Remaining_Bytes := Remaining_Bytes - 1;
end loop;
end;
end if;
end Extract_Bytes;
---------------------
-- Extract_Bytes --
---------------------
procedure Extract_Bytes (A : in Lane_Complemented_State;
Data : out Keccak.Types.Byte_Array)
is
Complement_Mask : constant Lane_Complemented_State :=
(0 => (4 => Lane_Type'Last,
others => 0),
1 => (0 => Lane_Type'Last,
others => 0),
2 => (0 | 2 | 3 => Lane_Type'Last,
others => 0),
3 => (1 => Lane_Type'Last,
others => 0),
4 => (others => 0));
-- Some lanes need to be complemented (bitwise NOT) when reading them
-- from the Keccak-f state. We do this by storing a mask of all 1's
-- for those lanes that need to be complemented (and all 0's for the
-- other lanes). We then XOR against the corresponding entry in this
-- Complement_Mask to complement only the required lanes (as XOR'ing
-- against all 1's has the same effect as bitwise NOT).
X : X_Coord := 0;
Y : Y_Coord := 0;
Remaining_Bytes : Natural := Data'Length;
Offset : Natural := 0;
Lane : Lane_Type;
begin
-- Case when each lane is at least 1 byte (i.e. 8, 16, 32, or 64 bits)
-- Process whole lanes
Outer_Loop :
for Y2 in Y_Coord loop
pragma Loop_Invariant (Offset mod (Lane_Size_Bits / 8) = 0
and Offset + Remaining_Bytes = Data'Length);
for X2 in X_Coord loop
pragma Loop_Variant (Increases => Offset,
Decreases => Remaining_Bytes);
pragma Loop_Invariant (Offset mod (Lane_Size_Bits / 8) = 0
and Offset + Remaining_Bytes = Data'Length);
if Remaining_Bytes < Lane_Size_Bits / 8 then
X := X2;
Y := Y2;
exit Outer_Loop;
end if;
Lane := A (X2, Y2) xor Complement_Mask (X2, Y2);
for I in Natural range 0 .. (Lane_Size_Bits / 8) - 1 loop
Data (Data'First + Offset + I)
:= Keccak.Types.Byte (Shift_Right (Lane, I * 8) and 16#FF#);
pragma Annotate (GNATprove, False_Positive,
"""Data"" might not be initialized",
"Data is initialized at end of procedure");
end loop;
Remaining_Bytes := Remaining_Bytes - Lane_Size_Bits / 8;
Offset := Offset + Lane_Size_Bits / 8;
end loop;
end loop Outer_Loop;
-- Process any remaining data (smaller than 1 lane)
if Remaining_Bytes > 0 then
Lane := A (X, Y) xor Complement_Mask (X, Y);
declare
Initial_Offset : constant Natural := Offset with Ghost;
Shift : Natural := 0;
begin
while Remaining_Bytes > 0 loop
pragma Loop_Variant (Increases => Offset,
Increases => Shift,
Decreases => Remaining_Bytes);
pragma Loop_Invariant (Offset + Remaining_Bytes = Data'Length
and Shift mod 8 = 0
and Shift = (Offset - Initial_Offset) * 8);
Data (Data'First + Offset)
:= Keccak.Types.Byte (Shift_Right (Lane, Shift) and 16#FF#);
pragma Annotate (GNATprove, False_Positive,
"""Data"" might not be initialized",
"Data is initialized at end of procedure");
Shift := Shift + 8;
Offset := Offset + 1;
Remaining_Bytes := Remaining_Bytes - 1;
end loop;
end;
end if;
end Extract_Bytes;
--------------------
-- Extract_Bits --
--------------------
procedure Extract_Bits (A : in State;
Data : out Keccak.Types.Byte_Array;
Bit_Len : in Natural)
is
use type Keccak.Types.Byte;
begin
Extract_Bytes (A, Data);
-- Avoid exposing more bits than requested by masking away higher bits
-- in the last byte.
if Bit_Len > 0 and Bit_Len mod 8 /= 0 then
Data (Data'Last) := Data (Data'Last) and (2**(Bit_Len mod 8) - 1);
end if;
end Extract_Bits;
--------------------
-- Extract_Bits --
--------------------
procedure Extract_Bits (A : in Lane_Complemented_State;
Data : out Keccak.Types.Byte_Array;
Bit_Len : in Natural)
is
use type Keccak.Types.Byte;
begin
Extract_Bytes (A, Data);
-- Avoid exposing more bits than requested by masking away higher bits
-- in the last byte.
if Bit_Len > 0 and Bit_Len mod 8 /= 0 then
Data (Data'Last) := Data (Data'Last) and (2**(Bit_Len mod 8) - 1);
end if;
end Extract_Bits;
end Keccak.Generic_KeccakF.Byte_Lanes;
|
eqcola/ada-ado | Ada | 1,297 | ads | -----------------------------------------------------------------------
-- ado-statements-tests -- Test statements package
-- Copyright (C) 2015, 2017 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Tests;
package ADO.Statements.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
-- Test creation of several rows in test_table with different column type.
procedure Test_Save (T : in out Test);
-- Test queries using the $entity_type[] cache group.
procedure Test_Entity_Types (T : in out Test);
end ADO.Statements.Tests;
|
afrl-rq/OpenUxAS | Ada | 2,617 | adb | package body Int64_Parsing with SPARK_Mode is
function Char_To_Int (C : Character) return Int64 is
(case C is
when '0' => 0,
when '1' => 1,
when '2' => 2,
when '3' => 3,
when '4' => 4,
when '5' => 5,
when '6' => 6,
when '7' => 7,
when '8' => 8,
when '9' => 9,
when others => raise Program_Error)
with Pre => C in '0' .. '9';
subtype Digit is Int64 range 0 .. 9;
function Int_To_Char (V : Digit) return Character is
(case V is
when 0 => '0',
when 1 => '1',
when 2 => '2',
when 3 => '3',
when 4 => '4',
when 5 => '5',
when 6 => '6',
when 7 => '7',
when 8 => '8',
when 9 => '9');
procedure Parse_Int64 (S : String; V : out Int64; Error : out Boolean) is
Is_Pos : constant Boolean := S'Length = 0 or else S (S'First) /= '-';
FirstZ : constant Integer := (if Is_Pos then S'First else S'First + 1);
First : Integer;
begin
V := 0;
Error := True;
if FirstZ > S'Last then
return;
end if;
First :=
(if FirstZ > S'Last or else S'Last - FirstZ <= 18
then FirstZ else S'Last - 18);
for I in FirstZ .. First - 1 loop
if S (I) /= '0' then
return;
end if;
pragma Loop_Invariant (for all K in FirstZ .. I => S (K) = '0');
end loop;
for I in 1 .. 19 loop
if S (I - 1 + First) not in '0' .. '9' then
return;
end if;
if I = 19 and then
(abs (V) > Int64'Last / 10
or else (abs (V) = Int64'Last / 10 and then S (I - 1 + First) > (if Is_Pos then '7' else '8')))
then
return;
end if;
V := V * 10 + (if Is_Pos then 1 else -1) * Char_To_Int (S (I - 1 + First));
if I - 1 + First = S'Last then
Error := False;
return;
end if;
end loop;
end Parse_Int64;
function Print_Int64 (V : Int64) return String is
res : String (1 .. 20) := (others => '0');
X : Int64 := V;
top : Natural := 20;
begin
if V = 0 then
return "0";
end if;
for I in 1 .. 19 loop
res (top) := Int_To_Char (abs (X rem 10));
top := top - 1;
X := X / 10;
exit when X = 0;
end loop;
if V < 0 then
res (top) := '-';
top := top - 1;
end if;
return (res (top + 1 .. 20));
end Print_Int64;
end Int64_Parsing;
|
mgrojo/bingada | Ada | 519 | adb | with Ada.Numerics.Discrete_Random;
package body Q_Gen_Shuffle is
procedure P_Shuffle (List : in out Array_Type) is
package Discrete_Random is new Ada.Numerics.Discrete_Random
(Result_Subtype => Positive);
use Discrete_Random;
K : Positive;
G : Generator;
T : Element_Type;
begin
Reset (G);
for I in reverse List'Range loop
K := (Random(G) mod I) + 1;
T := List(I);
List(I) := List(K);
List(K) := T;
end loop;
end P_Shuffle;
end Q_Gen_Shuffle;
|
shintakezou/drake | Ada | 35,552 | adb | with Ada.Exceptions.Finally;
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
with Ada.Streams; -- [gcc-4.7] can not search in private with
with System;
package body Ada.Containers.Indefinite_Ordered_Sets is
use type Binary_Trees.Node_Access;
use type Copy_On_Write.Data_Access;
function Upcast is
new Unchecked_Conversion (Cursor, Binary_Trees.Node_Access);
function Downcast is
new Unchecked_Conversion (Binary_Trees.Node_Access, Cursor);
function Upcast is
new Unchecked_Conversion (Data_Access, Copy_On_Write.Data_Access);
function Downcast is
new Unchecked_Conversion (Copy_On_Write.Data_Access, Data_Access);
procedure Free is new Unchecked_Deallocation (Element_Type, Element_Access);
procedure Free is new Unchecked_Deallocation (Node, Cursor);
function Compare_Elements (Left, Right : Element_Type) return Integer;
function Compare_Elements (Left, Right : Element_Type) return Integer is
begin
if Left < Right then
return -1;
elsif Right < Left then
return 1;
else
return 0;
end if;
end Compare_Elements;
type Context_Type is limited record
Left : not null access Element_Type;
end record;
pragma Suppress_Initialization (Context_Type);
function Compare_Element (
Position : not null Binary_Trees.Node_Access;
Params : System.Address)
return Integer;
function Compare_Element (
Position : not null Binary_Trees.Node_Access;
Params : System.Address)
return Integer
is
Context : Context_Type;
for Context'Address use Params;
begin
return Compare_Elements (
Context.Left.all,
Downcast (Position).Element.all);
end Compare_Element;
function Compare_Node (Left, Right : not null Binary_Trees.Node_Access)
return Integer;
function Compare_Node (Left, Right : not null Binary_Trees.Node_Access)
return Integer is
begin
return Compare_Elements (
Downcast (Left).Element.all,
Downcast (Right).Element.all);
end Compare_Node;
procedure Allocate_Element (
Item : out Element_Access;
New_Item : Element_Type);
procedure Allocate_Element (
Item : out Element_Access;
New_Item : Element_Type) is
begin
Item := new Element_Type'(New_Item);
end Allocate_Element;
procedure Allocate_Node (Item : out Cursor; New_Item : Element_Type);
procedure Allocate_Node (Item : out Cursor; New_Item : Element_Type) is
package Holder is
new Exceptions.Finally.Scoped_Holder (Cursor, Free);
X : aliased Cursor := new Node;
begin
Holder.Assign (X);
Allocate_Element (X.Element, New_Item);
Holder.Clear;
Item := X;
end Allocate_Node;
procedure Copy_Node (
Target : out Binary_Trees.Node_Access;
Source : not null Binary_Trees.Node_Access);
procedure Copy_Node (
Target : out Binary_Trees.Node_Access;
Source : not null Binary_Trees.Node_Access)
is
New_Node : Cursor;
begin
Allocate_Node (New_Node, Downcast (Source).Element.all);
Target := Upcast (New_Node);
end Copy_Node;
procedure Free_Node (Object : in out Binary_Trees.Node_Access);
procedure Free_Node (Object : in out Binary_Trees.Node_Access) is
X : Cursor := Downcast (Object);
begin
Free (X.Element);
Free (X);
Object := null;
end Free_Node;
procedure Allocate_Data (
Target : out not null Copy_On_Write.Data_Access;
New_Length : Count_Type;
Capacity : Count_Type);
procedure Allocate_Data (
Target : out not null Copy_On_Write.Data_Access;
New_Length : Count_Type;
Capacity : Count_Type)
is
pragma Unreferenced (New_Length);
pragma Unreferenced (Capacity);
New_Data : constant Data_Access :=
new Data'(Super => <>, Root => null, Length => 0);
begin
Target := Upcast (New_Data);
end Allocate_Data;
procedure Copy_Data (
Target : out not null Copy_On_Write.Data_Access;
Source : not null Copy_On_Write.Data_Access;
Length : Count_Type;
New_Length : Count_Type;
Capacity : Count_Type);
procedure Copy_Data (
Target : out not null Copy_On_Write.Data_Access;
Source : not null Copy_On_Write.Data_Access;
Length : Count_Type;
New_Length : Count_Type;
Capacity : Count_Type)
is
pragma Unreferenced (Length);
pragma Unreferenced (New_Length);
pragma Unreferenced (Capacity);
begin
Allocate_Data (Target, 0, 0);
Base.Copy (
Downcast (Target).Root,
Downcast (Target).Length,
Source => Downcast (Source).Root,
Copy => Copy_Node'Access);
end Copy_Data;
procedure Free is new Unchecked_Deallocation (Data, Data_Access);
procedure Free_Data (Data : in out Copy_On_Write.Data_Access);
procedure Free_Data (Data : in out Copy_On_Write.Data_Access) is
X : Data_Access := Downcast (Data);
begin
Binary_Trees.Free (X.Root, X.Length, Free => Free_Node'Access);
Free (X);
Data := null;
end Free_Data;
procedure Unique (Container : in out Set; To_Update : Boolean);
procedure Unique (Container : in out Set; To_Update : Boolean) is
begin
if Copy_On_Write.Shared (Container.Super.Data) then
Copy_On_Write.Unique (
Target => Container.Super'Access,
To_Update => To_Update,
Allocate => Allocate_Data'Access,
Move => Copy_Data'Access,
Copy => Copy_Data'Access,
Free => Free_Data'Access);
end if;
end Unique;
function Equivalent_Sets (
Left, Right : Set;
Equivalent : not null access function (
Left, Right : not null Binary_Trees.Node_Access)
return Boolean)
return Boolean;
function Equivalent_Sets (
Left, Right : Set;
Equivalent : not null access function (
Left, Right : not null Binary_Trees.Node_Access)
return Boolean)
return Boolean
is
Left_Length : constant Count_Type := Length (Left);
Right_Length : constant Count_Type := Length (Right);
begin
if Left_Length /= Right_Length then
return False;
elsif Left_Length = 0 or else Left.Super.Data = Right.Super.Data then
return True;
else
Unique (Left'Unrestricted_Access.all, False); -- private
Unique (Right'Unrestricted_Access.all, False); -- private
return Binary_Trees.Equivalent (
Downcast (Left.Super.Data).Root,
Downcast (Right.Super.Data).Root,
Equivalent => Equivalent);
end if;
end Equivalent_Sets;
-- implementation
function Equivalent_Elements (Left, Right : Element_Type) return Boolean is
begin
return Compare_Elements (Left, Right) = 0;
end Equivalent_Elements;
function Empty_Set return Set is
begin
return (Finalization.Controlled with Super => (null, null));
end Empty_Set;
function Has_Element (Position : Cursor) return Boolean is
begin
return Position /= No_Element;
end Has_Element;
overriding function "=" (Left, Right : Set) return Boolean is
function Equivalent (Left, Right : not null Binary_Trees.Node_Access)
return Boolean;
function Equivalent (Left, Right : not null Binary_Trees.Node_Access)
return Boolean is
begin
return Downcast (Left).Element.all = Downcast (Right).Element.all;
end Equivalent;
begin
return Equivalent_Sets (Left, Right, Equivalent => Equivalent'Access);
end "=";
function Equivalent_Sets (Left, Right : Set) return Boolean is
function Equivalent (Left, Right : not null Binary_Trees.Node_Access)
return Boolean;
function Equivalent (Left, Right : not null Binary_Trees.Node_Access)
return Boolean is
begin
return Equivalent_Elements (
Downcast (Left).Element.all,
Downcast (Right).Element.all);
end Equivalent;
begin
return Equivalent_Sets (Left, Right, Equivalent => Equivalent'Access);
end Equivalent_Sets;
function To_Set (New_Item : Element_Type) return Set is
begin
return Result : Set do
Insert (Result, New_Item);
end return;
end To_Set;
-- diff (Generic_Array_To_Set)
--
--
--
--
--
--
--
function Length (Container : Set) return Count_Type is
Data : constant Data_Access := Downcast (Container.Super.Data);
begin
if Data = null then
return 0;
else
return Data.Length;
end if;
end Length;
function Is_Empty (Container : Set) return Boolean is
Data : constant Data_Access := Downcast (Container.Super.Data);
begin
return Data = null or else Data.Root = null;
end Is_Empty;
procedure Clear (Container : in out Set) is
begin
Copy_On_Write.Clear (Container.Super'Access, Free => Free_Data'Access);
end Clear;
function Element (Position : Cursor) return Element_Type is
begin
return Position.Element.all;
end Element;
procedure Replace_Element (
Container : in out Set;
Position : Cursor;
New_Item : Element_Type) is
begin
Unique (Container, True);
Free (Position.Element);
Allocate_Element (Position.Element, New_Item);
end Replace_Element;
procedure Query_Element (
Position : Cursor;
Process : not null access procedure (Element : Element_Type)) is
begin
Process (Position.Element.all);
end Query_Element;
function Constant_Reference (Container : aliased Set; Position : Cursor)
return Constant_Reference_Type
is
pragma Unreferenced (Container);
begin
return (Element => Position.Element.all'Access);
end Constant_Reference;
procedure Assign (Target : in out Set; Source : Set) is
begin
Copy_On_Write.Assign (
Target.Super'Access,
Source.Super'Access,
Free => Free_Data'Access);
end Assign;
function Copy (Source : Set) return Set is
begin
return Result : Set do
Copy_On_Write.Copy (
Result.Super'Access,
Source.Super'Access,
Allocate => Allocate_Data'Access,
Copy => Copy_Data'Access);
end return;
end Copy;
procedure Move (Target : in out Set; Source : in out Set) is
begin
Copy_On_Write.Move (
Target.Super'Access,
Source.Super'Access,
Free => Free_Data'Access);
-- diff
-- diff
-- diff
end Move;
procedure Insert (
Container : in out Set;
New_Item : Element_Type;
Position : out Cursor;
Inserted : out Boolean)
is
-- diff
-- diff
-- diff
Before : constant Cursor := Ceiling (Container, New_Item);
begin
-- diff
Inserted := Before = null or else New_Item < Before.Element.all;
if Inserted then
Unique (Container, True);
Allocate_Node (Position, New_Item);
declare
Data : constant Data_Access := Downcast (Container.Super.Data);
begin
Base.Insert (
Data.Root,
Data.Length,
Upcast (Before),
Upcast (Position));
end;
else
Position := Before;
end if;
end Insert;
procedure Insert (
Container : in out Set;
New_Item : Element_Type)
is
Position : Cursor;
Inserted : Boolean;
begin
Insert (Container, New_Item, Position, Inserted);
if not Inserted then
raise Constraint_Error;
end if;
end Insert;
procedure Include (Container : in out Set; New_Item : Element_Type) is
Position : Cursor;
Inserted : Boolean;
begin
Insert (Container, New_Item, Position, Inserted);
if not Inserted then
Replace_Element (Container, Position, New_Item);
end if;
end Include;
procedure Replace (Container : in out Set; New_Item : Element_Type) is
begin
Replace_Element (Container, Find (Container, New_Item), New_Item);
end Replace;
procedure Exclude (Container : in out Set; Item : Element_Type) is
Position : Cursor := Find (Container, Item);
begin
if Position /= null then
Delete (Container, Position);
end if;
end Exclude;
procedure Delete (Container : in out Set; Item : Element_Type) is
Position : Cursor := Find (Container, Item);
begin
Delete (Container, Position);
end Delete;
procedure Delete (Container : in out Set; Position : in out Cursor) is
Position_2 : Binary_Trees.Node_Access := Upcast (Position);
begin
Unique (Container, True);
declare
Data : constant Data_Access := Downcast (Container.Super.Data);
begin
Base.Remove (Data.Root, Data.Length, Position_2);
end;
Free_Node (Position_2);
Position := null;
end Delete;
procedure Delete_First (Container : in out Set'Class) is
Position : Cursor := First (Set (Container));
begin
Delete (Set (Container), Position);
end Delete_First;
procedure Delete_Last (Container : in out Set'Class) is
Position : Cursor := Last (Set (Container));
begin
Delete (Set (Container), Position);
end Delete_Last;
procedure Union (Target : in out Set; Source : Set) is
begin
if Is_Empty (Source) or else Target.Super.Data = Source.Super.Data then
null;
elsif Is_Empty (Target) then
Assign (Target, Source);
else
Unique (Target, True);
Unique (Source'Unrestricted_Access.all, False); -- private
declare
Target_Data : constant Data_Access := Downcast (Target.Super.Data);
begin
Base.Merge (
Target_Data.Root,
Target_Data.Length,
Downcast (Source.Super.Data).Root,
(others => True),
Compare => Compare_Node'Access,
Copy => Copy_Node'Access,
Free => Free_Node'Access);
end;
end if;
end Union;
function Union (Left, Right : Set) return Set is
begin
return Result : Set do
if Is_Empty (Right) or else Left.Super.Data = Right.Super.Data then
Assign (Result, Left);
elsif Is_Empty (Left) then
Assign (Result, Right);
else
Unique (Result, True);
Unique (Left'Unrestricted_Access.all, False); -- private
Unique (Right'Unrestricted_Access.all, False); -- private
declare
Result_Data : constant Data_Access :=
Downcast (Result.Super.Data);
begin
Base.Copying_Merge (
Result_Data.Root,
Result_Data.Length,
Downcast (Left.Super.Data).Root,
Downcast (Right.Super.Data).Root,
(others => True),
Compare => Compare_Node'Access,
Copy => Copy_Node'Access);
end;
end if;
end return;
end Union;
procedure Intersection (Target : in out Set; Source : Set) is
begin
if Is_Empty (Target) or else Is_Empty (Source) then
Clear (Target);
elsif Target.Super.Data = Source.Super.Data then
null;
else
Unique (Target, True);
Unique (Source'Unrestricted_Access.all, False); -- private
declare
Target_Data : constant Data_Access := Downcast (Target.Super.Data);
begin
Base.Merge (
Target_Data.Root,
Target_Data.Length,
Downcast (Source.Super.Data).Root,
(Binary_Trees.In_Both => True, others => False),
Compare => Compare_Node'Access,
Copy => Copy_Node'Access,
Free => Free_Node'Access);
end;
end if;
end Intersection;
function Intersection (Left, Right : Set) return Set is
begin
return Result : Set do
if Is_Empty (Left) or else Is_Empty (Right) then
null; -- Empty_Set
elsif Left.Super.Data = Right.Super.Data then
Assign (Result, Left);
else
Unique (Result, True);
Unique (Left'Unrestricted_Access.all, False); -- private
Unique (Right'Unrestricted_Access.all, False); -- private
declare
Result_Data : constant Data_Access :=
Downcast (Result.Super.Data);
begin
Base.Copying_Merge (
Result_Data.Root,
Result_Data.Length,
Downcast (Left.Super.Data).Root,
Downcast (Right.Super.Data).Root,
(Binary_Trees.In_Both => True, others => False),
Compare => Compare_Node'Access,
Copy => Copy_Node'Access);
end;
end if;
end return;
end Intersection;
procedure Difference (Target : in out Set; Source : Set) is
begin
if Is_Empty (Target) or else Target.Super.Data = Source.Super.Data then
Clear (Target);
elsif Is_Empty (Source) then
null;
else
Unique (Target, True);
Unique (Source'Unrestricted_Access.all, False); -- private
declare
Target_Data : constant Data_Access := Downcast (Target.Super.Data);
begin
Base.Merge (
Target_Data.Root,
Target_Data.Length,
Downcast (Source.Super.Data).Root,
(Binary_Trees.In_Only_Left => True, others => False),
Compare => Compare_Node'Access,
Copy => Copy_Node'Access,
Free => Free_Node'Access);
end;
end if;
end Difference;
function Difference (Left, Right : Set) return Set is
begin
return Result : Set do
if Is_Empty (Left) or else Left.Super.Data = Right.Super.Data then
null; -- Empty_Set
elsif Is_Empty (Right) then
Assign (Result, Left);
else
Unique (Result, True);
Unique (Left'Unrestricted_Access.all, False); -- private
Unique (Right'Unrestricted_Access.all, False); -- private
declare
Result_Data : constant Data_Access :=
Downcast (Result.Super.Data);
begin
Base.Copying_Merge (
Result_Data.Root,
Result_Data.Length,
Downcast (Left.Super.Data).Root,
Downcast (Right.Super.Data).Root,
(Binary_Trees.In_Only_Left => True, others => False),
Compare => Compare_Node'Access,
Copy => Copy_Node'Access);
end;
end if;
end return;
end Difference;
procedure Symmetric_Difference (Target : in out Set; Source : Set) is
begin
if Target.Super.Data = Source.Super.Data then
Clear (Target);
elsif Is_Empty (Source) then
null;
elsif Is_Empty (Target) then
Assign (Target, Source);
else
Unique (Target, True);
Unique (Source'Unrestricted_Access.all, False); -- private
declare
Target_Data : constant Data_Access := Downcast (Target.Super.Data);
begin
Base.Merge (
Target_Data.Root,
Target_Data.Length,
Downcast (Source.Super.Data).Root,
(Binary_Trees.In_Both => False, others => True),
Compare => Compare_Node'Access,
Copy => Copy_Node'Access,
Free => Free_Node'Access);
end;
end if;
end Symmetric_Difference;
function Symmetric_Difference (Left, Right : Set) return Set is
begin
return Result : Set do
if Left.Super.Data = Right.Super.Data then
null; -- Empty_Set
elsif Is_Empty (Right) then
Assign (Result, Left);
elsif Is_Empty (Left) then
Assign (Result, Right);
else
Unique (Result, True);
Unique (Left'Unrestricted_Access.all, False); -- private
Unique (Right'Unrestricted_Access.all, False); -- private
declare
Result_Data : constant Data_Access :=
Downcast (Result.Super.Data);
begin
Base.Copying_Merge (
Result_Data.Root,
Result_Data.Length,
Downcast (Left.Super.Data).Root,
Downcast (Right.Super.Data).Root,
(Binary_Trees.In_Both => False, others => True),
Compare => Compare_Node'Access,
Copy => Copy_Node'Access);
end;
end if;
end return;
end Symmetric_Difference;
function Overlap (Left, Right : Set) return Boolean is
begin
if Is_Empty (Left) or else Is_Empty (Right) then
return False;
elsif Left.Super.Data = Right.Super.Data then
return True;
else
Unique (Left'Unrestricted_Access.all, False); -- private
Unique (Right'Unrestricted_Access.all, False); -- private
return Binary_Trees.Overlap (
Downcast (Left.Super.Data).Root,
Downcast (Right.Super.Data).Root,
Compare => Compare_Node'Access);
end if;
end Overlap;
function Is_Subset (Subset : Set; Of_Set : Set) return Boolean is
begin
if Is_Empty (Subset) or else Subset.Super.Data = Of_Set.Super.Data then
return True;
elsif Is_Empty (Of_Set) then
return False;
else
Unique (Subset'Unrestricted_Access.all, False); -- private
Unique (Of_Set'Unrestricted_Access.all, False); -- private
return Binary_Trees.Is_Subset (
Downcast (Subset.Super.Data).Root,
Downcast (Of_Set.Super.Data).Root,
Compare => Compare_Node'Access);
end if;
end Is_Subset;
function First (Container : Set) return Cursor is
begin
if Is_Empty (Container) then
return null;
else
Unique (Container'Unrestricted_Access.all, False);
return Downcast (Binary_Trees.First (
Downcast (Container.Super.Data).Root));
end if;
end First;
function First_Element (Container : Set'Class)
return Element_Type is
begin
return Element (First (Set (Container)));
end First_Element;
function Last (Container : Set) return Cursor is
begin
if Is_Empty (Container) then
return null;
else
Unique (Container'Unrestricted_Access.all, False);
return Downcast (Binary_Trees.Last (
Downcast (Container.Super.Data).Root));
end if;
end Last;
function Last_Element (Container : Set'Class)
return Element_Type is
begin
return Element (Last (Set (Container)));
end Last_Element;
function Next (Position : Cursor) return Cursor is
begin
return Downcast (Binary_Trees.Next (Upcast (Position)));
end Next;
procedure Next (Position : in out Cursor) is
begin
Position := Downcast (Binary_Trees.Next (Upcast (Position)));
end Next;
function Previous (Position : Cursor) return Cursor is
begin
return Downcast (Binary_Trees.Previous (Upcast (Position)));
end Previous;
procedure Previous (Position : in out Cursor) is
begin
Position := Downcast (Binary_Trees.Previous (Upcast (Position)));
end Previous;
function Find (Container : Set; Item : Element_Type) return Cursor is
begin
if Is_Empty (Container) then
return null;
else
Unique (Container'Unrestricted_Access.all, False);
declare
Context : Context_Type := (Left => Item'Unrestricted_Access);
begin
return Downcast (Binary_Trees.Find (
Downcast (Container.Super.Data).Root,
Binary_Trees.Just,
Context'Address,
Compare => Compare_Element'Access));
end;
end if;
end Find;
function Floor (Container : Set; Item : Element_Type) return Cursor is
begin
if Is_Empty (Container) then
return null;
else
Unique (Container'Unrestricted_Access.all, False);
declare
Context : Context_Type := (Left => Item'Unrestricted_Access);
begin
return Downcast (Binary_Trees.Find (
Downcast (Container.Super.Data).Root,
Binary_Trees.Floor,
Context'Address,
Compare => Compare_Element'Access));
end;
end if;
end Floor;
function Ceiling (Container : Set; Item : Element_Type) return Cursor is
begin
if Is_Empty (Container) then
return null;
else
Unique (Container'Unrestricted_Access.all, False);
declare
Context : Context_Type := (Left => Item'Unrestricted_Access);
begin
return Downcast (Binary_Trees.Find (
Downcast (Container.Super.Data).Root,
Binary_Trees.Ceiling,
Context'Address,
Compare => Compare_Element'Access));
end;
end if;
end Ceiling;
function Contains (Container : Set; Item : Element_Type) return Boolean is
begin
return Find (Container, Item) /= null;
end Contains;
function "<" (Left, Right : Cursor) return Boolean is
begin
return Left /= Right and then Left.Element.all < Right.Element.all;
end "<";
function ">" (Left, Right : Cursor) return Boolean is
begin
return Right < Left;
end ">";
function "<" (Left : Cursor; Right : Element_Type) return Boolean is
begin
return Left.Element.all < Right;
end "<";
function ">" (Left : Cursor; Right : Element_Type) return Boolean is
begin
return Right < Left;
end ">";
function "<" (Left : Element_Type; Right : Cursor) return Boolean is
begin
return Left < Right.Element.all;
end "<";
function ">" (Left : Element_Type; Right : Cursor) return Boolean is
begin
return Right < Left;
end ">";
procedure Iterate (
Container : Set'Class;
Process : not null access procedure (Position : Cursor))
is
type P1 is access procedure (Position : Cursor);
type P2 is access procedure (Position : Binary_Trees.Node_Access);
function Cast is new Unchecked_Conversion (P1, P2);
begin
if not Is_Empty (Set (Container)) then
Unique (Set (Container)'Unrestricted_Access.all, False);
Binary_Trees.Iterate (
Downcast (Container.Super.Data).Root,
Cast (Process));
end if;
end Iterate;
procedure Reverse_Iterate (
Container : Set'Class;
Process : not null access procedure (Position : Cursor))
is
type P1 is access procedure (Position : Cursor);
type P2 is access procedure (Position : Binary_Trees.Node_Access);
function Cast is new Unchecked_Conversion (P1, P2);
begin
if not Is_Empty (Set (Container)) then
Unique (Set (Container)'Unrestricted_Access.all, False);
Binary_Trees.Reverse_Iterate (
Downcast (Container.Super.Data).Root,
Cast (Process));
end if;
end Reverse_Iterate;
function Iterate (Container : Set'Class)
return Set_Iterator_Interfaces.Reversible_Iterator'Class is
begin
return Set_Iterator'(
First => First (Set (Container)),
Last => Last (Set (Container)));
end Iterate;
function Iterate (Container : Set'Class; First, Last : Cursor)
return Set_Iterator_Interfaces.Reversible_Iterator'Class
is
pragma Unreferenced (Container);
Actual_First : Cursor := First;
Actual_Last : Cursor := Last;
begin
if Actual_First = No_Element
or else Actual_Last = No_Element
or else Actual_Last < Actual_First
then
Actual_First := No_Element;
Actual_Last := No_Element;
end if;
return Set_Iterator'(First => Actual_First, Last => Actual_Last);
end Iterate;
overriding procedure Adjust (Object : in out Set) is
begin
Copy_On_Write.Adjust (Object.Super'Access);
end Adjust;
overriding function First (Object : Set_Iterator) return Cursor is
begin
return Object.First;
end First;
overriding function Next (Object : Set_Iterator; Position : Cursor)
return Cursor is
begin
if Position = Object.Last then
return No_Element;
else
return Next (Position);
end if;
end Next;
overriding function Last (Object : Set_Iterator) return Cursor is
begin
return Object.Last;
end Last;
overriding function Previous (Object : Set_Iterator; Position : Cursor)
return Cursor is
begin
if Position = Object.First then
return No_Element;
else
return Previous (Position);
end if;
end Previous;
package body Generic_Keys is
type Context_Type is limited record
Left : not null access Key_Type;
end record;
pragma Suppress_Initialization (Context_Type);
function Compare_Key (
Position : not null Binary_Trees.Node_Access;
Params : System.Address)
return Integer;
function Compare_Key (
Position : not null Binary_Trees.Node_Access;
Params : System.Address)
return Integer
is
Context : Context_Type;
for Context'Address use Params;
Left : Key_Type
renames Context.Left.all;
Right : Key_Type
renames Key (Downcast (Position).Element.all);
begin
if Left < Right then
return -1;
elsif Right < Left then
return 1;
else
return 0;
end if;
end Compare_Key;
function Equivalent_Keys (Left, Right : Key_Type) return Boolean is
begin
return not (Left < Right) and then not (Right < Left);
end Equivalent_Keys;
function Key (Position : Cursor) return Key_Type is
begin
return Key (Position.Element.all);
end Key;
function Element (Container : Set; Key : Key_Type) return Element_Type is
begin
return Element (Find (Container, Key));
end Element;
procedure Replace (
Container : in out Set;
Key : Key_Type;
New_Item : Element_Type) is
begin
Replace_Element (Container, Find (Container, Key), New_Item);
end Replace;
procedure Exclude (Container : in out Set; Key : Key_Type) is
Position : Cursor := Find (Container, Key);
begin
if Position /= null then
Delete (Container, Position);
end if;
end Exclude;
procedure Delete (Container : in out Set; Key : Key_Type) is
Position : Cursor := Find (Container, Key);
begin
Delete (Container, Position);
end Delete;
function Find (Container : Set; Key : Key_Type) return Cursor is
begin
if Is_Empty (Container) then
return null;
else
Unique (Container'Unrestricted_Access.all, False);
declare
Context : Context_Type := (Left => Key'Unrestricted_Access);
begin
return Downcast (Binary_Trees.Find (
Downcast (Container.Super.Data).Root,
Binary_Trees.Just,
Context'Address,
Compare => Compare_Key'Access));
end;
end if;
end Find;
function Floor (Container : Set; Key : Key_Type) return Cursor is
begin
if Is_Empty (Container) then
return null;
else
Unique (Container'Unrestricted_Access.all, False);
declare
Context : Context_Type := (Left => Key'Unrestricted_Access);
begin
return Downcast (Binary_Trees.Find (
Downcast (Container.Super.Data).Root,
Binary_Trees.Floor,
Context'Address,
Compare => Compare_Key'Access));
end;
end if;
end Floor;
function Ceiling (Container : Set; Key : Key_Type) return Cursor is
begin
if Is_Empty (Container) then
return null;
else
Unique (Container'Unrestricted_Access.all, False);
declare
Context : Context_Type := (Left => Key'Unrestricted_Access);
begin
return Downcast (Binary_Trees.Find (
Downcast (Container.Super.Data).Root,
Binary_Trees.Ceiling,
Context'Address,
Compare => Compare_Key'Access));
end;
end if;
end Ceiling;
function Contains (Container : Set; Key : Key_Type) return Boolean is
begin
return Find (Container, Key) /= null;
end Contains;
procedure Update_Element_Preserving_Key (
Container : in out Set;
Position : Cursor;
Process : not null access procedure (
Element : in out Element_Type)) is
begin
Process (Reference_Preserving_Key (Container, Position).Element.all);
end Update_Element_Preserving_Key;
function Reference_Preserving_Key (
Container : aliased in out Set;
Position : Cursor)
return Reference_Type is
begin
Unique (Container, True);
-- diff
return (Element => Position.Element.all'Access);
end Reference_Preserving_Key;
function Constant_Reference (Container : aliased Set; Key : Key_Type)
return Constant_Reference_Type is
begin
return Constant_Reference (Container, Find (Container, Key));
end Constant_Reference;
function Reference_Preserving_Key (
Container : aliased in out Set;
Key : Key_Type)
return Reference_Type is
begin
return Reference_Preserving_Key (Container, Find (Container, Key));
end Reference_Preserving_Key;
end Generic_Keys;
package body Streaming is
procedure Read (
Stream : not null access Streams.Root_Stream_Type'Class;
Item : out Set)
is
Length : Count_Type'Base;
begin
Count_Type'Base'Read (Stream, Length);
Clear (Item);
for I in 1 .. Length loop
declare
New_Item : constant Element_Type := Element_Type'Input (Stream);
begin
-- diff
Include (Item, New_Item);
end;
end loop;
end Read;
procedure Write (
Stream : not null access Streams.Root_Stream_Type'Class;
Item : Set)
is
Length : constant Count_Type := Indefinite_Ordered_Sets.Length (Item);
begin
Count_Type'Write (Stream, Length);
if Length > 0 then
declare
Position : Cursor := First (Item);
begin
while Position /= null loop
Element_Type'Output (Stream, Position.Element.all);
Next (Position);
end loop;
end;
end if;
end Write;
end Streaming;
end Ada.Containers.Indefinite_Ordered_Sets;
|
twdroeger/ada-awa | Ada | 9,628 | adb | -----------------------------------------------------------------------
-- awa-events-queues-persistents -- AWA Event Queues
-- Copyright (C) 2012, 2013, 2014, 2017, 2020 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Calendar;
with Util.Log.Loggers;
with Util.Serialize.Tools;
with AWA.Services.Contexts;
with AWA.Applications;
with AWA.Events.Services;
with AWA.Users.Models;
with ADO;
with ADO.Sessions;
with ADO.SQL;
package body AWA.Events.Queues.Persistents is
package ASC renames AWA.Services.Contexts;
use Util.Log;
Log : constant Loggers.Logger := Loggers.Create ("AWA.Events.Queues.Persistents");
-- ------------------------------
-- Get the queue name.
-- ------------------------------
overriding
function Get_Name (From : in Persistent_Queue) return String is
begin
return From.Name;
end Get_Name;
-- ------------------------------
-- Get the model queue reference object.
-- Returns a null object if the queue is not persistent.
-- ------------------------------
overriding
function Get_Queue (From : in Persistent_Queue) return Models.Queue_Ref is
begin
return From.Queue;
end Get_Queue;
-- ------------------------------
-- Queue the event. The event is saved in the database with a relation to
-- the user, the user session, the event queue and the event type.
-- ------------------------------
overriding
procedure Enqueue (Into : in out Persistent_Queue;
Event : in AWA.Events.Module_Event'Class) is
procedure Set_Event (Manager : in out AWA.Events.Services.Event_Manager);
Ctx : constant ASC.Service_Context_Access := ASC.Current;
App : constant AWA.Applications.Application_Access := Ctx.Get_Application;
DB : ADO.Sessions.Master_Session := ASC.Get_Master_Session (Ctx);
Msg : AWA.Events.Models.Message_Ref;
procedure Set_Event (Manager : in out AWA.Events.Services.Event_Manager) is
begin
Manager.Set_Message_Type (Msg, Event.Get_Event_Kind);
end Set_Event;
begin
App.Do_Event_Manager (Set_Event'Access);
Ctx.Start;
Msg.Set_Queue (Into.Queue);
Msg.Set_User (Ctx.Get_User);
Msg.Set_Session (Ctx.Get_User_Session);
Msg.Set_Create_Date (Event.Get_Time);
Msg.Set_Status (AWA.Events.Models.QUEUED);
Msg.Set_Entity_Id (Event.Get_Entity_Identifier);
Msg.Set_Entity_Type (Event.Entity_Type);
-- Collect the event parameters in a string and format the result in JSON.
Msg.Set_Parameters (Util.Serialize.Tools.To_JSON (Event.Props));
Msg.Save (DB);
Ctx.Commit;
Log.Info ("Event {0} created", ADO.Identifier'Image (Msg.Get_Id));
end Enqueue;
overriding
procedure Dequeue (From : in out Persistent_Queue;
Process : access procedure (Event : in Module_Event'Class)) is
-- Prepare the message by indicating in the database it is going
-- to be processed by the given server and task.
procedure Prepare_Message (Msg : in out Models.Message_Ref);
-- Dispatch the event.
procedure Dispatch_Message (Msg : in out Models.Message_Ref);
-- Finish processing the message by marking it as being processed.
procedure Finish_Message (Msg : in out Models.Message_Ref);
Ctx : constant ASC.Service_Context_Access := ASC.Current;
DB : ADO.Sessions.Master_Session := ASC.Get_Master_Session (Ctx);
Messages : Models.Message_Vector;
Query : ADO.SQL.Query;
Task_Id : constant Integer := 0;
procedure Prepare_Message (Msg : in out Models.Message_Ref) is
begin
Msg.Set_Status (Models.PROCESSING);
Msg.Set_Server_Id (From.Server_Id);
Msg.Set_Task_Id (Task_Id);
Msg.Set_Processing_Date
(ADO.Nullable_Time '(Is_Null => False,
Value => Ada.Calendar.Clock));
Msg.Save (DB);
end Prepare_Message;
procedure Dispatch_Message (Msg : in out Models.Message_Ref) is
User : constant AWA.Users.Models.User_Ref'Class := Msg.Get_User;
Session : constant AWA.Users.Models.Session_Ref'Class := Msg.Get_Session;
Name : constant String := Msg.Get_Message_Type.Get_Name;
Event : Module_Event;
procedure Action;
procedure Action is
begin
Process (Event);
end Action;
procedure Run is new AWA.Services.Contexts.Run_As (Action);
begin
Event.Set_Event_Kind (AWA.Events.Find_Event_Index (Name));
Util.Serialize.Tools.From_JSON (Msg.Get_Parameters, Event.Props);
Event.Set_Entity_Identifier (Msg.Get_Entity_Id);
Event.Entity_Type := Msg.Get_Entity_Type;
if not User.Is_Null then
Log.Info ("Dispatching event {0} for user{1} session{2}", Name,
ADO.Identifier'Image (User.Get_Id),
ADO.Identifier'Image (Session.Get_Id));
else
Log.Info ("Dispatching event {0}", Name);
end if;
-- Run the Process action on behalf of the user associated
-- with the message.
Run (AWA.Users.Models.User_Ref (User),
AWA.Users.Models.Session_Ref (Session));
exception
when E : others =>
Log.Error ("Exception when processing event " & Name, E, True);
end Dispatch_Message;
-- ------------------------------
-- Finish processing the message by marking it as being processed.
-- ------------------------------
procedure Finish_Message (Msg : in out Models.Message_Ref) is
begin
Msg.Set_Status (Models.PROCESSED);
Msg.Set_Finish_Date (ADO.Nullable_Time '(Is_Null => False,
Value => Ada.Calendar.Clock));
Msg.Save (DB);
end Finish_Message;
Count : Natural;
begin
Ctx.Start;
Query.Set_Filter ("o.status = 0 AND o.queue_id = :queue "
& "ORDER BY o.priority DESC, "
& "o.id ASC LIMIT :max");
Query.Bind_Param ("queue", From.Queue.Get_Id);
Query.Bind_Param ("max", From.Max_Batch);
Models.List (Messages, DB, Query);
Count := Natural (Messages.Length);
-- Prepare the event messages by marking them in the database.
-- This makes sure that no other server or task (if any), will process them.
if Count > 0 then
for I in 0 .. Count - 1 loop
Messages.Update_Element (Index => I,
Process => Prepare_Message'Access);
end loop;
end if;
Ctx.Commit;
if Count = 0 then
return;
end if;
Log.Info ("Dispatching {0} events", Natural'Image (Count));
-- Dispatch each event.
for I in 0 .. Count - 1 loop
Messages.Update_Element (Index => I,
Process => Dispatch_Message'Access);
end loop;
-- After having dispatched the events, mark them as dispatched in the queue.
Ctx.Start;
for I in 0 .. Count - 1 loop
Messages.Update_Element (Index => I,
Process => Finish_Message'Access);
end loop;
Ctx.Commit;
end Dequeue;
-- ------------------------------
-- Create the queue associated with the given name and configure it by using
-- the configuration properties.
-- ------------------------------
function Create_Queue (Name : in String;
Props : in EL.Beans.Param_Vectors.Vector;
Context : in EL.Contexts.ELContext'Class) return Queue_Access is
pragma Unreferenced (Props, Context);
Ctx : constant ASC.Service_Context_Access := ASC.Current;
Session : ADO.Sessions.Master_Session := ASC.Get_Master_Session (Ctx);
Queue : AWA.Events.Models.Queue_Ref;
Query : ADO.SQL.Query;
Found : Boolean;
begin
Session.Begin_Transaction;
-- Find the queue instance which matches the name.
Query.Set_Filter ("o.name = ?");
Query.Add_Param (Name);
Queue.Find (Session => Session,
Query => Query,
Found => Found);
-- But create the queue instance if it does not exist.
if not Found then
Log.Info ("Creating database queue {0}", Name);
Queue.Set_Name (Name);
Queue.Save (Session);
else
Log.Info ("Using database queue {0}", Name);
end if;
Session.Commit;
return new Persistent_Queue '(Name_Length => Name'Length,
Name => Name,
Queue => Queue,
others => <>);
end Create_Queue;
end AWA.Events.Queues.Persistents;
|
AdaCore/libadalang | Ada | 1,559 | adb | procedure Test is
type T1 is (E1, E2);
type T2 (D : T1 := E2) is record
case D is
when E1 =>
C1 : Integer;
C2 : Boolean;
when E2 =>
null;
end case;
end record;
type T3 is record
C1 : Integer;
C2 : Boolean := True;
end record;
type T4 (D : T1 := E1) is record
case D is
when E1 =>
C1 : Integer;
C2 : Boolean;
when E2 =>
null;
end case;
end record;
type T5 (D1, D2 : T1 := E1; D3 : T1 := E2) is record
case D2 is
when E1 =>
C1 : Integer;
C2 : Boolean;
when E2 =>
null;
end case;
end record;
O : constant T2 (D => E2) := (others => <>);
pragma Test_Statement;
P : constant T2 (D => E1) := (E1, others => <>);
pragma Test_Statement;
Q : constant T2 (D => E2) := (D => E2);
pragma Test_Statement;
F : constant T2 (D => E1) := (D => E1, C1 => 1, C2 => True);
pragma Test_Statement;
G : constant T3 := (C1 => 1, others => <>);
pragma Test_Statement;
H : constant T3 := (C1 => 1, C2 => True);
pragma Test_Statement;
OO : constant T4 (D => E1) := (E1, C1 => 1, C2 => True);
pragma Test_Statement;
PP : constant T4 (D => E2) := (E2, others => <>);
pragma Test_Statement;
QQ : constant T4 (D => E1) := (E1, 1, others => <>);
pragma Test_Statement;
Z : constant T5 (D1|D2 => E1, D3 => E2) := (D3 => E2, others => <>);
pragma Test_Statement;
begin
null;
end Test;
|
stcarrez/ada-util | Ada | 1,719 | ads | -----------------------------------------------------------------------
-- Util-texts-formats -- Text Format ala Java MessageFormat
-- Copyright (C) 2001, 2002, 2003, 2009, 2010, 2011, 2012, 2013 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
generic
type Stream is limited private;
type Char is (<>);
type Input is array (Positive range <>) of Char;
type Value is limited private;
type Value_List is array (Positive range <>) of Value;
with procedure Put (Buffer : in out Stream; C : in Character);
with function To_Input (Arg : in Value) return Input;
package Util.Texts.Formats is
pragma Preelaborate;
-- Format the message and replace occurrences of argument patterns by
-- their associated value.
-- Returns the formatted message in the stream
procedure Format (Message : in Input;
Arguments : in Value_List;
Into : in out Stream);
private
procedure Format (Argument : in Value;
Into : in out Stream);
end Util.Texts.Formats;
|
ohenley/ada-util | Ada | 6,442 | ads | -----------------------------------------------------------------------
-- util-commands-drivers -- Support to make command line tools
-- 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 Util.Log;
private with Ada.Strings.Unbounded;
private with Ada.Containers.Indefinite_Ordered_Maps;
-- == Command line driver ==
-- The <tt>Util.Commands.Drivers</tt> generic package provides a support to build command line
-- tools that have different commands identified by a name.
generic
-- The command execution context.
type Context_Type (<>) is limited private;
Driver_Name : String := "Drivers";
package Util.Commands.Drivers is
-- A simple command handler executed when the command with the given name is executed.
type Command_Handler is not null access procedure (Name : in String;
Args : in Argument_List'Class;
Context : in out Context_Type);
-- A more complex command handler that has a command instance as context.
type Command_Type is abstract tagged limited private;
type Command_Access is access all Command_Type'Class;
-- Execute the command with the arguments. The command name is passed with the command
-- arguments.
procedure Execute (Command : in Command_Type;
Name : in String;
Args : in Argument_List'Class;
Context : in out Context_Type) is abstract;
-- Write the help associated with the command.
procedure Help (Command : in Command_Type;
Context : in out Context_Type) is abstract;
-- Write the command usage.
procedure Usage (Command : in Command_Type);
-- Print a message for the command. The level indicates whether the message is an error,
-- warning or informational. The command name can be used to known the originator.
-- The <tt>Log</tt> operation is redirected to the driver's <tt>Log</tt> procedure.
procedure Log (Command : in Command_Type;
Level : in Util.Log.Level_Type;
Name : in String;
Message : in String);
type Help_Command_Type is new Command_Type with private;
-- Execute the help command with the arguments.
-- Print the help for every registered command.
overriding
procedure Execute (Command : in Help_Command_Type;
Name : in String;
Args : in Argument_List'Class;
Context : in out Context_Type);
-- Write the help associated with the command.
procedure Help (Command : in Help_Command_Type;
Context : in out Context_Type);
type Driver_Type is tagged limited private;
-- Report the command usage.
procedure Usage (Driver : in Driver_Type;
Args : in Argument_List'Class);
-- Set the driver description printed in the usage.
procedure Set_Description (Driver : in out Driver_Type;
Description : in String);
-- Set the driver usage printed in the usage.
procedure Set_Usage (Driver : in out Driver_Type;
Usage : in String);
-- Register the command under the given name.
procedure Add_Command (Driver : in out Driver_Type;
Name : in String;
Command : in Command_Access);
-- Register the command under the given name.
procedure Add_Command (Driver : in out Driver_Type;
Name : in String;
Handler : in Command_Handler);
-- Find the command having the given name.
-- Returns null if the command was not found.
function Find_Command (Driver : in Driver_Type;
Name : in String) return Command_Access;
-- Execute the command registered under the given name.
procedure Execute (Driver : in Driver_Type;
Name : in String;
Args : in Argument_List'Class;
Context : in out Context_Type);
-- Print a message for the command. The level indicates whether the message is an error,
-- warning or informational. The command name can be used to known the originator.
procedure Log (Driver : in Driver_Type;
Level : in Util.Log.Level_Type;
Name : in String;
Message : in String);
private
package Command_Maps is
new Ada.Containers.Indefinite_Ordered_Maps (Key_Type => String,
Element_Type => Command_Access,
"<" => "<");
type Command_Type is abstract tagged limited record
Driver : access Driver_Type'Class;
end record;
type Help_Command_Type is new Command_Type with null record;
type Handler_Command_Type is new Command_Type with record
Handler : Command_Handler;
end record;
-- Execute the command with the arguments.
overriding
procedure Execute (Command : in Handler_Command_Type;
Name : in String;
Args : in Argument_List'Class;
Context : in out Context_Type);
-- Write the help associated with the command.
overriding
procedure Help (Command : in Handler_Command_Type;
Context : in out Context_Type);
type Driver_Type is tagged limited record
List : Command_Maps.Map;
Desc : Ada.Strings.Unbounded.Unbounded_String;
Usage : Ada.Strings.Unbounded.Unbounded_String;
end record;
end Util.Commands.Drivers;
|
vasil-sd/ada-tlsf | Ada | 8,586 | ads | with System;
with Interfaces;
with TLSF.Config;
package TLSF.Block.Types with SPARK_Mode, Pure, Preelaborate is
use TLSF.Config;
use Interfaces;
type Size is new Natural range 0 .. 2 ** Max_Block_Size_Log2-1
with Size => Max_Block_Size_Log2;
type Size_Bits is mod 2**Size'Size;
type Address is new Size;
type Address_Bits is mod 2**Address'Size;
Address_Null : constant Address := 0;
subtype Valid_Address is Address
with Predicate => (Valid_Address /= Address_Null);
function To_Size_Bits (S : Size) return Size_Bits
with
Global => null,
Pure_Function,
Post => Size(To_Size_Bits'Result) = S;
function To_Address_Bits (A : Address) return Address_Bits
with
Global => null,
Pure_Function,
Post => Address(To_Address_Bits'Result) = A;
Align_Mask : constant := (2 ** Align_Size_Log2) - 1;
Quantum : constant := Align_Mask + 1;
function Is_Aligned (Val : Size) return Boolean
with
Global => null,
Pure_Function,
Contract_Cases =>
( (Size_Bits(Val) and Align_Mask) = 0 => Is_Aligned'Result = True,
others => Is_Aligned'Result = False);
function Is_Aligned (Val : Address) return Boolean
with
Global => null,
Pure_Function,
Contract_Cases =>
( (Address_Bits(Val) and Align_Mask) = 0 => Is_Aligned'Result = True,
others => Is_Aligned'Result = False);
subtype Aligned_Size is Size with
Predicate => Is_Aligned(Aligned_Size);
subtype Aligned_Address is Address with
Predicate => Is_Aligned(Aligned_Address);
function Round_Size_Up (S : Size) return Aligned_Size
with
Global => null,
Pure_Function,
Pre => S <= Size'Last - Align_Mask,
Post => Is_Aligned(Round_Size_Up'Result);
function Round_Address_Up (A : Address) return Aligned_Address
with
Global => null,
Pure_Function,
Pre => A <= Address'Last - Align_Mask,
Post => Is_Aligned(Round_Address_Up'Result);
function "+" (A: Aligned_Address; S: Aligned_Size) return Aligned_Address
with
Global => null,
Pure_Function,
Pre => Integer(A) + Integer(S) in 0 .. Integer(Address'Last),
Post =>
Is_Aligned("+"'Result)
and "+"'Result = Aligned_Address(Integer(A) + Integer(S));
function "+" (L, R : Aligned_Size) return Aligned_Size
with
Global => null,
Pure_Function,
Pre => Integer(L) + Integer(R) in 0 .. Integer(Address'Last),
Post =>
Is_Aligned ("+"'Result)
and "+"'Result = Aligned_Size (Integer (L) + Integer (R));
-- To is not inclusive, ie [From, To)
function "-" (To, From : Aligned_Address) return Aligned_Size
with
Global => null,
Pure_Function,
Pre => To >= From,
Post => Is_Aligned ("-"'Result)
and "-"'Result = Aligned_Size (Integer (To) - Integer (From));
-- address space for blocks
type Address_Space is record
First : Aligned_Address := Quantum;
Last : Aligned_Address := Address'Last - (Quantum - 1);
end record
with Predicate =>
First >= Quantum and then
Last <= Address'Last - (Quantum - 1) and then
Last > First;
type Status is (Free, Occupied)
with Size => 1;
-- Free: block is free
-- Occupied: block in use
-- Absent: block is absent (previous of the first
-- block or next of the last)
type Free_Blocks_List is
record
Prev_Address : Aligned_Address := Address_Null;
Next_Address : Aligned_Address := Address_Null;
end record
with Pack,
Predicate => ((Prev_Address = 0 and then Next_Address = 0) or else
(Prev_Address /=0 and then Next_Address /= 0));
type Block_Header (Status : Types.Status := Free) is
record
Prev_Block_Address : Aligned_Address := Address_Null;
Size : Aligned_Size := 0;
case Status is
when Free => Free_List : Free_Blocks_List;
when Occupied => null;
end case;
end record
with Pack;
subtype Block_Header_Occupied is Block_Header(Status => Occupied);
subtype Block_Header_Free is Block_Header(Status => Free);
pragma Assert ((Size_Bits'(Small_Block_Size) and Align_Mask) = 0);
Block_Header_Size : constant Size := Small_Block_Size;
-- Size(Block_Header'Max_Size_In_Storage_Elements);
Block_Header_Occupied_Size : constant Size := Small_Block_Size;
-- Size(Block_Header_Occupied'Max_Size_In_Storage_Elements);
Block_Header_Free_Size : constant Size := Small_Block_Size;
-- Size(Block_Header_Free'Max_Size_In_Storage_Elements);
Empty_Free_List : constant Free_Blocks_List :=
Free_Blocks_List'(Address_Null, Address_Null);
pragma Assert (Small_Block_Size >= Block_Header_Size);
-- should be >= Block_Header max size in storage elements
pragma Assert (Block_Header_Free_Size >= Block_Header_Occupied_Size);
-- Predicates
function Is_Free_List_Empty (Free_List : Free_Blocks_List)
return Boolean
is (Free_List = Empty_Free_List);
function Is_Block_Free (Block : Block_Header) return Boolean
is (Block.Status = Free);
function Is_Block_Occupied (Block : Block_Header) return Boolean
is (Block.Status = Occupied);
function Is_Block_Linked_To_Free_List (Block : Block_Header_Free) return Boolean
is (Block.Free_List.Prev_Address /= Address_Null and then
Block.Free_List.Next_Address /= Address_Null)
with Pre => Is_Block_Free (Block),
Post => (if not Is_Free_List_Empty (Block.Free_List)
then Is_Block_Linked_To_Free_List'Result = True
else Is_Block_Linked_To_Free_List'Result = False);
-- Contract_Cases => (not Is_Free_List_Empty(Block.Free_List)
-- => Is_Block_Linked_To_Free_List'Result = True,
-- others
-- => Is_Block_Linked_To_Free_List'Result = False);
function Is_Block_Last_In_Free_List (Block: Block_Header) return Boolean
is (Block.Free_List /= Empty_Free_List and then
Block.Free_List.Prev_Address = Block.Free_List.Next_Address)
with Pre => Is_Block_Free(Block),
Post => (if Block.Free_List /= Empty_Free_List and then
Block.Free_List.Prev_Address = Block.Free_List.Next_Address
then Is_Block_Last_In_Free_List'Result = True
else Is_Block_Last_In_Free_List'Result = False);
-- Contract_Cases =>
-- (Block.Free_List /= Empty_Free_List and then
-- Block.Free_List.Prev_Address = Block.Free_List.Next_Address
-- => Is_Block_Last_In_Free_List'Result = True,
-- others => Is_Block_Last_In_Free_List'Result = False);
--
function Changed_Only_Links_For_Free_List (Block_Old, Block_New : Block_Header)
return Boolean
is
(Is_Block_Free(Block_Old) and then
Is_Block_Free(Block_New) and then
Block_New.Prev_Block_Address = Block_Old.Prev_Block_Address and then
Block_New.Size = Block_Old.Size);
-- Calculation of levels
type First_Level_Index is new Natural range SL_Index_Count_Log2 .. FL_Index_Max;
type Second_Level_Index is new Natural range 0 .. SL_Index_Count - 1;
pragma Assert (Second_Level_Index'Last =
(2 ** Natural(First_Level_Index'First)) - 1);
type Level_Index is
record
First_Level : First_Level_Index;
Second_Level : Second_Level_Index;
end record;
function Calculate_Levels_Indices
(S : Size_Bits)
return Level_Index
with
Pure_Function,
Pre => S >= Size_Bits(Small_Block_Size);
function Is_Same_Size_Class(S1, S2: Size) return Boolean
with
Pre =>
S1 >= Small_Block_Size and then
S2 >= Small_Block_Size,
Contract_Cases =>
(Calculate_Levels_Indices(Size_Bits(S1)) =
Calculate_Levels_Indices(Size_Bits(S2)) =>
Is_Same_Size_Class'Result = True,
others =>
Is_Same_Size_Class'Result = False);
end TLSF.Block.Types;
|
Fabien-Chouteau/shoot-n-loot | Ada | 4,665 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . A R I T H _ 6 4 --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2012, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This unit provides software routines for doing arithmetic on 64-bit
-- signed integer values in cases where either overflow checking is
-- required, or intermediate results are longer than 64 bits.
pragma Restrictions (No_Elaboration_Code);
-- Allow direct call from gigi generated code
with Interfaces;
package Arith_64 is
pragma Pure;
subtype Int64 is Interfaces.Integer_64;
function Add_With_Ovflo_Check (X, Y : Int64) return Int64;
-- Raises Constraint_Error if sum of operands overflows 64 bits,
-- otherwise returns the 64-bit signed integer sum.
function Subtract_With_Ovflo_Check (X, Y : Int64) return Int64;
-- Raises Constraint_Error if difference of operands overflows 64
-- bits, otherwise returns the 64-bit signed integer difference.
function Multiply_With_Ovflo_Check (X, Y : Int64) return Int64;
pragma Export (C, Multiply_With_Ovflo_Check, "__gnat_mulv64");
-- Raises Constraint_Error if product of operands overflows 64
-- bits, otherwise returns the 64-bit signed integer product.
-- GIGI may also call this routine directly.
procedure Scaled_Divide
(X, Y, Z : Int64;
Q, R : out Int64;
Round : Boolean);
-- Performs the division of (X * Y) / Z, storing the quotient in Q
-- and the remainder in R. Constraint_Error is raised if Z is zero,
-- or if the quotient does not fit in 64-bits. Round indicates if
-- the result should be rounded. If Round is False, then Q, R are
-- the normal quotient and remainder from a truncating division.
-- If Round is True, then Q is the rounded quotient. The remainder
-- R is not affected by the setting of the Round flag.
procedure Double_Divide
(X, Y, Z : Int64;
Q, R : out Int64;
Round : Boolean);
-- Performs the division X / (Y * Z), storing the quotient in Q and
-- the remainder in R. Constraint_Error is raised if Y or Z is zero,
-- or if the quotient does not fit in 64-bits. Round indicates if the
-- result should be rounded. If Round is False, then Q, R are the normal
-- quotient and remainder from a truncating division. If Round is True,
-- then Q is the rounded quotient. The remainder R is not affected by the
-- setting of the Round flag.
end Arith_64;
|
Lucretia/Cherry | Ada | 872 | ads | --
-- The author disclaims copyright to this source code. In place of
-- a legal notice, here is a blessing:
--
-- May you do good and not evil.
-- May you find forgiveness for yourself and forgive others.
-- May you share freely, not taking more than you give.
--
with Backend;
with Lime;
package Generate_C is
use Backend;
procedure Open_Template
-- (Cherry : in Cherry_Interface;
(Context : in out Context_Type;
User_Template : in String;
File_Name : in String;
Error_Count : in out Integer);
procedure Generate_Spec
(Lemp : in Lime.Lemon_Record;
Context : in out Context_Type;
File_Name : in String;
Module : in String;
Prefix : in String;
First : in Integer;
Last : in Integer);
end Generate_C;
|
Gabriel-Degret/adalib | Ada | 1,969 | ads | -- Standard Ada library specification
-- Copyright (c) 2004-2016 AXE Consultants
-- Copyright (c) 2004, 2005, 2006 Ada-Europe
-- Copyright (c) 2000 The MITRE Corporation, Inc.
-- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc.
-- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual
---------------------------------------------------------------------------
package Ada.Wide_Wide_Characters.Handling is
pragma Pure(Handling);
function Character_Set_Version return String;
function Is_Control (Item : Wide_Wide_Character) return Boolean;
function Is_Letter (Item : Wide_Wide_Character) return Boolean;
function Is_Lower (Item : Wide_Wide_Character) return Boolean;
function Is_Upper (Item : Wide_Wide_Character) return Boolean;
function Is_Digit (Item : Wide_Wide_Character) return Boolean;
function Is_Decimal_Digit (Item : Wide_Wide_Character) return Boolean
renames Is_Digit;
function Is_Hexadecimal_Digit (Item : Wide_Wide_Character) return Boolean;
function Is_Alphanumeric (Item : Wide_Wide_Character) return Boolean;
function Is_Special (Item : Wide_Wide_Character) return Boolean;
function Is_Line_Terminator (Item : Wide_Wide_Character) return Boolean;
function Is_Mark (Item : Wide_Wide_Character) return Boolean;
function Is_Other_Format (Item : Wide_Wide_Character) return Boolean;
function Is_Punctuation_Connector (Item : Wide_Wide_Character) return Boolean;
function Is_Space (Item : Wide_Wide_Character) return Boolean;
function Is_Graphic (Item : Wide_Wide_Character) return Boolean;
function To_Lower (Item : Wide_Wide_Character) return Wide_Wide_Character;
function To_Upper (Item : Wide_Wide_Character) return Wide_Wide_Character;
function To_Lower (Item : Wide_Wide_String) return Wide_Wide_String;
function To_Upper (Item : Wide_Wide_String) return Wide_Wide_String;
end Ada.Wide_Wide_Characters.Handling;
|
persan/A-gst | Ada | 3,736 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
pragma Warnings (Off);
with Interfaces.C; use Interfaces.C;
with glib;
with glib.Values;
with System;
with System;
with GStreamer.GST_Low_Level.gstreamer_0_10_gst_fft_gstfft_h;
package GStreamer.GST_Low_Level.gstreamer_0_10_gst_fft_gstfftf32_h is
-- GStreamer
-- * Copyright (C) <2007> Sebastian Dröge <[email protected]>
-- *
-- * This library is free software; you can redistribute it and/or
-- * modify it under the terms of the GNU Library General Public
-- * License as published by the Free Software Foundation; either
-- * version 2 of the License, or (at your option) any later version.
-- *
-- * This library is distributed in the hope that it will be useful,
-- * but WITHOUT ANY WARRANTY; without even the implied warranty of
-- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- * Library General Public License for more details.
-- *
-- * You should have received a copy of the GNU Library General Public
-- * License along with this library; if not, write to the
-- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-- * Boston, MA 02111-1307, USA.
--
type GstFFTF32;
type u_GstFFTF32_u_padding_array is array (0 .. 3) of System.Address;
--subtype GstFFTF32 is u_GstFFTF32; -- gst/fft/gstfftf32.h:30
type GstFFTF32Complex;
--subtype GstFFTF32Complex is u_GstFFTF32Complex; -- gst/fft/gstfftf32.h:31
-- FIXME 0.11: Move the struct definition to the sources,
-- * there's no reason to have it public.
--
--*
-- * GstFFTF32:
-- *
-- * Instance structure for #GstFFTF32.
-- *
--
-- <private>
type GstFFTF32 is record
cfg : System.Address; -- gst/fft/gstfftf32.h:44
inverse : aliased GLIB.gboolean; -- gst/fft/gstfftf32.h:45
len : aliased GLIB.gint; -- gst/fft/gstfftf32.h:46
u_padding : u_GstFFTF32_u_padding_array; -- gst/fft/gstfftf32.h:47
end record;
pragma Convention (C_Pass_By_Copy, GstFFTF32); -- gst/fft/gstfftf32.h:42
-- Copy of kiss_fft_f32_cpx for documentation reasons,
-- * do NOT change!
--*
-- * GstFFTF32Complex:
-- * @r: Real part
-- * @i: Imaginary part
-- *
-- * Data type for complex numbers composed of
-- * 32 bit float.
-- *
--
type GstFFTF32Complex is record
r : aliased GLIB.gfloat; -- gst/fft/gstfftf32.h:64
i : aliased GLIB.gfloat; -- gst/fft/gstfftf32.h:65
end record;
pragma Convention (C_Pass_By_Copy, GstFFTF32Complex); -- gst/fft/gstfftf32.h:62
-- Functions
function gst_fft_f32_new (len : GLIB.gint; inverse : GLIB.gboolean) return access GstFFTF32; -- gst/fft/gstfftf32.h:70
pragma Import (C, gst_fft_f32_new, "gst_fft_f32_new");
procedure gst_fft_f32_fft
(self : access GstFFTF32;
timedata : access GLIB.gfloat;
freqdata : access GstFFTF32Complex); -- gst/fft/gstfftf32.h:71
pragma Import (C, gst_fft_f32_fft, "gst_fft_f32_fft");
procedure gst_fft_f32_inverse_fft
(self : access GstFFTF32;
freqdata : access constant GstFFTF32Complex;
timedata : access GLIB.gfloat); -- gst/fft/gstfftf32.h:72
pragma Import (C, gst_fft_f32_inverse_fft, "gst_fft_f32_inverse_fft");
procedure gst_fft_f32_free (self : access GstFFTF32); -- gst/fft/gstfftf32.h:73
pragma Import (C, gst_fft_f32_free, "gst_fft_f32_free");
procedure gst_fft_f32_window
(self : access GstFFTF32;
timedata : access GLIB.gfloat;
window : GStreamer.GST_Low_Level.gstreamer_0_10_gst_fft_gstfft_h.GstFFTWindow); -- gst/fft/gstfftf32.h:75
pragma Import (C, gst_fft_f32_window, "gst_fft_f32_window");
end GStreamer.GST_Low_Level.gstreamer_0_10_gst_fft_gstfftf32_h;
|
mokafiht/u2f_key_SDCC | Ada | 23,971 | adb | M:bsp
S:Lbsp.aligned_alloc$size$1$101({2}SI:U),B,1,-4
S:Lbsp.aligned_alloc$alignment$1$101({2}SI:U),B,1,1
F:G$u2f_delay$0$0({2}DF,SV:S),Z,0,8,0,0,0
S:Lbsp.u2f_delay$ms$1$131({4}SL:U),B,1,1
S:Lbsp.u2f_delay$ms_now$1$132({4}SL:U),B,1,5
F:G$usb_write$0$0({2}DF,SV:S),Z,0,0,0,0,0
S:Lbsp.usb_write$len$1$134({1}SC:U),B,1,-3
S:Lbsp.usb_write$buf$1$134({3}DG,SC:U),R,0,0,[r5,r6,r7]
S:Lbsp.usb_write$errors$1$135({1}SC:U),R,0,0,[r4]
F:G$putf$0$0({2}DF,SV:S),Z,0,0,0,0,0
S:Lbsp.putf$c$1$138({1}SC:U),R,0,0,[]
S:Lbsp.putf$i$1$139({1}SC:U),R,0,0,[r7]
F:G$dump_hex$0$0({2}DF,SV:S),Z,0,3,0,0,0
S:Lbsp.dump_hex$len$1$143({1}SC:U),B,1,-3
S:Lbsp.dump_hex$hex$1$143({3}DG,SC:U),B,1,1
S:Lbsp.dump_hex$i$1$144({1}SC:U),R,0,0,[r4]
F:G$u2f_prints$0$0({2}DF,SV:S),Z,0,0,0,0,0
S:Lbsp.u2f_prints$d$1$147({3}DG,SC:U),R,0,0,[]
F:Fbsp$int2str_reduce_n$0$0({2}DF,SV:S),C,0,0,0,0,0
S:Lbsp.int2str_reduce_n$copy$1$150({4}SL:U),B,1,-6
S:Lbsp.int2str_reduce_n$n$1$150({1}SC:U),B,1,-7
S:Lbsp.int2str_reduce_n$snum$1$150({3}DG,DG,SC:U),R,0,0,[]
F:Fbsp$int2str_map_n$0$0({2}DF,SV:S),C,0,0,0,0,0
S:Lbsp.int2str_map_n$i$1$153({4}SL:U),B,1,-6
S:Lbsp.int2str_map_n$n$1$153({1}SC:U),B,1,-7
S:Lbsp.int2str_map_n$snum$1$153({3}DG,DG,SC:U),R,0,0,[r5,r6,r7]
S:Lbsp.int2str_map_n$sloc0$1$0({3}DG,SC:U),B,1,1
S:Lbsp.int2str_map_n$sloc1$1$0({4}SL:U),B,1,4
S:Lbsp.int2str_map_n$sloc2$1$0({4}SL:U),B,1,8
F:G$__int2strn$0$0({2}DF,DG,SC:U),Z,0,7,0,0,0
S:Lbsp.__int2strn$n$1$156({1}SC:U),B,1,-3
S:Lbsp.__int2strn$i$1$156({4}SL:S),B,1,1
S:Lbsp.__int2strn$snum$1$157({3}DG,SC:U),B,1,5
F:G$u2f_putd$0$0({2}DF,SV:S),Z,0,0,0,0,0
S:Lbsp.u2f_putd$i$1$158({4}SL:S),R,0,0,[r4,r5,r6,r7]
F:G$u2f_putx$0$0({2}DF,SV:S),Z,0,0,0,0,0
S:Lbsp.u2f_putx$i$1$160({4}SL:S),R,0,0,[r4,r5,r6,r7]
F:Fbsp$put_space$0$0({2}DF,SV:S),C,0,0,0,0,0
F:Fbsp$put_line$0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$u2f_printd$0$0({2}DF,SV:S),Z,0,0,0,0,0
S:Lbsp.u2f_printd$tag$1$164({3}DG,SC:U),B,1,-5
S:Lbsp.u2f_printd$c$1$164({1}SC:U),B,1,-6
S:Lbsp.u2f_printd$args$1$165({1}DD,SC:U),R,0,0,[r7]
F:G$u2f_printl$0$0({2}DF,SV:S),C,0,0,0,0,0
S:Lbsp.u2f_printl$tag$1$169({3}DG,SC:U),B,1,-5
S:Lbsp.u2f_printl$c$1$169({1}SC:U),B,1,-6
S:Lbsp.u2f_printl$args$1$170({1}DD,SC:U),R,0,0,[r7]
F:G$u2f_printx$0$0({2}DF,SV:S),Z,0,0,0,0,0
S:Lbsp.u2f_printx$tag$1$174({3}DG,SC:U),B,1,-5
S:Lbsp.u2f_printx$c$1$174({1}SC:U),B,1,-6
S:Lbsp.u2f_printx$args$1$175({1}DD,SC:U),R,0,0,[r7]
F:G$u2f_printb$0$0({2}DF,SV:S),Z,0,0,0,0,0
S:Lbsp.u2f_printb$tag$1$179({3}DG,SC:U),B,1,-5
S:Lbsp.u2f_printb$c$1$179({1}SC:U),B,1,-6
S:Lbsp.u2f_printb$args$1$180({1}DD,SC:U),R,0,0,[r7]
F:G$u2f_printlx$0$0({2}DF,SV:S),Z,0,0,0,0,0
S:Lbsp.u2f_printlx$tag$1$184({3}DG,SC:U),B,1,-5
S:Lbsp.u2f_printlx$c$1$184({1}SC:U),B,1,-6
S:Lbsp.u2f_printlx$args$1$185({1}DD,SC:U),R,0,0,[r7]
T:Fbsp$SI_UU32[({0}S:S$u32$0$0({4}SL:U),Z,0,0)({0}S:S$s32$0$0({4}SL:S),Z,0,0)({0}S:S$uu16$0$0({4}DA2d,STSI_UU16:S),Z,0,0)({0}S:S$u16$0$0({4}DA2d,SI:U),Z,0,0)({0}S:S$s16$0$0({4}DA2d,SI:S),Z,0,0)({0}S:S$u8$0$0({4}DA4d,SC:U),Z,0,0)({0}S:S$s8$0$0({4}DA4d,SC:S),Z,0,0)]
T:Fbsp$SI_UU16[({0}S:S$u16$0$0({2}SI:U),Z,0,0)({0}S:S$s16$0$0({2}SI:S),Z,0,0)({0}S:S$u8$0$0({2}DA2d,SC:U),Z,0,0)({0}S:S$s8$0$0({2}DA2d,SC:S),Z,0,0)]
T:Fbsp$u2f_hid_nonce[({0}S:S$nonce$0$0({8}DA8d,SC:U),Z,0,0)]
T:Fbsp$config_msg[({0}S:S$cmd$0$0({1}SC:U),Z,0,0)({1}S:S$buf$0$0({63}DA63d,SC:U),Z,0,0)]
T:Fbsp$SI_GEN_PTR[({0}S:S$u8$0$0({3}DA3d,SC:U),Z,0,0)({0}S:S$gptr$0$0({3}ST__00000000:S),Z,0,0)]
T:Fbsp$__00000000[({0}S:S$memtype$0$0({1}SC:U),Z,0,0)({1}S:S$address$0$0({2}STSI_UU16:S),Z,0,0)]
T:Fbsp$__00000010[({0}S:S$bits$0$0({1}ST__00000011:S),Z,0,0)({0}S:S$c$0$0({1}SC:U),Z,0,0)]
T:Fbsp$__00000001[({0}S:S$bmRequestType$0$0({1}ST__00000002:S),Z,0,0)({1}S:S$bRequest$0$0({1}SC:U),Z,0,0)({2}S:S$wValue$0$0({2}SI:U),Z,0,0)({4}S:S$wIndex$0$0({2}SI:U),Z,0,0)({6}S:S$wLength$0$0({2}SI:U),Z,0,0)]
T:Fbsp$__00000011[({0}S:S$callback$0$0({1}SB0$1:U),Z,0,0)({0}S:S$outPacketPending$0$0({1}SB1$1:U),Z,0,0)({0}S:S$inPacketPending$0$0({1}SB2$1:U),Z,0,0)({0}S:S$waitForRead$0$0({1}SB3$1:U),Z,0,0)]
T:Fbsp$__00000002[({0}S:S$Recipient$0$0({1}SB0$5:U),Z,0,0)({0}S:S$Type$0$0({1}SB5$2:U),Z,0,0)({0}S:S$Direction$0$0({1}SB7$1:U),Z,0,0)]
T:Fbsp$__00000012[({0}S:S$configurationValue$0$0({1}SC:U),Z,0,0)({1}S:S$numberOfStrings$0$0({1}SC:U),Z,0,0)({2}S:S$state$0$0({1}SC:U),Z,0,0)({3}S:S$savedState$0$0({1}SC:U),Z,0,0)({4}S:S$setup$0$0({8}ST__00000001:S),Z,0,0)({12}S:S$ep0String$0$0({1}ST__00000013:S),Z,0,0)({13}S:S$ep0$0$0({7}ST__00000009:S),Z,0,0)({20}S:S$ep1in$0$0({7}ST__00000009:S),Z,0,0)({27}S:S$ep1out$0$0({7}ST__00000009:S),Z,0,0)({34}S:S$deviceDescriptor$0$0({3}DG,ST__00000004:S),Z,0,0)({37}S:S$configDescriptor$0$0({3}DG,ST__00000005:S),Z,0,0)({40}S:S$stringDescriptors$0$0({3}DG,DG,DG,SC:U),Z,0,0)]
T:Fbsp$__00000003[({0}S:S$setup$0$0({8}ST__00000001:S),Z,0,0)({0}S:S$c$0$0({8}DA8d,SC:U),Z,0,0)({0}S:S$i$0$0({8}DA4d,SI:U),Z,0,0)]
T:Fbsp$__00000013[({0}S:S$encoding$0$0({1}ST__00000014:S),Z,0,0)({0}S:S$c$0$0({1}SC:U),Z,0,0)]
T:Fbsp$__00000004[({0}S:S$bLength$0$0({1}SC:U),Z,0,0)({1}S:S$bDescriptorType$0$0({1}SC:U),Z,0,0)({2}S:S$bcdUSB$0$0({2}SI:U),Z,0,0)({4}S:S$bDeviceClass$0$0({1}SC:U),Z,0,0)({5}S:S$bDeviceSubClass$0$0({1}SC:U),Z,0,0)({6}S:S$bDeviceProtocol$0$0({1}SC:U),Z,0,0)({7}S:S$bMaxPacketSize0$0$0({1}SC:U),Z,0,0)({8}S:S$idVendor$0$0({2}SI:U),Z,0,0)({10}S:S$idProduct$0$0({2}SI:U),Z,0,0)({12}S:S$bcdDevice$0$0({2}SI:U),Z,0,0)({14}S:S$iManufacturer$0$0({1}SC:U),Z,0,0)({15}S:S$iProduct$0$0({1}SC:U),Z,0,0)({16}S:S$iSerialNumber$0$0({1}SC:U),Z,0,0)({17}S:S$bNumConfigurations$0$0({1}SC:U),Z,0,0)]
T:Fbsp$__00000014[({0}S:S$type$0$0({1}SB0$7:U),Z,0,0)({0}S:S$init$0$0({1}SB7$1:U),Z,0,0)]
T:Fbsp$__00000005[({0}S:S$bLength$0$0({1}SC:U),Z,0,0)({1}S:S$bDescriptorType$0$0({1}SC:U),Z,0,0)({2}S:S$wTotalLength$0$0({2}SI:U),Z,0,0)({4}S:S$bNumInterfaces$0$0({1}SC:U),Z,0,0)({5}S:S$bConfigurationValue$0$0({1}SC:U),Z,0,0)({6}S:S$iConfiguration$0$0({1}SC:U),Z,0,0)({7}S:S$bmAttributes$0$0({1}SC:U),Z,0,0)({8}S:S$bMaxPower$0$0({1}SC:U),Z,0,0)]
T:Fbsp$__00000015[({0}S:S$init$0$0({60}ST__00000016:S),Z,0,0)({0}S:S$cont$0$0({60}ST__00000017:S),Z,0,0)]
T:Fbsp$__00000006[({0}S:S$bLength$0$0({1}SC:U),Z,0,0)({1}S:S$bDescriptorType$0$0({1}SC:U),Z,0,0)({2}S:S$bInterfaceNumber$0$0({1}SC:U),Z,0,0)({3}S:S$bAlternateSetting$0$0({1}SC:U),Z,0,0)({4}S:S$bNumEndpoints$0$0({1}SC:U),Z,0,0)({5}S:S$bInterfaceClass$0$0({1}SC:U),Z,0,0)({6}S:S$bInterfaceSubClass$0$0({1}SC:U),Z,0,0)({7}S:S$bInterfaceProtocol$0$0({1}SC:U),Z,0,0)({8}S:S$iInterface$0$0({1}SC:U),Z,0,0)]
T:Fbsp$__00000016[({0}S:S$cmd$0$0({1}SC:U),Z,0,0)({1}S:S$bcnth$0$0({1}SC:U),Z,0,0)({2}S:S$bcntl$0$0({1}SC:U),Z,0,0)({3}S:S$payload$0$0({57}DA57d,SC:U),Z,0,0)]
T:Fbsp$__00000007[({0}S:S$bLength$0$0({1}SC:U),Z,0,0)({1}S:S$bDescriptorType$0$0({1}SC:U),Z,0,0)({2}S:S$bEndpointAddress$0$0({1}SC:U),Z,0,0)({3}S:S$bmAttributes$0$0({1}SC:U),Z,0,0)({4}S:S$wMaxPacketSize$0$0({2}SI:U),Z,0,0)({6}S:S$bInterval$0$0({1}SC:U),Z,0,0)]
T:Fbsp$__00000017[({0}S:S$seq$0$0({1}SC:U),Z,0,0)({1}S:S$payload$0$0({59}DA59d,SC:U),Z,0,0)]
T:Fbsp$__00000008[({0}S:S$deviceDescriptor$0$0({3}DG,ST__00000004:S),Z,0,0)({3}S:S$configDescriptor$0$0({3}DG,SC:U),Z,0,0)({6}S:S$stringDescriptors$0$0({3}DG,DG,DG,SC:U),Z,0,0)({9}S:S$numberOfStrings$0$0({1}SC:U),Z,0,0)]
T:Fbsp$u2f_hid_msg[({0}S:S$cid$0$0({4}SL:U),Z,0,0)({4}S:S$pkt$0$0({60}ST__00000015:S),Z,0,0)]
T:Fbsp$__00000009[({0}S:S$buf$0$0({3}DG,SC:U),Z,0,0)({3}S:S$remaining$0$0({2}SI:U),Z,0,0)({5}S:S$state$0$0({1}SC:U),Z,0,0)({6}S:S$misc$0$0({1}ST__00000010:S),Z,0,0)]
T:Fbsp$APP_DATA[({0}S:S$tmp$0$0({70}DA70d,SC:U),Z,0,0)]
T:Fbsp$u2f_hid_init_response[({0}S:S$cid$0$0({4}SL:U),Z,0,0)({4}S:S$version_id$0$0({1}SC:U),Z,0,0)({5}S:S$version_major$0$0({1}SC:U),Z,0,0)({6}S:S$version_minor$0$0({1}SC:U),Z,0,0)({7}S:S$version_build$0$0({1}SC:U),Z,0,0)({8}S:S$cflags$0$0({1}SC:U),Z,0,0)]
S:G$appdata$0$0({70}STAPP_DATA:S),E,0,0
S:G$_MS_$0$0({4}SL:U),E,0,0
S:G$hidmsgbuf$0$0({64}DA64d,SC:U),F,0,0
S:G$myUsbDevice$0$0({43}ST__00000012:S),F,0,0
S:Fbsp$__int2str_buf$0$0({9}DA9d,SC:U),F,0,0
S:Fbsp$__digits$0$0({3}DG,SC:U),F,0,0
S:G$ACC$0$0({1}SC:U),I,0,0
S:G$ADC0AC$0$0({1}SC:U),I,0,0
S:G$ADC0CF$0$0({1}SC:U),I,0,0
S:G$ADC0CN0$0$0({1}SC:U),I,0,0
S:G$ADC0CN1$0$0({1}SC:U),I,0,0
S:G$ADC0GTH$0$0({1}SC:U),I,0,0
S:G$ADC0GTL$0$0({1}SC:U),I,0,0
S:G$ADC0H$0$0({1}SC:U),I,0,0
S:G$ADC0L$0$0({1}SC:U),I,0,0
S:G$ADC0LTH$0$0({1}SC:U),I,0,0
S:G$ADC0LTL$0$0({1}SC:U),I,0,0
S:G$ADC0MX$0$0({1}SC:U),I,0,0
S:G$ADC0PWR$0$0({1}SC:U),I,0,0
S:G$ADC0TK$0$0({1}SC:U),I,0,0
S:G$B$0$0({1}SC:U),I,0,0
S:G$CKCON0$0$0({1}SC:U),I,0,0
S:G$CKCON1$0$0({1}SC:U),I,0,0
S:G$CLKSEL$0$0({1}SC:U),I,0,0
S:G$CMP0CN0$0$0({1}SC:U),I,0,0
S:G$CMP0CN1$0$0({1}SC:U),I,0,0
S:G$CMP0MD$0$0({1}SC:U),I,0,0
S:G$CMP0MX$0$0({1}SC:U),I,0,0
S:G$CMP1CN0$0$0({1}SC:U),I,0,0
S:G$CMP1CN1$0$0({1}SC:U),I,0,0
S:G$CMP1MD$0$0({1}SC:U),I,0,0
S:G$CMP1MX$0$0({1}SC:U),I,0,0
S:G$CRC0CN0$0$0({1}SC:U),I,0,0
S:G$CRC0CN1$0$0({1}SC:U),I,0,0
S:G$CRC0CNT$0$0({1}SC:U),I,0,0
S:G$CRC0DAT$0$0({1}SC:U),I,0,0
S:G$CRC0FLIP$0$0({1}SC:U),I,0,0
S:G$CRC0IN$0$0({1}SC:U),I,0,0
S:G$CRC0ST$0$0({1}SC:U),I,0,0
S:G$DERIVID$0$0({1}SC:U),I,0,0
S:G$DEVICEID$0$0({1}SC:U),I,0,0
S:G$DPH$0$0({1}SC:U),I,0,0
S:G$DPL$0$0({1}SC:U),I,0,0
S:G$EIE1$0$0({1}SC:U),I,0,0
S:G$EIE2$0$0({1}SC:U),I,0,0
S:G$EIP1$0$0({1}SC:U),I,0,0
S:G$EIP1H$0$0({1}SC:U),I,0,0
S:G$EIP2$0$0({1}SC:U),I,0,0
S:G$EIP2H$0$0({1}SC:U),I,0,0
S:G$EMI0CN$0$0({1}SC:U),I,0,0
S:G$FLKEY$0$0({1}SC:U),I,0,0
S:G$HFO0CAL$0$0({1}SC:U),I,0,0
S:G$HFO1CAL$0$0({1}SC:U),I,0,0
S:G$HFOCN$0$0({1}SC:U),I,0,0
S:G$I2C0CN0$0$0({1}SC:U),I,0,0
S:G$I2C0DIN$0$0({1}SC:U),I,0,0
S:G$I2C0DOUT$0$0({1}SC:U),I,0,0
S:G$I2C0FCN0$0$0({1}SC:U),I,0,0
S:G$I2C0FCN1$0$0({1}SC:U),I,0,0
S:G$I2C0FCT$0$0({1}SC:U),I,0,0
S:G$I2C0SLAD$0$0({1}SC:U),I,0,0
S:G$I2C0STAT$0$0({1}SC:U),I,0,0
S:G$IE$0$0({1}SC:U),I,0,0
S:G$IP$0$0({1}SC:U),I,0,0
S:G$IPH$0$0({1}SC:U),I,0,0
S:G$IT01CF$0$0({1}SC:U),I,0,0
S:G$LFO0CN$0$0({1}SC:U),I,0,0
S:G$P0$0$0({1}SC:U),I,0,0
S:G$P0MASK$0$0({1}SC:U),I,0,0
S:G$P0MAT$0$0({1}SC:U),I,0,0
S:G$P0MDIN$0$0({1}SC:U),I,0,0
S:G$P0MDOUT$0$0({1}SC:U),I,0,0
S:G$P0SKIP$0$0({1}SC:U),I,0,0
S:G$P1$0$0({1}SC:U),I,0,0
S:G$P1MASK$0$0({1}SC:U),I,0,0
S:G$P1MAT$0$0({1}SC:U),I,0,0
S:G$P1MDIN$0$0({1}SC:U),I,0,0
S:G$P1MDOUT$0$0({1}SC:U),I,0,0
S:G$P1SKIP$0$0({1}SC:U),I,0,0
S:G$P2$0$0({1}SC:U),I,0,0
S:G$P2MASK$0$0({1}SC:U),I,0,0
S:G$P2MAT$0$0({1}SC:U),I,0,0
S:G$P2MDIN$0$0({1}SC:U),I,0,0
S:G$P2MDOUT$0$0({1}SC:U),I,0,0
S:G$P2SKIP$0$0({1}SC:U),I,0,0
S:G$P3$0$0({1}SC:U),I,0,0
S:G$P3MDIN$0$0({1}SC:U),I,0,0
S:G$P3MDOUT$0$0({1}SC:U),I,0,0
S:G$PCA0CENT$0$0({1}SC:U),I,0,0
S:G$PCA0CLR$0$0({1}SC:U),I,0,0
S:G$PCA0CN0$0$0({1}SC:U),I,0,0
S:G$PCA0CPH0$0$0({1}SC:U),I,0,0
S:G$PCA0CPH1$0$0({1}SC:U),I,0,0
S:G$PCA0CPH2$0$0({1}SC:U),I,0,0
S:G$PCA0CPL0$0$0({1}SC:U),I,0,0
S:G$PCA0CPL1$0$0({1}SC:U),I,0,0
S:G$PCA0CPL2$0$0({1}SC:U),I,0,0
S:G$PCA0CPM0$0$0({1}SC:U),I,0,0
S:G$PCA0CPM1$0$0({1}SC:U),I,0,0
S:G$PCA0CPM2$0$0({1}SC:U),I,0,0
S:G$PCA0H$0$0({1}SC:U),I,0,0
S:G$PCA0L$0$0({1}SC:U),I,0,0
S:G$PCA0MD$0$0({1}SC:U),I,0,0
S:G$PCA0POL$0$0({1}SC:U),I,0,0
S:G$PCA0PWM$0$0({1}SC:U),I,0,0
S:G$PCON0$0$0({1}SC:U),I,0,0
S:G$PCON1$0$0({1}SC:U),I,0,0
S:G$PFE0CN$0$0({1}SC:U),I,0,0
S:G$PRTDRV$0$0({1}SC:U),I,0,0
S:G$PSCTL$0$0({1}SC:U),I,0,0
S:G$PSW$0$0({1}SC:U),I,0,0
S:G$REF0CN$0$0({1}SC:U),I,0,0
S:G$REG0CN$0$0({1}SC:U),I,0,0
S:G$REG1CN$0$0({1}SC:U),I,0,0
S:G$REVID$0$0({1}SC:U),I,0,0
S:G$RSTSRC$0$0({1}SC:U),I,0,0
S:G$SBCON1$0$0({1}SC:U),I,0,0
S:G$SBRLH1$0$0({1}SC:U),I,0,0
S:G$SBRLL1$0$0({1}SC:U),I,0,0
S:G$SBUF0$0$0({1}SC:U),I,0,0
S:G$SBUF1$0$0({1}SC:U),I,0,0
S:G$SCON0$0$0({1}SC:U),I,0,0
S:G$SCON1$0$0({1}SC:U),I,0,0
S:G$SFRPAGE$0$0({1}SC:U),I,0,0
S:G$SFRPGCN$0$0({1}SC:U),I,0,0
S:G$SFRSTACK$0$0({1}SC:U),I,0,0
S:G$SMB0ADM$0$0({1}SC:U),I,0,0
S:G$SMB0ADR$0$0({1}SC:U),I,0,0
S:G$SMB0CF$0$0({1}SC:U),I,0,0
S:G$SMB0CN0$0$0({1}SC:U),I,0,0
S:G$SMB0DAT$0$0({1}SC:U),I,0,0
S:G$SMB0FCN0$0$0({1}SC:U),I,0,0
S:G$SMB0FCN1$0$0({1}SC:U),I,0,0
S:G$SMB0FCT$0$0({1}SC:U),I,0,0
S:G$SMB0RXLN$0$0({1}SC:U),I,0,0
S:G$SMB0TC$0$0({1}SC:U),I,0,0
S:G$SMOD1$0$0({1}SC:U),I,0,0
S:G$SP$0$0({1}SC:U),I,0,0
S:G$SPI0CFG$0$0({1}SC:U),I,0,0
S:G$SPI0CKR$0$0({1}SC:U),I,0,0
S:G$SPI0CN0$0$0({1}SC:U),I,0,0
S:G$SPI0DAT$0$0({1}SC:U),I,0,0
S:G$SPI0FCN0$0$0({1}SC:U),I,0,0
S:G$SPI0FCN1$0$0({1}SC:U),I,0,0
S:G$SPI0FCT$0$0({1}SC:U),I,0,0
S:G$TCON$0$0({1}SC:U),I,0,0
S:G$TH0$0$0({1}SC:U),I,0,0
S:G$TH1$0$0({1}SC:U),I,0,0
S:G$TL0$0$0({1}SC:U),I,0,0
S:G$TL1$0$0({1}SC:U),I,0,0
S:G$TMOD$0$0({1}SC:U),I,0,0
S:G$TMR2CN0$0$0({1}SC:U),I,0,0
S:G$TMR2CN1$0$0({1}SC:U),I,0,0
S:G$TMR2H$0$0({1}SC:U),I,0,0
S:G$TMR2L$0$0({1}SC:U),I,0,0
S:G$TMR2RLH$0$0({1}SC:U),I,0,0
S:G$TMR2RLL$0$0({1}SC:U),I,0,0
S:G$TMR3CN0$0$0({1}SC:U),I,0,0
S:G$TMR3CN1$0$0({1}SC:U),I,0,0
S:G$TMR3H$0$0({1}SC:U),I,0,0
S:G$TMR3L$0$0({1}SC:U),I,0,0
S:G$TMR3RLH$0$0({1}SC:U),I,0,0
S:G$TMR3RLL$0$0({1}SC:U),I,0,0
S:G$TMR4CN0$0$0({1}SC:U),I,0,0
S:G$TMR4CN1$0$0({1}SC:U),I,0,0
S:G$TMR4H$0$0({1}SC:U),I,0,0
S:G$TMR4L$0$0({1}SC:U),I,0,0
S:G$TMR4RLH$0$0({1}SC:U),I,0,0
S:G$TMR4RLL$0$0({1}SC:U),I,0,0
S:G$UART1FCN0$0$0({1}SC:U),I,0,0
S:G$UART1FCN1$0$0({1}SC:U),I,0,0
S:G$UART1FCT$0$0({1}SC:U),I,0,0
S:G$UART1LIN$0$0({1}SC:U),I,0,0
S:G$USB0ADR$0$0({1}SC:U),I,0,0
S:G$USB0AEC$0$0({1}SC:U),I,0,0
S:G$USB0CDCF$0$0({1}SC:U),I,0,0
S:G$USB0CDCN$0$0({1}SC:U),I,0,0
S:G$USB0CDSTA$0$0({1}SC:U),I,0,0
S:G$USB0CF$0$0({1}SC:U),I,0,0
S:G$USB0DAT$0$0({1}SC:U),I,0,0
S:G$USB0XCN$0$0({1}SC:U),I,0,0
S:G$VDM0CN$0$0({1}SC:U),I,0,0
S:G$WDTCN$0$0({1}SC:U),I,0,0
S:G$XBR0$0$0({1}SC:U),I,0,0
S:G$XBR1$0$0({1}SC:U),I,0,0
S:G$XBR2$0$0({1}SC:U),I,0,0
S:G$ADC0GT$0$0({2}SI:U),I,0,0
S:G$ADC0$0$0({2}SI:U),I,0,0
S:G$ADC0LT$0$0({2}SI:U),I,0,0
S:G$DP$0$0({2}SI:U),I,0,0
S:G$PCA0CP0$0$0({2}SI:U),I,0,0
S:G$PCA0CP1$0$0({2}SI:U),I,0,0
S:G$PCA0CP2$0$0({2}SI:U),I,0,0
S:G$PCA0$0$0({2}SI:U),I,0,0
S:G$SBRL1$0$0({2}SI:U),I,0,0
S:G$TMR2$0$0({2}SI:U),I,0,0
S:G$TMR2RL$0$0({2}SI:U),I,0,0
S:G$TMR3$0$0({2}SI:U),I,0,0
S:G$TMR3RL$0$0({2}SI:U),I,0,0
S:G$TMR4$0$0({2}SI:U),I,0,0
S:G$TMR4RL$0$0({2}SI:U),I,0,0
S:G$_XPAGE$0$0({1}SC:U),I,0,0
S:G$ACC_ACC0$0$0({1}SX:U),J,0,0
S:G$ACC_ACC1$0$0({1}SX:U),J,0,0
S:G$ACC_ACC2$0$0({1}SX:U),J,0,0
S:G$ACC_ACC3$0$0({1}SX:U),J,0,0
S:G$ACC_ACC4$0$0({1}SX:U),J,0,0
S:G$ACC_ACC5$0$0({1}SX:U),J,0,0
S:G$ACC_ACC6$0$0({1}SX:U),J,0,0
S:G$ACC_ACC7$0$0({1}SX:U),J,0,0
S:G$ADC0CN0_ADCM0$0$0({1}SX:U),J,0,0
S:G$ADC0CN0_ADCM1$0$0({1}SX:U),J,0,0
S:G$ADC0CN0_ADCM2$0$0({1}SX:U),J,0,0
S:G$ADC0CN0_ADWINT$0$0({1}SX:U),J,0,0
S:G$ADC0CN0_ADBUSY$0$0({1}SX:U),J,0,0
S:G$ADC0CN0_ADINT$0$0({1}SX:U),J,0,0
S:G$ADC0CN0_ADBMEN$0$0({1}SX:U),J,0,0
S:G$ADC0CN0_ADEN$0$0({1}SX:U),J,0,0
S:G$B_B0$0$0({1}SX:U),J,0,0
S:G$B_B1$0$0({1}SX:U),J,0,0
S:G$B_B2$0$0({1}SX:U),J,0,0
S:G$B_B3$0$0({1}SX:U),J,0,0
S:G$B_B4$0$0({1}SX:U),J,0,0
S:G$B_B5$0$0({1}SX:U),J,0,0
S:G$B_B6$0$0({1}SX:U),J,0,0
S:G$B_B7$0$0({1}SX:U),J,0,0
S:G$IE_EX0$0$0({1}SX:U),J,0,0
S:G$IE_ET0$0$0({1}SX:U),J,0,0
S:G$IE_EX1$0$0({1}SX:U),J,0,0
S:G$IE_ET1$0$0({1}SX:U),J,0,0
S:G$IE_ES0$0$0({1}SX:U),J,0,0
S:G$IE_ET2$0$0({1}SX:U),J,0,0
S:G$IE_ESPI0$0$0({1}SX:U),J,0,0
S:G$IE_EA$0$0({1}SX:U),J,0,0
S:G$IP_PX0$0$0({1}SX:U),J,0,0
S:G$IP_PT0$0$0({1}SX:U),J,0,0
S:G$IP_PX1$0$0({1}SX:U),J,0,0
S:G$IP_PT1$0$0({1}SX:U),J,0,0
S:G$IP_PS0$0$0({1}SX:U),J,0,0
S:G$IP_PT2$0$0({1}SX:U),J,0,0
S:G$IP_PSPI0$0$0({1}SX:U),J,0,0
S:G$P0_B0$0$0({1}SX:U),J,0,0
S:G$P0_B1$0$0({1}SX:U),J,0,0
S:G$P0_B2$0$0({1}SX:U),J,0,0
S:G$P0_B3$0$0({1}SX:U),J,0,0
S:G$P0_B4$0$0({1}SX:U),J,0,0
S:G$P0_B5$0$0({1}SX:U),J,0,0
S:G$P0_B6$0$0({1}SX:U),J,0,0
S:G$P0_B7$0$0({1}SX:U),J,0,0
S:G$P1_B0$0$0({1}SX:U),J,0,0
S:G$P1_B1$0$0({1}SX:U),J,0,0
S:G$P1_B2$0$0({1}SX:U),J,0,0
S:G$P1_B3$0$0({1}SX:U),J,0,0
S:G$P1_B4$0$0({1}SX:U),J,0,0
S:G$P1_B5$0$0({1}SX:U),J,0,0
S:G$P1_B6$0$0({1}SX:U),J,0,0
S:G$P1_B7$0$0({1}SX:U),J,0,0
S:G$P2_B0$0$0({1}SX:U),J,0,0
S:G$P2_B1$0$0({1}SX:U),J,0,0
S:G$P2_B2$0$0({1}SX:U),J,0,0
S:G$P2_B3$0$0({1}SX:U),J,0,0
S:G$P3_B0$0$0({1}SX:U),J,0,0
S:G$P3_B1$0$0({1}SX:U),J,0,0
S:G$PCA0CN0_CCF0$0$0({1}SX:U),J,0,0
S:G$PCA0CN0_CCF1$0$0({1}SX:U),J,0,0
S:G$PCA0CN0_CCF2$0$0({1}SX:U),J,0,0
S:G$PCA0CN0_CR$0$0({1}SX:U),J,0,0
S:G$PCA0CN0_CF$0$0({1}SX:U),J,0,0
S:G$PSW_PARITY$0$0({1}SX:U),J,0,0
S:G$PSW_F1$0$0({1}SX:U),J,0,0
S:G$PSW_OV$0$0({1}SX:U),J,0,0
S:G$PSW_RS0$0$0({1}SX:U),J,0,0
S:G$PSW_RS1$0$0({1}SX:U),J,0,0
S:G$PSW_F0$0$0({1}SX:U),J,0,0
S:G$PSW_AC$0$0({1}SX:U),J,0,0
S:G$PSW_CY$0$0({1}SX:U),J,0,0
S:G$SCON0_RI$0$0({1}SX:U),J,0,0
S:G$SCON0_TI$0$0({1}SX:U),J,0,0
S:G$SCON0_RB8$0$0({1}SX:U),J,0,0
S:G$SCON0_TB8$0$0({1}SX:U),J,0,0
S:G$SCON0_REN$0$0({1}SX:U),J,0,0
S:G$SCON0_MCE$0$0({1}SX:U),J,0,0
S:G$SCON0_SMODE$0$0({1}SX:U),J,0,0
S:G$SCON1_RI$0$0({1}SX:U),J,0,0
S:G$SCON1_TI$0$0({1}SX:U),J,0,0
S:G$SCON1_RBX$0$0({1}SX:U),J,0,0
S:G$SCON1_TBX$0$0({1}SX:U),J,0,0
S:G$SCON1_REN$0$0({1}SX:U),J,0,0
S:G$SCON1_PERR$0$0({1}SX:U),J,0,0
S:G$SCON1_OVR$0$0({1}SX:U),J,0,0
S:G$SMB0CN0_SI$0$0({1}SX:U),J,0,0
S:G$SMB0CN0_ACK$0$0({1}SX:U),J,0,0
S:G$SMB0CN0_ARBLOST$0$0({1}SX:U),J,0,0
S:G$SMB0CN0_ACKRQ$0$0({1}SX:U),J,0,0
S:G$SMB0CN0_STO$0$0({1}SX:U),J,0,0
S:G$SMB0CN0_STA$0$0({1}SX:U),J,0,0
S:G$SMB0CN0_TXMODE$0$0({1}SX:U),J,0,0
S:G$SMB0CN0_MASTER$0$0({1}SX:U),J,0,0
S:G$SPI0CN0_SPIEN$0$0({1}SX:U),J,0,0
S:G$SPI0CN0_TXNF$0$0({1}SX:U),J,0,0
S:G$SPI0CN0_NSSMD0$0$0({1}SX:U),J,0,0
S:G$SPI0CN0_NSSMD1$0$0({1}SX:U),J,0,0
S:G$SPI0CN0_RXOVRN$0$0({1}SX:U),J,0,0
S:G$SPI0CN0_MODF$0$0({1}SX:U),J,0,0
S:G$SPI0CN0_WCOL$0$0({1}SX:U),J,0,0
S:G$SPI0CN0_SPIF$0$0({1}SX:U),J,0,0
S:G$TCON_IT0$0$0({1}SX:U),J,0,0
S:G$TCON_IE0$0$0({1}SX:U),J,0,0
S:G$TCON_IT1$0$0({1}SX:U),J,0,0
S:G$TCON_IE1$0$0({1}SX:U),J,0,0
S:G$TCON_TR0$0$0({1}SX:U),J,0,0
S:G$TCON_TF0$0$0({1}SX:U),J,0,0
S:G$TCON_TR1$0$0({1}SX:U),J,0,0
S:G$TCON_TF1$0$0({1}SX:U),J,0,0
S:G$TMR2CN0_T2XCLK0$0$0({1}SX:U),J,0,0
S:G$TMR2CN0_T2XCLK1$0$0({1}SX:U),J,0,0
S:G$TMR2CN0_TR2$0$0({1}SX:U),J,0,0
S:G$TMR2CN0_T2SPLIT$0$0({1}SX:U),J,0,0
S:G$TMR2CN0_TF2CEN$0$0({1}SX:U),J,0,0
S:G$TMR2CN0_TF2LEN$0$0({1}SX:U),J,0,0
S:G$TMR2CN0_TF2L$0$0({1}SX:U),J,0,0
S:G$TMR2CN0_TF2H$0$0({1}SX:U),J,0,0
S:G$TMR4CN0_T4XCLK0$0$0({1}SX:U),J,0,0
S:G$TMR4CN0_T4XCLK1$0$0({1}SX:U),J,0,0
S:G$TMR4CN0_TR4$0$0({1}SX:U),J,0,0
S:G$TMR4CN0_T4SPLIT$0$0({1}SX:U),J,0,0
S:G$TMR4CN0_TF4CEN$0$0({1}SX:U),J,0,0
S:G$TMR4CN0_TF4LEN$0$0({1}SX:U),J,0,0
S:G$TMR4CN0_TF4L$0$0({1}SX:U),J,0,0
S:G$TMR4CN0_TF4H$0$0({1}SX:U),J,0,0
S:G$UART1FCN1_RIE$0$0({1}SX:U),J,0,0
S:G$UART1FCN1_RXTO0$0$0({1}SX:U),J,0,0
S:G$UART1FCN1_RXTO1$0$0({1}SX:U),J,0,0
S:G$UART1FCN1_RFRQ$0$0({1}SX:U),J,0,0
S:G$UART1FCN1_TIE$0$0({1}SX:U),J,0,0
S:G$UART1FCN1_TXHOLD$0$0({1}SX:U),J,0,0
S:G$UART1FCN1_TXNF$0$0({1}SX:U),J,0,0
S:G$UART1FCN1_TFRQ$0$0({1}SX:U),J,0,0
S:G$U2F_BUTTON$0$0({1}SX:U),J,0,0
S:G$U2F_BUTTON_VAL$0$0({1}SX:U),J,0,0
S:G$U2F_RED$0$0({1}SX:U),J,0,0
S:G$U2F_GREEN$0$0({1}SX:U),J,0,0
S:G$U2F_BLUE$0$0({1}SX:U),J,0,0
S:G$memcpy$0$0({2}DF,DG,SV:S),C,0,0
S:G$memmove$0$0({2}DF,DG,SV:S),C,0,0
S:G$strcpy$0$0({2}DF,DG,SC:U),C,0,0
S:G$strncpy$0$0({2}DF,DG,SC:U),C,0,0
S:G$strcat$0$0({2}DF,DG,SC:U),C,0,0
S:G$strncat$0$0({2}DF,DG,SC:U),C,0,0
S:G$memcmp$0$0({2}DF,SI:S),C,0,0
S:G$strcmp$0$0({2}DF,SI:S),C,0,0
S:G$strncmp$0$0({2}DF,SI:S),C,0,0
S:G$strxfrm$0$0({2}DF,SI:U),C,0,0
S:G$memchr$0$0({2}DF,DG,SV:S),C,0,0
S:G$strchr$0$0({2}DF,DG,SC:U),C,0,0
S:G$strcspn$0$0({2}DF,SI:U),C,0,0
S:G$strpbrk$0$0({2}DF,DG,SC:U),C,0,0
S:G$strrchr$0$0({2}DF,DG,SC:U),C,0,0
S:G$strspn$0$0({2}DF,SI:U),C,0,0
S:G$strstr$0$0({2}DF,DG,SC:U),C,0,0
S:G$strtok$0$0({2}DF,DG,SC:U),C,0,0
S:G$memset$0$0({2}DF,DG,SV:S),C,0,0
S:G$strlen$0$0({2}DF,SI:U),C,0,0
S:G$USBD_SetUsbState$0$0({2}DF,SV:S),C,0,0
S:G$USBDCH9_SetupCmd$0$0({2}DF,SC:U),C,0,0
S:G$USBD_AbortAllTransfers$0$0({2}DF,SV:S),C,0,0
S:G$USBD_AbortTransfer$0$0({2}DF,SC:S),C,0,0
S:G$USBD_Connect$0$0({2}DF,SV:S),C,0,0
S:G$USBD_Disconnect$0$0({2}DF,SV:S),C,0,0
S:G$USBD_EpIsBusy$0$0({2}DF,SB0$1:U),C,0,0
S:G$USBD_GetUsbState$0$0({2}DF,SC:U),C,0,0
S:G$USBD_Init$0$0({2}DF,SC:S),C,0,0
S:G$USBD_Read$0$0({2}DF,SC:S),C,0,0
S:G$USBD_RemoteWakeup$0$0({2}DF,SC:S),C,0,0
S:G$USBD_StallEp$0$0({2}DF,SC:S),C,0,0
S:G$USBD_Stop$0$0({2}DF,SV:S),C,0,0
S:G$USBD_Suspend$0$0({2}DF,SV:S),C,0,0
S:G$USBD_UnStallEp$0$0({2}DF,SC:S),C,0,0
S:G$USBD_Write$0$0({2}DF,SC:S),C,0,0
S:G$USBD_EnterHandler$0$0({2}DF,SV:S),C,0,0
S:G$USBD_ExitHandler$0$0({2}DF,SV:S),C,0,0
S:G$USBD_ResetCb$0$0({2}DF,SV:S),C,0,0
S:G$USBD_SofCb$0$0({2}DF,SV:S),C,0,0
S:G$USBD_DeviceStateChangeCb$0$0({2}DF,SV:S),C,0,0
S:G$USBD_IsSelfPoweredCb$0$0({2}DF,SB0$1:U),C,0,0
S:G$USBD_SetupCmdCb$0$0({2}DF,SC:U),C,0,0
S:G$USBD_SetInterfaceCb$0$0({2}DF,SC:U),C,0,0
S:G$USBD_RemoteWakeupCb$0$0({2}DF,SB0$1:U),C,0,0
S:G$USBD_RemoteWakeupDelay$0$0({2}DF,SV:S),C,0,0
S:G$USBD_Run$0$0({2}DF,SV:S),C,0,0
S:G$USBD_XferCompleteCb$0$0({2}DF,SI:U),C,0,0
S:G$USB_ReadFIFO$0$0({2}DF,SV:S),C,0,0
S:G$USB_WriteFIFO$0$0({2}DF,SV:S),C,0,0
S:G$USB_GetIntsEnabled$0$0({2}DF,SB0$1:U),C,0,0
S:G$USB_IsRegulatorEnabled$0$0({2}DF,SB0$1:U),C,0,0
S:G$USB_IsPrefetchEnabled$0$0({2}DF,SB0$1:U),C,0,0
S:G$USB_SuspendOscillator$0$0({2}DF,SV:S),C,0,0
S:G$USB_SetIndex$0$0({2}DF,SV:S),C,0,0
S:G$USB_GetCommonInts$0$0({2}DF,SC:U),C,0,0
S:G$USB_GetInInts$0$0({2}DF,SC:U),C,0,0
S:G$USB_GetOutInts$0$0({2}DF,SC:U),C,0,0
S:G$USB_GetIndex$0$0({2}DF,SC:U),C,0,0
S:G$USB_IsSuspended$0$0({2}DF,SB0$1:U),C,0,0
S:G$USB_GetSetupEnd$0$0({2}DF,SB0$1:U),C,0,0
S:G$USB_Ep0SentStall$0$0({2}DF,SB0$1:U),C,0,0
S:G$USB_Ep0InPacketReady$0$0({2}DF,SB0$1:U),C,0,0
S:G$USB_Ep0OutPacketReady$0$0({2}DF,SB0$1:U),C,0,0
S:G$USB_Ep0GetCount$0$0({2}DF,SC:U),C,0,0
S:G$USB_EpnInGetSentStall$0$0({2}DF,SB0$1:U),C,0,0
S:G$USB_EpnGetInPacketReady$0$0({2}DF,SB0$1:U),C,0,0
S:G$USB_EpnOutGetSentStall$0$0({2}DF,SB0$1:U),C,0,0
S:G$USB_EpnGetOutPacketReady$0$0({2}DF,SB0$1:U),C,0,0
S:G$USB_EpOutGetCount$0$0({2}DF,SI:U),C,0,0
S:G$USB_GetSofNumber$0$0({2}DF,SI:U),C,0,0
S:G$USB_AbortInEp$0$0({2}DF,SV:S),C,0,0
S:G$USB_AbortOutEp$0$0({2}DF,SV:S),C,0,0
S:G$USB_ActivateEp$0$0({2}DF,SV:S),C,0,0
S:G$_print_format$0$0({2}DF,SI:S),C,0,0
S:G$printf_small$0$0({2}DF,SV:S),C,0,0
S:G$printf$0$0({2}DF,SI:S),C,0,0
S:G$vprintf$0$0({2}DF,SI:S),C,0,0
S:G$sprintf$0$0({2}DF,SI:S),C,0,0
S:G$vsprintf$0$0({2}DF,SI:S),C,0,0
S:G$puts$0$0({2}DF,SI:S),C,0,0
S:G$getchar$0$0({2}DF,SC:U),C,0,0
S:G$putchar$0$0({2}DF,SV:S),C,0,0
S:G$printf_fast$0$0({2}DF,SV:S),C,0,0
S:G$printf_fast_f$0$0({2}DF,SV:S),C,0,0
S:G$printf_tiny$0$0({2}DF,SV:S),C,0,0
S:G$atof$0$0({2}DF,SF:S),C,0,0
S:G$atoi$0$0({2}DF,SI:S),C,0,0
S:G$atol$0$0({2}DF,SL:S),C,0,0
S:G$_uitoa$0$0({2}DF,SV:S),C,0,0
S:G$_itoa$0$0({2}DF,SV:S),C,0,0
S:G$_ultoa$0$0({2}DF,SV:S),C,0,0
S:G$_ltoa$0$0({2}DF,SV:S),C,0,0
S:G$rand$0$0({2}DF,SI:S),C,0,0
S:G$srand$0$0({2}DF,SV:S),C,0,0
S:G$calloc$0$0({2}DF,DX,SV:S),C,0,0
S:G$malloc$0$0({2}DF,DX,SV:S),C,0,0
S:G$realloc$0$0({2}DF,DX,SV:S),C,0,0
S:G$aligned_alloc$0$0({2}DF,DG,SV:S),C,0,2
S:G$free$0$0({2}DF,SV:S),C,0,0
S:G$abs$0$0({2}DF,SI:S),C,0,0
S:G$labs$0$0({2}DF,SL:S),C,0,0
S:G$mblen$0$0({2}DF,SI:S),C,0,0
S:G$mbtowc$0$0({2}DF,SI:S),C,0,0
S:G$wctomb$0$0({2}DF,SI:S),C,0,0
S:G$u2f_hid_init$0$0({2}DF,SV:S),C,0,0
S:G$u2f_hid_set_len$0$0({2}DF,SV:S),C,0,0
S:G$u2f_hid_writeback$0$0({2}DF,SV:S),C,0,0
S:G$u2f_hid_flush$0$0({2}DF,SV:S),C,0,0
S:G$u2f_hid_request$0$0({2}DF,SV:S),C,0,0
S:G$u2f_hid_check_timeouts$0$0({2}DF,SV:S),C,0,0
S:G$u2f_print_hid_check_timeouts$0$0({2}DF,SV:S),C,0,0
S:G$set_app_u2f_hid_msg$0$0({2}DF,SV:S),C,0,0
S:G$set_app_error$0$0({2}DF,SV:S),C,0,0
S:G$get_app_error$0$0({2}DF,SC:U),C,0,0
S:G$get_app_state$0$0({2}DF,SC:U),C,0,0
S:G$set_app_state$0$0({2}DF,SV:S),C,0,0
S:G$rgb$0$0({2}DF,SV:S),C,0,0
S:G$app_wink$0$0({2}DF,SV:S),C,0,0
S:G$u2f_init$0$0({2}DF,SV:S),C,0,0
S:G$u2f_wipe_keys$0$0({2}DF,SC:S),C,0,0
S:Fbsp$int2str_reduce_n$0$0({2}DF,SV:S),C,0,0
S:Fbsp$int2str_map_n$0$0({2}DF,SV:S),C,0,0
S:Fbsp$put_space$0$0({2}DF,SV:S),C,0,0
S:Fbsp$put_line$0$0({2}DF,SV:S),C,0,0
S:G$u2f_printl$0$0({2}DF,SV:S),C,0,0
S:G$ReportDescriptor0$0$0({34}DA34d,SC:U),D,0,0
S:G$deviceDesc$0$0({0}DA0d,SC:U),D,0,0
S:G$configDesc$0$0({0}DA0d,SC:U),D,0,0
S:G$initstruct$0$0({10}ST__00000008:S),D,0,0
S:G$WMASK$0$0({0}DA0d,SC:U),D,0,0
S:G$RMASK$0$0({0}DA0d,SC:U),D,0,0
S:Fbsp$__str_0$0$0({3}DA3d,SC:S),D,0,0
S:Fbsp$__str_1$0$0({3}DA3d,SC:S),D,0,0
S:Fbsp$__str_2$0$0({2}DA2d,SC:S),D,0,0
S:Fbsp$__str_3$0$0({17}DA17d,SC:S),D,0,0
S:Fbsp$__xinit___digits$0$0({3}DG,SC:U),C,0,0
|
zhmu/ananas | Ada | 95 | adb | -- { dg-do compile }
with Generic_Inst4_Inst;
procedure Generic_Inst4 is
begin
null;
end;
|
AaronC98/PlaneSystem | Ada | 15,746 | adb | ------------------------------------------------------------------------------
-- Ada Web Server --
-- --
-- Copyright (C) 2002-2017, AdaCore --
-- --
-- This library is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the --
-- Free Software Foundation; either version 3, or (at your option) any --
-- later version. This library is distributed in the hope that it will be --
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
------------------------------------------------------------------------------
pragma Ada_2012;
with Ada.Characters.Handling;
with Ada.Strings.Fixed;
with AWS.Digest;
with AWS.Headers.Values;
with AWS.Resources.Streams.Memory.ZLib;
with AWS.Resources.Streams.ZLib;
with AWS.Server;
with AWS.Translator;
with ZLib;
package body AWS.Response.Set is
package RSM renames AWS.Resources.Streams.Memory;
procedure Check_Memory_Stream (D : in out Data) with Inline;
-- Test if the memory stream allocated and create it if necessary
procedure Clear_Memory_Stream (D : in out Data) with Inline;
-- Test if the memory stream allocated and create it if necessary,
-- if the stream already created, clear it.
----------------
-- Add_Header --
----------------
procedure Add_Header
(D : in out Data;
Name : String;
Value : String) is
begin
D.Header.Add (Name, Value);
end Add_Header;
-----------------
-- Append_Body --
-----------------
procedure Append_Body
(D : in out Data;
Item : Streams.Stream_Element_Array) is
begin
Check_Memory_Stream (D);
RSM.Append (RSM.Stream_Type'Class (D.Stream.all), Item);
end Append_Body;
procedure Append_Body (D : in out Data; Item : String) is
begin
Append_Body (D, Translator.To_Stream_Element_Array (Item));
end Append_Body;
--------------------
-- Authentication --
--------------------
procedure Authentication
(D : in out Data;
Realm : String;
Mode : Authentication_Mode := Basic;
Stale : Boolean := False)
is
N : Positive := 1;
-- The index for the update of WWW-Authenticate header values.
-- We are not using AWS.Headers.Set.Add routine for add WWW-Authenticate
-- header lines, because user could call this routine more than once.
begin
-- In case of Authenticate = Any
-- We should create both header lines
-- WWW-Authenticate: Basic
-- and
-- WWW-Authenticate: Digest
if Mode = Digest or else Mode = Any then
D.Header.Update
(Name => Messages.WWW_Authenticate_Token,
Value => "Digest qop=""auth"", realm=""" & Realm
& """, stale=""" & Boolean'Image (Stale)
& """, nonce="""
& String (AWS.Digest.Create_Nonce) & """",
N => N);
N := N + 1;
end if;
if Mode = Basic or else Mode = Any then
D.Header.Update
(Name => Messages.WWW_Authenticate_Token,
Value => "Basic realm=""" & Realm & """",
N => N);
end if;
D.Status_Code := Messages.S401;
end Authentication;
-------------------
-- Cache_Control --
-------------------
procedure Cache_Control
(D : in out Data;
Value : Messages.Cache_Option)
is
use type Messages.Cache_Option;
begin
if Value /= Messages.Unspecified then
D.Header.Update
(Name => Messages.Cache_Control_Token,
Value => String (Value));
if Strings.Fixed.Index (String (Value), "no-cache") /= 0 then
-- There is a no-cache option specified for the Cache-Control
-- header. Add "Pragma: no-cache" for compatibility with HTTP/1.0
-- protocol.
D.Header.Update
(Name => Messages.Pragma_Token, Value => "no-cache");
end if;
end if;
end Cache_Control;
-------------------------
-- Check_Memory_Stream --
-------------------------
procedure Check_Memory_Stream (D : in out Data) is
use type Resources.Streams.Stream_Access;
begin
if D.Stream = null then
D.Stream := new RSM.Stream_Type;
D.Mode := Message;
end if;
end Check_Memory_Stream;
-----------
-- Clear --
-----------
procedure Clear (D : in out Data) is
use type Resources.Streams.Stream_Access;
begin
if D.Stream /= null then
if not D.Ref_Counter.Stream_Taken then
Resources.Streams.Close (D.Stream.all);
end if;
Unchecked_Free (D.Stream);
end if;
D.Header.Reset;
D.Mode := No_Data;
D.Status_Code := Messages.S200;
D.Filename := Null_Unbounded_String;
end Clear;
-------------------------
-- Clear_Memory_Stream --
-------------------------
procedure Clear_Memory_Stream (D : in out Data) is
use type Resources.Streams.Stream_Access;
begin
if D.Stream = null then
D.Stream := new RSM.Stream_Type;
D.Mode := Message;
else
RSM.Clear (RSM.Stream_Type (D.Stream.all));
end if;
end Clear_Memory_Stream;
-------------------
-- Clear_Session --
-------------------
procedure Clear_Session (D : in out Data) is
begin
Add_Header (D, "Set-Cookie", AWS.Server.Session_Name & "=");
end Clear_Session;
--------------------
-- Close_Resource --
--------------------
procedure Close_Resource
(D : in out Data;
State : Boolean) is
begin
D.Close_Stream := State;
end Close_Resource;
------------------
-- Content_Type --
------------------
procedure Content_Type
(D : in out Data;
Value : String) is
begin
D.Content_Type := To_Unbounded_String (Value);
end Content_Type;
-------------------
-- Data_Encoding --
-------------------
procedure Data_Encoding
(D : in out Data;
Encoding : Messages.Content_Encoding;
Direction : Encoding_Direction := Encode)
is
use type Resources.Streams.Stream_Access;
Header : RSM.ZLib.Header_Type := ZLib.None;
begin
if D.Stream /= null then
-- The stream is already active, there is nothing to do, we can't
-- change the encoding when data has alredy been added into the
-- stream.
return;
end if;
D.Mode := Message;
case Encoding is
when Messages.Identity => D.Stream := new RSM.Stream_Type;
when Messages.GZip => Header := ZLib.GZip;
when Messages.Deflate => Header := ZLib.Default;
end case;
if D.Stream = null then
-- ZLib encoding/decoding is necessary
D.Stream := new RSM.ZLib.Stream_Type;
-- Create the encoding stream, now initialize it
if Direction = Encode then
RSM.ZLib.Deflate_Initialize
(RSM.ZLib.Stream_Type (D.Stream.all), Header => Header);
-- Set the Content-Encoding header value for server's response
--
-- Looks like IE in the Windows Mobile 5.0 do not understand
-- content coding in the upper case. Bug found in the
-- User-Agent:
-- Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; PPC; 240x320)
Update_Header
(D,
Messages.Content_Encoding_Token,
Ada.Characters.Handling.To_Lower
(Messages.Content_Encoding'Image (Encoding)));
else
RSM.ZLib.Inflate_Initialize
(RSM.ZLib.Stream_Type (D.Stream.all), Header => Header);
end if;
end if;
end Data_Encoding;
-------------
-- Expires --
-------------
procedure Expires
(D : in out Data;
Value : Calendar.Time) is
begin
Expires (D, Messages.To_HTTP_Date (Value));
end Expires;
procedure Expires
(D : in out Data;
Value : String) is
begin
D.Header.Update (Name => Messages.Expires_Token, Value => Value);
end Expires;
--------------
-- Filename --
--------------
procedure Filename
(D : in out Data;
Value : String) is
begin
D.Filename := To_Unbounded_String (Value);
D.Mode := File;
end Filename;
--------------
-- Is_Valid --
--------------
function Is_Valid (D : Data) return Boolean is
Redirection_Code : Boolean;
begin
case D.Status_Code is
when
Messages.S300 | -- Section 10.3.1: Multiple Choices
Messages.S301 | -- Section 10.3.2: Moved Permanently
Messages.S302 | -- Section 10.3.3: Found
Messages.S303 | -- Section 10.3.4: See Other
Messages.S305 | -- Section 10.3.6: Use Proxy
Messages.S307 -- Section 10.3.8: Temporary Redirect
=>
Redirection_Code := True;
when others =>
Redirection_Code := False;
end case;
return (Redirection_Code
xor not Headers.Exist
(D.Header,
Messages.Location_Token))
and then (D.Status_Code = Messages.S401
xor not Headers.Exist
(D.Header,
Messages.WWW_Authenticate_Token));
end Is_Valid;
----------------
-- Keep_Alive --
----------------
procedure Keep_Alive (D : in out Data; State : Boolean) is
begin
D.Keep_Alive := State;
end Keep_Alive;
--------------
-- Location --
--------------
procedure Location
(D : in out Data;
Value : String) is
begin
D.Header.Update (Name => Messages.Location_Token, Value => Value);
end Location;
------------------
-- Message_Body --
------------------
procedure Message_Body
(D : in out Data;
Value : Streams.Stream_Element_Array) is
begin
Clear_Memory_Stream (D);
RSM.Append (RSM.Stream_Type'Class (D.Stream.all), Value);
end Message_Body;
procedure Message_Body
(D : in out Data;
Value : String) is
begin
Message_Body (D, To_Unbounded_String (Value));
end Message_Body;
procedure Message_Body
(D : in out Data;
Value : Unbounded_String)
is
Chunk_Size : constant := 8 * 1_024;
Len : constant Natural := Length (Value);
First, Last : Natural;
begin
-- Prepare the memory stream
Clear_Memory_Stream (D);
First := 1;
loop
Last := Integer'Min (First + Chunk_Size - 1, Len);
RSM.Append
(RSM.Stream_Type'Class (D.Stream.all),
Translator.To_Stream_Element_Array (Slice (Value, First, Last)));
First := Last + 1;
exit when First > Len;
end loop;
end Message_Body;
----------
-- Mode --
----------
procedure Mode
(D : in out Data;
Value : Data_Mode) is
begin
D.Mode := Value;
end Mode;
-----------------
-- Read_Header --
-----------------
procedure Read_Header
(Socket : Net.Socket_Type'Class;
D : in out Data) is
begin
D.Header.Read (Socket);
-- Set D.Content_Type with the value read from the socket
D.Content_Type := To_Unbounded_String
(Headers.Get (D.Header, Messages.Content_Type_Token));
-- Set the Filename if any
if AWS.Headers.Exist (D.Header, Messages.Content_Disposition_Token) then
D.Filename := To_Unbounded_String
(AWS.Headers.Values.Search
(AWS.Headers.Get
(D.Header, Messages.Content_Disposition_Token), "filename"));
end if;
end Read_Header;
-----------------
-- Status_Code --
-----------------
procedure Status_Code
(D : in out Data;
Value : Messages.Status_Code) is
begin
D.Status_Code := Value;
end Status_Code;
------------
-- Stream --
------------
procedure Stream
(D : in out Data;
Handle : not null access Resources.Streams.Stream_Type'Class;
Encoding : Messages.Content_Encoding := Messages.Identity)
is
use type Messages.Content_Encoding;
begin
case Encoding is
when Messages.GZip =>
D.Stream := Resources.Streams.ZLib.Deflate_Create
(Resources.Streams.Stream_Access (Handle),
Header => ZLib.GZip);
when Messages.Deflate =>
D.Stream := Resources.Streams.ZLib.Deflate_Create
(Resources.Streams.Stream_Access (Handle),
Header => ZLib.Default);
when Messages.Identity =>
D.Stream := Resources.Streams.Stream_Access (Handle);
end case;
if Encoding /= Messages.Identity then
-- We should not send "Content-Encoding: Identity" header line
--
-- RFC 2616
-- 3.5 Content Codings
-- ...
-- identity
-- The default (identity) encoding; the use of no transformation
-- whatsoever. This content-coding is used only in the Accept-
-- Encoding header, and SHOULD NOT be used in the Content-Encoding
-- header.
Update_Header
(D,
Messages.Content_Encoding_Token,
Ada.Characters.Handling.To_Lower
(Messages.Content_Encoding'Image (Encoding)));
elsif D.Header.Get (Messages.Content_Encoding_Token) /= "" then
raise Constraint_Error
with "Response content encoding is not supported.";
end if;
D.Mode := Stream;
end Stream;
-------------------
-- Update_Header --
-------------------
procedure Update_Header
(D : in out Data;
Name : String;
Value : String;
N : Positive := 1) is
begin
D.Header.Update (Name, Value, N);
end Update_Header;
end AWS.Response.Set;
|
onox/sdlada | Ada | 3,829 | ads | --------------------------------------------------------------------------------------------------------------------
-- Copyright (c) 2013-2018 Luke A. Guest
--
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
--
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
--
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
--
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
--
-- 3. This notice may not be removed or altered from any source
-- distribution.
--------------------------------------------------------------------------------------------------------------------
-- SDL.Events.Joysticks.Game_Controllers
--
-- Game controller specific events.
--------------------------------------------------------------------------------------------------------------------
with Interfaces;
package SDL.Events.Joysticks.Game_Controllers is
type Axes is (Invalid,
Left_X,
Left_Y,
Right_X,
Right_Y,
Trigger_Left,
Trigger_Right) with
Convention => C;
for Axes use (Invalid => -1,
Left_X => 0,
Left_Y => 1,
Right_X => 2,
Right_Y => 3,
Trigger_Left => 4,
Trigger_Right => 5);
subtype LR_Axes is Axes range Left_X .. Right_Y;
subtype Trigger_Axes is Axes range Trigger_Left .. Trigger_Right;
type LR_Axes_Values is range -32768 .. 32767 with
Convention => C,
Size => 16;
type Trigger_Axes_Values is range 0 .. 32767 with
Convention => C,
Size => 16;
type Buttons is (Invalid,
A,
B,
X,
Y,
Back,
Guide,
Start,
Left_Stick,
Right_Stick,
Left_Shoulder,
Right_Shoulder,
D_Pad_Up,
D_Pad_Down,
D_Pad_Left,
D_Pad_Right) with
Convention => C;
for Buttons use (Invalid => -1,
A => 0,
B => 1,
X => 2,
Y => 3,
Back => 4,
Guide => 5,
Start => 6,
Left_Stick => 7,
Right_Stick => 8,
Left_Shoulder => 9,
Right_Shoulder => 10,
D_Pad_Up => 11,
D_Pad_Down => 12,
D_Pad_Left => 13,
D_Pad_Right => 14);
-- Update the game controller event data. This is called by the event loop.
procedure Update with
Import => True,
Convention => C,
External_Name => "SDL_GameControllerUpdate";
function Is_Polling_Enabled return Boolean;
procedure Enable_Polling with
Inline => True;
procedure Disable_Polling with
Inline => True;
end SDL.Events.Joysticks.Game_Controllers;
|
msrLi/portingSources | Ada | 798 | ads | -- Copyright 2011-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/>.
with System;
package Pck is
procedure Do_Nothing (A : System.Address);
end Pck;
|
davidkristola/vole | Ada | 1,018 | adb |
with vole_lex_dfa; use vole_lex_dfa;
package body vole_lex_dfa is
function YYText return string is
i : integer;
str_loc : integer := 1;
buffer : string(1..1024);
EMPTY_STRING : constant string := "";
begin
-- find end of buffer
i := yytext_ptr;
while ( yy_ch_buf(i) /= ASCII.NUL ) loop
buffer(str_loc ) := yy_ch_buf(i);
i := i + 1;
str_loc := str_loc + 1;
end loop;
-- return yy_ch_buf(yytext_ptr.. i - 1);
if (str_loc < 2) then
return EMPTY_STRING;
else
return buffer(1..str_loc-1);
end if;
end;
-- returns the length of the matched text
function YYLength return integer is
begin
return yy_cp - yy_bp;
end YYLength;
-- done after the current pattern has been matched and before the
-- corresponding action - sets up yytext
procedure YY_DO_BEFORE_ACTION is
begin
yytext_ptr := yy_bp;
yy_hold_char := yy_ch_buf(yy_cp);
yy_ch_buf(yy_cp) := ASCII.NUL;
yy_c_buf_p := yy_cp;
end YY_DO_BEFORE_ACTION;
end vole_lex_dfa;
|
silky/synth | Ada | 47,170 | adb | -- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
with Ada.Calendar.Arithmetic;
with Ada.Calendar.Formatting;
with Ada.Direct_IO;
with Replicant.Platform;
package body PortScan.Buildcycle is
package ACA renames Ada.Calendar.Arithmetic;
package ACF renames Ada.Calendar.Formatting;
package REP renames Replicant;
----------------------
-- initialize_log --
----------------------
function initialize_log (id : builders) return Boolean
is
FA : access TIO.File_Type;
H_ENV : constant String := "Environment";
H_OPT : constant String := "Options";
CFG1 : constant String := "/etc/make.conf";
CFG2 : constant String := "/etc/mk.conf";
UNAME : constant String := JT.USS (uname_mrv);
BENV : constant String := get_environment (id);
COPTS : constant String := get_options_configuration (id);
PTVAR : JT.Text := get_port_variables (id);
begin
trackers (id).dynlink.Clear;
trackers (id).head_time := CAL.Clock;
declare
log_path : constant String := log_name (trackers (id).seq_id);
begin
if AD.Exists (log_path) then
AD.Delete_File (log_path);
end if;
TIO.Create (File => trackers (id).log_handle,
Mode => TIO.Out_File,
Name => log_path);
FA := trackers (id).log_handle'Access;
exception
when error : others =>
raise cycle_log_error
with "failed to create log " & log_path;
end;
TIO.Put_Line (FA.all, "=> Building " &
get_catport (all_ports (trackers (id).seq_id)));
TIO.Put_Line (FA.all, "Started : " & timestamp (trackers (id).head_time));
TIO.Put (FA.all, "Platform: " & UNAME);
if BENV = discerr then
TIO.Put_Line (FA.all, LAT.LF & "Environment definition failed, " &
"aborting entire build");
return False;
end if;
TIO.Put_Line (FA.all, LAT.LF & log_section (H_ENV, True));
TIO.Put (FA.all, BENV);
TIO.Put_Line (FA.all, log_section (H_ENV, False) & LAT.LF);
TIO.Put_Line (FA.all, log_section (H_OPT, True));
TIO.Put (FA.all, COPTS);
TIO.Put_Line (FA.all, log_section (H_OPT, False) & LAT.LF);
dump_port_variables (id => id, content => PTVAR);
case software_framework is
when ports_collection =>
TIO.Put_Line (FA.all, log_section (CFG1, True));
TIO.Put (FA.all, dump_make_conf (id, CFG1));
TIO.Put_Line (FA.all, log_section (CFG1, False) & LAT.LF);
when pkgsrc =>
TIO.Put_Line (FA.all, log_section (CFG2, True));
TIO.Put (FA.all, dump_make_conf (id, CFG2));
TIO.Put_Line (FA.all, log_section (CFG2, False) & LAT.LF);
end case;
return True;
end initialize_log;
--------------------
-- finalize_log --
--------------------
procedure finalize_log (id : builders) is
begin
TIO.Put_Line (trackers (id).log_handle, log_section ("Termination", True));
trackers (id).tail_time := CAL.Clock;
TIO.Put_Line (trackers (id).log_handle,
"Finished: " & timestamp (trackers (id).tail_time));
TIO.Put_Line (trackers (id).log_handle,
log_duration (start => trackers (id).head_time,
stop => trackers (id).tail_time));
TIO.Close (trackers (id).log_handle);
end finalize_log;
--------------------
-- log_duration --
--------------------
function log_duration (start, stop : CAL.Time) return String
is
raw : JT.Text := JT.SUS ("Duration:");
diff_days : ACA.Day_Count;
diff_secs : Duration;
leap_secs : ACA.Leap_Seconds_Count;
use type ACA.Day_Count;
begin
ACA.Difference (Left => stop,
Right => start,
Days => diff_days,
Seconds => diff_secs,
Leap_Seconds => leap_secs);
if diff_days > 0 then
if diff_days = 1 then
JT.SU.Append (raw, " 1 day and " &
ACF.Image (Elapsed_Time => diff_secs));
else
JT.SU.Append (raw, diff_days'Img & " days and " &
ACF.Image (Elapsed_Time => diff_secs));
end if;
else
JT.SU.Append (raw, " " & ACF.Image (Elapsed_Time => diff_secs));
end if;
return JT.USS (raw);
end log_duration;
------------------------
-- elapsed_HH_MM_SS --
------------------------
function elapsed_HH_MM_SS (start, stop : CAL.Time) return String
is
diff_days : ACA.Day_Count;
diff_secs : Duration;
leap_secs : ACA.Leap_Seconds_Count;
secs_per_hour : constant Integer := 3600;
total_hours : Integer;
total_minutes : Integer;
work_hours : Integer;
work_seconds : Integer;
use type ACA.Day_Count;
begin
ACA.Difference (Left => stop,
Right => start,
Days => diff_days,
Seconds => diff_secs,
Leap_Seconds => leap_secs);
-- Seems the ACF image is shit, so let's roll our own. If more than
-- 100 hours, change format to "HHH:MM.M"
work_seconds := Integer (diff_secs);
total_hours := work_seconds / secs_per_hour;
total_hours := total_hours + Integer (diff_days) * 24;
if total_hours < 24 then
if work_seconds < 0 then
return "--:--:--";
else
work_seconds := work_seconds - (total_hours * secs_per_hour);
total_minutes := work_seconds / 60;
work_seconds := work_seconds - (total_minutes * 60);
return
JT.zeropad (total_hours, 2) & LAT.Colon &
JT.zeropad (total_minutes, 2) & LAT.Colon &
JT.zeropad (work_seconds, 2);
end if;
elsif total_hours < 100 then
if work_seconds < 0 then
return JT.zeropad (total_hours, 2) & ":00:00";
else
work_hours := work_seconds / secs_per_hour;
work_seconds := work_seconds - (work_hours * secs_per_hour);
total_minutes := work_seconds / 60;
work_seconds := work_seconds - (total_minutes * 60);
return
JT.zeropad (total_hours, 2) & LAT.Colon &
JT.zeropad (total_minutes, 2) & LAT.Colon &
JT.zeropad (work_seconds, 2);
end if;
else
if work_seconds < 0 then
return JT.zeropad (total_hours, 3) & ":00.0";
else
work_hours := work_seconds / secs_per_hour;
work_seconds := work_seconds - (work_hours * secs_per_hour);
total_minutes := work_seconds / 60;
work_seconds := (work_seconds - (total_minutes * 60)) * 10 / 60;
return
JT.zeropad (total_hours, 3) & LAT.Colon &
JT.zeropad (total_minutes, 2) & '.' &
JT.int2str (work_seconds);
end if;
end if;
end elapsed_HH_MM_SS;
-------------------
-- elapsed_now --
-------------------
function elapsed_now return String is
begin
return elapsed_HH_MM_SS (start => start_time, stop => CAL.Clock);
end elapsed_now;
-----------------------------
-- generic_system_command --
-----------------------------
function generic_system_command (command : String) return JT.Text
is
content : JT.Text;
status : Integer;
begin
content := Unix.piped_command (command, status);
if status /= 0 then
raise cycle_cmd_error with "cmd: " & command &
" (return code =" & status'Img & ")";
end if;
return content;
end generic_system_command;
---------------------
-- set_uname_mrv --
---------------------
procedure set_uname_mrv
is
-- valid for all platforms
command : constant String := "/usr/bin/uname -mrv";
begin
uname_mrv := generic_system_command (command);
exception
when others =>
uname_mrv := JT.SUS (discerr);
end set_uname_mrv;
----------------
-- get_root --
----------------
function get_root (id : builders) return String
is
id_image : constant String := Integer (id)'Img;
suffix : String := "/SL00";
begin
if id < 10 then
suffix (5) := id_image (2);
else
suffix (4 .. 5) := id_image (2 .. 3);
end if;
return JT.USS (PM.configuration.dir_buildbase) & suffix;
end get_root;
-----------------------
-- get_environment --
-----------------------
function get_environment (id : builders) return String
is
root : constant String := get_root (id);
command : constant String := chroot & root & environment_override;
begin
return JT.USS (generic_system_command (command));
exception
when others =>
return discerr;
end get_environment;
---------------------------------
-- get_options_configuration --
---------------------------------
function get_options_configuration (id : builders) return String
is
root : constant String := get_root (id);
command : constant String := chroot & root & environment_override &
chroot_make_program & " -C " & dir_ports & "/" &
get_catport (all_ports (trackers (id).seq_id));
begin
case software_framework is
when ports_collection =>
return JT.USS (generic_system_command (command & " showconfig"));
when pkgsrc =>
return JT.USS (generic_system_command (command & " show-options"));
end case;
exception
when others =>
return discerr;
end get_options_configuration;
------------------------
-- split_collection --
------------------------
function split_collection (line : JT.Text; title : String) return String
is
-- Support spaces in two ways
-- 1) quoted, e.g. TYPING="The Quick Brown Fox"
-- 2) Escaped, e.g. TYPING=The\ Quick\ Brown\ Fox
meat : JT.Text;
waiting : Boolean := True;
escaped : Boolean := False;
quoted : Boolean := False;
keepit : Boolean;
counter : Natural := 0;
meatlen : Natural := 0;
linelen : Natural := JT.SU.Length (line);
onechar : String (1 .. 1);
meatstr : String (1 .. linelen);
begin
loop
counter := counter + 1;
exit when counter > linelen;
keepit := True;
onechar := JT.SU.Slice (Source => line,
Low => counter,
High => counter);
if onechar (1) = LAT.Reverse_Solidus then
-- A) if inside quotes, it's literal
-- B) if it's first RS, don't keep but mark escaped
-- C) If it's second RS, it's literal, remove escaped
-- D) RS can never start a new NV pair
if not quoted then
if not escaped then
keepit := False;
end if;
escaped := not escaped;
end if;
elsif escaped then
-- E) by definition, next character after an escape is literal
-- We know it's not inside quotes. Keep this (could be a space)
waiting := False;
escaped := not escaped;
elsif onechar (1) = LAT.Space then
if waiting then
keepit := False;
else
if not quoted then
-- name-pair ended, reset
waiting := True;
quoted := False;
onechar (1) := LAT.LF;
end if;
end if;
else
waiting := False;
if onechar (1) = LAT.Quotation then
quoted := not quoted;
end if;
end if;
if keepit then
meatlen := meatlen + 1;
meatstr (meatlen) := onechar (1);
end if;
end loop;
return log_section (title, True) & LAT.LF &
meatstr (1 .. meatlen) & LAT.LF &
log_section (title, False) & LAT.LF;
end split_collection;
--------------------------
-- get_port_variables --
--------------------------
function get_port_variables (id : builders) return JT.Text
is
root : constant String := get_root (id);
command : constant String := chroot & root & environment_override &
chroot_make_program & " -C " & dir_ports & "/" &
get_catport (all_ports (trackers (id).seq_id));
cmd_fpc : constant String := command &
" -VCONFIGURE_ENV -VCONFIGURE_ARGS -VMAKE_ENV -VMAKE_ARGS" &
" -VPLIST_SUB -VSUB_LIST";
cmd_nps : constant String := command &
" .MAKE.EXPAND_VARIABLES=yes -VCONFIGURE_ENV -VCONFIGURE_ARGS" &
" -VMAKE_ENV -VMAKE_FLAGS -VBUILD_MAKE_FLAGS -VPLIST_SUBST" &
" -VFILES_SUBST";
begin
case software_framework is
when ports_collection =>
return generic_system_command (cmd_fpc);
when pkgsrc =>
return generic_system_command (cmd_nps);
end case;
exception
when others =>
return JT.SUS (discerr);
end get_port_variables;
---------------------------
-- dump_port_variables --
---------------------------
procedure dump_port_variables (id : builders; content : JT.Text)
is
LA : access TIO.File_Type := trackers (id).log_handle'Access;
topline : JT.Text;
concopy : JT.Text := content;
type result_range_fpc is range 1 .. 6;
type result_range_nps is range 1 .. 7;
begin
case software_framework is
when ports_collection =>
for k in result_range_fpc loop
JT.nextline (lineblock => concopy, firstline => topline);
case k is
when 1 => TIO.Put_Line
(LA.all, split_collection (topline, "CONFIGURE_ENV"));
when 2 => TIO.Put_Line
(LA.all, split_collection (topline, "CONFIGURE_ARGS"));
when 3 => TIO.Put_Line
(LA.all, split_collection (topline, "MAKE_ENV"));
when 4 => TIO.Put_Line
(LA.all, split_collection (topline, "MAKE_ARGS"));
when 5 => TIO.Put_Line
(LA.all, split_collection (topline, "PLIST_SUB"));
when 6 => TIO.Put_Line
(LA.all, split_collection (topline, "SUB_LIST"));
end case;
end loop;
when pkgsrc =>
for k in result_range_nps loop
JT.nextline (lineblock => concopy, firstline => topline);
case k is
when 1 => TIO.Put_Line
(LA.all, split_collection (topline, "CONFIGURE_ENV"));
when 2 => TIO.Put_Line
(LA.all, split_collection (topline, "CONFIGURE_ARGS"));
when 3 => TIO.Put_Line
(LA.all, split_collection (topline, "MAKE_ENV"));
when 4 => TIO.Put_Line
(LA.all, split_collection (topline, "MAKE_FLAGS"));
when 5 => TIO.Put_Line
(LA.all, split_collection (topline, "BUILD_MAKE_FLAGS"));
when 6 => TIO.Put_Line
(LA.all, split_collection (topline, "PLIST_SUBST"));
when 7 => TIO.Put_Line
(LA.all, split_collection (topline, "FILES_SUBST"));
end case;
end loop;
end case;
end dump_port_variables;
----------------
-- log_name --
----------------
function log_name (sid : port_id) return String
is
catport : constant String := get_catport (all_ports (sid));
begin
return JT.USS (PM.configuration.dir_logs) & "/" &
JT.part_1 (catport) & "___" & JT.part_2 (catport) & ".log";
end log_name;
-----------------
-- dump_file --
-----------------
function dump_file (filename : String) return String
is
File_Size : Natural := Natural (AD.Size (filename));
subtype File_String is String (1 .. File_Size);
package File_String_IO is new Ada.Direct_IO (File_String);
File : File_String_IO.File_Type;
Contents : File_String;
begin
File_String_IO.Open (File, Mode => File_String_IO.In_File,
Name => filename);
File_String_IO.Read (File, Item => Contents);
File_String_IO.Close (File);
return String (Contents);
end dump_file;
----------------------
-- dump_make_conf --
----------------------
function dump_make_conf (id : builders; conf_file : String) return String
is
root : constant String := get_root (id);
filename : constant String := root & conf_file;
begin
return dump_file (filename);
end dump_make_conf;
------------------
-- initialize --
------------------
procedure initialize (test_mode : Boolean; jail_env : JT.Text) is
begin
set_uname_mrv;
testing := test_mode;
lock_localbase := testing and then Unix.env_variable_defined ("LOCK");
slave_env := jail_env;
declare
logdir : constant String := JT.USS (PM.configuration.dir_logs);
begin
if not AD.Exists (logdir) then
AD.Create_Path (New_Directory => logdir);
end if;
exception
when error : others =>
raise cycle_log_error
with "failed to create " & logdir;
end;
obtain_custom_environment;
end initialize;
-------------------
-- log_section --
-------------------
function log_section (title : String; header : Boolean) return String
is
hyphens : constant String := (1 .. 50 => '-');
begin
if header then
return LAT.LF & hyphens & LAT.LF & "-- " & title & LAT.LF & hyphens;
else
return "";
end if;
end log_section;
---------------------
-- log_phase_end --
---------------------
procedure log_phase_end (id : builders)
is
begin
TIO.Put_Line (trackers (id).log_handle, "" & LAT.LF);
end log_phase_end;
-----------------------
-- log_phase_begin --
-----------------------
procedure log_phase_begin (phase : String; id : builders)
is
hyphens : constant String := (1 .. 80 => '-');
middle : constant String := "-- Phase: " & phase;
begin
TIO.Put_Line (trackers (id).log_handle,
LAT.LF & hyphens & LAT.LF & middle & LAT.LF & hyphens);
end log_phase_begin;
-----------------------
-- generic_execute --
-----------------------
function generic_execute (id : builders; command : String;
dogbite : out Boolean;
time_limit : execution_limit) return Boolean
is
subtype time_cycle is execution_limit range 1 .. time_limit;
subtype one_minute is Positive range 1 .. 230; -- lose 10 in rounding
type dim_watchdog is array (time_cycle) of Natural;
use type Unix.process_exit;
watchdog : dim_watchdog;
squirrel : time_cycle := time_cycle'First;
cycle_done : Boolean := False;
pid : Unix.pid_t;
status : Unix.process_exit;
lock_lines : Natural;
quartersec : one_minute := one_minute'First;
hangmonitor : constant Boolean := True;
synthexec : constant String := host_localbase & "/libexec/synthexec";
truecommand : constant String := synthexec & " " &
log_name (trackers (id).seq_id) & " " & command;
begin
dogbite := False;
watchdog (squirrel) := trackers (id).loglines;
pid := Unix.launch_process (truecommand);
if Unix.fork_failed (pid) then
return False;
end if;
loop
delay 0.25;
if quartersec = one_minute'Last then
quartersec := one_minute'First;
-- increment squirrel
if squirrel = time_cycle'Last then
squirrel := time_cycle'First;
cycle_done := True;
else
squirrel := squirrel + 1;
end if;
if hangmonitor then
lock_lines := trackers (id).loglines;
if cycle_done then
if watchdog (squirrel) = lock_lines then
-- Log hasn't advanced in a full cycle so bail out
dogbite := True;
Unix.kill_process_tree (process_group => pid);
delay 5.0; -- Give some time for error to write to log
return False;
end if;
end if;
watchdog (squirrel) := lock_lines;
end if;
else
quartersec := quartersec + 1;
end if;
status := Unix.process_status (pid);
if status = Unix.exited_normally then
return True;
end if;
if status = Unix.exited_with_error then
return False;
end if;
end loop;
end generic_execute;
------------------------------
-- stack_linked_libraries --
------------------------------
procedure stack_linked_libraries (id : builders; base, filename : String)
is
command : String := chroot & base & " /usr/bin/objdump -p " & filename;
comres : JT.Text;
topline : JT.Text;
crlen1 : Natural;
crlen2 : Natural;
begin
comres := generic_system_command (command);
crlen1 := JT.SU.Length (comres);
loop
JT.nextline (lineblock => comres, firstline => topline);
crlen2 := JT.SU.Length (comres);
exit when crlen1 = crlen2;
crlen1 := crlen2;
if not JT.IsBlank (topline) then
if JT.contains (topline, "NEEDED") then
if not trackers (id).dynlink.Contains (topline) then
trackers (id).dynlink.Append (topline);
end if;
end if;
end if;
end loop;
exception
-- the command result was not zero, so it was an expected format
-- or static file. Just skip it. (Should never happen)
when bad_result : others => null;
end stack_linked_libraries;
----------------------------
-- log_linked_libraries --
----------------------------
procedure log_linked_libraries (id : builders)
is
procedure log_dump (cursor : string_crate.Cursor);
comres : JT.Text;
topline : JT.Text;
crlen1 : Natural;
crlen2 : Natural;
pkgfile : constant String := JT.USS
(all_ports (trackers (id).seq_id).package_name);
pkgname : constant String := pkgfile (1 .. pkgfile'Last - 4);
root : constant String := get_root (id);
command : constant String := chroot & root & environment_override &
REP.root_localbase & "/sbin/pkg-static query %Fp " & pkgname;
procedure log_dump (cursor : string_crate.Cursor) is
begin
TIO.Put_Line (trackers (id).log_handle,
JT.USS (string_crate.Element (Position => cursor)));
end log_dump;
begin
TIO.Put_Line (trackers (id).log_handle,
"=> Checking shared library dependencies");
comres := generic_system_command (command);
crlen1 := JT.SU.Length (comres);
loop
JT.nextline (lineblock => comres, firstline => topline);
crlen2 := JT.SU.Length (comres);
exit when crlen1 = crlen2;
crlen1 := crlen2;
if REP.Platform.dynamically_linked (root, JT.USS (topline)) then
stack_linked_libraries (id, root, JT.USS (topline));
end if;
end loop;
trackers (id).dynlink.Iterate (log_dump'Access);
exception
when others => null;
end log_linked_libraries;
----------------------------
-- environment_override --
----------------------------
function environment_override (enable_tty : Boolean := False) return String
is
function set_terminal (enable_tty : Boolean) return String;
function set_terminal (enable_tty : Boolean) return String is
begin
if enable_tty then
return "TERM=cons25 ";
end if;
return "TERM=dumb ";
end set_terminal;
PATH : constant String := "PATH=/sbin:/bin:/usr/sbin:/usr/bin:"
& REP.root_localbase & "/sbin:" & REP.root_localbase & "/bin ";
TERM : constant String := set_terminal (enable_tty);
USER : constant String := "USER=root ";
HOME : constant String := "HOME=/root ";
LANG : constant String := "LANG=C ";
FTP : constant String := "SSL_NO_VERIFY_PEER=1 ";
PKG8 : constant String := "PORTSDIR=" & dir_ports & " " &
"PKG_DBDIR=/var/db/pkg8 " &
"PKG_CACHEDIR=/var/cache/pkg8 ";
CENV : constant String := JT.USS (customenv);
JENV : constant String := JT.USS (slave_env);
begin
return " /usr/bin/env -i " &
USER & HOME & LANG & PKG8 & TERM & FTP & PATH & JENV & CENV;
end environment_override;
---------------------
-- set_log_lines --
---------------------
procedure set_log_lines (id : builders)
is
log_path : constant String := log_name (trackers (id).seq_id);
command : constant String := "/usr/bin/wc -l " & log_path;
comres : JT.Text;
begin
if not uselog then
trackers (id).loglines := 0;
return;
end if;
comres := JT.trim (generic_system_command (command));
declare
numtext : constant String :=
JT.part_1 (S => JT.USS (comres), separator => " ");
begin
trackers (id).loglines := Natural'Value (numtext);
end;
exception
when others => null; -- just skip this cycle
end set_log_lines;
-----------------------
-- format_loglines --
-----------------------
function format_loglines (numlines : Natural) return String
is
begin
if numlines < 10000000 then -- 10 million
return JT.int2str (numlines);
end if;
declare
kilo : constant Natural := numlines / 1000;
kilotxt : constant String := JT.int2str (kilo);
begin
if numlines < 100000000 then -- 100 million
return kilotxt (1 .. 2) & "." & kilotxt (3 .. 5) & 'M';
elsif numlines < 1000000000 then -- 1 billion
return kilotxt (1 .. 3) & "." & kilotxt (3 .. 4) & 'M';
else
return kilotxt (1 .. 4) & "." & kilotxt (3 .. 3) & 'M';
end if;
end;
end format_loglines;
---------------------
-- elapsed_build --
---------------------
function elapsed_build (id : builders) return String is
begin
return elapsed_HH_MM_SS (start => trackers (id).head_time,
stop => trackers (id).tail_time);
end elapsed_build;
-----------------------------
-- get_packages_per_hour --
-----------------------------
function get_packages_per_hour (packages_done : Natural;
from_when : CAL.Time)
return Natural
is
diff_days : ACA.Day_Count;
diff_secs : Duration;
leap_secs : ACA.Leap_Seconds_Count;
result : Natural;
rightnow : CAL.Time := CAL.Clock;
work_seconds : Integer;
work_days : Integer;
use type ACA.Day_Count;
begin
if packages_done = 0 then
return 0;
end if;
ACA.Difference (Left => rightnow,
Right => from_when,
Days => diff_days,
Seconds => diff_secs,
Leap_Seconds => leap_secs);
work_seconds := Integer (diff_secs);
work_days := Integer (diff_days);
work_seconds := work_seconds + (work_days * 3600 * 24);
if work_seconds < 0 then
-- should be impossible to get here.
return 0;
end if;
result := packages_done * 3600;
result := result / work_seconds;
return result;
exception
when others => return 0;
end get_packages_per_hour;
------------------------
-- mark_file_system --
------------------------
procedure mark_file_system (id : builders; action : String)
is
function attributes (action : String) return String;
function attributes (action : String) return String
is
core : constant String := "uid,gid,mode,md5digest";
begin
if action = "preconfig" then
return core & ",time";
else
return core;
end if;
end attributes;
path_mm : String := JT.USS (PM.configuration.dir_buildbase) & "/Base";
path_sm : String := JT.USS (PM.configuration.dir_buildbase) & "/SL" &
JT.zeropad (Natural (id), 2);
mtfile : constant String := path_mm & "/mtree." & action & ".exclude";
command : constant String := "/usr/sbin/mtree -X " & mtfile &
" -cn -k " & attributes (action) & " -p " & path_sm;
filename : constant String := path_sm & "/tmp/mtree." & action;
result : JT.Text;
resfile : TIO.File_Type;
begin
result := generic_system_command (command);
TIO.Create (File => resfile, Mode => TIO.Out_File, Name => filename);
TIO.Put (resfile, JT.USS (result));
TIO.Close (resfile);
exception
when others =>
if TIO.Is_Open (resfile) then
TIO.Close (resfile);
end if;
end mark_file_system;
--------------------------------
-- detect_leftovers_and_MIA --
--------------------------------
function detect_leftovers_and_MIA (id : builders; action : String;
description : String) return Boolean
is
package crate is new AC.Vectors (Index_Type => Positive,
Element_Type => JT.Text,
"=" => JT.SU."=");
package sorter is new crate.Generic_Sorting ("<" => JT.SU."<");
function ignore_modifications return Boolean;
procedure print (cursor : crate.Cursor);
procedure close_active_modifications;
path_mm : String := JT.USS (PM.configuration.dir_buildbase) & "/Base";
path_sm : String := JT.USS (PM.configuration.dir_buildbase) & "/SL" &
JT.zeropad (Natural (id), 2);
mtfile : constant String := path_mm & "/mtree." & action & ".exclude";
filename : constant String := path_sm & "/tmp/mtree." & action;
command : constant String := "/usr/sbin/mtree -X " & mtfile & " -f " &
filename & " -p " & path_sm;
status : Integer;
comres : JT.Text;
topline : JT.Text;
crlen1 : Natural;
crlen2 : Natural;
toplen : Natural;
skiprest : Boolean;
passed : Boolean := True;
activemod : Boolean := False;
modport : JT.Text := JT.blank;
reasons : JT.Text := JT.blank;
leftover : crate.Vector;
missing : crate.Vector;
changed : crate.Vector;
function ignore_modifications return Boolean
is
-- Some modifications need to be ignored
-- A) */ls-R
-- #ls-R files from texmf are often regenerated
-- B) share/xml/catalog.ports
-- # xmlcatmgr is constantly updating catalog.ports, ignore
-- C) share/octave/octave_packages
-- # Octave packages database, blank lines can be inserted
-- # between pre-install and post-deinstall
-- D) info/dir | */info/dir
-- E) lib/gio/modules/giomodule.cache
-- # gio modules cache could be modified for any gio modules
-- F) etc/gconf/gconf.xml.defaults/%gconf-tree*.xml
-- # gconftool-2 --makefile-uninstall-rule is unpredictable
-- G) %%PEARDIR%%/.depdb | %%PEARDIR%%/.filemap
-- # The is pear database cache
-- H) "." with timestamp modification
-- # this happens when ./tmp or ./var is used, which is legal
filename : constant String := JT.USS (modport);
fnlen : constant Natural := filename'Length;
begin
if filename = "usr/local/share/xml/catalog.ports" or else
filename = "usr/local/share/octave/octave_packages" or else
filename = "usr/local/info/dir" or else
filename = "usr/local/lib/gio/modules/giomodule.cache" or else
filename = "usr/local/share/pear/.depdb" or else
filename = "usr/local/share/pear/.filemap"
then
return True;
end if;
if filename = "." and then JT.equivalent (reasons, "modification") then
return True;
end if;
if fnlen > 17 and then filename (1 .. 10) = "usr/local/"
then
if filename (fnlen - 4 .. fnlen) = "/ls-R" or else
filename (fnlen - 8 .. fnlen) = "/info/dir"
then
return True;
end if;
end if;
if fnlen > 56 and then filename (1 .. 39) =
"usr/local/etc/gconf/gconf.xml.defaults/" and then
filename (fnlen - 3 .. fnlen) = ".xml"
then
if JT.contains (filename, "/%gconf-tree") then
return True;
end if;
end if;
return False;
end ignore_modifications;
procedure close_active_modifications is
begin
if activemod and then not ignore_modifications then
JT.SU.Append (modport, " [ ");
JT.SU.Append (modport, reasons);
JT.SU.Append (modport, " ]");
if not changed.Contains (modport) then
changed.Append (modport);
end if;
end if;
activemod := False;
reasons := JT.blank;
modport := JT.blank;
end close_active_modifications;
procedure print (cursor : crate.Cursor)
is
dossier : constant String := JT.USS (crate.Element (cursor));
begin
TIO.Put_Line (trackers (id).log_handle, LAT.HT & dossier);
end print;
begin
-- we can't use generic_system_command because exit code /= 0 normally
comres := Unix.piped_command (command, status);
crlen1 := JT.SU.Length (comres);
loop
skiprest := False;
JT.nextline (lineblock => comres, firstline => topline);
crlen2 := JT.SU.Length (comres);
exit when crlen1 = crlen2;
crlen1 := crlen2;
toplen := JT.SU.Length (topline);
if not skiprest and then JT.SU.Length (topline) > 6 then
declare
sx : constant Natural := toplen - 5;
caboose : constant String := JT.SU.Slice (topline, sx, toplen);
filename : JT.Text := JT.SUS (JT.SU.Slice (topline, 1, sx - 1));
begin
if caboose = " extra" then
close_active_modifications;
if not leftover.Contains (filename) then
leftover.Append (filename);
end if;
skiprest := True;
end if;
end;
end if;
if not skiprest and then JT.SU.Length (topline) > 7 then
declare
canopy : constant String := JT.SU.Slice (topline, 1, 7);
filename : JT.Text := JT.SUS (JT.SU.Slice (topline, 8, toplen));
begin
if canopy = "extra: " then
close_active_modifications;
if not leftover.Contains (filename) then
leftover.Append (filename);
end if;
skiprest := True;
end if;
end;
end if;
if not skiprest and then JT.SU.Length (topline) > 10 then
declare
sx : constant Natural := toplen - 7;
caboose : constant String := JT.SU.Slice (topline, sx, toplen);
filename : JT.Text := JT.SUS (JT.SU.Slice (topline, 3, sx - 1));
begin
if caboose = " missing" then
close_active_modifications;
if not missing.Contains (filename) then
missing.Append (filename);
end if;
skiprest := True;
end if;
end;
end if;
if not skiprest then
declare
line : constant String := JT.USS (topline);
blank8 : constant String := " ";
sx : constant Natural := toplen - 7;
begin
if toplen > 5 and then line (1) = LAT.HT then
-- reason, but only valid if modification is active
if activemod then
if JT.IsBlank (reasons) then
reasons := JT.SUS (JT.part_1 (line (2 .. toplen), " "));
else
JT.SU.Append (reasons, " | ");
JT.SU.Append (reasons, JT.part_1
(line (2 .. toplen), " "));
end if;
end if;
skiprest := True;
end if;
if not skiprest and then line (toplen) = LAT.Colon then
close_active_modifications;
activemod := True;
modport := JT.SUS (line (1 .. toplen - 1));
skiprest := True;
end if;
if not skiprest and then
JT.SU.Slice (topline, sx, toplen) = " changed"
then
close_active_modifications;
activemod := True;
modport := JT.SUS (line (1 .. toplen - 8));
skiprest := True;
end if;
end;
end if;
end loop;
close_active_modifications;
sorter.Sort (Container => changed);
sorter.Sort (Container => missing);
sorter.Sort (Container => leftover);
TIO.Put_Line (trackers (id).log_handle, LAT.LF & "=> Checking for " &
"system changes " & description);
if not leftover.Is_Empty then
passed := False;
TIO.Put_Line (trackers (id).log_handle, LAT.LF &
" Left over files/directories:");
leftover.Iterate (Process => print'Access);
end if;
if not missing.Is_Empty then
passed := False;
TIO.Put_Line (trackers (id).log_handle, LAT.LF &
" Missing files/directories:");
missing.Iterate (Process => print'Access);
end if;
if not changed.Is_Empty then
passed := False;
TIO.Put_Line (trackers (id).log_handle, LAT.LF &
" Modified files/directories:");
changed.Iterate (Process => print'Access);
end if;
if passed then
TIO.Put_Line (trackers (id).log_handle, "Everything is fine.");
end if;
return passed;
end detect_leftovers_and_MIA;
-----------------------------
-- interact_with_builder --
-----------------------------
procedure interact_with_builder (id : builders)
is
root : constant String := get_root (id);
command : constant String := chroot & root &
environment_override (enable_tty => True) &
REP.Platform.interactive_shell;
result : Boolean;
begin
TIO.Put_Line ("Entering interactive test mode at the builder root " &
"directory.");
TIO.Put_Line ("Type 'exit' when done exploring.");
result := Unix.external_command (command);
end interact_with_builder;
---------------------------------
-- obtain_custom_environment --
---------------------------------
procedure obtain_custom_environment
is
target_name : constant String := PM.synth_confdir & "/" &
JT.USS (PM.configuration.profile) & "-environment";
fragment : TIO.File_Type;
begin
customenv := JT.blank;
if AD.Exists (target_name) then
TIO.Open (File => fragment, Mode => TIO.In_File, Name => target_name);
while not TIO.End_Of_File (fragment) loop
declare
Line : String := TIO.Get_Line (fragment);
begin
if JT.contains (Line, "=") then
JT.SU.Append (customenv, JT.trim (Line) & " ");
end if;
end;
end loop;
TIO.Close (fragment);
end if;
exception
when others =>
if TIO.Is_Open (fragment) then
TIO.Close (fragment);
end if;
end obtain_custom_environment;
--------------------------------
-- set_localbase_protection --
--------------------------------
procedure set_localbase_protection (id : builders; lock : Boolean)
is
procedure remount (readonly : Boolean);
procedure dismount;
smount : constant String := get_root (id);
slave_local : constant String := smount & "_localbase";
procedure remount (readonly : Boolean)
is
cmd_freebsd : String := "/sbin/mount_nullfs ";
cmd_dragonfly : String := "/sbin/mount_null ";
points : String := slave_local & " " & smount & REP.root_localbase;
options : String := "-o ro ";
cmd : JT.Text;
cmd_output : JT.Text;
begin
if JT.equivalent (PM.configuration.operating_sys, "FreeBSD") then
cmd := JT.SUS (cmd_freebsd);
else
cmd := JT.SUS (cmd_dragonfly);
end if;
if readonly then
JT.SU.Append (cmd, options);
end if;
JT.SU.Append (cmd, points);
if not Unix.piped_mute_command (JT.USS (cmd), cmd_output) then
if uselog then
TIO.Put_Line (trackers (id).log_handle,
"command failed: " & JT.USS (cmd));
if not JT.IsBlank (cmd_output) then
TIO.Put_Line (trackers (id).log_handle, JT.USS (cmd_output));
end if;
end if;
end if;
end remount;
procedure dismount
is
cmd_unmount : constant String := "/sbin/umount " & smount & REP.root_localbase;
cmd_output : JT.Text;
begin
if not Unix.piped_mute_command (cmd_unmount, cmd_output) then
if uselog then
TIO.Put_Line (trackers (id).log_handle,
"command failed: " & cmd_unmount);
if not JT.IsBlank (cmd_output) then
TIO.Put_Line (trackers (id).log_handle, JT.USS (cmd_output));
end if;
end if;
end if;
end dismount;
begin
if lock then
dismount;
remount (readonly => True);
else
dismount;
remount (readonly => False);
end if;
end set_localbase_protection;
------------------------------
-- timeout_multiplier_x10 --
------------------------------
function timeout_multiplier_x10 return Positive
is
average5 : constant Float := REP.Platform.get_5_minute_load;
avefloat : constant Float := average5 / Float (number_cores);
begin
if avefloat <= 1.0 then
return 10;
else
return Integer (avefloat * 10.0);
end if;
exception
when others => return 10;
end timeout_multiplier_x10;
---------------------------
-- valid_test_phase #2 --
---------------------------
function valid_test_phase (afterphase : String) return Boolean is
begin
if afterphase = "extract" or else
afterphase = "patch" or else
afterphase = "configure" or else
afterphase = "build" or else
afterphase = "stage" or else
afterphase = "install" or else
afterphase = "deinstall"
then
return True;
else
return False;
end if;
end valid_test_phase;
---------------------------
-- builder_status_core --
---------------------------
function builder_status_core (id : builders;
shutdown : Boolean := False;
idle : Boolean := False;
phasestr : String)
return Display.builder_rec
is
result : Display.builder_rec;
phaselen : constant Positive := phasestr'Length;
begin
-- 123456789 123456789 123456789 123456789 1234
-- SL elapsed phase lines origin
-- 01 00:00:00 extract-depends 9999999 www/joe
result.id := id;
result.slavid := JT.zeropad (Natural (id), 2);
result.LLines := (others => ' ');
result.phase := (others => ' ');
result.origin := (others => ' ');
result.shutdown := False;
result.idle := False;
if shutdown then
-- Overrides "idle" if both Shutdown and Idle are True
result.Elapsed := "Shutdown";
result.shutdown := True;
return result;
end if;
if idle then
result.Elapsed := "Idle ";
result.idle := True;
return result;
end if;
declare
catport : constant String :=
get_catport (all_ports (trackers (id).seq_id));
numlines : constant String := format_loglines (trackers (id).loglines);
linehead : constant Natural := 8 - numlines'Length;
begin
result.Elapsed := elapsed_HH_MM_SS (start => trackers (id).head_time,
stop => CAL.Clock);
result.LLines (linehead .. 7) := numlines;
if phaselen <= result.phase'Length then
result.phase (1 .. phasestr'Length) := phasestr;
else
-- special handling for long descriptions
if phasestr = "bootstrap-depends" then
result.phase (1 .. 14) := "bootstrap-deps";
else
result.phase := phasestr
(phasestr'First .. phasestr'First + result.phase'Length - 1);
end if;
end if;
if catport'Length > 37 then
result.origin (1 .. 36) := catport (1 .. 36);
result.origin (37) := LAT.Asterisk;
else
result.origin (1 .. catport'Length) := catport;
end if;
end;
return result;
end builder_status_core;
end PortScan.Buildcycle;
|
zhmu/ananas | Ada | 11,136 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- ADA.CONTAINERS.HASH_TABLES.GENERIC_BOUNDED_KEYS --
-- --
-- B o d y --
-- --
-- Copyright (C) 2004-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- This unit was originally developed by Matthew J Heaney. --
------------------------------------------------------------------------------
package body Ada.Containers.Hash_Tables.Generic_Bounded_Keys is
pragma Warnings (Off, "variable ""Busy*"" is not referenced");
pragma Warnings (Off, "variable ""Lock*"" is not referenced");
-- See comment in Ada.Containers.Helpers
-----------------------------
-- Checked_Equivalent_Keys --
-----------------------------
function Checked_Equivalent_Keys
(HT : aliased in out Hash_Table_Type'Class;
Key : Key_Type;
Node : Count_Type) return Boolean
is
Lock : With_Lock (HT.TC'Unrestricted_Access);
begin
return Equivalent_Keys (Key, HT.Nodes (Node));
end Checked_Equivalent_Keys;
-------------------
-- Checked_Index --
-------------------
function Checked_Index
(HT : aliased in out Hash_Table_Type'Class;
Key : Key_Type) return Hash_Type
is
Lock : With_Lock (HT.TC'Unrestricted_Access);
begin
return HT.Buckets'First + Hash (Key) mod HT.Buckets'Length;
end Checked_Index;
--------------------------
-- Delete_Key_Sans_Free --
--------------------------
procedure Delete_Key_Sans_Free
(HT : in out Hash_Table_Type'Class;
Key : Key_Type;
X : out Count_Type)
is
Indx : Hash_Type;
Prev : Count_Type;
begin
if HT.Length = 0 then
X := 0;
return;
end if;
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
TC_Check (HT.TC);
Indx := Checked_Index (HT, Key);
X := HT.Buckets (Indx);
if X = 0 then
return;
end if;
if Checked_Equivalent_Keys (HT, Key, X) then
TC_Check (HT.TC);
HT.Buckets (Indx) := Next (HT.Nodes (X));
HT.Length := HT.Length - 1;
return;
end if;
loop
Prev := X;
X := Next (HT.Nodes (Prev));
if X = 0 then
return;
end if;
if Checked_Equivalent_Keys (HT, Key, X) then
TC_Check (HT.TC);
Set_Next (HT.Nodes (Prev), Next => Next (HT.Nodes (X)));
HT.Length := HT.Length - 1;
return;
end if;
end loop;
end Delete_Key_Sans_Free;
----------
-- Find --
----------
function Find
(HT : Hash_Table_Type'Class;
Key : Key_Type) return Count_Type
is
Indx : Hash_Type;
Node : Count_Type;
begin
if HT.Length = 0 then
return 0;
end if;
Indx := Checked_Index (HT'Unrestricted_Access.all, Key);
Node := HT.Buckets (Indx);
while Node /= 0 loop
if Checked_Equivalent_Keys
(HT'Unrestricted_Access.all, Key, Node)
then
return Node;
end if;
Node := Next (HT.Nodes (Node));
end loop;
return 0;
end Find;
--------------------------------
-- Generic_Conditional_Insert --
--------------------------------
procedure Generic_Conditional_Insert
(HT : in out Hash_Table_Type'Class;
Key : Key_Type;
Node : out Count_Type;
Inserted : out Boolean)
is
Indx : Hash_Type;
begin
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
TC_Check (HT.TC);
Indx := Checked_Index (HT, Key);
Node := HT.Buckets (Indx);
if Node = 0 then
if Checks and then HT.Length = HT.Capacity then
raise Capacity_Error with "no more capacity for insertion";
end if;
Node := New_Node;
Set_Next (HT.Nodes (Node), Next => 0);
Inserted := True;
HT.Buckets (Indx) := Node;
HT.Length := HT.Length + 1;
return;
end if;
loop
if Checked_Equivalent_Keys (HT, Key, Node) then
Inserted := False;
return;
end if;
Node := Next (HT.Nodes (Node));
exit when Node = 0;
end loop;
if Checks and then HT.Length = HT.Capacity then
raise Capacity_Error with "no more capacity for insertion";
end if;
Node := New_Node;
Set_Next (HT.Nodes (Node), Next => HT.Buckets (Indx));
Inserted := True;
HT.Buckets (Indx) := Node;
HT.Length := HT.Length + 1;
end Generic_Conditional_Insert;
-----------------------------
-- Generic_Replace_Element --
-----------------------------
procedure Generic_Replace_Element
(HT : in out Hash_Table_Type'Class;
Node : Count_Type;
Key : Key_Type)
is
pragma Assert (HT.Length > 0);
pragma Assert (Node /= 0);
BB : Buckets_Type renames HT.Buckets;
NN : Nodes_Type renames HT.Nodes;
Old_Indx : Hash_Type;
New_Indx : constant Hash_Type := Checked_Index (HT, Key);
New_Bucket : Count_Type renames BB (New_Indx);
N, M : Count_Type;
begin
TC_Check (HT.TC);
-- Per AI05-0022, the container implementation is required to detect
-- element tampering by a generic actual subprogram.
-- The following block appears to be vestigial -- this should be done
-- using Checked_Index instead. Also, we might have to move the actual
-- tampering checks to the top of the subprogram, in order to prevent
-- infinite recursion when calling Hash. (This is similar to how Insert
-- and Delete are implemented.) This implies that we will have to defer
-- the computation of New_Index until after the tampering check. ???
declare
Lock : With_Lock (HT.TC'Unrestricted_Access);
begin
Old_Indx := HT.Buckets'First + Hash (NN (Node)) mod HT.Buckets'Length;
end;
-- Replace_Element is allowed to change a node's key to Key
-- (generic formal operation Assign provides the mechanism), but
-- only if Key is not already in the hash table. (In a unique-key
-- hash table as this one, a key is mapped to exactly one node.)
if Checked_Equivalent_Keys (HT, Key, Node) then
-- The new Key value is mapped to this same Node, so Node
-- stays in the same bucket.
Assign (NN (Node), Key);
return;
end if;
-- Key is not equivalent to Node, so we now have to determine if it's
-- equivalent to some other node in the hash table. This is the case
-- irrespective of whether Key is in the same or a different bucket from
-- Node.
N := New_Bucket;
while N /= 0 loop
if Checks and then Checked_Equivalent_Keys (HT, Key, N) then
pragma Assert (N /= Node);
raise Program_Error with
"attempt to replace existing element";
end if;
N := Next (NN (N));
end loop;
-- We have determined that Key is not already in the hash table, so
-- the change is tentatively allowed. We now perform the standard
-- checks to determine whether the hash table is locked (because you
-- cannot change an element while it's in use by Query_Element or
-- Update_Element), or if the container is busy (because moving a
-- node to a different bucket would interfere with iteration).
if Old_Indx = New_Indx then
-- The node is already in the bucket implied by Key. In this case
-- we merely change its value without moving it.
TE_Check (HT.TC);
Assign (NN (Node), Key);
return;
end if;
-- The node is in a bucket different from the bucket implied by Key.
-- Do the assignment first, before moving the node, so that if Assign
-- propagates an exception, then the hash table will not have been
-- modified (except for any possible side-effect Assign had on Node).
Assign (NN (Node), Key);
-- Now we can safely remove the node from its current bucket
N := BB (Old_Indx); -- get value of first node in old bucket
pragma Assert (N /= 0);
if N = Node then -- node is first node in its bucket
BB (Old_Indx) := Next (NN (Node));
else
pragma Assert (HT.Length > 1);
loop
M := Next (NN (N));
pragma Assert (M /= 0);
if M = Node then
Set_Next (NN (N), Next => Next (NN (Node)));
exit;
end if;
N := M;
end loop;
end if;
-- Now we link the node into its new bucket (corresponding to Key)
Set_Next (NN (Node), Next => New_Bucket);
New_Bucket := Node;
end Generic_Replace_Element;
-----------
-- Index --
-----------
function Index
(HT : Hash_Table_Type'Class;
Key : Key_Type) return Hash_Type is
begin
return HT.Buckets'First + Hash (Key) mod HT.Buckets'Length;
end Index;
end Ada.Containers.Hash_Tables.Generic_Bounded_Keys;
|
shintakezou/drake | Ada | 5,759 | adb | with Ada.Unchecked_Conversion;
with System.Storage_Map;
with C.basetsd;
with C.winternl;
package body System.Native_Tasks is
use type C.char_array;
use type C.windef.DWORD;
use type C.windef.WINBOOL;
use type C.winnt.HANDLE; -- C.void_ptr
type struct_THREAD_BASIC_INFORMATION is record
ExitStatus : C.winternl.NTSTATUS;
TebBaseAddress : C.winnt.struct_TEB_ptr; -- PVOID;
ClientId : C.winternl.CLIENT_ID;
AffinityMask : C.basetsd.KAFFINITY;
Priority : C.winternl.KPRIORITY;
BasePriority : C.winternl.KPRIORITY;
end record
with Convention => C;
pragma Suppress_Initialization (struct_THREAD_BASIC_INFORMATION);
type NtQueryInformationThread_Type is access function (
ThreadHandle : C.winnt.HANDLE;
ThreadInformationClass : C.winternl.THREADINFOCLASS;
ThreadInformation : C.winnt.PVOID;
ThreadInformationLength : C.windef.ULONG;
ReturnLength : access C.windef.ULONG)
return C.winternl.NTSTATUS
with Convention => WINAPI;
NtQueryInformationThread_Name : constant C.char_array (0 .. 24) :=
"NtQueryInformationThread" & C.char'Val (0);
procedure Nop is null;
Installed_Abort_Handler : not null Abort_Handler := Nop'Access;
-- implementation of thread
procedure Create (
Handle : aliased out Handle_Type;
Parameter : Parameter_Type;
Thread_Body : Thread_Body_Type;
Error : out Boolean)
is
Id : aliased C.windef.DWORD;
begin
Handle := C.winbase.CreateThread (
lpThreadAttributes => null,
dwStackSize => 0,
lpStartAddress => Thread_Body,
lpParameter => Parameter,
dwCreationFlags => 0,
lpThreadId => Id'Access);
Error := Handle = C.winbase.INVALID_HANDLE_VALUE;
end Create;
procedure Join (
Handle : Handle_Type;
Current_Abort_Event : access Synchronous_Objects.Event;
Result : aliased out Result_Type;
Error : out Boolean)
is
Signaled : C.windef.DWORD;
begin
Error := False;
if Current_Abort_Event /= null then
declare
Handles : aliased array (0 .. 1) of aliased C.winnt.HANDLE :=
(Handle, Synchronous_Objects.Handle (Current_Abort_Event.all));
begin
Signaled :=
C.winbase.WaitForMultipleObjects (
2,
Handles (0)'Access,
0,
C.winbase.INFINITE);
if Signaled /= C.winbase.WAIT_OBJECT_0 + 1 then
goto Done;
end if;
Installed_Abort_Handler.all; -- may abort child tasks
end;
end if;
Signaled := C.winbase.WaitForSingleObject (Handle, C.winbase.INFINITE);
<<Done>>
case Signaled is
when C.winbase.WAIT_OBJECT_0 =>
if C.winbase.GetExitCodeThread (Handle, Result'Access) =
C.windef.FALSE
then
Error := True;
end if;
when others =>
Error := True;
end case;
if C.winbase.CloseHandle (Handle) = C.windef.FALSE then
Error := True;
end if;
end Join;
procedure Detach (
Handle : in out Handle_Type;
Error : out Boolean) is
begin
Error := False;
if C.winbase.CloseHandle (Handle) /= C.windef.FALSE then
Handle := C.winbase.GetCurrentThread;
-- magic value meaning current thread
pragma Assert (
Handle = C.winnt.HANDLE (System'To_Address (16#fffffffe#)));
else
Error := True;
end if;
end Detach;
-- implementation of stack
function Info_Block (Handle : Handle_Type) return C.winnt.struct_TEB_ptr is
function To_NtQueryInformationThread_Type is
new Ada.Unchecked_Conversion (
C.windef.FARPROC,
NtQueryInformationThread_Type);
NtQueryInformationThread : NtQueryInformationThread_Type;
begin
NtQueryInformationThread :=
To_NtQueryInformationThread_Type (
C.winbase.GetProcAddress (
Storage_Map.NTDLL,
NtQueryInformationThread_Name (0)'Access));
if NtQueryInformationThread = null then
return null; -- ???
else
declare
TBI : aliased struct_THREAD_BASIC_INFORMATION;
ReturnLength : aliased C.windef.ULONG;
Dummy_Status : C.winternl.NTSTATUS;
begin
Dummy_Status := NtQueryInformationThread (
Handle,
C.winternl.ThreadBasicInformation,
C.windef.LPVOID (TBI'Address),
struct_THREAD_BASIC_INFORMATION'Size / Standard'Storage_Unit,
ReturnLength'Access);
return TBI.TebBaseAddress;
end;
end if;
end Info_Block;
-- implementation of signals
procedure Install_Abort_Handler (Handler : Abort_Handler) is
begin
Installed_Abort_Handler := Handler;
end Install_Abort_Handler;
procedure Uninstall_Abort_Handler is
begin
Installed_Abort_Handler := Nop'Access;
end Uninstall_Abort_Handler;
procedure Send_Abort_Signal (
Handle : Handle_Type;
Abort_Event : in out Synchronous_Objects.Event;
Error : out Boolean)
is
pragma Unreferenced (Handle);
begin
Synchronous_Objects.Set (Abort_Event);
Error := False;
end Send_Abort_Signal;
procedure Block_Abort_Signal (Abort_Event : Synchronous_Objects.Event) is
begin
-- check aborted
if Synchronous_Objects.Get (Abort_Event) then
Installed_Abort_Handler.all;
end if;
end Block_Abort_Signal;
procedure Yield is
begin
C.winbase.Sleep (0);
end Yield;
end System.Native_Tasks;
|
AdaCore/Ada_Drivers_Library | Ada | 7,072 | ads | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with HAL; use HAL;
with HAL.Framebuffer; use HAL.Framebuffer;
with HAL.Bitmap;
private with STM32.DMA2D_Bitmap;
private with STM32.LTDC;
package Framebuffer_LTDC is
type Frame_Buffer is abstract limited
new HAL.Framebuffer.Frame_Buffer_Display with private;
procedure Initialize
(Display : in out Frame_Buffer;
Width : Positive;
Height : Positive;
H_Sync : Natural;
H_Back_Porch : Natural;
H_Front_Porch : Natural;
V_Sync : Natural;
V_Back_Porch : Natural;
V_Front_Porch : Natural;
PLLSAI_N : UInt9;
PLLSAI_R : UInt3;
DivR : Natural;
Orientation : HAL.Framebuffer.Display_Orientation := Default;
Mode : HAL.Framebuffer.Wait_Mode := Interrupt);
overriding procedure Set_Orientation
(Display : in out Frame_Buffer;
Orientation : HAL.Framebuffer.Display_Orientation);
overriding procedure Set_Mode
(Display : in out Frame_Buffer;
Mode : HAL.Framebuffer.Wait_Mode);
overriding function Initialized
(Display : Frame_Buffer) return Boolean;
overriding function Max_Layers
(Display : Frame_Buffer) return Positive;
overriding function Supported
(Display : Frame_Buffer;
Mode : HAL.Framebuffer.FB_Color_Mode) return Boolean;
overriding function Width
(Display : Frame_Buffer) return Positive
with Pre => Display.Initialized;
overriding function Height
(Display : Frame_Buffer) return Positive
with Pre => Display.Initialized;
overriding function Swapped
(Display : Frame_Buffer) return Boolean;
overriding procedure Set_Background
(Display : Frame_Buffer; R, G, B : UInt8)
with Pre => Display.Initialized;
overriding procedure Initialize_Layer
(Display : in out Frame_Buffer;
Layer : Positive;
Mode : HAL.Framebuffer.FB_Color_Mode;
X : Natural := 0;
Y : Natural := 0;
Width : Positive := Positive'Last;
Height : Positive := Positive'Last)
with Pre =>
Initialized (Display) and then
Supported (Display, Mode) and then
not Initialized (Display, Layer) and then
Layer <= Max_Layers (Display);
-- All layers are double buffered, so an explicit call to Update_Layer
-- needs to be performed to actually display the current buffer attached
-- to the layer.
-- Alloc is called to create the actual buffer.
overriding function Initialized
(Display : Frame_Buffer;
Layer : Positive) return Boolean
with Pre =>
Initialized (Display) and then
Layer <= Max_Layers (Display);
overriding procedure Update_Layer
(Display : in out Frame_Buffer;
Layer : Positive;
Copy_Back : Boolean := False)
with Pre => Initialized (Display, Layer);
-- Updates the layer so that the hidden buffer is displayed.
-- If Copy_Back is set, then the newly displayed buffer will be copied back
-- the the hidden buffer
overriding procedure Update_Layers
(Display : in out Frame_Buffer)
with Pre => Initialized (Display);
-- Updates all initialized layers at once with their respective hidden
-- buffer
procedure Update_Layers
(Display : in out Frame_Buffer;
Copy_Layer1 : Boolean;
Copy_Layer2 : Boolean)
with Pre => Initialized (Display);
-- Updates all initialized layers at once with their respective hidden
-- buffer
overriding function Color_Mode
(Display : Frame_Buffer;
Layer : Positive) return HAL.Framebuffer.FB_Color_Mode
with Pre => Initialized (Display, Layer);
overriding function Hidden_Buffer
(Display : in out Frame_Buffer;
Layer : Positive) return not null HAL.Bitmap.Any_Bitmap_Buffer
with Pre => Initialized (Display, Layer);
-- Retrieves the current hidden buffer for the layer.
overriding function Pixel_Size
(Display : Frame_Buffer;
Layer : Positive) return Positive
with Pre => Initialized (Display, Layer);
private
type FB_Array is array (STM32.LTDC.LCD_Layer, 1 .. 2) of
aliased STM32.DMA2D_Bitmap.DMA2D_Bitmap_Buffer;
type Buffer_Idx is range 0 .. 2;
type FB_Current is array (STM32.LTDC.LCD_Layer) of Buffer_Idx;
type Frame_Buffer is abstract limited
new HAL.Framebuffer.Frame_Buffer_Display with record
Swapped : Boolean := False;
Width : Natural;
Height : Natural;
Buffers : FB_Array :=
(others => (others => STM32.DMA2D_Bitmap.Null_Buffer));
Current : FB_Current := (others => 0);
end record;
end Framebuffer_LTDC;
|
zhmu/ananas | Ada | 9,194 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- I N T E R F A C E S . V X W O R K S --
-- --
-- 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/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
-- This is the x86 VxWorks version of this package
-- This package provides a limited binding to the VxWorks API
-- In particular, it interfaces with the VxWorks hardware interrupt
-- facilities, allowing the use of low-latency direct-vectored
-- interrupt handlers. Note that such handlers have a variety of
-- restrictions regarding system calls and language constructs. In particular,
-- the use of exception handlers and functions returning variable-length
-- objects cannot be used. Less restrictive, but higher-latency handlers can
-- be written using Ada protected procedures, Ada 83 style interrupt entries,
-- or by signalling an Ada task from within an interrupt handler using a
-- binary semaphore as described in the VxWorks Programmer's Manual.
--
-- For complete documentation of the operations in this package, please
-- consult the VxWorks Programmer's Manual and VxWorks Reference Manual.
pragma Warnings (Off, "*foreign convention*");
pragma Warnings (Off, "*add Convention pragma*");
with System.VxWorks;
package Interfaces.VxWorks is
pragma Preelaborate;
------------------------------------------------------------------------
-- Here is a complete example that shows how to handle the Interrupt 0x33
-- with a direct-vectored interrupt handler in Ada using this package:
-- with Interfaces.VxWorks; use Interfaces.VxWorks;
-- with System;
--
-- package P is
--
-- Count : Integer;
-- pragma Atomic (Count);
--
-- procedure Handler (Parameter : System.Address);
--
-- end P;
--
-- package body P is
--
-- procedure Handler (Parameter : System.Address) is
-- begin
-- Count := Count + 1;
-- logMsg ("received an interrupt" & ASCII.LF & ASCII.NUL);
-- end Handler;
-- end P;
--
-- with Interfaces.VxWorks; use Interfaces.VxWorks;
-- with Ada.Text_IO; use Ada.Text_IO;
-- with Ada.Interrupts;
-- with Machine_Code; use Machine_Code;
--
-- with P; use P;
-- procedure Useint is
--
-- -- Be sure to use a reasonable interrupt number for target board.
-- -- This one is an unreserved interrupt for the Pentium 3 BSP
--
-- Interrupt : constant := 16#33#;
--
-- task T;
--
-- S : STATUS;
--
-- task body T is
-- begin
-- loop
-- Put_Line ("Generating an interrupt...");
-- delay 1.0;
--
-- -- Generate interrupt, using interrupt number
--
-- Asm ("int %0",
-- Inputs =>
-- Ada.Interrupts.Interrupt_ID'Asm_Input
-- ("i", Interrupt));
-- end loop;
-- end T;
--
-- begin
-- S := intConnect (INUM_TO_IVEC (Interrupt), Handler'Access);
--
-- loop
-- delay 2.0;
-- Put_Line ("value of count:" & P.Count'Img);
-- end loop;
-- end Useint;
-------------------------------------
subtype int is Integer;
type STATUS is new int;
-- Equivalent of the C type STATUS
OK : constant STATUS := 0;
ERROR : constant STATUS := -1;
type BOOL is new int;
-- Equivalent of the C type BOOL
type VOIDFUNCPTR is access procedure (parameter : System.Address);
type Interrupt_Vector is new System.Address;
type Exception_Vector is new System.Address;
function intConnect
(vector : Interrupt_Vector;
handler : VOIDFUNCPTR;
parameter : System.Address := System.Null_Address) return STATUS;
-- Binding to the C routine intConnect. Use this to set up an user handler.
-- The routine generates a wrapper around the user handler to save and
-- restore context
function intContext return BOOL;
-- Binding to the C routine intContext. This function returns 1 (TRUE)
-- only if the current execution state is in interrupt context.
function intVecGet
(Vector : Interrupt_Vector) return VOIDFUNCPTR;
-- Binding to the C routine intVecGet. Use this to get the existing handler
-- for later restoral
procedure intVecSet
(Vector : Interrupt_Vector;
Handler : VOIDFUNCPTR);
-- Binding to the C routine intVecSet. Use this to restore a handler
-- obtained using intVecGet
procedure intVecGet2
(vector : Interrupt_Vector;
pFunction : out VOIDFUNCPTR;
pIdtGate : not null access int;
pIdtSelector : not null access int);
-- Binding to the C routine intVecGet2. Use this to get the existing
-- handler for later restoral
procedure intVecSet2
(vector : Interrupt_Vector;
pFunction : VOIDFUNCPTR;
pIdtGate : not null access int;
pIdtSelector : not null access int);
-- Binding to the C routine intVecSet2. Use this to restore a
-- handler obtained using intVecGet2
function INUM_TO_IVEC (intNum : int) return Interrupt_Vector;
-- Equivalent to the C macro INUM_TO_IVEC used to convert an interrupt
-- number to an interrupt vector
procedure logMsg
(fmt : String; arg1, arg2, arg3, arg4, arg5, arg6 : int := 0);
-- Binding to the C routine logMsg. Note that it is the caller's
-- responsibility to ensure that fmt is a null-terminated string
-- (e.g logMsg ("Interrupt" & ASCII.NUL))
type FP_CONTEXT is private;
-- Floating point context save and restore. Handlers using floating point
-- must be bracketed with these calls. The pFpContext parameter should be
-- an object of type FP_CONTEXT that is declared local to the handler.
--
-- See the VxWorks Intel Architecture Supplement regarding these routines
procedure fppRestore (pFpContext : in out FP_CONTEXT);
-- Restore floating point context - old style
procedure fppSave (pFpContext : in out FP_CONTEXT);
-- Save floating point context - old style
procedure fppXrestore (pFpContext : in out FP_CONTEXT);
-- Restore floating point context - new style
procedure fppXsave (pFpContext : in out FP_CONTEXT);
-- Save floating point context - new style
private
type FP_CONTEXT is new System.VxWorks.FP_CONTEXT;
-- Target-dependent floating point context type
pragma Import (C, intConnect, "intConnect");
pragma Import (C, intContext, "intContext");
pragma Import (C, intVecGet, "intVecGet");
pragma Import (C, intVecSet, "intVecSet");
pragma Import (C, intVecGet2, "intVecGet2");
pragma Import (C, intVecSet2, "intVecSet2");
pragma Import (C, INUM_TO_IVEC, "__gnat_inum_to_ivec");
pragma Import (C, logMsg, "logMsg");
pragma Import (C, fppRestore, "fppRestore");
pragma Import (C, fppSave, "fppSave");
pragma Import (C, fppXrestore, "fppXrestore");
pragma Import (C, fppXsave, "fppXsave");
end Interfaces.VxWorks;
|
reznikmm/matreshka | Ada | 3,777 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- 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$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.UML.Classifiers;
package AMF.OCL.Void_Types is
pragma Preelaborate;
type OCL_Void_Type is limited interface
and AMF.UML.Classifiers.UML_Classifier;
type OCL_Void_Type_Access is
access all OCL_Void_Type'Class;
for OCL_Void_Type_Access'Storage_Size use 0;
end AMF.OCL.Void_Types;
|
stcarrez/ada-util | Ada | 14,158 | ads | --
-- Copyright (c) 2007-2009, 2022 Tero Koskinen <[email protected]>
--
-- Permission to use, copy, modify, and distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
--
with Ada.Finalization;
with Ahven.Listeners;
with Ahven.SList;
with Ahven.AStrings;
pragma Elaborate_All (Ahven);
pragma Elaborate_All (Ahven.SList);
package Ahven.Framework is
Three_Hours : constant := 10800.0;
subtype Test_Duration is Duration range 0.0 .. Three_Hours;
type Test_Count_Type is new Natural;
-- Type for the test count. This effectively
-- limits the amount tests to whatever Natural is.
--
-- Although, in practice when adding tests the limit
-- is not checked.
type Test is abstract new Ada.Finalization.Controlled with null record;
-- A type, which provides the base for Test_Case and
-- Test_Suite types.
type Test_Class_Access is access all Test'Class;
procedure Set_Up (T : in out Test);
-- Set_Up is called before executing the test procedure.
--
-- By default, the procedure does nothing, but derived
-- types can overwrite this method and add their own
-- customisations.
--
-- One should not call this explicitly by herself.
-- The framework calls it when necessary.
procedure Tear_Down (T : in out Test);
-- Tear_Down is called after the test procedure is executed.
--
-- By default, the procedure does nothing, but derived
-- types can overwrite this method and add their own
-- customisations.
--
-- One should not call this explicitly by herself.
-- The framework calls it when necessary.
function Get_Name (T : Test) return String is abstract;
-- Return the name of the test.
--
-- Types derived from the Test type are required to overwrite
-- this procedure.
procedure Run (T : in out Test;
Listener : in out Listeners.Result_Listener'Class);
-- Run the test and place the test result to Result.
--
-- Calls Run (T, Listener, Timeout) with Timeout value 0.0.
procedure Run (T : in out Test;
Listener : in out Listeners.Result_Listener'Class;
Timeout : Test_Duration)
is abstract;
-- Run the test and place the test result to Result.
-- Timeout specifies the maximum runtime for a single test.
--
-- Types derived from the Test type are required to overwrite
-- this procedure.
procedure Run (T : in out Test;
Test_Name : String;
Listener : in out Listeners.Result_Listener'Class);
-- Run the test and place the test result to Result.
--
-- Calls Run (T, Test_Name, Listener, Timeout) with Timeout value 0.0.
procedure Run (T : in out Test;
Test_Name : String;
Listener : in out Listeners.Result_Listener'Class;
Timeout : Test_Duration)
is abstract;
-- Run the test with given name and place the test result to Result.
-- Timeout specifies the maximum runtime for a single test.
-- Notice: If multiple tests have same name this might call all of
-- them.
--
-- Types derived from the Test type are required to overwrite
-- this procedure.
function Test_Count (T : Test) return Test_Count_Type is abstract;
-- Return the amount of tests (test routines) which will be executed when
-- the Run (T) procedure is called.
function Test_Count (T : Test; Test_Name : String)
return Test_Count_Type is abstract;
-- Return the amount of tests (test routines) which will be executed when
-- the Run (T, Test_Name) procedure is called.
procedure Execute (T : in out Test'Class;
Listener : in out Listeners.Result_Listener'Class;
Timeout : Test_Duration);
-- Call Test class' Run method and place the test outcome to Result.
-- The procedure calls Start_Test of every listener before calling
-- the Run procedure and End_Test after calling the Run procedure.
--
-- This procedure is meant to be called from Runner package(s).
-- There should be no need for other to use this.
procedure Execute (T : in out Test'Class;
Test_Name : String;
Listener : in out Listeners.Result_Listener'Class;
Timeout : Test_Duration);
-- Same as Execute above, but call the Run procedure which
-- takes Test_Name parameter.
type Test_Case is abstract new Test with private;
-- The base type for other test cases.
overriding
function Get_Name (T : Test_Case) return String;
-- Return the name of the test case.
overriding
procedure Run (T : in out Test_Case;
Listener : in out Listeners.Result_Listener'Class;
Timeout : Test_Duration);
-- Run Test_Case's test routines.
overriding
procedure Run (T : in out Test_Case;
Test_Name : String;
Listener : in out Listeners.Result_Listener'Class;
Timeout : Test_Duration);
-- Run Test_Case's test routine which matches to the Name.
overriding
function Test_Count (T : Test_Case) return Test_Count_Type;
-- Implementation of Test_Count (T : Test).
overriding
function Test_Count (T : Test_Case; Test_Name : String)
return Test_Count_Type;
-- Implementation of Test_Count (T : Test, Test_Name : String).
overriding
procedure Finalize (T : in out Test_Case);
-- Finalize procedure of the Test_Case.
procedure Set_Name (T : in out Test_Case; Name : String);
-- Set Test_Case's name.
--
-- If longer than 160 characters, the name is truncated
-- to 160 characters.
type Object_Test_Routine_Access is
access procedure (T : in out Test_Case'Class);
-- A pointer to a test routine which takes Test_Case'Class object
-- as an argument.
--
-- For this kind of test routines, the framework will
-- call Set_Up and Tear_Down routines before and after
-- test routine execution.
type Simple_Test_Routine_Access is access procedure;
-- A pointer to a test routine which does not take arguments.
procedure Add_Test_Routine (T : in out Test_Case'Class;
Routine : Object_Test_Routine_Access;
Name : String);
-- Register a test routine to the Test_Case object.
--
-- The routine must have signature
-- "procedure R (T : in out Test_Case'Class)".
procedure Add_Test_Routine (T : in out Test_Case'Class;
Routine : Simple_Test_Routine_Access;
Name : String);
-- Register a simple test routine to the Test_Case.
--
-- The routine must have signature
-- "procedure R".
type Test_Suite is new Test with private;
-- A collection of Tests.
--
-- You can either fill a Test_Suite object with Test_Case objects
-- or nest multiple Test_Suite objects. You can even mix
-- Test_Case and Test_Suite objects, if necessary.
type Test_Suite_Access is access all Test_Suite;
function Create_Suite (Suite_Name : String)
return Test_Suite_Access;
-- Create a new Test_Suite.
-- Caller must free the returned Test_Suite using Release_Suite.
function Create_Suite (Suite_Name : String)
return Test_Suite;
-- Create a new Test_Suite. The suite and its children are
-- released automatically.
procedure Add_Test (Suite : in out Test_Suite; T : Test_Class_Access);
-- Add a Test to the suite. The suite frees the Test automatically
-- when it is no longer needed.
procedure Add_Test (Suite : in out Test_Suite; T : Test_Suite_Access);
-- Add a Test suite to the suite. The suite frees the Test automatically
-- when it is no longer needed.
--
-- This is a helper function, which internally calls
-- Add_Test (Suite : in out Test_Suite; T : Test_Class_Access).
procedure Add_Static_Test
(Suite : in out Test_Suite; T : Test'Class);
-- Add a Test to the suite. This procedure is meant for statically
-- allocated Test_Case objects.
--
-- Please note, that a copy of the Test'Class object is saved to
-- the suite. Original test object is not modified and changes
-- made to it after adding the test are not propagated to
-- the added object.
overriding
function Get_Name (T : Test_Suite) return String;
-- Return the name of Test_Suite.
overriding
procedure Run (T : in out Test_Suite;
Listener : in out Listeners.Result_Listener'Class;
Timeout : Test_Duration);
-- Run Test_Suite's Test_Cases.
overriding
procedure Run (T : in out Test_Suite;
Test_Name : String;
Listener : in out Listeners.Result_Listener'Class;
Timeout : Test_Duration);
-- Run test suite's child which matches to the given name.
overriding
function Test_Count (T : Test_Suite) return Test_Count_Type;
-- Implementation of Test_Count (T : Test).
overriding
function Test_Count (T : Test_Suite; Test_Name : String)
return Test_Count_Type;
-- Implementation of Test_Count (T : Test, Test_Name : String).
overriding
procedure Adjust (T : in out Test_Suite);
-- Adjust procedure of Test_Suite.
-- Handles the copying of the structure properly
overriding
procedure Finalize (T : in out Test_Suite);
-- Finalize procedure of Test_Suite. Frees all added Tests.
procedure Release_Suite (T : Test_Suite_Access);
-- Release the memory of Test_Suite.
-- All added tests are released automatically.
procedure Set_Logging (Flag : in Boolean);
-- Enable or disable traces before/after test execution.
private
type Command_Object_Enum is (SIMPLE, OBJECT);
type Test_Command (Command_Kind : Command_Object_Enum := SIMPLE) is record
Name : AStrings.Bounded_String;
case Command_Kind is
when SIMPLE =>
Simple_Routine : Simple_Test_Routine_Access;
when OBJECT =>
Object_Routine : Object_Test_Routine_Access;
end case;
end record;
-- Name attribute tells the name of the test routine.
procedure Run (Command : Test_Command; T : in out Test_Case'Class);
-- Run the specified command.
-- Calls Set_Up and Tear_Down if necessary.
package Test_Command_List is
new Ahven.SList (Element_Type => Test_Command);
type Test_Case is abstract new Test with record
Routines : Test_Command_List.List := Test_Command_List.Empty_List;
Name : AStrings.Bounded_String := AStrings.Null_Bounded_String;
end record;
-- Our test case type. It holds a list of test routines
-- (test command objects) and the name of the test case.
procedure Run_Command (Command : Test_Command;
Info : Listeners.Context;
Timeout : Test_Duration;
Listener : in out Listeners.Result_Listener'Class;
T : in out Test_Case'Class);
-- Handle dispatching to the right Run (Command : Test_Command)
-- procedure and record test routine result to the Result object.
--
-- Timeout parameter defines the longest time the test is allowed
-- to run. Value 0.0 means infinite time.
type Test_Class_Wrapper is record
Ptr : Test_Class_Access;
end record;
package Test_List is
new Ahven.SList (Element_Type => Test_Class_Wrapper);
package Indefinite_Test_List is
type List is new Ada.Finalization.Controlled with private;
Empty_List : constant List;
procedure Append (Target : in out List; Node_Data : Test'Class);
-- Append an element at the end of the list.
procedure Clear (Target : in out List);
-- Remove all elements from the list.
generic
with procedure Action (T : in out Test'Class) is <>;
procedure For_Each (Target : List);
-- A generic procedure for walk through every item
-- in the list and call Action procedure for them.
private
type Node;
type Node_Access is access Node;
procedure Remove (Ptr : Node_Access);
-- A procedure to release memory pointed by Ptr.
type Node is record
Next : Node_Access := null;
Data : Test_Class_Access := null;
end record;
type List is new Ada.Finalization.Controlled with record
First : Node_Access := null;
Last : Node_Access := null;
end record;
overriding
procedure Initialize (Target : in out List);
overriding
procedure Finalize (Target : in out List);
overriding
procedure Adjust (Target : in out List);
Empty_List : constant List :=
(Ada.Finalization.Controlled with First => null,
Last => null);
end Indefinite_Test_List;
type Test_Suite is new Test with record
Suite_Name : AStrings.Bounded_String := AStrings.Null_Bounded_String;
Test_Cases : Test_List.List := Test_List.Empty_List;
Static_Test_Cases : Indefinite_Test_List.List :=
Indefinite_Test_List.Empty_List;
end record;
-- A suite type which holds a list of test cases and the name
-- of the suite.
end Ahven.Framework;
|
stcarrez/ada-css | Ada | 4,089 | ads | private package CSS.Analysis.Parser.Parser_Goto is
type Rule is new Natural;
type Nonterminal is new Integer;
type Small_Integer is range -32_000 .. 32_000;
subtype Small_Nonterminal is Nonterminal range -32_000 .. 32_000;
type Goto_Entry is record
Nonterm : Small_Nonterminal;
Newstate : Small_Integer;
end record;
-- pragma suppress(index_check);
type Row is new Integer range -1 .. Integer'Last;
type Goto_Parse_Table is array (Row range <>) of Goto_Entry;
Goto_Matrix : constant Goto_Parse_Table :=
((-1, -1) -- Dummy Entry.
-- State 0
, (-6, 7), (-5, 5), (-4, 3), (-3, 2), (-2, 1)
-- State 1
, (-6, 7), (-5, 5), (-3, 11)
-- State 5
, (-4, 13)
-- State 7
, (-4, 14)
-- State 16
, (-4, 20)
-- State 17
, (-4, 21)
-- State 20
, (-17, 30), (-16, 29), (-14, 28), (-13, 27), (-12, 26)
, (-11, 25), (-10, 24), (-9, 23), (-8, 22), (-7, 37)
-- State 21
, (-17, 30), (-16, 29), (-14, 28), (-13, 27), (-12, 26)
, (-11, 25), (-10, 24), (-9, 23), (-8, 22), (-7, 38)
-- State 22
, (-4, 39)
-- State 23
, (-4, 40)
-- State 24
, (-4, 41)
-- State 25
, (-4, 42)
-- State 26
, (-4, 43)
-- State 27
, (-4, 44)
-- State 28
, (-15, 51), (-4, 46)
-- State 31
, (-4, 52)
-- State 43
, (-17, 30), (-16, 29), (-14, 28), (-13, 59)
-- State 48
, (-15, 61), (-4, 46)
-- State 49
, (-15, 62), (-4, 46)
-- State 50
, (-15, 63), (-4, 46)
-- State 52
, (-17, 30), (-16, 29), (-14, 28), (-13, 27), (-12, 26)
, (-11, 25), (-10, 24), (-9, 23), (-8, 22), (-7, 64)
-- State 53
, (-4, 65)
-- State 54
, (-4, 66)
-- State 55
, (-4, 67)
-- State 56
, (-4, 68)
-- State 57
, (-4, 69)
-- State 58
, (-4, 70)
-- State 59
, (-4, 71)
-- State 65
, (-17, 30), (-16, 29), (-14, 28), (-13, 27), (-12, 26)
, (-11, 25), (-10, 24), (-9, 23), (-8, 22), (-7, 75)
-- State 66
, (-17, 30), (-16, 29), (-14, 28), (-13, 27), (-12, 26)
, (-11, 25), (-10, 24), (-9, 76)
-- State 67
, (-17, 30), (-16, 29), (-14, 28), (-13, 27), (-12, 26)
, (-11, 25), (-10, 77)
-- State 68
, (-17, 30), (-16, 29), (-14, 28), (-13, 27), (-12, 26)
, (-11, 78)
-- State 69
, (-17, 30), (-16, 29), (-14, 28), (-13, 27), (-12, 79)
-- State 70
, (-17, 30), (-16, 29), (-14, 28), (-13, 80)
-- State 75
, (-4, 84)
-- State 76
, (-4, 40)
-- State 77
, (-4, 41)
-- State 78
, (-4, 42)
-- State 79
, (-4, 43)
-- State 80
, (-4, 85)
);
-- The offset vector
Goto_Offset : constant array (0 .. 87) of Row :=
(0,
5, 8, 8, 8, 8, 9, 9, 10, 10, 10,
10, 10, 10, 10, 10, 10, 11, 12, 12, 12,
22, 32, 33, 34, 35, 36, 37, 38, 40, 40,
40, 41, 41, 41, 41, 41, 41, 41, 41, 41,
41, 41, 41, 45, 45, 45, 45, 45, 47, 49,
51, 51, 61, 62, 63, 64, 65, 66, 67, 68,
68, 68, 68, 68, 68, 78, 86, 93, 99, 104,
108, 108, 108, 108, 108, 109, 110, 111, 112, 113,
114, 114, 114, 114, 114, 114, 114);
Rule_Length : constant array (Rule range 0 .. 51) of Natural := (2,
2, 1, 1, 1, 2, 2, 1, 0, 5, 5, 2, 3, 3, 1, 1, 1, 5, 1, 5, 1, 5, 1, 5,
1, 4, 6, 2, 2, 3, 3, 3, 2, 1, 1, 6, 1, 1, 1, 1, 1, 3, 1, 5, 4, 1, 5,
4, 5, 4, 3, 1);
Get_LHS_Rule : constant array (Rule range 0 .. 51) of Nonterminal := (-1,
-2, -2, -2, -2, -3, -4, -4, -4, -5, -5, -5, -6, -6, -6,
-6, -7, -8, -8, -9, -9, -10, -10, -11, -11, -12, -12, -12, -13,
-13, -13, -13, -13, -14, -14, -17, -17, -17, -17, -17, -17, -18, -18,
-19, -19, -19, -16, -16, -15, -15, -15, -15);
end CSS.Analysis.Parser.Parser_Goto;
|
stcarrez/ada-el | Ada | 2,845 | adb | -----------------------------------------------------------------------
-- el-contexts-properties -- EL Resolver using util properties
-- Copyright (C) 2011, 2021 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Beans.Objects;
package body EL.Contexts.Properties is
-- ------------------------------
-- Set the properties used for resolving values.
-- ------------------------------
procedure Set_Properties (Resolver : in out Property_Resolver;
Properties : in Util.Properties.Manager'Class) is
begin
Resolver.Props := Util.Properties.Manager (Properties);
end Set_Properties;
-- ------------------------------
-- Get the value associated with a base object and a given property.
-- ------------------------------
overriding
function Get_Value (Resolver : in Property_Resolver;
Context : in ELContext'Class;
Base : access Util.Beans.Basic.Readonly_Bean'Class;
Name : in Unbounded_String) return EL.Objects.Object is
pragma Unreferenced (Context);
begin
if Base /= null then
return Base.Get_Value (To_String (Name));
elsif Resolver.Props.Exists (Name) then
return Util.Beans.Objects.To_Object (String '(Resolver.Props.Get (Name)));
else
return Util.Beans.Objects.Null_Object;
end if;
end Get_Value;
-- ------------------------------
-- Set the value associated with a base object and a given property.
-- ------------------------------
overriding
procedure Set_Value (Resolver : in out Property_Resolver;
Context : in ELContext'Class;
Base : access Util.Beans.Basic.Bean'Class;
Name : in Unbounded_String;
Value : in EL.Objects.Object) is
pragma Unreferenced (Context);
begin
if Base /= null then
Base.Set_Value (To_String (Name), Value);
else
Resolver.Props.Set (Name, Util.Beans.Objects.To_Unbounded_String (Value));
end if;
end Set_Value;
end EL.Contexts.Properties;
|
PThierry/ewok-kernel | Ada | 2,784 | ads | --
-- Copyright 2018 The wookey project team <[email protected]>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with soc.gpio;
with ewok.exported.gpios;
with ewok.tasks_shared; use ewok.tasks_shared;
with ewok.devices_shared; use ewok.devices_shared;
package ewok.gpio
with spark_mode => off
is
function is_used
(ref : ewok.exported.gpios.t_gpio_ref)
return boolean;
procedure register
(task_id : in ewok.tasks_shared.t_task_id;
device_id : in ewok.devices_shared.t_device_id;
conf_a : in ewok.exported.gpios.t_gpio_config_access;
success : out boolean);
procedure release
(task_id : in ewok.tasks_shared.t_task_id;
device_id : in ewok.devices_shared.t_device_id;
conf_a : in ewok.exported.gpios.t_gpio_config_access);
procedure config
(conf : in ewok.exported.gpios.t_gpio_config_access);
procedure write_pin
(ref : in ewok.exported.gpios.t_gpio_ref;
value : in bit);
function read_pin
(ref : in ewok.exported.gpios.t_gpio_ref)
return bit;
function belong_to
(task_id : in ewok.tasks_shared.t_task_id;
ref : in ewok.exported.gpios.t_gpio_ref)
return boolean;
function get_task_id
(ref : in ewok.exported.gpios.t_gpio_ref)
return ewok.tasks_shared.t_task_id;
function get_device_id
(ref : in ewok.exported.gpios.t_gpio_ref)
return ewok.devices_shared.t_device_id;
function get_config
(ref : in ewok.exported.gpios.t_gpio_ref)
return ewok.exported.gpios.t_gpio_config_access;
private
type t_gpio_state is record
used : boolean := false;
task_id : ewok.tasks_shared.t_task_id;
device_id : ewok.devices_shared.t_device_id;
config : ewok.exported.gpios.t_gpio_config_access;
end record;
-- Keep track of used GPIO points
gpio_points : array (soc.gpio.t_gpio_port_index, soc.gpio.t_gpio_pin_index)
of t_gpio_state :=
(others => (others => (false, ID_UNUSED, ID_DEV_UNUSED, NULL)));
end ewok.gpio;
|
reznikmm/matreshka | Ada | 3,420 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package Properties.Statements is
pragma Pure;
end Properties.Statements;
|
damaki/libkeccak | Ada | 1,954 | adb | -------------------------------------------------------------------------------
-- Copyright (c) 2019, Daniel King
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
-- * Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * The name of the copyright holder may not be used to endorse or promote
-- Products derived from this software without specific prior written
-- permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
with KAT.Parallel_Hash_Runner;
with Parallel_Hash;
procedure ParallelHashXOF_256_KAT
is
package Runner is new KAT.Parallel_Hash_Runner (Parallel_Hash.ParallelHash256, True);
begin
Runner.Run_Tests;
end ParallelHashXOF_256_KAT;
|
rveenker/sdlada | Ada | 7,213 | adb | with Ada.Directories;
with Ada.Text_IO;
with SDL.RWops.Streams;
procedure Rwops is
package Text_IO renames Ada.Text_IO;
package Directories renames Ada.Directories;
procedure RWops_Tests is
begin
declare
use type SDL.RWops.Offsets;
Op : constant SDL.RWops.RWops := SDL.RWops.From_File ("test", SDL.RWops.Read_Binary);
Offset : SDL.RWops.Offsets := SDL.RWops.Error_Offset;
begin
Text_IO.Put_Line ("Testing RW_Seek, RW_Tell and RW_Size:");
-- Moving the file offset in steps of size 10.
for I in 1 .. 10 loop
Offset := SDL.RWops.Seek (Context => Op,
Offset => 10,
Whence => SDL.RWops.RW_Seek_Cur);
Text_IO.Put ("Current offset (should be" & Integer'Image (10 * I) & "):");
Text_IO.Put (SDL.RWops.Offsets'Image (Offset) & " (returned value) ");
Offset := SDL.RWops.Tell (Context => Op);
Text_IO.Put (SDL.RWops.Offsets'Image (Offset) & " (from RW_Tell)");
Text_IO.New_Line;
end loop;
Text_IO.New_Line;
Offset := SDL.RWops.Seek
(Context => Op,
Offset => -10,
Whence => SDL.RWops.RW_Seek_End);
Text_IO.Put_Line ("offset 10 before end of file:" & SDL.RWops.Offsets'Image (Offset));
Offset := SDL.RWops.Size (Op);
Text_IO.Put_Line ("offset Rw_Size (should be previous value + 10):" & SDL.RWops.Offsets'Image (Offset));
SDL.RWops.Close (Op);
end;
declare
use type SDL.RWops.Offsets;
Op : constant SDL.RWops.RWops := SDL.RWops.From_File ("test.bin", SDL.RWops.Create_To_Write);
begin
Text_IO.New_Line;
Text_IO.Put_Line ("Writing some numbers as Uint8 into a file...");
for I in 1 .. 16 loop
SDL.RWops.Write_U_8 (Op, SDL.RWops.Uint8 (I));
end loop;
SDL.RWops.Close (Op);
end;
declare
use type SDL.RWops.Offsets;
Op : SDL.RWops.RWops := SDL.RWops.From_File ("test.bin", SDL.RWops.Read_Binary);
Result8 : SDL.RWops.Uint8 := 0;
Result32 : SDL.RWops.Uint32 := 0;
begin
Text_IO.Put_Line ("Reading Uint8 from file...");
for I in 1 .. 16 loop
Result8 := SDL.RWops.Read_U_8 (Op);
Text_IO.Put_Line ("read Uint8:" & SDL.RWops.Uint8'Image (Result8));
end loop;
SDL.RWops.Close (Op);
Text_IO.New_Line;
Text_IO.Put_Line ("Reading Uint32 from file...");
SDL.RWops.From_File ("test.bin", SDL.RWops.Read_Binary, Op);
for I in 1 .. 4 loop
Result32 := SDL.RWops.Read_LE_32 (Op);
Text_IO.Put_Line ("read Uint32:" & SDL.RWops.Uint32'Image (Result32));
end loop;
SDL.RWops.Close (Op);
end;
Text_IO.New_Line;
Text_IO.Put_Line ("Base path: " & SDL.RWops.Base_Path);
declare
Tmp_Path : constant String := Directories.Current_Directory;
Pref_Path : constant String := SDL.RWops.Preferences_Path ("org", "app");
begin
Text_IO.Put_Line ("Pref path: " & Pref_Path);
if Directories.Exists (Pref_Path) then
-- Remove app/org if it was created.
Directories.Set_Directory (Pref_Path);
Directories.Set_Directory ("..");
Directories.Delete_Directory ("app");
Directories.Set_Directory ("..");
Directories.Delete_Directory ("org");
Directories.Set_Directory (Tmp_Path);
end if;
end;
end RWops_Tests;
procedure RWops_Streams_Test is
-- Dummy type to write into and read from stream.
type Complicated_Union (B : Boolean := True) is
record
I : Integer := 0;
S : String (1 .. 5) := "hello";
case B is
when True =>
T : String (1 .. 4) := "true";
F : Long_Float := 3.14159265;
when False =>
C : Character := 'X';
end case;
end record;
begin
Text_IO.Put_Line ("Testing RWops.Streams:");
Text_IO.Put_Line ("Creating file-stream ""out.bin""...");
declare
W_Stream : aliased SDL.RWops.Streams.RWops_Stream := SDL.RWops.Streams.Open
(SDL.RWops.From_File
("out.bin",
SDL.RWops.Create_To_Write_Binary));
I : constant Integer := 42;
S : constant String := "Hello, world!!!";
T_True : Complicated_Union;
T_False : Complicated_Union (False);
begin
Text_IO.Put_Line ("Writing:" & I'Img);
Integer'Write (W_Stream'Access, I);
Text_IO.Put_Line ("Writing: " & S);
String'Write (W_Stream'Access, S);
Text_IO.Put_Line ("Writing two objects of a more complex type...");
Complicated_Union'Output (W_Stream'Access, T_True);
Complicated_Union'Output (W_Stream'Access, T_False);
Text_IO.Put_Line ("Closing stream.");
W_Stream.Close;
end;
declare
R_Stream : aliased SDL.RWops.Streams.RWops_Stream := SDL.RWops.Streams.Open
(SDL.RWops.From_File
("out.bin",
SDL.RWops.Read_Binary));
I : Integer := 0;
S : String := "xxxxxxxxxxxxxxx";
T_True : Complicated_Union;
T_False : Complicated_Union;
begin
Text_IO.Put_Line ("Now reading from file-stream...");
Integer'Read (R_Stream'Access, I);
String'Read (R_Stream'Access, S);
T_True := Complicated_Union'Input (R_Stream'Access);
T_False := Complicated_Union'Input (R_Stream'Access);
R_Stream.Close;
Text_IO.Put_Line (I'Img);
Text_IO.Put_Line (S);
Text_IO.Put_Line (T_True.F'Img);
Text_IO.Put_Line (T_False.C'Img);
end;
declare
Op : SDL.RWops.RWops;
Stream : aliased SDL.RWops.Streams.RWops_Stream;
I : Integer := 0;
S : String := "xxxxxxxxxxxxxxx";
T_True : Complicated_Union;
T_False : Complicated_Union;
begin
SDL.RWops.From_File (File_Name => "out.bin",
Mode => SDL.RWops.Read_Binary,
Ops => Op);
SDL.RWops.Streams.Open
(Op => Op,
Stream => Stream);
Integer'Read (Stream'Access, I);
String'Read (Stream'Access, S);
T_True := Complicated_Union'Input (Stream'Access);
T_False := Complicated_Union'Input (Stream'Access);
Stream.Close;
Text_IO.Put_Line (I'Img);
Text_IO.Put_Line (S);
Text_IO.Put_Line (T_True.F'Img);
Text_IO.Put_Line (T_False.C'Img);
end;
end RWops_Streams_Test;
begin
RWops_Tests;
RWops_Streams_Test;
exception
when SDL.RWops.RWops_Error =>
Text_IO.Put_Line ("Make sure you have a file named 'test' in this directory, it can be any file.");
end Rwops;
|
stcarrez/ada-util | Ada | 9,445 | adb | -----------------------------------------------------------------------
-- util-events-timers -- Timer list management
-- 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.
-----------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Util.Log.Loggers;
package body Util.Events.Timers is
use type Ada.Real_Time.Time;
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Util.Events.Timers");
procedure Free is
new Ada.Unchecked_Deallocation (Object => Timer_Node,
Name => Timer_Node_Access);
-- -----------------------
-- Repeat the timer.
-- -----------------------
procedure Repeat (Event : in out Timer_Ref;
In_Time : in Ada.Real_Time.Time_Span) is
Timer : constant Timer_Node_Access := Event.Value;
begin
if Timer /= null and then Timer.List /= null then
Timer.List.Add (Timer, Timer.Deadline + In_Time);
end if;
end Repeat;
-- -----------------------
-- Cancel the timer.
-- -----------------------
procedure Cancel (Event : in out Timer_Ref) is
begin
if Event.Value /= null and then Event.Value.List /= null then
Event.Value.List.all.Cancel (Event.Value);
Event.Value.List := null;
end if;
end Cancel;
-- -----------------------
-- Check if the timer is ready to be executed.
-- -----------------------
function Is_Scheduled (Event : in Timer_Ref) return Boolean is
begin
return Event.Value /= null and then Event.Value.List /= null;
end Is_Scheduled;
-- -----------------------
-- Returns the deadline time for the timer execution.
-- Returns Time'Last if the timer is not scheduled.
-- -----------------------
function Time_Of_Event (Event : in Timer_Ref) return Ada.Real_Time.Time is
begin
return (if Event.Value /= null then Event.Value.Deadline else Ada.Real_Time.Time_Last);
end Time_Of_Event;
-- -----------------------
-- Set a timer to be called at the given time.
-- -----------------------
procedure Set_Timer (List : in out Timer_List;
Handler : in Timer_Access;
Event : in out Timer_Ref'Class;
At_Time : in Ada.Real_Time.Time) is
Timer : Timer_Node_Access := Event.Value;
begin
if Timer = null then
Event.Value := new Timer_Node;
Timer := Event.Value;
end if;
Timer.Handler := Handler;
-- Cancel the timer if it is part of another timer manager.
if Timer.List /= null and then Timer.List /= List.Manager'Unchecked_Access then
Timer.List.Cancel (Timer);
end if;
-- Update the timer.
Timer.List := List.Manager'Unchecked_Access;
List.Manager.Add (Timer, At_Time);
end Set_Timer;
-- -----------------------
-- Set a timer to be called after the given time span.
-- -----------------------
procedure Set_Timer (List : in out Timer_List;
Handler : in Timer_Access;
Event : in out Timer_Ref'Class;
In_Time : in Ada.Real_Time.Time_Span) is
begin
List.Set_Timer (Handler, Event, Ada.Real_Time.Clock + In_Time);
end Set_Timer;
-- -----------------------
-- Process the timer handlers that have passed the deadline and return the next
-- deadline. The <tt>Max_Count</tt> parameter allows to limit the number of timer handlers
-- that are called by operation. The default is not limited.
-- -----------------------
procedure Process (List : in out Timer_List;
Timeout : out Ada.Real_Time.Time;
Max_Count : in Natural := Natural'Last) is
Timer : Timer_Ref;
Now : constant Ada.Real_Time.Time := Ada.Real_Time.Clock;
begin
for Count in 1 .. Max_Count loop
List.Manager.Find_Next (Now, Timeout, Timer);
exit when Timer.Value = null;
begin
Timer.Value.Handler.Time_Handler (Timer);
exception
when E : others =>
Timer_List'Class (List).Error (Timer.Value.Handler, E);
end;
Timer.Finalize;
end loop;
end Process;
-- -----------------------
-- Procedure called when a timer handler raises an exception.
-- The default operation reports an error in the logs. This procedure can be
-- overridden to implement specific error handling.
-- -----------------------
procedure Error (List : in out Timer_List;
Handler : in Timer_Access;
E : in Ada.Exceptions.Exception_Occurrence) is
pragma Unreferenced (List, Handler);
begin
Log.Error ("Timer handler raised an exception", E, True);
end Error;
overriding
procedure Adjust (Object : in out Timer_Ref) is
begin
if Object.Value /= null then
Util.Concurrent.Counters.Increment (Object.Value.Counter);
end if;
end Adjust;
overriding
procedure Finalize (Object : in out Timer_Ref) is
Is_Zero : Boolean;
begin
if Object.Value /= null then
Util.Concurrent.Counters.Decrement (Object.Value.Counter, Is_Zero);
if Is_Zero then
Free (Object.Value);
else
Object.Value := null;
end if;
end if;
end Finalize;
protected body Timer_Manager is
procedure Remove (Timer : in Timer_Node_Access) is
begin
if List = Timer then
List := Timer.Next;
Timer.Prev := null;
if List /= null then
List.Prev := null;
end if;
elsif Timer.Prev /= null then
Timer.Prev.Next := Timer.Next;
Timer.Next.Prev := Timer.Prev;
else
return;
end if;
Timer.Next := null;
Timer.Prev := null;
Timer.List := null;
end Remove;
-- -----------------------
-- Add a timer.
-- -----------------------
procedure Add (Timer : in Timer_Node_Access;
Deadline : in Ada.Real_Time.Time) is
Current : Timer_Node_Access := List;
Prev : Timer_Node_Access;
begin
Util.Concurrent.Counters.Increment (Timer.Counter);
if Timer.List /= null then
Remove (Timer);
end if;
Timer.Deadline := Deadline;
while Current /= null loop
if Current.Deadline > Deadline then
if Prev = null then
List := Timer;
else
Prev.Next := Timer;
end if;
Timer.Next := Current;
Current.Prev := Timer;
return;
end if;
Prev := Current;
Current := Current.Next;
end loop;
if Prev = null then
List := Timer;
Timer.Prev := null;
else
Prev.Next := Timer;
Timer.Prev := Prev;
end if;
Timer.Next := null;
end Add;
-- -----------------------
-- Cancel a timer.
-- -----------------------
procedure Cancel (Timer : in out Timer_Node_Access) is
Is_Zero : Boolean;
begin
if Timer.List = null then
return;
end if;
Remove (Timer);
Util.Concurrent.Counters.Decrement (Timer.Counter, Is_Zero);
if Is_Zero then
Free (Timer);
end if;
end Cancel;
-- -----------------------
-- Find the next timer to be executed before the given time or return the next deadline.
-- -----------------------
procedure Find_Next (Before : in Ada.Real_Time.Time;
Deadline : out Ada.Real_Time.Time;
Timer : in out Timer_Ref) is
begin
if List = null then
Deadline := Ada.Real_Time.Time_Last;
elsif List.Deadline < Before then
Timer.Value := List;
List := List.Next;
if List /= null then
List.Prev := null;
Deadline := List.Deadline;
else
Deadline := Ada.Real_Time.Time_Last;
end if;
else
Deadline := List.Deadline;
end if;
end Find_Next;
end Timer_Manager;
overriding
procedure Finalize (Object : in out Timer_List) is
Timer : Timer_Ref;
Timeout : Ada.Real_Time.Time;
begin
loop
Object.Manager.Find_Next (Ada.Real_Time.Time_Last, Timeout, Timer);
exit when Timer.Value = null;
Timer.Finalize;
end loop;
end Finalize;
end Util.Events.Timers;
|
reznikmm/matreshka | Ada | 3,430 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2017, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Core.Connectables.Slots_0;
package Core.Slots_0 renames Core.Connectables.Slots_0;
|
reznikmm/matreshka | Ada | 4,069 | 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.Office_Automatic_Update_Attributes;
package Matreshka.ODF_Office.Automatic_Update_Attributes is
type Office_Automatic_Update_Attribute_Node is
new Matreshka.ODF_Office.Abstract_Office_Attribute_Node
and ODF.DOM.Office_Automatic_Update_Attributes.ODF_Office_Automatic_Update_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Office_Automatic_Update_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Office_Automatic_Update_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Office.Automatic_Update_Attributes;
|
optikos/oasis | Ada | 281 | ads |
with Anagram.Grammars;
with Program.Parsers.Nodes;
private procedure Program.Parsers.On_Reduce_1
(Self : access Parse_Context;
Prod : Anagram.Grammars.Production_Index;
Nodes : in out Program.Parsers.Nodes.Node_Array);
pragma Preelaborate (Program.Parsers.On_Reduce_1);
|
peterfrankjohnson/kernel | Ada | 2,844 | ads | with Interfaces; use Interfaces;
with System; use System;
package CPU.ProtectedMode.IDT is
type InterruptDescriptorType is
(Reserved1,
TSS286,
LDT,
TSS286Busy,
CallGate,
TaskGate, -- <- These
InterruptGate286, -- <- are
TrapGate286, -- <- the
Reserved2,
TSS386Available,
Reserved3,
TSS386Busy,
CallGate386,
Reserved4,
InterruptGate386, -- <- only valid
TrapGate386); -- <- types.
--
-- Need to define this as a subtype of SystemDescriptorType???
-- Use range to specify the allowed ranges of the subtype as 5-7 and E-F
--
for InterruptDescriptorType use
(Reserved1 => 16#0#,
TSS286 => 16#1#,
LDT => 16#2#,
TSS286Busy => 16#3#,
CallGate => 16#4#,
TaskGate => 16#5#, -- <- These
InterruptGate286 => 16#6#, -- <- are
TrapGate286 => 16#7#, -- <- the
Reserved2 => 16#8#,
TSS386Available => 16#9#,
Reserved3 => 16#A#,
TSS386Busy => 16#B#,
CallGate386 => 16#C#,
Reserved4 => 16#D#,
InterruptGate386 => 16#E#, -- <- only valid
TrapGate386 => 16#F#); -- <- types.
for InterruptDescriptorType'Size use 4;
type TypeAttributesByte is
record
DescriptorType : InterruptDescriptorType;
StorageSegment : Boolean;
Privilege : DescriptorPrivilege;
Present : Boolean;
end record;
for TypeAttributesByte'Size use 8;
pragma Pack (TypeAttributesByte);
type InterruptDescriptor is
record
OffsetLow : Word;
Selector : Word;
Zero : Byte;
TypeAttributes : TypeAttributesByte;
OffsetHigh : Word;
end record;
for InterruptDescriptor'Size use 64;
pragma Pack (InterruptDescriptor);
type InterruptDescriptorTable is array (Word range 1 .. 256) of InterruptDescriptor;
IDT : InterruptDescriptorTable;
type IDTR_Record is
record
Length : Word;
Address : System.Address;
end record;
for IDTR_Record'Size use 48;
pragma Pack (IDTR_Record);
IDTR : IDTR_Record;
procedure AddInterruptDescriptor (Offset : System.Address;
Selector : Word;
Present : Boolean := True;
Privilege : DescriptorPrivilege := Ring0;
StorageSegment : Boolean := False;
DescriptorType : InterruptDescriptorType);
procedure Init;
procedure Load (Address : System.Address);
pragma Import (C, Load, "load_idt");
end CPU.ProtectedMode.IDT;
|
reznikmm/matreshka | Ada | 3,914 | 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.Text.List_Level_Position_And_Space_Mode is
type Text_List_Level_Position_And_Space_Mode_Node is
new Matreshka.ODF_Attributes.Text.Text_Node_Base with null record;
type Text_List_Level_Position_And_Space_Mode_Access is
access all Text_List_Level_Position_And_Space_Mode_Node'Class;
overriding function Get_Local_Name
(Self : not null access constant Text_List_Level_Position_And_Space_Mode_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Attributes.Text.List_Level_Position_And_Space_Mode;
|
charlie5/cBound | Ada | 1,403 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces.C;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_visualid_iterator_t is
-- Item
--
type Item is record
data : access xcb.xcb_visualid_t;
the_rem : aliased Interfaces.C.int;
index : aliased Interfaces.C.int;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_visualid_iterator_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_visualid_iterator_t.Item,
Element_Array => xcb.xcb_visualid_iterator_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_visualid_iterator_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_visualid_iterator_t.Pointer,
Element_Array => xcb.xcb_visualid_iterator_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_visualid_iterator_t;
|
sungyeon/drake | Ada | 1,026 | ads | pragma License (Unrestricted);
-- implementation unit required by compiler
with System.Packed_Arrays;
package System.Pack_24 is
pragma Preelaborate;
-- It can not be Pure, subprograms would become __attribute__((const)).
type Bits_24 is mod 2 ** 24;
for Bits_24'Size use 24;
package Indexing is new Packed_Arrays.Indexing (Bits_24);
-- required for accessing arrays by compiler
function Get_24 (
Arr : Address;
N : Natural;
Rev_SSO : Boolean)
return Bits_24
renames Indexing.Get;
procedure Set_24 (
Arr : Address;
N : Natural;
E : Bits_24;
Rev_SSO : Boolean)
renames Indexing.Set;
-- required for accessing unaligned arrays by compiler
function GetU_24 (
Arr : Address;
N : Natural;
Rev_SSO : Boolean)
return Bits_24
renames Indexing.Get;
procedure SetU_24 (
Arr : Address;
N : Natural;
E : Bits_24;
Rev_SSO : Boolean)
renames Indexing.Set;
end System.Pack_24;
|
zhmu/ananas | Ada | 370 | ads | package Debug6_Pkg is
type Vkind is (Int, Undefined);
for Vkind use (Int => -2 ** 31, Undefined => 0);
type Value (Kind : Vkind) is record
case Kind is
when Undefined => null;
when Int => Value : Integer;
when others => null;
end case;
end record;
procedure Process (V : Value);
end Debug6_Pkg;
|
charlie5/cBound | Ada | 1,532 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_query_pointer_request_t is
-- Item
--
type Item is record
major_opcode : aliased Interfaces.Unsigned_8;
pad0 : aliased Interfaces.Unsigned_8;
length : aliased Interfaces.Unsigned_16;
window : aliased xcb.xcb_window_t;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_query_pointer_request_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_query_pointer_request_t.Item,
Element_Array => xcb.xcb_query_pointer_request_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb.xcb_query_pointer_request_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_query_pointer_request_t.Pointer,
Element_Array => xcb.xcb_query_pointer_request_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_query_pointer_request_t;
|
io7m/coreland-c_string | Ada | 1,677 | ads | with Interfaces.C;
with Interfaces.C.Strings;
package C_String is
--
-- Terminated C string pointer type.
--
type String_Ptr_t is access all Interfaces.C.char;
pragma Convention (C, String_Ptr_t);
pragma No_Strict_Aliasing (String_Ptr_t);
subtype String_Not_Null_Ptr_t is not null String_Ptr_t;
--
-- Unterminated C char array pointer type.
--
type Char_Array_Ptr_t is access all Interfaces.C.char;
pragma Convention (C, Char_Array_Ptr_t);
pragma No_Strict_Aliasing (Char_Array_Ptr_t);
subtype Char_Array_Not_Null_Ptr_t is not null Char_Array_Ptr_t;
--
-- Convert terminated or unterminated C string to Ada string.
--
function To_String
(Item : in String_Not_Null_Ptr_t) return String;
function To_String
(Item : in Char_Array_Not_Null_Ptr_t;
Size : in Interfaces.C.size_t) return String;
--
-- Convert Ada string to terminated or unterminated Ada string.
--
function To_C_String
(Item : in not null Interfaces.C.Strings.char_array_access) return String_Ptr_t;
function To_C_Char_Array
(Item : in not null Interfaces.C.Strings.char_array_access) return Char_Array_Ptr_t;
--
-- Fetch character 'Index' from C string.
--
function Index
(Item : in String_Not_Null_Ptr_t;
Index : in Interfaces.C.size_t) return Interfaces.C.char;
function Index
(Item : in Char_Array_Not_Null_Ptr_t;
Size : in Interfaces.C.size_t;
Index : in Interfaces.C.size_t) return Interfaces.C.char;
--
-- Get length of terminated C string.
--
function Length
(Item : in String_Not_Null_Ptr_t) return Interfaces.C.size_t;
Null_Termination_Error : exception;
end C_String;
|
stcarrez/ada-util | Ada | 3,632 | adb | -----------------------------------------------------------------------
-- util-serialize-contexts -- Contexts for serialization framework
-- Copyright (C) 2010, 2011 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Util.Concurrent.Counters;
package body Util.Serialize.Contexts is
procedure Free is new Ada.Unchecked_Deallocation (Data'Class, Data_Access);
-- ------------------------------
-- Context data key
-- ------------------------------
Next_Key : Util.Concurrent.Counters.Counter := Util.Concurrent.Counters.ONE;
-- ------------------------------
-- Allocate a unique data key for a mapper.
-- ------------------------------
procedure Allocate (Key : out Data_Key) is
Val : Integer;
begin
Util.Concurrent.Counters.Increment (Next_Key, Val);
Key := Data_Key (Val);
end Allocate;
function Hash (Key : in Data_Key) return Ada.Containers.Hash_Type is
begin
return Ada.Containers.Hash_Type (Key);
end Hash;
-- ------------------------------
-- Reader context
-- ------------------------------
-- ------------------------------
-- Get the data object associated with the given key.
-- Raises No_Data exception if there is no data object.
-- ------------------------------
function Get_Data (Ctx : in Context;
Key : in Data_Key) return Data_Access is
Pos : constant Data_Map.Cursor := Ctx.Data.Find (Key);
begin
if Data_Map.Has_Element (Pos) then
return Data_Map.Element (Pos);
else
raise No_Data;
end if;
end Get_Data;
-- ------------------------------
-- Set the data object associated with the given key.
-- ------------------------------
procedure Set_Data (Ctx : in out Context;
Key : in Data_Key;
Content : in Data_Access) is
Pos : constant Data_Map.Cursor := Ctx.Data.Find (Key);
begin
if Data_Map.Has_Element (Pos) then
declare
Old : Data_Access := Data_Map.Element (Pos);
begin
if Old = Content then
return;
end if;
Old.Finalize;
Free (Old);
end;
Ctx.Data.Replace_Element (Position => Pos, New_Item => Content);
else
Ctx.Data.Insert (Key => Key, New_Item => Content);
end if;
end Set_Data;
-- ------------------------------
-- Free the context data.
-- ------------------------------
overriding
procedure Finalize (Ctx : in out Context) is
Pos : Data_Map.Cursor;
Content : Data_Access;
begin
loop
Pos := Ctx.Data.First;
exit when not Data_Map.Has_Element (Pos);
Content := Data_Map.Element (Pos);
Content.Finalize;
Free (Content);
Ctx.Data.Delete (Pos);
end loop;
end Finalize;
end Util.Serialize.Contexts;
|
PThierry/ewok-kernel | Ada | 3,370 | adb | --
-- Copyright 2018 The wookey project team <[email protected]>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with m4.scb; use m4.scb;
package body m4.mpu
with spark_mode => on
is
function address_to_bits_27 (addr : system_address)
return bits_27
is
pragma warnings (off);
function to_bits_27 is
new ada.unchecked_conversion (unsigned_32, bits_27);
pragma warnings (on);
begin
return to_bits_27 (shift_right (addr, 5));
end address_to_bits_27;
procedure is_mpu_available
(success : out boolean)
is
begin
if to_unsigned_32 (MPU.TYPER) = 0 then
success := false;
else
success := true;
end if;
end is_mpu_available;
procedure enable is
begin
MPU.CTRL.ENABLE := true;
end enable;
procedure disable is
begin
MPU.CTRL.ENABLE := false;
end disable;
procedure init
is
begin
-- Kernel has *no access* to default memory map
m4.mpu.MPU.CTRL.PRIVDEFENA := false;
-- Enable the memory fault exception
m4.scb.SCB.SHCSR.MEMFAULTENA := true;
end init;
procedure enable_unrestricted_kernel_access
is
begin
m4.mpu.MPU.CTRL.PRIVDEFENA := true;
end enable_unrestricted_kernel_access;
procedure disable_unrestricted_kernel_access
is
begin
m4.mpu.MPU.CTRL.PRIVDEFENA := false;
end disable_unrestricted_kernel_access;
procedure configure_region
(region : in t_region_config)
is
begin
-- Selects which memory region is referenced
MPU.RNR.REGION := region.region_number;
-- Defines the base address of the MPU region
MPU.RBAR :=
(VALID => false,
REGION => 0,
ADDR => address_to_bits_27 (region.addr));
-- Defines the region size and memory attributes
MPU.RASR :=
(ENABLE => true,
SIZE => region.size,
SRD => 0,
B => region.b,
C => false,
S => region.S,
TEX => 0,
AP => region.access_perm,
XN => region.xn);
end configure_region;
procedure disable_region
(region_number : in t_region_number)
is
begin
MPU.RNR.REGION := region_number;
MPU.RASR.ENABLE := false;
end disable_region;
procedure update_subregion_mask
(region_number : in t_region_number;
subregion_mask : in unsigned_8)
is
begin
-- Selects which memory region is referenced
MPU.RNR.REGION := region_number;
-- Defines the region size and memory attributes
MPU.RASR.SRD := subregion_mask;
end update_subregion_mask;
end m4.mpu;
|
stcarrez/ada-util | Ada | 2,873 | adb | -----------------------------------------------------------------------
-- util-mail-tests -- Unit tests for mail
-- Copyright (C) 2018, 2021 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Test_Caller;
package body Util.Mail.Tests is
package Caller is new Util.Test_Caller (Test, "Mail");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test Util.Mail.Parse_Address",
Test_Parse_Address'Access);
end Add_Tests;
procedure Test_Parse_Address (T : in out Test) is
use Ada.Strings.Unbounded;
procedure Check (Value : in String;
Name : in String;
Email : in String;
First_Name : in String;
Last_Name : in String);
procedure Check (Value : in String;
Name : in String;
Email : in String;
First_Name : in String;
Last_Name : in String) is
A : constant Email_Address := Parse_Address (Value);
begin
Util.Tests.Assert_Equals (T, Name, To_String (A.Name),
"Invalid name for: " & Value);
Util.Tests.Assert_Equals (T, Email, To_String (A.Address),
"Invalid email for: " & Value);
Util.Tests.Assert_Equals (T, First_Name, Get_First_Name (A),
"Invalid first_name for: " & Value);
Util.Tests.Assert_Equals (T, Last_Name, Get_Last_Name (A),
"Invalid last_name for: " & Value);
end Check;
begin
Check ("Luke Jedi <[email protected]> ", "Luke Jedi", "[email protected]",
"Luke", "Jedi");
Check (" <[email protected]> ", "Anakin", "[email protected]",
"", "Anakin");
Check (" [email protected] ", "Vador", "[email protected]",
"", "Vador");
Check ("<[email protected]> ", "Ada.Lovelace", "[email protected]",
"Ada", "Lovelace");
end Test_Parse_Address;
end Util.Mail.Tests;
|
reznikmm/webdriver | Ada | 4,272 | adb | -- Copyright (c) 2017 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with AWS.Client;
with League.JSON.Objects;
with League.JSON.Values;
with League.String_Vectors;
with WebDriver.Elements;
with WebDriver.Sessions;
package body WebDriver.Remote is
type Method_Kinds is (Get, Post);
type Command is record
Method : Method_Kinds;
Path : League.Strings.Universal_String;
Session_Id : League.Strings.Universal_String;
Parameters : League.JSON.Objects.JSON_Object;
end record;
type Response is record
Session_Id : League.Strings.Universal_String;
State : League.Strings.Universal_String;
Status : Integer;
Value : League.JSON.Objects.JSON_Object;
end record;
package Executors is
type HTTP_Command_Executor is tagged limited record
Server : AWS.Client.HTTP_Connection;
end record;
not overriding function Execute
(Self : access HTTP_Command_Executor;
Command : Remote.Command) return Response;
end Executors;
package body Executors is separate;
package Elements is
type Element is new WebDriver.Elements.Element with record
Session_Id : League.Strings.Universal_String;
Element_Id : League.Strings.Universal_String;
Executor : access Executors.HTTP_Command_Executor;
end record;
overriding function Is_Selected (Self : access Element) return Boolean;
overriding function Is_Enabled (Self : access Element) return Boolean;
overriding function Get_Attribute
(Self : access Element;
Name : League.Strings.Universal_String)
return League.Strings.Universal_String;
overriding function Get_Property
(Self : access Element;
Name : League.Strings.Universal_String)
return League.Strings.Universal_String;
overriding function Get_CSS_Value
(Self : access Element;
Name : League.Strings.Universal_String)
return League.Strings.Universal_String;
overriding function Get_Text
(Self : access Element) return League.Strings.Universal_String;
overriding function Get_Tag_Name
(Self : access Element) return League.Strings.Universal_String;
overriding procedure Click (Self : access Element);
overriding procedure Clear (Self : access Element);
overriding procedure Send_Keys
(Self : access Element;
Text : League.String_Vectors.Universal_String_Vector);
end Elements;
package body Elements is separate;
package Sessions is
type Session is new WebDriver.Sessions.Session with record
Session_Id : League.Strings.Universal_String;
Executor : access Executors.HTTP_Command_Executor;
end record;
overriding procedure Go
(Self : access Session;
URL : League.Strings.Universal_String);
overriding function Get_Current_URL
(Self : access Session) return League.Strings.Universal_String;
overriding function Find_Element
(Self : access Session;
Strategy : WebDriver.Location_Strategy;
Selector : League.Strings.Universal_String)
return WebDriver.Elements.Element_Access;
end Sessions;
package body Sessions is separate;
package Drivers is
type Driver is limited new WebDriver.Drivers.Driver with record
Executor : aliased Executors.HTTP_Command_Executor;
end record;
overriding function New_Session
(Self : access Driver;
Capabilities : League.JSON.Values.JSON_Value :=
League.JSON.Values.Empty_JSON_Value)
return WebDriver.Sessions.Session_Access;
end Drivers;
package body Drivers is separate;
------------
-- Create --
------------
function Create
(URL : League.Strings.Universal_String)
return WebDriver.Drivers.Driver'Class
is
begin
return Result : Drivers.Driver do
AWS.Client.Create
(Result.Executor.Server,
Host => URL.To_UTF_8_String);
end return;
end Create;
end WebDriver.Remote;
|
AdaCore/libadalang | Ada | 346 | adb | procedure Test is
Value : constant Integer := 10;
Var : Integer := 1;
generic
X : in out Integer;
Y : in Integer;
procedure Foo;
procedure Foo is
begin
X := Y;
end Foo;
procedure P_1 is new Foo (X => Var, Y => Value);
procedure P_2 is new Foo (X => Var, Y => 13);
begin
P_1;
P_2;
end Test;
|
charlie5/lace | Ada | 11,671 | adb | with
openGL.Primitive.indexed,
openGL.Geometry.lit_textured,
openGL.Model.hexagon;
package body openGL.Model.Hexagon_Column.lit_textured_faceted
is
---------
--- Forge
--
function new_hexagon_Column (Radius : in Real;
Height : in Real;
Upper,
Lower : in hex_Face;
Shaft : in shaft_Face) return View
is
Self : constant View := new Item;
begin
Self.Radius := Radius;
Self.Height := Height;
Self.upper_Face := Upper;
Self.lower_Face := Lower;
Self.Shaft := Shaft;
return Self;
end new_hexagon_Column;
--------------
--- Attributes
--
overriding
function to_GL_Geometries (Self : access Item; Textures : access Texture.name_Map_of_texture'Class;
Fonts : in Font.font_id_Map_of_font) return Geometry.views
is
pragma unreferenced (Fonts);
use Geometry.lit_textured,
Model.hexagon,
Texture;
shaft_Height : constant Real := Self.Height;
height_Offset : constant Vector_3 := (0.0, shaft_Height / 2.0, 0.0);
mid_Sites : constant hexagon.Sites := vertex_Sites (Self.Radius);
upper_Sites : hexagon.Sites := mid_Sites;
lower_Sites : hexagon.Sites := mid_Sites;
function new_hexagon_Face (Vertices : access Geometry.lit_textured.Vertex_array;
Flip : in Boolean := False) return Geometry.lit_textured.view
is
use Primitive;
function the_Indices return Indices
is
begin
if Flip
then return (1, 7, 6, 5, 4, 3, 2, 7);
else return (1, 2, 3, 4, 5, 6, 7, 2);
end if;
end the_Indices;
the_Geometry : constant Geometry.lit_textured.view
:= Geometry.lit_textured.new_Geometry;
the_Primitive : constant Primitive.indexed.view
:= Primitive.indexed.new_Primitive (triangle_Fan,
the_Indices);
begin
the_Geometry.Vertices_are (Vertices.all);
the_Geometry.add (Primitive.view (the_Primitive));
return the_Geometry;
end new_hexagon_Face;
function new_shaft_Face (Vertices : access Geometry.lit_textured.Vertex_array)
return Geometry.lit_textured.view
is
use Primitive;
the_Indices : constant Indices := (1, 2, 3, 4);
the_Geometry : constant Geometry.lit_textured.view
:= Geometry.lit_textured.new_Geometry;
the_Primitive : constant Primitive.view
:= Primitive.indexed.new_Primitive (triangle_Strip, the_Indices).all'Access;
begin
the_Geometry.Vertices_are (Vertices.all);
the_Geometry.add (the_Primitive);
return the_Geometry;
end new_shaft_Face;
upper_Face : Geometry.lit_textured.view;
lower_Face : Geometry.lit_textured.view;
shaft_Faces : array (1 .. 6) of Geometry.lit_textured.view;
begin
for Each in mid_Sites'Range
loop
upper_Sites (Each) := upper_Sites (Each) + height_Offset;
lower_Sites (Each) := lower_Sites (Each) - height_Offset;
end loop;
-- Upper
--
declare
the_Vertices : aliased Geometry.lit_textured.Vertex_array
:= (1 => (Site => height_Offset, Normal => Normal, Coords => (0.0, 0.0), Shine => default_Shine),
2 => (Site => upper_Sites (1), Normal => Normal, Coords => (0.0, 0.0), Shine => default_Shine),
3 => (Site => upper_Sites (2), Normal => Normal, Coords => (1.0, 0.0), Shine => default_Shine),
4 => (Site => upper_Sites (3), Normal => Normal, Coords => (1.0, 1.0), Shine => default_Shine),
5 => (Site => upper_Sites (4), Normal => Normal, Coords => (0.0, 1.0), Shine => default_Shine),
6 => (Site => upper_Sites (5), Normal => Normal, Coords => (0.0, 1.0), Shine => default_Shine),
7 => (Site => upper_Sites (6), Normal => Normal, Coords => (0.0, 1.0), Shine => default_Shine));
begin
upper_Face := new_hexagon_Face (Vertices => the_Vertices'Access);
if Self.upper_Face.Texture /= null_Asset
then
upper_Face.Texture_is (Textures.fetch (Self.upper_Face.Texture));
end if;
end;
-- Lower
--
declare
the_Vertices : aliased Geometry.lit_textured.Vertex_array
:= (1 => (Site => -height_Offset, Normal => -Normal, Coords => (0.0, 0.0), Shine => default_Shine),
2 => (Site => lower_Sites (1), Normal => -Normal, Coords => (0.0, 0.0), Shine => default_Shine),
3 => (Site => lower_Sites (2), Normal => -Normal, Coords => (1.0, 0.0), Shine => default_Shine),
4 => (Site => lower_Sites (3), Normal => -Normal, Coords => (1.0, 1.0), Shine => default_Shine),
5 => (Site => lower_Sites (4), Normal => -Normal, Coords => (0.0, 1.0), Shine => default_Shine),
6 => (Site => lower_Sites (5), Normal => -Normal, Coords => (0.0, 1.0), Shine => default_Shine),
7 => (Site => lower_Sites (6), Normal => -Normal, Coords => (0.0, 1.0), Shine => default_Shine));
begin
lower_Face := new_hexagon_Face (vertices => the_Vertices'Access,
flip => True);
if Self.upper_Face.Texture /= null_Asset
then
lower_Face.Texture_is (Textures.fetch (Self.lower_Face.Texture));
end if;
end;
-- Shaft
--
declare
type shaft_Normals is array (1 .. 6) of Vector_3;
function get_Normals return shaft_Normals
is
use linear_Algebra_3D;
Rotation : constant Matrix_3x3 := y_Rotation_from (to_Radians (60.0));
the_Normal : Vector_3 := (0.0, 0.0, -1.0);
Result : shaft_Normals;
begin
Result (2) := the_Normal;
the_Normal := Rotation * the_Normal;
Result (3) := the_Normal;
the_Normal := Rotation * the_Normal;
Result (4) := the_Normal;
the_Normal := (0.0, 0.0, 1.0);
Result (5) := the_Normal;
the_Normal := Rotation * the_Normal;
Result (6) := the_Normal;
the_Normal := Rotation * the_Normal;
Result (1) := the_Normal;
return Result;
end get_Normals;
Normals : constant shaft_Normals := get_Normals;
s_Delta : constant := 1.0 / 6.0;
the_Vertices_1 : aliased Geometry.lit_textured.Vertex_array
:= (1 => (Site => upper_Sites (1), Normal => Normals (1), Coords => (0.0, 1.0), Shine => default_Shine),
2 => (Site => lower_Sites (1), Normal => Normals (1), Coords => (0.0, 0.0), Shine => default_Shine),
3 => (Site => upper_Sites (2), Normal => Normals (1), Coords => (s_Delta, 1.0), Shine => default_Shine),
4 => (Site => lower_Sites (2), Normal => Normals (1), Coords => (s_Delta, 0.0), Shine => default_Shine));
the_Vertices_2 : aliased Geometry.lit_textured.Vertex_array
:= (1 => (Site => upper_Sites (2), Normal => Normals (2), Coords => (s_Delta, 1.0), Shine => default_Shine),
2 => (Site => lower_Sites (2), Normal => Normals (2), Coords => (s_Delta, 0.0), Shine => default_Shine),
3 => (Site => upper_Sites (3), Normal => Normals (2), Coords => (s_Delta * 2.0, 1.0), Shine => default_Shine),
4 => (Site => lower_Sites (3), Normal => Normals (2), Coords => (s_Delta * 2.0, 0.0), Shine => default_Shine));
the_Vertices_3 : aliased Geometry.lit_textured.Vertex_array
:= (1 => (Site => upper_Sites (3), Normal => Normals (3), Coords => (s_Delta * 2.0, 1.0), Shine => default_Shine),
2 => (Site => lower_Sites (3), Normal => Normals (3), Coords => (s_Delta * 2.0, 0.0), Shine => default_Shine),
3 => (Site => upper_Sites (4), Normal => Normals (3), Coords => (s_Delta * 3.0, 1.0), Shine => default_Shine),
4 => (Site => lower_Sites (4), Normal => Normals (3), Coords => (s_Delta * 3.0, 0.0), Shine => default_Shine));
the_Vertices_4 : aliased Geometry.lit_textured.Vertex_array
:= (1 => (Site => upper_Sites (4), Normal => Normals (4), Coords => (s_Delta * 3.0, 1.0), Shine => default_Shine),
2 => (Site => lower_Sites (4), Normal => Normals (4), Coords => (s_Delta * 3.0, 0.0), Shine => default_Shine),
3 => (Site => upper_Sites (5), Normal => Normals (4), Coords => (s_Delta * 4.0, 1.0), Shine => default_Shine),
4 => (Site => lower_Sites (5), Normal => Normals (4), Coords => (s_Delta * 4.0, 0.0), Shine => default_Shine));
the_Vertices_5 : aliased Geometry.lit_textured.Vertex_array
:= (1 => (Site => upper_Sites (5), Normal => Normals (5), Coords => (s_Delta * 4.0, 1.0), Shine => default_Shine),
2 => (Site => lower_Sites (5), Normal => Normals (5), Coords => (s_Delta * 4.0, 0.0), Shine => default_Shine),
3 => (Site => upper_Sites (6), Normal => Normals (5), Coords => (s_Delta * 5.0, 1.0), Shine => default_Shine),
4 => (Site => lower_Sites (6), Normal => Normals (5), Coords => (s_Delta * 5.0, 0.0), Shine => default_Shine));
the_Vertices_6 : aliased Geometry.lit_textured.Vertex_array
:= (1 => (Site => upper_Sites (6), Normal => Normals (6), Coords => (s_Delta * 5.0, 1.0), Shine => default_Shine),
2 => (Site => lower_Sites (6), Normal => Normals (6), Coords => (s_Delta * 5.0, 0.0), Shine => default_Shine),
3 => (Site => upper_Sites (1), Normal => Normals (6), Coords => (1.0, 1.0), Shine => default_Shine),
4 => (Site => lower_Sites (1), Normal => Normals (6), Coords => (1.0, 0.0), Shine => default_Shine));
the_Vertices : constant array (1 .. 6) of access Geometry.lit_textured.Vertex_array
:= (the_Vertices_1'Access,
the_Vertices_2'Access,
the_Vertices_3'Access,
the_Vertices_4'Access,
the_Vertices_5'Access,
the_Vertices_6'Access);
begin
for i in shaft_Faces'Range
loop
shaft_Faces (i) := new_shaft_Face (vertices => the_Vertices (i));
if Self.shaft.Texture /= null_Asset
then
shaft_Faces (i).Texture_is (Textures.fetch (Self.shaft.Texture));
end if;
end loop;
end;
return (1 => upper_Face .all'Access,
2 => lower_Face .all'Access,
3 => shaft_Faces (1).all'Access,
4 => shaft_Faces (2).all'Access,
5 => shaft_Faces (3).all'Access,
6 => shaft_Faces (4).all'Access,
7 => shaft_Faces (5).all'Access,
8 => shaft_Faces (6).all'Access);
end to_GL_Geometries;
end openGL.Model.Hexagon_Column.lit_textured_faceted;
|
emacsmirror/ada-mode | Ada | 1,376 | ads | -- Abstract :
--
-- Run the Ada LALR parser standalone. Useful for debugging grammar issues.
--
-- Copyright (C) 2017 - 2020, 2022 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 Ada_Annex_P_Process_LALR_Main;
with Gen_Run_Wisi_LR_Parse;
with WisiToken.Parse.LR.McKenzie_Recover.Ada;
with Wisi.Ada;
procedure Run_Ada_LALR_Parse is new Gen_Run_Wisi_LR_Parse
(Wisi.Ada.Parse_Data_Type,
WisiToken.Parse.LR.McKenzie_Recover.Ada.Language_Fixes'Access,
WisiToken.Parse.LR.McKenzie_Recover.Ada.Matching_Begin_Tokens'Access,
WisiToken.Parse.LR.McKenzie_Recover.Ada.String_ID_Set'Access,
Ada_Annex_P_Process_LALR_Main.Create_Parser);
|
reznikmm/matreshka | Ada | 4,652 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with System.Storage_Elements;
private with System;
with League.Strings;
private with AMF3.Object_References;
with AMF3.Slots;
private with AMF3.Slots.Collections;
with AMF3.Metadata;
package AMF3.Objects is
-- pragma Preelaborate;
function To_Slot (Address : System.Address) return AMF3.Slots.Slot_Access;
---------------------
-- Abstract_Object --
---------------------
Object_Descriptor : aliased constant AMF3.Metadata.Descriptor;
type Abstract_Object
(Metadata : access constant AMF3.Metadata.Descriptor
:= Object_Descriptor'Access) is abstract tagged limited private;
not overriding procedure On_Property_Changed
(Self : in out Abstract_Object) is null;
private
Object_Descriptor : aliased constant AMF3.Metadata.Descriptor
:= (Name => League.Strings.Empty_Universal_String,
Superclass_Count => 0,
Superclasses => (others => <>),
Slot_Count => 0,
Slots => (others => <>));
type Abstract_Object
(Metadata : access constant AMF3.Metadata.Descriptor
:= Object_Descriptor'Access) is abstract tagged limited
record
Default : aliased
AMF3.Slots.Collections.Collection_Slot (Abstract_Object'Access);
end record;
end AMF3.Objects;
|
AdaCore/training_material | Ada | 2,632 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT EXAMPLE --
-- --
-- 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. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This file provides declarations for the blue user button on the STM32F4
-- Discovery board from ST Microelectronics.
with Ada.Interrupts.Names;
with Ada.Real_Time; use Ada.Real_Time;
package My_Button is
pragma Elaborate_Body;
protected Button is
pragma Interrupt_Priority;
entry Wait_Press;
private
procedure Interrupt_Handler;
pragma Attach_Handler
(Interrupt_Handler,
Ada.Interrupts.Names.EXTI0_Interrupt);
Last_Time : Time := Clock;
Is_Pressed : Boolean := False;
end Button;
end My_Button;
|
SayCV/rtems-addon-packages | Ada | 6,253 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- Rain --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998-2007,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: Laurent Pautet <[email protected]>
-- Modified by: Juergen Pfeifer, 1997
-- Version Control
-- $Revision$
-- $Date$
-- Binding Version 01.00
------------------------------------------------------------------------------
-- --
with ncurses2.util; use ncurses2.util;
with Ada.Numerics.Float_Random; use Ada.Numerics.Float_Random;
with Status; use Status;
with Terminal_Interface.Curses; use Terminal_Interface.Curses;
procedure Rain is
Visibility : Cursor_Visibility;
subtype X_Position is Line_Position;
subtype Y_Position is Column_Position;
Xpos : array (1 .. 5) of X_Position;
Ypos : array (1 .. 5) of Y_Position;
done : Boolean;
c : Key_Code;
N : Integer;
G : Generator;
Max_X, X : X_Position;
Max_Y, Y : Y_Position;
procedure Next (J : in out Integer);
procedure Cursor (X : X_Position; Y : Y_Position);
procedure Next (J : in out Integer) is
begin
if J = 5 then
J := 1;
else
J := J + 1;
end if;
end Next;
procedure Cursor (X : X_Position; Y : Y_Position) is
begin
Move_Cursor (Line => X, Column => Y);
end Cursor;
pragma Inline (Cursor);
begin
Init_Screen;
Set_NL_Mode;
Set_Echo_Mode (False);
Visibility := Invisible;
Set_Cursor_Visibility (Visibility);
Set_Timeout_Mode (Standard_Window, Non_Blocking, 0);
Max_X := Lines - 5;
Max_Y := Columns - 5;
for I in Xpos'Range loop
Xpos (I) := X_Position (Float (Max_X) * Random (G)) + 2;
Ypos (I) := Y_Position (Float (Max_Y) * Random (G)) + 2;
end loop;
N := 1;
done := False;
while not done and Process.Continue loop
X := X_Position (Float (Max_X) * Random (G)) + 2;
Y := Y_Position (Float (Max_Y) * Random (G)) + 2;
Cursor (X, Y);
Add (Ch => '.');
Cursor (Xpos (N), Ypos (N));
Add (Ch => 'o');
--
Next (N);
Cursor (Xpos (N), Ypos (N));
Add (Ch => 'O');
--
Next (N);
Cursor (Xpos (N) - 1, Ypos (N));
Add (Ch => '-');
Cursor (Xpos (N), Ypos (N) - 1);
Add (Str => "|.|");
Cursor (Xpos (N) + 1, Ypos (N));
Add (Ch => '-');
--
Next (N);
Cursor (Xpos (N) - 2, Ypos (N));
Add (Ch => '-');
Cursor (Xpos (N) - 1, Ypos (N) - 1);
Add (Str => "/\\");
Cursor (Xpos (N), Ypos (N) - 2);
Add (Str => "| O |");
Cursor (Xpos (N) + 1, Ypos (N) - 1);
Add (Str => "\\/");
Cursor (Xpos (N) + 2, Ypos (N));
Add (Ch => '-');
--
Next (N);
Cursor (Xpos (N) - 2, Ypos (N));
Add (Ch => ' ');
Cursor (Xpos (N) - 1, Ypos (N) - 1);
Add (Str => " ");
Cursor (Xpos (N), Ypos (N) - 2);
Add (Str => " ");
Cursor (Xpos (N) + 1, Ypos (N) - 1);
Add (Str => " ");
Cursor (Xpos (N) + 2, Ypos (N));
Add (Ch => ' ');
Xpos (N) := X;
Ypos (N) := Y;
c := Getchar;
case c is
when Character'Pos ('q') => done := True;
when Character'Pos ('Q') => done := True;
when Character'Pos ('s') => Set_NoDelay_Mode (Standard_Window, False);
when Character'Pos (' ') => Set_NoDelay_Mode (Standard_Window, True);
when others => null;
end case;
Nap_Milli_Seconds (50);
end loop;
Visibility := Normal;
Set_Cursor_Visibility (Visibility);
End_Windows;
Curses_Free_All;
end Rain;
|
reznikmm/matreshka | Ada | 6,902 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Office.Annotation_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Office_Annotation_Element_Node is
begin
return Self : Office_Annotation_Element_Node do
Matreshka.ODF_Office.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Office_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Office_Annotation_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Office_Annotation
(ODF.DOM.Office_Annotation_Elements.ODF_Office_Annotation_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Office_Annotation_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Annotation_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Office_Annotation_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Office_Annotation
(ODF.DOM.Office_Annotation_Elements.ODF_Office_Annotation_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Office_Annotation_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Office_Annotation
(Visitor,
ODF.DOM.Office_Annotation_Elements.ODF_Office_Annotation_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Office_URI,
Matreshka.ODF_String_Constants.Annotation_Element,
Office_Annotation_Element_Node'Tag);
end Matreshka.ODF_Office.Annotation_Elements;
|
AdaCore/libadalang | Ada | 46 | ads | procedure Aaa.Aaa.Aaa.Aaa;
pragma Test_Block;
|
ecalderini/bingada | Ada | 432 | ads | --*****************************************************************************
--*
--* PROJECT: BingAda
--*
--* FILE: q_bingo_help.ads
--*
--* AUTHOR: Javier Fuica Fernandez
--*
--*****************************************************************************
with GTK.WINDOW;
package Q_BINGO_HELP is
procedure P_SHOW_WINDOW (V_PARENT_WINDOW : GTK.WINDOW.GTK_WINDOW);
end Q_BINGO_HELP;
|
tum-ei-rcs/StratoX | Ada | 799 | adb | package body LogQueue with SPARK_Mode is
protected body queue is
procedure Put (msg : mylog.logmsg) is
buf_int : mylog.logmsg;
begin
buf := msg;
buf_int := msg;
Not_Empty := True;
end Put;
entry Get (msg : out mylog.logmsg) when Not_Empty is
msg_ucon : mylog.logmsg (TEXT);
begin
msg := buf;
msg_ucon := buf;
Not_Empty := False;
end Get;
end queue;
procedure mytest is
msg_ucon : mylog.logmsg (GPS);
begin
myqueue.Get (msg_ucon); -- this call is not analyzed, because there is no
-- precondition. But we would need one to tell
-- that the parameter must be unconstrained
end mytest;
end LogQueue;
|
reznikmm/matreshka | Ada | 5,683 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
-- A test identity action is an action that tests if two values are identical
-- objects.
------------------------------------------------------------------------------
with AMF.UML.Actions;
limited with AMF.UML.Input_Pins;
limited with AMF.UML.Output_Pins;
package AMF.UML.Test_Identity_Actions is
pragma Preelaborate;
type UML_Test_Identity_Action is limited interface
and AMF.UML.Actions.UML_Action;
type UML_Test_Identity_Action_Access is
access all UML_Test_Identity_Action'Class;
for UML_Test_Identity_Action_Access'Storage_Size use 0;
not overriding function Get_First
(Self : not null access constant UML_Test_Identity_Action)
return AMF.UML.Input_Pins.UML_Input_Pin_Access is abstract;
-- Getter of TestIdentityAction::first.
--
-- Gives the pin on which an object is placed.
not overriding procedure Set_First
(Self : not null access UML_Test_Identity_Action;
To : AMF.UML.Input_Pins.UML_Input_Pin_Access) is abstract;
-- Setter of TestIdentityAction::first.
--
-- Gives the pin on which an object is placed.
not overriding function Get_Result
(Self : not null access constant UML_Test_Identity_Action)
return AMF.UML.Output_Pins.UML_Output_Pin_Access is abstract;
-- Getter of TestIdentityAction::result.
--
-- Tells whether the two input objects are identical.
not overriding procedure Set_Result
(Self : not null access UML_Test_Identity_Action;
To : AMF.UML.Output_Pins.UML_Output_Pin_Access) is abstract;
-- Setter of TestIdentityAction::result.
--
-- Tells whether the two input objects are identical.
not overriding function Get_Second
(Self : not null access constant UML_Test_Identity_Action)
return AMF.UML.Input_Pins.UML_Input_Pin_Access is abstract;
-- Getter of TestIdentityAction::second.
--
-- Gives the pin on which an object is placed.
not overriding procedure Set_Second
(Self : not null access UML_Test_Identity_Action;
To : AMF.UML.Input_Pins.UML_Input_Pin_Access) is abstract;
-- Setter of TestIdentityAction::second.
--
-- Gives the pin on which an object is placed.
end AMF.UML.Test_Identity_Actions;
|
micahwelf/FLTK-Ada | Ada | 1,526 | ads |
package FLTK.Widgets.Groups.Windows.Single.Menu is
type Menu_Window is new Single_Window with private;
type Menu_Window_Reference (Data : not null access Menu_Window'Class) is
limited null record with Implicit_Dereference => Data;
package Forge is
function Create
(X, Y, W, H : in Integer;
Text : in String)
return Menu_Window;
function Create
(W, H : in Integer;
Text : in String)
return Menu_Window;
end Forge;
procedure Show
(This : in out Menu_Window);
procedure Hide
(This : in out Menu_Window);
procedure Flush
(This : in out Menu_Window);
function Is_Overlay
(This : in Menu_Window)
return Boolean;
procedure Set_Overlay
(This : in out Menu_Window;
Value : in Boolean);
procedure Draw
(This : in out Menu_Window);
function Handle
(This : in out Menu_Window;
Event : in Event_Kind)
return Event_Outcome;
private
type Menu_Window is new Single_Window with null record;
overriding procedure Finalize
(This : in out Menu_Window);
pragma Inline (Show);
pragma Inline (Hide);
pragma Inline (Flush);
pragma Inline (Is_Overlay);
pragma Inline (Set_Overlay);
pragma Inline (Draw);
pragma Inline (Handle);
end FLTK.Widgets.Groups.Windows.Single.Menu;
|
persan/spawn-manager | Ada | 9,612 | adb | with GNAT.Sockets; use GNAT.Sockets;
with GNAT.Random_Numbers;
with Ada.Directories; use Ada.Directories;
with Ada.Command_Line;
with GNAT.IO;
package body Spawn_Manager.Client is
Initialized : Boolean := False;
Address : Sock_Addr_Type;
Socket : Socket_Type;
Server : Socket_Type;
Channel : Stream_Access;
Id : Long_Integer;
Lock : aliased GNAT.Semaphores.Binary_Semaphore (True, GNAT.Semaphores.Default_Ceiling);
function Image (P : GNAT.Sockets.Port_Type) return String;
function Image (P : GNAT.Sockets.Port_Type) return String is
Ret : constant String := P'Img;
begin
return Ret (Ret'First + 1 .. Ret'Last);
end Image;
overriding procedure Initialize (Object : in out Controler) is
Args : GNAT.OS_Lib.Argument_List_Access := new GNAT.OS_Lib.Argument_List (1 .. 3);
Pid : GNAT.OS_Lib.Process_Id;
Exe : GNAT.OS_Lib.String_Access;
Gen : GNAT.Random_Numbers.Generator;
Key : Key_Type (Lock'Access); pragma Unreferenced (Key);
begin
if Initialized then
raise Program_Error with "only one controler per executabel is allowed";
end if;
GNAT.Random_Numbers.Reset (Gen);
Id := GNAT.Random_Numbers.Random (Gen);
declare
Cmd : constant String := Ada.Command_Line.Command_Name;
Dir : constant String := Containing_Directory (Cmd);
Tmp : constant String := Current_Directory;
begin
Set_Directory (Dir);
declare
New_Name : constant String := Compose (Current_Directory, Object.Server_Name.all);
begin
GNAT.IO.Put_Line (New_Name);
if Ada.Directories.Exists (New_Name) then
Free (Exe);
Exe := new String'(New_Name);
end if;
end;
Set_Directory (Tmp);
end;
if Exe = null then
Exe := GNAT.OS_Lib.Locate_Exec_On_Path (Object.Server_Name.all);
end if;
if Exe = null then
raise Program_Error with "Unable to locate server '" & Object.Server_Name.all & "'";
end if;
Address.Addr := Loopback_Inet_Addr;
Address.Port := Any_Port;
Create_Socket (Server);
Bind_Socket (Server, Address);
Listen_Socket (Server);
Args (1) := new String'(Image (Get_Socket_Name (Server).Addr));
Args (2) := new String'(Image (Get_Socket_Name (Server).Port));
Args (3) := new String'(Id'Img);
if Debug then
GNAT.IO.Put (Exe.all);
for I of Args.all loop
GNAT.IO.Put (" " & I.all);
end loop;
GNAT.IO.Put_Line ("");
end if;
Pid := GNAT.OS_Lib.Non_Blocking_Spawn (Exe.all, Args.all);
if Pid = GNAT.OS_Lib.Invalid_Pid then
Close_Socket (Server);
raise Program_Error with "Unable to launch server '" & Exe.all & "'";
end if;
GNAT.OS_Lib.Free (Args);
GNAT.OS_Lib.Free (Exe);
Accept_Socket (Server, Socket, Address);
Channel := Stream (Socket, Address);
Initialized := True;
end Initialize;
overriding procedure Finalize (Object : in out Controler) is
pragma Unreferenced (Object);
Command : Spawn_Request;
Key : Key_Type (Lock'Access); pragma Unreferenced (Key);
begin
if Initialized then
Command.Id := Id;
Command.Spawn_Type := Terminate_Server;
Command.Program_Name := Null_Unbounded_String;
Spawn_Request'Write (Channel, Command);
Initialized := False;
Close_Socket (Socket);
Close_Socket (Server);
Initialized := False;
end if;
end Finalize;
-----------
-- Spawn --
-----------
procedure Spawn
(Program_Name : String;
Args : GNAT.OS_Lib.Argument_List;
Success : out Boolean)
is
Command : Spawn_Request;
Response : Spawn_Response;
Key : Key_Type (Lock'Access); pragma Unreferenced (Key);
begin
if not Initialized then
raise Program_Error with "Uninitialized server not running";
end if;
Command.Id := Id;
Command.Spawn_Type := Spawn_1;
Command.Program_Name := To_Unbounded_String (Program_Name);
for I of Args loop
Command.Args.Append (To_Unbounded_String (I.all));
end loop;
Spawn_Request'Write (Channel, Command);
Spawn_Response'Read (Channel, Response);
Success := Response.Success;
end Spawn;
-----------
-- Spawn --
-----------
function Spawn
(Program_Name : String;
Args : GNAT.OS_Lib.Argument_List)
return Integer
is
Command : Spawn_Request;
Response : Spawn_Response;
Key : Key_Type (Lock'Access); pragma Unreferenced (Key);
begin
if not Initialized then
raise Program_Error with "Uninitialized server not running";
end if;
Command.Id := Id;
Command.Spawn_Type := Spawn_2;
Command.Program_Name := To_Unbounded_String (Program_Name);
for I of Args loop
Command.Args.Append (To_Unbounded_String (I.all));
end loop;
Spawn_Request'Write (Channel, Command);
Spawn_Response'Read (Channel, Response);
return Response.Return_Code;
end Spawn;
-----------
-- Spawn --
-----------
procedure Spawn
(Program_Name : String;
Args : GNAT.OS_Lib.Argument_List;
Output_File : String;
Success : out Boolean;
Return_Code : out Integer;
Err_To_Out : Boolean := True)
is
Command : Spawn_Request;
Response : Spawn_Response;
Key : Key_Type (Lock'Access); pragma Unreferenced (Key);
begin
if not Initialized then
raise Program_Error with "Uninitialized server not running";
end if;
Command.Id := Id;
Command.Spawn_Type := Spawn_3;
Command.Program_Name := To_Unbounded_String (Program_Name);
for I of Args loop
Command.Args.Append (To_Unbounded_String (I.all));
end loop;
Command.Output_File := To_Unbounded_String (Output_File);
Command.Err_To_Out := Err_To_Out;
Spawn_Request'Write (Channel, Command);
Spawn_Response'Read (Channel, Response);
Success := Response.Success;
Return_Code := Response.Return_Code;
end Spawn;
function Non_Blocking_Spawn
(Program_Name : String;
Args : Argument_List) return Process_Id is
Command : Spawn_Request;
Response : Spawn_Response;
Key : Key_Type (Lock'Access); pragma Unreferenced (Key);
begin
if not Initialized then
raise Program_Error with "Uninitialized server not running";
end if;
Command.Id := Id;
Command.Spawn_Type := Non_Blocking_Spawn_1;
Command.Program_Name := To_Unbounded_String (Program_Name);
for I of Args loop
Command.Args.Append (To_Unbounded_String (I.all));
end loop;
Spawn_Request'Write (Channel, Command);
Spawn_Response'Read (Channel, Response);
return Response.Pid;
end Non_Blocking_Spawn;
function Non_Blocking_Spawn
(Program_Name : String;
Args : Argument_List;
Output_File : String;
Err_To_Out : Boolean := True) return Process_Id is
Command : Spawn_Request;
Response : Spawn_Response;
Key : Key_Type (Lock'Access); pragma Unreferenced (Key);
begin
if not Initialized then
raise Program_Error with "Uninitialized server not running";
end if;
Command.Id := Id;
Command.Spawn_Type := Non_Blocking_Spawn_2;
Command.Program_Name := To_Unbounded_String (Program_Name);
for I of Args loop
Command.Args.Append (To_Unbounded_String (I.all));
end loop;
Command.Output_File := To_Unbounded_String (Output_File);
Command.Err_To_Out := Err_To_Out;
Spawn_Request'Write (Channel, Command);
Spawn_Response'Read (Channel, Response);
return Response.Pid;
end Non_Blocking_Spawn;
procedure Wait_Process (Pid : out Process_Id; Success : out Boolean) is
Command : Spawn_Request;
Response : Spawn_Response;
Key : Key_Type (Lock'Access); pragma Unreferenced (Key);
begin
if not Initialized then
raise Program_Error with "Uninitialized server not running";
end if;
Command.Id := Id;
Command.Spawn_Type := Wait_Process;
Spawn_Request'Write (Channel, Command);
Spawn_Response'Read (Channel, Response);
Success := Response.Success;
Pid := Response.Pid;
end Wait_Process;
function Waitpid
(Pid : Process_Id;
Status : out Status_Kind;
Options : Wait_Options) return Process_Id is
Command : Spawn_Request;
Response : Spawn_Response;
Key : Key_Type (Lock'Access); pragma Unreferenced (Key);
begin
if not Initialized then
raise Program_Error with "Uninitialized server not running";
end if;
Command.Id := Id;
Command.Spawn_Type := Waitpid;
Command.Pid := Pid;
Command.Options := Options;
Spawn_Request'Write (Channel, Command);
Spawn_Response'Read (Channel, Response);
Status := Status_Kind (Response.Return_Code);
return Response.Pid;
end Waitpid;
overriding procedure Initialize (Object : in out Key_Type) is
begin
Object.Sema.all.Seize;
end Initialize;
overriding procedure Finalize (Object : in out Key_Type) is
begin
Object.Sema.all.Release;
end Finalize;
end Spawn_Manager.Client;
|
docandrew/sdlada | Ada | 20,091 | 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 Ada.Unchecked_Conversion;
with SDL.Error;
package body SDL.Video.Surfaces is
use type C.int;
function Pixel_Format (Self : in Surface) return Pixel_Formats.Pixel_Format_Access is
begin
return Self.Internal.Pixel_Format;
end Pixel_Format;
function Size (Self : in Surface) return SDL.Sizes is
begin
return SDL.Sizes'(Self.Internal.Width, Self.Internal.Height);
end Size;
function Pixels (Self : in Surface) return System.Address is
use type C.int;
begin
if Must_Lock (Self) and then Self.Internal.Locked <= 0 then
raise Surface_Error with "Surface must be locked before access can be gained to the pixel data.";
end if;
return Self.Internal.Pixels;
end Pixels;
package body User_Data is
function Convert is new Ada.Unchecked_Conversion (Source => Data_Pointer,
Target => User_Data_Pointer);
function Convert is new Ada.Unchecked_Conversion (Source => User_Data_Pointer,
Target => Data_Pointer);
function Get (Self : in Surface) return Data_Pointer is
begin
return Convert (Self.Internal.User_Data);
end Get;
procedure Set (Self : in out Surface; Data : in Data_Pointer) is
begin
Self.Internal.User_Data := Convert (Data);
end Set;
end User_Data;
procedure Blit (Self : in out Surface;
Source : in Surface) is
function SDL_Blit_Surface (S : in Internal_Surface_Pointer;
SR : access Rectangles.Rectangle;
D : in Internal_Surface_Pointer;
DR : access Rectangles.Rectangle) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_UpperBlit"; -- SDL_BlitSurface is a macro in SDL_surface.h
Result : C.int := SDL_Blit_Surface (Source.Internal, null, Self.Internal, null);
begin
if Result /= SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
end Blit;
procedure Blit (Self : in out Surface;
Self_Area : in out Rectangles.Rectangle;
Source : in Surface;
Source_Area : in out Rectangles.Rectangle) is
function SDL_Blit_Surface (S : in Internal_Surface_Pointer;
SR : access Rectangles.Rectangle;
D : in Internal_Surface_Pointer;
DR : access Rectangles.Rectangle) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_UpperBlit"; -- SDL_BlitSurface is a macro in SDL_surface.h
use type Rectangles.Rectangle;
Result : C.int := 0;
Src_Area : aliased Rectangles.Rectangle := Source_Area;
Dest_Area : aliased Rectangles.Rectangle := Self_Area;
begin
if Dest_Area = Rectangles.Null_Rectangle then
if Src_Area = Rectangles.Null_Rectangle then
Result := SDL_Blit_Surface (Source.Internal, null, Self.Internal, null);
else
Result := SDL_Blit_Surface (Source.Internal, Src_Area'Access, Self.Internal, null);
Source_Area := Src_Area;
end if;
else
if Src_Area = Rectangles.Null_Rectangle then
Result := SDL_Blit_Surface (Source.Internal, null, Self.Internal, Dest_Area'Access);
else
Result := SDL_Blit_Surface (Source.Internal, Src_Area'Access, Self.Internal, Dest_Area'Access);
Source_Area := Src_Area;
end if;
Self_Area := Dest_Area;
end if;
if Result /= SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
end Blit;
procedure Blit_Scaled (Self : in out Surface;
Source : in Surface) is
function SDL_Blit_Scaled (S : in Internal_Surface_Pointer;
SR : access Rectangles.Rectangle;
D : in Internal_Surface_Pointer;
DR : access Rectangles.Rectangle) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_UpperBlitScaled"; -- SDL_BlitScaled is a macro in SDL_surface.h
Result : C.int := SDL_Blit_Scaled (Source.Internal, null, Self.Internal, null);
begin
if Result /= SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
end Blit_Scaled;
-- Blit_Scaled
--
-- Self : The destination surface to blit onto.
-- Self_Area : The coordinates and size of the area to blit into.
-- Source : The surface to blit onto Self.
-- Source_Area : The coordinates and size of the area to blit from.
procedure Blit_Scaled (Self : in out Surface;
Self_Area : in out Rectangles.Rectangle;
Source : in Surface;
Source_Area : in Rectangles.Rectangle := Rectangles.Null_Rectangle) is
function SDL_Blit_Scaled (S : in Internal_Surface_Pointer;
SR : access Rectangles.Rectangle;
D : in Internal_Surface_Pointer;
DR : access Rectangles.Rectangle) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_UpperBlitScaled"; -- SDL_BlitScaled is a macro in SDL_surface.h
use type Rectangles.Rectangle;
Result : C.int := 0;
Area : aliased Rectangles.Rectangle := Self_Area;
Src_Area : aliased Rectangles.Rectangle := Source_Area;
begin
if Self_Area = Rectangles.Null_Rectangle then
if Source_Area = Rectangles.Null_Rectangle then
Result := SDL_Blit_Scaled (Source.Internal, null, Self.Internal, null);
else
Result := SDL_Blit_Scaled (Source.Internal, Src_Area'Access, Self.Internal, null);
end if;
else
if Source_Area = Rectangles.Null_Rectangle then
Result := SDL_Blit_Scaled (Source.Internal, null, Self.Internal, Area'Access);
else
Result := SDL_Blit_Scaled (Source.Internal, Src_Area'Access, Self.Internal, Area'Access);
end if;
Self_Area := Area;
end if;
if Result /= SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
end Blit_Scaled;
procedure Lower_Blit (Self : in out Surface;
Self_Area : in Rectangles.Rectangle;
Source : in Surface;
Source_Area : in Rectangles.Rectangle) is
function SDL_Lower_Blit (S : in Internal_Surface_Pointer;
SR : in Rectangles.Rectangle;
D : in Internal_Surface_Pointer;
DR : in Rectangles.Rectangle) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_LowerBlit";
Result : C.int := SDL_Lower_Blit (Source.Internal, Source_Area, Self.Internal, Self_Area);
begin
if Result /= SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
end Lower_Blit;
procedure Lower_Blit_Scaled (Self : in out Surface;
Self_Area : in Rectangles.Rectangle;
Source : in Surface;
Source_Area : in Rectangles.Rectangle) is
function SDL_Lower_Blit_Scaled (S : in Internal_Surface_Pointer;
SR : in Rectangles.Rectangle;
D : in Internal_Surface_Pointer;
DR : in Rectangles.Rectangle) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_LowerBlitScaled";
Result : C.int := SDL_Lower_Blit_Scaled (Source.Internal, Source_Area, Self.Internal, Self_Area);
begin
if Result /= SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
end Lower_Blit_Scaled;
procedure Fill (Self : in out Surface;
Area : in Rectangles.Rectangle;
Colour : in Interfaces.Unsigned_32) is
function SDL_Fill_Rect (S : in Internal_Surface_Pointer;
Rect : in Rectangles.Rectangle;
Colour : in Interfaces.Unsigned_32) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_FillRect";
Result : C.int := SDL_Fill_Rect (Self.Internal, Area, Colour);
begin
if Result < SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
end Fill;
procedure Fill (Self : in out Surface;
Areas : in Rectangles.Rectangle_Arrays;
Colour : in Interfaces.Unsigned_32) is
function SDL_Fill_Rects (S : in Internal_Surface_Pointer;
Rects : in Rectangles.Rectangle_Arrays;
Count : in C.int;
Colour : in Interfaces.Unsigned_32) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_FillRects";
Result : C.int := SDL_Fill_Rects (Self.Internal, Areas, Areas'Length, Colour);
begin
if Result < SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
end Fill;
function Clip_Rectangle (Self : in Surface) return Rectangles.Rectangle is
procedure SDL_Get_Clip_Rect (S : in Internal_Surface_Pointer;
R : out Rectangles.Rectangle) with
Import => True,
Convention => C,
External_Name => "SDL_GetClipRect";
begin
return Result : Rectangles.Rectangle := Rectangles.Null_Rectangle do
SDL_Get_Clip_Rect (Self.Internal, Result);
end return;
end Clip_Rectangle;
procedure Set_Clip_Rectangle (Self : in out Surface; Now : in Rectangles.Rectangle) is
function SDL_Set_Clip_Rect (S : in Internal_Surface_Pointer;
R : in Rectangles.Rectangle) return SDL_Bool with
Import => True,
Convention => C,
External_Name => "SDL_SetClipRect";
Result : SDL_Bool := SDL_Set_Clip_Rect (S => Self.Internal, R => Now);
begin
if Result = SDL_False then
raise Surface_Error with SDL.Error.Get;
end if;
end Set_Clip_Rectangle;
function Colour_Key (Self : in Surface) return Palettes.Colour is
function SDL_Get_Color_Key (S : in Internal_Surface_Pointer;
K : out Interfaces.Unsigned_32) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_GetColorKey";
Key : Interfaces.Unsigned_32;
Result : C.int := SDL_Get_Color_Key (Self.Internal, Key);
begin
if Result < SDL.Success then
-- TODO: The SDL source does not set an error message, see https://bugzilla.libsdl.org/show_bug.cgi?id=3992
raise Surface_Error with "No colour key set for this surface."; -- with SDL.Error.Get;
end if;
return Pixel_Formats.To_Colour (Pixel => Key,
Format => Self.Pixel_Format);
end Colour_Key;
procedure Set_Colour_Key (Self : in out Surface; Now : in Palettes.Colour; Enable : in Boolean := True) is
-- TODO: This can work as an "in out Internal_Surface" as the compiler will pass the object as a reference.
-- Should the entire API use this? For review!
function SDL_Set_Color_Key (S : in Internal_Surface_Pointer;
F : in C.int;
K : in Interfaces.Unsigned_32) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_SetColorKey";
Result : C.int := SDL_Set_Color_Key (S => Self.Internal,
F => (if Enable then 1 else 0),
K => Pixel_Formats.To_Pixel (Colour => Now,
Format => Self.Pixel_Format));
begin
if Result < SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
end Set_Colour_Key;
function Alpha_Blend (Self : in Surface) return Palettes.Colour_Component is
function SDL_Get_Surface_Alpha_Mod (S : in Internal_Surface_Pointer;
A : out Palettes.Colour_Component) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_GetSurfaceAlphaMod";
Alpha : Palettes.Colour_Component;
Result : C.int := SDL_Get_Surface_Alpha_Mod (S => Self.Internal, A => Alpha);
begin
if Result < SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
return Alpha;
end Alpha_Blend;
procedure Set_Alpha_Blend (Self : in out Surface; Now : in Palettes.Colour_Component) is
function SDL_Set_Surface_Alpha_Mod (S : in Internal_Surface_Pointer;
A : in Palettes.Colour_Component) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_SetSurfaceAlphaMod";
Result : C.int := SDL_Set_Surface_Alpha_Mod (S => Self.Internal, A => Now);
begin
if Result < SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
end Set_Alpha_Blend;
function Blend_Mode (Self : in Surface) return Blend_Modes is
function SDL_Get_Surface_Blend_Mode (S : in Internal_Surface_Pointer;
B : out Blend_Modes) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_GetSurfaceAlphaMod";
Blend_Mode : Blend_Modes;
Result : C.int := SDL_Get_Surface_Blend_Mode (S => Self.Internal, B => Blend_Mode);
begin
if Result < SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
return Blend_Mode;
end Blend_Mode;
procedure Set_Blend_Mode (Self : in out Surface; Now : in Blend_Modes) is
function SDL_Set_Surface_Blend_Mode (S : in Internal_Surface_Pointer;
B : in Blend_Modes) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_SetSurfaceBlendMode";
Result : C.int := SDL_Set_Surface_Blend_Mode (S => Self.Internal, B => Now);
begin
if Result < SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
end Set_Blend_Mode;
function Colour (Self : in Surface) return Palettes.RGB_Colour is
function SDL_Get_Surface_Color_Mod (S : in Internal_Surface_Pointer;
R : out Palettes.Colour_Component;
G : out Palettes.Colour_Component;
B : out Palettes.Colour_Component) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_GetSurfaceColorMod";
Red : Palettes.Colour_Component;
Green : Palettes.Colour_Component;
Blue : Palettes.Colour_Component;
Result : C.int := SDL_Get_Surface_Color_Mod (S => Self.Internal, R => Red, G => Green, B => Blue);
begin
if Result < SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
return (Red, Green, Blue);
end Colour;
procedure Set_Colour (Self : in out Surface; Now : in Palettes.RGB_Colour) is
function SDL_Set_Surface_Color_Mod (S : in Internal_Surface_Pointer;
R : in Palettes.Colour_Component;
G : in Palettes.Colour_Component;
B : in Palettes.Colour_Component) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_SetSurfaceColorMod";
Result : C.int := SDL_Set_Surface_Color_Mod (S => Self.Internal, R => Now.Red, G => Now.Green, B => Now.Blue);
begin
if Result < SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
end Set_Colour;
procedure Lock (Self : in out Surface) is
function SDL_Lock_Surface (Self : in Internal_Surface_Pointer) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_LockSurface";
Result : C.int := SDL_Lock_Surface (Self.Internal);
begin
if Result < SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
end Lock;
procedure Unlock (Self : in out Surface) is
procedure SDL_Unlock_Surface (Self : in Internal_Surface_Pointer) with
Import => True,
Convention => C,
External_Name => "SDL_UnlockSurface";
begin
SDL_Unlock_Surface (Self.Internal);
end Unlock;
procedure Set_RLE (Self : in out Surface; Enabled : in Boolean) is
function SDL_Set_Surface_RLE (Self : in Internal_Surface_Pointer; Enabled : in C.int) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_SetSurfaceRLE";
Result : C.int := SDL_Set_Surface_RLE (Self.Internal, C.int (if Enabled then 1 else 0));
begin
if Result < SDL.Success then
raise Surface_Error with SDL.Error.Get;
end if;
end Set_RLE;
-- This is equivalent to the macro SDL_MUSTLOCK in SDL_surface.h.
function Must_Lock (Self : in Surface) return Boolean is
begin
return (Self.Internal.Flags and RLE_Encoded) = RLE_Encoded;
end Must_Lock;
overriding
procedure Adjust (Self : in out Surface) is
begin
-- if Self.Internal.Flags and Dont_Free = Dont_Free then
-- end if;
if Self.Internal /= null and Self.Owns then
Self.Internal.Reference_Count := Self.Internal.Reference_Count + 1;
end if;
end Adjust;
overriding
procedure Finalize (Self : in out Surface) is
procedure SDL_Free_Surface (S : in Internal_Surface_Pointer) with
Import => True,
Convention => C,
External_Name => "SDL_FreeSurface";
begin
if Self.Internal /= null and then Self.Owns then
SDL_Free_Surface (Self.Internal);
end if;
end Finalize;
end SDL.Video.Surfaces;
|
twdroeger/ada-awa | Ada | 3,071 | adb | -----------------------------------------------------------------------
-- awa-commands-stop -- Command to stop the web server
-- Copyright (C) 2020 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with GNAT.Sockets;
with Util.Streams.Sockets;
with Util.Streams.Texts;
package body AWA.Commands.Stop is
-- ------------------------------
-- Setup the command before parsing the arguments and executing it.
-- ------------------------------
overriding
procedure Setup (Command : in out Command_Type;
Config : in out GNAT.Command_Line.Command_Line_Configuration;
Context : in out Context_Type) is
begin
GC.Set_Usage (Config => Config,
Usage => Command.Get_Name & " [arguments]",
Help => Command.Get_Description);
GC.Define_Switch (Config => Config,
Output => Command.Management_Port'Access,
Switch => "-m:",
Long_Switch => "--management-port=",
Initial => Command.Management_Port,
Argument => "NUMBER",
Help => -("The server listening management port on localhost"));
AWA.Commands.Setup_Command (Config, Context);
end Setup;
-- ------------------------------
-- Stop the server by sending a 'stop' command on the management socket.
-- ------------------------------
overriding
procedure Execute (Command : in out Command_Type;
Name : in String;
Args : in Argument_List'Class;
Context : in out Context_Type) is
pragma Unreferenced (Name, Args, Context);
Address : GNAT.Sockets.Sock_Addr_Type;
Stream : aliased Util.Streams.Sockets.Socket_Stream;
Writer : Util.Streams.Texts.Print_Stream;
begin
Address.Addr := GNAT.Sockets.Loopback_Inet_Addr;
Address.Port := GNAT.Sockets.Port_Type (Command.Management_Port);
Stream.Connect (Address);
Writer.Initialize (Stream'Access, 1024);
Writer.Write ("stop" & ASCII.CR & ASCII.LF);
Writer.Flush;
Writer.Close;
end Execute;
begin
Command_Drivers.Driver.Add_Command ("stop",
-("stop the web server"),
Command'Access);
end AWA.Commands.Stop;
|
reznikmm/matreshka | Ada | 5,460 | 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.Standard_Profile_L2.Frameworks.Collections is
pragma Preelaborate;
package Standard_Profile_L2_Framework_Collections is
new AMF.Generic_Collections
(Standard_Profile_L2_Framework,
Standard_Profile_L2_Framework_Access);
type Set_Of_Standard_Profile_L2_Framework is
new Standard_Profile_L2_Framework_Collections.Set with null record;
Empty_Set_Of_Standard_Profile_L2_Framework : constant Set_Of_Standard_Profile_L2_Framework;
type Ordered_Set_Of_Standard_Profile_L2_Framework is
new Standard_Profile_L2_Framework_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_Standard_Profile_L2_Framework : constant Ordered_Set_Of_Standard_Profile_L2_Framework;
type Bag_Of_Standard_Profile_L2_Framework is
new Standard_Profile_L2_Framework_Collections.Bag with null record;
Empty_Bag_Of_Standard_Profile_L2_Framework : constant Bag_Of_Standard_Profile_L2_Framework;
type Sequence_Of_Standard_Profile_L2_Framework is
new Standard_Profile_L2_Framework_Collections.Sequence with null record;
Empty_Sequence_Of_Standard_Profile_L2_Framework : constant Sequence_Of_Standard_Profile_L2_Framework;
private
Empty_Set_Of_Standard_Profile_L2_Framework : constant Set_Of_Standard_Profile_L2_Framework
:= (Standard_Profile_L2_Framework_Collections.Set with null record);
Empty_Ordered_Set_Of_Standard_Profile_L2_Framework : constant Ordered_Set_Of_Standard_Profile_L2_Framework
:= (Standard_Profile_L2_Framework_Collections.Ordered_Set with null record);
Empty_Bag_Of_Standard_Profile_L2_Framework : constant Bag_Of_Standard_Profile_L2_Framework
:= (Standard_Profile_L2_Framework_Collections.Bag with null record);
Empty_Sequence_Of_Standard_Profile_L2_Framework : constant Sequence_Of_Standard_Profile_L2_Framework
:= (Standard_Profile_L2_Framework_Collections.Sequence with null record);
end AMF.Standard_Profile_L2.Frameworks.Collections;
|
sebsgit/textproc | Ada | 877 | adb | with Ada.Calendar;
with Ada.Text_IO;
use Ada.Calendar;
package body Timer is
function start return T is
result: T;
begin
result.clock := Ada.Calendar.Clock;
return result;
end start;
procedure reset(tm: in out T) is
begin
tm.clock := Ada.Calendar.Clock;
end reset;
function reset(tm: in out T) return Float is
oldTime: Ada.Calendar.Time;
begin
oldTime := tm.clock;
tm.clock := Ada.Calendar.Clock;
return Float(tm.clock - oldTime);
end reset;
procedure report(tm: in out T) is
dur: Float;
begin
dur := tm.reset;
Ada.Text_IO.Put_Line("Elapsed: " & dur'Image);
end report;
procedure report(tm: in out T; message: in String) is
dur: Float;
begin
dur := tm.reset;
Ada.Text_IO.Put_Line(message & ", elapsed: " & dur'Image);
end report;
end Timer;
|
jhumphry/auto_counters | Ada | 637 | ads | -- auto_counters_tests_config.ads
-- Configuration for Unit tests for Auto_Counters
-- Configuration for optimized builds
-- Copyright (c) 2016, James Humphry - see LICENSE file for details
package Auto_Counters_Tests_Config is
pragma Pure;
Assertions_Enabled : constant Boolean := False;
-- Some unit tests are checking that appropriate preconditions and assertions
-- are in place. In optimized builds where assertions are disabled these
-- tests will cause incorrect failure notifications or segfaults. The
-- Assertions_Enabled flag indicates whether these tests should be run.
end Auto_Counters_Tests_Config;
|
stcarrez/ada-util | Ada | 2,014 | adb | --
-- Copyright (c) 2007, 2008 Tero Koskinen <[email protected]>
--
-- Permission to use, copy, modify, and distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
--
with Ada.Command_Line;
with Ahven.Listeners;
with Ahven.Listeners.Basic;
package body Ahven.Runner is
use Ahven.Results;
procedure Run_Suite (Suite : in out Framework.Test'Class;
Reporter : Report_Proc) is
use Ahven.Listeners.Basic;
Listener : Listeners.Basic.Basic_Listener;
Params : Parameters.Parameter_Info;
begin
Parameters.Parse_Parameters (Parameters.NORMAL_PARAMETERS, Params);
Set_Output_Capture (Listener, Parameters.Capture (Params));
if Parameters.Single_Test (Params) then
Framework.Execute
(T => Suite, Test_Name => Parameters.Test_Name (Params),
Listener => Listener, Timeout => Parameters.Timeout (Params));
else
Framework.Execute (Suite, Listener, Parameters.Timeout (Params));
end if;
Reporter (Listener.Main_Result, Params);
if (Error_Count (Listener.Main_Result) > 0) or else
(Failure_Count (Listener.Main_Result) > 0)
then
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
end if;
exception
when Parameters.Invalid_Parameter =>
Parameters.Usage;
end Run_Suite;
end Ahven.Runner;
|
reznikmm/matreshka | Ada | 3,621 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Elements.Generic_Hash;
function AMF.UML.State_Invariants.Hash is
new AMF.Elements.Generic_Hash (UML_State_Invariant, UML_State_Invariant_Access);
|
Fabien-Chouteau/samd51-hal | Ada | 7,587 | ads | pragma Style_Checks (Off);
-- This spec has been automatically generated from ATSAMD51G19A.svd
pragma Restrictions (No_Elaboration_Code);
with HAL;
with System;
package SAM_SVD.GCLK is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Control
type GCLK_CTRLA_Register is record
-- Software Reset
SWRST : Boolean := False;
-- unspecified
Reserved_1_7 : HAL.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for GCLK_CTRLA_Register use record
SWRST at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
end record;
-- Generic Clock Generator Control n Synchronization Busy bits
type SYNCBUSY_GENCTRLSelect is
(-- Generic clock generator 0
GCLK0,
-- Generic clock generator 1
GCLK1,
-- Generic clock generator 2
GCLK2,
-- Generic clock generator 3
GCLK3,
-- Generic clock generator 4
GCLK4,
-- Generic clock generator 5
GCLK5,
-- Generic clock generator 6
GCLK6,
-- Generic clock generator 7
GCLK7,
-- Generic clock generator 8
GCLK8,
-- Generic clock generator 9
GCLK9,
-- Generic clock generator 10
GCLK10,
-- Generic clock generator 11
GCLK11)
with Size => 12;
for SYNCBUSY_GENCTRLSelect use
(GCLK0 => 1,
GCLK1 => 2,
GCLK2 => 4,
GCLK3 => 8,
GCLK4 => 16,
GCLK5 => 32,
GCLK6 => 64,
GCLK7 => 128,
GCLK8 => 256,
GCLK9 => 512,
GCLK10 => 1024,
GCLK11 => 2048);
-- Synchronization Busy
type GCLK_SYNCBUSY_Register is record
-- Read-only. Software Reset Synchroniation Busy bit
SWRST : Boolean;
-- unspecified
Reserved_1_1 : HAL.Bit;
-- Read-only. Generic Clock Generator Control n Synchronization Busy
-- bits
GENCTRL : SYNCBUSY_GENCTRLSelect;
-- unspecified
Reserved_14_31 : HAL.UInt18;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for GCLK_SYNCBUSY_Register use record
SWRST at 0 range 0 .. 0;
Reserved_1_1 at 0 range 1 .. 1;
GENCTRL at 0 range 2 .. 13;
Reserved_14_31 at 0 range 14 .. 31;
end record;
-- Source Select
type GENCTRL_SRCSelect is
(-- XOSC0 oscillator output
XOSC0,
-- XOSC1 oscillator output
XOSC1,
-- Generator input pad
GCLKIN,
-- Generic clock generator 1 output
GCLKGEN1,
-- OSCULP32K oscillator output
OSCULP32K,
-- XOSC32K oscillator output
XOSC32K,
-- DFLL output
DFLL,
-- DPLL0 output
DPLL0,
-- DPLL1 output
DPLL1)
with Size => 4;
for GENCTRL_SRCSelect use
(XOSC0 => 0,
XOSC1 => 1,
GCLKIN => 2,
GCLKGEN1 => 3,
OSCULP32K => 4,
XOSC32K => 5,
DFLL => 6,
DPLL0 => 7,
DPLL1 => 8);
-- Divide Selection
type GENCTRL_DIVSELSelect is
(-- Divide input directly by divider factor
DIV1,
-- Divide input by 2^(divider factor+ 1)
DIV2)
with Size => 1;
for GENCTRL_DIVSELSelect use
(DIV1 => 0,
DIV2 => 1);
subtype GCLK_GENCTRL_DIV_Field is HAL.UInt16;
-- Generic Clock Generator Control
type GCLK_GENCTRL_Register is record
-- Source Select
SRC : GENCTRL_SRCSelect := SAM_SVD.GCLK.XOSC0;
-- unspecified
Reserved_4_7 : HAL.UInt4 := 16#0#;
-- Generic Clock Generator Enable
GENEN : Boolean := False;
-- Improve Duty Cycle
IDC : Boolean := False;
-- Output Off Value
OOV : Boolean := False;
-- Output Enable
OE : Boolean := False;
-- Divide Selection
DIVSEL : GENCTRL_DIVSELSelect := SAM_SVD.GCLK.DIV1;
-- Run in Standby
RUNSTDBY : Boolean := False;
-- unspecified
Reserved_14_15 : HAL.UInt2 := 16#0#;
-- Division Factor
DIV : GCLK_GENCTRL_DIV_Field := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for GCLK_GENCTRL_Register use record
SRC at 0 range 0 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
GENEN at 0 range 8 .. 8;
IDC at 0 range 9 .. 9;
OOV at 0 range 10 .. 10;
OE at 0 range 11 .. 11;
DIVSEL at 0 range 12 .. 12;
RUNSTDBY at 0 range 13 .. 13;
Reserved_14_15 at 0 range 14 .. 15;
DIV at 0 range 16 .. 31;
end record;
-- Generic Clock Generator Control
type GCLK_GENCTRL_Registers is array (0 .. 11) of GCLK_GENCTRL_Register;
-- Generic Clock Generator
type PCHCTRL_GENSelect is
(-- Generic clock generator 0
GCLK0,
-- Generic clock generator 1
GCLK1,
-- Generic clock generator 2
GCLK2,
-- Generic clock generator 3
GCLK3,
-- Generic clock generator 4
GCLK4,
-- Generic clock generator 5
GCLK5,
-- Generic clock generator 6
GCLK6,
-- Generic clock generator 7
GCLK7,
-- Generic clock generator 8
GCLK8,
-- Generic clock generator 9
GCLK9,
-- Generic clock generator 10
GCLK10,
-- Generic clock generator 11
GCLK11)
with Size => 4;
for PCHCTRL_GENSelect use
(GCLK0 => 0,
GCLK1 => 1,
GCLK2 => 2,
GCLK3 => 3,
GCLK4 => 4,
GCLK5 => 5,
GCLK6 => 6,
GCLK7 => 7,
GCLK8 => 8,
GCLK9 => 9,
GCLK10 => 10,
GCLK11 => 11);
-- Peripheral Clock Control
type GCLK_PCHCTRL_Register is record
-- Generic Clock Generator
GEN : PCHCTRL_GENSelect := SAM_SVD.GCLK.GCLK0;
-- unspecified
Reserved_4_5 : HAL.UInt2 := 16#0#;
-- Channel Enable
CHEN : Boolean := False;
-- Write Lock
WRTLOCK : Boolean := False;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for GCLK_PCHCTRL_Register use record
GEN at 0 range 0 .. 3;
Reserved_4_5 at 0 range 4 .. 5;
CHEN at 0 range 6 .. 6;
WRTLOCK at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-- Peripheral Clock Control
type GCLK_PCHCTRL_Registers is array (0 .. 47) of GCLK_PCHCTRL_Register;
-----------------
-- Peripherals --
-----------------
-- Generic Clock Generator
type GCLK_Peripheral is record
-- Control
CTRLA : aliased GCLK_CTRLA_Register;
-- Synchronization Busy
SYNCBUSY : aliased GCLK_SYNCBUSY_Register;
-- Generic Clock Generator Control
GENCTRL : aliased GCLK_GENCTRL_Registers;
-- Peripheral Clock Control
PCHCTRL : aliased GCLK_PCHCTRL_Registers;
end record
with Volatile;
for GCLK_Peripheral use record
CTRLA at 16#0# range 0 .. 7;
SYNCBUSY at 16#4# range 0 .. 31;
GENCTRL at 16#20# range 0 .. 383;
PCHCTRL at 16#80# range 0 .. 1535;
end record;
-- Generic Clock Generator
GCLK_Periph : aliased GCLK_Peripheral
with Import, Address => GCLK_Base;
end SAM_SVD.GCLK;
|
sungyeon/drake | Ada | 1,474 | adb | with System.Storage_Elements;
with System.Debug; -- assertions
package body System.Stack is
pragma Suppress (All_Checks);
use type Storage_Elements.Storage_Offset;
use type C.signed_int;
procedure Get (
Thread : C.pthread.pthread_t := C.pthread.pthread_self;
Top, Bottom : out Address)
is
Attr : aliased C.pthread.pthread_attr_t;
C_Addr : aliased C.void_ptr;
C_Size : aliased C.size_t;
OK : Boolean := False;
begin
if C.pthread.pthread_attr_init (Attr'Access) = 0 then
OK := C.pthread.pthread_getattr_np (Thread, Attr'Access) = 0
and then C.pthread.pthread_attr_getstack (
Attr'Access,
C_Addr'Access,
C_Size'Access) = 0;
declare
errno : C.signed_int;
begin
errno := C.pthread.pthread_attr_destroy (Attr'Access);
pragma Check (Debug,
Check =>
errno = 0
or else Debug.Runtime_Error ("pthread_attr_destroy failed"));
end;
end if;
if not OK then
Top := Null_Address;
Bottom := Null_Address;
else
Top := Address (C_Addr);
Bottom := Top + Storage_Elements.Storage_Offset (C_Size);
end if;
end Get;
function Fault_Address (Info : C.signal.siginfo_t) return Address is
begin
return Address (Info.sifields.sigfault.si_addr);
end Fault_Address;
end System.Stack;
|
sungyeon/drake | Ada | 28 | adb | ../../../zcx/c-unwind_pe.adb |
gitter-badger/libAnne | Ada | 1,806 | adb | with Ada.Strings.Unbounded, Ada.Strings.Wide_Unbounded, Ada.Strings.Wide_Wide_Unbounded;
use Ada.Strings.Unbounded, Ada.Strings.Wide_Unbounded, Ada.Strings.Wide_Wide_Unbounded;
package body Containers.Lists.Doubly_Linked.IO is
----------
-- Node --
----------
function Image(Self : in Node) return String is (Image(Self.Value));
function Wide_Image(Self : in Node) return Wide_String is (Wide_Image(Self.Value));
function Wide_Wide_Image(Self : in Node) return Wide_Wide_String is (Wide_Wide_Image(Self.Value));
----------
-- List --
----------
function Image(Self : in List) return String is
Result : Unbounded_String;
N : Node_Access := Self.Foremost;
begin
Result := Result & "(";
while N /= null loop
Result := Result & Image(N.Value);
if Next(N) /= null then
Result := Result & "<->";
end if;
N := N.Hind;
end loop;
Result := Result & ")";
return To_String(Result);
end Image;
function Wide_Image(Self : in List) return Wide_String is
Result : Unbounded_Wide_String;
N : Node_Access := Self.Foremost;
begin
Result := Result & "(";
while N /= null loop
Result := Result & Wide_Image(N.Value);
if Next(N) /= null then
Result := Result & "↔";
end if;
N := N.Hind;
end loop;
Result := Result & ")";
return To_Wide_String(Result);
end Wide_Image;
function Wide_Wide_Image(Self : in List) return Wide_Wide_String is
Result : Unbounded_Wide_Wide_String;
N : Node_Access := Self.Foremost;
begin
Result := Result & "(";
while N /= null loop
Result := Result & Wide_Wide_Image(N.Value);
if Next(N) /= null then
Result := Result & "↔";
end if;
N := N.Hind;
end loop;
Result := Result & ")";
return To_Wide_Wide_String(Result);
end Wide_Wide_Image;
end Containers.Lists.Doubly_Linked.IO;
|
vpodzime/ada-util | Ada | 4,651 | ads | -----------------------------------------------------------------------
-- util-streams-pipes -- Pipe stream to or from a process
-- Copyright (C) 2011, 2013, 2015, 2016, 2017 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Finalization;
with Util.Processes;
-- The <b>Util.Streams.Pipes</b> package defines a pipe stream to or from a process.
-- The process is created and launched by the <b>Open</b> operation. The pipe allows
-- to read or write to the process through the <b>Read</b> and <b>Write</b> operation.
package Util.Streams.Pipes is
use Util.Processes;
subtype Pipe_Mode is Util.Processes.Pipe_Mode range READ .. READ_WRITE;
-- -----------------------
-- Pipe stream
-- -----------------------
-- The <b>Pipe_Stream</b> is an output/input stream that reads or writes
-- to or from a process.
type Pipe_Stream is limited new Output_Stream and Input_Stream with private;
-- Set the shell executable path to use to launch a command. The default on Unix is
-- the /bin/sh command. Argument splitting is done by the /bin/sh -c command.
-- When setting an empty shell command, the argument splitting is done by the
-- <tt>Spawn</tt> procedure.
procedure Set_Shell (Stream : in out Pipe_Stream;
Shell : in String);
-- Before launching the process, redirect the input stream of the process
-- to the specified file.
-- Raises <b>Invalid_State</b> if the process is running.
procedure Set_Input_Stream (Stream : in out Pipe_Stream;
File : in String);
-- Set the output stream of the process.
-- Raises <b>Invalid_State</b> if the process is running.
procedure Set_Output_Stream (Stream : in out Pipe_Stream;
File : in String;
Append : in Boolean := False);
-- Set the error stream of the process.
-- Raises <b>Invalid_State</b> if the process is running.
procedure Set_Error_Stream (Stream : in out Pipe_Stream;
File : in String;
Append : in Boolean := False);
-- Set the working directory that the process will use once it is created.
-- The directory must exist or the <b>Invalid_Directory</b> exception will be raised.
procedure Set_Working_Directory (Stream : in out Pipe_Stream;
Path : in String);
-- Open a pipe to read or write to an external process. The pipe is created and the
-- command is executed with the input and output streams redirected through the pipe.
procedure Open (Stream : in out Pipe_Stream;
Command : in String;
Mode : in Pipe_Mode := READ);
-- Close the pipe and wait for the external process to terminate.
overriding
procedure Close (Stream : in out Pipe_Stream);
-- Get the process exit status.
function Get_Exit_Status (Stream : in Pipe_Stream) return Integer;
-- Returns True if the process is running.
function Is_Running (Stream : in Pipe_Stream) return Boolean;
-- Write the buffer array to the output stream.
overriding
procedure Write (Stream : in out Pipe_Stream;
Buffer : in Ada.Streams.Stream_Element_Array);
-- Read into the buffer as many bytes as possible and return in
-- <b>last</b> the position of the last byte read.
overriding
procedure Read (Stream : in out Pipe_Stream;
Into : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
private
use Ada.Streams;
type Pipe_Stream is limited new Ada.Finalization.Limited_Controlled
and Output_Stream and Input_Stream with record
Proc : Util.Processes.Process;
end record;
-- Flush the stream and release the buffer.
overriding
procedure Finalize (Object : in out Pipe_Stream);
end Util.Streams.Pipes;
|
annexi-strayline/ASAP-HEX | Ada | 13,023 | adb | ------------------------------------------------------------------------------
-- --
-- Generic HEX String Handling Package --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2018-2019, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai, Ensi Martini, Aninda Poddar, Noshen Atashe --
-- (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
package body Hex
with SPARK_Mode => On
is
pragma Assertion_Policy (Ignore);
pragma Suppress (Division_Check);
pragma Suppress (Index_Check);
pragma Suppress (Length_Check);
pragma Suppress (Overflow_Check);
pragma Suppress (Range_Check);
-- Fully verified unit
------------------
-- Idenfity_Hex --
------------------
procedure Identify_Hex (Source: in String;
First : out Positive;
Last : out Natural)
is
procedure Search_Initial_Candidate
(Start_From: in Positive;
Candidate : out Positive;
Found : out Boolean)
with
Inline => True,
Global => (Input => Source),
Depends => ((Candidate, Found) => (Source, Start_From)),
Pre => Source'Length > 0 and Start_From in Source'Range,
Post => (if Found then
Candidate >= Start_From
and Candidate in Source'Range
and Source (Candidate) in Hex_Character
and Demarcation_Precedent_Check
(Source => Source,
First => Candidate))
is
begin
-- Attempts to identify they first valid hexadecimal digit which
-- satisfies the precedent check, starting from Start_From
Candidate := Start_From;
Found := False;
for I in Start_From .. Source'Last loop
if Source(I) in Hex_Character
and then Demarcation_Precedent_Check
(Source => Source,
First => I)
then
Candidate := I;
Found := True;
return;
end if;
pragma Loop_Invariant
(not Found and Candidate = Start_From);
end loop;
end Search_Initial_Candidate;
procedure Search_Terminal_Candidate
(Initial : in Positive;
Candidate: out Positive;
Found : out Boolean)
with
Inline => True,
Global => (Input => Source),
Depends => ((Candidate, Found) => (Source, Initial)),
Pre => Source'Length >= 1
and then Initial in Source'Range
and then Source(Initial) in Hex_Character
and then Demarcation_Precedent_Check (Source => Source,
First => Initial),
Post => Candidate in Source'Range
and then (if Initial = Source'Last then Found)
and then (if Found then
Candidate >= Initial
and then Valid_Hex_String
(Source (Initial .. Candidate))
and then Demarcation_Subsequent_Check
(Source => Source,
Last => Candidate)
else
Candidate > Initial
and then Valid_Hex_String
(Source (Initial .. Candidate - 1))
and then Source(Candidate) not in Hex_Character)
is
begin
-- Given a valid initial position of a candidate hexadecimal string,
-- attempts to find the terminal digit of that string such that
-- the demarcation subsequent check passes.
for I in Initial .. Source'Last loop
if Source(I) not in Hex_Character then
-- Precondition ensures us that this never happens on the first
-- iteration, (Initial points at a Hex_Character) therefore
-- I - 1 is always a Hex_Character
if Demarcation_Subsequent_Check (Source => Source,
Last => I - 1)
then
-- This is a good one
Found := True;
Candidate := I - 1;
return;
else
-- No luck, but we set Candidate to be what should
-- be the next start-point
Found := False;
Candidate := I;
return;
end if;
end if;
pragma Loop_Invariant (Source(I) in Hex_Character);
pragma Loop_Invariant (Valid_Hex_String (Source(Initial .. I)));
-- Used to prove our postcondition
end loop;
-- Based on the Loop_Invariants of the above loop, as well as
-- the two possible "return" paths, we know that
-- Initial .. Source'Last is valid
Found := True;
Candidate := Source'Last;
end Search_Terminal_Candidate;
Trial_OK, Retrial_OK: Boolean;
Trial_First, Retrial_First, Trial_Last: Positive;
begin
-- With the above nested procedures, the high-level view is quite simple.
-- We continually alternate between looking for a initial candidate,
-- then a terminal candidate, starting with Source'First, until the
-- initial candidate attempt fails, at which point we fail to identify a
-- string. Of course the first successful pair means a match, which is
-- the goal
if Source'Length = 0 then
First := 1;
Last := 0;
-- This is an interesting special case.
-- The Ada Standard allows for null ranges to be totally outside
-- of the underlying subtype when used as an index. Therefore it
-- is entirely possible for a String to have a range like (-3 .. -8).
--
-- The goal of this procedure is to avoid any precondition, so that
-- it can be safely called from full Ada, while retaining the proven
-- postcondition.
--
-- So in the case of an input null string, we explicitly set
-- First .. Last to a null range, but one that is not actually tied to
-- the range of the input string.
--
-- We make this caveat clear in the postcondition in the
-- specification, in the off chance that it would cause a problem
--
-- Realistically, a good programmer should not (cannot?) be depending
-- on First = Source'First if Source is a null string.
return;
end if;
pragma Assert (Source'First in Positive);
Trial_Last := Source'First;
loop
Search_Initial_Candidate (Start_From => Trial_Last,
Candidate => Trial_First,
Found => Trial_OK);
if not Trial_OK then
First := Source'First;
Last := First - 1;
return;
end if;
-- We need to handle skipping of any '0x' condition, but we
if Source(Trial_First) = '0'
and then Trial_First < Source'Last
and then Source(Trial_First + 1) in 'x' | 'X'
then
-- We require one of two valid conditions.
-- 1. Source literally starts with "0x", or
-- 2. "0x" is preceeded by Valid_Exterior
if Trial_First + 1 < Source'Last
and then Source(Trial_First + 2) in Hex_Character
and then (if Trial_First + 2 < Source'Last then
Source(Trial_First + 3) in Valid_Exterior)
then
-- We can safely skip forward and try again
Trial_First := Trial_First + 2;
-- By doing this here instead of trying to re-run the
-- whole loop, we avoid problems with "0x0x" sequences
-- After this search, we won't try another skip, if
-- 0x follows, Retrial_First will be Trial_First, and then
-- Search_Terminal_Candidate will fail
Search_Initial_Candidate (Start_From => Trial_First,
Candidate => Retrial_First,
Found => Retrial_OK);
if not Retrial_OK then
-- Game over
First := Source'First;
Last := First - 1;
return;
else
-- In theory, Retrial_First should be equal to
-- Trial_First, but this ensures that we are still
-- meeting our contractual requirements
Trial_First := Retrial_First;
end if;
end if;
end if;
Search_Terminal_Candidate (Initial => Trial_First,
Candidate => Trial_Last,
Found => Trial_OK);
if Trial_OK then
-- Match - we're done
First := Trial_First;
Last := Trial_Last;
return;
end if;
-- Otherwise, Trail_Last will be set by Search_Terminal_Candidate
-- to be an optimal start-point for Search_Initial_Candidate
pragma Loop_Invariant (Trial_First in Source'Range);
pragma Loop_Invariant (Trial_Last in Source'Range);
pragma Loop_Variant (Increases => Trial_Last);
end loop;
end Identify_Hex;
end Hex;
|
AdaCore/libadalang | Ada | 762 | adb | with Ada.Text_IO; use Ada.Text_IO;
with Libadalang.Analysis; use Libadalang.Analysis;
with Libadalang.Common; use Libadalang.Common;
with Libadalang.Iterators; use Libadalang.Iterators;
procedure Main is
Ctx : constant Analysis_Context := Create_Context;
Unit : Analysis_Unit := Get_From_File (Ctx, "foo.adb");
CU : constant Compilation_Unit := Root (Unit).As_Compilation_Unit;
function Find_Binops (N : Ada_Node) return Boolean
is (N.Kind = Ada_Bin_Op);
BO_Array : constant Ada_Node_Array := Find (CU, Find_Binops'Access).Consume;
BO : constant Bin_Op := BO_Array (1).As_Bin_Op;
begin
Put_Line ("Tokens for node " & BO.Image & ":");
for Tok of BO.Token_Range loop
Put_Line (Image (Tok));
end loop;
end Main;
|
Sejik/SignalAnalysis | Ada | 4,468 | adb | ----------------------------------------------------------------
-- ZLib for Ada thick binding. --
-- --
-- Copyright (C) 2002-2003 Dmitriy Anisimkov --
-- --
-- Open source license information is in the zlib.ads file. --
----------------------------------------------------------------
-- Continuous test for ZLib multithreading. If the test would fail
-- we should provide thread safe allocation routines for the Z_Stream.
--
-- $Id: mtest.adb,v 1.2 2007/06/14 11:55:45 duncan Exp $
with ZLib;
with Ada.Streams;
with Ada.Numerics.Discrete_Random;
with Ada.Text_IO;
with Ada.Exceptions;
with Ada.Task_Identification;
procedure MTest is
use Ada.Streams;
use ZLib;
Stop : Boolean := False;
pragma Atomic (Stop);
subtype Visible_Symbols is Stream_Element range 16#20# .. 16#7E#;
package Random_Elements is
new Ada.Numerics.Discrete_Random (Visible_Symbols);
task type Test_Task;
task body Test_Task is
Buffer : Stream_Element_Array (1 .. 100_000);
Gen : Random_Elements.Generator;
Buffer_First : Stream_Element_Offset;
Compare_First : Stream_Element_Offset;
Deflate : Filter_Type;
Inflate : Filter_Type;
procedure Further (Item : in Stream_Element_Array);
procedure Read_Buffer
(Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
-------------
-- Further --
-------------
procedure Further (Item : in Stream_Element_Array) is
procedure Compare (Item : in Stream_Element_Array);
-------------
-- Compare --
-------------
procedure Compare (Item : in Stream_Element_Array) is
Next_First : Stream_Element_Offset := Compare_First + Item'Length;
begin
if Buffer (Compare_First .. Next_First - 1) /= Item then
raise Program_Error;
end if;
Compare_First := Next_First;
end Compare;
procedure Compare_Write is new ZLib.Write (Write => Compare);
begin
Compare_Write (Inflate, Item, No_Flush);
end Further;
-----------------
-- Read_Buffer --
-----------------
procedure Read_Buffer
(Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset)
is
Buff_Diff : Stream_Element_Offset := Buffer'Last - Buffer_First;
Next_First : Stream_Element_Offset;
begin
if Item'Length <= Buff_Diff then
Last := Item'Last;
Next_First := Buffer_First + Item'Length;
Item := Buffer (Buffer_First .. Next_First - 1);
Buffer_First := Next_First;
else
Last := Item'First + Buff_Diff;
Item (Item'First .. Last) := Buffer (Buffer_First .. Buffer'Last);
Buffer_First := Buffer'Last + 1;
end if;
end Read_Buffer;
procedure Translate is new Generic_Translate
(Data_In => Read_Buffer,
Data_Out => Further);
begin
Random_Elements.Reset (Gen);
Buffer := (others => 20);
Main : loop
for J in Buffer'Range loop
Buffer (J) := Random_Elements.Random (Gen);
Deflate_Init (Deflate);
Inflate_Init (Inflate);
Buffer_First := Buffer'First;
Compare_First := Buffer'First;
Translate (Deflate);
if Compare_First /= Buffer'Last + 1 then
raise Program_Error;
end if;
Ada.Text_IO.Put_Line
(Ada.Task_Identification.Image
(Ada.Task_Identification.Current_Task)
& Stream_Element_Offset'Image (J)
& ZLib.Count'Image (Total_Out (Deflate)));
Close (Deflate);
Close (Inflate);
exit Main when Stop;
end loop;
end loop Main;
exception
when E : others =>
Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Information (E));
Stop := True;
end Test_Task;
Test : array (1 .. 4) of Test_Task;
pragma Unreferenced (Test);
Dummy : Character;
begin
Ada.Text_IO.Get_Immediate (Dummy);
Stop := True;
end MTest;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 808 | adb | with Last_Chance_Handler; pragma Unreferenced (Last_Chance_Handler);
with Ada.Real_Time; use Ada.Real_Time;
with Ada.Text_IO; use Ada.Text_IO;
with STM32GD.Board; use STM32GD.Board;
with STM32GD.GPIO; use STM32GD.GPIO;
with STM32GD.GPIO.Pin;
with STM32GD.EXTI;
with STM32_SVD.AFIO;
with STM32_SVD.NVIC;
with STM32_SVD.RCC;
with Peripherals; use Peripherals;
procedure Main is
Next_Release : Time := Clock;
Period : constant Time_Span := Milliseconds (1000); -- arbitrary
begin
Init;
STM32_SVD.NVIC.NVIC_Periph.ISER0 := 2#00000000_10011000_00000000_00000000#;
Put_Line ("Init");
USB_Re_Enumerate;
USB.Init;
LED2.Set;
Put_Line ("Starting");
loop
LED2.Toggle;
Next_Release := Next_Release + Period;
delay until Next_Release;
end loop;
end Main;
|
LiberatorUSA/GUCEF | Ada | 6,993 | ads | with agar.gui.surface;
with agar.gui.widget;
with agar.gui.types;
package agar.gui.window is
use type c.unsigned;
use type agar.gui.types.window_flags_t;
subtype window_t is agar.gui.types.window_t;
subtype window_access_t is agar.gui.types.window_access_t;
--
-- constants
--
caption_max : constant c.unsigned := agar.gui.types.window_caption_max;
--
-- types
--
subtype flags_t is agar.gui.types.window_flags_t;
WINDOW_MODAL : constant flags_t := 16#000001#;
WINDOW_MAXIMIZED : constant flags_t := 16#000002#;
WINDOW_MINIMIZED : constant flags_t := 16#000004#;
WINDOW_KEEPABOVE : constant flags_t := 16#000008#;
WINDOW_KEEPBELOW : constant flags_t := 16#000010#;
WINDOW_DENYFOCUS : constant flags_t := 16#000020#;
WINDOW_NOTITLE : constant flags_t := 16#000040#;
WINDOW_NOBORDERS : constant flags_t := 16#000080#;
WINDOW_NOHRESIZE : constant flags_t := 16#000100#;
WINDOW_NOVRESIZE : constant flags_t := 16#000200#;
WINDOW_NOCLOSE : constant flags_t := 16#000400#;
WINDOW_NOMINIMIZE : constant flags_t := 16#000800#;
WINDOW_NOMAXIMIZE : constant flags_t := 16#001000#;
WINDOW_NOBACKGROUND : constant flags_t := 16#008000#;
WINDOW_NOUPDATERECT : constant flags_t := 16#010000#;
WINDOW_FOCUSONATTACH : constant flags_t := 16#020000#;
WINDOW_HMAXIMIZE : constant flags_t := 16#040000#;
WINDOW_VMAXIMIZE : constant flags_t := 16#080000#;
WINDOW_NOMOVE : constant flags_t := 16#100000#;
WINDOW_NOCLIPPING : constant flags_t := 16#200000#;
WINDOW_NORESIZE : constant flags_t := WINDOW_NOHRESIZE or
WINDOW_NOVRESIZE;
WINDOW_NOBUTTONS : constant flags_t := WINDOW_NOCLOSE or
WINDOW_NOMINIMIZE or
WINDOW_NOMAXIMIZE;
WINDOW_PLAIN : constant flags_t := WINDOW_NOTITLE or
WINDOW_NOBORDERS;
subtype alignment_t is agar.gui.types.window_alignment_t;
type close_action_t is (
WINDOW_HIDE,
WINDOW_DETACH,
WINDOW_NONE
);
for close_action_t use (
WINDOW_HIDE => 0,
WINDOW_DETACH => 1,
WINDOW_NONE => 2
);
for close_action_t'size use c.unsigned'size;
pragma convention (c, close_action_t);
subtype percent_t is positive range 1 .. 100;
--
-- API
--
function allocate (flags : flags_t := 0) return window_access_t;
pragma import (c, allocate, "AG_WindowNew");
function allocate_named
(flags : flags_t := 0;
name : string) return window_access_t;
pragma inline (allocate_named);
procedure set_caption
(window : window_access_t;
caption : string);
pragma inline (set_caption);
procedure set_icon
(window : window_access_t;
surface : agar.gui.surface.surface_access_t);
pragma import (c, set_icon, "agar_window_set_icon");
procedure set_icon_no_copy
(window : window_access_t;
surface : agar.gui.surface.surface_access_t);
pragma import (c, set_icon_no_copy, "agar_window_set_icon_no_copy");
procedure set_close_action
(window : window_access_t;
mode : close_action_t);
pragma import (c, set_close_action, "AG_WindowSetCloseAction");
procedure set_padding
(window : window_access_t;
left : natural;
right : natural;
top : natural;
bottom : natural);
pragma inline (set_padding);
procedure set_spacing
(window : window_access_t;
spacing : natural);
pragma inline (set_spacing);
procedure set_position
(window : window_access_t;
alignment : alignment_t;
cascade : boolean);
pragma inline (set_position);
procedure set_geometry
(window : window_access_t;
x : natural;
y : natural;
width : natural;
height : natural);
pragma inline (set_geometry);
procedure set_geometry_aligned
(window : window_access_t;
alignment : alignment_t;
width : positive;
height : positive);
pragma inline (set_geometry_aligned);
procedure set_geometry_aligned_percent
(window : window_access_t;
alignment : alignment_t;
width : percent_t;
height : percent_t);
pragma inline (set_geometry_aligned_percent);
procedure set_geometry_bounded
(window : window_access_t;
x : natural;
y : natural;
width : natural;
height : natural);
pragma inline (set_geometry_bounded);
procedure set_geometry_max (window : window_access_t);
pragma import (c, set_geometry_max, "AG_WindowSetGeometryMax");
procedure set_minimum_size
(window : window_access_t;
width : natural;
height : natural);
pragma inline (set_minimum_size);
procedure set_minimum_size_percentage
(window : window_access_t;
percent : percent_t);
pragma inline (set_minimum_size_percentage);
procedure maximize (window : window_access_t);
pragma import (c, maximize, "AG_WindowMaximize");
procedure unmaximize (window : window_access_t);
pragma import (c, unmaximize, "AG_WindowUnmaximize");
procedure minimize (window : window_access_t);
pragma import (c, minimize, "AG_WindowMinimize");
procedure unminimize (window : window_access_t);
pragma import (c, unminimize, "AG_WindowUnminimize");
procedure attach
(window : window_access_t;
subwindow : window_access_t);
pragma import (c, attach, "AG_WindowAttach");
procedure detach
(window : window_access_t;
subwindow : window_access_t);
pragma import (c, detach, "AG_WindowDetach");
procedure update (window : window_access_t);
pragma import (c, update, "agar_window_update");
-- visibility
procedure show (window : window_access_t);
pragma import (c, show, "AG_WindowShow");
procedure hide (window : window_access_t);
pragma import (c, hide, "AG_WindowHide");
function is_visible (window : window_access_t) return c.int;
pragma import (c, is_visible, "agar_window_is_visible");
function is_visible (window : window_access_t) return boolean;
pragma inline (is_visible);
procedure set_visibility
(window : window_access_t;
visible : boolean);
pragma inline (set_visibility);
-- focus
procedure focus (window : window_access_t);
pragma import (c, focus, "AG_WindowFocus");
function focus_named (name : string) return boolean;
pragma inline (focus_named);
function find_focused (window : window_access_t) return agar.gui.widget.widget_access_t;
pragma import (c, find_focused, "AG_WidgetFindFocused");
function is_focused (window : window_access_t) return c.int;
pragma import (c, is_focused, "agar_window_is_focused");
function is_focused (window : window_access_t) return boolean;
pragma inline (is_focused);
--
function widget (window : window_access_t) return agar.gui.widget.widget_access_t
renames agar.gui.types.window_widget;
end agar.gui.window;
|
zhmu/ananas | Ada | 1,913 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- E I N F O --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
pragma No_Body;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 919 | ads | with STM32_SVD; use STM32_SVD;
with HAL;
generic
with package Chip_Select is new HAL.Pin (<>);
with package IRQ is new HAL.Pin (<>);
with package SPI is new HAL.SPI (<>);
package Drivers.CC1101 is
type Raw_Register_Array is array (0 .. 16#3D#) of Byte;
type Packet_Type is array (Positive range <>) of Byte;
procedure Init;
procedure TX_Mode;
procedure RX_Mode;
procedure Set_Sync_Word (Word : Unsigned_16);
function Get_Sync_Word return Unsigned_16;
procedure TX (Packet: Packet_Type);
function Wait_For_RX return Boolean;
procedure RX (Packet : out Packet_Type; Length : out Natural);
function RX_Available return Boolean;
procedure Clear_IRQ;
procedure Power_Down;
procedure Cancel;
procedure Read_Registers (Registers : out Raw_Register_Array);
generic
with procedure Put_Line (Line: in string);
procedure Print_Registers;
end Drivers.CC1101;
|
apple-oss-distributions/old_ncurses | Ada | 7,974 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- ncurses --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 2000 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Eugene V. Melaragno <[email protected]> 2000
-- Version Control
-- $Revision: 1.1.1.1 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Terminal_Interface.Curses; use Terminal_Interface.Curses;
with ncurses2.util; use ncurses2.util;
-- Graphic-rendition test (adapted from vttest)
procedure ncurses2.test_sgr_attributes is
procedure xAdd (l : Line_Position; c : Column_Position; s : String);
procedure xAdd (l : Line_Position; c : Column_Position; s : String) is
begin
Add (Line => l, Column => c, Str => s);
end xAdd;
normal, current : Attributed_Character;
begin
for pass in reverse Boolean loop
if pass then
normal := (Ch => ' ', Attr => Normal_Video, Color => 0);
else
normal := (Ch => ' ', Attr =>
(Reverse_Video => True, others => False), Color => 0);
end if;
-- Use non-default colors if possible to exercise bce a little
if Has_Colors then
Init_Pair (1, White, Blue);
normal.Color := 1;
end if;
Set_Background (Ch => normal);
Erase;
xAdd (1, 20, "Graphic rendition test pattern:");
xAdd (4, 1, "vanilla");
current := normal;
current.Attr.Bold_Character := not current.Attr.Bold_Character;
Set_Background (Ch => current);
xAdd (4, 40, "bold");
current := normal;
current.Attr.Under_Line := not current.Attr.Under_Line;
Set_Background (Ch => current);
xAdd (6, 6, "underline");
current := normal;
current.Attr.Bold_Character := not current.Attr.Bold_Character;
current.Attr.Under_Line := not current.Attr.Under_Line;
Set_Background (Ch => current);
xAdd (6, 45, "bold underline");
current := normal;
current.Attr.Blink := not current.Attr.Blink;
Set_Background (Ch => current);
xAdd (8, 1, "blink");
current := normal;
current.Attr.Blink := not current.Attr.Blink;
current.Attr.Bold_Character := not current.Attr.Bold_Character;
Set_Background (Ch => current);
xAdd (8, 40, "bold blink");
current := normal;
current.Attr.Under_Line := not current.Attr.Under_Line;
current.Attr.Blink := not current.Attr.Blink;
Set_Background (Ch => current);
xAdd (10, 6, "underline blink");
current := normal;
current.Attr.Bold_Character := not current.Attr.Bold_Character;
current.Attr.Under_Line := not current.Attr.Under_Line;
current.Attr.Blink := not current.Attr.Blink;
Set_Background (Ch => current);
xAdd (10, 45, "bold underline blink");
current := normal;
current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
Set_Background (Ch => current);
xAdd (12, 1, "negative");
current := normal;
current.Attr.Bold_Character := not current.Attr.Bold_Character;
current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
Set_Background (Ch => current);
xAdd (12, 40, "bold negative");
current := normal;
current.Attr.Under_Line := not current.Attr.Under_Line;
current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
Set_Background (Ch => current);
xAdd (14, 6, "underline negative");
current := normal;
current.Attr.Bold_Character := not current.Attr.Bold_Character;
current.Attr.Under_Line := not current.Attr.Under_Line;
current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
Set_Background (Ch => current);
xAdd (14, 45, "bold underline negative");
current := normal;
current.Attr.Blink := not current.Attr.Blink;
current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
Set_Background (Ch => current);
xAdd (16, 1, "blink negative");
current := normal;
current.Attr.Bold_Character := not current.Attr.Bold_Character;
current.Attr.Blink := not current.Attr.Blink;
current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
Set_Background (Ch => current);
xAdd (16, 40, "bold blink negative");
current := normal;
current.Attr.Under_Line := not current.Attr.Under_Line;
current.Attr.Blink := not current.Attr.Blink;
current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
Set_Background (Ch => current);
xAdd (18, 6, "underline blink negative");
current := normal;
current.Attr.Bold_Character := not current.Attr.Bold_Character;
current.Attr.Under_Line := not current.Attr.Under_Line;
current.Attr.Blink := not current.Attr.Blink;
current.Attr.Reverse_Video := not current.Attr.Reverse_Video;
Set_Background (Ch => current);
xAdd (18, 45, "bold underline blink negative");
Set_Background (Ch => normal);
Move_Cursor (Line => Lines - 2, Column => 1);
if pass then
Add (Str => "Dark");
else
Add (Str => "Light");
end if;
Add (Str => " background. ");
Clear_To_End_Of_Line;
Pause;
end loop;
Set_Background (Ch => Blank2);
Erase;
End_Windows;
end ncurses2.test_sgr_attributes;
|
reznikmm/matreshka | Ada | 14,321 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Internals.UML_Named_Elements;
with AMF.UML.Activities;
with AMF.UML.Activity_Edges.Collections;
with AMF.UML.Activity_Groups.Collections;
with AMF.UML.Activity_Nodes.Collections;
with AMF.UML.Activity_Partitions.Collections;
with AMF.UML.Classifiers.Collections;
with AMF.UML.Dependencies.Collections;
with AMF.UML.Initial_Nodes;
with AMF.UML.Interruptible_Activity_Regions.Collections;
with AMF.UML.Named_Elements;
with AMF.UML.Namespaces;
with AMF.UML.Packages.Collections;
with AMF.UML.Redefinable_Elements.Collections;
with AMF.UML.String_Expressions;
with AMF.UML.Structured_Activity_Nodes;
with AMF.Visitors;
package AMF.Internals.UML_Initial_Nodes is
type UML_Initial_Node_Proxy is
limited new AMF.Internals.UML_Named_Elements.UML_Named_Element_Proxy
and AMF.UML.Initial_Nodes.UML_Initial_Node with null record;
overriding function Get_Activity
(Self : not null access constant UML_Initial_Node_Proxy)
return AMF.UML.Activities.UML_Activity_Access;
-- Getter of ActivityNode::activity.
--
-- Activity containing the node.
overriding procedure Set_Activity
(Self : not null access UML_Initial_Node_Proxy;
To : AMF.UML.Activities.UML_Activity_Access);
-- Setter of ActivityNode::activity.
--
-- Activity containing the node.
overriding function Get_In_Group
(Self : not null access constant UML_Initial_Node_Proxy)
return AMF.UML.Activity_Groups.Collections.Set_Of_UML_Activity_Group;
-- Getter of ActivityNode::inGroup.
--
-- Groups containing the node.
overriding function Get_In_Interruptible_Region
(Self : not null access constant UML_Initial_Node_Proxy)
return AMF.UML.Interruptible_Activity_Regions.Collections.Set_Of_UML_Interruptible_Activity_Region;
-- Getter of ActivityNode::inInterruptibleRegion.
--
-- Interruptible regions containing the node.
overriding function Get_In_Partition
(Self : not null access constant UML_Initial_Node_Proxy)
return AMF.UML.Activity_Partitions.Collections.Set_Of_UML_Activity_Partition;
-- Getter of ActivityNode::inPartition.
--
-- Partitions containing the node.
overriding function Get_In_Structured_Node
(Self : not null access constant UML_Initial_Node_Proxy)
return AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access;
-- Getter of ActivityNode::inStructuredNode.
--
-- Structured activity node containing the node.
overriding procedure Set_In_Structured_Node
(Self : not null access UML_Initial_Node_Proxy;
To : AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access);
-- Setter of ActivityNode::inStructuredNode.
--
-- Structured activity node containing the node.
overriding function Get_Incoming
(Self : not null access constant UML_Initial_Node_Proxy)
return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge;
-- Getter of ActivityNode::incoming.
--
-- Edges that have the node as target.
overriding function Get_Outgoing
(Self : not null access constant UML_Initial_Node_Proxy)
return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge;
-- Getter of ActivityNode::outgoing.
--
-- Edges that have the node as source.
overriding function Get_Redefined_Node
(Self : not null access constant UML_Initial_Node_Proxy)
return AMF.UML.Activity_Nodes.Collections.Set_Of_UML_Activity_Node;
-- Getter of ActivityNode::redefinedNode.
--
-- Inherited nodes replaced by this node in a specialization of the
-- activity.
overriding function Get_Is_Leaf
(Self : not null access constant UML_Initial_Node_Proxy)
return Boolean;
-- Getter of RedefinableElement::isLeaf.
--
-- Indicates whether it is possible to further redefine a
-- RedefinableElement. If the value is true, then it is not possible to
-- further redefine the RedefinableElement. Note that this property is
-- preserved through package merge operations; that is, the capability to
-- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in
-- the resulting RedefinableElement of a package merge operation where a
-- RedefinableElement with isLeaf=false is merged with a matching
-- RedefinableElement with isLeaf=true: the resulting RedefinableElement
-- will have isLeaf=false. Default value is false.
overriding procedure Set_Is_Leaf
(Self : not null access UML_Initial_Node_Proxy;
To : Boolean);
-- Setter of RedefinableElement::isLeaf.
--
-- Indicates whether it is possible to further redefine a
-- RedefinableElement. If the value is true, then it is not possible to
-- further redefine the RedefinableElement. Note that this property is
-- preserved through package merge operations; that is, the capability to
-- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in
-- the resulting RedefinableElement of a package merge operation where a
-- RedefinableElement with isLeaf=false is merged with a matching
-- RedefinableElement with isLeaf=true: the resulting RedefinableElement
-- will have isLeaf=false. Default value is false.
overriding function Get_Redefined_Element
(Self : not null access constant UML_Initial_Node_Proxy)
return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element;
-- Getter of RedefinableElement::redefinedElement.
--
-- The redefinable element that is being redefined by this element.
overriding function Get_Redefinition_Context
(Self : not null access constant UML_Initial_Node_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of RedefinableElement::redefinitionContext.
--
-- References the contexts that this element may be redefined from.
overriding function Get_Client_Dependency
(Self : not null access constant UML_Initial_Node_Proxy)
return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency;
-- Getter of NamedElement::clientDependency.
--
-- Indicates the dependencies that reference the client.
overriding function Get_Name_Expression
(Self : not null access constant UML_Initial_Node_Proxy)
return AMF.UML.String_Expressions.UML_String_Expression_Access;
-- Getter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding procedure Set_Name_Expression
(Self : not null access UML_Initial_Node_Proxy;
To : AMF.UML.String_Expressions.UML_String_Expression_Access);
-- Setter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding function Get_Namespace
(Self : not null access constant UML_Initial_Node_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Getter of NamedElement::namespace.
--
-- Specifies the namespace that owns the NamedElement.
overriding function Get_Qualified_Name
(Self : not null access constant UML_Initial_Node_Proxy)
return AMF.Optional_String;
-- Getter of NamedElement::qualifiedName.
--
-- A name which allows the NamedElement to be identified within a
-- hierarchy of nested Namespaces. It is constructed from the names of the
-- containing namespaces starting at the root of the hierarchy and ending
-- with the name of the NamedElement itself.
overriding function Is_Consistent_With
(Self : not null access constant UML_Initial_Node_Proxy;
Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean;
-- Operation RedefinableElement::isConsistentWith.
--
-- The query isConsistentWith() specifies, for any two RedefinableElements
-- in a context in which redefinition is possible, whether redefinition
-- would be logically consistent. By default, this is false; this
-- operation must be overridden for subclasses of RedefinableElement to
-- define the consistency conditions.
overriding function Is_Redefinition_Context_Valid
(Self : not null access constant UML_Initial_Node_Proxy;
Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean;
-- Operation RedefinableElement::isRedefinitionContextValid.
--
-- The query isRedefinitionContextValid() specifies whether the
-- redefinition contexts of this RedefinableElement are properly related
-- to the redefinition contexts of the specified RedefinableElement to
-- allow this element to redefine the other. By default at least one of
-- the redefinition contexts of this element must be a specialization of
-- at least one of the redefinition contexts of the specified element.
overriding function All_Owning_Packages
(Self : not null access constant UML_Initial_Node_Proxy)
return AMF.UML.Packages.Collections.Set_Of_UML_Package;
-- Operation NamedElement::allOwningPackages.
--
-- The query allOwningPackages() returns all the directly or indirectly
-- owning packages.
overriding function Is_Distinguishable_From
(Self : not null access constant UML_Initial_Node_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access;
Ns : AMF.UML.Namespaces.UML_Namespace_Access)
return Boolean;
-- Operation NamedElement::isDistinguishableFrom.
--
-- The query isDistinguishableFrom() determines whether two NamedElements
-- may logically co-exist within a Namespace. By default, two named
-- elements are distinguishable if (a) they have unrelated types or (b)
-- they have related types but different names.
overriding function Namespace
(Self : not null access constant UML_Initial_Node_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Operation NamedElement::namespace.
--
-- Missing derivation for NamedElement::/namespace : Namespace
overriding procedure Enter_Element
(Self : not null access constant UML_Initial_Node_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Leave_Element
(Self : not null access constant UML_Initial_Node_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Visit_Element
(Self : not null access constant UML_Initial_Node_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of iterator interface.
end AMF.Internals.UML_Initial_Nodes;
|
ecalderini/bingada | Ada | 2,456 | adb | --*****************************************************************************
--*
--* PROJECT: BingAda
--*
--* FILE: q_csv-q_read_file.adb
--*
--* AUTHOR: Javier Fuica Fernandez
--*
--*****************************************************************************
with ADA.EXCEPTIONS;
with TEXT_IO;
package body Q_CSV.Q_READ_FILE is
--==================================================================
V_FILE : TEXT_IO.FILE_TYPE;
--==================================================================
procedure P_READ_CARDS_IN_VECTOR (V_FILE : TEXT_IO.FILE_TYPE;
V_CARDS : in out Q_BINGO_CARDS.VECTOR) is
V_ROW : T_ROW := F_LINE (TEXT_IO.GET_LINE (V_FILE));
V_FIRST_COL : BOOLEAN;
V_NUMBERS : T_NUMBERS;
V_INDEX : POSITIVE := 1;
V_CARD_NAME : T_NAME;
begin
V_FIRST_COL := V_ROW.F_NEXT;
V_CARD_NAME := V_ROW.F_ITEM (T_NAME'RANGE);
while V_ROW.F_NEXT loop
V_NUMBERS (V_INDEX) := Q_BINGO.T_NUMBER'VALUE (V_ROW.F_ITEM);
V_INDEX := V_INDEX + 1;
end loop;
V_CARDS.APPEND ((R_NAME => V_CARD_NAME,
R_NUMBERS => V_NUMBERS));
end P_READ_CARDS_IN_VECTOR;
--==================================================================
procedure P_READ_BINGO_CARDS
(V_FILE_NAME : STRING;
V_CARDS : out Q_BINGO_CARDS.VECTOR) is
begin
TEXT_IO.OPEN (FILE => V_FILE,
MODE => TEXT_IO.IN_FILE,
NAME => V_FILE_NAME);
if TEXT_IO.IS_OPEN (V_FILE) then
-- skip header
--
TEXT_IO.SKIP_LINE (V_FILE);
while not TEXT_IO.END_OF_FILE (V_FILE) loop
P_READ_CARDS_IN_VECTOR (V_FILE => V_FILE,
V_CARDS => V_CARDS);
end loop;
end if;
TEXT_IO.CLOSE (V_FILE);
exception
when V_EXCEPTION : others =>
-- No exception is raised because if the csv file is not correctly read
-- the bingada can continue without cards to check.
--
TEXT_IO.CLOSE (V_FILE);
TEXT_IO.PUT_LINE
("exception : " & ADA.EXCEPTIONS.EXCEPTION_INFORMATION (V_EXCEPTION));
end P_READ_BINGO_CARDS;
--==================================================================
end Q_CSV.Q_READ_FILE;
|
AdaCore/ada-traits-containers | Ada | 3,162 | ads | --
-- Copyright (C) 2015-2016, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
-- Support for output of the tests
with Ada.Unchecked_Conversion;
with Ada.Calendar; use Ada.Calendar;
with GNATCOLL.JSON; use GNATCOLL.JSON;
with Memory; use Memory;
package Report is
type Output is tagged private;
procedure Start_Container_Test
(Self : not null access Output'Class;
Name : String;
Category : String; -- "integer list", "string list", ...
Favorite : Boolean := False);
-- If Favorite is true, the container will be highlighted in the results
procedure Save_Container_Size
(Self : not null access Output'Class;
Size : Long_Integer);
-- Saves the size of the container in the output (for information only)
procedure End_Container_Test (Self : not null access Output'Class);
-- A new set of tests is started, for a specific container.
-- This automatically counts the number of allocation and
-- deallocations done by that test.
procedure Start_Test
(Self : not null access Output'Class;
Name : String;
Comment : String := "";
Start_Group : Boolean := False);
procedure End_Test (Self : not null access Output'Class);
-- A test on the current container is executed. These procedures measure
-- the execution time. Calling End_Test is optional if you are calling
-- Start_Test immediately.
-- You can run the same test multiple times after calling
-- Start_Container_Test. All timings will be recorded.
-- Tests are grouped, so that the first test run in a group, for the
-- first container, is displayed as "100%", and other tests in the same
-- group are displayed relative to this one.
-- Set Start_Group to True to start a new group. All following tests
-- will belong to the same group, until a test that also sets Start_Group
-- to True.
procedure End_Test_Not_Run (Self : not null access Output'Class);
-- Same as End_Test, but mark the test as "NOT RUN".
procedure Display (Self : not null access Output'Class);
-- Outputs the results to a JSON file
-- generic
-- type Container (<>) is limited private;
-- with procedure Run
-- (Self : in out Container; Col : Column_Number; Start : Time) is <>;
-- procedure Run_Tests
-- (Stdout : in out Output'Class;
-- Title : String;
-- Self : in out Container;
-- Fewer_Items : Boolean := False);
-- For each column defined in Stdout and associated with a test, executes
-- Run. Run can either print some output via Stdout.Print_Line (for
-- instance), or let this procedure print the time on its own.
private
type Output is tagged record
Global_Result : JSON_Value := JSON_Null;
All_Tests : JSON_Array;
Container_Test : JSON_Value := JSON_Null;
Tests_In_Container : JSON_Value;
Current_Test : JSON_Value := JSON_Null;
At_Test_Start : Mem_Info;
Start_Time : Ada.Calendar.Time;
end record;
end Report;
|
reznikmm/matreshka | Ada | 301 | ads |
package Types.Discretes is
pragma Preelaborate;
type Discrete_Type is limited interface;
type Discrete_Type_Access is access all Discrete_Type'Class
with Storage_Size => 0;
type Discrete_Type_Array is
array (Positive range <>) of Discrete_Type_Access;
end Types.Discretes;
|
AdaCore/training_material | Ada | 194 | adb | with Calendar;
procedure Main is
Relative : Duration := 1.0;
Absolute : Calendar.Time
:= Calendar.Time_Of (2030, 10, 01);
begin
delay Relative;
delay until Absolute;
end Main;
|
stcarrez/atlas | Ada | 973 | ads | -----------------------------------------------------------------------
-- atlas -- Atlas demo
-----------------------------------------------------------------------
-- Copyright (C) 2009, 2010, 2011, 2012, 2013 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package Atlas is
pragma Pure;
end Atlas;
|
smola/language-dataset | Ada | 3,616 | ads | with Standard_Natural_Numbers; use Standard_Natural_Numbers;
with Standard_Floating_Matrices;
with Standard_Complex_Matrices;
with Double_Double_Matrices;
with Quad_Double_Matrices;
with Multprec_Floating_Matrices;
with DoblDobl_Complex_Matrices;
with QuadDobl_Complex_Matrices;
with Multprec_Complex_Matrices;
package VarbPrec_Matrix_Conversions is
-- DESCRIPTION :
-- Often we want to convert matrices of various precisions.
-- This package collects routines to convert between matrices of
-- different types of precision for use in variable precision solvers,
-- for real and complex numbers.
function d2dd ( mtx : Standard_Floating_Matrices.Matrix )
return Double_Double_Matrices.Matrix;
function d2dd ( mtx : Standard_Complex_Matrices.Matrix )
return DoblDobl_Complex_Matrices.Matrix;
function d2qd ( mtx : Standard_Floating_Matrices.Matrix )
return Quad_Double_Matrices.Matrix;
function d2qd ( mtx : Standard_Complex_Matrices.Matrix )
return QuadDobl_Complex_Matrices.Matrix;
function d2mp ( mtx : Standard_Floating_Matrices.Matrix )
return Multprec_Floating_Matrices.Matrix;
function d2mp ( mtx : Standard_Complex_Matrices.Matrix )
return Multprec_Complex_Matrices.Matrix;
-- DESCRIPTION :
-- Converts a floating-point matrix in standard double precision
-- to a matrix in double double (dd), quad double (qd) precision,
-- or arbitrary multiprecision (mp).
function dd2d ( mtx : Double_Double_Matrices.Matrix )
return Standard_Floating_Matrices.Matrix;
function dd2d ( mtx : DoblDobl_Complex_Matrices.Matrix )
return Standard_Complex_Matrices.Matrix;
function dd2qd ( mtx : Double_Double_Matrices.Matrix )
return Quad_Double_Matrices.Matrix;
function dd2qd ( mtx : DoblDobl_Complex_Matrices.Matrix )
return QuadDobl_Complex_Matrices.Matrix;
function dd2mp ( mtx : Double_Double_Matrices.Matrix )
return Multprec_Floating_Matrices.Matrix;
function dd2mp ( mtx : DoblDobl_Complex_Matrices.Matrix )
return Multprec_Complex_Matrices.Matrix;
-- DESCRIPTION :
-- Converts a matrix in double double precision to a matrix
-- in standard double (d), quad double (qd) precision,
-- or arbitrary multiprecision (mp).
function qd2d ( mtx : Quad_Double_Matrices.Matrix )
return Standard_Floating_Matrices.Matrix;
function qd2d ( mtx : QuadDobl_Complex_Matrices.Matrix )
return Standard_Complex_Matrices.Matrix;
function qd2dd ( mtx : Quad_Double_Matrices.Matrix )
return Double_Double_Matrices.Matrix;
function qd2dd ( mtx : QuadDobl_Complex_Matrices.Matrix )
return DoblDobl_Complex_Matrices.Matrix;
function qd2mp ( mtx : Quad_Double_Matrices.Matrix )
return Multprec_Floating_Matrices.Matrix;
function qd2mp ( mtx : QuadDobl_Complex_Matrices.Matrix )
return Multprec_Complex_Matrices.Matrix;
-- DESCRIPTION :
-- Converts a matrix in quad double precision to a matrix
-- in standard double (d) or double double (dd) precision,
-- or arbitrary multiprecision (mp).
procedure Set_Size ( mtx : in out Multprec_Floating_Matrices.Matrix;
size : in natural32 );
procedure Set_Size ( mtx : in out Multprec_Complex_Matrices.Matrix;
size : in natural32 );
-- DESCRIPTION :
-- Sets the size of the matrix mtx to the given value of size.
end VarbPrec_Matrix_Conversions;
|
optikos/oasis | Ada | 553 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Elements.Definitions;
package Program.Elements.Type_Definitions is
pragma Pure (Program.Elements.Type_Definitions);
type Type_Definition is
limited interface and Program.Elements.Definitions.Definition;
type Type_Definition_Access is access all Type_Definition'Class
with Storage_Size => 0;
end Program.Elements.Type_Definitions;
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.