repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
leonhxx/pok | Ada | 4,673 | ads | -- POK header
--
-- The following file is a part of the POK project. Any modification should
-- be made according to the POK licence. You CANNOT use this file or a part
-- of a file for your own project.
--
-- For more information on the POK licence, please see our LICENCE FILE
--
-- Please follow the coding guidelines described in doc/CODING_GUIDELINES
--
-- Copyright (c) 2007-2021 POK team
-- This is a compilable Ada 95 specification for the APEX interface,
-- derived from section 3 of ARINC 653.
-- The declarations of the services given below are taken from the
-- standard, as are the enumerated types and the names of the others types.
-- However, the definitions given for these others types, and the
-- names and values given below for constants, are all implementation
-- specific.
-- All types have defining representation pragmas or clauses to ensure
-- representation compatibility with the C and Ada 83 bindings.
-- ---------------------------------------------------------------------------
-- --
-- Root package providing constant and type definitions --
-- --
-- ---------------------------------------------------------------------------
with System;
-- This is the Ada 95 predefined C interface package
with Interfaces.C;
package APEX is
pragma Pure;
-- ----------------------------
-- Domain limits --
-- ----------------------------
-- Domain dependent
-- These values define the domain limits and are implementation-dependent.
System_Limit_Number_Of_Partitions : constant := 32;
-- module scope
System_Limit_Number_Of_Messages : constant := 512;
-- module scope
System_Limit_Message_Size : constant := 16#10_0000#;
-- module scope
System_Limit_Number_Of_Processes : constant := 1024;
-- partition scope
System_Limit_Number_Of_Sampling_Ports : constant := 1024;
-- partition scope
System_Limit_Number_Of_Queuing_Ports : constant := 1024;
-- partition scope
System_Limit_Number_Of_Buffers : constant := 512;
-- partition scope
System_Limit_Number_Of_Blackboards : constant := 512;
-- partition scope
System_Limit_Number_Of_Semaphores : constant := 512;
-- partition scope
System_Limit_Number_Of_Events : constant := 512;
-- partition scope
-- ----------------------------
-- Base APEX types --
-- ----------------------------
-- The actual sizes of these base types are system-specific and must
-- match those of the underlying Operating System.
type APEX_Byte is new Interfaces.C.unsigned_char;
type APEX_Integer is new Interfaces.C.long;
type APEX_Unsigned is new Interfaces.C.unsigned_long;
type APEX_Long_Integer is new Interfaces.Integer_64;
-- If Integer_64 is not provided in package Interfaces, any implementation-
-- defined alternative 64-bit signed integer type may be used.
-- ----------------------------
-- General APEX types --
-- ----------------------------
type Return_Code_Type is (
No_Error, -- request valid and operation performed
No_Action, -- status of system unaffected by request
Not_Available, -- resource required by request unavailable
Invalid_Param, -- invalid parameter specified in request
Invalid_Config, -- parameter incompatible with configuration
Invalid_Mode, -- request incompatible with current mode
Timed_Out); -- time-out tied up with request has expired
pragma Convention (C, Return_Code_Type);
Max_Name_Length : constant := 30;
subtype Name_Type is String (1 .. Max_Name_Length);
subtype System_Address_Type is System.Address;
subtype Message_Addr_Type is System.Address;
subtype Message_Size_Type is APEX_Integer range
1 .. System_Limit_Message_Size;
subtype Message_Range_Type is APEX_Integer range
0 .. System_Limit_Number_Of_Messages;
type Port_Direction_Type is (Source, Destination);
pragma Convention (C, Port_Direction_Type);
type Queuing_Discipline_Type is (Fifo, Priority);
pragma Convention (C, Queuing_Discipline_Type);
subtype System_Time_Type is APEX_Long_Integer;
-- 64-bit signed integer with 1 nanosecond LSB
Infinite_Time_Value : constant System_Time_Type;
Aperiodic : constant System_Time_Type;
Zero_Time_Value : constant System_Time_Type;
private
Infinite_Time_Value : constant System_Time_Type := -1;
Aperiodic : constant System_Time_Type := 0;
Zero_Time_Value : constant System_Time_Type := 0;
end APEX;
|
kjseefried/coreland-cgbc | Ada | 797 | adb | with Ada.Strings;
with CGBC.Bounded_Strings;
with Test;
procedure T_Bstr_Append_L01 is
package BS renames CGBC.Bounded_Strings;
TC : Test.Context_t;
S1 : BS.Bounded_String (8);
begin
Test.Initialize
(Test_Context => TC,
Program => "t_bstr_append_l01",
Test_DB => "TEST_DB",
Test_Results => "TEST_RESULTS");
BS.Append (S1, "ABCD");
-- Requires truncation and Right'Length >= Left.Data_Size
BS.Append
(Source => S1,
New_Item => "012345678",
Drop => Ada.Strings.Left);
Test.Check (TC, 209, BS.Length (S1) = 8, "BS.Length (S1) = 8");
Test.Check (TC, 210, BS.Maximum_Length (S1) = 8, "BS.Maximum_Length (S1) = 8");
Test.Check (TC, 211, BS.To_String (S1) = "12345678", "BS.To_String (S1) = ""12345678""");
end T_Bstr_Append_L01;
|
tum-ei-rcs/StratoX | Ada | 6,475 | ads | -- This spec has been automatically generated from STM32F429x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
with HAL;
with System;
package STM32_SVD.NVIC is
pragma Preelaborate;
---------------
-- Registers --
---------------
-------------------
-- ICTR_Register --
-------------------
subtype ICTR_INTLINESNUM_Field is HAL.UInt4;
-- Interrupt Controller Type Register
type ICTR_Register is record
-- Read-only. Total number of interrupt lines in groups
INTLINESNUM : ICTR_INTLINESNUM_Field;
-- unspecified
Reserved_4_31 : HAL.UInt28;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ICTR_Register use record
INTLINESNUM at 0 range 0 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
------------------
-- IPR_Register --
------------------
-- IPR0_IPR_N array element
subtype IPR0_IPR_N_Element is HAL.Byte;
-- IPR0_IPR_N array
type IPR0_IPR_N_Field_Array is array (0 .. 3) of IPR0_IPR_N_Element
with Component_Size => 8, Size => 32;
-- Interrupt Priority Register
type IPR_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- IPR_N as a value
Val : HAL.Word;
when True =>
-- IPR_N as an array
Arr : IPR0_IPR_N_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for IPR_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-------------------
-- STIR_Register --
-------------------
subtype STIR_INTID_Field is HAL.UInt9;
-- Software Triggered Interrupt Register
type STIR_Register is record
-- Write-only. interrupt to be triggered
INTID : STIR_INTID_Field := 16#0#;
-- unspecified
Reserved_9_31 : HAL.UInt23 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for STIR_Register use record
INTID at 0 range 0 .. 8;
Reserved_9_31 at 0 range 9 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Nested Vectored Interrupt Controller
type NVIC_Peripheral is record
-- Interrupt Controller Type Register
ICTR : ICTR_Register;
-- Interrupt Set-Enable Register
ISER0 : HAL.Word;
-- Interrupt Set-Enable Register
ISER1 : HAL.Word;
-- Interrupt Set-Enable Register
ISER2 : HAL.Word;
-- Interrupt Clear-Enable Register
ICER0 : HAL.Word;
-- Interrupt Clear-Enable Register
ICER1 : HAL.Word;
-- Interrupt Clear-Enable Register
ICER2 : HAL.Word;
-- Interrupt Set-Pending Register
ISPR0 : HAL.Word;
-- Interrupt Set-Pending Register
ISPR1 : HAL.Word;
-- Interrupt Set-Pending Register
ISPR2 : HAL.Word;
-- Interrupt Clear-Pending Register
ICPR0 : HAL.Word;
-- Interrupt Clear-Pending Register
ICPR1 : HAL.Word;
-- Interrupt Clear-Pending Register
ICPR2 : HAL.Word;
-- Interrupt Active Bit Register
IABR0 : HAL.Word;
-- Interrupt Active Bit Register
IABR1 : HAL.Word;
-- Interrupt Active Bit Register
IABR2 : HAL.Word;
-- Interrupt Priority Register
IPR0 : IPR_Register;
-- Interrupt Priority Register
IPR1 : IPR_Register;
-- Interrupt Priority Register
IPR2 : IPR_Register;
-- Interrupt Priority Register
IPR3 : IPR_Register;
-- Interrupt Priority Register
IPR4 : IPR_Register;
-- Interrupt Priority Register
IPR5 : IPR_Register;
-- Interrupt Priority Register
IPR6 : IPR_Register;
-- Interrupt Priority Register
IPR7 : IPR_Register;
-- Interrupt Priority Register
IPR8 : IPR_Register;
-- Interrupt Priority Register
IPR9 : IPR_Register;
-- Interrupt Priority Register
IPR10 : IPR_Register;
-- Interrupt Priority Register
IPR11 : IPR_Register;
-- Interrupt Priority Register
IPR12 : IPR_Register;
-- Interrupt Priority Register
IPR13 : IPR_Register;
-- Interrupt Priority Register
IPR14 : IPR_Register;
-- Interrupt Priority Register
IPR15 : IPR_Register;
-- Interrupt Priority Register
IPR16 : IPR_Register;
-- Interrupt Priority Register
IPR17 : IPR_Register;
-- Interrupt Priority Register
IPR18 : IPR_Register;
-- Interrupt Priority Register
IPR19 : IPR_Register;
-- Interrupt Priority Register
IPR20 : IPR_Register;
-- Software Triggered Interrupt Register
STIR : STIR_Register;
end record
with Volatile;
for NVIC_Peripheral use record
ICTR at 4 range 0 .. 31;
ISER0 at 256 range 0 .. 31;
ISER1 at 260 range 0 .. 31;
ISER2 at 264 range 0 .. 31;
ICER0 at 384 range 0 .. 31;
ICER1 at 388 range 0 .. 31;
ICER2 at 392 range 0 .. 31;
ISPR0 at 512 range 0 .. 31;
ISPR1 at 516 range 0 .. 31;
ISPR2 at 520 range 0 .. 31;
ICPR0 at 640 range 0 .. 31;
ICPR1 at 644 range 0 .. 31;
ICPR2 at 648 range 0 .. 31;
IABR0 at 768 range 0 .. 31;
IABR1 at 772 range 0 .. 31;
IABR2 at 776 range 0 .. 31;
IPR0 at 1024 range 0 .. 31;
IPR1 at 1028 range 0 .. 31;
IPR2 at 1032 range 0 .. 31;
IPR3 at 1036 range 0 .. 31;
IPR4 at 1040 range 0 .. 31;
IPR5 at 1044 range 0 .. 31;
IPR6 at 1048 range 0 .. 31;
IPR7 at 1052 range 0 .. 31;
IPR8 at 1056 range 0 .. 31;
IPR9 at 1060 range 0 .. 31;
IPR10 at 1064 range 0 .. 31;
IPR11 at 1068 range 0 .. 31;
IPR12 at 1072 range 0 .. 31;
IPR13 at 1076 range 0 .. 31;
IPR14 at 1080 range 0 .. 31;
IPR15 at 1084 range 0 .. 31;
IPR16 at 1088 range 0 .. 31;
IPR17 at 1092 range 0 .. 31;
IPR18 at 1096 range 0 .. 31;
IPR19 at 1100 range 0 .. 31;
IPR20 at 1104 range 0 .. 31;
STIR at 3840 range 0 .. 31;
end record;
-- Nested Vectored Interrupt Controller
NVIC_Periph : aliased NVIC_Peripheral
with Import, Address => NVIC_Base;
end STM32_SVD.NVIC;
|
wookey-project/ewok-legacy | Ada | 11,834 | adb | --
-- Copyright 2018 The wookey project team <[email protected]>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with ewok.syscalls; use ewok.syscalls;
with ewok.tasks; use ewok.tasks;
with ewok.debug;
with ewok.devices;
with ewok.exported.interrupts;
use type ewok.exported.interrupts.t_interrupt_config_access;
with ewok.interrupts;
with ewok.layout;
with ewok.sched;
with ewok.syscalls.init;
with ewok.syscalls.cfg;
with ewok.syscalls.gettick;
with ewok.syscalls.ipc;
with ewok.syscalls.lock;
with ewok.syscalls.log;
with ewok.syscalls.reset;
with ewok.syscalls.sleep;
with ewok.syscalls.yield;
with ewok.syscalls.rng;
with soc.interrupts; use type soc.interrupts.t_interrupt;
with soc.nvic;
with m4.cpu;
with m4.cpu.instructions;
#if CONFIG_DBGLEVEL >= 7
with types.c; use types.c;
#end if;
package body ewok.softirq
with spark_mode => off
is
package TSK renames ewok.tasks;
procedure init
is
begin
p_isr_requests.init (isr_queue);
p_syscall_requests.init (syscall_queue);
pragma DEBUG (debug.log (debug.INFO, "SOFTIRQ initialized"));
end init;
procedure push_isr
(task_id : in ewok.tasks_shared.t_task_id;
params : in t_isr_parameters)
is
req : constant t_isr_request := (task_id, WAITING, params);
ok : boolean;
begin
p_isr_requests.write (isr_queue, req, ok);
if not ok then
debug.panic ("push_isr() failed.");
end if;
ewok.tasks.set_state
(ID_SOFTIRQ, TASK_MODE_MAINTHREAD, TASK_STATE_RUNNABLE);
end push_isr;
procedure push_syscall
(task_id : in ewok.tasks_shared.t_task_id)
is
req : constant t_syscall_request := (task_id, WAITING);
ok : boolean;
begin
p_syscall_requests.write (syscall_queue, req, ok);
if not ok then
debug.panic ("push_syscall() failed.");
end if;
ewok.tasks.set_state
(ID_SOFTIRQ, TASK_MODE_MAINTHREAD, TASK_STATE_RUNNABLE);
end push_syscall;
procedure syscall_handler (req : in t_syscall_request)
is
type t_syscall_parameters_access is access all t_syscall_parameters;
function to_syscall_parameters_access is new ada.unchecked_conversion
(system_address, t_syscall_parameters_access);
svc : t_svc_type;
params_a : t_syscall_parameters_access;
begin
--
-- Getting the svc number from the SVC instruction
--
declare
PC : constant system_address :=
TSK.tasks_list(req.caller_id).ctx.frame_a.all.PC;
inst : m4.cpu.instructions.t_svc_instruction
with import, address => to_address (PC - 2);
begin
if not inst.opcode'valid then
raise program_error;
end if;
declare
svc_type : t_svc_type with address => inst.svc_num'address;
val : unsigned_8 with address => inst.svc_num'address;
begin
if not svc_type'valid then
pragma DEBUG (debug.log (debug.ERROR, "Invalid SVC: "
& unsigned_8'image (val)));
ewok.tasks.set_state
(req.caller_id, TASK_MODE_MAINTHREAD, TASK_STATE_FAULT);
set_return_value
(req.caller_id, TSK.tasks_list(req.caller_id).mode, SYS_E_DENIED);
return;
end if;
svc := svc_type;
end;
end;
--
-- Getting syscall parameters
--
params_a :=
to_syscall_parameters_access (TSK.tasks_list(req.caller_id).ctx.frame_a.all.R0);
if params_a = NULL then
pragma DEBUG (debug.log (debug.ERROR,
ewok.tasks.tasks_list(req.caller_id).name
& ": syscall with no parameters"));
return;
end if;
if not params_a.all.syscall_type'valid then
pragma DEBUG (debug.log (debug.ERROR,
ewok.tasks.tasks_list(req.caller_id).name
& ": unknown syscall " &
ewok.syscalls.t_syscall_type'image (params_a.all.syscall_type)));
return;
end if;
--
-- Logging
--
#if CONFIG_DBGLEVEL >= 7
declare
len : constant natural := types.c.len (TSK.tasks_list(req.caller_id).name.all);
name : string (1 .. len);
begin
to_ada (name, TSK.tasks_list(req.caller_id).name.all);
debug.log (debug.INFO, name & ": svc"
& ewok.syscalls.t_svc_type'image (svc)
& ", syscall" & ewok.syscalls.t_syscall_type'image
(params_a.all.syscall_type));
end;
#end if;
--
-- Calling the handler
--
if svc /= SVC_SYSCALL then
debug.panic ("syscall_handler(): wrong SVC"
& ewok.syscalls.t_svc_type'image (svc));
end if;
case params_a.all.syscall_type is
when SYS_LOG =>
ewok.syscalls.log.sys_log
(req.caller_id, params_a.all.args, TASK_MODE_MAINTHREAD);
when SYS_YIELD =>
ewok.syscalls.yield.sys_yield (req.caller_id, TASK_MODE_MAINTHREAD);
when SYS_INIT =>
ewok.syscalls.init.sys_init
(req.caller_id, params_a.all.args, TASK_MODE_MAINTHREAD);
when SYS_IPC =>
ewok.syscalls.ipc.sys_ipc
(req.caller_id, params_a.all.args, TASK_MODE_MAINTHREAD);
when SYS_CFG =>
ewok.syscalls.cfg.sys_cfg
(req.caller_id, params_a.all.args, TASK_MODE_MAINTHREAD);
when SYS_GETTICK =>
ewok.syscalls.gettick.sys_gettick
(req.caller_id, params_a.all.args, TASK_MODE_MAINTHREAD);
when SYS_RESET =>
ewok.syscalls.reset.sys_reset
(req.caller_id, TASK_MODE_MAINTHREAD);
when SYS_SLEEP =>
ewok.syscalls.sleep.sys_sleep
(req.caller_id, params_a.all.args, TASK_MODE_MAINTHREAD);
when SYS_LOCK =>
ewok.syscalls.lock.sys_lock
(req.caller_id, params_a.all.args, TASK_MODE_MAINTHREAD);
when SYS_GET_RANDOM =>
ewok.syscalls.rng.sys_get_random
(req.caller_id, params_a.all.args, TASK_MODE_MAINTHREAD);
end case;
end syscall_handler;
procedure isr_handler (req : in t_isr_request)
is
params : t_parameters;
config_a : ewok.exported.interrupts.t_interrupt_config_access;
begin
-- For further MPU mapping of the device, we need to know which device
-- triggered that interrupt.
-- Note
-- - EXTIs are not associated to any device because they can be
-- associated to several GPIO pins
-- - DMAs are not considered as devices because a single controller
-- can be used by several drivers. DMA streams are registered in a
-- specific table
TSK.tasks_list(req.caller_id).isr_ctx.device_id :=
ewok.interrupts.get_device_from_interrupt (req.params.interrupt);
-- Keep track of some hint about scheduling policy to apply after the end
-- of the ISR execution
-- Note - see above
config_a :=
ewok.devices.get_interrupt_config_from_interrupt (req.params.interrupt);
if config_a /= NULL then
TSK.tasks_list(req.caller_id).isr_ctx.sched_policy := config_a.all.mode;
else
TSK.tasks_list(req.caller_id).isr_ctx.sched_policy := ISR_STANDARD;
end if;
-- Zeroing the ISR stack if the ISR previously executed belongs to
-- another task
if previous_isr_owner /= req.caller_id then
declare
stack : byte_array(1 .. ewok.layout.STACK_SIZE_TASK_ISR)
with address => to_address (ewok.layout.STACK_BOTTOM_TASK_ISR);
begin
stack := (others => 0);
end;
previous_isr_owner := req.caller_id;
end if;
--
-- Note - isr_ctx.entry_point is a wrapper. The real ISR entry
-- point is defined in params(0)
--
-- User defined ISR handler
params(0) := req.params.handler;
-- IRQ
params(1) := unsigned_32'val
(soc.nvic.to_irq_number (req.params.interrupt));
-- Status and data returned by the 'posthook' treatement
-- (cf. ewok.posthook.exec)
params(2) := req.params.posthook_status;
params(3) := req.params.posthook_data;
create_stack
(ewok.layout.STACK_TOP_TASK_ISR,
TSK.tasks_list(req.caller_id).isr_ctx.entry_point, -- Wrapper
params,
TSK.tasks_list(req.caller_id).isr_ctx.frame_a);
ewok.tasks.set_mode (req.caller_id, TASK_MODE_ISRTHREAD);
ewok.tasks.set_state
(req.caller_id, TASK_MODE_ISRTHREAD, TASK_STATE_RUNNABLE);
end isr_handler;
procedure main_task
is
isr_req : t_isr_request;
sys_req : t_syscall_request;
ok : boolean;
begin
loop
--
-- User ISRs
--
loop
m4.cpu.disable_irq;
p_isr_requests.read (isr_queue, isr_req, ok);
m4.cpu.enable_irq;
exit when not ok;
if isr_req.state = WAITING then
if TSK.tasks_list(isr_req.caller_id).state /= TASK_STATE_LOCKED and
TSK.tasks_list(isr_req.caller_id).state /= TASK_STATE_SLEEPING_DEEP
then
m4.cpu.disable_irq;
isr_handler (isr_req);
isr_req.state := DONE;
ewok.sched.request_schedule;
m4.cpu.enable_irq;
m4.cpu.instructions.full_memory_barrier;
else
m4.cpu.disable_irq;
p_isr_requests.write (isr_queue, isr_req, ok);
if not ok then
debug.panic ("SOFTIRQ failed to add ISR request");
end if;
ewok.sched.request_schedule;
m4.cpu.enable_irq;
m4.cpu.instructions.full_memory_barrier;
end if;
else
raise program_error;
end if;
end loop;
--
-- Syscalls
--
loop
m4.cpu.disable_irq;
p_syscall_requests.read (syscall_queue, sys_req, ok);
m4.cpu.enable_irq;
exit when not ok;
if sys_req.state = WAITING then
syscall_handler (sys_req);
sys_req.state := DONE;
else
raise program_error;
end if;
end loop;
--
-- Set softirq task as IDLE if there is no more request to handle
--
m4.cpu.disable_irq;
if p_isr_requests.state (isr_queue) = p_isr_requests.EMPTY and
p_syscall_requests.state (syscall_queue) = p_syscall_requests.EMPTY
then
ewok.tasks.set_state
(ID_SOFTIRQ, TASK_MODE_MAINTHREAD, TASK_STATE_IDLE);
m4.cpu.instructions.full_memory_barrier;
ewok.sched.request_schedule;
end if;
m4.cpu.enable_irq;
end loop;
end main_task;
end ewok.softirq;
|
reznikmm/matreshka | Ada | 3,993 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Draw_Text_Path_Attributes;
package Matreshka.ODF_Draw.Text_Path_Attributes is
type Draw_Text_Path_Attribute_Node is
new Matreshka.ODF_Draw.Abstract_Draw_Attribute_Node
and ODF.DOM.Draw_Text_Path_Attributes.ODF_Draw_Text_Path_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Draw_Text_Path_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Draw_Text_Path_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Draw.Text_Path_Attributes;
|
jscparker/math_packages | Ada | 11,269 | adb |
-- Procedure tests DFT_Chirped. Code fragments
-- demonstrate some features of DFT's.
with Chirped;
with Text_IO; use Text_IO;
with Ada.Numerics.Generic_Elementary_Functions;
procedure chirped_demo_1 is
type Real is digits 15;
package mth is new Ada.Numerics.Generic_Elementary_Functions (Real);
use mth;
package rio is new Float_IO(Real);
use rio;
package iio is new Integer_IO(Integer);
use iio;
Log_Of_Max_Data_Length : constant := 12;
-- ***NOTICE this means max data array size is 4096.***
-- The larger you make this array, the slower program
-- might run.
type Array_Index is range 0..2**(Log_Of_Max_Data_Length+1)-1;
--subtype Array_Index is Integer range 0..2**(Log_Of_Max_Data_Length+1)-1;
type Data_Array is array(Array_Index) of Real;
package fft is new Chirped
(Real, Array_Index, Data_Array, Log_Of_Max_Data_Length);
use fft;
D_Re, D_Im : Data_Array;
Data_Set_Last : Data_Index;
Basis_Function_Last : Data_Index;
Theta, Frequency, Norm : Real;
Two_Pi_Over_N : Real;
Num, Mode : Integer;
Area1, Area2 : Real;
DeltaRE, DeltaIM : Real;
Dat_Re, Dat_Im : Real;
Max_Error, Del : Real;
Pii : constant Real := 3.14159_26535_89793_23846;
-----------
-- Pause --
-----------
procedure Pause (s1,s2,s3,s4,s5,s6,s7,s8,s9,s10 : string := "") is
Continue : Character := ' ';
begin
new_line(2);
if S1 /= "" then put_line (S1); end if;
if S2 /= "" then put_line (S2); end if;
if S3 /= "" then put_line (S3); end if;
if S4 /= "" then put_line (S4); end if;
if S5 /= "" then put_line (S5); end if;
if S6 /= "" then put_line (S6); end if;
if S7 /= "" then put_line (S7); end if;
if S8 /= "" then put_line (S8); end if;
if S9 /= "" then put_line (S9); end if;
if S10 /= "" then put_line (S10); end if;
dialog: loop
begin
new_line(1);
put ("Type a character to continue: ");
get_immediate (Continue);
exit dialog;
exception
when others => null;
end;
end loop dialog;
new_line(2);
end pause;
begin
new_line;
put ("Input number of data points to use in the following tests.");
new_line;
put ("Maximum allowed number is: ");
put (2**Log_Of_Max_Data_Length);
new_line;
put ("A nice prime number will demonstate the algorithm, for example 37.");
new_line;
put ("Enter the desired number: ");
get (Num);
Basis_Function_Last := Data_Index (Num - 1);
Data_Set_Last := Basis_Function_Last;
--*****************************************************************
-- Test 1.
-- Make a basis element of the set of Fourier basis states:
-- Its DFT should zero everywhere except for the element = Mode.
-- There, the value of the DFT should be (1.0, 0.0). Below
-- we normalize the basis element with the factor Norm = 1/Sqrt(N).
--*****************************************************************
Pause
("Test 1: Use the Chirped_FFT to take the",
"Discrete Fourier Transform (DFT) the Fourier basis function:",
" ",
" Exp (i*T*Mode*2*Pi/N) / SQRT(N),",
" ",
"where N is the number of points. The result of the DFT",
"should be a delta-function peaked at position Mode.");
put_line ("Input Mode (0, 1, 2, ...) of the basis function you wish to DFT: ");
put_line ("For example, if you are using 37 points, try entering mode 31. ");
put ("Enter the desired number: ");
Get (Mode);
Frequency := Real (Mode);
--*****************************************************************
Two_Pi_Over_N := 2.0 * Pii / (Real (Basis_Function_Last) + 1.0);
Norm := 1.0 / SQRT ((Real (Basis_Function_Last) + 1.0));
for I in 0..Basis_Function_Last loop
Theta := Two_Pi_Over_N * Frequency * Real (I);
D_Re(I) := Norm * Cos (Theta);
D_Im(I) := Norm * Sin (Theta);
end loop;
put_line ("Starting Test 1:");
new_line; put ("Basis function was constructed using "); put(Num);
put(" data points.");
FFT_Chirped
(Data_Re => D_Re,
Data_Im => D_Im,
Input_Data_Last => Basis_Function_Last,
Inverse_FFT_Desired => False,
Normalized_Data_Desired => True);
Pause
("Ending the Discrete Fourier Transform (DFT).",
"We have taken the DFT of Exp (i*T*Mode*2*Pi/N) / SQRT(N).",
"The result should be (0.0, 0.0) everywhere except for ",
"a (1.0, 0.0) at data point Mode.");
for I in Data_Index range 0..Basis_Function_Last loop
new_line; put (Integer(I)); put(' ');
put (D_Re(I)); put(' '); put(D_Im(I));
end loop;
--*****************************************************************
-- Test 1b.
-- We 1st make a basis element of the set of Fourier basis states:
-- Its DFT should zero everywhere except for the element = Mode.
-- There, the value of the DFT should be (1.0, 0.0). Below
-- we normalize the basis element with the factor Norm = 1/Sqrt(N).
--*****************************************************************
Pause
("Test 1b: Use the Chirped_FFT to take the inverse",
"Discrete Fourier Transform (DFT) the Fourier basis function:",
" ",
" Exp (-i*T*Mode*2*Pi/N) / SQRT(N),",
" ",
"where N is the number of points. The result of the DFT",
"should be a delta-function peaked at position Mode.");
put_line ("Input Mode (0, 1, 2, ...) of the basis function you wish to DFT.");
put_line ("For example, if you are using 37 points, try entering mode 31.");
put ("Enter the desired number: ");
Get (Mode);
Frequency := Real (Mode);
Two_Pi_Over_N := 2.0 * Pii / (Real (Basis_Function_Last) + 1.0);
Norm := 1.0 / SQRT ((Real (Basis_Function_Last) + 1.0));
for I in 0..Basis_Function_Last loop
Theta := Two_Pi_Over_N * Frequency * Real (I);
D_Re(I) := Norm * Cos (Theta);
D_Im(I) := -Norm * Sin (Theta);
end loop;
put_line ("Starting Test 1b:");
new_line; put ("Basis function was constructed using "); put(Num);
put(" data points.");
FFT_Chirped
(Data_Re => D_Re,
Data_Im => D_Im,
Input_Data_Last => Basis_Function_Last,
Inverse_FFT_Desired => True,
Normalized_Data_Desired => True);
Pause
("Ending the Discrete Fourier Transform (DFT).",
"We have taken the inverse DFT of Exp (-i*T*Mode*2*Pi/N) / SQRT(N).",
"The result should be (0.0, 0.0) everywhere except for ",
"a (1.0, 0.0) at data point Mode.");
for I in Data_Index range 0..Basis_Function_Last loop
new_line; put (Integer(I)); put(' ');
put (D_Re(I)); put(' '); put(D_Im(I));
end loop;
--*****************************************************************
-- Test2.
-- Verify Parceval's Theorem. The area under the DFT coefficients
-- should equal the area under the data. Notice that was true in the
-- above test, because Sum (|exp(i*T*Mode*2*Pi/N) / Sqrt(N)|**2) is
-- one on the interval [0,N-1].
-- First we create a new data set:
--*****************************************************************
for I in 0..Data_Set_Last loop
Theta := Real (I);
D_Re(I) := 1.0 / (Theta + 1.0);
D_Im(I) := Theta**2;
end loop;
Area1 := 0.0;
for I in 0..Data_Set_Last loop
Area1 := Area1 + D_Re(I)*D_Re(I) + D_Im(I)*D_Im(I);
end loop;
Pause
("Test 2: test of Parceval's theorem. The area under the",
"DFT curve (sum of coefficients modulus squared) should equal",
"area under the original curve. This requires the use of the",
"normalized version of the DFT.");
put_line ("Starting Test 2:");
FFT_Chirped
(Data_Re => D_Re,
Data_Im => D_Im,
Input_Data_Last => Data_Set_Last,
Inverse_FFT_Desired => False,
Normalized_Data_Desired => True);
put_line ("Ending DFT");
Area2 := 0.0;
for I in 0..Data_Set_Last loop
Area2 := Area2 + D_Re(I)*D_Re(I) + D_Im(I)*D_Im(I);
end loop;
new_line; put ("Area under the original curve: "); put(Area1);
new_line; put ("Area under Fourier transformed curve: "); put(Area2);
-- Test3.
-- Inverse DFT of the DFT.
Pause
("Test 3: take the inverse DFT of the DFT of some",
"artificial data, and compare with the original data.",
"The test calculates: Data - Inverse_DFT (DFT (Data),",
"then prints the max error.");
for I in 0..Data_Set_Last loop
Theta := Real (I);
D_Re(I) := Sqrt (Theta) / (Theta + 1.0);
D_Im(I) := Cos (0.03737*Theta**2/(Theta + 1.0)) * Theta / (Theta + 1.0);
end loop;
put_line("Starting Test 3:");
FFT_Chirped
(Data_Re => D_Re,
Data_Im => D_Im,
Input_Data_Last => Data_Set_Last,
Inverse_FFT_Desired => False,
Normalized_Data_Desired => True);
FFT_Chirped
(Data_Re => D_Re,
Data_Im => D_Im,
Input_Data_Last => Data_Set_Last,
Inverse_FFT_Desired => True,
Normalized_Data_Desired => True);
Max_Error := 0.0;
for I in 0..Data_Set_Last loop
Theta := Real (I);
Dat_Re := Sqrt (Theta) / (Theta + 1.0);
Dat_Im := Cos (0.03737*Theta**2/(Theta + 1.0)) * Theta / (Theta + 1.0);
Del := Abs (Dat_Re - D_Re(I));
if Max_Error < Del then Max_Error := Del; end if;
Del := Abs (Dat_Im - D_Im(I));
if Max_Error < Del then Max_Error := Del; end if;
end loop;
new_line(2);
put ("Max error in Data - Inverse_DFT (DFT (Data)):"); put (Max_Error);
new_line;
Pause
("Test 4 is a long test..runs through entire range of Array_Index ",
"to see if DFT_Inverse (DFT (Data)) = Data. Nothing is printed",
"unless large errors are detected. (Use 15 digit floating point.)",
"Interrupt the program here if you do not want a long wait.");
for N in Array_Index range 0..Data_Set_Last loop
for I in Array_Index range 0..N loop
Theta := Real (I);
D_Re(I) := 1.0 / (Theta + 1.0);
D_Im(I) := Cos (0.03737 * Theta**2 / (Theta + 1.0));
end loop;
FFT_Chirped
(Data_Re => D_Re,
Data_Im => D_Im,
Input_Data_Last => N,
Inverse_FFT_Desired => False,
Normalized_Data_Desired => True);
FFT_Chirped
(Data_Re => D_Re,
Data_Im => D_Im,
Input_Data_Last => N,
Inverse_FFT_Desired => True,
Normalized_Data_Desired => True);
for I in Array_Index range 0..N loop
Theta := Real (I);
Dat_Re := 1.0 / (Theta + 1.0);
Dat_Im := Cos (0.03737 * Theta**2 / (Theta + 1.0));
DeltaRE := Abs (Dat_Re - D_Re(I));
DeltaIM := Abs (Dat_Im - D_Im(I));
if DeltaRE > 1.0E-11 then
new_line;
put("FAILURE: "); put (DeltaRE); put(" at "); put(Real(I));
end if;
if DeltaIM > 1.0E-11 then
new_line;
put("FAILURE: "); put (DeltaIM); put(" at "); put(Real(I));
end if;
end loop;
end loop;
end;
|
reznikmm/matreshka | Ada | 3,632 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Character_Datas;
package XML.DOM.Comments is
pragma Preelaborate;
type DOM_Comment is limited interface
and XML.DOM.Character_Datas.DOM_Character_Data;
type DOM_Comment_Access is access all DOM_Comment'Class
with Storage_Size => 0;
end XML.DOM.Comments;
|
AdaCore/libadalang | Ada | 288 | ads | package Pkg is
function F1 (A : Integer := 0; B : Integer := 1) return Integer;
procedure P1 (A : Integer := 0; B : Integer := 1);
function F2 (A, B : Integer := 1) return Integer;
procedure P2 (A, B : Integer := 1);
function F3 return Integer;
procedure P3;
end Pkg;
|
zhmu/ananas | Ada | 294 | adb | -- { dg-do compile }
procedure Alignment14 is
type My_Int1 is new Integer;
for My_Int1'Alignment use 8;
type Arr1 is array (1 .. 2) of My_Int1;
type My_Int2 is new Integer;
for My_Int2'Alignment use 16;
type Arr2 is array (1 .. 2) of My_Int2;
begin
null;
end Alignment14;
|
charlie5/cBound | Ada | 1,867 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with swig;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_glx_get_convolution_filter_reply_t is
-- Item
--
type Item is record
response_type : aliased Interfaces.Unsigned_8;
pad0 : aliased Interfaces.Unsigned_8;
sequence : aliased Interfaces.Unsigned_16;
length : aliased Interfaces.Unsigned_32;
pad1 : aliased swig.int8_t_Array (0 .. 7);
width : aliased Interfaces.Integer_32;
height : aliased Interfaces.Integer_32;
pad2 : aliased swig.int8_t_Array (0 .. 7);
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb
.xcb_glx_get_convolution_filter_reply_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_get_convolution_filter_reply_t.Item,
Element_Array => xcb.xcb_glx_get_convolution_filter_reply_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb
.xcb_glx_get_convolution_filter_reply_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_get_convolution_filter_reply_t.Pointer,
Element_Array =>
xcb.xcb_glx_get_convolution_filter_reply_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_glx_get_convolution_filter_reply_t;
|
charlie5/lace | Ada | 155 | ads | with
any_Math.any_Computational;
package float_Math.Computational is new float_Math.any_Computational;
pragma Pure (float_Math.Computational);
|
pmderodat/sdlada | Ada | 5,656 | adb | --------------------------------------------------------------------------------------------------------------------
-- 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.
--------------------------------------------------------------------------------------------------------------------
with Interfaces.C;
with SDL.Error;
with System;
package body SDL.Inputs.Mice is
package C renames Interfaces.C;
use type C.int;
use type C.unsigned;
-- TODO: Re-enable this when the library links against 2.0.4!
-- function Capture (Enabled : in Boolean) return Supported is
-- function SDL_Capture_Mouse (Enabled : in C.unsigned) return C.int with
-- Import => True,
-- Convention => C,
-- External_Name => "SDL_CaptureMouse";
-- begin
-- if SDL_Capture_Mouse (if Enabled = True then 1 else 0) /= Success then
-- return No;
-- end if;
--
-- return Yes;
-- end Capture;
-- TODO: Re-enable this when the library links against 2.0.4!
-- function Get_Global_State (X_Relative, Y_Relative : out SDL.Events.Mice.Movement_Values) return
-- SDL.Events.Mice.Button_Masks is
--
-- function SDL_Get_Global_Mouse_State (X, Y : out C.int) return C.unsigned with
-- Import => True,
-- Convention => C,
-- External_Name => "SDL_GetGlobalMouseState";
--
-- X, Y : C.int;
-- Masks : C.unsigned := SDL_Get_Global_Mouse_State (X, Y);
--
-- use SDL.Events.Mice;
-- begin
-- X_Relative := Movement_Values (X);
-- Y_Relative := Movement_Values (Y);
--
-- return Button_Masks (Masks);
-- end Get_Global_State;
function Get_State (X_Relative, Y_Relative : out SDL.Events.Mice.Movement_Values) return
SDL.Events.Mice.Button_Masks is
function SDL_Get_Mouse_State (X, Y : out C.int) return C.unsigned with
Import => True,
Convention => C,
External_Name => "SDL_GetMouseState";
X, Y : C.int;
Masks : C.unsigned := SDL_Get_Mouse_State (X, Y);
use SDL.Events.Mice;
begin
X_Relative := Movement_Values (X);
Y_Relative := Movement_Values (Y);
return Button_Masks (Masks);
end Get_State;
function In_Relative_Mode return Boolean is
function SDL_Get_Relative_Mouse_Mode return SDL_Bool with
Import => True,
Convention => C,
External_Name => "SDL_GetRelativeMouseMode";
begin
if SDL_Get_Relative_Mouse_Mode = SDL_True then
return True;
end if;
return False;
end In_Relative_Mode;
function Get_Relative_State (X_Relative, Y_Relative : out SDL.Events.Mice.Movement_Values) return
SDL.Events.Mice.Button_Masks is
function SDL_Get_Relative_Mouse_State (X, Y : out C.int) return C.unsigned with
Import => True,
Convention => C,
External_Name => "SDL_GetRelativeMouseState";
X, Y : C.int;
Masks : C.unsigned := SDL_Get_Relative_Mouse_State (X, Y);
use SDL.Events.Mice;
begin
X_Relative := Movement_Values (X);
Y_Relative := Movement_Values (Y);
return Button_Masks (Masks);
end Get_Relative_State;
procedure Set_Relative_Mode (Enable : in Boolean) is
function SDL_Set_Relative_Mouse_Mode (Enable : in C.unsigned) return C.int with
Import => True,
Convention => C,
External_Name => "SDL_SetRelativeMouseMode";
begin
if SDL_Set_Relative_Mouse_Mode (if Enable = True then 1 else 0) /= Success then
raise Mice_Error with SDL.Error.Get;
end if;
end Set_Relative_Mode;
-- TODO: Re-enable this when the library links against 2.0.4!
-- procedure Warp (X, Y : in SDL.Events.Mice.Screen_Coordinates) is
-- procedure SDL_Warp_Mouse_Global (X, Y : in C.int) with
-- Import => True,
-- Convention => C,
-- External_Name => "SDL_WarpMouseGlobal";
-- begin
-- SDL_Warp_Mouse_Global (C.int (X), C.int (Y));
-- end Warp;
--
-- procedure Warp (Window : in SDL.Video.Windows.Window; X, Y : in SDL.Events.Mice.Window_Coordinates) is
-- function Get_Address (Self : in SDL.Video.Windows.Window) return System.Address with
-- Import => True,
-- Convention => Ada;
--
-- procedure SDL_Warp_Mouse_In_Window (Window : in System.Address; X, Y : in C.int) with
-- Import => True,
-- Convention => C,
-- External_Name => "SDL_WarpMouseInWindow";
-- begin
-- SDL_Warp_Mouse_In_Window (Get_Address (Window), C.int (X), C.int (Y));
-- end Warp;
end SDL.Inputs.Mice;
|
Fabien-Chouteau/Ada_Drivers_Library | Ada | 14,950 | ads | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2017, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of STMicroelectronics nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
-- --
-- This file is based on X-CUBE-53L0A1 STM32Cube expansion --
-- --
-- COPYRIGHT(c) 2016 STMicroelectronics --
------------------------------------------------------------------------------
with HAL.I2C;
package VL53L0X is
Fix_Point_16_16_Delta : constant := 1.0 / (2.0 ** 16);
type Fix_Point_16_16 is
delta Fix_Point_16_16_Delta
range -2.0 ** 15 .. 2.0 ** 15 - Fix_Point_16_16_Delta
with Size => 32;
type VL53L0X_Ranging_Sensor
(Port : not null HAL.I2C.Any_I2C_Port) is limited private;
type VL53L0X_GPIO_Functionality is
(No_Interrupt,
Level_Low,
Level_High,
Out_Of_Window,
New_Sample_Ready);
type VL53L0X_Interrupt_Polarity is
(Polarity_Low,
Polarity_High);
procedure Initialize
(This : in out VL53L0X_Ranging_Sensor);
function Read_Id (This : VL53L0X_Ranging_Sensor) return HAL.UInt16;
procedure Set_Device_Address
(This : in out VL53L0X_Ranging_Sensor;
Addr : HAL.I2C.I2C_Address;
Status : out Boolean);
procedure Data_Init
(This : in out VL53L0X_Ranging_Sensor;
Status : out Boolean);
procedure Static_Init
(This : in out VL53L0X_Ranging_Sensor;
GPIO_Function : VL53L0X_GPIO_Functionality;
Status : out Boolean);
procedure Perform_Ref_Calibration
(This : in out VL53L0X_Ranging_Sensor;
Status : out Boolean);
procedure Start_Range_Single_Millimeters
(This : VL53L0X_Ranging_Sensor;
Status : out Boolean);
-- Start a read operation on sensor
function Range_Value_Available
(This : VL53L0X_Ranging_Sensor) return Boolean;
-- Returns True when a new value is available
function Read_Range_Millimeters
(This : VL53L0X_Ranging_Sensor) return HAL.UInt16
with Pre => Range_Value_Available (This);
-- Read the available ranging value
function Read_Range_Single_Millimeters
(This : VL53L0X_Ranging_Sensor) return HAL.UInt16;
procedure Set_GPIO_Config
(This : in out VL53L0X_Ranging_Sensor;
Functionality : VL53L0X_GPIO_Functionality;
Polarity : VL53L0X_Interrupt_Polarity;
Status : out Boolean);
procedure Clear_Interrupt_Mask
(This : VL53L0X_Ranging_Sensor);
function Measurement_Timing_Budget
(This : VL53L0X_Ranging_Sensor) return HAL.UInt32;
procedure Set_Measurement_Timing_Budget
(This : VL53L0X_Ranging_Sensor;
Budget_Micro_Seconds : HAL.UInt32;
Status : out Boolean);
-- Sets the measurement timing budget.
-- The more time, the more precisions. By default, the budget is ~33ms
procedure Set_Signal_Rate_Limit
(This : VL53L0X_Ranging_Sensor;
Rate_Limit : Fix_Point_16_16);
-- Default signal rate: 0.25 MCPS
procedure Set_VCSEL_Pulse_Period_Pre_Range
(This : VL53L0X_Ranging_Sensor;
Period : HAL.UInt8;
Status : out Boolean);
-- Default period: 14 PCLKs
procedure Set_VCSEL_Pulse_Period_Final_Range
(This : VL53L0X_Ranging_Sensor;
Period : HAL.UInt8;
Status : out Boolean);
-- Default period: 10 PCLKs
private
REG_SYSRANGE_START : constant := 16#000#;
-- mask existing bit in #REG_SYSRANGE_START
REG_SYSRANGE_MODE_MASK : constant := 16#0F#;
-- bit 0 in #REG_SYSRANGE_START write 1 toggle state in
-- continuous mode and arm next shot in single shot mode
REG_SYSRANGE_MODE_START_STOP : constant := 16#01#;
-- bit 1 write 0 in #REG_SYSRANGE_START set single shot mode
REG_SYSRANGE_MODE_SINGLESHOT : constant := 16#00#;
-- bit 1 write 1 in #REG_SYSRANGE_START set back-to-back
-- operation mode
REG_SYSRANGE_MODE_BACKTOBACK : constant := 16#02#;
-- bit 2 write 1 in #REG_SYSRANGE_START set timed operation
-- mode
REG_SYSRANGE_MODE_TIMED : constant := 16#04#;
-- bit 3 write 1 in #REG_SYSRANGE_START set histogram operation
-- mode
REG_SYSRANGE_MODE_HISTOGRAM : constant := 16#08#;
REG_SYSTEM_THRESH_HIGH : constant := 16#000C#;
REG_SYSTEM_THRESH_LOW : constant := 16#000E#;
REG_SYSTEM_SEQUENCE_CONFIG : constant := 16#0001#;
REG_SYSTEM_RANGE_CONFIG : constant := 16#0009#;
REG_SYSTEM_INTERMEASUREMENT_PERIOD : constant := 16#0004#;
REG_SYSTEM_INTERRUPT_CONFIG_GPIO : constant := 16#000A#;
REG_SYSTEM_INTERRUPT_GPIO_DISABLED : constant := 16#00#;
REG_SYSTEM_INTERRUPT_GPIO_LEVEL_LOW : constant := 16#01#;
REG_SYSTEM_INTERRUPT_GPIO_LEVEL_HIGH : constant := 16#02#;
REG_SYSTEM_INTERRUPT_GPIO_OUT_OF_WINDOW : constant := 16#03#;
REG_SYSTEM_INTERRUPT_GPIO_NEW_SAMPLE_READY : constant := 16#04#;
REG_GPIO_HV_MUX_ACTIVE_HIGH : constant := 16#0084#;
REG_SYSTEM_INTERRUPT_CLEAR : constant := 16#000B#;
-- Result registers
REG_RESULT_INTERRUPT_STATUS : constant := 16#0013#;
REG_RESULT_RANGE_STATUS : constant := 16#0014#;
REG_RESULT_CORE_PAGE : constant := 1;
REG_RESULT_CORE_AMBIENT_WINDOW_EVENTS_RTN : constant := 16#00BC#;
REG_RESULT_CORE_RANGING_TOTAL_EVENTS_RTN : constant := 16#00C0#;
REG_RESULT_CORE_AMBIENT_WINDOW_EVENTS_REF : constant := 16#00D0#;
REG_RESULT_CORE_RANGING_TOTAL_EVENTS_REF : constant := 16#00D4#;
REG_RESULT_PEAK_SIGNAL_RATE_REF : constant := 16#00B6#;
-- Algo register
REG_ALGO_PART_TO_PART_RANGE_OFFSET_MM : constant := 16#0028#;
REG_I2C_SLAVE_DEVICE_ADDRESS : constant := 16#008A#;
-- Check Limit registers
REG_MSRC_CONFIG_CONTROL : constant := 16#0060#;
REG_PRE_RANGE_CONFIG_MIN_SNR : constant := 16#0027#;
REG_PRE_RANGE_CONFIG_VALID_PHASE_LOW : constant := 16#0056#;
REG_PRE_RANGE_CONFIG_VALID_PHASE_HIGH : constant := 16#0057#;
REG_PRE_RANGE_MIN_COUNT_RATE_RTN_LIMIT : constant := 16#0064#;
REG_FINAL_RANGE_CONFIG_MIN_SNR : constant := 16#0067#;
REG_FINAL_RANGE_CONFIG_VALID_PHASE_LOW : constant := 16#0047#;
REG_FINAL_RANGE_CONFIG_VALID_PHASE_HIGH : constant := 16#0048#;
REG_FINAL_RANGE_CONFIG_MIN_COUNT_RATE_RTN_LIMIT : constant := 16#0044#;
REG_PRE_RANGE_CONFIG_SIGMA_THRESH_HI : constant := 16#0061#;
REG_PRE_RANGE_CONFIG_SIGMA_THRESH_LO : constant := 16#0062#;
-- PRE RANGE registers
REG_PRE_RANGE_CONFIG_VCSEL_PERIOD : constant := 16#0050#;
REG_PRE_RANGE_CONFIG_TIMEOUT_MACROP_HI : constant := 16#0051#;
REG_PRE_RANGE_CONFIG_TIMEOUT_MACROP_LO : constant := 16#0052#;
REG_SYSTEM_HISTOGRAM_BIN : constant := 16#0081#;
REG_HISTOGRAM_CONFIG_INITIAL_PHASE_SELECT : constant := 16#0033#;
REG_HISTOGRAM_CONFIG_READOUT_CTRL : constant := 16#0055#;
REG_FINAL_RANGE_CONFIG_VCSEL_PERIOD : constant := 16#0070#;
REG_FINAL_RANGE_CONFIG_TIMEOUT_MACROP_HI : constant := 16#0071#;
REG_FINAL_RANGE_CONFIG_TIMEOUT_MACROP_LO : constant := 16#0072#;
REG_CROSSTALK_COMPENSATION_PEAK_RATE_MCPS : constant := 16#0020#;
REG_MSRC_CONFIG_TIMEOUT_MACROP : constant := 16#0046#;
REG_SOFT_RESET_GO2_SOFT_RESET_N : constant := 16#00bf#;
REG_IDENTIFICATION_MODEL_ID : constant := 16#00c0#;
REG_IDENTIFICATION_REVISION_ID : constant := 16#00c2#;
REG_OSC_CALIBRATE_VAL : constant := 16#00f8#;
SIGMA_ESTIMATE_MAX_VALUE : constant := 65535;
-- equivalent to a range sigma of 655.35mm
REG_GLOBAL_CONFIG_VCSEL_WIDTH : constant := 16#032#;
REG_GLOBAL_CONFIG_SPAD_ENABLES_REF_0 : constant := 16#0B0#;
REG_GLOBAL_CONFIG_SPAD_ENABLES_REF_1 : constant := 16#0B1#;
REG_GLOBAL_CONFIG_SPAD_ENABLES_REF_2 : constant := 16#0B2#;
REG_GLOBAL_CONFIG_SPAD_ENABLES_REF_3 : constant := 16#0B3#;
REG_GLOBAL_CONFIG_SPAD_ENABLES_REF_4 : constant := 16#0B4#;
REG_GLOBAL_CONFIG_SPAD_ENABLES_REF_5 : constant := 16#0B5#;
REG_GLOBAL_CONFIG_REF_EN_START_SELECT : constant := 16#B6#;
REG_DYNAMIC_SPAD_NUM_REQUESTED_REF_SPAD : constant := 16#4E#;
REG_DYNAMIC_SPAD_REF_EN_START_OFFSET : constant := 16#4F#;
REG_POWER_MANAGEMENT_GO1_POWER_FORCE : constant := 16#80#;
-- Speed of light in um per 1E-10 Seconds
SPEED_OF_LIGHT_IN_AIR : constant := 2997;
REG_VHV_CONFIG_PAD_SCL_SDA_EXTSUP_HV : constant := 16#0089#;
REG_ALGO_PHASECAL_LIM : constant := 16#0030#;
REG_ALGO_PHASECAL_CONFIG_TIMEOUT : constant := 16#0030#;
type VL53L0X_Device_Specific_Parameters is record
Osc_Frequency : HAL.UInt32 := 0;
Last_Timeout : HAL.UInt16 := 0;
Pin0_Functionality : VL53L0X_GPIO_Functionality := No_Interrupt;
Final_Range_Timeout_Micro_Seconds : HAL.UInt32 := 0;
Final_Range_Vcsel_Pulse_Period : HAL.UInt8 := 0;
Pre_Range_Timeout_Micro_Seconds : HAL.UInt32 := 0;
Pre_Range_Vcsel_Pulse_Period : HAL.UInt8 := 0;
Sigma_Est_Ref_Array : HAL.UInt16 := 0;
Sigma_Est_Eff_Pulso_Width : HAL.UInt16 := 0;
Sigma_Est_Eff_Amb_Width : HAL.UInt16 := 0;
Read_Data_From_Device_Done : Boolean := False;
Module_Id : HAL.UInt8;
Revision : HAL.UInt8;
Reference_SPAD_Count : HAL.UInt8;
Reference_SPAD_Type : HAL.UInt8;
Reference_SPADs_Initialised : Boolean := False;
Part_UID_Upper : HAL.UInt32;
Part_UID_Lower : HAL.UInt32;
end record;
type VL53L0X_Ranging_Sensor (Port : not null HAL.I2C.Any_I2C_Port)
is limited record
-- Default address: can be changed by software
I2C_Address : HAL.I2C.I2C_Address := 16#52#;
Stop_Variable : HAL.UInt8;
end record;
procedure I2C_Write
(This : VL53L0X_Ranging_Sensor;
Data : HAL.UInt8_Array;
Status : out Boolean);
procedure I2C_Read
(This : VL53L0X_Ranging_Sensor;
Data : out HAL.UInt8_Array;
Status : out Boolean);
procedure Write
(This : VL53L0X_Ranging_Sensor;
Index : HAL.UInt8;
Data : HAL.UInt8_Array;
Status : out Boolean);
procedure Write
(This : VL53L0X_Ranging_Sensor;
Index : HAL.UInt8;
Data : HAL.UInt8;
Status : out Boolean);
procedure Write
(This : VL53L0X_Ranging_Sensor;
Index : HAL.UInt8;
Data : HAL.UInt16;
Status : out Boolean);
procedure Write
(This : VL53L0X_Ranging_Sensor;
Index : HAL.UInt8;
Data : HAL.UInt32;
Status : out Boolean);
procedure Read
(This : VL53L0X_Ranging_Sensor;
Index : HAL.UInt8;
Data : out HAL.UInt8_Array;
Status : out Boolean);
procedure Read
(This : VL53L0X_Ranging_Sensor;
Index : HAL.UInt8;
Data : out HAL.UInt8;
Status : out Boolean);
procedure Read
(This : VL53L0X_Ranging_Sensor;
Index : HAL.UInt8;
Data : out HAL.UInt16;
Status : out Boolean);
procedure Read
(This : VL53L0X_Ranging_Sensor;
Index : HAL.UInt8;
Data : out HAL.UInt32;
Status : out Boolean);
function Set_Signal_Rate_Limit
(This : VL53L0X_Ranging_Sensor;
Limit_Mcps : Fix_Point_16_16) return Boolean;
function SPAD_Info
(This : VL53L0X_Ranging_Sensor;
SPAD_Count : out HAL.UInt8;
Is_Aperture : out Boolean) return Boolean;
type VL53L0x_Sequence_Step is
(TCC, DSS, MSRC, Pre_Range, Final_Range);
type VL53L0x_Sequence_Step_Enabled is
array (VL53L0x_Sequence_Step) of Boolean;
type VL53L0x_Sequence_Step_Timeout is
array (VL53L0x_Sequence_Step) of HAL.UInt32;
function Sequence_Step_Enabled
(This : VL53L0X_Ranging_Sensor) return VL53L0x_Sequence_Step_Enabled;
function Sequence_Step_Timeout
(This : VL53L0X_Ranging_Sensor;
Step : VL53L0x_Sequence_Step;
As_Mclks : Boolean := False) return HAL.UInt32;
function VCSel_Pulse_Period
(This : VL53L0X_Ranging_Sensor;
Sequence : VL53L0x_Sequence_Step) return HAL.UInt8;
procedure Set_VCSel_Pulse_Period
(This : VL53L0X_Ranging_Sensor;
Period : HAL.UInt8;
Sequence : VL53L0x_Sequence_Step;
Status : out Boolean);
end VL53L0X;
|
OneWingedShark/Byron | Ada | 298 | ads | Pragma Ada_2012;
Pragma Assertion_Policy( Check );
With
Ada.Containers.Indefinite_Vectors,
Lexington.Aux;
Use Type
Lexington.Aux.Token;
Package Lexington.Token_Vector_Pkg is new Ada.Containers.Indefinite_Vectors(
Index_Type => Positive,
Element_Type => Lexington.Aux.Token
);
|
M1nified/Ada-Samples | Ada | 505 | adb | -- przykłady: pakiet, select w zasdaniu, access do zadania jako parametr wywołania
with Qsort;
with Ada.Text_Io;
use Qsort,Ada.Text_Io;
procedure Qsort_demo is
Arr1 : vector := (1,6,2,67,3);
Arr1_ptr : vector_ptr;
begin
Arr1_ptr := new vector(Arr1'range);
Put_Line(Integer'Image(Arr1'Length));
Put_Line(Integer'Image(Arr1'Length));
Put_Line(Integer'Image(Arr1_ptr'Length));
for i in Arr1'range loop
Arr1_ptr(i) := Arr1(i);
end loop;
Qsort.Sort(Arr1_ptr);
null;
end Qsort_demo;
|
sungyeon/drake | Ada | 191 | ads | pragma License (Unrestricted);
with Ada.Numerics.Long_Complex_Types;
with Ada.Text_IO.Complex_IO;
package Ada.Long_Complex_Text_IO is
new Text_IO.Complex_IO (Numerics.Long_Complex_Types);
|
AdaCore/gpr | Ada | 92 | adb | with GNAT.IO; use GNAT.IO;
procedure main is
begin
Put_Line ("Hello World!");
end main;
|
onox/orka | Ada | 3,506 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2022 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with GL.Blending;
with GL.Buffers;
with GL.Rasterization;
with GL.Types.Colors;
with GL.Viewports;
package Orka.Rendering.States is
pragma Preelaborate;
type Cull_Face_Selector is (None, Front, Back);
type Face is (Front, Back);
----------------------------------------------------------------------------
type Stencil_Operation_Kind is (Stencil_Fail, Depth_Fail, Depth_Pass);
type Stencil_Operations is array (Stencil_Operation_Kind) of GL.Buffers.Stencil_Action;
type Stencil_Test is record
Reference : Orka.Integer_32 := 0;
Test_Func : GL.Types.Compare_Function := GL.Types.Always;
Test_Mask : Orka.Unsigned_32 := 16#FF#;
Write_Mask : Orka.Unsigned_32 := 16#FF#;
Operations : Stencil_Operations := (others => GL.Buffers.Keep);
end record;
type Stencil_Tests is array (Face) of Stencil_Test;
----------------------------------------------------------------------------
type Polygon_Offset_Type is record
Factor, Units, Clamp : Orka.Float_32 := 0.0;
end record;
----------------------------------------------------------------------------
type Color_Masks is array (GL.Buffers.Draw_Buffer_Index) of GL.Types.Colors.Enabled_Color;
type Blending_Functions is array (GL.Buffers.Draw_Buffer_Index) of GL.Blending.Blend_Factors;
type Blending_Equations is array (GL.Buffers.Draw_Buffer_Index) of GL.Blending.Blend_Equations;
use all type GL.Blending.Blend_Factor;
use all type GL.Blending.Equation;
type State is record
Scissor_Box : GL.Viewports.Scissor_Rectangle := (others => 0);
Depth_Clamp : Boolean := False;
Depth_Func : GL.Types.Compare_Function := GL.Types.Greater;
Stenciling : Stencil_Tests;
Minimum_Sample_Shading : GL.Types.Normalized_Single := 0.0;
Cull_Face : Cull_Face_Selector := Back;
-- Do not render triangles in the first place if you want to cull both Front and Back
Polygon_Mode : GL.Rasterization.Polygon_Mode_Type := GL.Rasterization.Fill;
Polygon_Offset : Polygon_Offset_Type;
-- Enabled if any Polygon_Offset.* > 0.0
Color_Mask : Color_Masks := (others => (others => True));
Blending : Boolean := False;
Blend_Functions : Blending_Functions := (others => (One, Zero, One, Zero));
Blend_Equations : Blending_Equations := (others => (Func_Add, Func_Add));
Blend_Color : GL.Types.Colors.Color := (others => 0.0);
Logic_Operation : GL.Blending.Logic_Op := GL.Blending.Copy;
-- Enabled if /= Copy, disables blending when enabled.
-- Has no effect on floating-point buffers.
end record;
-- TODO Sample_Mask, Clip_Distance
procedure Apply_Changes (Previous, Current : State);
end Orka.Rendering.States;
|
stcarrez/ada-awa | Ada | 16,989 | adb | -----------------------------------------------------------------------
-- awa-jobs-services -- Job services
-- Copyright (C) 2012, 2014, 2015, 2016, 2019, 2020, 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Serialize.Tools;
with Util.Log.Loggers;
with Ada.Tags;
with Ada.Calendar;
with ADO.Utils;
with ADO.Statements;
with AWA.Users.Models;
with AWA.Services.Contexts;
with AWA.Jobs.Modules;
with AWA.Applications;
with AWA.Modules;
package body AWA.Jobs.Services is
package ASC renames AWA.Services.Contexts;
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Jobs.Services");
-- ------------------------------
-- Get the job status.
-- ------------------------------
function Get_Job_Status (Id : in ADO.Identifier) return Models.Job_Status_Type is
Ctx : constant ASC.Service_Context_Access := ASC.Current;
DB : constant ADO.Sessions.Session := ASC.Get_Session (Ctx);
Stmt : ADO.Statements.Query_Statement
:= DB.Create_Statement ("SELECT status FROM awa_job WHERE id = ?");
begin
Stmt.Add_Param (Id);
Stmt.Execute;
return Models.Job_Status_Type'Val (Stmt.Get_Result_Integer);
end Get_Job_Status;
-- ------------------------------
-- Set the job parameter identified by the `Name` to the value
-- given in `Value`.
-- ------------------------------
procedure Set_Parameter (Job : in out Abstract_Job_Type;
Name : in String;
Value : in String) is
begin
Job.Set_Parameter (Name, Util.Beans.Objects.To_Object (Value));
end Set_Parameter;
-- ------------------------------
-- Set the job parameter identified by the `Name` to the value
-- given in `Value`.
-- ------------------------------
procedure Set_Parameter (Job : in out Abstract_Job_Type;
Name : in String;
Value : in Integer) is
begin
Job.Set_Parameter (Name, Util.Beans.Objects.To_Object (Value));
end Set_Parameter;
-- ------------------------------
-- Set the job parameter identified by the `Name` to the value
-- given in `Value`.
-- ------------------------------
procedure Set_Parameter (Job : in out Abstract_Job_Type;
Name : in String;
Value : in ADO.Objects.Object_Ref'Class) is
begin
if Value.Is_Null then
Job.Set_Parameter (Name, Util.Beans.Objects.Null_Object);
else
Job.Set_Parameter (Name, ADO.Objects.To_Object (Value.Get_Key));
end if;
end Set_Parameter;
-- ------------------------------
-- Set the job parameter identified by the `Name` to the value
-- given in `Value`.
-- The value object can hold any kind of basic value type
-- (integer, enum, date, strings). If the value represents
-- a bean, the `Invalid_Value` exception is raised.
-- ------------------------------
procedure Set_Parameter (Job : in out Abstract_Job_Type;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
Job.Props.Include (Name, Value);
Job.Props_Modified := True;
end Set_Parameter;
-- ------------------------------
-- Set the job result identified by the `Name` to the value given
-- in `Value`. The value object can hold any kind of basic value
-- type (integer, enum, date, strings). If the value represents a bean,
-- the `Invalid_Value` exception is raised.
-- ------------------------------
procedure Set_Result (Job : in out Abstract_Job_Type;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
Job.Results.Include (Name, Value);
Job.Results_Modified := True;
end Set_Result;
-- ------------------------------
-- Set the job result identified by the `Name` to the value given in `Value`.
-- ------------------------------
procedure Set_Result (Job : in out Abstract_Job_Type;
Name : in String;
Value : in String) is
begin
Job.Set_Result (Name, Util.Beans.Objects.To_Object (Value));
end Set_Result;
-- ------------------------------
-- Get the value identified by the name.
-- If the name cannot be found, the method should return the Null object.
-- ------------------------------
overriding
function Get_Value (Job : in Abstract_Job_Type;
Name : in String) return Util.Beans.Objects.Object is
begin
return Job.Get_Parameter (Name);
end Get_Value;
-- ------------------------------
-- Get the job parameter identified by the `Name` and convert
-- the value into a string.
-- ------------------------------
function Get_Parameter (Job : in Abstract_Job_Type;
Name : in String) return String is
Value : constant Util.Beans.Objects.Object := Job.Get_Parameter (Name);
begin
return Util.Beans.Objects.To_String (Value);
end Get_Parameter;
-- ------------------------------
-- Get the job parameter identified by the `Name` and convert
-- the value as an integer. If the parameter is not defined,
-- return the default value passed in `Default`.
-- ------------------------------
function Get_Parameter (Job : in Abstract_Job_Type;
Name : in String;
Default : in Integer) return Integer is
Pos : constant Util.Beans.Objects.Maps.Cursor := Job.Props.Find (Name);
begin
if Util.Beans.Objects.Maps.Has_Element (Pos) then
declare
Value : constant Util.Beans.Objects.Object := Util.Beans.Objects.Maps.Element (Pos);
begin
if Util.Beans.Objects.Is_Null (Value) then
return Default;
else
return Util.Beans.Objects.To_Integer (Value);
end if;
end;
else
return Default;
end if;
end Get_Parameter;
-- ------------------------------
-- Get the job parameter identified by the `Name` and convert
-- the value as a database identifier. If the parameter is not defined,
-- return the `ADO.NO_IDENTIFIER`.
-- ------------------------------
function Get_Parameter (Job : in Abstract_Job_Type;
Name : in String) return ADO.Identifier is
Pos : constant Util.Beans.Objects.Maps.Cursor := Job.Props.Find (Name);
begin
if Util.Beans.Objects.Maps.Has_Element (Pos) then
declare
Value : constant Util.Beans.Objects.Object := Util.Beans.Objects.Maps.Element (Pos);
begin
if Util.Beans.Objects.Is_Null (Value) then
return ADO.NO_IDENTIFIER;
else
return ADO.Utils.To_Identifier (Value);
end if;
end;
else
return ADO.NO_IDENTIFIER;
end if;
end Get_Parameter;
-- ------------------------------
-- Get the job parameter identified by the `Name` and return it as
-- a typed object.
-- ------------------------------
function Get_Parameter (Job : in Abstract_Job_Type;
Name : in String) return Util.Beans.Objects.Object is
begin
return Job.Props.Element (Name);
end Get_Parameter;
-- ------------------------------
-- Get the job status.
-- ------------------------------
function Get_Status (Job : in Abstract_Job_Type) return Models.Job_Status_Type is
begin
return Job.Job.Get_Status;
end Get_Status;
-- ------------------------------
-- Get the job identifier once the job was scheduled.
-- The job identifier allows to retrieve the job and check its
-- execution and completion status later on.
-- ------------------------------
function Get_Identifier (Job : in Abstract_Job_Type) return ADO.Identifier is
begin
return Job.Job.Get_Id;
end Get_Identifier;
-- ------------------------------
-- Set the job status. When the job is terminated, it is closed
-- and the job parameters or results cannot be changed.
-- ------------------------------
procedure Set_Status (Job : in out Abstract_Job_Type;
Status : in AWA.Jobs.Models.Job_Status_Type) is
begin
case Job.Job.Get_Status is
when AWA.Jobs.Models.CANCELED | Models.FAILED | Models.TERMINATED =>
Log.Info ("Job {0} is closed", ADO.Identifier'Image (Job.Job.Get_Id));
raise Closed_Error;
when Models.SCHEDULED | Models.RUNNING =>
Job.Job.Set_Status (Status);
end case;
end Set_Status;
-- ------------------------------
-- Save the job information in the database. Use the database session
-- defined by `DB` to save the job.
-- ------------------------------
procedure Save (Job : in out Abstract_Job_Type;
DB : in out ADO.Sessions.Master_Session'Class) is
begin
if Job.Props_Modified then
Job.Job.Set_Parameters (Util.Serialize.Tools.To_JSON (Job.Props));
Job.Props_Modified := False;
end if;
if Job.Results_Modified then
Job.Job.Set_Results (Util.Serialize.Tools.To_JSON (Job.Results));
Job.Results_Modified := False;
end if;
Job.Job.Save (DB);
end Save;
-- ------------------------------
-- Schedule the job.
-- ------------------------------
procedure Schedule (Job : in out Abstract_Job_Type;
Definition : in Job_Factory'Class) is
Ctx : constant ASC.Service_Context_Access := ASC.Current;
DB : ADO.Sessions.Master_Session := ASC.Get_Master_Session (Ctx);
User : constant AWA.Users.Models.User_Ref := Ctx.Get_User;
Sess : constant AWA.Users.Models.Session_Ref := Ctx.Get_User_Session;
App : constant AWA.Applications.Application_Access := Ctx.Get_Application;
Msg : AWA.Events.Module_Event;
begin
if Job.Job.Is_Inserted then
Log.Error ("Job is already scheduled");
raise Schedule_Error with "The job is already scheduled.";
end if;
Job.Job.Set_Create_Date (Ada.Calendar.Clock);
DB.Begin_Transaction;
Job.Job.Set_Name (Definition.Get_Name);
Job.Job.Set_User (User);
Job.Job.Set_Session (Sess);
Job.Save (DB);
-- Create the event
Msg.Set_Parameters (Job.Props);
Msg.Set_Entity (Job.Job, DB);
Msg.Set_Event_Kind (Job_Create_Event.Kind);
App.Send_Event (Msg);
DB.Commit;
end Schedule;
-- ------------------------------
-- Execute the job and save the job information in the database.
-- ------------------------------
procedure Execute (Job : in out Abstract_Job_Type'Class;
DB : in out ADO.Sessions.Master_Session'Class) is
use type AWA.Jobs.Models.Job_Status_Type;
begin
-- Execute the job with an exception guard.
Log.Info ("Execute job {0}", String '(Job.Job.Get_Name));
begin
Job.Execute;
exception
when E : others =>
Log.Error ("Exception when executing job {0}", Job.Job.Get_Name);
Log.Error ("Exception:", E, True);
Job.Job.Set_Status (Models.FAILED);
end;
-- If the job did not set a completion status, mark it as terminated.
if Job.Job.Get_Status in Models.SCHEDULED | Models.RUNNING then
Job.Job.Set_Status (Models.TERMINATED);
end if;
-- And save the job.
DB.Begin_Transaction;
Job.Job.Set_Finish_Date (ADO.Nullable_Time '(Is_Null => False,
Value => Ada.Calendar.Clock));
Job.Save (DB);
DB.Commit;
end Execute;
-- ------------------------------
-- Execute the job associated with the given event.
-- ------------------------------
procedure Execute (Event : in AWA.Events.Module_Event'Class;
Result : in out Job_Ref) is
use AWA.Jobs.Modules;
use type AWA.Modules.Module_Access;
Ctx : constant ASC.Service_Context_Access := ASC.Current;
App : constant AWA.Applications.Application_Access := Ctx.Get_Application;
Module : constant AWA.Modules.Module_Access := App.Find_Module (AWA.Jobs.Modules.NAME);
DB : ADO.Sessions.Master_Session := ASC.Get_Master_Session (Ctx);
Job : AWA.Jobs.Models.Job_Ref;
Id : constant ADO.Identifier := Event.Get_Entity_Identifier;
begin
if Module = null then
Log.Warn ("There is no Job module to execute a job");
raise Execute_Error;
end if;
if not (Module.all in AWA.Jobs.Modules.Job_Module'Class) then
Log.Warn ("The 'job' module is not a valid module for job execution");
raise Execute_Error;
end if;
DB.Begin_Transaction;
Job.Load (Session => DB,
Id => Id);
Job.Set_Start_Date (ADO.Nullable_Time '(Is_Null => False,
Value => Ada.Calendar.Clock));
Job.Set_Status (AWA.Jobs.Models.RUNNING);
Job.Save (Session => DB);
DB.Commit;
declare
Name : constant String := Job.Get_Name;
Ident : constant String := ADO.Identifier'Image (Id);
begin
Log.Info ("Restoring job {0} - '{1}'", Ident, Name);
declare
Plugin : constant Job_Module_Access := Job_Module'Class (Module.all)'Access;
Factory : constant Job_Factory_Access := Plugin.Find_Factory (Name);
Work : AWA.Jobs.Services.Abstract_Job_Type_Access := null;
begin
if Factory /= null then
Work := Factory.Create;
Work.Job := Job;
Event.Copy (Work.Props);
Result := Job_Ref '(Job_Refs.Create (Work) with null record);
Work.Execute (DB);
else
Log.Error ("There is no factory to execute job {0} - '{1}'",
Ident, Name);
Job.Set_Status (AWA.Jobs.Models.FAILED);
Job.Set_Finish_Date (ADO.Nullable_Time '(Is_Null => False,
Value => Ada.Calendar.Clock));
DB.Begin_Transaction;
Job.Save (Session => DB);
DB.Commit;
end if;
end;
end;
end Execute;
-- ------------------------------
-- Get the job parameter identified by the `Name` and return it as
-- a typed object. Return the `Null_Object` if the job is empty
-- or there is no such parameter.
-- ------------------------------
function Get_Parameter (Job : in Job_Ref;
Name : in String) return Util.Beans.Objects.Object is
begin
if Job.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Job.Value.Get_Parameter (Name);
end if;
end Get_Parameter;
-- ------------------------------
-- Get the job factory name.
-- ------------------------------
function Get_Name (Factory : in Job_Factory'Class) return String is
begin
return Ada.Tags.Expanded_Name (Factory'Tag);
end Get_Name;
overriding
procedure Execute (Job : in out Job_Type) is
begin
Job.Work (Job);
end Execute;
-- ------------------------------
-- Create the job instance to execute the associated `Work_Access` procedure.
-- ------------------------------
overriding
function Create (Factory : in Work_Factory) return Abstract_Job_Type_Access is
begin
return new Job_Type '(Util.Refs.Ref_Entity with
Work => Factory.Work,
others => <>);
end Create;
-- ------------------------------
-- Job Declaration
-- ------------------------------
package body Definition is
overriding
function Create (Factory : in Job_Type_Factory) return Abstract_Job_Type_Access is
pragma Unreferenced (Factory);
begin
return new T;
end Create;
end Definition;
end AWA.Jobs.Services;
|
1Crazymoney/LearnAda | Ada | 723 | ads | package hauntedhouse is
-- W: Wall, R: Room, C: Corridor, E: Exit
type Fields is (W,R,C,E);
type Position is record
x: Natural;
y: Natural;
end record;
function IsWall(pos: Position) return Boolean;
function IsCorrect(pos: Position) return Boolean;
function IsCorridor(pos: Position) return Boolean;
function GetField(pos:Position) return Fields;
function GetRandPos return Position;
private
type field_array is array(Natural range <>,Natural range <>) of Fields;
House: constant field_array(1..5,1..5):= ((C,C,C,W,R),
(R,W,C,W,C),
(W,C,C,R,R),
(C,R,W,W,R),
(R,C,E,C,C));
end hauntedhouse;
|
stcarrez/ada-awa | Ada | 1,035 | ads | -----------------------------------------------------------------------
-- awa-countries -- Country module
-- Copyright (C) 2013 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
-- == Introduction ==
-- The <b>Countries</b> module defines a database model to represent countries and regions.
--
package AWA.Countries is
pragma Preelaborate;
end AWA.Countries;
|
AdaCore/Ada_Drivers_Library | Ada | 12,109 | ads | -- Copyright (c) 2013, Nordic Semiconductor ASA
-- 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 Nordic Semiconductor ASA nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--
-- This spec has been automatically generated from nrf51.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package NRF_SVD.AAR is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Enable interrupt on END event.
type INTENSET_END_Field is
(-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENSET_END_Field use
(Disabled => 0,
Enabled => 1);
-- Enable interrupt on END event.
type INTENSET_END_Field_1 is
(-- Reset value for the field
Intenset_End_Field_Reset,
-- Enable interrupt on write.
Set)
with Size => 1;
for INTENSET_END_Field_1 use
(Intenset_End_Field_Reset => 0,
Set => 1);
-- Enable interrupt on RESOLVED event.
type INTENSET_RESOLVED_Field is
(-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENSET_RESOLVED_Field use
(Disabled => 0,
Enabled => 1);
-- Enable interrupt on RESOLVED event.
type INTENSET_RESOLVED_Field_1 is
(-- Reset value for the field
Intenset_Resolved_Field_Reset,
-- Enable interrupt on write.
Set)
with Size => 1;
for INTENSET_RESOLVED_Field_1 use
(Intenset_Resolved_Field_Reset => 0,
Set => 1);
-- Enable interrupt on NOTRESOLVED event.
type INTENSET_NOTRESOLVED_Field is
(-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENSET_NOTRESOLVED_Field use
(Disabled => 0,
Enabled => 1);
-- Enable interrupt on NOTRESOLVED event.
type INTENSET_NOTRESOLVED_Field_1 is
(-- Reset value for the field
Intenset_Notresolved_Field_Reset,
-- Enable interrupt on write.
Set)
with Size => 1;
for INTENSET_NOTRESOLVED_Field_1 use
(Intenset_Notresolved_Field_Reset => 0,
Set => 1);
-- Interrupt enable set register.
type INTENSET_Register is record
-- Enable interrupt on END event.
END_k : INTENSET_END_Field_1 := Intenset_End_Field_Reset;
-- Enable interrupt on RESOLVED event.
RESOLVED : INTENSET_RESOLVED_Field_1 :=
Intenset_Resolved_Field_Reset;
-- Enable interrupt on NOTRESOLVED event.
NOTRESOLVED : INTENSET_NOTRESOLVED_Field_1 :=
Intenset_Notresolved_Field_Reset;
-- unspecified
Reserved_3_31 : HAL.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTENSET_Register use record
END_k at 0 range 0 .. 0;
RESOLVED at 0 range 1 .. 1;
NOTRESOLVED at 0 range 2 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
-- Disable interrupt on ENDKSGEN event.
type INTENCLR_END_Field is
(-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENCLR_END_Field use
(Disabled => 0,
Enabled => 1);
-- Disable interrupt on ENDKSGEN event.
type INTENCLR_END_Field_1 is
(-- Reset value for the field
Intenclr_End_Field_Reset,
-- Disable interrupt on write.
Clear)
with Size => 1;
for INTENCLR_END_Field_1 use
(Intenclr_End_Field_Reset => 0,
Clear => 1);
-- Disable interrupt on RESOLVED event.
type INTENCLR_RESOLVED_Field is
(-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENCLR_RESOLVED_Field use
(Disabled => 0,
Enabled => 1);
-- Disable interrupt on RESOLVED event.
type INTENCLR_RESOLVED_Field_1 is
(-- Reset value for the field
Intenclr_Resolved_Field_Reset,
-- Disable interrupt on write.
Clear)
with Size => 1;
for INTENCLR_RESOLVED_Field_1 use
(Intenclr_Resolved_Field_Reset => 0,
Clear => 1);
-- Disable interrupt on NOTRESOLVED event.
type INTENCLR_NOTRESOLVED_Field is
(-- Interrupt disabled.
Disabled,
-- Interrupt enabled.
Enabled)
with Size => 1;
for INTENCLR_NOTRESOLVED_Field use
(Disabled => 0,
Enabled => 1);
-- Disable interrupt on NOTRESOLVED event.
type INTENCLR_NOTRESOLVED_Field_1 is
(-- Reset value for the field
Intenclr_Notresolved_Field_Reset,
-- Disable interrupt on write.
Clear)
with Size => 1;
for INTENCLR_NOTRESOLVED_Field_1 use
(Intenclr_Notresolved_Field_Reset => 0,
Clear => 1);
-- Interrupt enable clear register.
type INTENCLR_Register is record
-- Disable interrupt on ENDKSGEN event.
END_k : INTENCLR_END_Field_1 := Intenclr_End_Field_Reset;
-- Disable interrupt on RESOLVED event.
RESOLVED : INTENCLR_RESOLVED_Field_1 :=
Intenclr_Resolved_Field_Reset;
-- Disable interrupt on NOTRESOLVED event.
NOTRESOLVED : INTENCLR_NOTRESOLVED_Field_1 :=
Intenclr_Notresolved_Field_Reset;
-- unspecified
Reserved_3_31 : HAL.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for INTENCLR_Register use record
END_k at 0 range 0 .. 0;
RESOLVED at 0 range 1 .. 1;
NOTRESOLVED at 0 range 2 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
subtype STATUS_STATUS_Field is HAL.UInt4;
-- Resolution status.
type STATUS_Register is record
-- Read-only. The IRK used last time an address was resolved.
STATUS : STATUS_STATUS_Field;
-- unspecified
Reserved_4_31 : HAL.UInt28;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for STATUS_Register use record
STATUS at 0 range 0 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
-- Enable AAR.
type ENABLE_ENABLE_Field is
(-- Disabled AAR.
Disabled,
-- Enable AAR.
Enabled)
with Size => 2;
for ENABLE_ENABLE_Field use
(Disabled => 0,
Enabled => 3);
-- Enable AAR.
type ENABLE_Register is record
-- Enable AAR.
ENABLE : ENABLE_ENABLE_Field := NRF_SVD.AAR.Disabled;
-- unspecified
Reserved_2_31 : HAL.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ENABLE_Register use record
ENABLE at 0 range 0 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
subtype NIRK_NIRK_Field is HAL.UInt5;
-- Number of Identity root Keys in the IRK data structure.
type NIRK_Register is record
-- Number of Identity root Keys in the IRK data structure.
NIRK : NIRK_NIRK_Field := 16#1#;
-- unspecified
Reserved_5_31 : HAL.UInt27 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for NIRK_Register use record
NIRK at 0 range 0 .. 4;
Reserved_5_31 at 0 range 5 .. 31;
end record;
-- Peripheral power control.
type POWER_POWER_Field is
(-- Module power disabled.
Disabled,
-- Module power enabled.
Enabled)
with Size => 1;
for POWER_POWER_Field use
(Disabled => 0,
Enabled => 1);
-- Peripheral power control.
type POWER_Register is record
-- Peripheral power control.
POWER : POWER_POWER_Field := NRF_SVD.AAR.Disabled;
-- unspecified
Reserved_1_31 : HAL.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for POWER_Register use record
POWER at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Accelerated Address Resolver.
type AAR_Peripheral is record
-- Start resolving addresses based on IRKs specified in the IRK data
-- structure.
TASKS_START : aliased HAL.UInt32;
-- Stop resolving addresses.
TASKS_STOP : aliased HAL.UInt32;
-- Address resolution procedure completed.
EVENTS_END : aliased HAL.UInt32;
-- Address resolved.
EVENTS_RESOLVED : aliased HAL.UInt32;
-- Address not resolved.
EVENTS_NOTRESOLVED : aliased HAL.UInt32;
-- Interrupt enable set register.
INTENSET : aliased INTENSET_Register;
-- Interrupt enable clear register.
INTENCLR : aliased INTENCLR_Register;
-- Resolution status.
STATUS : aliased STATUS_Register;
-- Enable AAR.
ENABLE : aliased ENABLE_Register;
-- Number of Identity root Keys in the IRK data structure.
NIRK : aliased NIRK_Register;
-- Pointer to the IRK data structure.
IRKPTR : aliased HAL.UInt32;
-- Pointer to the resolvable address (6 bytes).
ADDRPTR : aliased HAL.UInt32;
-- Pointer to a "scratch" data area used for temporary storage during
-- resolution. A minimum of 3 bytes must be reserved.
SCRATCHPTR : aliased HAL.UInt32;
-- Peripheral power control.
POWER : aliased POWER_Register;
end record
with Volatile;
for AAR_Peripheral use record
TASKS_START at 16#0# range 0 .. 31;
TASKS_STOP at 16#8# range 0 .. 31;
EVENTS_END at 16#100# range 0 .. 31;
EVENTS_RESOLVED at 16#104# range 0 .. 31;
EVENTS_NOTRESOLVED at 16#108# range 0 .. 31;
INTENSET at 16#304# range 0 .. 31;
INTENCLR at 16#308# range 0 .. 31;
STATUS at 16#400# range 0 .. 31;
ENABLE at 16#500# range 0 .. 31;
NIRK at 16#504# range 0 .. 31;
IRKPTR at 16#508# range 0 .. 31;
ADDRPTR at 16#510# range 0 .. 31;
SCRATCHPTR at 16#514# range 0 .. 31;
POWER at 16#FFC# range 0 .. 31;
end record;
-- Accelerated Address Resolver.
AAR_Periph : aliased AAR_Peripheral
with Import, Address => AAR_Base;
end NRF_SVD.AAR;
|
MEDiCODEDEV/coinapi-sdk | Ada | 4,642 | adb | -- OMS _ REST API
-- OMS Project
--
-- The version of the OpenAPI document: v1
--
--
-- NOTE: This package is auto generated by OpenAPI-Generator 4.3.1.
-- https://openapi-generator.tech
-- Do not edit the class manually.
with Swagger.Streams;
package body .Clients is
-- Get balances
-- Returns all of your balances, including available balance.
procedure V1_Balances_Get
(Client : in out Client_Type;
Exchange_Id : in Swagger.Nullable_UString;
Result : out .Models.Balance_Type_Vectors.Vector) is
URI : Swagger.Clients.URI_Type;
Reply : Swagger.Value_Type;
begin
Client.Set_Accept ((1 => Swagger.Clients.APPLICATION_JSON));
URI.Add_Param ("exchange_id", Exchange_Id);
URI.Set_Path ("/v1/balances");
Client.Call (Swagger.Clients.GET, URI, Reply);
.Models.Deserialize (Reply, "", Result);
end V1_Balances_Get;
-- Cancel all order
-- Cancel all existing order.
procedure V1_Orders_Cancel_All_Post
(Client : in out Client_Type;
Cancel_All_Order_Type : in .Models.CancelAllOrder_Type;
Result : out .Models.MessagesOk_Type) is
URI : Swagger.Clients.URI_Type;
Req : Swagger.Clients.Request_Type;
Reply : Swagger.Value_Type;
begin
Client.Set_Accept ((1 => Swagger.Clients.APPLICATION_JSON));
Client.Initialize (Req, (1 => Swagger.Clients.APPLICATION_JSON));
.Models.Serialize (Req.Stream, "", Cancel_All_Order_Type);
URI.Set_Path ("/v1/orders/cancel/all");
Client.Call (Swagger.Clients.POST, URI, Req, Reply);
.Models.Deserialize (Reply, "", Result);
end V1_Orders_Cancel_All_Post;
-- Cancel order
-- Cancel an existing order, can be used to cancel margin, exchange, and derivative orders. You can cancel the order by the internal order ID or exchange order ID.
procedure V1_Orders_Cancel_Post
(Client : in out Client_Type;
Cancel_Order_Type : in .Models.CancelOrder_Type;
Result : out .Models.OrderLive_Type) is
URI : Swagger.Clients.URI_Type;
Req : Swagger.Clients.Request_Type;
Reply : Swagger.Value_Type;
begin
Client.Set_Accept ((Swagger.Clients.APPLICATION_JSON,
Swagger.Clients.APPLICTION_JSON));
Client.Initialize (Req, (1 => Swagger.Clients.APPLICATION_JSON));
.Models.Serialize (Req.Stream, "", Cancel_Order_Type);
URI.Set_Path ("/v1/orders/cancel");
Client.Call (Swagger.Clients.POST, URI, Req, Reply);
.Models.Deserialize (Reply, "", Result);
end V1_Orders_Cancel_Post;
-- Get orders
-- List your current open orders.
procedure V1_Orders_Get
(Client : in out Client_Type;
Exchange_Id : in Swagger.Nullable_UString;
Result : out .Models.Order_Type_Vectors.Vector) is
URI : Swagger.Clients.URI_Type;
Reply : Swagger.Value_Type;
begin
Client.Set_Accept ((1 => Swagger.Clients.APPLICATION_JSON));
URI.Add_Param ("exchange_id", Exchange_Id);
URI.Set_Path ("/v1/orders");
Client.Call (Swagger.Clients.GET, URI, Reply);
.Models.Deserialize (Reply, "", Result);
end V1_Orders_Get;
-- Create new order
-- You can place two types of orders: limit and market. Orders can only be placed if your account has sufficient funds.
procedure V1_Orders_Post
(Client : in out Client_Type;
New_Order_Type : in .Models.NewOrder_Type;
Result : out .Models.OrderLive_Type) is
URI : Swagger.Clients.URI_Type;
Req : Swagger.Clients.Request_Type;
Reply : Swagger.Value_Type;
begin
Client.Set_Accept ((Swagger.Clients.APPLICATION_JSON,
Swagger.Clients.APPLICTION_JSON));
Client.Initialize (Req, (1 => Swagger.Clients.APPLICATION_JSON));
.Models.Serialize (Req.Stream, "", New_Order_Type);
URI.Set_Path ("/v1/orders");
Client.Call (Swagger.Clients.POST, URI, Req, Reply);
.Models.Deserialize (Reply, "", Result);
end V1_Orders_Post;
-- Get positions
-- Returns all of your positions.
procedure V1_Positions_Get
(Client : in out Client_Type;
Exchange_Id : in Swagger.Nullable_UString;
Result : out .Models.Position_Type_Vectors.Vector) is
URI : Swagger.Clients.URI_Type;
Reply : Swagger.Value_Type;
begin
Client.Set_Accept ((1 => Swagger.Clients.APPLICATION_JSON));
URI.Add_Param ("exchange_id", Exchange_Id);
URI.Set_Path ("/v1/positions");
Client.Call (Swagger.Clients.GET, URI, Reply);
.Models.Deserialize (Reply, "", Result);
end V1_Positions_Get;
end .Clients;
|
coopht/axmpp | Ada | 4,248 | adb | ------------------------------------------------------------------------------
-- --
-- AXMPP Project --
-- --
-- XMPP Library for Ada --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2016, Alexander Basov <[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 Alexander Basov, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package body XMPP.Null_Objects is
----------------
-- Set_Kind --
----------------
overriding
function Get_Kind (Self : XMPP_Null_Object) return XMPP.Object_Kind is
pragma Unreferenced (Self);
begin
return XMPP.Null_Object;
end Get_Kind;
-----------------
-- Serialize --
-----------------
overriding procedure Serialize
(Self : XMPP_Null_Object;
Writer : in out XML.SAX.Pretty_Writers.XML_Pretty_Writer'Class)
is
pragma Unreferenced (Self);
pragma Unreferenced (Writer);
begin
raise Program_Error with "Cannot serialize Null Object";
end Serialize;
-------------------
-- Set_Content --
-------------------
overriding
procedure Set_Content (Self : in out XMPP_Null_Object;
Parameter : League.Strings.Universal_String;
Value : League.Strings.Universal_String)
is
begin
raise Program_Error with "Unable to set content for XMPP_Null_Object";
end Set_Content;
end XMPP.Null_Objects;
|
reznikmm/matreshka | Ada | 135 | ads | package Parser is
procedure build_eof_action;
procedure yyerror(msg: string);
procedure YYParse;
def_rule:integer;
end Parser;
|
faelys/natools | Ada | 8,556 | adb | ------------------------------------------------------------------------------
-- Copyright (c) 2015-2017, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with Natools.S_Expressions.Caches;
with Natools.S_Expressions.Test_Tools;
package body Natools.S_Expressions.Conditionals.Strings.Tests is
procedure Check
(Test : in out NT.Test;
Context : in Strings.Context;
Expression : in Caches.Reference;
Image : in String;
Expected : in Boolean := True);
procedure Check
(Test : in out NT.Test;
Value : in String;
Expression : in Caches.Reference;
Image : in String;
Expected : in Boolean := True);
------------------------------
-- Local Helper Subprograms --
------------------------------
procedure Check
(Test : in out NT.Test;
Context : in Strings.Context;
Expression : in Caches.Reference;
Image : in String;
Expected : in Boolean := True)
is
function Match_Image return String;
Cursor : Caches.Cursor := Expression.First;
function Match_Image return String is
begin
if Expected then
return " does not match ";
else
return " does match ";
end if;
end Match_Image;
begin
if Evaluate (Context, Cursor) /= Expected then
Test.Fail ('"' & Context.Data.all & '"' & Match_Image & Image);
end if;
end Check;
procedure Check
(Test : in out NT.Test;
Value : in String;
Expression : in Caches.Reference;
Image : in String;
Expected : in Boolean := True)
is
function Match_Image return String;
Cursor : Caches.Cursor := Expression.First;
function Match_Image return String is
begin
if Expected then
return " does not match ";
else
return " does match ";
end if;
end Match_Image;
begin
if Evaluate (Value, Cursor) /= Expected then
Test.Fail ('"' & Value & '"' & Match_Image & Image);
end if;
end Check;
-------------------------
-- Complete Test Suite --
-------------------------
procedure All_Tests (Report : in out NT.Reporter'Class) is
begin
Basic_Usage (Report);
Fallbacks (Report);
end All_Tests;
----------------------
-- Individual Tests --
----------------------
procedure Basic_Usage (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Basic usage");
begin
declare
procedure Check (Value : in String; Expected : in Boolean := True);
Image : constant String := "Expression 1";
Exp : constant Caches.Reference := Test_Tools.To_S_Expression
("(or is-empty (starts-with Hi)"
& "(is BY) (case-insensitive (is HELLO))"
& "(and (contains 1:.) (contains-any-of 1:! 1:?))"
& "(case-insensitive (or (contains aLiCe)"
& " (case-sensitive (contains Bob))))"
& "(not is-ascii))");
procedure Check (Value : in String; Expected : in Boolean := True) is
begin
Check (Test, Value, Exp, Image, Expected);
end Check;
begin
Check ("");
Check ("A", False);
Check ("Hi, my name is John.");
Check ("Hello, my name is John.", False);
Check ("Hello. My name is John!");
Check ("Hello. My name is John?");
Check ("Alice and Bob");
Check ("BOBBY!", False);
Check ("AlicE and Malory");
Check ("©");
Check ("BY");
Check ("By", False);
Check ("Hello");
Check ("Hell", False);
end;
exception
when Error : others => Test.Report_Exception (Error);
end Basic_Usage;
procedure Fallbacks (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Fallback functions");
begin
declare
procedure Check
(Value : in String;
With_Fallback : in Boolean);
procedure Check_Counts
(Expected_Parametric, Expected_Simple : in Natural);
function Parametric_Fallback
(Settings : in Strings.Settings;
Name : in Atom;
Arguments : in out Lockable.Descriptor'Class)
return Boolean;
function Simple_Fallback
(Settings : in Strings.Settings;
Name : in Atom)
return Boolean;
Parametric_Count : Natural := 0;
Simple_Count : Natural := 0;
Exp : constant Caches.Reference := Test_Tools.To_S_Expression
("(or"
& "(and (starts-with a) non-existant)"
& "(does-not-exist ohai ()))");
procedure Check
(Value : in String;
With_Fallback : in Boolean)
is
Copy : aliased constant String := Value;
Context : Strings.Context
(Data => Copy'Access,
Parametric_Fallback => (if With_Fallback
then Parametric_Fallback'Access
else null),
Simple_Fallback => (if With_Fallback
then Simple_Fallback'Access
else null));
begin
Context.Settings.Case_Sensitive := False;
begin
Check (Test, Context, Exp, "Fallback expression");
if not With_Fallback then
Test.Fail ("Exception expected from """ & Value & '"');
end if;
exception
when Constraint_Error =>
if With_Fallback then
raise;
end if;
end;
end Check;
procedure Check_Counts
(Expected_Parametric, Expected_Simple : in Natural) is
begin
if Parametric_Count /= Expected_Parametric then
Test.Fail ("Parametric_Count is"
& Natural'Image (Parametric_Count) & ", expected"
& Natural'Image (Expected_Parametric));
end if;
if Simple_Count /= Expected_Simple then
Test.Fail ("Simple_Count is"
& Natural'Image (Simple_Count) & ", expected"
& Natural'Image (Expected_Simple));
end if;
end Check_Counts;
function Parametric_Fallback
(Settings : in Strings.Settings;
Name : in Atom;
Arguments : in out Lockable.Descriptor'Class)
return Boolean
is
pragma Unreferenced (Settings, Arguments);
begin
Parametric_Count := Parametric_Count + 1;
return To_String (Name) = "does-not-exist";
end Parametric_Fallback;
function Simple_Fallback
(Settings : in Strings.Settings;
Name : in Atom)
return Boolean
is
pragma Unreferenced (Settings);
begin
Simple_Count := Simple_Count + 1;
return To_String (Name) = "non-existant";
end Simple_Fallback;
begin
Check ("Oook?", False);
Check ("Alice", False);
Check ("Alpha", True);
Check_Counts (0, 1);
Check ("Bob", True);
Check_Counts (1, 1);
end;
exception
when Error : others => Test.Report_Exception (Error);
end Fallbacks;
end Natools.S_Expressions.Conditionals.Strings.Tests;
|
persan/A-gst | Ada | 30,880 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
pragma Warnings (Off);
with Interfaces.C; use Interfaces.C;
with glib;
with glib;
with glib.Values;
with System;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttaglist_h;
-- limited with GStreamer.GST_Low_Level.glib_2_0_glib_glist_h;
limited with GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h;
with GLIB; -- with GStreamer.GST_Low_Level.glibconfig_h;
with System;
package GStreamer.GST_Low_Level.gstreamer_0_10_gst_tag_tag_h is
GST_TAG_MUSICBRAINZ_TRACKID : aliased constant String := "musicbrainz-trackid" & ASCII.NUL; -- gst/tag/tag.h:36
GST_TAG_MUSICBRAINZ_ARTISTID : aliased constant String := "musicbrainz-artistid" & ASCII.NUL; -- gst/tag/tag.h:42
GST_TAG_MUSICBRAINZ_ALBUMID : aliased constant String := "musicbrainz-albumid" & ASCII.NUL; -- gst/tag/tag.h:48
GST_TAG_MUSICBRAINZ_ALBUMARTISTID : aliased constant String := "musicbrainz-albumartistid" & ASCII.NUL; -- gst/tag/tag.h:54
GST_TAG_MUSICBRAINZ_TRMID : aliased constant String := "musicbrainz-trmid" & ASCII.NUL; -- gst/tag/tag.h:60
-- unsupported macro: GST_TAG_MUSICBRAINZ_SORTNAME GST_TAG_ARTIST_SORTNAME
GST_TAG_CMML_STREAM : aliased constant String := "cmml-stream" & ASCII.NUL; -- gst/tag/tag.h:79
GST_TAG_CMML_HEAD : aliased constant String := "cmml-head" & ASCII.NUL; -- gst/tag/tag.h:86
GST_TAG_CMML_CLIP : aliased constant String := "cmml-clip" & ASCII.NUL; -- gst/tag/tag.h:92
GST_TAG_CDDA_CDDB_DISCID : aliased constant String := "discid" & ASCII.NUL; -- gst/tag/tag.h:101
GST_TAG_CDDA_CDDB_DISCID_FULL : aliased constant String := "discid-full" & ASCII.NUL; -- gst/tag/tag.h:108
GST_TAG_CDDA_MUSICBRAINZ_DISCID : aliased constant String := "musicbrainz-discid" & ASCII.NUL; -- gst/tag/tag.h:115
GST_TAG_CDDA_MUSICBRAINZ_DISCID_FULL : aliased constant String := "musicbrainz-discid-full" & ASCII.NUL; -- gst/tag/tag.h:122
GST_TAG_CAPTURING_SHUTTER_SPEED : aliased constant String := "capturing-shutter-speed" & ASCII.NUL; -- gst/tag/tag.h:131
GST_TAG_CAPTURING_FOCAL_RATIO : aliased constant String := "capturing-focal-ratio" & ASCII.NUL; -- gst/tag/tag.h:143
GST_TAG_CAPTURING_FOCAL_LENGTH : aliased constant String := "capturing-focal-length" & ASCII.NUL; -- gst/tag/tag.h:152
GST_TAG_CAPTURING_DIGITAL_ZOOM_RATIO : aliased constant String := "capturing-digital-zoom-ratio" & ASCII.NUL; -- gst/tag/tag.h:161
GST_TAG_CAPTURING_ISO_SPEED : aliased constant String := "capturing-iso-speed" & ASCII.NUL; -- gst/tag/tag.h:170
GST_TAG_CAPTURING_EXPOSURE_PROGRAM : aliased constant String := "capturing-exposure-program" & ASCII.NUL; -- gst/tag/tag.h:190
GST_TAG_CAPTURING_EXPOSURE_MODE : aliased constant String := "capturing-exposure-mode" & ASCII.NUL; -- gst/tag/tag.h:204
GST_TAG_CAPTURING_EXPOSURE_COMPENSATION : aliased constant String := "capturing-exposure-compensation" & ASCII.NUL; -- gst/tag/tag.h:213
GST_TAG_CAPTURING_SCENE_CAPTURE_TYPE : aliased constant String := "capturing-scene-capture-type" & ASCII.NUL; -- gst/tag/tag.h:228
GST_TAG_CAPTURING_GAIN_ADJUSTMENT : aliased constant String := "capturing-gain-adjustment" & ASCII.NUL; -- gst/tag/tag.h:244
GST_TAG_CAPTURING_WHITE_BALANCE : aliased constant String := "capturing-white-balance" & ASCII.NUL; -- gst/tag/tag.h:263
GST_TAG_CAPTURING_CONTRAST : aliased constant String := "capturing-contrast" & ASCII.NUL; -- gst/tag/tag.h:277
GST_TAG_CAPTURING_SATURATION : aliased constant String := "capturing-saturation" & ASCII.NUL; -- gst/tag/tag.h:291
GST_TAG_CAPTURING_SHARPNESS : aliased constant String := "capturing-sharpness" & ASCII.NUL; -- gst/tag/tag.h:305
GST_TAG_CAPTURING_FLASH_FIRED : aliased constant String := "capturing-flash-fired" & ASCII.NUL; -- gst/tag/tag.h:317
GST_TAG_CAPTURING_FLASH_MODE : aliased constant String := "capturing-flash-mode" & ASCII.NUL; -- gst/tag/tag.h:331
GST_TAG_CAPTURING_METERING_MODE : aliased constant String := "capturing-metering-mode" & ASCII.NUL; -- gst/tag/tag.h:350
GST_TAG_CAPTURING_SOURCE : aliased constant String := "capturing-source" & ASCII.NUL; -- gst/tag/tag.h:366
GST_TAG_IMAGE_HORIZONTAL_PPI : aliased constant String := "image-horizontal-ppi" & ASCII.NUL; -- gst/tag/tag.h:375
GST_TAG_IMAGE_VERTICAL_PPI : aliased constant String := "image-vertical-ppi" & ASCII.NUL; -- gst/tag/tag.h:383
-- unsupported macro: GST_TYPE_TAG_IMAGE_TYPE (gst_tag_image_type_get_type ())
GST_TAG_ID3V2_HEADER_SIZE : constant := 10; -- gst/tag/tag.h:453
-- arg-macro: procedure gst_tag_get_language_code (lang_code)
-- gst_tag_get_language_code_iso_639_1(lang_code)
-- GStreamer
-- * Copyright (C) 2003 Benjamin Otte <[email protected]>
-- * Copyright (C) 2006-2011 Tim-Philipp Müller <tim centricular net>
-- *
-- * 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.
--
-- Tag names
--*
-- * GST_TAG_MUSICBRAINZ_TRACKID
-- *
-- * MusicBrainz track ID
--
--*
-- * GST_TAG_MUSICBRAINZ_ARTISTID
-- *
-- * MusicBrainz artist ID
--
--*
-- * GST_TAG_MUSICBRAINZ_ALBUMID
-- *
-- * MusicBrainz album ID
--
--*
-- * GST_TAG_MUSICBRAINZ_ALBUMARTISTID
-- *
-- * MusicBrainz album artist ID
--
--*
-- * GST_TAG_MUSICBRAINZ_TRMID
-- *
-- * MusicBrainz track TRM ID
--
-- FIXME 0.11: remove GST_TAG_MUSICBRAINZ_SORTNAME
--*
-- * GST_TAG_MUSICBRAINZ_SORTNAME
-- *
-- * MusicBrainz artist sort name
-- *
-- * Deprecated. Use GST_TAG_ARTIST_SORTNAME instead.
--
--*
-- * GST_TAG_CMML_STREAM
-- *
-- * Annodex CMML stream element tag
--
--*
-- * GST_TAG_CMML_HEAD
-- *
-- * Annodex CMML head element tag
--
--*
-- * GST_TAG_CMML_CLIP
-- *
-- * Annodex CMML clip element tag
--
-- CDDA tags
--*
-- * GST_TAG_CDDA_CDDB_DISCID:
-- *
-- * CDDB disc id in its short form (e.g. 'aa063d0f')
--
--*
-- * GST_TAG_CDDA_CDDB_DISCID_FULL:
-- *
-- * CDDB disc id including all details
--
--*
-- * GST_TAG_CDDA_MUSICBRAINZ_DISCID:
-- *
-- * Musicbrainz disc id (e.g. 'ahg7JUcfR3vCYBphSDIogOOWrr0-')
--
--*
-- * GST_TAG_CDDA_MUSICBRAINZ_DISCID_FULL:
-- *
-- * Musicbrainz disc id details
--
--*
-- * GST_TAG_CAPTURING_SHUTTER_SPEED:
-- *
-- * Shutter speed used when capturing an image, in seconds. (fraction)
-- *
-- * Since: 0.10.31
--
--*
-- * GST_TAG_CAPTURING_FOCAL_RATIO:
-- *
-- * Focal ratio (f-number) used when capturing an image. (double)
-- *
-- * The value stored is the denominator of the focal ratio (f-number).
-- * For example, if this tag value is 2, the focal ratio is f/2.
-- *
-- * Since: 0.10.31
--
--*
-- * GST_TAG_CAPTURING_FOCAL_LENGTH:
-- *
-- * Focal length used when capturing an image, in mm. (double)
-- *
-- * Since: 0.10.31
--
--*
-- * GST_TAG_CAPTURING_DIGITAL_ZOOM_RATIO:
-- *
-- * Digital zoom ratio used when capturing an image. (double)
-- *
-- * Since: 0.10.31
--
--*
-- * GST_TAG_CAPTURING_ISO_SPEED:
-- *
-- * ISO speed used when capturing an image. (integer)
-- *
-- * Since: 0.10.31
--
--*
-- * GST_TAG_CAPTURING_EXPOSURE_PROGRAM:
-- *
-- * Type of exposure control used when capturing an image. (string)
-- *
-- * The allowed values are:
-- * "undefined"
-- * "manual"
-- * "normal" - automatically controlled
-- * "aperture-priority" - user selects aperture value
-- * "shutter-priority" - user selects shutter speed
-- * "creative" - biased towards depth of field
-- * "action" - biased towards fast shutter speed
-- * "portrait" - closeup, leaving background out of focus
-- * "landscape" - landscape photos, background in focus
-- *
-- * Since: 0.10.31
--
--*
-- * GST_TAG_CAPTURING_EXPOSURE_MODE:
-- *
-- * Exposure mode used when capturing an image. (string)
-- *
-- * The allowed values are:
-- * "auto-exposure"
-- * "manual-exposure"
-- * "auto-bracket"
-- *
-- * Since: 0.10.31
--
--*
-- * GST_TAG_CAPTURING_EXPOSURE_COMPENSATION:
-- *
-- * Exposure compensation using when capturing an image in EV. (double)
-- *
-- * Since: 0.10.33
--
--*
-- * GST_TAG_CAPTURING_SCENE_CAPTURE_TYPE:
-- *
-- * Scene mode used when capturing an image. (string)
-- *
-- * The allowed values are:
-- * "standard"
-- * "landscape"
-- * "portrait"
-- * "night-scene"
-- *
-- * Since: 0.10.31
--
--*
-- * GST_TAG_CAPTURING_GAIN_ADJUSTMENT:
-- *
-- * Gain adjustment applied to an image. (string)
-- *
-- * The allowed values are:
-- * "none"
-- * "low-gain-up"
-- * "high-gain-up"
-- * "low-gain-down"
-- * "high-gain-down"
-- *
-- * Since: 0.10.31
--
--*
-- * GST_TAG_CAPTURING_WHITE_BALANCE:
-- *
-- * White balance mode used when capturing an image. (string)
-- *
-- * The allowed values are:
-- * "auto"
-- * "manual"
-- * "daylight"
-- * "cloudy"
-- * "tungsten"
-- * "fluorescent"
-- * "fluorescent h" (newer daylight-calibrated fluorescents)
-- * "flash"
-- *
-- * Since: 0.10.31
--
--*
-- * GST_TAG_CAPTURING_CONTRAST:
-- *
-- * Direction of contrast processing applied when capturing an image. (string)
-- *
-- * The allowed values are:
-- * "normal"
-- * "soft"
-- * "hard"
-- *
-- * Since: 0.10.31
--
--*
-- * GST_TAG_CAPTURING_SATURATION:
-- *
-- * Direction of saturation processing applied when capturing an image. (string)
-- *
-- * The allowed values are:
-- * "normal"
-- * "low-saturation"
-- * "high-saturation"
-- *
-- * Since: 0.10.31
--
--*
-- * GST_TAG_CAPTURING_SHARPNESS:
-- *
-- * Direction of sharpness processing applied when capturing an image. (string)
-- *
-- * The allowed values are:
-- * "normal"
-- * "soft"
-- * "hard"
-- *
-- * Since: 0.10.31
--
--*
-- * GST_TAG_CAPTURING_FLASH_FIRED:
-- *
-- * If flash was fired during the capture of an image. (boolean)
-- *
-- * Note that if this tag isn't present, it should not be assumed that
-- * the flash did not fire. It should be treated as unknown.
-- *
-- * Since: 0.10.31
--
--*
-- * GST_TAG_CAPTURING_FLASH_MODE:
-- *
-- * The flash mode selected during the capture of an image. (string)
-- *
-- * The allowed values are:
-- * "auto"
-- * "always"
-- * "never"
-- *
-- * Since: 0.10.31
--
--*
-- * GST_TAG_CAPTURING_METERING_MODE:
-- *
-- * Defines the way a camera determines the exposure. (string)
-- *
-- * The allowed values are:
-- * "unknown"
-- * "average"
-- * "center-weighted-average"
-- * "spot"
-- * "multi-spot"
-- * "pattern"
-- * "partial"
-- * "other"
-- *
-- * Since: 0.10.31
--
--*
-- * GST_TAG_CAPTURING_SOURCE:
-- *
-- * Indicates the source of capture. The device/medium used to do the
-- * capture. (string)
-- *
-- * Allowed values are:
-- * "dsc" (= digital still camera)
-- * "transparent-scanner"
-- * "reflex-scanner"
-- * "other"
-- *
-- * Since: 0.10.31
--
--*
-- * GST_TAG_IMAGE_HORIZONTAL_PPI:
-- *
-- * Media (image/video) intended horizontal pixel density in ppi. (double)
-- *
-- * Since: 0.10.31
--
--*
-- * GST_TAG_IMAGE_VERTICAL_PPI:
-- *
-- * Media (image/video) intended vertical pixel density in ppi. (double)
-- *
-- * Since: 0.10.31
--
-- additional information for image tags
--*
-- * GstTagImageType:
-- * @GST_TAG_IMAGE_TYPE_NONE : No image type. Can be used to
-- * tell functions such as gst_tag_image_data_to_image_buffer() that no
-- * image type should be set. (Since: 0.10.20)
-- * @GST_TAG_IMAGE_TYPE_UNDEFINED : Undefined/other image type
-- * @GST_TAG_IMAGE_TYPE_FRONT_COVER : Cover (front)
-- * @GST_TAG_IMAGE_TYPE_BACK_COVER : Cover (back)
-- * @GST_TAG_IMAGE_TYPE_LEAFLET_PAGE : Leaflet page
-- * @GST_TAG_IMAGE_TYPE_MEDIUM : Medium (e.g. label side of CD)
-- * @GST_TAG_IMAGE_TYPE_LEAD_ARTIST : Lead artist/lead performer/soloist
-- * @GST_TAG_IMAGE_TYPE_ARTIST : Artist/performer
-- * @GST_TAG_IMAGE_TYPE_CONDUCTOR : Conductor
-- * @GST_TAG_IMAGE_TYPE_BAND_ORCHESTRA : Band/orchestra
-- * @GST_TAG_IMAGE_TYPE_COMPOSER : Composer
-- * @GST_TAG_IMAGE_TYPE_LYRICIST : Lyricist/text writer
-- * @GST_TAG_IMAGE_TYPE_RECORDING_LOCATION : Recording location
-- * @GST_TAG_IMAGE_TYPE_DURING_RECORDING : During recording
-- * @GST_TAG_IMAGE_TYPE_DURING_PERFORMANCE : During performance
-- * @GST_TAG_IMAGE_TYPE_VIDEO_CAPTURE : Movie/video screen capture
-- * @GST_TAG_IMAGE_TYPE_FISH : A fish as funny as the ID3v2 spec
-- * @GST_TAG_IMAGE_TYPE_ILLUSTRATION : Illustration
-- * @GST_TAG_IMAGE_TYPE_BAND_ARTIST_LOGO : Band/artist logotype
-- * @GST_TAG_IMAGE_TYPE_PUBLISHER_STUDIO_LOGO : Publisher/studio logotype
-- *
-- * Type of image contained in an image tag (specified as field in
-- * the image buffer's caps structure)
-- *
-- * Since: 0.10.9
--
-- Note: keep in sync with register_tag_image_type_enum()
subtype GstTagImageType is int;
GST_TAG_IMAGE_TYPE_NONE : constant GstTagImageType := -1;
GST_TAG_IMAGE_TYPE_UNDEFINED : constant GstTagImageType := 0;
GST_TAG_IMAGE_TYPE_FRONT_COVER : constant GstTagImageType := 1;
GST_TAG_IMAGE_TYPE_BACK_COVER : constant GstTagImageType := 2;
GST_TAG_IMAGE_TYPE_LEAFLET_PAGE : constant GstTagImageType := 3;
GST_TAG_IMAGE_TYPE_MEDIUM : constant GstTagImageType := 4;
GST_TAG_IMAGE_TYPE_LEAD_ARTIST : constant GstTagImageType := 5;
GST_TAG_IMAGE_TYPE_ARTIST : constant GstTagImageType := 6;
GST_TAG_IMAGE_TYPE_CONDUCTOR : constant GstTagImageType := 7;
GST_TAG_IMAGE_TYPE_BAND_ORCHESTRA : constant GstTagImageType := 8;
GST_TAG_IMAGE_TYPE_COMPOSER : constant GstTagImageType := 9;
GST_TAG_IMAGE_TYPE_LYRICIST : constant GstTagImageType := 10;
GST_TAG_IMAGE_TYPE_RECORDING_LOCATION : constant GstTagImageType := 11;
GST_TAG_IMAGE_TYPE_DURING_RECORDING : constant GstTagImageType := 12;
GST_TAG_IMAGE_TYPE_DURING_PERFORMANCE : constant GstTagImageType := 13;
GST_TAG_IMAGE_TYPE_VIDEO_CAPTURE : constant GstTagImageType := 14;
GST_TAG_IMAGE_TYPE_FISH : constant GstTagImageType := 15;
GST_TAG_IMAGE_TYPE_ILLUSTRATION : constant GstTagImageType := 16;
GST_TAG_IMAGE_TYPE_BAND_ARTIST_LOGO : constant GstTagImageType := 17;
GST_TAG_IMAGE_TYPE_PUBLISHER_STUDIO_LOGO : constant GstTagImageType := 18; -- gst/tag/tag.h:440
function gst_tag_image_type_get_type return GLIB.GType; -- gst/tag/tag.h:443
pragma Import (C, gst_tag_image_type_get_type, "gst_tag_image_type_get_type");
--*
-- * GST_TAG_ID3V2_HEADER_SIZE:
-- *
-- * ID3V2 header size considered minimum input for some functions such as
-- * gst_tag_list_from_id3v2_tag() and gst_tag_get_id3v2_tag_size() for example.
-- *
-- * Since: 0.10.36
--
-- functions for vorbis comment manipulation
function gst_tag_from_vorbis_tag (vorbis_tag : access GLIB.gchar) return access GLIB.gchar; -- gst/tag/tag.h:457
pragma Import (C, gst_tag_from_vorbis_tag, "gst_tag_from_vorbis_tag");
function gst_tag_to_vorbis_tag (gst_tag : access GLIB.gchar) return access GLIB.gchar; -- gst/tag/tag.h:458
pragma Import (C, gst_tag_to_vorbis_tag, "gst_tag_to_vorbis_tag");
procedure gst_vorbis_tag_add
(list : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttaglist_h.GstTagList;
tag : access GLIB.gchar;
value : access GLIB.gchar); -- gst/tag/tag.h:459
pragma Import (C, gst_vorbis_tag_add, "gst_vorbis_tag_add");
function gst_tag_to_vorbis_comments (list : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttaglist_h.GstTagList; tag : access GLIB.gchar) return access GStreamer.GST_Low_Level.glib_2_0_glib_glist_h.GList; -- gst/tag/tag.h:463
pragma Import (C, gst_tag_to_vorbis_comments, "gst_tag_to_vorbis_comments");
-- functions to convert GstBuffers with vorbiscomment contents to GstTagLists and back
function gst_tag_list_from_vorbiscomment_buffer
(buffer : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
id_data : access GLIB.guint8;
id_data_length : GLIB.guint;
vendor_string : System.Address) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttaglist_h.GstTagList; -- gst/tag/tag.h:467
pragma Import (C, gst_tag_list_from_vorbiscomment_buffer, "gst_tag_list_from_vorbiscomment_buffer");
function gst_tag_list_to_vorbiscomment_buffer
(list : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttaglist_h.GstTagList;
id_data : access GLIB.guint8;
id_data_length : GLIB.guint;
vendor_string : access GLIB.gchar) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; -- gst/tag/tag.h:471
pragma Import (C, gst_tag_list_to_vorbiscomment_buffer, "gst_tag_list_to_vorbiscomment_buffer");
-- functions for ID3 tag manipulation
-- FIXME 0.11: inconsistent API naming: gst_tag_list_new_from_id3v1(), gst_tag_list_from_*_buffer(),
-- * gst_tag_list_from_id3v2_tag(). Also, note gst.tag.list_xyz() namespace vs. gst.tag_list_xyz(),
-- * which is a bit confusing and possibly doesn't map too well
function gst_tag_id3_genre_count return GLIB.guint; -- gst/tag/tag.h:482
pragma Import (C, gst_tag_id3_genre_count, "gst_tag_id3_genre_count");
function gst_tag_id3_genre_get (id : GLIB.guint) return access GLIB.gchar; -- gst/tag/tag.h:483
pragma Import (C, gst_tag_id3_genre_get, "gst_tag_id3_genre_get");
function gst_tag_list_new_from_id3v1 (data : access GLIB.guint8) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttaglist_h.GstTagList; -- gst/tag/tag.h:484
pragma Import (C, gst_tag_list_new_from_id3v1, "gst_tag_list_new_from_id3v1");
function gst_tag_from_id3_tag (id3_tag : access GLIB.gchar) return access GLIB.gchar; -- gst/tag/tag.h:486
pragma Import (C, gst_tag_from_id3_tag, "gst_tag_from_id3_tag");
function gst_tag_from_id3_user_tag (c_type : access GLIB.gchar; id3_user_tag : access GLIB.gchar) return access GLIB.gchar; -- gst/tag/tag.h:487
pragma Import (C, gst_tag_from_id3_user_tag, "gst_tag_from_id3_user_tag");
function gst_tag_to_id3_tag (gst_tag : access GLIB.gchar) return access GLIB.gchar; -- gst/tag/tag.h:489
pragma Import (C, gst_tag_to_id3_tag, "gst_tag_to_id3_tag");
function gst_tag_list_add_id3_image
(tag_list : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttaglist_h.GstTagList;
image_data : access GLIB.guint8;
image_data_len : GLIB.guint;
id3_picture_type : GLIB.guint) return GLIB.gboolean; -- gst/tag/tag.h:491
pragma Import (C, gst_tag_list_add_id3_image, "gst_tag_list_add_id3_image");
function gst_tag_list_from_id3v2_tag (buffer : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttaglist_h.GstTagList; -- gst/tag/tag.h:496
pragma Import (C, gst_tag_list_from_id3v2_tag, "gst_tag_list_from_id3v2_tag");
function gst_tag_get_id3v2_tag_size (buffer : access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer) return GLIB.guint; -- gst/tag/tag.h:498
pragma Import (C, gst_tag_get_id3v2_tag_size, "gst_tag_get_id3v2_tag_size");
-- functions to convert GstBuffers with xmp packets contents to GstTagLists and back
function gst_tag_list_from_xmp_buffer (buffer : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttaglist_h.GstTagList; -- gst/tag/tag.h:501
pragma Import (C, gst_tag_list_from_xmp_buffer, "gst_tag_list_from_xmp_buffer");
function gst_tag_list_to_xmp_buffer (list : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttaglist_h.GstTagList; read_only : GLIB.gboolean) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; -- gst/tag/tag.h:502
pragma Import (C, gst_tag_list_to_xmp_buffer, "gst_tag_list_to_xmp_buffer");
function gst_tag_list_to_xmp_buffer_full
(list : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttaglist_h.GstTagList;
read_only : GLIB.gboolean;
schemas : System.Address) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; -- gst/tag/tag.h:504
pragma Import (C, gst_tag_list_to_xmp_buffer_full, "gst_tag_list_to_xmp_buffer_full");
function gst_tag_xmp_list_schemas return System.Address; -- gst/tag/tag.h:506
pragma Import (C, gst_tag_xmp_list_schemas, "gst_tag_xmp_list_schemas");
-- functions related to exif
function gst_tag_list_to_exif_buffer
(taglist : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttaglist_h.GstTagList;
byte_order : GLIB.gint;
base_offset : GLIB.guint32) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; -- gst/tag/tag.h:509
pragma Import (C, gst_tag_list_to_exif_buffer, "gst_tag_list_to_exif_buffer");
function gst_tag_list_to_exif_buffer_with_tiff_header (taglist : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttaglist_h.GstTagList) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; -- gst/tag/tag.h:513
pragma Import (C, gst_tag_list_to_exif_buffer_with_tiff_header, "gst_tag_list_to_exif_buffer_with_tiff_header");
function gst_tag_list_from_exif_buffer
(buffer : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer;
byte_order : GLIB.gint;
base_offset : GLIB.guint32) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttaglist_h.GstTagList; -- gst/tag/tag.h:515
pragma Import (C, gst_tag_list_from_exif_buffer, "gst_tag_list_from_exif_buffer");
function gst_tag_list_from_exif_buffer_with_tiff_header (buffer : access constant GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gsttaglist_h.GstTagList; -- gst/tag/tag.h:519
pragma Import (C, gst_tag_list_from_exif_buffer_with_tiff_header, "gst_tag_list_from_exif_buffer_with_tiff_header");
-- other tag-related functions
function gst_tag_parse_extended_comment
(ext_comment : access GLIB.gchar;
key : System.Address;
lang : System.Address;
value : System.Address;
fail_if_no_key : GLIB.gboolean) return GLIB.gboolean; -- gst/tag/tag.h:524
pragma Import (C, gst_tag_parse_extended_comment, "gst_tag_parse_extended_comment");
function gst_tag_freeform_string_to_utf8
(data : access GLIB.gchar;
size : GLIB.gint;
env_vars : System.Address) return access GLIB.gchar; -- gst/tag/tag.h:530
pragma Import (C, gst_tag_freeform_string_to_utf8, "gst_tag_freeform_string_to_utf8");
function gst_tag_image_data_to_image_buffer
(image_data : access GLIB.guint8;
image_data_len : GLIB.guint;
image_type : GstTagImageType) return access GStreamer.GST_Low_Level.gstreamer_0_10_gst_gstbuffer_h.GstBuffer; -- gst/tag/tag.h:534
pragma Import (C, gst_tag_image_data_to_image_buffer, "gst_tag_image_data_to_image_buffer");
-- FIXME 0.11: get rid of this awkward register/init function, see tags.c
procedure gst_tag_register_musicbrainz_tags; -- gst/tag/tag.h:539
pragma Import (C, gst_tag_register_musicbrainz_tags, "gst_tag_register_musicbrainz_tags");
-- language tag related functions
function gst_tag_get_language_codes return System.Address; -- gst/tag/tag.h:544
pragma Import (C, gst_tag_get_language_codes, "gst_tag_get_language_codes");
function gst_tag_get_language_name (language_code : access GLIB.gchar) return access GLIB.gchar; -- gst/tag/tag.h:546
pragma Import (C, gst_tag_get_language_name, "gst_tag_get_language_name");
function gst_tag_get_language_code_iso_639_1 (lang_code : access GLIB.gchar) return access GLIB.gchar; -- gst/tag/tag.h:548
pragma Import (C, gst_tag_get_language_code_iso_639_1, "gst_tag_get_language_code_iso_639_1");
function gst_tag_get_language_code_iso_639_2B (lang_code : access GLIB.gchar) return access GLIB.gchar; -- gst/tag/tag.h:550
pragma Import (C, gst_tag_get_language_code_iso_639_2B, "gst_tag_get_language_code_iso_639_2B");
function gst_tag_get_language_code_iso_639_2T (lang_code : access GLIB.gchar) return access GLIB.gchar; -- gst/tag/tag.h:552
pragma Import (C, gst_tag_get_language_code_iso_639_2T, "gst_tag_get_language_code_iso_639_2T");
--*
-- * gst_tag_get_language_code:
-- * @lang_code: ISO-639 language code (e.g. "deu" or "ger" or "de")
-- *
-- * Convenience macro wrapping gst_tag_get_language_code_iso_639_1().
-- *
-- * Since: 0.10.26
--
-- functions to deal with (mostly) Creative Commons licenses
--*
-- * GstTagLicenseFlags:
-- * @GST_TAG_LICENSE_PERMITS_REPRODUCTION: making multiple copies
-- * is allowed
-- * @GST_TAG_LICENSE_PERMITS_DISTRIBUTION: distribution, public display
-- * and public performance are allowed
-- * @GST_TAG_LICENSE_PERMITS_DERIVATIVE_WORKS: distribution of derivative
-- * works is allowed
-- * @GST_TAG_LICENSE_PERMITS_SHARING: commercial derivatives are allowed,
-- * but only non-commercial distribution is allowed
-- * @GST_TAG_LICENSE_REQUIRES_NOTICE: copyright and license notices
-- * must be kept intact
-- * @GST_TAG_LICENSE_REQUIRES_ATTRIBUTION: credit must be given to
-- * copyright holder and/or author
-- * @GST_TAG_LICENSE_REQUIRES_SHARE_ALIKE: derivative works must be
-- * licensed under the same terms or compatible terms as the original work
-- * @GST_TAG_LICENSE_REQUIRES_SOURCE_CODE: source code (the preferred
-- * form for making modifications) must be provided when exercising some
-- * rights granted by the license
-- * @GST_TAG_LICENSE_REQUIRES_COPYLEFT: derivative and combined works
-- * must be licensed under specified terms, similar to those of the original
-- * work
-- * @GST_TAG_LICENSE_REQUIRES_LESSER_COPYLEFT: derivative works must be
-- * licensed under specified terms, with at least the same conditions as
-- * the original work; combinations with the work may be licensed under
-- * different terms
-- * @GST_TAG_LICENSE_PROHIBITS_COMMERCIAL_USE: exercising rights for
-- * commercial purposes is prohibited
-- * @GST_TAG_LICENSE_PROHIBITS_HIGH_INCOME_NATION_USE: use in a
-- * non-developing country is prohibited
-- * @GST_TAG_LICENSE_CREATIVE_COMMONS_LICENSE: this license was created
-- * by the Creative Commons project
-- * @GST_TAG_LICENSE_FREE_SOFTWARE_FOUNDATION_LICENSE: this license was
-- * created by the Free Software Foundation (FSF)
-- *
-- * See http://creativecommons.org/ns for more information.
-- *
-- * Since: 0.10.36
--
subtype GstTagLicenseFlags is unsigned;
GST_TAG_LICENSE_PERMITS_REPRODUCTION : constant GstTagLicenseFlags := 1;
GST_TAG_LICENSE_PERMITS_DISTRIBUTION : constant GstTagLicenseFlags := 2;
GST_TAG_LICENSE_PERMITS_DERIVATIVE_WORKS : constant GstTagLicenseFlags := 4;
GST_TAG_LICENSE_PERMITS_SHARING : constant GstTagLicenseFlags := 8;
GST_TAG_LICENSE_REQUIRES_NOTICE : constant GstTagLicenseFlags := 256;
GST_TAG_LICENSE_REQUIRES_ATTRIBUTION : constant GstTagLicenseFlags := 512;
GST_TAG_LICENSE_REQUIRES_SHARE_ALIKE : constant GstTagLicenseFlags := 1024;
GST_TAG_LICENSE_REQUIRES_SOURCE_CODE : constant GstTagLicenseFlags := 2048;
GST_TAG_LICENSE_REQUIRES_COPYLEFT : constant GstTagLicenseFlags := 4096;
GST_TAG_LICENSE_REQUIRES_LESSER_COPYLEFT : constant GstTagLicenseFlags := 8192;
GST_TAG_LICENSE_PROHIBITS_COMMERCIAL_USE : constant GstTagLicenseFlags := 65536;
GST_TAG_LICENSE_PROHIBITS_HIGH_INCOME_NATION_USE : constant GstTagLicenseFlags := 131072;
GST_TAG_LICENSE_CREATIVE_COMMONS_LICENSE : constant GstTagLicenseFlags := 16777216;
GST_TAG_LICENSE_FREE_SOFTWARE_FOUNDATION_LICENSE : constant GstTagLicenseFlags := 33554432; -- gst/tag/tag.h:625
function gst_tag_get_licenses return System.Address; -- gst/tag/tag.h:627
pragma Import (C, gst_tag_get_licenses, "gst_tag_get_licenses");
function gst_tag_get_license_flags (license_ref : access GLIB.gchar) return GstTagLicenseFlags; -- gst/tag/tag.h:629
pragma Import (C, gst_tag_get_license_flags, "gst_tag_get_license_flags");
function gst_tag_get_license_nick (license_ref : access GLIB.gchar) return access GLIB.gchar; -- gst/tag/tag.h:631
pragma Import (C, gst_tag_get_license_nick, "gst_tag_get_license_nick");
function gst_tag_get_license_title (license_ref : access GLIB.gchar) return access GLIB.gchar; -- gst/tag/tag.h:633
pragma Import (C, gst_tag_get_license_title, "gst_tag_get_license_title");
function gst_tag_get_license_version (license_ref : access GLIB.gchar) return access GLIB.gchar; -- gst/tag/tag.h:635
pragma Import (C, gst_tag_get_license_version, "gst_tag_get_license_version");
function gst_tag_get_license_description (license_ref : access GLIB.gchar) return access GLIB.gchar; -- gst/tag/tag.h:637
pragma Import (C, gst_tag_get_license_description, "gst_tag_get_license_description");
function gst_tag_get_license_jurisdiction (license_ref : access GLIB.gchar) return access GLIB.gchar; -- gst/tag/tag.h:639
pragma Import (C, gst_tag_get_license_jurisdiction, "gst_tag_get_license_jurisdiction");
function gst_tag_license_flags_get_type return GLIB.GType; -- gst/tag/tag.h:641
pragma Import (C, gst_tag_license_flags_get_type, "gst_tag_license_flags_get_type");
end GStreamer.GST_Low_Level.gstreamer_0_10_gst_tag_tag_h;
|
gitter-badger/libAnne | Ada | 1,718 | ads | with Ada.Execution_Time, Ada.Real_Time, Ada.Strings.Wide_Wide_Unbounded;
use Ada.Execution_Time, Ada.Real_Time, Ada.Strings.Wide_Wide_Unbounded;
package Testing.Timers is
-----------
-- Timer --
-----------
type Timer is abstract tagged limited private; --Represents an abstract timer
function Running(Self : in Timer'Class) return Boolean with Inline, Pure_Function;
function Run_Time(Self : in Timer) return Duration is abstract;
procedure Start(Self : in out Timer; Name : in Wide_Wide_String) is abstract;
procedure Stop(Self : in out Timer) is abstract;
----------------
-- Real Timer --
----------------
type Real_Timer is new Timer with private; --Represents a timer for Real_Time
overriding function Run_Time(Self : in Real_Timer) return Duration with Inline, Pure_Function;
overriding procedure Start(Self : in out Real_Timer; Name : in Wide_Wide_String);
overriding procedure Stop(Self : in out Real_Timer);
---------------------
-- Execution Timer --
---------------------
type Execution_Timer is new Timer with private; --Represents a timer for Execution_Time
overriding function Run_Time(Self : in Execution_Timer) return Duration with Inline, Pure_Function;
overriding procedure Start(Self : in out Execution_Timer; Name : in Wide_Wide_String);
overriding procedure Stop(Self : in out Execution_Timer);
private
type Timer is abstract tagged limited record
Running : Boolean := False;
Name : Unbounded_Wide_Wide_String;
end record;
type Real_Timer is new Timer with record
Start_Time : Time;
Stop_Time : Time;
end record;
type Execution_Timer is new Timer with record
Start_Time : CPU_Time;
Stop_Time : CPU_Time;
end record;
end Testing.Timers; |
riccardo-bernardini/eugen | Ada | 3,704 | ads | with DOM.Core;
with Ada.Finalization;
package XML_Scanners is
--
-- As well knnown, an XML document is a tree. An XML_Scanner is
-- an object associated to a tree of the node that allows to
-- iterate over the node children. At every time there is a
-- "current child." The function Scan returns the current child
-- and "consumes" it.
--
type XML_Scanner (<>) is
new Ada.Finalization.Limited_Controlled
with
private;
function Create_Child_Scanner (Parent : DOM.Core.Node) return XML_Scanner;
-- Return true if all the children have been used
function No_More_Children (Scanner : XML_Scanner) return Boolean;
-- Return the number of children still to be used
function Remaining_Children (Scanner : XML_Scanner) return Natural;
-- Return the current node, but do not consume it
function Peek_Node (Scanner : XML_Scanner) return DOM.Core.Node;
-- Raise Unexpected_Node unless the current node has the given name.
-- Do not consume the node.
procedure Expect (Scanner : XML_Scanner; Name : String);
-- Raise Unexpected_Node unless all the children have been used.
procedure Expect_End_Of_Children (Scanner : XML_Scanner);
--
-- Expect that current node has the specified name and it is a
-- "pure text" node, that is, a node whose only children is text.
-- If everything is OK, it consumes the node and returns the node content,
-- otherwise raises Unexpected_Node.
--
function Parse_Text_Node (Scanner : XML_Scanner;
Name : String)
return String;
No_Limit : constant Natural;
--
-- Expect a sequence of nodes with the given name. For every node
-- calls the given callback. Unexpected_Node is raised if the
-- number of nodes is not within the specified limits
--
procedure Parse_Sequence
(Scanner : in out XML_Scanner;
Name : in String;
Callback : not null access procedure (N : DOM.Core.Node);
Min_Length : in Natural := 1;
Max_Length : in Natural := No_Limit);
-- Like Parse_Sequence with min=0, max=1
procedure Parse_Optional
(Scanner : in out XML_Scanner;
Name : in String;
Callback : not null access procedure (N : DOM.Core.Node));
-- Like Parse_Sequence with min=max=1
procedure Parse_Single_Node
(Scanner : in out XML_Scanner;
Name : in String;
Callback : not null access procedure (N : DOM.Core.Node));
No_Name : constant String;
function Peek_Name (Scanner : XML_Scanner)
return String;
function Scan (Scanner : XML_Scanner)
return DOM.Core.Node;
Unexpected_Node : exception;
type Abstract_Node_Processor is interface;
procedure Process (Processor : in out Abstract_Node_Processor;
Node : in DOM.Core.Node)
is abstract;
procedure Process_Sequence
(Scanner : in out XML_Scanner;
Name : in String;
Processor : in out Abstract_Node_Processor'Class;
Min_Length : in Natural := 1;
Max_Length : in Natural := No_Limit);
private
No_Name : constant String := "";
No_Limit : constant Natural := Natural'Last;
type XML_Scanner_Data is
record
Nodes : DOM.Core.Node_List;
Cursor : Natural;
end record;
type XML_Scanner_Data_Access is access XML_Scanner_Data;
type XML_Scanner is
new Ada.Finalization.Limited_Controlled with
record
Acc : XML_Scanner_Data_Access;
end record;
overriding
procedure Finalize (Object : in out XML_Scanner);
end XML_Scanners;
|
RREE/ada-util | Ada | 4,401 | adb | -----------------------------------------------------------------------
-- Util.Beans.Objects.Enums -- Helper conversion for discrete types
-- Copyright (C) 2010, 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.Characters.Conversions;
package body Util.Beans.Objects.Enums is
use Ada.Characters.Conversions;
Value_Range : constant Long_Long_Integer := T'Pos (T'Last) - T'Pos (T'First) + 1;
-- ------------------------------
-- Integer Type
-- ------------------------------
type Enum_Type is new Int_Type with null record;
-- Get the type name
overriding
function Get_Name (Type_Def : in Enum_Type) return String;
overriding
function To_String (Type_Def : in Enum_Type;
Value : in Object_Value) return String;
-- ------------------------------
-- Get the type name
-- ------------------------------
overriding
function Get_Name (Type_Def : Enum_Type) return String is
pragma Unreferenced (Type_Def);
begin
return "Enum";
end Get_Name;
-- ------------------------------
-- Convert the value into a string.
-- ------------------------------
overriding
function To_String (Type_Def : in Enum_Type;
Value : in Object_Value) return String is
pragma Unreferenced (Type_Def);
begin
return T'Image (T'Val (Value.Int_Value));
end To_String;
Value_Type : aliased constant Enum_Type := Enum_Type '(null record);
-- ------------------------------
-- Create an object from the given value.
-- ------------------------------
function To_Object (Value : in T) return Object is
begin
return Object '(Controlled with
V => Object_Value '(Of_Type => TYPE_INTEGER,
Int_Value => Long_Long_Integer (T'Pos (Value))),
Type_Def => Value_Type'Access);
end To_Object;
-- ------------------------------
-- Convert the object into a value.
-- Raises Constraint_Error if the object cannot be converter to the target type.
-- ------------------------------
function To_Value (Value : in Util.Beans.Objects.Object) return T is
begin
case Value.V.Of_Type is
when TYPE_INTEGER =>
if ROUND_VALUE then
return T'Val (Value.V.Int_Value mod Value_Range);
else
return T'Val (Value.V.Int_Value);
end if;
when TYPE_BOOLEAN =>
return T'Val (Boolean'Pos (Value.V.Bool_Value));
when TYPE_FLOAT =>
if ROUND_VALUE then
return T'Val (To_Long_Long_Integer (Value) mod Value_Range);
else
return T'Val (To_Long_Long_Integer (Value));
end if;
when TYPE_STRING =>
if Value.V.String_Proxy = null then
raise Constraint_Error with "The object value is null";
end if;
return T'Value (Value.V.String_Proxy.Value);
when TYPE_WIDE_STRING =>
if Value.V.Wide_Proxy = null then
raise Constraint_Error with "The object value is null";
end if;
return T'Value (To_String (Value.V.Wide_Proxy.Value));
when TYPE_NULL =>
raise Constraint_Error with "The object value is null";
when TYPE_TIME =>
raise Constraint_Error with "Cannot convert a date into a discrete type";
when TYPE_BEAN =>
raise Constraint_Error with "Cannot convert a bean into a discrete type";
when TYPE_ARRAY =>
raise Constraint_Error with "Cannot convert an array into a discrete type";
end case;
end To_Value;
end Util.Beans.Objects.Enums;
|
MayaPosch/NymphRPC | Ada | 600 | ads | -- remote_server.ads - Main package for use by NymphRPC clients (Spec).
--
-- 2017/07/01, Maya Posch
-- (c) Nyanko.ws
package NymphRemoteServer is
function init(logger : in LogFunction, level : in integer, timeout: in integer) return Boolean;
function sync(handle : in integer, result : out string) return Boolean;
procedure setLogger();
function shutdown() return Boolean;
function connect(host : in string, port : in integer, handle : out integer, data : in out,
result : out string);
function connect(url : in string, handle : out integer,
private
--
end NymphRemoteServer;
|
charlie5/lace | Ada | 1,796 | adb | with
ada.Numerics.discrete_Random;
package body openGL.Palette
is
package random_Colors is new ada.Numerics.discrete_Random (Color_Value);
use random_Colors;
the_Generator : random_Colors.Generator;
function random_Color return Color
is
begin
return +(random (the_Generator),
random (the_Generator),
random (the_Generator));
end random_Color;
function Shade_of (Self : in Color; Level : in Shade_Level) return Color
is
begin
return (Self.Red * Primary (Level),
Self.Green * Primary (Level),
Self.Blue * Primary (Level));
end Shade_of;
function Mixed (Self : in Color; Other : in Color;
Mix : in mix_Factor := 0.5) return Color
is
function Interpolate (Value_1, Value_2 : in Primary) return Primary -- Linear interpolate.
is
begin
return Value_1
+ (Value_2 - Value_1) * Primary (Mix);
end Interpolate;
begin
return (Interpolate (Self.Red, Other.Red),
Interpolate (Self.Green, Other.Green),
Interpolate (Self.Blue, Other.Blue));
end Mixed;
function is_Similar (Self : in Color; To : in Color;
Similarity : in Primary := default_Similarity) return Boolean
is
begin
return Self.Red <= to.Red + Similarity
and then Self.Red >= to.Red - Similarity
and then Self.Green <= to.Green + Similarity
and then Self.Green >= to.Green - Similarity
and then Self.Blue <= to.Blue + Similarity
and then Self.Blue >= to.Blue - Similarity;
end is_Similar;
begin
reset (the_Generator);
end openGL.Palette;
|
charlie5/cBound | Ada | 1,442 | 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_render_glyph_error_t is
-- Item
--
type Item is record
response_type : aliased Interfaces.Unsigned_8;
error_code : aliased Interfaces.Unsigned_8;
sequence : aliased Interfaces.Unsigned_16;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_render_glyph_error_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_render_glyph_error_t.Item,
Element_Array => xcb.xcb_render_glyph_error_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_render_glyph_error_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_render_glyph_error_t.Pointer,
Element_Array => xcb.xcb_render_glyph_error_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_render_glyph_error_t;
|
docandrew/troodon | Ada | 11,474 | ads | pragma Ada_2012;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with System;
package ftsystem is
--***************************************************************************
-- *
-- * ftsystem.h
-- *
-- * FreeType low-level system interface definition (specification).
-- *
-- * Copyright (C) 1996-2020 by
-- * David Turner, Robert Wilhelm, and Werner Lemberg.
-- *
-- * This file is part of the FreeType project, and may only be used,
-- * modified, and distributed under the terms of the FreeType project
-- * license, LICENSE.TXT. By continuing to use, modify, or distribute
-- * this file you indicate that you have read the license and
-- * understand and accept it fully.
-- *
--
--*************************************************************************
-- *
-- * @section:
-- * system_interface
-- *
-- * @title:
-- * System Interface
-- *
-- * @abstract:
-- * How FreeType manages memory and i/o.
-- *
-- * @description:
-- * This section contains various definitions related to memory management
-- * and i/o access. You need to understand this information if you want to
-- * use a custom memory manager or you own i/o streams.
-- *
--
--*************************************************************************
-- *
-- * M E M O R Y M A N A G E M E N T
-- *
--
--*************************************************************************
-- *
-- * @type:
-- * FT_Memory
-- *
-- * @description:
-- * A handle to a given memory manager object, defined with an
-- * @FT_MemoryRec structure.
-- *
--
type FT_MemoryRec_u;
type FT_Memory is access all FT_MemoryRec_u; -- /usr/include/freetype2/freetype/ftsystem.h:64
--*************************************************************************
-- *
-- * @functype:
-- * FT_Alloc_Func
-- *
-- * @description:
-- * A function used to allocate `size` bytes from `memory`.
-- *
-- * @input:
-- * memory ::
-- * A handle to the source memory manager.
-- *
-- * size ::
-- * The size in bytes to allocate.
-- *
-- * @return:
-- * Address of new memory block. 0~in case of failure.
-- *
--
type FT_Alloc_Func is access function (arg1 : FT_Memory; arg2 : long) return System.Address
with Convention => C; -- /usr/include/freetype2/freetype/ftsystem.h:87
--*************************************************************************
-- *
-- * @functype:
-- * FT_Free_Func
-- *
-- * @description:
-- * A function used to release a given block of memory.
-- *
-- * @input:
-- * memory ::
-- * A handle to the source memory manager.
-- *
-- * block ::
-- * The address of the target memory block.
-- *
--
type FT_Free_Func is access procedure (arg1 : FT_Memory; arg2 : System.Address)
with Convention => C; -- /usr/include/freetype2/freetype/ftsystem.h:108
--*************************************************************************
-- *
-- * @functype:
-- * FT_Realloc_Func
-- *
-- * @description:
-- * A function used to re-allocate a given block of memory.
-- *
-- * @input:
-- * memory ::
-- * A handle to the source memory manager.
-- *
-- * cur_size ::
-- * The block's current size in bytes.
-- *
-- * new_size ::
-- * The block's requested new size.
-- *
-- * block ::
-- * The block's current address.
-- *
-- * @return:
-- * New block address. 0~in case of memory shortage.
-- *
-- * @note:
-- * In case of error, the old block must still be available.
-- *
--
type FT_Realloc_Func is access function
(arg1 : FT_Memory;
arg2 : long;
arg3 : long;
arg4 : System.Address) return System.Address
with Convention => C; -- /usr/include/freetype2/freetype/ftsystem.h:141
--*************************************************************************
-- *
-- * @struct:
-- * FT_MemoryRec
-- *
-- * @description:
-- * A structure used to describe a given memory manager to FreeType~2.
-- *
-- * @fields:
-- * user ::
-- * A generic typeless pointer for user data.
-- *
-- * alloc ::
-- * A pointer type to an allocation function.
-- *
-- * free ::
-- * A pointer type to an memory freeing function.
-- *
-- * realloc ::
-- * A pointer type to a reallocation function.
-- *
--
type FT_MemoryRec_u is record
user : System.Address; -- /usr/include/freetype2/freetype/ftsystem.h:171
alloc : FT_Alloc_Func; -- /usr/include/freetype2/freetype/ftsystem.h:172
free : FT_Free_Func; -- /usr/include/freetype2/freetype/ftsystem.h:173
realloc : FT_Realloc_Func; -- /usr/include/freetype2/freetype/ftsystem.h:174
end record
with Convention => C_Pass_By_Copy; -- /usr/include/freetype2/freetype/ftsystem.h:169
--*************************************************************************
-- *
-- * I / O M A N A G E M E N T
-- *
--
--*************************************************************************
-- *
-- * @type:
-- * FT_Stream
-- *
-- * @description:
-- * A handle to an input stream.
-- *
-- * @also:
-- * See @FT_StreamRec for the publicly accessible fields of a given stream
-- * object.
-- *
--
type FT_StreamRec_u;
type FT_Stream is access all FT_StreamRec_u; -- /usr/include/freetype2/freetype/ftsystem.h:198
--*************************************************************************
-- *
-- * @struct:
-- * FT_StreamDesc
-- *
-- * @description:
-- * A union type used to store either a long or a pointer. This is used
-- * to store a file descriptor or a `FILE*` in an input stream.
-- *
--
type FT_StreamDesc_u (discr : unsigned := 0) is record
case discr is
when 0 =>
value : aliased long; -- /usr/include/freetype2/freetype/ftsystem.h:213
when others =>
pointer : System.Address; -- /usr/include/freetype2/freetype/ftsystem.h:214
end case;
end record
with Convention => C_Pass_By_Copy,
Unchecked_Union => True; -- /usr/include/freetype2/freetype/ftsystem.h:211
subtype FT_StreamDesc is FT_StreamDesc_u; -- /usr/include/freetype2/freetype/ftsystem.h:216
--*************************************************************************
-- *
-- * @functype:
-- * FT_Stream_IoFunc
-- *
-- * @description:
-- * A function used to seek and read data from a given input stream.
-- *
-- * @input:
-- * stream ::
-- * A handle to the source stream.
-- *
-- * offset ::
-- * The offset of read in stream (always from start).
-- *
-- * buffer ::
-- * The address of the read buffer.
-- *
-- * count ::
-- * The number of bytes to read from the stream.
-- *
-- * @return:
-- * The number of bytes effectively read by the stream.
-- *
-- * @note:
-- * This function might be called to perform a seek or skip operation with
-- * a `count` of~0. A non-zero return value then indicates an error.
-- *
--
type FT_Stream_IoFunc is access function
(arg1 : FT_Stream;
arg2 : unsigned_long;
arg3 : access unsigned_char;
arg4 : unsigned_long) return unsigned_long
with Convention => C; -- /usr/include/freetype2/freetype/ftsystem.h:249
--*************************************************************************
-- *
-- * @functype:
-- * FT_Stream_CloseFunc
-- *
-- * @description:
-- * A function used to close a given input stream.
-- *
-- * @input:
-- * stream ::
-- * A handle to the target stream.
-- *
--
type FT_Stream_CloseFunc is access procedure (arg1 : FT_Stream)
with Convention => C; -- /usr/include/freetype2/freetype/ftsystem.h:269
--*************************************************************************
-- *
-- * @struct:
-- * FT_StreamRec
-- *
-- * @description:
-- * A structure used to describe an input stream.
-- *
-- * @input:
-- * base ::
-- * For memory-based streams, this is the address of the first stream
-- * byte in memory. This field should always be set to `NULL` for
-- * disk-based streams.
-- *
-- * size ::
-- * The stream size in bytes.
-- *
-- * In case of compressed streams where the size is unknown before
-- * actually doing the decompression, the value is set to 0x7FFFFFFF.
-- * (Note that this size value can occur for normal streams also; it is
-- * thus just a hint.)
-- *
-- * pos ::
-- * The current position within the stream.
-- *
-- * descriptor ::
-- * This field is a union that can hold an integer or a pointer. It is
-- * used by stream implementations to store file descriptors or `FILE*`
-- * pointers.
-- *
-- * pathname ::
-- * This field is completely ignored by FreeType. However, it is often
-- * useful during debugging to use it to store the stream's filename
-- * (where available).
-- *
-- * read ::
-- * The stream's input function.
-- *
-- * close ::
-- * The stream's close function.
-- *
-- * memory ::
-- * The memory manager to use to preload frames. This is set internally
-- * by FreeType and shouldn't be touched by stream implementations.
-- *
-- * cursor ::
-- * This field is set and used internally by FreeType when parsing
-- * frames. In particular, the `FT_GET_XXX` macros use this instead of
-- * the `pos` field.
-- *
-- * limit ::
-- * This field is set and used internally by FreeType when parsing
-- * frames.
-- *
--
type FT_StreamRec_u is record
base : access unsigned_char; -- /usr/include/freetype2/freetype/ftsystem.h:329
size : aliased unsigned_long; -- /usr/include/freetype2/freetype/ftsystem.h:330
pos : aliased unsigned_long; -- /usr/include/freetype2/freetype/ftsystem.h:331
descriptor : aliased FT_StreamDesc; -- /usr/include/freetype2/freetype/ftsystem.h:333
pathname : aliased FT_StreamDesc; -- /usr/include/freetype2/freetype/ftsystem.h:334
read : FT_Stream_IoFunc; -- /usr/include/freetype2/freetype/ftsystem.h:335
close : FT_Stream_CloseFunc; -- /usr/include/freetype2/freetype/ftsystem.h:336
memory : FT_Memory; -- /usr/include/freetype2/freetype/ftsystem.h:338
cursor : access unsigned_char; -- /usr/include/freetype2/freetype/ftsystem.h:339
limit : access unsigned_char; -- /usr/include/freetype2/freetype/ftsystem.h:340
end record
with Convention => C_Pass_By_Copy; -- /usr/include/freetype2/freetype/ftsystem.h:327
subtype FT_StreamRec is FT_StreamRec_u; -- /usr/include/freetype2/freetype/ftsystem.h:342
--
-- END
end ftsystem;
|
fengjixuchui/ewok-kernel | Ada | 2,310 | adb | --
-- Copyright 2018 The wookey project team <[email protected]>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
with ewok.debug;
package body ewok.tasks.debug
with spark_mode => off
is
procedure crashdump (frame_a : in ewok.t_stack_frame_access)
is
begin
ewok.debug.log (ewok.debug.ERROR,
"registers (frame at " &
system_address'image (to_system_address (frame_a)) &
", EXC_RETURN " & unsigned_32'image (frame_a.all.exc_return) & ")");
ewok.debug.log (ewok.debug.ERROR,
"R0 " & unsigned_32'image (frame_a.all.R0) &
", R1 " & unsigned_32'image (frame_a.all.R1) &
", R2 " & unsigned_32'image (frame_a.all.R2) &
", R3 " & unsigned_32'image (frame_a.all.R3));
ewok.debug.log (ewok.debug.ERROR,
"R4 " & unsigned_32'image (frame_a.all.R4) &
", R5 " & unsigned_32'image (frame_a.all.R5) &
", R6 " & unsigned_32'image (frame_a.all.R6) &
", R7 " & unsigned_32'image (frame_a.all.R7));
ewok.debug.log (ewok.debug.ERROR,
"R8 " & unsigned_32'image (frame_a.all.R8) &
", R9 " & unsigned_32'image (frame_a.all.R9) &
", R10 " & unsigned_32'image (frame_a.all.R10) &
", R11 " & unsigned_32'image (frame_a.all.R11));
ewok.debug.log (ewok.debug.ERROR,
"R12 " & unsigned_32'image (frame_a.all.R12) &
", PC " & unsigned_32'image (frame_a.all.PC) &
", LR " & unsigned_32'image (frame_a.all.LR));
ewok.debug.log (ewok.debug.ERROR,
"PSR " & unsigned_32'image (m4.cpu.to_unsigned_32 (frame_a.all.PSR)));
end crashdump;
end ewok.tasks.debug;
|
sparre/Command-Line-Parser-Generator | Ada | 33 | ads | procedure An_Application.Driver;
|
johnperry-math/hac | Ada | 1,679 | ads | -------------------------------------------------------------------------------------
--
-- HAC - HAC Ada Compiler
--
-- A compiler in Ada for an Ada subset
--
-- Copyright, license, etc. : see top package.
--
-------------------------------------------------------------------------------------
--
with HAC_Sys.Defs, HAC_Sys.PCode;
private package HAC_Sys.Parser.Type_Def is -- Package around type definitions.
use Defs;
------------------------------------------------------------------
------------------Number_Declaration_or_Enum_Item_or_Literal_Char-
--
procedure Number_Declaration_or_Enum_Item_or_Literal_Char (
CD : in out Compiler_Data;
Level : in PCode.Nesting_level;
FSys_ND : in Symset;
C : out Constant_Rec
);
------------------------------------------------------------------
-------------------------------------------------Type_Declaration-
--
-- Parses "type T is ..." and "subtype T is ..."
--
procedure Type_Declaration (
CD : in out Compiler_Data;
Level : in PCode.Nesting_level;
FSys_NTD : in Symset
);
------------------------------------------------------------------
-----------------------------------Type_Definition - RM 3.2.1 (4)-
--
procedure Type_Definition (
CD : in out Compiler_Data;
Initial_Level : in PCode.Nesting_level;
FSys_TD : in Symset;
xTP : out Exact_Typ;
Size : out Integer;
First : out HAC_Integer; -- T'First value if discrete
Last : out HAC_Integer -- T'Last value if discrete
);
end HAC_Sys.Parser.Type_Def;
|
AdaCore/gpr | Ada | 995 | ads | --
-- Copyright (C) 2019-2023, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-Exception
--
-- Knowledge base xml parsing
with GPR2.Environment;
private package GPR2.KB.Parsing is
procedure Parse_Knowledge_Base
(Self : in out Object;
Location : GPR2.Path_Name.Object;
Flags : Parsing_Flags;
Environment : GPR2.Environment.Object)
with Pre => Self.Is_Defined and then Location.Is_Defined
and then Location.Exists;
-- Parses xml file(s) into KB contents
procedure Add
(Self : in out Object;
Flags : Parsing_Flags;
Content : Value_Not_Empty;
Environment : GPR2.Environment.Object)
with Pre => Self.Is_Defined;
-- Implementation of Knowledge_Base.Add
function Parse_Default_Knowledge_Base
(Flags : Parsing_Flags;
Environment : GPR2.Environment.Object) return Object;
-- Implementation of Knowledge_Base.Create_Default
end GPR2.KB.Parsing;
|
reznikmm/matreshka | Ada | 3,615 | 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.Message_Events.Hash is
new AMF.Elements.Generic_Hash (UML_Message_Event, UML_Message_Event_Access);
|
OpenAPITools/openapi-generator | Ada | 10,533 | adb | with Samples.Petstore.Clients;
with Samples.Petstore.Models;
with Swagger;
with Util.Http.Clients.Curl;
with Ada.Text_IO;
with Ada.Command_Line;
with Ada.Calendar.Formatting;
with Ada.Exceptions;
procedure Petstore is
use Ada.Text_IO;
procedure Usage;
procedure Print_Pet (Pet : in Samples.Petstore.Models.Pet_Type);
procedure Print_Order (Order : in Samples.Petstore.Models.Order_Type);
procedure Get_User (C : in out Samples.Petstore.Clients.Client_Type);
procedure Get_Pet (C : in out Samples.Petstore.Clients.Client_Type);
procedure Get_Order (C : in out Samples.Petstore.Clients.Client_Type);
procedure List_Inventory (C : in out Samples.Petstore.Clients.Client_Type);
procedure List_Pet (C : in out Samples.Petstore.Clients.Client_Type);
procedure Delete_Pet (C : in out Samples.Petstore.Clients.Client_Type);
procedure Delete_User (C : in out Samples.Petstore.Clients.Client_Type);
procedure Delete_Order (C : in out Samples.Petstore.Clients.Client_Type);
procedure Add_Pet (C : in out Samples.Petstore.Clients.Client_Type);
procedure Login (C : in out Samples.Petstore.Clients.Client_Type;
Username : in String;
Password : in String);
Server : constant Swagger.UString := Swagger.To_UString ("http://petstore.swagger.io/v2");
Arg_Count : constant Natural := Ada.Command_Line.Argument_Count;
Arg : Positive := 1;
procedure Usage is
begin
Put_Line ("Usage: petstore {list|add|rm|update} {user|order|pet} {params}...");
Put_Line (" get pet <id>... Print pet given its id");
Put_Line (" get user <name>... Print user given its name");
Put_Line (" get order <id>... Print order given its id");
Put_Line (" list pet <status>... List the pets with the given status");
Put_Line (" list inventory List the inventory");
Put_Line (" add pet <id> <name> <status> <category-id> <category-name");
Put_Line (" Add a pet");
Put_Line (" rm user <name>... Remove user with given name");
Put_Line (" rm order <id>... Remove order with given id");
Put_Line (" login <username> <password> Use login operation to get a session");
end Usage;
procedure Print_Pet (Pet : in Samples.Petstore.Models.Pet_Type) is
Need_Indent : Boolean := False;
begin
Put_Line ("Id : " & Swagger.Long'Image (Pet.Id.Value));
Put_Line ("Name : " & Swagger.To_String (Pet.Name));
Put_Line ("Status : " & Swagger.To_String (Pet.Status.Value));
if not Pet.Tags.Is_Empty then
Put ("Tags : ");
for Tag of Pet.Tags loop
Put_Line ((if Need_Indent then " " else "")
& Swagger.To_String (Tag.Name.Value));
Need_Indent := True;
end loop;
end if;
if not Pet.Photo_Urls.Is_Empty then
Need_Indent := False;
Put ("URLs : ");
for Url of Pet.Photo_Urls loop
Put_Line ((if Need_Indent then " " else "") & Swagger.To_String (Url));
Need_Indent := True;
end loop;
end if;
end Print_Pet;
procedure Print_Order (Order : in Samples.Petstore.Models.Order_Type) is
begin
Put_Line ("Id : " & Swagger.Long'Image (Order.Id.Value));
Put_Line ("Pet id : " & Swagger.Long'Image (Order.Pet_Id.Value));
Put_Line ("Quantity : " & Integer'Image (Order.Quantity.Value));
Put_Line ("Status : " & Swagger.To_String (Order.Status.Value));
Put_Line ("Ship date : " & Ada.Calendar.Formatting.Image (Order.Ship_Date.Value));
Put_Line ("Complete : " & Boolean'Image (Order.Complete.Value));
end Print_Order;
procedure Get_User (C : in out Samples.Petstore.Clients.Client_Type) is
User : Samples.Petstore.Models.User_Type;
begin
for I in Arg .. Arg_Count loop
C.Get_User_By_Name (Swagger.To_UString (Ada.Command_Line.Argument (I)), User);
Put_Line ("Id : " & Swagger.Long'Image (User.Id.Value));
Put_Line ("Username : " & Swagger.To_String (User.Username.Value));
Put_Line ("Firstname: " & Swagger.To_String (User.First_Name.Value));
Put_Line ("Lastname : " & Swagger.To_String (User.Last_Name.Value));
Put_Line ("Email : " & Swagger.To_String (User.Email.Value));
Put_Line ("Password : " & Swagger.To_String (User.Password.Value));
Put_Line ("Phone : " & Swagger.To_String (User.Phone.Value));
end loop;
end Get_User;
procedure Get_Pet (C : in out Samples.Petstore.Clients.Client_Type) is
Pet : Samples.Petstore.Models.Pet_Type;
begin
C.Set_Server (Server);
for I in Arg .. Arg_Count loop
declare
P : constant String := Ada.Command_Line.Argument (I);
begin
C.Get_Pet_By_Id (Swagger.Long'Value (P), Pet);
Print_Pet (Pet);
end;
end loop;
end Get_Pet;
procedure Get_Order (C : in out Samples.Petstore.Clients.Client_Type) is
Order : Samples.Petstore.Models.Order_Type;
begin
C.Set_Server (Server);
for I in Arg .. Arg_Count loop
declare
P : constant String := Ada.Command_Line.Argument (I);
begin
C.Get_Order_By_Id (Swagger.Long'Value (P), Order);
Print_Order (Order);
end;
end loop;
end Get_Order;
procedure List_Pet (C : in out Samples.Petstore.Clients.Client_Type) is
Pets : Samples.Petstore.Models.Pet_Type_Vectors.Vector;
begin
for I in Arg .. Arg_Count loop
declare
Status : Swagger.UString_Vectors.Vector;
P : constant String := Ada.Command_Line.Argument (I);
begin
Status.Append (New_Item => Swagger.To_UString (P));
C.Find_Pets_By_Status (Status, Pets);
for Pet of Pets loop
Print_Pet (Pet);
end loop;
end;
end loop;
end List_Pet;
procedure List_Inventory (C : in out Samples.Petstore.Clients.Client_Type) is
List : Swagger.Integer_Map;
Iter : Swagger.Integer_Maps.Cursor;
begin
C.Get_Inventory (List);
Ada.Text_IO.Put_Line ("Inventory size " & Natural'Image (Natural (List.Length)));
Iter := List.First;
while Swagger.Integer_Maps.Has_Element (Iter) loop
Put (Swagger.Integer_Maps.Key (Iter));
Set_Col (70);
Put_Line (Natural'Image (Swagger.Integer_Maps.Element (Iter)));
Swagger.Integer_Maps.Next (Iter);
end loop;
end List_Inventory;
procedure Login (C : in out Samples.Petstore.Clients.Client_Type;
Username : in String;
Password : in String) is
Session : Swagger.UString;
begin
C.Login_User (Swagger.To_UString (Username),
Swagger.To_UString (Password),
Session);
Put_Line ("New session : " & Swagger.To_String (Session));
end Login;
procedure Add_Pet (C : in out Samples.Petstore.Clients.Client_Type) is
Pet : Samples.Petstore.Models.Pet_Type;
begin
if Arg_Count /= 7 then
Put_Line ("Missing some arguments for add pet command");
Usage;
return;
end if;
Pet.Id := (Is_Null => False, Value => Swagger.Long'Value (Ada.Command_Line.Argument (Arg)));
Pet.Name := Swagger.To_UString (Ada.Command_Line.Argument (Arg + 1));
Pet.Status := (Is_Null => False,
Value => Swagger.To_UString (Ada.Command_Line.Argument (Arg + 2)));
Pet.Category.Id := (Is_Null => False,
Value => Swagger.Long'Value (Ada.Command_Line.Argument (Arg + 3)));
Pet.Category.Name := (Is_Null => False,
Value => Swagger.To_UString (Ada.Command_Line.Argument (Arg + 4)));
C.Add_Pet (Pet);
end Add_Pet;
procedure Delete_User (C : in out Samples.Petstore.Clients.Client_Type) is
begin
for I in Arg .. Arg_Count loop
C.Delete_User (Username => Swagger.To_UString (Ada.Command_Line.Argument (I)));
end loop;
end Delete_User;
procedure Delete_Order (C : in out Samples.Petstore.Clients.Client_Type) is
begin
for I in Arg .. Arg_Count loop
C.Delete_Order (Swagger.To_UString (Ada.Command_Line.Argument (I)));
end loop;
end Delete_Order;
procedure Delete_Pet (C : in out Samples.Petstore.Clients.Client_Type) is
Key : constant Swagger.UString := Swagger.To_UString (Ada.Command_Line.Argument (Arg));
begin
Arg := Arg + 1;
for I in Arg .. Arg_Count loop
C.Delete_Pet (Swagger.Long'Value (Ada.Command_Line.Argument (I)),
(Is_Null => False, Value => Key));
end loop;
end Delete_Pet;
begin
if Arg_Count <= 1 then
Usage;
return;
end if;
Util.Http.Clients.Curl.Register;
declare
Command : constant String := Ada.Command_Line.Argument (Arg);
Item : constant String := Ada.Command_Line.Argument (Arg + 1);
C : Samples.Petstore.Clients.Client_Type;
begin
C.Set_Server (Server);
Arg := Arg + 2;
if Command = "login" then
Login (C, Item, Ada.Command_Line.Argument (Arg));
elsif Command = "get" then
if Item = "user" then
Get_User (C);
elsif Item = "pet" then
Get_Pet (C);
elsif Item = "order" then
Get_Order (C);
else
Usage;
end if;
elsif Command = "list" then
if Item = "pet" then
List_Pet (C);
elsif Item = "inventory" then
List_Inventory (C);
else
Usage;
end if;
elsif Command = "add" then
if Item = "pet" then
Add_Pet (C);
else
Usage;
end if;
elsif Command = "rm" then
if Item = "user" then
Delete_User (C);
elsif Item = "order" then
Delete_Order (C);
elsif Item = "pet" then
Delete_Pet (C);
else
Usage;
end if;
elsif Command = "update" then
Usage;
else
Usage;
end if;
exception
when E : Constraint_Error =>
Put_Line ("Constraint error raised: " & Ada.Exceptions.Exception_Message (E));
end;
end Petstore;
|
coopht/axmpp | Ada | 11,144 | adb | ------------------------------------------------------------------------------
-- --
-- AXMPP Project --
-- --
-- XMPP Library for Ada --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2016, Alexander Basov <[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 Alexander Basov, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.SAX.Attributes;
with XMPP.Logger;
package body XMPP.Presences is
use League.Strings;
--------------
-- Create --
--------------
function Create return XMPP_Presence_Access is
begin
return new XMPP_Presence;
end Create;
----------------
-- Get_From --
----------------
function Get_From (Self : XMPP_Presence)
return League.Strings.Universal_String is
begin
return Self.From;
end Get_From;
----------------
-- Get_Kind --
----------------
overriding function Get_Kind (Self : XMPP_Presence) return Object_Kind is
pragma Unreferenced (Self);
begin
return XMPP.Presence;
end Get_Kind;
---------------
-- Get_MUC --
---------------
function Get_MUC (Self : XMPP_Presence) return XMPP.MUCS.XMPP_MUC is
begin
return Self.MUC;
end Get_MUC;
--------------------
-- Get_Priority --
--------------------
function Get_Priority (Self : XMPP_Presence) return Priority_Type is
begin
return Self.Priority;
end Get_Priority;
----------------
-- Get_Show --
----------------
function Get_Show (Self : XMPP_Presence) return Show_Kind is
begin
return Self.Show;
end Get_Show;
------------------
-- Get_Status --
------------------
function Get_Status (Self : XMPP_Presence)
return League.Strings.Universal_String is
begin
return Self.Status;
end Get_Status;
--------------
-- Get_To --
--------------
function Get_To (Self : XMPP_Presence)
return League.Strings.Universal_String is
begin
return Self.To;
end Get_To;
----------------
-- Get_Type --
----------------
function Get_Type (Self : XMPP_Presence) return Presence_Type is
begin
return Self.Type_Of_Presence;
end Get_Type;
---------------------
-- Is_Multi_Chat --
---------------------
function Is_Multi_Chat (Self : XMPP_Presence) return Boolean is
begin
return Self.Multi_Chat;
end Is_Multi_Chat;
-----------------
-- Serialize --
-----------------
overriding procedure Serialize
(Self : XMPP_Presence;
Writer : in out XML.SAX.Pretty_Writers.XML_Pretty_Writer'Class) is
Attrs : XML.SAX.Attributes.SAX_Attributes;
begin
if not Self.To.Is_Empty then
Attrs.Set_Value (Qualified_Name => Presence_To_Attribute,
Value => Self.To);
end if;
if not Self.From.Is_Empty then
Attrs.Set_Value (Qualified_Name => Presence_From_Attribute,
Value => Self.From);
end if;
Writer.Start_Element (Qualified_Name => Presence_Element,
Attributes => Attrs);
if Self.Priority /= -129 then
Writer.Start_Element (Qualified_Name => Priority_Element);
Writer.Characters
(League.Strings.To_Universal_String
(Priority_Type'Wide_Wide_Image (Self.Priority)));
Writer.End_Element (Qualified_Name => Priority_Element);
end if;
if not Self.Status.Is_Empty then
Writer.Start_Element (Qualified_Name => Status_Element);
Writer.Characters (Self.Status);
Writer.End_Element (Qualified_Name => Status_Element);
end if;
if Self.Show /= Online then
Writer.Start_Element (Qualified_Name => Show_Element);
case Self.Show is
when Away =>
Writer.Characters (To_Universal_String ("away"));
when Chat =>
Writer.Characters (To_Universal_String ("chat"));
when DND =>
Writer.Characters (To_Universal_String ("dnd"));
when XA =>
Writer.Characters (To_Universal_String ("xa"));
when Online =>
raise Program_Error;
end case;
Writer.End_Element (Qualified_Name => Show_Element);
end if;
if Self.Multi_Chat then
Self.MUC.Serialize (Writer);
end if;
Writer.End_Element (Qualified_Name => Presence_Element);
end Serialize;
-------------------
-- Set_Content --
-------------------
overriding procedure Set_Content
(Self : in out XMPP_Presence;
Parameter : League.Strings.Universal_String;
Value : League.Strings.Universal_String) is
begin
if Parameter = To_Universal_String ("from") then
Self.From := Value;
elsif Parameter = To_Universal_String ("to") then
Self.To := Value;
elsif Parameter = To_Universal_String ("show") then
if Value = To_Universal_String ("away") then
Self.Show := Away;
elsif Value = To_Universal_String ("chat") then
Self.Show := Chat;
elsif Value = To_Universal_String ("dnd") then
Self.Show := DND;
elsif Value = To_Universal_String ("xa") then
Self.Show := XA;
elsif Value = To_Universal_String ("online") then
Self.Show := Online;
end if;
elsif Parameter = To_Universal_String ("status") then
Self.Status := Value;
elsif Parameter = To_Universal_String ("type") then
if Value = To_Universal_String ("error") then
Self.Type_Of_Presence := Error;
elsif Value = To_Universal_String ("probe") then
Self.Type_Of_Presence := Probe;
elsif Value = To_Universal_String ("subscribe") then
Self.Type_Of_Presence := Subscribe;
elsif Value = To_Universal_String ("subscribed") then
Self.Type_Of_Presence := Subscribed;
elsif Value = To_Universal_String ("unavailable") then
Self.Type_Of_Presence := Unavailable;
elsif Value = To_Universal_String ("unsubscribe") then
Self.Type_Of_Presence := Unsubscribe;
elsif Value = To_Universal_String ("unsubscribed") then
Self.Type_Of_Presence := Unsubscribed;
end if;
elsif Parameter = To_Universal_String ("priority") then
Self.Priority
:= Priority_Type'Wide_Wide_Value (Value.To_Wide_Wide_String);
elsif Parameter = To_Universal_String ("presence") then
null;
else
XMPP.Logger.Log ("Unknown Parameter : " & Parameter);
end if;
end Set_Content;
----------------
-- Set_From --
----------------
procedure Set_From (Self : in out XMPP_Presence;
Value : League.Strings.Universal_String) is
begin
Self.From := Value;
end Set_From;
----------------------
-- Set_Multi_Chat --
----------------------
procedure Set_Multi_Chat (Self : in out XMPP_Presence;
MUC : XMPP.MUCS.XMPP_MUC) is
begin
Self.MUC := MUC;
Self.Multi_Chat := True;
end Set_Multi_Chat;
--------------------
-- Set_Priority --
--------------------
procedure Set_Priority (Self : in out XMPP_Presence; P : Priority_Type) is
begin
Self.Priority := P;
end Set_Priority;
----------------
-- Set_Show --
----------------
procedure Set_Show (Self : in out XMPP_Presence; Show : Show_Kind) is
begin
Self.Show := Show;
end Set_Show;
------------------
-- Set_Status --
------------------
procedure Set_Status (Self : in out XMPP_Presence;
Status : League.Strings.Universal_String) is
begin
Self.Status := Status;
end Set_Status;
--------------
-- Set_To --
--------------
procedure Set_To (Self : in out XMPP_Presence;
Value : League.Strings.Universal_String) is
begin
Self.To := Value;
end Set_To;
----------------
-- Set_Type --
----------------
procedure Set_Type (Self : in out XMPP_Presence; Value : Presence_Type) is
begin
Self.Type_Of_Presence := Value;
end Set_Type;
end XMPP.Presences;
|
AaronC98/PlaneSystem | Ada | 3,845 | adb | ------------------------------------------------------------------------------
-- Templates Parser --
-- --
-- Copyright (C) 2004-2012, 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/>. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
------------------------------------------------------------------------------
with Ada.Text_IO;
with Ada.Strings.Fixed;
package body Templates_Parser.Debug is
use Ada.Text_IO;
use Ada.Strings.Fixed;
-----------
-- Print --
-----------
procedure Print (T : Tag) is
procedure Print (T : Tag; K : Natural);
-- Print tag T, K is the indent level
-----------
-- Print --
-----------
procedure Print (T : Tag; K : Natural) is
Indent : constant String := K * ' ';
N : Tag_Node_Access := T.Data.Head;
begin
Put (Indent);
Put_Line
("(N=" & Natural'Image (T.Data.Count)
& ", Min=" & Natural'Image (T.Data.Min)
& ", Max=" & Natural'Image (T.Data.Max)
& ", Nested_Level=" & Natural'Image (T.Data.Nested_Level));
while N /= null loop
if N.Kind = Value then
Put_Line (Indent & Indent & To_String (N.V));
else
Print (N.VS.all, K + 1);
end if;
N := N.Next;
end loop;
Put_Line (Indent & ")");
end Print;
begin
Print (T, 1);
end Print;
--------------------------
-- Print_Defined_Macros --
--------------------------
procedure Print_Defined_Macros is
begin
Templates_Parser.Print_Defined_Macros;
end Print_Defined_Macros;
----------------
-- Print_Tree --
----------------
procedure Print_Tree (Filename : String; Expand_Macro : Boolean := False) is
begin
Templates_Parser.Expand_Macro := Expand_Macro;
Templates_Parser.Print_Tree (Filename);
end Print_Tree;
end Templates_Parser.Debug;
|
AaronC98/PlaneSystem | Ada | 8,099 | adb | ------------------------------------------------------------------------------
-- Ada Web Server --
-- --
-- Copyright (C) 2007-2015, 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/>. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
------------------------------------------------------------------------------
with Ada.Calendar;
with Ada.Containers.Hashed_Maps;
with AWS.Config;
with AWS.Utils.Streams;
package body AWS.Services.Web_Block.Context is
Max_Id_Deleted : constant := 100;
-- Maximum number of contexts deleted in one pass
function Hash (Key : Id) return Containers.Hash_Type;
type Context_Stamp is record
C : Object;
Created : Calendar.Time; -- used to delete when expired
end record;
package Contexts is new Containers.Hashed_Maps
(Id, Context_Stamp, Hash, "=");
-- Concurrent Database
protected Database is
procedure Clean;
-- Removes expired contexts
function Contains (CID : Id) return Boolean;
-- Returns True if context CID is in the database
function Get (CID : Id) return Object;
-- Retruns the context object
procedure Include (Context : Object; CID : Id)
with Post => Contains (CID);
-- Add or update context into the database
private
DB : Contexts.Map;
end Database;
--------------
-- Database --
--------------
protected body Database is
-----------
-- Clean --
-----------
procedure Clean is
use type Ada.Calendar.Time;
Now : constant Calendar.Time := Calendar.Clock;
Elapsed : constant Duration := Config.Context_Lifetime;
CIDS : array (1 .. Max_Id_Deleted) of Id;
Last : Natural := 0;
Position : Contexts.Cursor := DB.First;
begin
-- First check for obsolete context
while Contexts.Has_Element (Position) and then Last < CIDS'Last loop
if Now - Contexts.Element (Position).Created > Elapsed then
Last := Last + 1;
CIDS (Last) := Contexts.Key (Position);
end if;
Contexts.Next (Position);
end loop;
for K in CIDS'First .. Last loop
DB.Delete (CIDS (K));
end loop;
end Clean;
--------------
-- Contains --
--------------
function Contains (CID : Id) return Boolean is
begin
return DB.Contains (CID);
end Contains;
---------
-- Get --
---------
function Get (CID : Id) return Object is
begin
if DB.Contains (CID) then
return DB.Element (CID).C;
else
return Empty;
end if;
end Get;
-------------
-- Include --
-------------
procedure Include (Context : Object; CID : Id) is
begin
Clean;
-- Register new context
DB.Include (CID, Context_Stamp'(Context, Calendar.Clock));
end Include;
end Database;
-----------
-- Exist --
-----------
function Exist (Context : Object; Name : String) return Boolean is
begin
return Context.Contains (Name);
end Exist;
function Exist (CID : Id) return Boolean is
begin
return Database.Contains (CID);
end Exist;
---------
-- Get --
---------
function Get (CID : Id) return Object is
begin
return Database.Get (CID);
end Get;
---------------
-- Get_Value --
---------------
function Get_Value (Context : Object; Name : String) return String is
begin
if Context.Contains (Name) then
return Context.Element (Name);
else
return "";
end if;
end Get_Value;
----------
-- Hash --
----------
function Hash (Key : Id) return Containers.Hash_Type is
begin
return Strings.Hash (String (Key));
end Hash;
-----------
-- Image --
-----------
function Image (CID : Id) return String is
begin
return String (CID);
end Image;
--------------
-- Register --
--------------
function Register (Context : Object) return Id is
Stream : aliased Utils.Streams.SHA1;
CID : Id;
begin
Object'Output (Stream'Access, Context);
CID := Id (Utils.Streams.Value (Stream'Access));
Database.Include (Context, CID);
return CID;
end Register;
------------
-- Remove --
------------
procedure Remove (Context : in out Object; Name : String) is
begin
Context.Exclude (Name);
end Remove;
---------------
-- Set_Value --
---------------
procedure Set_Value (Context : in out Object; Name, Value : String) is
begin
Context.Include (Name, Value);
end Set_Value;
-----------
-- Value --
-----------
function Value (CID : String) return Id is
begin
if CID'Length = Id'Length then
return Id (CID);
else
return Id'(others => 'x');
end if;
end Value;
------------------
-- Generic_Data --
------------------
package body Generic_Data is
---------------
-- Get_Value --
---------------
function Get_Value (Context : Object; Name : String) return Data is
Position : constant KV.Cursor := Context.Find (Name);
begin
if KV.Has_Element (Position) then
declare
Result : constant String := KV.Element (Position);
Str : aliased Utils.Streams.Strings;
Value : Data;
begin
Utils.Streams.Open (Str, Result);
Data'Read (Str'Access, Value);
return Value;
end;
else
return Null_Data;
end if;
end Get_Value;
---------------
-- Set_Value --
---------------
procedure Set_Value
(Context : in out Object;
Name : String;
Value : Data)
is
Str : aliased Utils.Streams.Strings;
begin
Data'Write (Str'Access, Value);
Context.Include (Name, Utils.Streams.Value (Str'Access));
end Set_Value;
end Generic_Data;
end AWS.Services.Web_Block.Context;
|
reznikmm/matreshka | Ada | 4,248 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
limited with AMF.UML.Send_Object_Actions;
package AMF.Utp.Log_Actions is
pragma Preelaborate;
type Utp_Log_Action is limited interface;
type Utp_Log_Action_Access is
access all Utp_Log_Action'Class;
for Utp_Log_Action_Access'Storage_Size use 0;
not overriding function Get_Base_Send_Object_Action
(Self : not null access constant Utp_Log_Action)
return AMF.UML.Send_Object_Actions.UML_Send_Object_Action_Access is abstract;
-- Getter of LogAction::base_SendObjectAction.
--
not overriding procedure Set_Base_Send_Object_Action
(Self : not null access Utp_Log_Action;
To : AMF.UML.Send_Object_Actions.UML_Send_Object_Action_Access) is abstract;
-- Setter of LogAction::base_SendObjectAction.
--
end AMF.Utp.Log_Actions;
|
BrickBot/Bound-T-H8-300 | Ada | 116,671 | adb | -- Assertions (body)
--
-- A component of the Bound-T Worst-Case Execution Time Tool.
--
-------------------------------------------------------------------------------
-- Copyright (c) 1999 .. 2015 Tidorum Ltd
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
-- 2. Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
-- and/or other materials provided with the distribution.
--
-- This software is provided by the copyright holders and contributors "as is" and
-- any express or implied warranties, including, but not limited to, the implied
-- warranties of merchantability and fitness for a particular purpose are
-- disclaimed. In no event shall the copyright owner or contributors be liable for
-- any direct, indirect, incidental, special, exemplary, or consequential damages
-- (including, but not limited to, procurement of substitute goods or services;
-- loss of use, data, or profits; or business interruption) however caused and
-- on any theory of liability, whether in contract, strict liability, or tort
-- (including negligence or otherwise) arising in any way out of the use of this
-- software, even if advised of the possibility of such damage.
--
-- Other modules (files) of this software composition should contain their
-- own copyright statements, which may have different copyright and usage
-- conditions. The above conditions apply to this file.
-------------------------------------------------------------------------------
--
-- $Revision: 1.66 $
-- $Date: 2015/10/24 20:05:45 $
--
-- $Log: assertions.adb,v $
-- Revision 1.66 2015/10/24 20:05:45 niklas
-- Moved to free licence.
--
-- Revision 1.65 2011-08-31 04:23:33 niklas
-- BT-CH-0222: Option registry. Option -dump. External help files.
--
-- Revision 1.64 2010-01-30 21:13:29 niklas
-- BT-CH-0216: Subprograms have a Return_Method_T attribute.
--
-- Revision 1.63 2009-12-21 14:59:28 niklas
-- BT-CH-0201: Role names with blanks. Option -warn [no_]role.
--
-- Revision 1.62 2009-12-17 14:05:54 niklas
-- BT-CH-0197: Assertions on instruction roles.
--
-- Revision 1.61 2009-10-07 19:26:09 niklas
-- BT-CH-0183: Cell-sets are a tagged-type class.
--
-- Revision 1.60 2009-03-27 13:57:12 niklas
-- BT-CH-0167: Assertion context identified by source-code markers.
--
-- Revision 1.59 2009/03/20 18:19:29 niklas
-- BT-CH-0164: Assertion context identified by source-line number.
--
-- Revision 1.58 2009/01/18 07:51:05 niklas
-- Cleaned up context clauses.
--
-- Revision 1.57 2008/11/03 07:58:13 niklas
-- BT-CH-0155: Ignore assertions on absent subprograms.
--
-- Revision 1.56 2008/09/24 08:38:51 niklas
-- BT-CH-0146: Assertions on "loop starts <bound> times".
-- BT-CH-0146: Loop-repeat assertions set both lower and upper bound.
-- BT-CH-0146: Report locations of contradictory "count" assertions.
-- BT-CH-0146: Contradictory "count" assertions imply infeasibility.
--
-- Revision 1.55 2008/09/20 12:41:49 niklas
-- BT-CH-0145: No error re too few assertion matches if graph is growing.
--
-- Revision 1.54 2008/09/19 10:34:14 niklas
-- BT-CH-0144: Assertion "populations" work again, and more.
--
-- Revision 1.53 2008/07/28 19:23:44 niklas
-- BT-CH-0140: Detect contradictory execution-count bounds.
--
-- Revision 1.52 2008/07/23 09:07:14 niklas
-- BT-CH-0139: Fix recursion in Programs.Execution.Paths.
--
-- Revision 1.51 2008/07/14 19:16:55 niklas
-- BT-CH-0135: Assertions on "instructions".
--
-- Revision 1.50 2008/02/27 14:58:47 niklas
-- BT-CH-0116: Call-specific time and stack assertions.
--
-- Revision 1.49 2007/12/17 13:54:33 niklas
-- BT-CH-0098: Assertions on stack usage and final stack height, etc.
--
-- Revision 1.48 2007/08/03 19:16:54 niklas
-- Extended Apply (Fact, Subprogram), Apply_To_Identified_Subprograms
-- and Apply_Options to implement tracing per Opt.Trace_Sub_Options.
--
-- Revision 1.47 2007/08/02 11:14:50 niklas
-- Extended function Callees to trace the mapping of assertions
-- to the dynamic call. To help, added an Image function for an
-- Assertion_Subset_T within an Assertion_Set_T.
--
-- Revision 1.46 2007/04/24 08:16:25 niklas
-- For Opt.Trace_Map added display of the source location of each
-- mapped assertion (location in the assertion file).
--
-- Revision 1.45 2007/01/25 21:25:13 niklas
-- BT-CH-0043.
--
-- Revision 1.44 2006/11/26 22:07:23 niklas
-- BT-CH-0039.
--
-- Revision 1.43 2006/10/28 19:52:15 niklas
-- BT-CH-0031.
--
-- Revision 1.42 2006/09/29 18:02:17 niklas
-- Corrected Collect_Cell_Set to use only single-location
-- variables and warn about (ignored) multi-location ones.
--
-- Revision 1.41 2006/08/22 13:50:47 niklas
-- BT-CH-0025.
--
-- Revision 1.40 2006/05/29 14:16:18 niklas
-- Corrected Get_Assertions to raise Input_Error if some
-- assertion file was not valid.
--
-- Revision 1.39 2006/05/29 11:22:33 niklas
-- BT-CH-0023.
--
-- Revision 1.38 2006/05/28 07:09:49 niklas
-- BT-CH-0020 further: Added Apply (Fact to Subprogram) and
-- Apply_To_Identified_Subprograms, to implement the "return"
-- and "integrate" subprogram-options.
--
-- Revision 1.37 2006/05/27 21:45:43 niklas
-- BT-CH-0020.
--
-- Revision 1.36 2005/09/03 11:50:27 niklas
-- BT-CH-0006.
--
-- Revision 1.35 2005/02/23 09:05:13 niklas
-- BT-CH-0005.
--
-- Revision 1.34 2005/02/20 15:15:35 niklas
-- BT-CH-0004.
--
-- Revision 1.33 2005/02/16 21:11:37 niklas
-- BT-CH-0002.
--
-- Revision 1.32 2005/02/04 20:59:44 niklas
-- Added the procedure Apply_Options to enter subprogram options
-- from the assertion set into the Programs data structures.
-- At present this is used only for the "[no] return" option.
--
-- Revision 1.31 2004/05/01 14:57:20 niklas
-- First Tidorum version.
-- Taking Cell_T stuff from Storage, not from Arithmetic.
-- Defined Assertion_Set_T to have reference semantics. Thus, parameters
-- of this type are now always of mode "in" even if the underlying object
-- is updated.
-- Defined Assertion_Map_T objects to have default initial value No_Map.
-- Added Symbol_Table parameter to Check_Mapping. Added Display_Properties
-- to describe the properties of loops when loop-mapping fails.
-- Added support for variables that are held in different cell(s)
-- depending on the code address. Many functions of the form Xxx_Values
-- now have two variants: one taking an assertion set and returning a
-- Var_Bound_List_T, and another taking in addition a Code_Address_T and
-- returning a Cell_Bound_List_T valid at that address. If the program
-- point is implicitly known (eg. Call_Values, Subprogram_Inputs) the
-- second variant takes only the assertion set and no program point.
-- Added assertions on subprogram inputs, valid only on entry to the
-- subprogram, retrieved with the function Subprogram_Inputs (variants
-- as explained above).
-- Using the new package Loops.Cells in the implementation. This supports
-- variables that change location depending on code address.
--
-- Revision 1.30 2003/02/17 17:18:41 holsti
-- Added the ability for a loop/call assertion to apply (map) to
-- several loops/calls. The size of this loop/call population can be
-- bounded in the assertion, by a Population component in the
-- Loop_Block_T or Call_Block_T.
-- Removed the "scope list" level of the assertion-set structure. An
-- assertion-set now has a single list of subprograms blocks. The scope
-- prefix is used only at assertion-parsing time to abbreviate symbols.
-- Added a list of Global_Statements to the assertion-set structure.
-- These global loop/call assertions are mapped in each subprogram;
-- their population bounds can be set to allow no matches or to require
-- some matches.
-- Changed Mapping_Status_T to more appropriate literal identifiers.
-- Added a reference (Source_T) to the assertion-file in many assertion
-- elements (replaces the earlier Line_Number components).
-- Derived new types from all Unbounded_Vector instances so that the
-- vector operations are directly visible without qualification (in
-- consequence, some local variables named "Last" had to be renamed).
-- Changed Loop/Call_Description_T to be undiscriminated; a null list
-- of properties handles the special case.
-- Modified reporting of loop/call matches that are too few or too many.
-- Improved Identify_Loops_And_Calls to include the global bounds (and
-- global statements) even when there are no subprogram-specific
-- assertions (the scope-list structure made this hard, before).
--
-- Revision 1.29 2003/02/17 14:22:16 holsti
-- Added the loop-property "executes <code address>" as one more
-- way to identify loops in assertions.
--
-- Revision 1.28 2001/07/03 12:09:08 holsti
-- Call assertions mapped with use of callee (NC_137).
-- Possible mappings displayed for an ambiguous mapping.
--
-- Revision 1.27 2001/04/17 13:52:34 holsti
-- Processor.Code_Address_T replaces Processor.Address_T.
--
-- Revision 1.26 2001/04/10 13:29:22 ville
-- Deleted extra notes
--
-- Revision 1.25 2001/04/10 13:04:00 ville
-- Loop_Is_Labelled implemented
--
-- Revision 1.24 2001/03/21 20:32:21 holsti
-- Output with Locus values.
--
-- Revision 1.23 2001/03/10 00:29:46 holsti
-- Unused Program_T parameters removed.
-- Analysis mode uses Arithmetic.Opt.
--
-- Revision 1.22 2001/02/15 14:16:24 ville
-- Analysis mode assertions enabled
--
-- Revision 1.21 2000/12/29 14:38:04 holsti
-- Loop_Invariants added.
--
-- Revision 1.20 2000/12/29 13:20:06 holsti
-- Removed tbas etc. in favour of NCs.
--
-- Revision 1.19 2000/12/28 17:49:52 holsti
-- Execution_Time_Bound_T uses Processor.Time_T.
--
-- Revision 1.18 2000/12/28 12:57:29 holsti
-- Subprograms and cells are expected to be looked-up during parsing,
-- and found in the AST; look-up code deleted here.
-- Use Arithmetic.Bound_T instead of syntax-oriented, local Bound_T.
-- Loop- and call-mapping reimplemented, with some tracing output under
-- control of the Trace_Map option.
--
-- Revision 1.17 2000/12/05 15:40:13 holsti
-- Adapted to new name of Decoder.Default_Properties.
--
-- Revision 1.16 2000/12/05 11:40:56 holsti
-- Fixed assertion-mapping for subprogram with no assertions.
--
-- Revision 1.15 2000/11/29 19:42:21 holsti
-- Number of property-tables per assertion map corrected.
--
-- Revision 1.14 2000/11/29 15:02:39 holsti
-- Query functions simplified by a set of lower-level accessors.
-- Property map added to assertion mapping.
-- Check_Loop_And_Call_Blocks choice of mapped loop-index corrected.
-- Ambiguous mapping-status separated from Unmapped status.
-- Moved "use" clauses from context into package.
-- Duplicated descriptions of public subprograms removed.
--
-- Revision 1.13 2000/11/22 22:28:56 holsti
-- Using Processor.Code_Address_T instead of Processor.Address_T.
--
-- Revision 1.12 2000/11/22 15:04:59 langback
-- Bug fixes.
--
-- Revision 1.11 2000/11/22 12:48:33 langback
-- Intermediate version.
--
-- Revision 1.10 2000/11/06 08:23:30 langback
-- Added check for empty Assertion_Set also to the routine
-- "Identify_Loops_And_Calls".
--
-- Revision 1.9 2000/11/03 13:42:12 langback
-- Added check of assertion set (map) "emptiness" in all functions that
-- take user assertion information as parameters. Necessary after changes
-- in type declarations of the types Assertion_Set_T and Assertion_Map_T.
--
-- Revision 1.8 2000/10/31 11:44:33 langback
-- First version after adding abstract syntax tree specific child
-- package. Implemented a number of "tba"s.
--
-- Revision 1.7 2000/10/12 11:13:37 langback
-- First committed version with access functions implemented.
--
-- Revision 1.6 2000/09/07 13:07:51 langback
-- Minor fixes.
--
-- Revision 1.5 2000/09/01 08:15:22 saarinen
-- Some fixes and other minor changes.
--
-- Revision 1.4 2000/08/21 13:08:09 holsti
-- Loopless graphs allowed ('Last may be zero).
--
-- Revision 1.3 2000/08/04 15:03:35 langback
-- First version of Get added.
-- Incomplete version of Identify_Loops_And_Calls added.
-- Stubs added for a number of functions previously added to .ads file.
--
-- Revision 1.2 2000/04/21 20:01:42 holsti
-- Describe usage if error in arguments.
--
with Arithmetic.Opt;
with Assertions.Opt;
with Assertions.Own;
with Assertions.Own.Text;
with Assertions.Parser;
with Assertions.Source_Marks;
with Flow.Show;
with Loops.Show;
with Options.File_Sets;
with Options.String_Sets;
with Output;
with Processor.Properties;
with Storage.List_Cell_Sets;
with String_Pool;
with Unbounded_Vectors;
package body Assertions is
use Assertions.Own;
--
--- Assertion sets from Assertions.Own:
--
type Assertion_Set_Object_T is new Own.Assertion_Bag_T;
procedure Get_Assertions (
Program : in Programs.Program_T;
Assertion_Set : out Assertion_Set_T)
is
Files : Options.String_Sets.String_List_T :=
Options.File_Sets.To_List (Opt.Assertion_Files);
-- All the assertion file names.
Valid : Boolean;
-- Whether an assertion file was good.
All_Valid : Boolean := True;
-- Whether all assertion files were good.
begin
Assertion_Set := new Assertion_Set_Object_T;
for F in Files'Range loop
Parser.Parse_File (
File_Name => String_Pool.To_String (Files(F)),
Program => Program,
Into => Assertion_Bag_T (Assertion_Set.all),
Valid => Valid);
All_Valid := All_Valid and Valid;
end loop;
if not All_Valid then
raise Input_Error;
end if;
end Get_Assertions;
procedure Get_Marks
is
Files : Options.String_Sets.String_List_T :=
Options.File_Sets.To_List (Opt.Mark_Files);
-- All the mark-definition file names.
Valid : Boolean;
-- Whether a mark-definition file was good.
All_Valid : Boolean := True;
-- Whether all mark-definition files were good.
begin
for F in Files'Range loop
Source_Marks.Load_File (
File_Name => String_Pool.To_String (Files(F)),
Valid => Valid);
All_Valid := All_Valid and Valid;
end loop;
if not All_Valid then
raise Input_Error;
end if;
end Get_Marks;
procedure Apply (
Fact : in Fact_T;
To : in Programs.Subprogram_T)
--
-- Applies a Fact To a subprogram.
--
is
Sub_Mark : Output.Nest_Mark_T;
-- For the subprogram locus.
begin
Sub_Mark := Output.Nest (Programs.Locus (To));
if Opt.Trace_Sub_Options then
Output.Trace ("Applying fact " & Own.Text.Image (Fact));
end if;
case Fact.Kind is
when Return_Method =>
Programs.Set_Return_Method (
Subprogram => To,
To => Fact.Return_Method);
when Subprogram_Arithmetic =>
if Fact.Use_Arithmetic then
Programs.Set_Arithmetic_Analysis (
Subprogram => To,
Choice => Arithmetic.Opt.Enforced);
else
Programs.Set_Arithmetic_Analysis (
Subprogram => To,
Choice => Arithmetic.Opt.Disabled);
end if;
when Subprogram_Integrate =>
Programs.Set_Call_Integration (
Subprogram => To,
To => True);
when Subprogram_Hide =>
Programs.Set_Hiding_In_Call_Graph_Drawing (
Subprogram => To,
To => True);
when Subprogram_Omit =>
Programs.Set_Stub (
Subprogram => To,
To => True);
when Subprogram_Unused =>
Programs.Set_Unused (
Subprogram => To,
To => True);
when Property_Value =>
Processor.Properties.Apply (
Property => Fact.Property,
Values => Fact.Prop_Value,
To => To);
when others =>
null;
end case;
Output.Unnest (Sub_Mark);
exception
when others =>
Output.Unnest (Sub_Mark);
end Apply;
procedure Apply_To_Identified_Subprograms (
Fact : Fact_T;
Predicate : Part_Predicate_T)
--
-- Applies a Fact to the subprogram or subprograms that are
-- identified by the Predicate, which belongs to a Parts_T
-- with Kind = Subprogram.
--
is
Feature : Feature_T;
-- A feature in the Predicate.
begin
for P in Predicate'Range loop
Feature := Predicate(P);
if Opt.Trace_Sub_Options then
Output.Trace ("Applying feature" & Positive'Image (P));
Own.Text.Put (Item => Feature, Indent => 6, Outer => No_Goals);
end if;
case Feature.Kind is
when Subprogram_Identity =>
if not Feature.Negated then
-- This identifies a subprogram.
Apply (
Fact => Fact,
To => Feature.Subprogram);
end if;
when others =>
null; -- TBD for Predicate(P).Kind = Named?
end case;
end loop;
end Apply_To_Identified_Subprograms;
procedure Apply_To_Instruction (
Address : in Processor.Code_Address_T;
Fact : in Fact_T;
Program : in Programs.Program_T)
--
-- Applies a Fact to the instruction at the given Address.
--
is
Conflict : Boolean;
-- Whether the new role conflicts with a role that
-- was assigned earlier to this instruction.
begin
case Fact.Kind is
when Instruction_Role =>
Programs.Set_Instruction_Role (
Address => Address,
Role => Fact.Role,
Within => Program,
Conflict => Conflict);
if Conflict then
Output.Error (
Locus => Locus (Fact.Source),
Text => "Conflicts with earlier assertions.");
end if;
when others =>
null;
end case;
end Apply_To_Instruction;
procedure Apply_Options (
Assertion_Set : in Assertion_Set_T;
Program : in Programs.Program_T)
is
Object : Assertion_Set_Object_T renames Assertion_Set.all;
Ass : Assertion_T;
-- One of the assertions.
begin
if Opt.Trace_Sub_Options then
Output.Trace ("Applying asserted subprogram options.");
end if;
for A in First (Object) .. Last (Object) loop
Ass := Element (Object, A);
if Opt.Trace_Sub_Options then
Output.Trace ("Applying assertion" & Positive'Image (A));
Own.Text.Put (Ass);
end if;
case Ass.Parts.Kind is
when Subprogram =>
case Ass.Fact.Kind is
when Return_Method
| Subprogram_Arithmetic
| Subprogram_Integrate
| Subprogram_Omit
| Subprogram_Unused
| Subprogram_Hide
| Property_Value =>
Apply_To_Identified_Subprograms (
Fact => Ass.Fact,
Predicate => Ass.Parts.Predicate.all);
when others =>
null;
end case;
when Instruction =>
Apply_To_Instruction (
Address => Ass.Parts.Address,
Fact => Ass.Fact,
Program => Program);
when others =>
null;
end case;
end loop;
end Apply_Options;
procedure Warn_About_Unused_Options (
Assertion_Set : in Assertion_Set_T;
Program : in Programs.Program_T)
is
Object : Assertion_Set_Object_T renames Assertion_Set.all;
Ass : Assertion_T;
-- One of the assertions.
begin
-- The "options" checked now include:
--
-- > Instruction roles.
for A in First (Object) .. Last (Object) loop
Ass := Element (Object, A);
case Ass.Parts.Kind is
when Instruction =>
case Ass.Fact.Kind is
when Instruction_Role =>
if Opt.Warn_Unused_Role
and then not Programs.Instruction_Role_Was_Used (
Address => Ass.Parts.Address,
Within => Program)
then
Output.Warning (
Locus => Locus (Ass.Fact.Source),
Text => "Instruction role assertion was not used.");
end if;
when others =>
null;
end case;
when others =>
null;
end case;
end loop;
end Warn_About_Unused_Options;
--
--- Choosing subsets of assertions and mapping subsets
--- to lists of results (transformed assertions) or
--- a cumulative (folded) result.
--
generic
type Params (<>) is private;
package Subsets
--
-- Defining subsets of assertions by means of a predicate
-- function with a certain type of filtering Parameters.
--
is
type Filter_T is access function (
Assertion : Assertion_T;
Param : Params)
return Boolean;
function Subset (
From : Assertion_Bag_T;
Filter : Filter_T;
Param : Params)
return Assertion_Subset_T;
--
-- The subset of assertions From the set, chosen by the
-- Filter function (returning True for "chosen") depending
-- on the given filtering Parameters.
function Subset (
From : Assertion_Subset_T;
Within : Assertion_Bag_T;
Filter : Filter_T;
Param : Params)
return Assertion_Subset_T;
--
-- The sub-subset of assertions From the given subset Within
-- the given assertion set, chosen by the Filter function
-- (returning True for "chosen") depending on the given
-- filtering Parameters.
end Subsets;
package body Subsets is
function Subset (
From : Assertion_Bag_T;
Filter : Filter_T;
Param : Params)
return Assertion_Subset_T
is
Sub : Assertion_Subset_T (1 .. Length (From));
Num : Natural := 0;
-- The result will be Sub(1 .. Num).
begin
for F in First (From) .. Last (From) loop
if Filter (Element (From, F), Param) then
-- This assertion is chosen for the result.
Num := Num + 1;
Sub(Num) := F;
end if;
end loop;
return Sub(1 .. Num);
end Subset;
function Subset (
From : Assertion_Subset_T;
Within : Assertion_Bag_T;
Filter : Filter_T;
Param : Params)
return Assertion_Subset_T
is
Sub : Assertion_Subset_T (1 .. From'Length);
Num : Natural := 0;
-- The result will be Sub(1 .. Num).
begin
for F in From'Range loop
if Filter (Element (Within, From(F)), Param) then
-- This assertion is chosen for the result.
Num := Num + 1;
Sub(Num) := From(F);
end if;
end loop;
return Sub(1 .. Num);
end Subset;
end Subsets;
generic
type Result is private;
type Result_List is array (Positive range <>) of Result;
type Params (<>) is private;
package Projections
--
-- Projecting an assertion subset to a list of computed Results
-- for each assertion in the subset.
--
is
type Projector_T is access function (
Assertion : Assertion_T;
Param : Params)
return Result;
function Projection (
From : Assertion_Subset_T;
Within : Assertion_Bag_T;
Projector : Projector_T;
Param : Params)
return Result_List;
--
-- The list of the Results returned by the Projector function
-- for the assertions From the given subset Within the given
-- assertion set and using the given projection Parameters.
end Projections;
package body Projections is
function Projection (
From : Assertion_Subset_T;
Within : Assertion_Bag_T;
Projector : Projector_T;
Param : Params)
return Result_List
is
Results : Result_List (From'Range);
-- The results.
begin
for R in Results'Range loop
Results(R) := Projector (
Assertion => Element (Within, From(R)),
Param => Param);
end loop;
return Results;
end Projection;
end Projections;
generic
type Result (<>) is private;
type Params (<>) is private;
package Cumulations
--
-- Accumulating a total Result from a subset of assertions
-- with the help of some Parameters.
--
is
type Cumulator_T is access procedure (
Assertion : in Assertion_T;
Param : in Params;
Total : in out Result);
procedure Cumulate (
From : in Assertion_Subset_T;
Within : in Assertion_Bag_T;
Cumulator : in Cumulator_T;
Param : in Params;
Total : in out Result);
--
-- Accumulates a Total result by applying the Cumulator
-- to each assertion From the subset Within the whole set,
-- using the same Parameters for all calls.
end Cumulations;
package body Cumulations is
procedure Cumulate (
From : in Assertion_Subset_T;
Within : in Assertion_Bag_T;
Cumulator : in Cumulator_T;
Param : in Params;
Total : in out Result)
is
begin
for F in From'Range loop
Cumulator (
Assertion => Element (Within, From(F)),
Param => Param,
Total => Total);
end loop;
end Cumulate;
end Cumulations;
--
--- Subsetting utilities
--
-- Part and facts
type Part_Facts_T is record
Part : Part_Kind_T;
Facts : Fact_Kinds_T;
end record;
--
-- Params for selecting an assertion subset based on the
-- kind of part and fact. One kind of part but many kinds
-- of facts can be selected.
package Part_Fact_Subsets is new Subsets (Params => Part_Facts_T);
--
-- Choosing assertion subsets based on the kind of Part and Fact.
function Match_Part_Fact (
Assertion : Assertion_T;
Param : Part_Facts_T)
return Boolean
--
-- Whether the Assertion concerns a given kind of part and
-- states a fact of some chosen kinds.
--
is
begin
return Assertion.Parts.Kind = Param.Part
and Param.Facts(Assertion.Fact.Kind);
end Match_Part_Fact;
-- Subprogram, part and fact
type Subprogram_Facts_Span_T is record
Subprogram : Programs.Subprogram_T;
Model : Flow.Computation.Model_Handle_T;
Facts : Fact_Kinds_T;
Span : Fact_Span_T;
end record;
--
-- Params for selecting an assertion subset based on the subject
-- subprogram and the kind of fact asserted. For Variable_Value
-- facts, the Span is also significant.
package Subprogram_Facts_Span_Subsets
is new Subsets (Params => Subprogram_Facts_Span_T);
--
-- Choosing assertion subsets that apply to a given subprogram
-- and state a given kind of fact, with a given span.
function Match_Subprogram_Fact_Span (
Assertion : Assertion_T;
Param : Subprogram_Facts_Span_T)
return Boolean
--
-- Whether the Assertion applies to a given Subprogram and
-- states a given kind of fact with a given span.
--
is
begin
return (Assertion.Parts.Kind = Subprogram
and Param.Facts(Assertion.Fact.Kind)
and (Assertion.Fact.Kind /= Variable_Value
or else
Assertion.Fact.Span = Param.Span))
and then
Match (
Subprogram => Param.Subprogram,
Model => Param.Model,
Predicate => Assertion.Parts.Predicate,
Goals => No_Goals);
end Match_Subprogram_Fact_Span;
-- Part and property
type Part_Property_T is record
Part : Part_Kind_T;
Property : Processor.Property_T;
end record;
--
-- Params for selecting a subset of property-value assertions
-- based on the kind of part and on which property.
package Part_Property_Subsets
is new Subsets (Params => Part_Property_T);
--
-- Choosing assertion subsets that constrain the values of
-- a particular processor-property in a particular part of
-- the program.
function Match_Part_Property (
Assertion : Assertion_T;
Param : Part_Property_T)
return Boolean
--
-- Whether the Assertion constrains the values of a particular
-- processor property over a particular part of the program.
--
is
use type Processor.Property_T;
begin
return (Assertion.Parts.Kind = Param.Part
and Assertion.Fact.Kind = Property_Value)
and then
Assertion.Fact.Property = Param.Property;
end Match_Part_Property;
-- Subprogram and property
type Subprogram_Property_T is record
Subprogram : Programs.Subprogram_T;
Model : Flow.Computation.Model_Handle_T;
Property : Processor.Property_T;
end record;
--
-- Params for selecting a subset of property-value assertions
-- based on the subprogram and property to which the assertion
-- applies.
package Subprogram_Property_Subsets
is new Subsets (Params => Subprogram_Property_T);
--
-- Choosing assertion subsets that constrain the values of
-- a particular processor-property in a particular subprogram.
function Match_Subprogram_Property (
Assertion : Assertion_T;
Param : Subprogram_Property_T)
return Boolean
--
-- Whether the Assertion constrains the values of a particular
-- processor property over a particular subprogram.
--
is
use type Processor.Property_T;
use type Programs.Subprogram_T;
begin
return (Assertion.Parts.Kind = Subprogram
and Assertion.Fact.Kind = Property_Value)
and then
Assertion.Fact.Property = Param.Property
and then
Match (
Subprogram => Param.Subprogram,
Model => Param.Model,
Predicate => Assertion.Parts.Predicate,
Goals => No_Goals);
end Match_Subprogram_Property;
-- Instruction (address) and facts
type Instruction_Facts_T is record
Address : Processor.Code_Address_T;
Facts : Fact_Kinds_T;
end record;
--
-- Params for selecting an assertion subset that asserts
-- some kinds of Facts on the instruction at a given Address.
package Instruction_Fact_Subsets is new
Subsets (Params => Instruction_Facts_T);
--
-- Choosing assertion subsets based on an instruction address
-- and the kinds of Facts that are asserted for the instruction.
function Match_Instruction_Fact (
Assertion : Assertion_T;
Param : Instruction_Facts_T)
return Boolean
--
-- Whether the Assertion concerns an instruction at a given
-- address and states a fact of some chosen kinds.
--
is
use type Processor.Code_Address_T;
begin
return Assertion.Parts.Kind = Instruction
and then Assertion.Parts.Address = Param.Address
and then Param.Facts(Assertion.Fact.Kind);
end Match_Instruction_Fact;
-- Actual part
package Actual_Part_Subsets is new Subsets (Params => Actual_Part_T);
--
-- Choosing assertion subsets that apply to a particular actual
-- part of the program under analysis.
function Match_Actual_Part (
Assertion : Assertion_T;
Param : Actual_Part_T)
return Boolean
--
-- Whether the Assertion applies to the actual part that is
-- the Param. The Assertion Kind must equal the part Kind and
-- the part must satisfy the Assertion predicate.
--
is
begin
if Assertion.Parts.Kind /= Param.Kind then
-- Evidently no match.
return False;
else
if Opt.Trace_Matching then
Output.Trace (
"Matching "
& Image (Param)
& " to assertion:");
Text.Put (Assertion);
end if;
return Match (
Part => Param,
Predicate => Assertion.Parts.Predicate,
Goals => No_Goals);
end if;
end Match_Actual_Part;
--
--- Projection utilities
--
type Null_T is null record;
--
-- In case parameters are not needed for a subset or projection.
package Var_Interval_Projections is new Projections (
Result => Storage.Bounds.Var_Interval_T,
Result_List => Storage.Bounds.Var_Interval_List_T,
Params => Null_T);
--
-- Projecting assertion subsets to variable-value bounds.
function To_Var_Interval (
Assertion : Assertion_T;
Param : Null_T)
return Storage.Bounds.Var_Interval_T
--
-- The Var_Interval_T that corresponds to an Assertion
-- on a Variable_Value fact.
--
-- Precondition: Assertion.Fact.Kind = Variable_Value.
--
is
begin
return (
Location => Assertion.Fact.Var_Name.Location,
Interval => Assertion.Fact.Var_Value);
end To_Var_Interval;
--
--- Cumulation utilities
--
-- Sets of invariant cells
subtype Cell_Set_T is Storage.List_Cell_Sets.Set_T;
--
-- A set of cells that is invariant in some context.
use Storage.List_Cell_Sets;
package Invariant_Cell_Sets is new Cumulations (
Result => Cell_Set_T,
Params => Null_T);
--
-- Accumulating sets of cells from invariant-cell assertions.
procedure Collect_Cell_Set (
Assertion : in Assertion_T;
Param : in Null_T;
Total : in out Cell_Set_T)
--
-- Adds the cells from an invariance Assertion to a Total.
--
-- Precondition: Assertion.Fact.Kind = Variable_Invariance.
--
is
Loc : Storage.Location_T renames
Assertion.Fact.Invariant_Var_Name.Location.all;
-- The locations of the invariant variable.
begin
if Loc'Length <= 1 then
for L in Loc'Range loop
Add (
Cell => Loc(L).Cell,
To => Total);
end loop;
else
-- TBD/TBM to make invariance depend on execution point.
Output.Warning (
"Ignored multi-location invariance assertion on "
& Image (Assertion.Fact.Invariant_Var_Name));
end if;
end Collect_Cell_Set;
-- Execution-time bounds
package Execution_Time_Bounds is new Cumulations (
Result => Time_Bound_T,
Params => Null_T);
--
-- Accumulating the conjunctive (intersected, strictest)
-- execution-time bounds.
procedure Restrict_Time (
Assertion : in Assertion_T;
Param : in Null_T;
Total : in out Time_Bound_T)
--
-- Restricts the Total execution-time bounds by the bounds from
-- an execution-time Assertion.
--
-- Precondition: Assertion.Fact.Kind = Execution_Time.
--
is
Time : constant Time_Bound_T := Assertion.Fact.Time;
begin
Total.Min := Processor.Time_T'Max (Total.Min, Time.Min);
Total.Max := Processor.Time_T'Min (Total.Max, Time.Max);
end Restrict_Time;
-- Stack usage/final-height bounds:
package Stack_Bounds is new Cumulations (
Result => Stack_Bounds_T,
Params => Null_T);
--
-- Accumulating the conjunctive (intersected, strictest)
-- bounds on stack usage or final stack height.
procedure Restrict_Stacks (
Assertion : in Assertion_T;
Param : in Null_T;
Total : in out Stack_Bounds_T)
--
-- Restricts the Total stack bounds by the bounds from
-- a stack Assertion.
--
-- Precondition: Assertion.Fact.Kind is Stack_Final or Stack_Usage.
--
is
use Storage.Bounds;
Interval : Interval_T renames Total(Assertion.Fact.Stack_Index);
-- The bounds on the stack named in the assertion.
begin
Interval := Interval and Assertion.Fact.Stack_Value;
end Restrict_Stacks;
function Default_Stack_Usage (Subprogram : Programs.Subprogram_T)
return Stack_Bounds_T
--
-- The default (unasserted) bounds on stack usage for the
-- given Subprogram (which may influence the Initial_Stack_Height)
-- for all stacks in this program.
--
is
Stacks : Programs.Stacks_T :=
Programs.Stacks (Within => Programs.Program (Subprogram));
-- All the stacks in the program.
Usage : Stack_Bounds_T (Stacks'Range);
-- The default (unasserted) stack-usage bounds.
begin
for S in Stacks'Range loop
Usage(S) := (
Min => Storage.Bounds.Limit (Programs.Initial_Stack_Height (
Stack => Stacks(S),
Entering => Subprogram)),
Max => Storage.Bounds.Not_Limited);
end loop;
return Usage;
end Default_Stack_Usage;
function Default_Final_Stack_Height (Program : in Programs.Program_T)
return Stack_Bounds_T
--
-- The default (unasserted) bounds on the final stack heights for
-- all stacks in the given Program.
--
is
Stacks : Programs.Stacks_T := Programs.Stacks (Program);
-- All the stacks in the program.
Final : Stack_Bounds_T (Stacks'Range);
-- The default (unasserted) final-height bounds.
begin
for S in Stacks'Range loop
case Programs.Kind (Stacks(S)) is
when Programs.Stable =>
Final(S) := Storage.Bounds.Exactly_Zero;
when Programs.Unstable =>
Final(S) := Storage.Bounds.Universal_Interval;
end case;
end loop;
return Final;
end Default_Final_Stack_Height;
-- Property bounds
package Value_Bounds is new Cumulations (
Result => Storage.Bounds.Interval_T,
Params => Null_T);
--
-- Accumulating the conjunctive (intersected, strictest)
-- bounds on some values (of variables or properties).
procedure Restrict_Property (
Assertion : in Assertion_T;
Param : in Null_T;
Total : in out Storage.Bounds.Interval_T)
--
-- Restricts the Total bounds on some property by the
-- bounds from a property-value Assertion.
--
-- Precondition: Assertion.Fact.Kind = Property_Value.
--
is
use type Storage.Bounds.Interval_T;
begin
Total := Total and Assertion.Fact.Prop_Value;
end Restrict_Property;
-- Execution or repetition count bounds:
package Count_Bounds is new Cumulations (
Result => Flow.Execution.Bound_T,
Params => Null_T);
--
-- Accumulating the conjunctive (intersected, strictest)
-- bounds on some values (of variables or properties).
procedure Restrict_Count (
Assertion : in Assertion_T;
Param : in Null_T;
Total : in out Flow.Execution.Bound_T)
--
-- Restricts the Total execution-count or repetition-count bounds
-- by the bounds from an execution-time Assertion.
--
-- Precondition: Assertion.Fact.Kind is Loop_Repetitions,
-- Loop_Starts or Call_Executions (that is, Assertions.Fact.Count
-- exists).
--
is
use type Flow.Execution.Bound_T;
begin
Total := Total and Assertion.Fact.Count;
end Restrict_Count;
--
--- Reporting contradictory assertions
--
procedure Report_Conflict (
Text : in String;
Subset : in Assertion_Subset_T;
Within : in Assertion_Set_T;
Locus : in Output.Locus_T)
--
-- Reports the assertions in the Subset as Error:Conflict lines
-- at the given Locus.
--
is
Ass : Assertion_T;
-- One of the Subset assertions.
begin
Output.Error (Locus, Text);
for S in Subset'Range loop
Ass := Element (Assertion_Bag_T (Within.all), Subset(S));
Output.Error (
Locus => Locus,
Text =>
"Conflict"
& Output.Field_Separator
& Image (Ass.Source));
end loop;
end Report_Conflict;
--
--- Applying assertion sets to various program parts under analysis
--
function Global_Values (
Asserts : Assertion_Set_T)
return Storage.Bounds.Var_Interval_List_T
is
Subset : constant Assertion_Subset_T :=
Part_Fact_Subsets.Subset (
From => Assertion_Bag_T (Asserts.all),
Filter => Match_Part_Fact'Access,
Param => (
Part => Program,
Facts => +Variable_Value));
-- The global variable-value assertions.
begin
return Var_Interval_Projections.Projection (
From => Subset,
Within => Assertion_Bag_T (Asserts.all),
Projector => To_Var_Interval'Access,
Param => (null record));
end Global_Values;
function Global_Values (
Asserts : Assertion_Set_T;
Point : Processor.Code_Address_T)
return Storage.Bounds.Cell_Interval_List_T
is
begin
return
Storage.Bounds.Cell_Intervals (
From => Global_Values (Asserts),
Point => Point);
end Global_Values;
function Subprogram_Inputs (
Subprogram : Programs.Subprogram_T;
Asserts : Assertion_Set_T)
return Storage.Bounds.Var_Interval_List_T
is
Subset : constant Assertion_Subset_T :=
Subprogram_Facts_Span_Subsets.Subset (
From => Assertion_Bag_T (Asserts.all),
Filter => Match_Subprogram_Fact_Span'Access,
Param => (
Subprogram => Subprogram,
Model => null,
Facts => +Variable_Value,
Span => Initially));
-- The variable-value assertions at the start of this Subprogram.
begin
return Var_Interval_Projections.Projection (
From => Subset,
Within => Assertion_Bag_T (Asserts.all),
Projector => To_Var_Interval'Access,
Param => (null record));
end Subprogram_Inputs;
function Subprogram_Inputs (
Subprogram : Programs.Subprogram_T;
Asserts : Assertion_Set_T)
return Storage.Bounds.Cell_Interval_List_T
is
begin
return
Storage.Bounds.Cell_Intervals (
From => Subprogram_Inputs (Subprogram, Asserts),
Point => Programs.Entry_Address (Subprogram));
end Subprogram_Inputs;
function Subprogram_Values (
Subprogram : Programs.Subprogram_T;
Asserts : Assertion_Set_T)
return Storage.Bounds.Var_Interval_List_T
is
Subset : constant Assertion_Subset_T :=
Subprogram_Facts_Span_Subsets.Subset (
From => Assertion_Bag_T (Asserts.all),
Filter => Match_Subprogram_Fact_Span'Access,
Param => (
Subprogram => Subprogram,
Model => null,
Facts => +Variable_Value,
Span => Always));
-- The variable-value assertions for all of this Subprogram.
begin
return Var_Interval_Projections.Projection (
From => Subset,
Within => Assertion_Bag_T (Asserts.all),
Projector => To_Var_Interval'Access,
Param => (null record));
end Subprogram_Values;
function Subprogram_Values (
Subprogram : Programs.Subprogram_T;
Point : Processor.Code_Address_T;
Asserts : Assertion_Set_T)
return Storage.Bounds.Cell_Interval_List_T
is
begin
return
Storage.Bounds.Cell_Intervals (
From => Subprogram_Values (Subprogram, Asserts),
Point => Point);
end Subprogram_Values;
function Subprogram_Invariants (
Subprogram : Programs.Subprogram_T;
Asserts : Assertion_Set_T)
return Storage.Cell_Set_T
is
Subset : constant Assertion_Subset_T :=
Subprogram_Facts_Span_Subsets.Subset (
From => Assertion_Bag_T (Asserts.all),
Filter => Match_Subprogram_Fact_Span'Access,
Param => (
Subprogram => Subprogram,
Model => null,
Facts => +Variable_Invariance,
Span => Always));
-- The variable-invariance assertions for this Subprogram.
-- Param.Span is irrelevant here.
Invariants : Cell_Set_T;
-- The collected cells, initially none.
begin
Invariant_Cell_Sets.Cumulate (
From => Subset,
Within => Assertion_Bag_T (Asserts.all),
Cumulator => Collect_Cell_Set'Access,
Param => (null record),
Total => Invariants);
return Invariants;
end Subprogram_Invariants;
function Subprogram_Time_Bounded (
Subprogram : Programs.Subprogram_T;
Asserts : Assertion_Set_T)
return Boolean
is
use type Processor.Time_T;
Time : constant Time_Bound_T := Subprogram_Time (Subprogram, Asserts);
-- The asserted bounds on the time.
begin
return Time.Max < Processor.Time_T'Last;
-- This is double work: the Subprogram_Time will probably be
-- accessed twice in the analysis, first to check if it *is*
-- asserted, then to insert the asserted bounds in the execution
-- bounds of the subprogram. Oh well.
end Subprogram_Time_Bounded;
function Subprogram_Time (
Subprogram : Programs.Subprogram_T;
Asserts : Assertion_Set_T)
return Time_Bound_T
is
Subset : constant Assertion_Subset_T :=
Subprogram_Facts_Span_Subsets.Subset (
From => Assertion_Bag_T (Asserts.all),
Filter => Match_Subprogram_Fact_Span'Access,
Param => (
Subprogram => Subprogram,
Model => null,
Facts => +Execution_Time,
Span => Always));
-- The execution-time assertions for this Subprogram.
-- Param.Span is irrelevant here.
Time : Time_Bound_T := No_Bound;
-- The cumulative (intersected) time bounds.
begin
Execution_Time_Bounds.Cumulate (
From => Subset,
Within => Assertion_Bag_T (Asserts.all),
Cumulator => Restrict_Time'Access,
Param => (null record),
Total => Time);
return Time;
end Subprogram_Time;
function Stacks_Bounded (
Subprogram : Programs.Subprogram_T;
Asserts : Assertion_Set_T)
return Boolean
is
Program : constant Programs.Program_T := Programs.Program (Subprogram);
-- The program under analysis.
Usage : constant Stack_Bounds_T := Stack_Usage (Subprogram, Asserts);
-- The asserted bounds on stack usage.
Final : constant Stack_Bounds_T :=
Final_Stack_Height (Subprogram, Asserts);
-- The asserted bounds on final stack height.
begin
-- Check the usage:
for U in Usage'Range loop
Output.Note (
"Asserted usage for "
& Programs.Stack_Name (U, Program)
& Output.Field_Separator
& Storage.Bounds.Image (Usage(U), "usage"));
if Storage.Bounds.Unlimited (Usage(U).Max) then
-- No upper bound on the usage of this stack.
return False;
end if;
end loop;
-- Check the final height:
for F in Final'Range loop
Output.Note (
"Asserted final height for "
& Programs.Stack_Name (F, Program)
& Output.Field_Separator
& Storage.Bounds.Image (
Item => Final(F),
Cell => Programs.Stack_Height (F, Program)));
if not Storage.Bounds.Singular (Final(F)) then
-- Fuzzy value or no bounds for the final stack height.
return False;
end if;
end loop;
-- All bounded, it seems.
return True;
end Stacks_Bounded;
function Stack_Usage (
Subprogram : Programs.Subprogram_T;
Asserts : Assertion_Set_T)
return Stack_Bounds_T
is
Num_Stacks : constant Natural :=
Programs.Number_Of_Stacks (Programs.Program (Subprogram));
-- The number of stacks in the program.
Subset : constant Assertion_Subset_T :=
Subprogram_Facts_Span_Subsets.Subset (
From => Assertion_Bag_T (Asserts.all),
Filter => Match_Subprogram_Fact_Span'Access,
Param => (
Subprogram => Subprogram,
Model => null,
Facts => +Stack_Usage,
Span => Always));
-- The stack-usage assertions for this Subprogram.
-- Param.Span is irrelevant here.
Usage : Stack_Bounds_T (1 .. Num_Stacks) :=
Default_Stack_Usage (Subprogram);
-- The cumulative (intersected) stack-usage bounds,
-- initialized to the default (non-asserted) bounds.
begin
-- Asserted bounds on usage:
Stack_Bounds.Cumulate (
From => Subset,
Within => Assertion_Bag_T (Asserts.all),
Cumulator => Restrict_Stacks'Access,
Param => (null record),
Total => Usage);
return Usage;
end Stack_Usage;
function Final_Stack_Height (
Subprogram : Programs.Subprogram_T;
Asserts : Assertion_Set_T)
return Stack_Bounds_T
is
Num_Stacks : constant Natural :=
Programs.Number_Of_Stacks (Programs.Program (Subprogram));
-- The number of stacks in the program.
Subset : constant Assertion_Subset_T :=
Subprogram_Facts_Span_Subsets.Subset (
From => Assertion_Bag_T (Asserts.all),
Filter => Match_Subprogram_Fact_Span'Access,
Param => (
Subprogram => Subprogram,
Model => null,
Facts => +Stack_Final,
Span => Always));
-- The assertions on final stack height for this Subprogram.
-- Param.Span is irrelevant here.
Final : Stack_Bounds_T (1 .. Num_Stacks) :=
Default_Final_Stack_Height (Programs.Program (Subprogram));
-- The cumulative (intersected) final stack height bounds,
-- initialized to the default (non-asserted) bounds.
begin
-- Asserted bounds on final height:
Stack_Bounds.Cumulate (
From => Subset,
Within => Assertion_Bag_T (Asserts.all),
Cumulator => Restrict_Stacks'Access,
Param => (null record),
Total => Final);
return Final;
end Final_Stack_Height;
function Subprogram_Enough_For_Time (
Subprogram : Programs.Subprogram_T;
Asserts : Assertion_Set_T)
return Boolean
is
Subset : constant Assertion_Subset_T :=
Subprogram_Facts_Span_Subsets.Subset (
From => Assertion_Bag_T (Asserts.all),
Filter => Match_Subprogram_Fact_Span'Access,
Param => (
Subprogram => Subprogram,
Model => null,
Facts => +Subprogram_Enough_For_Time,
Span => Always));
-- The "[not] enough for time" assertions for this Subprogram.
-- Param.Span is irrelevant here.
Assertion : Assertion_T;
-- One of the Subset assertions.
Final : Boolean := False;
-- The final choice.
-- The default is "not enough for time".
begin
-- Scan and accumulate the assertions:
for S in Subset'Range loop
Assertion := Element (Assertion_Bag_T (Asserts.all), Subset(S));
if S > Subset'First
and then Final /= Assertion.Fact.Enough_For_Time
then
Output.Warning ("Conflicting ""enough for time"" assertions.");
-- TBA display the conflicting assertions.
end if;
Final := Assertion.Fact.Enough_For_Time;
end loop;
-- Return final choice:
return Final;
end Subprogram_Enough_For_Time;
function Program_Has_Property (
Property : Processor.Property_T;
Asserts : Assertion_Set_T)
return Boolean
is
Subset : constant Assertion_Subset_T :=
Part_Property_Subsets.Subset (
From => Assertion_Bag_T (Asserts.all),
Filter => Match_Part_Property'Access,
Param => (
Part => Program,
Property => Property));
-- The global assertions on this Property.
begin
return Subset'Length > 0;
end Program_Has_Property;
function Subprogram_Has_Property (
Property : Processor.Property_T;
Subprogram : Programs.Subprogram_T;
Asserts : Assertion_Set_T)
return Boolean
is
Subset : constant Assertion_Subset_T :=
Subprogram_Property_Subsets.Subset (
From => Assertion_Bag_T (Asserts.all),
Filter => Match_Subprogram_Property'Access,
Param => (
Subprogram => Subprogram,
Model => null,
Property => Property));
-- The assertions on this Property for this Subprogram.
begin
return Subset'Length > 0;
end Subprogram_Has_Property;
function Program_Property (
Property : Processor.Property_T;
Asserts : Assertion_Set_T)
return Storage.Bounds.Interval_T
is
Subset : constant Assertion_Subset_T :=
Part_Property_Subsets.Subset (
From => Assertion_Bag_T (Asserts.all),
Filter => Match_Part_Property'Access,
Param => (
Part => Program,
Property => Property));
-- The global assertions on this Property.
Interval : Storage.Bounds.Interval_T :=
Storage.Bounds.Universal_Interval;
-- The intersection of all bounds from the Subset.
begin
if Subset'Length = 0 then
raise No_Such_Property;
end if;
Value_Bounds.Cumulate (
From => Subset,
Within => Assertion_Bag_T (Asserts.all),
Cumulator => Restrict_Property'Access,
Param => (null record),
Total => Interval);
return Interval;
end Program_Property;
function Subprogram_Property (
Property : Processor.Property_T;
Subprogram : Programs.Subprogram_T;
Asserts : Assertion_Set_T)
return Storage.Bounds.Interval_T
is
Subset : constant Assertion_Subset_T :=
Subprogram_Property_Subsets.Subset (
From => Assertion_Bag_T (Asserts.all),
Filter => Match_Subprogram_Property'Access,
Param => (
Subprogram => Subprogram,
Model => null,
Property => Property));
-- The assertions on this Property in this Subprogram.
Interval : Storage.Bounds.Interval_T :=
Storage.Bounds.Universal_Interval;
-- The intersection of all bounds from the Subset.
begin
if Subset'Length = 0 then
raise No_Such_Property;
end if;
Value_Bounds.Cumulate (
From => Subset,
Within => Assertion_Bag_T (Asserts.all),
Cumulator => Restrict_Property'Access,
Param => (null record),
Total => Interval);
return Interval;
end Subprogram_Property;
--
--- Finding Call_Callee assertions on dynamic calls
--
function Image (
Item : Assertion_Subset_T;
Within : Assertion_Set_T)
return String
--
-- An adapted parameter profile.
--
is
begin
return Image (
Item => Item,
Within => Assertion_Bag_T (Within.all));
end Image;
function Match_Dynamic_Callees (
Assertion : Assertion_T;
Param : Actual_Part_T)
return Boolean
--
-- Whether the Assertion applies to the actual part that is
-- the Param (which is a Call_Dynamic) and moreover the Assertion
-- gives the possible callees of this dynamic call.
--
is
begin
if Assertion.Parts.Kind /= Param.Kind
or Assertion.Fact.Kind /= Call_Callees
then
-- Evidently no match.
return False;
else
if Opt.Trace_Matching then
Output.Trace (
"Matching "
& Image (Param)
& " to callees assertion:");
Text.Put (Assertion);
end if;
return Match (
Part => Param,
Predicate => Assertion.Parts.Predicate,
Goals => No_Goals);
end if;
end Match_Dynamic_Callees;
package Subprogram_Vectors is new Unbounded_Vectors (
Element_Type => Programs.Subprogram_T,
Vector_Type => Programs.Subprogram_List_T,
Initial_Size => 50,
Size_Increment => 50,
Deallocate => Opt.Deallocate);
type Unbounded_Subprogram_List_T
is new Subprogram_Vectors.Unbounded_Vector;
--
-- For collecting callee lists from several Call_Callees facts.
package Callees_Cumulate is new Cumulations (
Result => Unbounded_Subprogram_List_T,
Params => Null_T);
--
-- For collecting callee lists from several Call_Callees facts.
procedure Collect_Callees (
Assertion : in Assertion_T;
Param : in Null_T;
Total : in out Unbounded_Subprogram_List_T)
--
-- Collects the callee lists from all Call_Callees assertions
-- that apply to one dynamic call.
--
is
Index : Positive;
-- The index of a new callee in Total. Not used.
Callees : Programs.Subprogram_List_T renames Assertion.Fact.Callees.all;
-- The asserted list of callees.
begin
for C in Callees'Range loop
Find_Or_Add (
Value => Callees(C),
Vector => Total,
Index => Index);
end loop;
end Collect_Callees;
function Callees (
Call : Flow.Dynamic_Edge_T;
From : Programs.Subprogram_T;
Model : Flow.Computation.Model_Handle_T;
Asserts : Assertion_Set_T)
return Programs.Subprogram_List_T
is
Subset : constant Assertion_Subset_T :=
Actual_Part_Subsets.Subset (
From => Assertion_Bag_T (Asserts.all),
Filter => Match_Dynamic_Callees'Access,
Param => (
Kind => Call_Dynamic,
Subprogram => From,
Model => Model,
Boundable_Call => Call));
-- The callee assertions for this dynamic Call.
Callee_Set : Unbounded_Subprogram_List_T;
-- Collects the callees.
begin
if Opt.Trace_Map then
Output.Trace (
Locus => Flow.Show.Locus (
Edge => Call.all,
Source => Programs.Symbol_Table (From)),
Text => "Assertions applied to dynamic call"
& Output.Field_Separator
& Image (Subset, Asserts));
end if;
Callees_Cumulate.Cumulate (
From => Subset,
Within => Assertion_Bag_T (Asserts.all),
Cumulator => Collect_Callees'Access,
Param => (null record),
Total => Callee_Set);
declare
Callee_List : constant Programs.Subprogram_List_T :=
To_Vector (Callee_Set);
-- The callees as a list.
begin
Erase (Callee_Set);
return Callee_List;
end;
end Callees;
--
--- Finding execution-count assertions on instructions
--
function Global_Or_Local (
Predicate : Part_Predicate_Ref;
Container : Programs.Subprogram_T;
Model : Flow.Computation.Model_Handle_T)
return Boolean
--
-- Whether the Predicate is void (true) or identifies the given
-- subprogram as an immediate container. This is a specialised
-- "matching" function for instruction-repetition assertions
-- applied within a given Container subprogram.
--
is
begin
if Predicate = null
or else Predicate'Length = 0
then
-- A global assertion, valid also within this Subprogram.
return True;
elsif Predicate'Length > 1 then
-- Should never happen, now.
Output.Fault (
Location => "Assertions.Global_Or_Local",
Text => "Complex predicate");
return False;
else
-- The predicate has a single feature.
declare
Feature : Feature_T renames Predicate(Predicate'First);
begin
return Feature.Kind = Within
and then Match (
Part => (
Kind => Subprogram,
Subprogram => Container,
Model => Model),
Parts => Feature.Whole.all,
Goals => No_Goals);
end;
end if;
end Global_Or_Local;
function Instruction_Counts (
Subprogram : Programs.Subprogram_T;
Model : Flow.Computation.Model_Handle_T;
Asserts : Assertion_Set_T)
return Flow.Execution.Node_Count_Bounds_T
is
Subset : constant Assertion_Subset_T :=
Part_Fact_Subsets.Subset (
From => Assertion_Bag_T (Asserts.all),
Filter => Match_Part_Fact'Access,
Param => (
Part => Instruction,
Facts => +Instruction_Executions));
-- All the assertions on the execution count of an instruction,
-- both global and local to any subprogram.
Graph : constant Flow.Graph_T := Programs.Flow_Graph (Subprogram);
-- The flow-graph of the subprogram.
Num_Nodes : constant Positive := Positive (Flow.Max_Node (Graph));
-- The total number of nodes in the Graph.
Result : Flow.Execution.Node_Count_Bounds_T (1 .. Num_Nodes);
Last : Natural := 0;
-- The result will be Result(1 .. Last).
procedure Add_Bound (
Node : in Flow.Node_T;
Bound : in Flow.Execution.Bound_T;
Voided : out Boolean)
--
-- Adds the Bound on this Node to the Result.
-- The Voided parameter shows if the result became a
-- void interval (a contradiction).
--
is
use type Flow.Node_T;
use type Flow.Execution.Bound_T;
N : Positive;
-- The index of the Node in the Result.
Was_Void : Boolean;
-- Whether the node already had a void bound.
begin
-- Find the Node in the Result:
N := 1;
while N <= Last and then Result(N).Node /= Node loop
N := N + 1;
end loop;
if N > Last then
-- The Node is not in the Result yet. Add it.
Last := Last + 1;
Result(Last) := (
Node => Node,
Count => (
Min => 0,
Max => Flow.Execution.Infinite));
N := Last;
end if;
-- Apply the Bound to Result(N).Count:
Was_Void := Flow.Execution.Void (Result(N).Count);
Result(N).Count := Result(N).Count and Bound;
Voided := Flow.Execution.Void (Result(N).Count) and not Was_Void;
end Add_Bound;
procedure Bound_Instruction_Count (
Assertion : in Assertion_T)
--
-- Adds the execution-count bound from this Assertion to the Result.
--
-- Preconditions:
-- Assertion.Parts.Kind = Instruction
-- Assertion.Fact.Kind = Instruction_Executions
--
is
Steps : constant Flow.Step_List_T := Flow.Steps_Containing (
Address => Assertion.Parts.Address,
Within => Graph,
Calls_Too => False);
-- The steps within this Subprogram's flow-graph that
-- model an instruction with the given address, but
-- excluding call steps.
Void : Boolean;
-- Whether the assertion resulted in void (contradictory)
-- bounds on the number of executions of the step.
begin
if Opt.Trace_Map then
for S in Steps'Range loop
Output.Trace (
Locus => Flow.Show.Locus (
Step => Steps(S),
Source => Programs.Symbol_Table (Subprogram)),
Text =>
"Assertion applies to step #"
& Flow.Step_Index_T'Image (Flow.Index (Steps(S)))
& Output.Field_Separator
& Image (Assertion.Source));
end loop;
end if;
if Steps'Length = 1 then
-- Acceptable.
Add_Bound (
Node => Flow.Node_Containing (Steps(Steps'First), Graph),
Bound => Assertion.Fact.Count,
Voided => Void);
if Void then
-- The result is an infeasible constraint, an empty
-- set of execution counts.
if Flow.Execution.Void (Assertion.Fact.Count) then
Output.Warning (
Locus => Own.Locus (Assertion.Source),
Text => "Assertion is a contradiction.");
else
Output.Warning (
Locus => Own.Locus (Assertion.Source),
Text => "Assertion contradicts other assertions.");
end if;
end if;
elsif Steps'Length > 0 then
Output.Error (
"Instruction-repetition assertion applies to several steps"
& Output.Field_Separator
& Image (Assertion.Source));
end if;
end Bound_Instruction_Count;
Assn : Assertion_T;
-- One of the assertions in the Subset.
begin -- Instruction_Counts
for S in Subset'Range loop
Assn := Element (Assertion_Bag_T (Asserts.all), Subset(S));
if Global_Or_Local (
Predicate => Assn.Parts.Predicate,
Container => Subprogram,
Model => Model)
then
-- This assertion applies in this Subprogram.
Bound_Instruction_Count (Assn);
end if;
end loop;
if Opt.Trace_Map then
for R in 1 .. Last loop
Output.Trace (
Locus => Flow.Show.Locus (
Node => Result(R).Node,
Source => Programs.Symbol_Table (Subprogram)),
Text =>
"Asserted execution count for node #"
& Flow.Node_Index_T'Image (Flow.Index (Result(R).Node))
& Output.Field_Separator
& Flow.Execution.Image (Result(R).Count));
end loop;
end if;
return Result(1 .. Last);
end Instruction_Counts;
function Instruction_Role (
Address : Processor.Code_Address_T;
Asserts : Assertion_Set_T)
return Processor.Instruction_Role_T
is
use type Processor.Instruction_Role_T;
Subset : constant Assertion_Subset_T :=
Instruction_Fact_Subsets.Subset (
From => Assertion_Bag_T (Asserts.all),
Filter => Match_Instruction_Fact'Access,
Param => (
Address => Address,
Facts => +Instruction_Role));
-- All the assertions on the role of an instruction,
-- both global and local to any subprogram.
Assn : Assertion_T;
-- One of the assertions in the Subset.
Role : Processor.Instruction_Role_T := Processor.No_Role;
-- The role that is asserted, or No_Role if there are
-- no assertions on this.
begin
for S in Subset'Range loop
Assn := Element (Assertion_Bag_T (Asserts.all), Subset(S));
if Role = Processor.No_Role then
-- This is the first role assertion.
Role := Assn.Fact.Role;
elsif Assn.Fact.Role /= Role then
-- This is a conflicting role assertion.
Output.Warning (
Locus => Own.Locus (Assn.Source),
Text => "Assertion contradicts other assertions.");
exit;
end if;
end loop;
return Role;
end Instruction_Role;
--
--- Mapping applicable assertions to subprogram parts
--
type Loop_Assertions_T is
array (Loops.Loop_Index_T range <>) of Assertion_Subset_Ref;
--
-- The subset of assertions that apply to a given loop, for
-- all the loops in a given subprogram.
type Call_Assertions_T is
array (Programs.Call_Index_T range <>) of Assertion_Subset_Ref;
--
-- The subset of assertions that apply to a given call, for
-- all the calls from a given subprogram.
type Property_Table_Count_T is new Natural;
--
-- The number of property tables in an assertion map.
-- As many tables are constructed as there are distinct "areas"
-- (loops,calls) with property assertions.
subtype Property_Table_Index_T is
Property_Table_Count_T range 1 .. Property_Table_Count_T'Last;
--
-- Identifies one of the property-tables in an assertion map.
type Property_Tables_T is
array (Property_Table_Index_T range <>) of Property_Table_T;
--
-- The property tables in an assertion map.
type Property_Map_T is
array (Flow.Node_Index_T range <>) of Property_Table_Index_T;
--
-- Associates each node in a flow-graph with the relevant property
-- table (tuple), which contains the most locally asserted property
-- values for the node.
type Assertion_Map_Object_T (
Number_Of_Loops : Loops.Loop_Count_T;
Number_Of_Calls : Natural;
Number_Of_Property_Tables : Property_Table_Count_T;
Max_Node_Index : Flow.Node_Index_T)
is record
Set : Assertion_Set_T;
Model : Flow.Computation.Model_Handle_T;
On_Subprogram : Assertion_Subset_Ref;
To_Map : Assertion_Subset_Ref;
On_Loop : Loop_Assertions_T (1 .. Number_Of_Loops);
On_Call : Call_Assertions_T (1 .. Number_Of_Calls);
Property_Tables : Property_Tables_T (1 .. Number_Of_Property_Tables);
Properties : Property_Map_T (1 .. Max_Node_Index);
end record;
--
-- Maps the assertions from a given assertion set to the loops and
-- calls in a given subprogram. The subprogram itself is not
-- recorded here, but its current (context-specific) computation
-- model is.
--
-- Set
-- The underlying assertion set.
-- Model
-- The computation model for the subprogram.
-- On_Subprogram
-- The subset of assertions applicable to the subprogram as a
-- whole (Parts.Kind = Subprogram and the Subprogram matches
-- Parts.Predicate). Global assertions (Parts.Kind = Program)
-- are not included.
-- To_Map
-- The subset of assertions that is applicable for mapping to
-- the loops and calls in this subprogram.
-- On_Loop
-- The subset of assertions applicable to the loop, for each
-- loop in the subprogram.
-- On_Call
-- The subset of assertions applicable to the call, for each
-- call in the subprogram.
-- Property_Tables
-- The set of property tables defined by property assertions
-- that apply to some or all parts (nodes) of the subprogram.
-- Properties
-- The asserted or defaulted property values for the node, for
-- each node in the subprogram's flow-graph.
--
-- Some of the Property_Tables may be unused (at the end of the vector).
-- The Property_Table_Index_T values in Properties will refer only to
-- defined and valid elements in Property_Tables.
package Part_Subsets is new Subsets (Params => Part_Kinds_T);
--
-- Choosing assertion subsets based on the kind of Part the
-- assertion applies to; all kinds of Facts are accepted.
function Part_Property (
Assertion : Assertion_T;
Param : Part_Kinds_T)
return Boolean
--
-- Whether the Assertion states bounds on the value of
-- some property, over some parts of the desired kinds.
--
is
begin
return Param(Assertion.Parts.Kind)
and Assertion.Fact.Kind = Property_Value;
end Part_Property;
procedure Map_Properties (
Subprogram : in Programs.Subprogram_T;
Luups : in Loops.Loops_T;
Map : in out Assertion_Map_Object_T)
--
-- Creates the property map for a subprogram, based on the set of
-- loops and the assertions that are applicable to each loop (as
-- already recorded in the assertion map).
--
is
Next_Table_Index : Property_Table_Index_T := Map.Property_Tables'First;
-- The lowest unused index of a property table in the
-- assertion map.
Initial_Table : Property_Table_T :=
Processor.Properties.Default_Properties (Subprogram);
-- The properties that apply in the subprogram, outside of
-- any loops with more specific assertions.
-- Initialised to default properties, to be updated with
-- global assertions and subprogram-level assertions.
Initial_Index : Property_Table_Index_T;
-- The index of Initial_Table in the map.
Mapped : array (Luups'Range) of Boolean := (others => False);
-- Records which loops have already been mapped.
procedure Apply (
Assertions : in Assertion_Subset_T;
To : in out Property_Table_T)
--
-- Update the property-table with the Property_Values
-- asserted in (some of) the given Assertions.
-- Note that the new bound _replaces_ the tabled bound;
-- there is no _intersection_ of bounds. Thus, a property
-- assertion in a loop can completely override an assertion
-- for the same property from a higher level. However, within
-- the given Assertions subset the bounds on the same property
-- are first intersected, before the To table is updated.
--
is
use type Storage.Bounds.Interval_T;
New_Table : Property_Table_T := (
others => Storage.Bounds.Universal_Interval);
-- The table of new property values from Assertions.
Asserted : array (Processor.Property_T) of Boolean := (
others => False);
-- Whether a given property is asserted in Assertions.
Fact : Fact_T;
-- One of the facts from the Assertions.
begin
-- Compute New_Table from the Assertions, taking
-- the intersection of multiple bounds for the
-- same property:
for A in Assertions'Range loop
Fact := Element (Map.Set.all, Assertions(A)).Fact;
if Fact.Kind = Property_Value then
New_Table(Fact.Property) :=
New_Table(Fact.Property) and Fact.Prop_Value;
Asserted(Fact.Property) := True;
end if;
end loop;
-- Update To with New_Table where Asserted:
for P in Processor.Property_T loop
if Asserted(P) then
To(P) := New_Table(P);
end if;
end loop;
end Apply;
procedure Add_To_Map (
Table : in Property_Table_T;
Index : out Property_Table_Index_T)
--
-- Adds a property table to the assertion map and
-- returns its index.
--
is
begin
Index := Next_Table_Index;
Map.Property_Tables (Index) := Table;
Next_Table_Index := Next_Table_Index;
end Add_To_Map;
procedure Map_Loop (
Root : Loops.Loop_T;
Inherit : Property_Table_T)
--
-- Maps properties into the loop hierarchy rooted at
-- a given loop, with a given set of inherited (outer)
-- property bounds.
-- Applies recursively to nested loops.
--
-- Each loop is given its own property table, whether or not
-- some properties are asserted specifically for that loop.
-- This is a little wasteful, but we don't expect zillions of
-- properties.
--
is
Loop_Table : Property_Table_T := Inherit;
-- The loop-level properties.
-- Initialised to the inherited properties, to be
-- updated with the assertions on the Root loop.
Loop_Table_Index : Property_Table_Index_T;
-- The index of Loop_Table in the map.
Members : constant Flow.Node_Index_List_T :=
Flow.To_Index_List (Loops.Members (Root).all);
-- The indices of the nodes in the Root loop.
-- Includes nodes in nested loops, but would not need to.
Inner_Loops : constant Loops.Loop_List_T :=
Loops.Loops_Contained_In (Loops => Luups, Luup => Root);
-- The loops nested immediately in the Root loop.
begin
-- Apply the assertions on the Root loop:
Apply (
Assertions => Part_Subsets.Subset (
From => Map.On_Loop(Loops.Index (Root)).all,
Within => Assertion_Bag_T (Map.Set.all),
Filter => Part_Property'Access,
Param => +Luup),
To => Loop_Table);
Add_To_Map (
Table => Loop_Table,
Index => Loop_Table_Index);
-- Map the Loop_Table on all member nodes:
for M in Members'Range loop
Map.Properties (Members (M)) := Loop_Table_Index;
end loop;
Mapped (Loops.Loop_Index (Root)) := True;
-- Recurse to inner loops:
for I in Inner_Loops'Range loop
Map_Loop (
Root => Inner_Loops (I),
Inherit => Loop_Table);
end loop;
end Map_Loop;
begin -- Map_Properties
-- Apply global assertions to the Initial table:
Apply (
Assertions => Part_Subsets.Subset (
From => Assertion_Bag_T (Map.Set.all),
Filter => Part_Property'Access,
Param => +Program),
To => Initial_Table);
-- Then apply subprogram-level assertions, overriding
-- the global assertions in the Initial table:
Apply (
Assertions => Part_Subsets.Subset (
From => Map.On_Subprogram.all,
Within => Assertion_Bag_T (Map.Set.all),
Filter => Part_Property'Access,
Param => +Program),
To => Initial_Table);
-- Initialise the property map to the initial table:
Add_To_Map (Table => Initial_Table, Index => Initial_Index);
for N in Map.Properties'Range loop
Map.Properties(N) := Initial_Index;
end loop;
-- Map each loop, recursing from outer loops to inner loops:
for L in reverse Luups'Range loop
if not Mapped (L) then
-- This is an outermost loop.
Map_Loop (
Root => Luups(L),
Inherit => Initial_Table);
-- else
-- The loop is nested in some outermost loop that
-- we already mapped, and so this nested loop was
-- also mapped by the recursive Map_Loop.
end if;
end loop;
end Map_Properties;
function Image (
Item : Assertion_Subset_Ref;
Within : Assertion_Set_T)
return String
--
-- A common parameter profile for the Image of an assertion subset.
--
is
begin
return Image (
Item => Item.all,
Within => Assertion_Bag_T (Within.all));
end Image;
procedure Identify_Assertions (
Model : in Flow.Computation.Model_Handle_T;
Assertion_Set : in Assertion_Set_T;
Assertion_Map : out Assertion_Map_T)
is
Subprogram : constant Programs.Subprogram_T :=
Flow.Computation.Subprogram (Model.all);
-- The subprogram under analysis, for which the computation
-- Model was built.
Luups : constant Loops.Loops_T := Programs.Loops_Of (Subprogram);
-- The loop structure of the Subprogram.
Calls : constant Programs.Call_List_T := Programs.Calls_From (Subprogram);
-- The calls from the Subprogram.
Map : constant Assertion_Map_T := new Assertion_Map_Object_T (
Number_Of_Loops => Luups'Length,
Number_Of_Calls => Calls'Length,
Number_Of_Property_Tables => Luups'Length + 1,
Max_Node_Index =>
Flow.Max_Node (Programs.Flow_Graph (Subprogram)));
--
-- The result.
Object : Assertion_Set_Object_T renames Assertion_Set.all;
-- The assertion set object.
To_Map : constant Assertion_Subset_T :=
To_Be_Mapped (
From => Assertion_Bag_T (Object),
Onto => Subprogram);
-- The assertions that should be mapped.
-- These assertions concern only mappable parts.
procedure Map_Loop (
Luup : in Loops.Loop_T;
Giving : out Assertion_Subset_Ref)
is
Loop_Mark : Output.Nest_Mark_T;
-- The default output locus is for the Luup.
begin
Loop_Mark := Output.Nest (Programs.Locus (Luup, Subprogram));
Giving := new Assertion_Subset_T'(
Actual_Part_Subsets.Subset (
From => Assertion_Bag_T (Object),
Filter => Match_Actual_Part'Access,
Param => (
Kind => Own.Luup,
Subprogram => Subprogram,
Model => Model,
Luup => Luup)));
if Opt.Trace_Map then
Output.Trace (
"Assertions mapped on loop"
& Output.Field_Separator
& Image (Giving, Assertion_Set));
end if;
Output.Unnest (Loop_Mark);
exception
when X : others =>
Output.Exception_Info (
Text => "Assertions.Identify_Assertions.Map_Loop",
Occurrence => X);
Giving := Empty_Subset;
Output.Unnest (Loop_Mark);
end Map_Loop;
procedure Map_Call (
Call : in Programs.Call_T;
Giving : out Assertion_Subset_Ref)
is
Call_Mark : Output.Nest_Mark_T;
-- The default output locus is for the Call.
begin
Call_Mark := Output.Nest (Programs.Locus (Call));
Giving := new Assertion_Subset_T'(
Actual_Part_Subsets.Subset (
From => Assertion_Bag_T (Object),
Filter => Match_Actual_Part'Access,
Param => (
Kind => Call_Static,
Subprogram => Subprogram,
Model => Model,
Call => Call)));
if Opt.Trace_Map then
Output.Trace (
"Assertions mapped on call"
& Output.Field_Separator
& Image (Giving, Assertion_Set));
end if;
Output.Unnest (Call_Mark);
exception
when X : others =>
Output.Exception_Info (
Text => "Assertions.Identify_Assertions.Map_Call",
Occurrence => X);
Giving := Empty_Subset;
Output.Unnest (Call_Mark);
end Map_Call;
begin -- Identify_Assertions
if Opt.Trace_Matching then
Output.Trace ("Assertion matching starts.");
end if;
if Opt.Trace_Map
or Opt.Trace_To_Be_Mapped
then
Output.Trace (
"Assertions to map"
& Output.Field_Separator
& Image (To_Map, Assertion_Set));
end if;
-- Create the assertion map object:
Map.Set := Assertion_Set;
Map.Model := Model;
-- Map the assertions:
Map.On_Subprogram := new Assertion_Subset_T'(
Actual_Part_Subsets.Subset (
From => Assertion_Bag_T (Object),
Filter => Match_Actual_Part'Access,
Param => (
Kind => Own.Subprogram,
Subprogram => Subprogram,
Model => Model)));
if Opt.Trace_Map then
Output.Trace (
"Assertions mapped on subprogram"
& Output.Field_Separator
& Image (Map.On_Subprogram, Assertion_Set));
end if;
if To_Map'Length > 0 then
-- There are some assertions that may be mapped
-- onto loops and calls in this Subprogram.
Map.To_Map := new Assertion_Subset_T'(To_Map);
for L in Luups'Range loop
Map_Loop (
Luup => Luups(L),
Giving => Map.On_Loop(Loops.Index (Luups(L))));
end loop;
for C in Calls'Range loop
Map_Call (
Call => Calls(C),
Giving => Map.On_Call(Programs.Index (Calls(C))));
end loop;
else
-- There are no assertions to map onto the loops
-- and calls in this subprogram.
Map.To_Map := Empty_Subset;
Map.On_Loop := (others => Empty_Subset);
Map.On_Call := (others => Empty_Subset);
end if;
Map_Properties (
Subprogram => Subprogram,
Luups => Luups,
Map => Map.all);
if Opt.Trace_Matching then
Output.Trace ("Assertion matching ends.");
end if;
Assertion_Map := Map;
end Identify_Assertions;
procedure Verify_Map (
Map : in Assertion_Map_T;
Valid : out Boolean)
is
Subprogram : constant Programs.Subprogram_T :=
Flow.Computation.Subprogram (Map.Model.all);
-- The subprogram for which the Map is made.
Luups : constant Loops.Loops_T := Programs.Loops_Of (Subprogram);
-- The loop structure of the Subprogram.
Calls : constant Programs.Call_List_T := Programs.Calls_From (Subprogram);
-- The calls from the Subprogram.
Object : Assertion_Set_Object_T renames Map.Set.all;
-- The assertion set object.
subtype Ass_Index_T is Positive range First (Object) .. Last (Object);
-- The indices of the assertions in the assertion set.
Map_Tally : array (Ass_Index_T) of Natural := (others => 0);
-- The number of parts (loops, calls) to which an assertion
-- is mapped.
procedure Tally (Mapped : Assertion_Subset_T)
--
-- Adds these Mapped assertions to Map_Tally.
--
is
Index : Ass_Index_T;
begin
for M in Mapped'Range loop
Index := Mapped(M);
if not Is_Member (Index, Map.To_Map.all) then
Output.Fault (
Location => "Assertions.Verify.Tally",
Text =>
"Assertion #"
& Ass_Index_T'Image (Index)
& " is not to be mapped.");
end if;
Map_Tally(Index) := Map_Tally(Index) + 1;
end loop;
end Tally;
procedure Warn_Infeasible_Assertions (
Subset : in Assertion_Subset_Ref;
Part : in String;
Locus : in Output.Locus_T)
--
-- Given a Subset of assertions on an infeasible part, at
-- the given program Locus, emits warnings for those assertions
-- that are not simply "repeats 0 times".
--
is
Ass : Assertion_T;
-- An assertion in the Subset.
begin
for S in Subset'Range loop
Ass := Element (Object, Subset(S));
if Ass.Fact.Kind in Count_Fact_Kind_T
and then (Flow.Execution.Is_In (0, Ass.Fact.Count)
or Flow.Execution.Void ( Ass.Fact.Count))
then
-- A Count assertion ("starts" or "repeats") that allows
-- zero executions, which is compatible with an infeasible
-- part, or is void (contradictory) and thus has been
-- reported elsewhere (and may be the reason for the
-- part being marked infeasible).
null;
else
-- Some non-Count assertion, or a Count assertion
-- that does not admit zero counts.
Output.Warning (
Locus => Locus,
Text =>
"Assertion on infeasible "
& Part
& " has no effect"
& Output.Field_Separator
& Image (Ass.Source));
end if;
end loop;
end Warn_Infeasible_Assertions;
function Wrong_Tally (
Tally : Arithmetic.Value_T;
Population : Storage.Bounds.Interval_T)
return String
--
-- Describes the Tally, which is not within the required
-- interval of Population, as too "few" or too "many".
--
is
use Storage.Bounds;
begin
if Tally < Population then return "few";
else return "many";
end if;
end Wrong_Tally;
procedure Wrong_Loop_Tally (
Assertion : in Assertion_T;
Index : in Ass_Index_T;
Tally : in Arithmetic.Value_T;
Population : in Storage.Bounds.Interval_T)
--
-- Emits the error "Loop matches too (many/few) entities",
-- followed by error messages that list the loops that do
-- match this Assertion, which has this Index.
--
is
use type Output.Locus_T;
Ass_Locus : constant Output.Locus_T := Locus (Assertion.Source);
-- The locus of the assertion, in an assertion file.
Num : Natural := 0;
-- Numbers the matching loops.
begin
Output.Error (
Locus => Ass_Locus,
Text =>
"Loop matches too "
& Wrong_Tally (Tally, Population)
& " ("
& Arithmetic.Image (Tally)
& ") entities in "
& Programs.Name (Subprogram));
for L in Luups'Range loop
if Is_Member (Index, Map.On_Loop(Loops.Index (Luups(L))).all)
then
Num := Num + 1;
Output.Error (
Locus => Ass_Locus,
Text =>
"Match"
& Natural'Image (Num)
& Output.Image (Loops.Show.Locus (
Luup => Luups(L),
Within => Programs.Flow_Graph (Subprogram),
Source => Programs.Symbol_Table (Subprogram))));
end if;
end loop;
end Wrong_Loop_Tally;
procedure Wrong_Call_Tally (
Assertion : in Assertion_T;
Index : in Ass_Index_T;
Tally : in Arithmetic.Value_T;
Population : in Storage.Bounds.Interval_T)
--
-- Emits the error "Call matches too (many/few) entities",
-- followed by error messages that list the calls that do
-- match this Assertion, which has this Index.
--
is
Ass_Locus : constant Output.Locus_T := Locus (Assertion.Source);
-- The locus of the assertion, in an assertion file.
Num : Natural := 0;
-- Numbers the matching calls.
begin
Output.Error (
Locus => Ass_Locus,
Text =>
"Call matches too "
& Wrong_Tally (Tally, Population)
& " ("
& Arithmetic.Image (Tally)
& ") entities in "
& Programs.Name (Subprogram));
for C in Calls'Range loop
if Is_Member (Index, Map.On_Call(Programs.Index (Calls(C))).all)
then
Num := Num + 1;
Output.Error (
Locus => Ass_Locus,
Text =>
"Match"
& Natural'Image (Num)
& Output.Field_Separator
& Programs.Image (Calls(C)));
end if;
end loop;
end Wrong_Call_Tally;
procedure Check_Tally (
Assertion : in Assertion_T;
Index : in Ass_Index_T;
Tally : in Arithmetic.Value_T)
--
-- Checks that the actually mapped Tally agrees with
-- the expected population of the Assertion, which has
-- the given Index and refers to a mappable part.
-- If they disagree, sets Valid to False and reports
-- errors.
--
is
Pop : Storage.Bounds.Interval_T renames Assertion.Parts.Population;
begin
if Opt.Trace_Map then
Output.Trace (
Locus => Locus (Assertion.Source),
Text =>
"Assertion #"
& Ass_Index_T'Image (Index)
& " matches "
& Arithmetic.Image (Tally)
& " entities in "
& Programs.Name (Subprogram));
end if;
if not Storage.Bounds.Is_In (Tally, Pop) then
Valid := False;
case Mappable_Part_Kind_T (Assertion.Parts.Kind) is
when Luup =>
Wrong_Loop_Tally (
Assertion => Assertion,
Index => Index,
Tally => Tally,
Population => Pop);
when Call_Static =>
Wrong_Call_Tally (
Assertion => Assertion,
Index => Index,
Tally => Tally,
Population => Pop);
end case;
end if;
end Check_Tally;
Subset : Assertion_Subset_Ref;
-- A subset of assertions mapped onto a loop or call.
Ass_Index : Ass_Index_T;
-- The index of an assertion being checked.
begin -- Verify_Map
Valid := True;
-- Initially we know nothing bad. We may learn some ...
if Map.To_Map'Length > 0 then
-- There are some assertions that may be mapped
-- onto loops and calls in this Subprogram, so there
-- is something to be verified.
-- Tally the number of matching loops and calls, and
-- check for mappings to infeasible loops or calls:
for L in Luups'Range loop
Subset := Map.On_Loop(Loops.Index (Luups(L)));
Tally (Subset.all);
if not Flow.Computation.Is_Feasible (Luups(L), Map.Model.all)
then
Warn_Infeasible_Assertions (
Subset => Subset,
Part => "loop",
Locus => Programs.Locus (Luups(L), Subprogram));
end if;
end loop;
for C in Calls'Range loop
Subset := Map.On_Call(Programs.Index (Calls(C)));
Tally (Subset.all);
if not Flow.Computation.Is_Feasible (Calls(C), Map.Model.all)
then
Warn_Infeasible_Assertions (
Subset => Subset,
Part => "call",
Locus => Programs.Locus (Calls(C)));
end if;
end loop;
-- Check the tallies against the expected populations:
for T in Map.To_Map'Range loop
Ass_Index := Map.To_Map(T);
Check_Tally (
Assertion => Element (Object, Ass_Index),
Index => Ass_Index,
Tally => Arithmetic.Value_T (Map_Tally(Ass_Index)));
end loop;
end if;
end Verify_Map;
function Set (Map : Assertion_Map_T) return Assertion_Set_T
is
begin
return Map.Set;
end Set;
function Subprogram (Map : Assertion_Map_T)
return Programs.Subprogram_T
is
begin
return Flow.Computation.Subprogram (Map.Model.all);
end Subprogram;
function Stack_By (
Index : Programs.Stack_Index_T;
Map : Assertion_Map_T)
return Programs.Stack_T
is
begin
return Programs.Stack_By (
Index => Index,
Within => Programs.Program (Subprogram (Map)));
end Stack_By;
--
--- Applying assertion maps to various program parts under analysis
--
function Loop_Values (
Luup : Loops.Loop_T;
Asserts : Assertion_Map_T)
return Storage.Bounds.Var_Interval_List_T
is
Subset : constant Assertion_Subset_T :=
Part_Fact_Subsets.Subset (
From => Asserts.On_Loop(Loops.Index (Luup)).all,
Within => Assertion_Bag_T (Asserts.Set.all),
Filter => Match_Part_Fact'Access,
Param => (
Part => Own.Luup,
Facts => +Variable_Value));
-- The assertions on variable values for this loop.
begin
return Var_Interval_Projections.Projection (
From => Subset,
Within => Assertion_Bag_T (Asserts.Set.all),
Projector => To_Var_Interval'Access,
Param => (null record));
end Loop_Values;
function Loop_Values (
Luup : Loops.Loop_T;
Point : Processor.Code_Address_T;
Asserts : Assertion_Map_T)
return Storage.Bounds.Cell_Interval_List_T
is
begin
return
Storage.Bounds.Cell_Intervals (
From => Loop_Values (Luup, Asserts),
Point => Point);
end Loop_Values;
function Call_Values (
Call : Programs.Call_T;
Asserts : Assertion_Map_T)
return Storage.Bounds.Var_Interval_List_T
is
Subset : constant Assertion_Subset_T :=
Part_Fact_Subsets.Subset (
From => Asserts.On_Call(Programs.Index (Call)).all,
Within => Assertion_Bag_T (Asserts.Set.all),
Filter => Match_Part_Fact'Access,
Param => (
Part => Call_Static,
Facts => +Variable_Value));
-- The assertions on variable values for this loop.
begin
return Var_Interval_Projections.Projection (
From => Subset,
Within => Assertion_Bag_T (Asserts.Set.all),
Projector => To_Var_Interval'Access,
Param => (null record));
end Call_Values;
function Call_Values (
Call : Programs.Call_T;
Asserts : Assertion_Map_T)
return Storage.Bounds.Cell_Interval_List_T
is
begin
return
Storage.Bounds.Cell_Intervals (
From => Call_Values (Call, Asserts),
Point => Flow.Prime_Address (Programs.Step (Call)));
end Call_Values;
function Loop_Nest_Values (
Luups : Loops.Loop_List_T;
Point : Processor.Code_Address_T;
Asserts : Assertion_Map_T)
return Storage.Bounds.Cell_Interval_List_T
is
use type Storage.Bounds.Cell_Interval_List_T;
begin
if Luups'Length = 0 then
return Storage.Bounds.Empty;
elsif Luups'Length = 1 then
return Loop_Values (
Luup => Luups(Luups'First),
Point => Point,
Asserts => Asserts);
else
-- More than one loop in the list.
return
Loop_Values (
Luup => Luups(Luups'First),
Point => Point,
Asserts => Asserts)
and
Loop_Nest_Values (
Luups => Luups(Luups'First + 1 .. Luups'Last),
Point => Point,
Asserts => Asserts);
end if;
end Loop_Nest_Values;
function Local_Call_Values (
Call : Programs.Call_T;
Asserts : Assertion_Map_T)
return Storage.Bounds.Cell_Interval_List_T
is
use Storage.Bounds;
Caller : constant Programs.Subprogram_T := Programs.Caller (Call);
-- The calling subprogram.
Step : constant Flow.Step_T := Programs.Step (Call);
-- The call step. This is the point at which variables
-- are mapped to cells.
Point : constant Processor.Code_Address_T := Flow.Prime_Address (Step);
-- The point at which variables are mapped to cells.
Sub_Bounds : constant Cell_Interval_List_T :=
Subprogram_Values (Caller, Point, Asserts.Set);
-- Bounds on cells asserted for the calling subprogram, at
-- the point of call.
Outer : constant Loops.Loop_List_T :=
Loops.Containing_Loops (
Loops => Loops.All_Loops (Programs.Loops_Of (Caller)),
Node => Programs.Node (Call));
-- The loops, if any, that contain the Call.
Loop_Bounds : constant Cell_Interval_List_T :=
Loop_Nest_Values (Outer, Point, Asserts);
-- Bounds asserted for the containing loops, at the point of call.
Call_Bounds : constant Cell_Interval_List_T :=
Call_Values (Call, Asserts);
-- Bounds asserted for the call itself.
begin
return Sub_Bounds
and Loop_Bounds
and Call_Bounds;
end Local_Call_Values;
function Loop_Invariants (
Luup : Loops.Loop_T;
Asserts : Assertion_Map_T)
return Storage.Cell_Set_T
is
Subset : constant Assertion_Subset_T :=
Part_Fact_Subsets.Subset (
From => Asserts.On_Loop(Loops.Index (Luup)).all,
Within => Assertion_Bag_T (Asserts.Set.all),
Filter => Match_Part_Fact'Access,
Param => (
Part => Own.Luup,
Facts => +Variable_Invariance));
-- The assertions on invariant variables for this loop.
Invariants : Cell_Set_T;
-- The collected cells, initially none.
begin
Invariant_Cell_Sets.Cumulate (
From => Subset,
Within => Assertion_Bag_T (Asserts.Set.all),
Cumulator => Collect_Cell_Set'Access,
Param => (null record),
Total => Invariants);
return Invariants;
end Loop_Invariants;
function Call_Invariants (
Call : Programs.Call_T;
Asserts : Assertion_Map_T)
return Storage.Cell_Set_T
is
Subset : constant Assertion_Subset_T :=
Part_Fact_Subsets.Subset (
From => Asserts.On_Call(Programs.Index (Call)).all,
Within => Assertion_Bag_T (Asserts.Set.all),
Filter => Match_Part_Fact'Access,
Param => (
Part => Call_Static,
Facts => +Variable_Invariance));
-- The assertions on invariant variables for this call.
Invariants : Cell_Set_T;
-- The collected cells, initially none.
begin
Invariant_Cell_Sets.Cumulate (
From => Subset,
Within => Assertion_Bag_T (Asserts.Set.all),
Cumulator => Collect_Cell_Set'Access,
Param => (null record),
Total => Invariants);
return Invariants;
end Call_Invariants;
function Call_Invariants (
Call : Programs.Call_T;
Asserts : Assertion_Map_T)
return Storage.Cell_List_T
is
begin
return Storage.To_List (Call_Invariants (Call, Asserts));
end Call_Invariants;
function Loop_Start (
Luup : Loops.Loop_T;
Asserts : Assertion_Map_T)
return Flow.Execution.Bound_T
is
Subset : constant Assertion_Subset_T :=
Part_Fact_Subsets.Subset (
From => Asserts.On_Loop(Loops.Index (Luup)).all,
Within => Assertion_Bag_T (Asserts.Set.all),
Filter => Match_Part_Fact'Access,
Param => (
Part => Own.Luup,
Facts => +Loop_Starts));
-- The assertions on the number of starts for this loop.
Count : Flow.Execution.Bound_T := Flow.Execution.Unbounded;
-- The intersection of all start-count assertions.
begin
Count_Bounds.Cumulate (
From => Subset,
Within => Assertion_Bag_T (Asserts.Set.all),
Cumulator => Restrict_Count'Access,
Param => (null record),
Total => Count);
if Flow.Execution.Void (Count) then
Report_Conflict (
Text => "Conflicting assertions on loop starts",
Subset => Subset,
Within => Set (Asserts),
Locus => Programs.Locus (Luup, Subprogram (Asserts)));
end if;
return Count;
end Loop_Start;
function Loop_Count (
Luup : Loops.Loop_T;
Asserts : Assertion_Map_T)
return Flow.Execution.Bound_T
is
Subset : constant Assertion_Subset_T :=
Part_Fact_Subsets.Subset (
From => Asserts.On_Loop(Loops.Index (Luup)).all,
Within => Assertion_Bag_T (Asserts.Set.all),
Filter => Match_Part_Fact'Access,
Param => (
Part => Own.Luup,
Facts => +Loop_Repetitions));
-- The assertions on the number of repetitions for this loop.
Count : Flow.Execution.Bound_T := Flow.Execution.Unbounded;
-- The intersection of all repetition-count assertions.
begin
Count_Bounds.Cumulate (
From => Subset,
Within => Assertion_Bag_T (Asserts.Set.all),
Cumulator => Restrict_Count'Access,
Param => (null record),
Total => Count);
if Flow.Execution.Void (Count) then
Report_Conflict (
Text => "Conflicting assertions on loop repetitions",
Subset => Subset,
Within => Set (Asserts),
Locus => Programs.Locus (Luup, Subprogram (Asserts)));
end if;
return Count;
end Loop_Count;
function Call_Count (
Call : Programs.Call_T;
Asserts : Assertion_Map_T)
return Flow.Execution.Bound_T
is
Subset : constant Assertion_Subset_T :=
Part_Fact_Subsets.Subset (
From => Asserts.On_Call(Programs.Index (Call)).all,
Within => Assertion_Bag_T (Asserts.Set.all),
Filter => Match_Part_Fact'Access,
Param => (
Part => Call_Static,
Facts => +Call_Executions));
-- The assertions on the number of executions of this call.
Count : Flow.Execution.Bound_T := Flow.Execution.Unbounded;
-- The intersection of all execution-count assertions.
begin
Count_Bounds.Cumulate (
From => Subset,
Within => Assertion_Bag_T (Asserts.Set.all),
Cumulator => Restrict_Count'Access,
Param => (null record),
Total => Count);
if Flow.Execution.Void (Count) then
Report_Conflict (
Text => "Conflicting assertions on call executions",
Subset => Subset,
Within => Set (Asserts),
Locus => Programs.Locus (Call));
end if;
return Count;
end Call_Count;
function Call_Time (
Call : Programs.Call_T;
Asserts : Assertion_Map_T)
return Time_Bound_T
is
Subset : constant Assertion_Subset_T :=
Part_Fact_Subsets.Subset (
From => Asserts.On_Call(Programs.Index (Call)).all,
Within => Assertion_Bag_T (Asserts.Set.all),
Filter => Match_Part_Fact'Access,
Param => (
Part => Call_Static,
Facts => +Execution_Time));
-- The assertions on the execution time of this call.
Time : Time_Bound_T := No_Bound;
-- The cumulative (intersected) time bounds.
begin
Execution_Time_Bounds.Cumulate (
From => Subset,
Within => Assertion_Bag_T (Asserts.Set.all),
Cumulator => Restrict_Time'Access,
Param => (null record),
Total => Time);
return Time;
end Call_Time;
function Call_Stack_Usage_Asserted (
Call : Programs.Call_T;
Asserts : Assertion_Map_T)
return Boolean
is
Usage : constant Stack_Bounds_T := Call_Stack_Usage (Call, Asserts);
-- The asserted bounds on stack usage for this Call.
begin
for U in Usage'Range loop
if Storage.Bounds.Known (Usage(U).Max) then
-- This stack has an asserted finite usage.
return True;
end if;
end loop;
-- Zilch.
return False;
end Call_Stack_Usage_Asserted;
function Call_Stack_Usage (
Call : Programs.Call_T;
Asserts : Assertion_Map_T)
return Stack_Bounds_T
is
Num_Stacks : constant Natural :=
Programs.Number_Of_Stacks (Programs.Program (Call));
-- The number of stacks in the program.
Subset : constant Assertion_Subset_T :=
Part_Fact_Subsets.Subset (
From => Asserts.On_Call(Programs.Index (Call)).all,
Within => Assertion_Bag_T (Asserts.Set.all),
Filter => Match_Part_Fact'Access,
Param => (
Part => Call_Static,
Facts => +Stack_Usage));
-- The stack-usage assertions for this Call.
Usage : Stack_Bounds_T (1 .. Num_Stacks) :=
Default_Stack_Usage (Programs.Callee (Call));
-- The cumulative (intersected) stack-usage bounds,
-- initialized to the default (non-asserted) bounds.
begin
-- Asserted bounds on usage:
Stack_Bounds.Cumulate (
From => Subset,
Within => Assertion_Bag_T (Asserts.Set.all),
Cumulator => Restrict_Stacks'Access,
Param => (null record),
Total => Usage);
return Usage;
end Call_Stack_Usage;
function Call_Final_Stack_Height_Asserted (
Call : Programs.Call_T;
Asserts : Assertion_Map_T)
return Boolean
is
use Storage.Bounds;
Final : constant Stack_Bounds_T :=
Call_Final_Stack_Height (Call, Asserts);
-- The asserted bounds on final stack height for this Call.
Stack : Programs.Stack_T;
-- A stack, on which there may be assertions.
begin
for F in Final'Range loop
Stack := Stack_By (Index => F, Map => Asserts);
case Programs.Kind (Stack) is
when Programs.Stable =>
null;
when Programs.Unstable =>
if Known (Final(F)) then
-- There are some asserted bounds on the final
-- height of this stack.
return True;
end if;
end case;
end loop;
-- Zilch.
return False;
end Call_Final_Stack_Height_Asserted;
function Call_Final_Stack_Height (
Call : Programs.Call_T;
Asserts : Assertion_Map_T)
return Stack_Bounds_T
is
Num_Stacks : constant Natural :=
Programs.Number_Of_Stacks (Programs.Program (Call));
-- The number of stacks in the program.
Subset : constant Assertion_Subset_T :=
Part_Fact_Subsets.Subset (
From => Asserts.On_Call(Programs.Index (Call)).all,
Within => Assertion_Bag_T (Asserts.Set.all),
Filter => Match_Part_Fact'Access,
Param => (
Part => Call_Static,
Facts => +Stack_Final));
-- The final-stack-height assertions for this Call.
Final : Stack_Bounds_T (1 .. Num_Stacks) :=
Default_Final_Stack_Height (Programs.Program (Call));
-- The cumulative (intersected) final stack height bounds,
-- initialized to the default (non-asserted) bounds.
begin
Stack_Bounds.Cumulate (
From => Subset,
Within => Assertion_Bag_T (Asserts.Set.all),
Cumulator => Restrict_Stacks'Access,
Param => (null record),
Total => Final);
return Final;
end Call_Final_Stack_Height;
function Loop_Has_Property (
Property : Processor.Property_T;
Luup : Loops.Loop_T;
Asserts : Assertion_Map_T)
return Boolean
is
Subset : constant Assertion_Subset_T :=
Part_Property_Subsets.Subset (
From => Asserts.On_Loop(Loops.Index (Luup)).all,
Within => Assertion_Bag_T (Asserts.Set.all),
Filter => Match_Part_Property'Access,
Param => (
Part => Own.Luup,
Property => Property));
-- The assertions on this Property for this Luup.
begin
return Subset'Length > 0;
end Loop_Has_Property;
function Call_Has_Property (
Property : Processor.Property_T;
Call : Programs.Call_T;
Asserts : Assertion_Map_T)
return Boolean
is
Subset : constant Assertion_Subset_T :=
Part_Property_Subsets.Subset (
From => Asserts.On_Call(Programs.Index (Call)).all,
Within => Assertion_Bag_T (Asserts.Set.all),
Filter => Match_Part_Property'Access,
Param => (
Part => Call_Static,
Property => Property));
-- The assertions on this Property for this Call.
begin
return Subset'Length > 0;
end Call_Has_Property;
function Loop_Property (
Property : Processor.Property_T;
Luup : Loops.Loop_T;
Asserts : Assertion_Map_T)
return Storage.Bounds.Interval_T
is
Subset : constant Assertion_Subset_T :=
Part_Property_Subsets.Subset (
From => Asserts.On_Loop(Loops.Index (Luup)).all,
Within => Assertion_Bag_T (Asserts.Set.all),
Filter => Match_Part_Property'Access,
Param => (
Part => Own.Luup,
Property => Property));
-- The assertions on this Property for this Luup.
Interval : Storage.Bounds.Interval_T :=
Storage.Bounds.Universal_Interval;
-- The intersection of all bounds from the Subset.
begin
if Subset'Length = 0 then
raise No_Such_Property;
end if;
Value_Bounds.Cumulate (
From => Subset,
Within => Assertion_Bag_T (Asserts.Set.all),
Cumulator => Restrict_Property'Access,
Param => (null record),
Total => Interval);
return Interval;
end Loop_Property;
function Call_Property (
Property : Processor.Property_T;
Call : Programs.Call_T;
Asserts : Assertion_Map_T)
return Storage.Bounds.Interval_T
is
Subset : constant Assertion_Subset_T :=
Part_Property_Subsets.Subset (
From => Asserts.On_Call(Programs.Index (Call)).all,
Within => Assertion_Bag_T (Asserts.Set.all),
Filter => Match_Part_Property'Access,
Param => (
Part => Call_Static,
Property => Property));
-- The assertions on this Property for this Call.
Interval : Storage.Bounds.Interval_T :=
Storage.Bounds.Universal_Interval;
-- The intersection of all bounds from the Subset.
begin
if Subset'Length = 0 then
raise No_Such_Property;
end if;
Value_Bounds.Cumulate (
From => Subset,
Within => Assertion_Bag_T (Asserts.Set.all),
Cumulator => Restrict_Property'Access,
Param => (null record),
Total => Interval);
return Interval;
end Call_Property;
function Node_Property (
Property : Processor.Property_T;
Node : Flow.Node_T;
Asserts : Assertion_Map_T)
return Storage.Bounds.Interval_T
is
Table : constant Property_Table_Index_T :=
Asserts.Properties (Flow.Index (Node));
-- The index of the property-table for this node.
begin
return Asserts.Property_Tables (Table) (Property);
end Node_Property;
end Assertions;
|
burratoo/Acton | Ada | 854 | ads | ------------------------------------------------------------------------------------------
-- --
-- OAK COMPONENTS --
-- --
-- OAK --
-- --
-- Copyright (C) 2010-2021, Patrick Bernardi --
-- --
------------------------------------------------------------------------------------------
package Oak with Pure is
end Oak;
|
tum-ei-rcs/StratoX | Ada | 2,357 | ads | ------------------------------------------------------------------------------
-- --
-- SPARK LIBRARY COMPONENTS --
-- --
-- S P A R K . M O D 3 2 _ A R I T H M E T I C _ L E M M A S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2016, AdaCore --
-- --
-- SPARK 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. SPARK 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/>. --
-- --
------------------------------------------------------------------------------
pragma SPARK_Mode;
with SPARK.Mod_Arithmetic_Lemmas;
pragma Elaborate_All (SPARK.Mod_Arithmetic_Lemmas);
with Interfaces;
package SPARK.Mod32_Arithmetic_Lemmas is new
SPARK.Mod_Arithmetic_Lemmas (Interfaces.Unsigned_32);
|
reznikmm/matreshka | Ada | 6,016 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with League.Text_Codecs;
package body FastCGI.Replies is
------------------
-- Error_Stream --
------------------
function Error_Stream
(Self : Reply)
return not null access Ada.Streams.Root_Stream_Type'Class is
begin
return null;
end Error_Stream;
--------------------
-- Has_Raw_Header --
--------------------
function Has_Raw_Header
(Self : Reply;
Name : League.Stream_Element_Vectors.Stream_Element_Vector)
return Boolean is
begin
return False;
end Has_Raw_Header;
----------------
-- Raw_Header --
----------------
function Raw_Header
(Self : Reply;
Name : League.Stream_Element_Vectors.Stream_Element_Vector)
return League.Stream_Element_Vectors.Stream_Element_Vector is
begin
return League.Stream_Element_Vectors.Empty_Stream_Element_Vector;
end Raw_Header;
----------
-- Read --
----------
overriding procedure Read
(Self : in out Output_Stream;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset) is
begin
null;
end Read;
----------------------
-- Set_Content_Type --
----------------------
procedure Set_Content_Type
(Self : in out Reply;
Value : League.Strings.Universal_String)
is
Codec : League.Text_Codecs.Text_Codec
:= League.Text_Codecs.Codec
(League.Strings.To_Universal_String ("utf-8"));
begin
Self.Set_Raw_Header
(Codec.Encode (League.Strings.To_Universal_String ("Content-type")),
Codec.Encode (Value));
end Set_Content_Type;
--------------------
-- Set_Raw_Header --
--------------------
procedure Set_Raw_Header
(Self : in out Reply;
Name : League.Stream_Element_Vectors.Stream_Element_Vector;
Value : League.Stream_Element_Vectors.Stream_Element_Vector) is
begin
Self.Descriptor.Reply_Headers.Include (Name, Value);
end Set_Raw_Header;
------------
-- Stream --
------------
function Stream
(Self : Reply)
return not null access Ada.Streams.Root_Stream_Type'Class is
begin
return Self.Out_Stream;
end Stream;
-----------
-- Write --
-----------
overriding procedure Write
(Self : in out Output_Stream;
Item : Ada.Streams.Stream_Element_Array)
is
use type Ada.Streams.Stream_Element_Array;
Aux : constant Ada.Streams.Stream_Element_Array
:= Self.Descriptor.Stdout.To_Stream_Element_Array;
begin
Self.Descriptor.Stdout :=
League.Stream_Element_Vectors.To_Stream_Element_Vector (Aux & Item);
end Write;
end FastCGI.Replies;
|
stcarrez/ada-awa | Ada | 6,333 | adb | -----------------------------------------------------------------------
-- awa-users-filters -- Specific filters for authentication
-- Copyright (C) 2011, 2012, 2013, 2015, 2019, 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Log.Loggers;
with ASF.Applications.Main;
with Util.Http.Cookies;
with AWA.Services.Contexts;
with AWA.Users.Services;
with AWA.Users.Modules;
with AWA.Users.Principals;
package body AWA.Users.Filters is
use Util.Http;
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Users.Filters");
-- ------------------------------
-- Get the redirection URL from the redirect cookie.
-- ------------------------------
function Get_Redirect_Cookie (Request : in Servlet.Requests.Request'Class) return String is
Cookies : constant Util.Http.Cookies.Cookie_Array := Request.Get_Cookies;
begin
for I in Cookies'Range loop
if Util.Http.Cookies.Get_Name (Cookies (I)) = REDIRECT_COOKIE then
return Util.Http.Cookies.Get_Value (Cookies (I));
end if;
end loop;
return "";
end Get_Redirect_Cookie;
-- ------------------------------
-- Clear the redirect cookie in the response.
-- ------------------------------
procedure Clear_Redirect_Cookie (Request : in Servlet.Requests.Request'Class;
Response : in out Servlet.Responses.Response'Class) is
C : Util.Http.Cookies.Cookie := Util.Http.Cookies.Create (REDIRECT_COOKIE, "");
begin
Util.Http.Cookies.Set_Path (C, Request.Get_Context_Path);
Util.Http.Cookies.Set_Max_Age (C, 0);
Response.Add_Cookie (Cookie => C);
end Clear_Redirect_Cookie;
-- ------------------------------
-- Initialize the filter and configure the redirection URIs.
-- ------------------------------
overriding
procedure Initialize (Filter : in out Auth_Filter;
Config : in Servlet.Core.Filter_Config) is
use ASF.Applications.Main;
Context : constant Servlet.Core.Servlet_Registry_Access
:= Servlet.Core.Get_Servlet_Context (Config);
URI : constant String
:= Servlet.Core.Get_Init_Parameter (Config,
AUTH_FILTER_REDIRECT_PARAM);
begin
Log.Info ("Using login URI: {0}", URI);
if URI = "" then
Log.Error ("The login URI is empty. Redirection to the login page will not work.");
end if;
Filter.Login_URI := To_Unbounded_String (URI);
Servlet.Security.Filters.Auth_Filter (Filter).Initialize (Config);
if Context.all in Application'Class then
Filter.Application := AWA.Applications.Application'Class (Context.all)'Access;
Filter.Set_Permission_Manager (Application'Class (Context.all).Get_Security_Manager);
end if;
end Initialize;
overriding
procedure Authenticate (F : in Auth_Filter;
Request : in out Servlet.Requests.Request'Class;
Response : in out Servlet.Responses.Response'Class;
Session : in Servlet.Sessions.Session;
Auth_Id : in String;
Principal : out ASF.Principals.Principal_Access) is
pragma Unreferenced (Session);
use AWA.Users.Services;
Context : aliased AWA.Services.Contexts.Service_Context;
Manager : User_Service_Access;
P : AWA.Users.Principals.Principal_Access;
begin
-- Setup the service context.
Context.Set_Context (F.Application, null);
Manager := AWA.Users.Modules.Get_User_Manager;
Manager.Authenticate (Cookie => Auth_Id,
Ip_Addr => "",
Principal => P);
Principal := P.all'Access;
-- Setup a new AID cookie with the new connection session.
declare
Cookie : constant String := Manager.Get_Authenticate_Cookie (P.Get_Session_Identifier);
C : Cookies.Cookie := Cookies.Create (Servlet.Security.Filters.AID_COOKIE,
Cookie);
begin
Cookies.Set_Path (C, Request.Get_Context_Path);
Cookies.Set_Max_Age (C, 15 * 86400);
Response.Add_Cookie (Cookie => C);
end;
exception
when Not_Found =>
Principal := null;
end Authenticate;
-- ------------------------------
-- Display or redirects the user to the login page. This procedure is called when
-- the user is not authenticated.
-- ------------------------------
overriding
procedure Do_Login (Filter : in Auth_Filter;
Request : in out Servlet.Requests.Request'Class;
Response : in out Servlet.Responses.Response'Class) is
Login_URI : constant String := To_String (Filter.Login_URI);
Context : constant String := Request.Get_Context_Path;
Path : constant String := Request.Get_Servlet_Path;
URL : constant String := Context & Path & Request.Get_Path_Info;
C : Cookies.Cookie := Cookies.Create (REDIRECT_COOKIE, URL);
begin
Log.Info ("User is not logged, redirecting to {0}", Login_URI);
Cookies.Set_Path (C, Request.Get_Context_Path);
Cookies.Set_Max_Age (C, 86400);
Response.Add_Cookie (Cookie => C);
if Request.Get_Header ("X-Requested-With") = "" then
Response.Send_Redirect (Location => Login_URI);
else
Response.Send_Error (Servlet.Responses.SC_UNAUTHORIZED);
end if;
end Do_Login;
end AWA.Users.Filters;
|
sungyeon/drake | Ada | 506 | ads | pragma License (Unrestricted);
-- runtime unit required by compiler
with System.Unwind;
package System.Standard_Library is
pragma Preelaborate;
-- required for controlled type by compiler (s-stalib.ads)
procedure Abort_Undefer_Direct
with Import,
Convention => Ada,
External_Name => "system__standard_library__abort_undefer_direct";
-- required by compiler (s-stalib.ads)
subtype Exception_Data_Ptr is Unwind.Exception_Data_Access;
end System.Standard_Library;
|
faelys/ada-syslog | Ada | 2,430 | adb | ------------------------------------------------------------------------------
-- Copyright (c) 2014, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with Syslog.Timestamps;
package body Syslog.RFC_5424 is
procedure Build_Message
(Output : out String;
Last : out Natural;
Pri : in Priority;
Message : in String;
Hostname : in String := "-";
App_Name : in String := "-";
Proc_ID : in String := "-";
Msg_ID : in String := "-";
With_Time_Frac : in Boolean := True)
is
begin
Last := Output'First - 1;
declare
Priority_Image : String := Priority'Image (Pri);
begin
pragma Assert (Priority_Image (Priority_Image'First) = ' ');
Priority_Image (Priority_Image'First) := '<';
Append (Output, Last, Priority_Image);
end;
Append (Output, Last, ">1 ");
Append (Output, Last, Timestamps.RFC_5424 (With_Time_Frac));
Append (Output, Last, " ");
Append (Output, Last, Check_Nil (Hostname));
Append (Output, Last, " ");
Append (Output, Last, Check_Nil (App_Name));
Append (Output, Last, " ");
Append (Output, Last, Check_Nil (Proc_ID));
Append (Output, Last, " ");
Append (Output, Last, Check_Nil (Msg_ID));
Append (Output, Last, " ");
Append (Output, Last, Message);
end Build_Message;
end Syslog.RFC_5424;
|
reznikmm/matreshka | Ada | 4,592 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Table.Formula_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Table_Formula_Attribute_Node is
begin
return Self : Table_Formula_Attribute_Node do
Matreshka.ODF_Table.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Table_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Table_Formula_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Formula_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Table_URI,
Matreshka.ODF_String_Constants.Formula_Attribute,
Table_Formula_Attribute_Node'Tag);
end Matreshka.ODF_Table.Formula_Attributes;
|
DrenfongWong/tkm-rpc | Ada | 1,605 | ads | with Tkmrpc.Types;
package Tkmrpc.Contexts.nc
is
type nc_State_Type is
(clean,
-- No nonce present.
invalid,
-- Error state.
created
-- Nonce available.
);
function Get_State
(Id : Types.nc_id_type)
return nc_State_Type
with
Pre => Is_Valid (Id);
function Is_Valid (Id : Types.nc_id_type) return Boolean;
-- Returns True if the given id has a valid value.
function Has_nonce
(Id : Types.nc_id_type;
nonce : Types.nonce_type)
return Boolean
with
Pre => Is_Valid (Id);
-- Returns True if the context specified by id has the given
-- nonce value.
function Has_State
(Id : Types.nc_id_type;
State : nc_State_Type)
return Boolean
with
Pre => Is_Valid (Id);
-- Returns True if the context specified by id has the given
-- State value.
procedure consume
(Id : Types.nc_id_type;
nonce : out Types.nonce_type)
with
Pre => Is_Valid (Id) and then
(Has_State (Id, created)),
Post => Has_State (Id, clean);
procedure create
(Id : Types.nc_id_type;
nonce : Types.nonce_type)
with
Pre => Is_Valid (Id) and then
(Has_State (Id, clean)),
Post => Has_State (Id, created) and
Has_nonce (Id, nonce);
procedure invalidate
(Id : Types.nc_id_type)
with
Pre => Is_Valid (Id),
Post => Has_State (Id, invalid);
procedure reset
(Id : Types.nc_id_type)
with
Pre => Is_Valid (Id),
Post => Has_State (Id, clean);
end Tkmrpc.Contexts.nc;
|
wookey-project/ewok-legacy | Ada | 2,741 | 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 ewok.tasks_shared;
package ewok.ipc
with spark_mode => off
is
MAX_IPC_MSG_SIZE : constant := 128;
ENDPOINTS_POOL_SIZE : constant := 10;
--
-- IPC EndPoints
--
type t_endpoint_state is (
-- IPC endpoint is unused
FREE,
-- IPC endpoint is used and is ready for message passing
READY,
-- send() block until the receiver read the message
WAIT_FOR_RECEIVER);
type t_extended_task_id is
(ID_UNUSED,
ID_APP1,
ID_APP2,
ID_APP3,
ID_APP4,
ID_APP5,
ID_APP6,
ID_APP7,
ANY_APP)
with size => 8;
for t_extended_task_id use
(ID_UNUSED => 0,
ID_APP1 => 1,
ID_APP2 => 2,
ID_APP3 => 3,
ID_APP4 => 4,
ID_APP5 => 5,
ID_APP6 => 6,
ID_APP7 => 7,
ANY_APP => 255);
function to_task_id
(eid : t_extended_task_id) return ewok.tasks_shared.t_task_id;
function to_ext_task_id
(id : ewok.tasks_shared.t_task_id) return t_extended_task_id;
type t_extended_task_id_access is access all t_extended_task_id;
type t_endpoint is record
from : t_extended_task_id;
to : t_extended_task_id;
state : t_endpoint_state;
data : byte_array (1 .. MAX_IPC_MSG_SIZE);
size : unsigned_8;
end record;
type t_endpoint_access is access all t_endpoint;
type t_endpoints is
array (ewok.tasks_shared.t_task_id range <>) of t_endpoint_access;
--
-- Global pool of IPC EndPoints
--
ipc_endpoints : array (1 .. ENDPOINTS_POOL_SIZE) of aliased t_endpoint;
--
-- Functions
--
-- Init IPC endpoints
procedure init_endpoints;
-- Get a free IPC endpoint
procedure get_endpoint
(endpoint_a : out t_endpoint_access;
success : out boolean);
-- Release a used IPC endpoint
procedure release_endpoint
(endpoint_a : in t_endpoint_access);
end ewok.ipc;
|
glencornell/ada-socketcan | Ada | 1,662 | adb | -- MIT License
--
-- Copyright (c) 2021 Glen Cornell <[email protected]>
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
with Sockets.Can;
with Sockets.Can_Frame;
procedure Stream_Writer is
Socket : Sockets.Can.Socket_Type;
Frame : Sockets.Can_Frame.Can_Frame;
Can_Stream : aliased Sockets.Can.Can_Stream;
begin
Socket := Sockets.Can.Open("vcan0");
Sockets.Can.Create_Stream (Can_Stream, Socket);
frame.can_id := 16#123#;
frame.can_dlc := 2;
frame.Data(1) := 16#11#;
frame.Data(2) := 16#22#;
Sockets.Can_Frame.Can_Frame'Write(Can_Stream'Access, Frame);
end Stream_Writer;
|
skordal/cupcake | Ada | 860 | ads | -- The Cupcake GUI Toolkit
-- (c) Kristian Klomsten Skordal 2012 <[email protected]>
-- Report bugs and issues on <http://github.com/skordal/cupcake/issues>
-- vim:ts=3:sw=3:et:si:sta
package Cupcake is
-- Cupcake version:
VERSION_MAJOR : constant := 0;
VERSION_MINOR : constant := 1;
VERSION_REVISION : constant := 0;
-- Exception thrown if the initialization fails:
Initialization_Error : exception;
-- Initializes Cupcake. This must be called before any other functions.
procedure Initialize;
-- Finalizes Cupcake. This must be the last Cupcake procedure called.
procedure Finalize;
-- Runs the main loop:
procedure Enter_Main_Loop;
-- Exits the main loop:
procedure Exit_Main_Loop;
-- Set to true to get debug messages:
Debug_Mode : constant Boolean := true;
end Cupcake;
|
AdaCore/libadalang | Ada | 859 | adb | procedure Iterassoc_Filter is
type R is range 1 .. 5;
type A is array (R) of Float;
X : A := (1.0, 2.0, 3.0, 4.0, 5.0);
M : A := (for I in R when X (I) >= 3.0 => X (I) * X (I));
pragma Test_Statement;
O : A := (for F : Float of X when F >= 3.0 => F * F);
pragma Test_Statement;
P : A := (for F of X when F >= 3.0 => F * F);
pragma Test_Statement;
type AA is array (R, R) of Float;
Q : AA :=
(for I in R when X (I) >= 3.0 =>
(for J in R when X (J) >= 3.0 => X (I) * X (J)));
pragma Test_Statement;
begin
declare
B : Boolean := (for all F of X when F >= 3.0 => F > 4.0);
C : Boolean := (for some I in 1 .. 5 when X (I) >= 3.0 => X (I) > 4.0);
begin
null;
end;
pragma Test_Block;
-- We use Test_Block so that inner ForLoopSpec nodes are also resolved
end Iterassoc_Filter;
|
sungyeon/drake | Ada | 621 | ads | pragma License (Unrestricted);
-- implementation unit specialized for Windows
package System.Synchronous_Objects.Abortable is
pragma Preelaborate;
-- queue
procedure Take (
Object : in out Queue;
Item : out Queue_Node_Access;
Params : Address;
Filter : Queue_Filter;
Aborted : out Boolean);
-- waiting
-- event
procedure Wait (
Object : in out Event;
Aborted : out Boolean);
procedure Wait (
Object : in out Event;
Timeout : Duration;
Value : out Boolean;
Aborted : out Boolean);
end System.Synchronous_Objects.Abortable;
|
MinimSecure/unum-sdk | Ada | 803 | adb | -- Copyright 2008-2019 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with Homonym;
procedure Homonym_Main is
begin
Homonym.Start_Test;
end Homonym_Main;
|
jklmnn/ash | Ada | 142 | ads | package File_Utils is
function Read (File_Name : String) return String;
function Is_Dir (Path : String) return Boolean;
end File_Utils;
|
zhmu/ananas | Ada | 13,165 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- M A K E _ U T I L --
-- --
-- S p e c --
-- --
-- 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. 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. --
-- --
------------------------------------------------------------------------------
-- This package contains various subprograms used by the builders, in
-- particular those subprograms related to build queue management.
with Namet; use Namet;
with Opt;
with Osint;
with Types; use Types;
with GNAT.OS_Lib; use GNAT.OS_Lib;
package Make_Util is
type Fail_Proc is access procedure (S : String);
-- Pointer to procedure which outputs a failure message
-- Root_Environment : Prj.Tree.Environment;
-- The environment coming from environment variables and command line
-- switches. When we do not have an aggregate project, this is used for
-- parsing the project tree. When we have an aggregate project, this is
-- used to parse the aggregate project; the latter then generates another
-- environment (with additional external values and project path) to parse
-- the aggregated projects.
-- Default_Config_Name : constant String := "default.cgpr";
-- Name of the configuration file used by gprbuild and generated by
-- gprconfig by default.
On_Windows : Boolean renames Osint.On_Windows;
-- True when on Windows
Source_Info_Option : constant String := "--source-info=";
-- Switch to indicate the source info file
Subdirs_Option : constant String := "--subdirs=";
-- Switch used to indicate that the real directories (object, exec,
-- library, ...) are subdirectories of those in the project file.
Relocate_Build_Tree_Option : constant String := "--relocate-build-tree";
-- Switch to build out-of-tree. In this context the object, exec and
-- library directories are relocated to the current working directory
-- or the directory specified as parameter to this option.
Unchecked_Shared_Lib_Imports : constant String :=
"--unchecked-shared-lib-imports";
-- Command line switch to allow shared library projects to import projects
-- that are not shared library projects.
Single_Compile_Per_Obj_Dir_Switch : constant String :=
"--single-compile-per-obj-dir";
-- Switch to forbid simultaneous compilations for the same object directory
-- when project files are used.
Create_Map_File_Switch : constant String := "--create-map-file";
-- Switch to create a map file when an executable is linked
No_Exit_Message_Option : constant String := "--no-exit-message";
-- Switch to suppress exit error message when there are compilation
-- failures. This is useful when a tool, such as gnatprove, silently calls
-- the builder and does not want to pollute its output with error messages
-- coming from the builder. This is an internal switch.
Keep_Temp_Files_Option : constant String := "--keep-temp-files";
-- Switch to suppress deletion of temp files created by the builder.
-- Note that debug switch -gnatdn also has this effect.
procedure Add
(Option : String_Access;
To : in out String_List_Access;
Last : in out Natural);
procedure Add
(Option : String;
To : in out String_List_Access;
Last : in out Natural);
-- Add a string to a list of strings
function Create_Name (Name : String) return File_Name_Type;
function Create_Name (Name : String) return Name_Id;
function Create_Name (Name : String) return Path_Name_Type;
-- Get an id for a name
function Base_Name_Index_For
(Main : String;
Main_Index : Int;
Index_Separator : Character) return File_Name_Type;
-- Returns the base name of Main, without the extension, followed by the
-- Index_Separator followed by the Main_Index if it is non-zero.
function Executable_Prefix_Path return String;
-- Return the absolute path parent directory of the directory where the
-- current executable resides, if its directory is named "bin", otherwise
-- return an empty string. When a directory is returned, it is guaranteed
-- to end with a directory separator.
procedure Inform (N : Name_Id := No_Name; Msg : String);
procedure Inform (N : File_Name_Type; Msg : String);
-- Prints out the program name followed by a colon, N and S
procedure Ensure_Absolute_Path
(Switch : in out String_Access;
Parent : String;
Do_Fail : Fail_Proc;
For_Gnatbind : Boolean := False;
Including_Non_Switch : Boolean := True;
Including_RTS : Boolean := False);
-- Do nothing if Switch is an absolute path switch. If relative, fail if
-- Parent is the empty string, otherwise prepend the path with Parent. This
-- subprogram is only used when using project files. If For_Gnatbind is
-- True, consider gnatbind specific syntax for -L (not a path, left
-- unchanged) and -A (path is optional, preceded with "=" if present).
-- If Including_RTS is True, process also switches --RTS=. Do_Fail is
-- called in case of error. Using Osint.Fail might be appropriate.
type Name_Ids is array (Positive range <>) of Name_Id;
No_Names : constant Name_Ids := (1 .. 0 => No_Name);
-- Name_Ids is used for list of language names in procedure Get_Directories
-- below.
function Path_Or_File_Name (Path : Path_Name_Type) return String;
-- Returns a file name if -df is used, otherwise return a path name
function Unit_Index_Of (ALI_File : File_Name_Type) return Int;
-- Find the index of a unit in a source file. Return zero if the file is
-- not a multi-unit source file.
procedure Verbose_Msg
(N1 : Name_Id;
S1 : String;
N2 : Name_Id := No_Name;
S2 : String := "";
Prefix : String := " -> ";
Minimum_Verbosity : Opt.Verbosity_Level_Type := Opt.Low);
procedure Verbose_Msg
(N1 : File_Name_Type;
S1 : String;
N2 : File_Name_Type := No_File;
S2 : String := "";
Prefix : String := " -> ";
Minimum_Verbosity : Opt.Verbosity_Level_Type := Opt.Low);
-- If the verbose flag (Verbose_Mode) is set and the verbosity level is at
-- least equal to Minimum_Verbosity, then print Prefix to standard output
-- followed by N1 and S1. If N2 /= No_Name then N2 is printed after S1. S2
-- is printed last. Both N1 and N2 are printed in quotation marks. The two
-- forms differ only in taking Name_Id or File_Name_Type arguments.
Max_Header_Num : constant := 6150;
type Header_Num is range 0 .. Max_Header_Num;
-- Size for hash table below. The upper bound is an arbitrary value, the
-- value here was chosen after testing to determine a good compromise
-- between speed of access and memory usage.
function Hash (Name : Name_Id) return Header_Num;
function Hash (Name : File_Name_Type) return Header_Num;
function Hash (Name : Path_Name_Type) return Header_Num;
-------------------------
-- Program termination --
-------------------------
procedure Fail_Program
(S : String;
Flush_Messages : Boolean := True);
pragma No_Return (Fail_Program);
-- Terminate program with a message and a fatal status code
procedure Finish_Program
(Exit_Code : Osint.Exit_Code_Type := Osint.E_Success;
S : String := "");
pragma No_Return (Finish_Program);
-- Terminate program, with or without a message, setting the status code
-- according to Fatal. This properly removes all temporary files.
-----------
-- Mains --
-----------
-- Package Mains is used to store the mains specified on the command line
-- and to retrieve them when a project file is used, to verify that the
-- files exist and that they belong to a project file.
-- Mains are stored in a table. An index is used to retrieve the mains
-- from the table.
type Main_Info is record
File : File_Name_Type; -- Always canonical casing
Index : Int := 0;
end record;
No_Main_Info : constant Main_Info := (No_File, 0);
package Mains is
procedure Add_Main (Name : String; Index : Int := 0);
-- Add one main to the table. This is in general used to add the main
-- files specified on the command line. Index is used for multi-unit
-- source files, and indicates which unit in the source is concerned.
procedure Delete;
-- Empty the table
procedure Reset;
-- Reset the cursor to the beginning of the table
procedure Set_Multi_Unit_Index
(Index : Int := 0);
-- If a single main file was defined, this subprogram indicates which
-- unit inside it is the main (case of a multi-unit source files).
-- Errors are raised if zero or more than one main file was defined,
-- and Index is non-zaero. This subprogram is used for the handling
-- of the command line switch.
function Next_Main return String;
function Next_Main return Main_Info;
-- Moves the cursor forward and returns the new current entry. Returns
-- No_Main_Info there are no more mains in the table.
function Number_Of_Mains return Natural;
-- Returns the number of main.
end Mains;
-----------
-- Queue --
-----------
package Queue is
-- The queue of sources to be checked for compilation. There can be a
-- single such queue per application.
type Source_Info is
record
File : File_Name_Type := No_File;
Unit : Unit_Name_Type := No_Unit_Name;
Index : Int := 0;
end record;
-- Information about files stored in the queue.
No_Source_Info : constant Source_Info := (No_File, No_Unit_Name, 0);
procedure Initialize (Force : Boolean := False);
-- Initialize the queue
procedure Remove_Marks;
-- Remove all marks set for the files. This means that the files will be
-- handed to the compiler if they are added to the queue, and is mostly
-- useful when recompiling several executables as the switches may be
-- different and -s may be in use.
function Is_Empty return Boolean;
-- Returns True if the queue is empty
procedure Insert (Source : Source_Info);
function Insert (Source : Source_Info) return Boolean;
-- Insert source in the queue. The second version returns False if the
-- Source was already marked in the queue.
procedure Extract
(Found : out Boolean;
Source : out Source_Info);
-- Get the first source that can be compiled from the queue. If no
-- source may be compiled, sets Found to False. In this case, the value
-- for Source is undefined.
function Size return Natural;
-- Return the total size of the queue, including the sources already
-- extracted.
function Processed return Natural;
-- Return the number of source in the queue that have aready been
-- processed.
function Element (Rank : Positive) return File_Name_Type;
-- Get the file name for element of index Rank in the queue
end Queue;
end Make_Util;
|
reznikmm/matreshka | Ada | 5,350 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision: $ $Date: $
------------------------------------------------------------------------------
package body Configure.Controlled_Tests is
--------------------
-- Disable_Switch --
--------------------
function Disable_Switch (Self : Controlled_Test) return String is
begin
return "--disable-" & Controlled_Test'Class (Self).Name;
end Disable_Switch;
-------------------
-- Enable_Switch --
-------------------
function Enable_Switch (Self : Controlled_Test) return String is
begin
return "--enable-" & Controlled_Test'Class (Self).Name;
end Enable_Switch;
-------------
-- Execute --
-------------
overriding procedure Execute
(Self : in out Controlled_Test;
Arguments : in out Unbounded_String_Vector)
is
Success : Boolean;
begin
if Has_Parameter (Arguments, Self.Disable_Switch) then
Controlled_Test'Class (Self).Drop_Known_Arguments (Arguments);
else
Controlled_Test'Class (Self).Execute (Arguments, Success);
if not Success
and Has_Parameter (Arguments, Self.Enable_Switch)
then
Self.Report_Check
("Support requested by "
& Self.Enable_Switch
& " but failed");
Self.Report_Status ("Exiting");
raise Internal_Error;
end if;
end if;
end Execute;
----------
-- Help --
----------
overriding function Help
(Self : Controlled_Test)
return Unbounded_String_Vector
is
Result : Unbounded_String_Vector
:= Controlled_Test'Class (Self).Nested_Help;
begin
Result.Append
(+" "
& Self.Enable_Switch
& " "
& "enable "
& Controlled_Test'Class (Self).Name
&" support or fail execution");
Result.Append
(+" "
& Self.Disable_Switch
& " "
& "disable "
& Controlled_Test'Class (Self).Name
&" support");
return Result;
end Help;
end Configure.Controlled_Tests;
|
msrLi/portingSources | Ada | 1,126 | adb | -- Copyright 2008-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 Pck; use Pck;
procedure Foo is
type Table is array (Integer range <>) of Integer;
type Matrix is array (1 .. 10, 1 .. 0) of Character;
type Wrapper is record
M : Matrix;
end record;
My_Table : Table (Ident (10) .. Ident (1));
My_Matrix : Wrapper := (M => (others => (others => 'a')));
begin
Do_Nothing (My_Table'Address); -- START
Do_Nothing (My_Matrix'Address);
end Foo;
|
rtoal/enhanced-dining-philosophers | Ada | 1,239 | ads | ------------------------------------------------------------------------------
-- buffers.ads
--
-- A generic package for bounded, blocking FIFO queues (buffers). It exports
-- a proected type called 'Buffer'. Note that the maximum size of any buffer
-- of this type is taken from a single generic package parameter.
--
-- Generic Parameters:
--
-- Item the desired type of the buffer elements.
-- Size the maximum size of a buffer of type Buffer.
--
-- Entries:
--
-- Write (I) write item I to the buffer.
-- Read (I) read into item I from the buffer.
------------------------------------------------------------------------------
generic
type Item is private;
Size: Positive;
package Buffers is
subtype Index is Integer range 0..Size-1;
type Item_Array is array (Index) of Item;
protected type Buffer is
entry Write (I: Item);
entry Read (I: out Item);
private
Data : Item_Array;
Front : Index := 0; -- index of head (when not empty)
Back : Index := 0; -- index of next free slot
Count : Integer range 0..Size := 0; -- number of items currently in
end Buffer;
end Buffers;
|
reznikmm/matreshka | Ada | 5,456 | 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 package that contains model elements that are intended to be reused by
-- other packages. Model libraries are frequently used in conjunction with
-- applied profiles. This is expressed by defining a dependency between a
-- profile and a model library package, or by defining a model library as
-- contained in a profile package. The classes in a model library are not
-- stereotypes and tagged definitions extending the metamodel. A model
-- library is analogous to a class library in some programming languages.
-- When a model library is defined as a part of a profile, it is imported or
-- deleted with the application or removal of the profile. The profile is
-- implicitly applied to its model library. In the other case, when the model
-- library is defined as an external package imported by a profile, the
-- profile requires that the model library be there in the model at the stage
-- of the profile application. The application or the removal of the profile
-- does not affect the presence of the model library elements.
------------------------------------------------------------------------------
limited with AMF.UML.Packages;
package AMF.Standard_Profile_L2.Model_Libraries is
pragma Preelaborate;
type Standard_Profile_L2_Model_Library is limited interface;
type Standard_Profile_L2_Model_Library_Access is
access all Standard_Profile_L2_Model_Library'Class;
for Standard_Profile_L2_Model_Library_Access'Storage_Size use 0;
not overriding function Get_Base_Package
(Self : not null access constant Standard_Profile_L2_Model_Library)
return AMF.UML.Packages.UML_Package_Access is abstract;
-- Getter of ModelLibrary::base_Package.
--
not overriding procedure Set_Base_Package
(Self : not null access Standard_Profile_L2_Model_Library;
To : AMF.UML.Packages.UML_Package_Access) is abstract;
-- Setter of ModelLibrary::base_Package.
--
end AMF.Standard_Profile_L2.Model_Libraries;
|
AdaCore/libadalang | Ada | 68 | adb | procedure Pkg.Baz is
begin
null;
end Pkg.Baz;
pragma Test_Block;
|
reznikmm/matreshka | Ada | 3,669 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Elements;
package ODF.DOM.Table_Odd_Rows_Elements is
pragma Preelaborate;
type ODF_Table_Odd_Rows is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Table_Odd_Rows_Access is
access all ODF_Table_Odd_Rows'Class
with Storage_Size => 0;
end ODF.DOM.Table_Odd_Rows_Elements;
|
optikos/oasis | Ada | 800 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Elements.Type_Definitions;
package Program.Elements.Root_Types is
pragma Pure (Program.Elements.Root_Types);
type Root_Type is
limited interface and Program.Elements.Type_Definitions.Type_Definition;
type Root_Type_Access is access all Root_Type'Class with Storage_Size => 0;
type Root_Type_Text is limited interface;
type Root_Type_Text_Access is access all Root_Type_Text'Class
with Storage_Size => 0;
not overriding function To_Root_Type_Text
(Self : aliased in out Root_Type)
return Root_Type_Text_Access is abstract;
end Program.Elements.Root_Types;
|
Fabien-Chouteau/GESTE | Ada | 3,848 | ads | ------------------------------------------------------------------------------
-- --
-- GESTE --
-- --
-- Copyright (C) 2018 Fabien Chouteau --
-- --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with GESTE.Tile_Bank;
package GESTE.Sprite is
subtype Parent is Layer.Instance;
type Instance (Bank : not null Tile_Bank.Const_Ref;
Init_Frame : Tile_Index)
is new Parent with private;
subtype Class is Instance'Class;
type Ref is access all Class;
type Const_Ref is access constant Class;
procedure Set_Tile (This : in out Instance;
Tile : Tile_Index);
procedure Flip_Vertical (This : in out Instance;
Flip : Boolean := True);
procedure Flip_Horizontal (This : in out Instance;
Flip : Boolean := True);
private
type Instance (Bank : not null Tile_Bank.Const_Ref;
Init_Frame : Tile_Index)
is new Parent with record
Tile : Tile_Index := Init_Frame;
V_Flip : Boolean := False;
H_Flip : Boolean := False;
end record;
overriding
procedure Update_Size (This : in out Instance);
overriding
function Pix (This : Instance; X, Y : Integer) return Output_Color
with Pre => X in 0 .. This.Width - 1 and then Y in 0 .. This.Height - 1;
overriding
function Collides (This : Instance; X, Y : Integer) return Boolean;
end GESTE.Sprite;
|
onedigitallife-net/Byron | Ada | 2,682 | adb | Pragma Ada_2012;
Pragma Assertion_Policy( Check );
With
Lexington.Search,
Ada.Characters.Wide_Wide_Latin_1,
Ada.Strings.Wide_Wide_Maps.Wide_Wide_Constants;
Use
Lexington.Search;
-- Splits TEXT tokens into WHITESPACE and TEXT.
Procedure Lexington.Aux.P1(Data : in out Token_Vector_Pkg.Vector) is
Result : Token_Vector_Pkg.Vector;
-- NOTE: remember Ada.Strings.Wide_Wide_Maps.
use Ada.Strings;
Package L renames Ada.Characters.Wide_Wide_Latin_1;
Package M renames Ada.Strings.Wide_Wide_Maps;
use all type M.Wide_Wide_Character_Set;
NOT_Space : M.Wide_Wide_Character_Set := NOT To_Set( L.Space );
NOT_No_Break_Space : M.Wide_Wide_Character_Set := NOT To_Set( L.No_Break_Space );
Non_Whitespace_Set : M.Wide_Wide_Character_Set :=
M.Wide_Wide_Constants.Graphic_Set and NOT_No_Break_Space and NOT_Space;
Use Lexington.Aux.Token_Pkg;
Begin
For Item of Data loop
if ID(Item) = Text then
declare
Start : Positive;
Stop : Natural:= 0;
Text : Wide_Wide_String renames Lexeme(Item);
begin
SPLITTING:
Loop
Start := Natural'Succ(Stop);
exit when Start > Text'Last;
Stop:= Index(Text, Start, NOT Non_Whitespace_Set);
-- Exit when Stop not in Positive; do clean up.
if Stop not in Positive then
Token_Vector_Pkg.Append
(
Container => Result,
New_Item => Make_Token(
ID => (if Is_In(Text(Start),Non_Whitespace_Set)
then Aux.Text else Aux.Whitespace),
Value => Text(Start..Text'Last))
);
exit;
end if;
PROCESSING:
declare
Subtype Prior is Natural range Start..Natural'Pred(Stop);
Prefix : Wide_Wide_String renames Text( Prior );
begin
if Prefix'Length in Positive then
Token_Vector_Pkg.Append(
Container => Result,
New_Item => Make_Token(Lexington.Aux.Text, Prefix)
);
end if;
Token_Vector_Pkg.Append(
Container => Result,
New_Item => Make_Token(Whitespace, Text(Stop..Stop))
);
End PROCESSING;
End Loop SPLITTING;
end;
else
Result.Append( Item );
end if;
end loop;
Data:= Result;
End Lexington.Aux.P1;
|
twdroeger/ada-awa | Ada | 3,631 | ads | -----------------------------------------------------------------------
-- events-tests -- Unit tests for AWA events
-- Copyright (C) 2012, 2019 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Tests;
with AWA.Tests;
private with Util.Beans.Methods;
package AWA.Events.Services.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new AWA.Tests.Test with null record;
-- Test searching an event name in the definition list.
procedure Test_Find_Event (T : in out Test);
-- Test the Get_Event_Type_Name internal operation.
procedure Test_Get_Event_Name (T : in out Test);
-- Test creation and initialization of event manager.
procedure Test_Initialize (T : in out Test);
-- Test adding an action.
procedure Test_Add_Action (T : in out Test);
-- Test dispatching synchronous event to a global bean.
procedure Test_Dispatch_Synchronous (T : in out Test);
-- Test dispatching event through a fifo queue.
procedure Test_Dispatch_Fifo (T : in out Test);
-- Test dispatching event through a database queue.
procedure Test_Dispatch_Persist (T : in out Test);
-- Test dispatching synchronous event to a dynamic bean (created on demand).
procedure Test_Dispatch_Synchronous_Dyn (T : in out Test);
-- Test dispatching synchronous event to a dynamic bean and raise an exception in the action.
procedure Test_Dispatch_Synchronous_Raise (T : in out Test);
procedure Dispatch_Event (T : in out Test;
Kind : in Event_Index;
Expect_Count : in Natural;
Expect_Prio : in Natural);
private
type Action_Bean is new Util.Beans.Basic.Bean
and Util.Beans.Methods.Method_Bean with record
Count : Natural := 0;
Priority : Integer := 0;
Raise_Exception : Boolean := False;
end record;
type Action_Bean_Access is access all Action_Bean'Class;
-- Get the value identified by the name.
-- If the name cannot be found, the method should return the Null object.
overriding
function Get_Value (From : in Action_Bean;
Name : in String) return Util.Beans.Objects.Object;
-- Set the value identified by the name.
-- If the name cannot be found, the method should raise the No_Value
-- exception.
overriding
procedure Set_Value (From : in out Action_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object);
overriding
function Get_Method_Bindings (From : in Action_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access;
procedure Event_Action (From : in out Action_Bean;
Event : in AWA.Events.Module_Event'Class);
function Create_Action_Bean return Util.Beans.Basic.Readonly_Bean_Access;
end AWA.Events.Services.Tests;
|
reznikmm/matreshka | Ada | 3,847 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.ODF_Elements.Style.Footnote_Sep;
package ODF.DOM.Elements.Style.Footnote_Sep.Internals is
function Create
(Node : Matreshka.ODF_Elements.Style.Footnote_Sep.Style_Footnote_Sep_Access)
return ODF.DOM.Elements.Style.Footnote_Sep.ODF_Style_Footnote_Sep;
function Wrap
(Node : Matreshka.ODF_Elements.Style.Footnote_Sep.Style_Footnote_Sep_Access)
return ODF.DOM.Elements.Style.Footnote_Sep.ODF_Style_Footnote_Sep;
end ODF.DOM.Elements.Style.Footnote_Sep.Internals;
|
AdaCore/gpr | Ada | 28,757 | ads | --
-- Copyright (C) 2019-2023, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-Exception
--
-- Knowledge base manipulations
--
-- This package is mostly intended to be used by GPR2 tools, users intending
-- to simply load the project and explore its contents should not call any
-- of these subprograms directly.
with Ada.Containers.Doubly_Linked_Lists;
with Ada.Containers.Indefinite_Doubly_Linked_Lists;
with Ada.Containers.Indefinite_Holders;
with Ada.Containers.Indefinite_Ordered_Maps;
with Ada.Containers.Indefinite_Hashed_Maps;
with Ada.Containers.Vectors;
with Ada.Strings.Hash;
with Ada.Strings.Unbounded;
with GPR2.Containers;
with GPR2.Environment;
with GPR2.Log;
with GPR2.Path_Name.Set;
with GPR2.Project.Configuration;
with GPR2.Source_Reference;
private with GNAT.Regpat;
package GPR2.KB is
pragma Warnings (Off, "already use-visible");
use Ada.Strings.Unbounded;
pragma Warnings (On, "already use-visible");
type Object is tagged private;
Undefined : constant Object;
function Is_Defined (Self : Object) return Boolean;
-- Returns whether Self is defined
type Flags_Kind is (Compiler_Info, Pedantic, Validation);
type Parsing_Flags is array (Flags_Kind) of Boolean;
-- Describes set of possible option while parsing the knowledge base.
--
-- Compiler_Info indicate whether part of KB related to compilers shall be
-- parsed. This is not needed for target normalization and may be skipped.
--
-- Pedantic expects strict accordance between the expected knowledge
-- base scheme and actual files parsed. When parsing an older knowledge
-- base some attributes may be missing (i.e. canonical target) and that
-- would lead to Invalid raised.
--
-- Validation indicates that the contents of the knowledge base should be
-- first validated with an XSD schema that comes with predefined KB.
Default_Flags : constant Parsing_Flags;
-- Default set of flags used by gprtools
Targetset_Only_Flags : constant Parsing_Flags;
-- Flags used for loading targets definitions only
Default_Location_Error : exception;
-- Raised when default location of the knowledge base cannot be found
function Default_Location return GPR2.Path_Name.Object
with Post => Default_Location'Result.Is_Defined;
-- Returns the default location of the knowledge database. This is based
-- on the location of gprbuild in path. If the default location cannot
-- be found or doesn't exist, raises Default_Location_Error.
function Create
(Flags : Parsing_Flags := Targetset_Only_Flags;
Default_KB : Boolean := True;
Custom_KB : GPR2.Path_Name.Set.Object := GPR2.Path_Name.Set.Empty_Set;
Environment : GPR2.Environment.Object :=
GPR2.Environment.Process_Environment)
return Object
with Post => Create'Result.Is_Defined;
-- Main entry point for creating a KB object.
-- The Flags will indicate how the knowledge base is read.
-- If Default_KB is set, then the default knowledge base embedded in the
-- gpr2 library is used to create the object. Otherwise, an empty knowledge
-- base is used.
-- Custom_KB provides a list of additional directories to use when reading
-- the knowledge base. If Default_KB is set, those directories will be used
-- in conjunction with the default knowledge base, while if Default_Kb is
-- not set, only those locations will be parsed.
function Create
(Location : GPR2.Path_Name.Object;
Flags : Parsing_Flags;
Environment : GPR2.Environment.Object :=
GPR2.Environment.Process_Environment) return Object
with Pre => Location.Is_Defined and then Location.Exists,
Post => Create'Result.Is_Defined;
-- Parses info from the knowledge base available at Location,
-- and store it in memory.
-- Location must be defined and can be either a single file or a directory,
-- in which case all of its contents are parsed (no in-depth recursion).
-- Only information relevant to the current host is parsed.
-- If the base contains incorrect data, resulting object will have error
-- messages.
-- During KB parsing and configuration creation a set of calls to external
-- processes is performed in order to collect info on compilers. Each call
-- is performed only once and cached for efficiency.
function Create
(Content : GPR2.Containers.Value_List;
Flags : Parsing_Flags;
Environment : GPR2.Environment.Object :=
GPR2.Environment.Process_Environment) return Object
with Post => Create'Result.Is_Defined;
-- Same as above, but the knowledge base is parsed from a list of Values
function Create_Default
(Flags : Parsing_Flags;
Environment : GPR2.Environment.Object :=
GPR2.Environment.Process_Environment) return Object
with Post => Create_Default'Result.Is_Defined;
-- Parses default contents of the knowledge base embedded
-- into the library.
function Create_Empty return Object
with Post => Create_Empty'Result.Is_Defined;
-- Creates an empty but initialized knowledge base to be later updated
-- with additional chunks.
procedure Add
(Self : in out Object;
Flags : Parsing_Flags;
Location : GPR2.Path_Name.Object;
Environment : GPR2.Environment.Object :=
GPR2.Environment.Process_Environment)
with Pre => Self.Is_Defined;
procedure Add
(Self : in out Object;
Flags : Parsing_Flags;
Content : Value_Not_Empty;
Environment : GPR2.Environment.Object :=
GPR2.Environment.Process_Environment)
with Pre => Self.Is_Defined;
-- Adds new portions of configuration chunks to the knowledge base
function Has_Messages (Self : Object) return Boolean
with Pre => Self.Is_Defined;
-- Returns whether some messages are present for this knowledge base.
-- Messages can appear during creation of knowledge base object as well as
-- during parsing additional of chunks by Add operation.
-- Messages can be of 3 kinds: warning, error and information.
function Has_Error (Self : Object) return Boolean
with Pre => Self.Is_Defined;
-- Returns whether error messages are present for this knowledge base
function Log_Messages (Self : Object) return Log.Object
with Pre => Self.Is_Defined,
Post => not Self.Has_Messages
or else not Log_Messages'Result.Is_Empty;
-- Returns the Logs (information, warning and error messages) produced by
-- Create and subsequent Add operations for this knowledge base.
function Is_Default_Db (Self : Object) return Boolean;
-- Whether the Knowledge base object is the default KB or was created empty
function Custom_KB_Locations
(Self : Object) return GPR2.Path_Name.Set.Object;
-- The various paths the Knowledge Base object uses to retrieve the kb
-- data.
function Configuration
(Self : in out Object;
Settings : Project.Configuration.Description_Set;
Target : Name_Type;
Messages : in out GPR2.Log.Object;
Fallback : Boolean := False;
Environment : GPR2.Environment.Object :=
GPR2.Environment.Process_Environment)
return Ada.Strings.Unbounded.Unbounded_String
with Pre => Self.Is_Defined,
Post => Configuration'Result /= Null_Unbounded_String
or else Messages.Has_Error or else Self.Has_Error;
-- Creates configuration string
procedure Release (Self : in out Object)
with Pre => Self.Is_Defined,
Post => Self = Undefined;
-- Releases memory associated with the knowledge base
function Normalized_Target
(Self : Object;
Target : Name_Type) return Name_Type
with Pre => Self.Is_Defined;
-- Returns the normalized name for given target. If a given target is not
-- not found in any of the knowledge base target sets, returns "unknown".
function Default_Target return Name_Type;
-- Returns name of the default target which is either specified in
-- <gprtools directory>/share/gprconfig/default_target if it exists, or
-- default host name.
procedure Set_Default_Target (New_Target : Name_Type);
-- Overrides the result returned by Default_Target
function Fallback_List
(Self : Object;
Target : Name_Type) return GPR2.Containers.Name_List
with Pre => Self.Is_Defined,
Post => not Fallback_List'Result.Is_Empty;
-- Gets the list of fallback targets for a given target. The list will
-- contain at least the given target itself.
-----------------------
-- Interactive usage --
-----------------------
type Compiler is private;
-- Describes one of the compilers found on the PATH
No_Compiler : constant Compiler;
type Compiler_Array is array (Positive range <>) of Compiler;
-- List of compilers
No_Compilers : constant Compiler_Array;
procedure Set_Selection (Comp : in out Compiler; Selected : Boolean);
-- Toggles the selection status of a compiler in the list
function Is_Selected (Comp : Compiler) return Boolean;
-- Returns the selection status of the compiler
function Is_Selectable (Comp : Compiler) return Boolean;
-- Returns whether compiler can be selected with the already existing
-- selection.
function Requires_Compiler (Comp : Compiler) return Boolean;
-- Returns whether Compiler is a real compiler or a placeholder
-- for a language that does not require a compiler
function Target (Comp : Compiler) return Name_Type
with Pre => Requires_Compiler (Comp);
-- Returns target of the compiler
function Executable (Comp : Compiler) return Name_Type
with Pre => Requires_Compiler (Comp);
-- Returns executable of the compiler
function Path (Comp : Compiler) return Name_Type
with Pre => Requires_Compiler (Comp);
-- Returns path to the compiler
function Language (Comp : Compiler) return Language_Id;
-- Returns language of the compiler
function Name (Comp : Compiler) return Name_Type
with Pre => Requires_Compiler (Comp);
-- Returns name of the compiler
function Version (Comp : Compiler) return Name_Type
with Pre => Requires_Compiler (Comp);
-- Returns version of the compiler
function Runtime
(Comp : Compiler;
Alternate : Boolean := False) return Optional_Name_Type
with Pre => Requires_Compiler (Comp);
-- Returns runtime of the compiler. When the same runtime gets found twice
-- due to e.g. a symbolic link that matches a regexp in the knowledge base
-- is pointing at another runtime and Alternate is set to True,
-- returns "runtime [alt_runtime]".
function All_Compilers
(Self : in out Object;
Settings : Project.Configuration.Description_Set;
Target : Name_Type;
Messages : in out GPR2.Log.Object;
Environment : GPR2.Environment.Object :=
GPR2.Environment.Process_Environment)
return Compiler_Array;
-- Returns the list of all compilers for given target, or all compilers
-- for any target when "all" is passed as Target.
-- Settings affect the selection status of the compilers, but do not
-- exclude any compilers from the resulting list.
function Configuration
(Self : in out Object;
Selection : Compiler_Array;
Target : Name_Type;
Messages : in out GPR2.Log.Object;
Environment : GPR2.Environment.Object :=
GPR2.Environment.Process_Environment)
return Ada.Strings.Unbounded.Unbounded_String
with Pre => Self.Is_Defined and then Selection'Length > 0,
Post => Configuration'Result /= Null_Unbounded_String
or else Messages.Has_Error;
-- Creates configuration string based on the selected compilers in
-- Selection.
function Known_Compiler_Names (Self : Object) return Unbounded_String;
-- Return a comma-separated list of known compilers
procedure Filter_Compilers_List
(Self : Object;
Compilers : in out Compiler_Array;
For_Target : Name_Type);
-- Based on the currently selected compilers, check which other compilers
-- can or cannot be selected by the user.
-- This is not the case if the resulting selection in Compilers is not a
-- supported config (multiple compilers for the same language, set of
-- compilers explicitly marked as unsupported in the knowledge base,...).
private
use GNAT;
type Targets_Set_Id is range -1 .. Natural'Last;
All_Target_Sets : constant Targets_Set_Id := -1;
Unknown_Targets_Set : constant Targets_Set_Id := 0;
Default_Flags : constant Parsing_Flags :=
(Compiler_Info => True,
Pedantic => True,
Validation => False);
Targetset_Only_Flags : constant Parsing_Flags :=
(Compiler_Info => False,
Pedantic => True,
Validation => False);
package Variables_Maps is new Ada.Containers.Indefinite_Ordered_Maps
(Key_Type => Unbounded_String,
Element_Type => Unbounded_String);
type Compiler is record
Name : Unbounded_String := Null_Unbounded_String;
-- The name of the compiler, as specified in the <name> node of the
-- knowledge base. If Compiler represents a filter as defined on through
-- --config switch, then name can also be the base name of the
-- executable we are looking for. In such a case, it never includes the
-- exec suffix (.exe on Windows)
Executable : Unbounded_String := Null_Unbounded_String;
Target : Unbounded_String := Null_Unbounded_String;
Targets_Set : Targets_Set_Id;
Path : GPR2.Path_Name.Object := GPR2.Path_Name.Undefined;
Base_Name : Unbounded_String := Null_Unbounded_String;
-- Base name of the executable. This does not include the exec suffix
Version : Unbounded_String := Null_Unbounded_String;
Variables : Variables_Maps.Map;
Prefix : Unbounded_String := Null_Unbounded_String;
Runtime : Unbounded_String := Null_Unbounded_String;
Alt_Runtime : Unbounded_String := Null_Unbounded_String;
Runtime_Dir : Unbounded_String := Null_Unbounded_String;
Default_Runtime : Boolean := False;
Any_Runtime : Boolean := False;
Path_Order : Integer;
Language : Language_Id := No_Language;
-- The supported language
Selectable : Boolean := True;
Selected : Boolean := False;
Complete : Boolean := True;
end record;
No_Compiler : constant Compiler :=
(Name => Null_Unbounded_String,
Target => Null_Unbounded_String,
Targets_Set => Unknown_Targets_Set,
Executable => Null_Unbounded_String,
Base_Name => Null_Unbounded_String,
Path => GPR2.Path_Name.Undefined,
Variables => Variables_Maps.Empty_Map,
Version => Null_Unbounded_String,
Prefix => Null_Unbounded_String,
Runtime => Null_Unbounded_String,
Alt_Runtime => Null_Unbounded_String,
Default_Runtime => False,
Any_Runtime => False,
Runtime_Dir => Null_Unbounded_String,
Language => No_Language,
Selectable => False,
Selected => False,
Complete => True,
Path_Order => 0);
No_Compilers : constant Compiler_Array :=
Compiler_Array'(1 .. 0 => No_Compiler);
function Is_Selected (Comp : Compiler) return Boolean is
(Comp.Selected);
function Is_Selectable (Comp : Compiler) return Boolean is
(Comp.Selectable);
function Target (Comp : Compiler) return Name_Type is
(Name_Type (To_String (Comp.Target)));
function Requires_Compiler (Comp : Compiler) return Boolean is
(Comp.Executable /= Null_Unbounded_String);
function Executable (Comp : Compiler) return Name_Type is
(Name_Type (To_String (Comp.Executable)));
function Path (Comp : Compiler) return Name_Type is
(Name_Type (Comp.Path.Dir_Name));
function Language (Comp : Compiler) return Language_Id is
(Comp.Language);
function Name (Comp : Compiler) return Name_Type is
(Name_Type (To_String (Comp.Name)));
function Version (Comp : Compiler) return Name_Type is
(Name_Type (To_String (Comp.Version)));
package Compiler_Lists is new
Ada.Containers.Indefinite_Doubly_Linked_Lists (Compiler);
function Filter_Match
(Self : Object;
Comp : Compiler;
Filter : Compiler) return Boolean;
-- Returns True if Comp match Filter
function "="
(Dummy_Left : Regpat.Pattern_Matcher;
Dummy_Right : Regpat.Pattern_Matcher) return Boolean is (False);
-- Always considers two Pattern_Matchers to be different as there is no way
-- to actually compare them.
package Pattern_Matcher_Holders is new Ada.Containers.Indefinite_Holders
(Regpat.Pattern_Matcher);
subtype Pattern_Matcher_Holder is Pattern_Matcher_Holders.Holder;
type External_Value_Type is (Value_Constant,
Value_Shell,
Value_Directory,
Value_Grep,
Value_Nogrep,
Value_Filter,
Value_Must_Match,
Value_Variable,
Value_Done);
type External_Value_Node (Typ : External_Value_Type := Value_Constant) is
record
case Typ is
when Value_Constant =>
Value : Unbounded_String;
when Value_Shell =>
Command : Unbounded_String;
when Value_Directory =>
Directory : Unbounded_String;
Directory_Group : Integer;
Dir_If_Match : Unbounded_String;
Contents : Pattern_Matcher_Holder;
when Value_Grep =>
Regexp_Re : Pattern_Matcher_Holder;
Group : Natural;
when Value_Nogrep =>
Regexp_No : Pattern_Matcher_Holder;
when Value_Filter =>
Filter : Unbounded_String;
when Value_Must_Match =>
Must_Match : Unbounded_String;
when Value_Variable =>
Var_Name : Unbounded_String;
when Value_Done =>
null;
end case;
end record;
package External_Value_Nodes is
new Ada.Containers.Doubly_Linked_Lists (External_Value_Node);
type External_Value is record
EV : External_Value_Nodes.List;
Sloc : GPR2.Source_Reference.Object;
end record;
Null_External_Value : constant External_Value :=
(EV => External_Value_Nodes.Empty_List,
Sloc => Source_Reference.Undefined);
type Compiler_Description is record
Name : Unbounded_String := Null_Unbounded_String;
Executable : Unbounded_String := Null_Unbounded_String;
Executable_Re : Pattern_Matcher_Holder;
Prefix_Index : Integer := -1;
Target : External_Value;
Version : External_Value;
Variables : External_Value;
Languages : External_Value;
Runtimes : External_Value;
Default_Runtimes : GPR2.Containers.Value_List;
end record;
-- Executable_Re is only set if the name of the <executable> must be
-- taken as a regular expression.
package Compiler_Description_Maps is new
Ada.Containers.Indefinite_Ordered_Maps
(Name_Type, Compiler_Description);
type Compiler_Filter is record
Name : Unbounded_String;
Name_Re : Pattern_Matcher_Holder;
Version : Unbounded_String;
Version_Re : Pattern_Matcher_Holder;
Runtime : Unbounded_String;
Runtime_Re : Pattern_Matcher_Holder;
Language : Language_Id;
end record
with Dynamic_Predicate =>
(Name = Null_Unbounded_String or else not Name_Re.Is_Empty)
and then (Version = Null_Unbounded_String
or else not Version_Re.Is_Empty)
and then (Runtime = Null_Unbounded_String
or else not Runtime_Re.Is_Empty);
-- Representation for a <compiler> node (in <configuration>)
package Compiler_Filter_Lists is new Ada.Containers.Doubly_Linked_Lists
(Compiler_Filter);
type Compilers_Filter is record
Compiler : Compiler_Filter_Lists.List;
Negate : Boolean := False;
end record;
No_Compilers_Filter : constant Compilers_Filter :=
(Compiler => Compiler_Filter_Lists.Empty_List,
Negate => False);
-- a <compilers> filter, that matches if any of its <compiler> child
-- matches.
package Compilers_Filter_Lists is new Ada.Containers.Doubly_Linked_Lists
(Compilers_Filter);
type Double_String is record
Positive_Regexp : Unbounded_String;
Negative_Regexp : Unbounded_String;
end record
with Dynamic_Predicate => Positive_Regexp /= Null_Unbounded_String;
package Double_String_Lists is
new Ada.Containers.Indefinite_Doubly_Linked_Lists (Double_String);
type Configuration_Type is record
Compilers_Filters : Compilers_Filter_Lists.List;
Targets_Filters : Double_String_Lists.List; -- these are regexps
Negate_Targets : Boolean := False;
Config : Unbounded_String;
Sloc : Source_Reference.Object;
Supported : Boolean;
-- Whether the combination of compilers is supported
end record;
package Configuration_Lists is new Ada.Containers.Doubly_Linked_Lists
(Configuration_Type);
package Target_Lists is new Ada.Containers.Indefinite_Doubly_Linked_Lists
(Regpat.Pattern_Matcher);
type Target_Set_Description is record
Name : Unbounded_String;
Patterns : Target_Lists.List;
end record;
subtype Known_Targets_Set_Id
is Targets_Set_Id range 1 .. Targets_Set_Id'Last;
-- Known targets set. They are in the base
package Targets_Set_Vectors is new Ada.Containers.Vectors
(Known_Targets_Set_Id, Target_Set_Description, "=");
package Fallback_Targets_Set_Vectors is new Ada.Containers.Vectors
(Known_Targets_Set_Id, GPR2.Containers.Name_List,
GPR2.Containers.Name_Type_List."=");
type Object is tagged record
Compilers : Compiler_Description_Maps.Map;
No_Compilers : Containers.Language_Set;
Check_Executable_Regexp : Boolean := False;
Configurations : Configuration_Lists.List;
Targets_Sets : Targets_Set_Vectors.Vector;
Fallback_Targets_Sets : Fallback_Targets_Set_Vectors.Vector;
Languages_Known : Containers.Language_Set;
Parsed_Directories : GPR2.Path_Name.Set.Object;
External_Calls_Cache : GPR2.Containers.Name_Value_Map;
Initialized : Boolean := False;
Messages : Log.Object;
Is_Default : Boolean := False;
Schema_File : GPR2.Path_Name.Object :=
GPR2.Path_Name.Undefined;
end record;
-- Check_Executable_Regexp is set to True if at least some of the
-- executable names are specified as regular expressions. In such a case,
-- a slightly slower algorithm is used to search for compilers.
-- No_Compilers is the list of languages that require no compiler, and thus
-- should not be searched on the PATH.
-- Schema_File is relevant when Is_Default id False. In that case the
-- first .xsd file found in the given knowledge base directory is taken
-- as a schema for the knowledge base. The file name is stored to later
-- get access to schema again for validating additional KB chunks.
function Name_As_Directory (Dir : String) return String;
-- Ensures that Dir ends with a directory separator
function Query_Targets_Set
(Self : Object;
Target : Name_Type) return Targets_Set_Id
with Pre => Self.Is_Defined;
-- Gets the target alias set id for a target, or Unknown_Targets_Set_Id if
-- no such target is in the base.
Undefined : constant Object := (others => <>);
function Custom_KB_Locations
(Self : Object) return GPR2.Path_Name.Set.Object is
(Self.Parsed_Directories);
function Has_Error (Self : Object) return Boolean is
(Self.Messages.Has_Error);
function Has_Messages (Self : Object) return Boolean is
(not Self.Messages.Is_Empty);
function Is_Defined (Self : Object) return Boolean is
(Self /= Undefined);
function Is_Default_Db (Self : Object) return Boolean is
(Self.Is_Default);
function Log_Messages (Self : Object) return Log.Object is
(Self.Messages);
Invalid_KB : exception;
-- Raised when an error occurred while parsing the knowledge base
type External_Value_Item is record
Value : Unbounded_String;
Alternate : Unbounded_String;
Extracted_From : Unbounded_String;
end record;
-- Value is the actual value of the <external_value> node.
-- Extracted_From will either be set to Value itself, or when the node is
-- a <directory node> to the full directory, before the regexp match.
-- When the value comes from a <shell> node, Extracted_From is set to the
-- full output of the shell command.
package External_Value_Lists is new Ada.Containers.Doubly_Linked_Lists
(External_Value_Item);
package String_To_External_Value is
new Ada.Containers.Indefinite_Hashed_Maps
(Key_Type => String,
Element_Type => External_Value_Lists.Cursor,
Hash => Ada.Strings.Hash,
Equivalent_Keys => "=",
"=" => External_Value_Lists."=");
procedure Get_External_Value
(Attribute : String;
Value : External_Value;
Comp : Compiler;
Environment : GPR2.Environment.Object;
Split_Into_Words : Boolean := True;
Merge_Same_Dirs : Boolean := False;
Calls_Cache : in out GPR2.Containers.Name_Value_Map;
Messages : in out Log.Object;
Processed_Value : out External_Value_Lists.List;
Ignore_Compiler : out Boolean);
-- Computes the value of Value, depending on its type. When an external
-- command needs to be executed, Path is put first on the PATH environment
-- variable. Results of external command execution are cached for
-- efficiency and are stored/looked up in Calls_Cache.
-- Sets Ignore_Compiler if the value doesn't match its <must_have>
-- regexp.
-- The <filter> node is also taken into account.
-- If Split_Into_Words is true, then the value read from <shell> or as a
-- constant string is further assumed to be a comma-separated or space-
-- separated string, and split.
-- Comparison with Matching is case-insensitive (this is needed for
-- languages, does not matter for versions, is not used for targets)
--
-- If Merge_Same_Dirs is True, then the values that come from a
-- <directory> node will be merged (the last one is kept, other removed) if
-- they point to the same physical directory (after normalizing names).
--
-- This is only for use within a <compiler_description> context.
procedure Get_Words
(Words : String;
Filter : String;
Separator1 : Character;
Separator2 : Character;
Map : out Containers.Value_List;
Allow_Empty_Elements : Boolean);
-- Returns the list of words in Words. Splitting is done on special
-- characters, so as to be compatible with a list of languages or a list of
-- runtimes
-- If Allow_Empty_Elements is false, then empty strings are not stored in
-- the list.
end GPR2.KB;
|
LaplaceKorea/curve25519-spark2014 | Ada | 2,832 | ads | with Big_Integers; use Big_Integers;
with Types ; use Types;
package Construct_Conversion_Array with
SPARK_Mode,
Ghost
is
function Property
(Conversion_Array : Conversion_Array_Type;
J, K : Index_Type)
return Boolean
is
(if J mod 2 = 1 and then K mod 2 = 1
then Conversion_Array (J + K) * (+2)
= Conversion_Array (J) * Conversion_Array (K)
else Conversion_Array (J + K)
= Conversion_Array (J) * Conversion_Array (K));
-- The conversion array has a property that helps to prove
-- the product function. This function verifies the property
-- at index J + K.
--------------------------
-- Functions and lemmas --
--------------------------
function Two_Power (Expon : Natural) return Big_Integer is
((+2) ** Expon);
-- Returns a big integer equal to 2 to the power Expon.
procedure Two_Power_Lemma (A, B : Natural) with
Pre => A <= Natural'Last - B,
Post => Two_Power (A + B) = Two_Power (A) * Two_Power (B);
procedure Two_Power_Lemma (A, B : Natural) is null;
-- Basic property of exponentiation used in proof.
function Exposant (J : Product_Index_Type) return Natural is
(Natural (J) / 2 * 51 + (if J mod 2 = 1 then 26 else 0))
with
Post => Exposant'Result <= Natural (J) * 51;
-- Returns the exposant of 2 at J index of conversion array.
-- (i.e Conversion_Array (J) = Two_Power (Exposant (J)))
procedure Exposant_Lemma (J, K : Index_Type) with
Contract_Cases =>
(J mod 2 = 1 and then K mod 2 = 1 => Exposant (J + K) + 1 = Exposant (J) + Exposant (K),
others => Exposant (J + K) = Exposant (J) + Exposant (K));
procedure Exposant_Lemma (J, K : Index_Type) is null;
-- Specificity of Exposant function, that helps to prove
-- the property.
----------------------------------------------------------------
-- Computation and proof of Conversion array and its property --
----------------------------------------------------------------
function Conversion_Array return Conversion_Array_Type with
Post => (for all J in Index_Type =>
(for all K in Index_Type =>
Property (Conversion_Array'Result, J, K)));
-- Computes the conversion array
procedure Prove_Property (Conversion_Array : Conversion_Array_Type) with
Pre => (for all J in Product_Index_Type => Conversion_Array (J) = Two_Power (Exposant (J))),
Post => (for all L in Index_Type =>
(for all M in Index_Type =>
Property (Conversion_Array, L, M)));
-- Helps to prove the property for all indexes of
-- Conversion_Array. Preconditions states that
-- the input array has the right content.
end Construct_Conversion_Array;
|
SayCV/rtems-addon-packages | Ada | 3,607 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Forms.Field_Types.IPV4_Address --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998-2009,2011 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer, 1996
-- Version Control:
-- $Revision$
-- $Date$
-- Binding Version 01.00
------------------------------------------------------------------------------
with Terminal_Interface.Curses.Aux; use Terminal_Interface.Curses.Aux;
package body Terminal_Interface.Curses.Forms.Field_Types.IPV4_Address is
procedure Set_Field_Type (Fld : Field;
Typ : Internet_V4_Address_Field)
is
function Set_Fld_Type (F : Field := Fld)
return C_Int;
pragma Import (C, Set_Fld_Type, "set_field_type_ipv4");
Res : Eti_Error;
begin
Res := Set_Fld_Type;
if Res /= E_Ok then
Eti_Exception (Res);
end if;
Wrap_Builtin (Fld, Typ);
end Set_Field_Type;
end Terminal_Interface.Curses.Forms.Field_Types.IPV4_Address;
|
AdaCore/training_material | Ada | 342 | ads | package Program_Practice is
type T_Index_Type is range 1 .. 10;
Anonymous_Array : array (T_Index_Type) of Integer :=
(1 => 1, 2 => 3, others => -1);
function Test
(Flag1 : in Boolean;
Flag2 : in Boolean)
return Boolean;
function Test
(Flag : Character)
return Character;
end Program_Practice;
|
reznikmm/matreshka | Ada | 4,107 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Style_Use_Optimal_Row_Height_Attributes;
package Matreshka.ODF_Style.Use_Optimal_Row_Height_Attributes is
type Style_Use_Optimal_Row_Height_Attribute_Node is
new Matreshka.ODF_Style.Abstract_Style_Attribute_Node
and ODF.DOM.Style_Use_Optimal_Row_Height_Attributes.ODF_Style_Use_Optimal_Row_Height_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Use_Optimal_Row_Height_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Style_Use_Optimal_Row_Height_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Style.Use_Optimal_Row_Height_Attributes;
|
RREE/ada-util | Ada | 6,978 | ads | -----------------------------------------------------------------------
-- util-log-appenders -- Log appenders
-- Copyright (C) 2001 - 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 Ada.Calendar;
with Ada.Finalization;
with Util.Properties;
with Util.Strings.Builders;
-- The log <b>Appender</b> will handle the low level operations to write
-- the log content to a file, the console, a database.
package Util.Log.Appenders is
-- The layout type to indicate how to format the message.
-- Unlike Logj4, there is no customizable layout.
type Layout_Type
is (
-- The <b>message</b> layout with only the log message.
-- Ex: "Cannot open file"
MESSAGE,
-- The <b>level-message</b> layout with level and message.
-- Ex: "ERROR: Cannot open file"
LEVEL_MESSAGE,
-- The <b>date-level-message</b> layout with date
-- Ex: "2011-03-04 12:13:34 ERROR: Cannot open file"
DATE_LEVEL_MESSAGE,
-- The <b>full</b> layout with everything (the default).
-- Ex: "2011-03-04 12:13:34 ERROR - my.application - Cannot open file"
FULL);
type Appender (Length : Positive) is
abstract new Ada.Finalization.Limited_Controlled with private;
type Appender_Access is access all Appender'Class;
-- Get the log level that triggers display of the log events
function Get_Level (Self : in Appender) return Level_Type;
-- Set the log level.
procedure Set_Level (Self : in out Appender;
Name : in String;
Properties : in Util.Properties.Manager;
Level : in Level_Type);
procedure Set_Level (Self : in out Appender;
Level : in Level_Type);
-- Set the log layout format.
procedure Set_Layout (Self : in out Appender;
Name : in String;
Properties : in Util.Properties.Manager;
Layout : in Layout_Type);
procedure Set_Layout (Self : in out Appender;
Layout : in Layout_Type);
-- Format the event into a string
function Format (Self : in Appender'Class;
Date : in Ada.Calendar.Time;
Level : in Level_Type;
Logger : in String) return String;
-- Append a log event to the appender. Depending on the log level
-- defined on the appender, the event can be taken into account or
-- ignored.
procedure Append (Self : in out Appender;
Message : in Util.Strings.Builders.Builder;
Date : in Ada.Calendar.Time;
Level : in Level_Type;
Logger : in String) is abstract;
-- Flush the log events.
procedure Flush (Self : in out Appender) is abstract;
-- ------------------------------
-- List appender
-- ------------------------------
-- Write log events to a list of appenders
type List_Appender (Length : Positive) is new Appender with private;
type List_Appender_Access is access all List_Appender'Class;
-- Max number of appenders that can be added to the list.
-- In most cases, 2 or 3 appenders will be used.
MAX_APPENDERS : constant Natural := 10;
overriding
procedure Append (Self : in out List_Appender;
Message : in Util.Strings.Builders.Builder;
Date : in Ada.Calendar.Time;
Level : in Level_Type;
Logger : in String);
-- Flush the log events.
overriding
procedure Flush (Self : in out List_Appender);
-- Add the appender to the list.
procedure Add_Appender (Self : in out List_Appender;
Object : in Appender_Access);
-- Create a list appender and configure it according to the properties
function Create_List_Appender (Name : in String) return List_Appender_Access;
type Appender_List is limited private;
-- Find an appender with a given name from the list of appenders.
-- Returns null if there is no such appender.
function Find_Appender (List : in Appender_List;
Name : in String) return Appender_Access;
-- Add the appender to the list of appenders.
procedure Add_Appender (List : in out Appender_List;
Appender : in Appender_Access);
-- Clear the list of appenders.
procedure Clear (List : in out Appender_List);
type Factory_Access is
access function (Name : in String;
Properties : in Util.Properties.Manager;
Default : in Level_Type) return Appender_Access;
type Appender_Factory;
type Appender_Factory_Access is access all Appender_Factory;
type Appender_Factory (Length : Positive) is limited record
Next_Factory : Appender_Factory_Access;
Factory : Factory_Access;
Name : String (1 .. Length);
end record;
-- Register the factory handler to create an appender instance.
procedure Register (Into : in Appender_Factory_Access;
Name : in String;
Create : in Factory_Access);
-- Create an appender instance with a factory with the given name.
function Create (Name : in String;
Config : in Util.Properties.Manager;
Default : in Level_Type) return Appender_Access;
private
-- ------------------------------
-- Log appender
-- ------------------------------
type Appender (Length : Positive) is abstract
new Ada.Finalization.Limited_Controlled with record
Next : Appender_Access;
Level : Level_Type := INFO_LEVEL;
Layout : Layout_Type := FULL;
Name : String (1 .. Length);
end record;
type Appender_List is limited record
First : Appender_Access;
end record;
type Appender_Array_Access is array (1 .. MAX_APPENDERS) of Appender_Access;
type List_Appender (Length : Positive) is new Appender (Length) with record
Appenders : Appender_Array_Access;
Count : Natural := 0;
end record;
end Util.Log.Appenders;
|
reznikmm/matreshka | Ada | 4,051 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Style_Font_Adornments_Attributes;
package Matreshka.ODF_Style.Font_Adornments_Attributes is
type Style_Font_Adornments_Attribute_Node is
new Matreshka.ODF_Style.Abstract_Style_Attribute_Node
and ODF.DOM.Style_Font_Adornments_Attributes.ODF_Style_Font_Adornments_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Font_Adornments_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Style_Font_Adornments_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Style.Font_Adornments_Attributes;
|
reznikmm/matreshka | Ada | 5,130 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.Utp.Managed_Elements.Collections is
pragma Preelaborate;
package Utp_Managed_Element_Collections is
new AMF.Generic_Collections
(Utp_Managed_Element,
Utp_Managed_Element_Access);
type Set_Of_Utp_Managed_Element is
new Utp_Managed_Element_Collections.Set with null record;
Empty_Set_Of_Utp_Managed_Element : constant Set_Of_Utp_Managed_Element;
type Ordered_Set_Of_Utp_Managed_Element is
new Utp_Managed_Element_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_Utp_Managed_Element : constant Ordered_Set_Of_Utp_Managed_Element;
type Bag_Of_Utp_Managed_Element is
new Utp_Managed_Element_Collections.Bag with null record;
Empty_Bag_Of_Utp_Managed_Element : constant Bag_Of_Utp_Managed_Element;
type Sequence_Of_Utp_Managed_Element is
new Utp_Managed_Element_Collections.Sequence with null record;
Empty_Sequence_Of_Utp_Managed_Element : constant Sequence_Of_Utp_Managed_Element;
private
Empty_Set_Of_Utp_Managed_Element : constant Set_Of_Utp_Managed_Element
:= (Utp_Managed_Element_Collections.Set with null record);
Empty_Ordered_Set_Of_Utp_Managed_Element : constant Ordered_Set_Of_Utp_Managed_Element
:= (Utp_Managed_Element_Collections.Ordered_Set with null record);
Empty_Bag_Of_Utp_Managed_Element : constant Bag_Of_Utp_Managed_Element
:= (Utp_Managed_Element_Collections.Bag with null record);
Empty_Sequence_Of_Utp_Managed_Element : constant Sequence_Of_Utp_Managed_Element
:= (Utp_Managed_Element_Collections.Sequence with null record);
end AMF.Utp.Managed_Elements.Collections;
|
reznikmm/matreshka | Ada | 3,719 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Anim_Audio_Level_Attributes is
pragma Preelaborate;
type ODF_Anim_Audio_Level_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Anim_Audio_Level_Attribute_Access is
access all ODF_Anim_Audio_Level_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Anim_Audio_Level_Attributes;
|
sbksba/Concurrence-LI330 | Ada | 977 | adb | with Ada.Text_IO, Matrice;
use Ada.Text_IO, Matrice;
procedure Test_Matrice_Sure1 is
A : Une_Matrice_Entiere(1..10,1..9);
B : Une_Matrice_Entiere(1..10,1..10);
C : Une_Matrice_Entiere(1..10,1..10);
D : Une_Matrice_Entiere(1..10,1..10);
reponse : character;
begin
Initialiser_Une_Matrice(A);
Initialiser_Une_Matrice(B);
Initialiser_Une_Matrice(D);
Put_line("Que voulez-vous effectuer d'abord : l'addition(a) ou la multiplication(m) ?");
get(reponse);
if (reponse = 'a') then
Put_line("Addition");
C := A + B;
Afficher_Une_Matrice(C);
Put_line("Multiplication");
C := A*D;
Afficher_Une_Matrice(C);
else
Put_line("Multiplication");
C := A*D;
Afficher_Une_Matrice(C);
Put_line("Addition");
C := A + B;
Afficher_Une_Matrice(C);
end if;
exception
when Taille_Non_Compatible_a =>
put_line("la taille des matrice ne permet pas l'operation souhaitee");
end Test_Matrice_Sure1;
|
reznikmm/matreshka | Ada | 4,011 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Table_Grouped_By_Attributes;
package Matreshka.ODF_Table.Grouped_By_Attributes is
type Table_Grouped_By_Attribute_Node is
new Matreshka.ODF_Table.Abstract_Table_Attribute_Node
and ODF.DOM.Table_Grouped_By_Attributes.ODF_Table_Grouped_By_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Table_Grouped_By_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Table_Grouped_By_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Table.Grouped_By_Attributes;
|
AdaCore/libadalang | Ada | 215 | adb | procedure Test is
package Pkg is
Error : exception;
end Pkg;
procedure Foo is
begin
exception
when Pkg.Error =>
null;
end Test;
pragma Test_Block;
begin
null;
end Test;
|
tum-ei-rcs/StratoX | Ada | 5,991 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . R E A L _ T I M E . T I M I N G _ E V E N T S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2005-2014, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
with System.BB.Time;
with System.BB.Protection;
package body Ada.Real_Time.Timing_Events is
procedure Handler_Wrapper
(Event : in out System.BB.Timing_Events.Timing_Event'Class) with
-- This wrapper is needed to make a clean conversion between
-- System.BB.Timing_Events.Timing_Event_Handler and
-- Ada.Real_Time.Timing_Events.Timing_Event_Handler.
Pre =>
-- Timing_Event can only be defined from the type defined in RM D.15
-- Ada.Real_Time.Timing_Events.Timing_Event.
Event in Ada.Real_Time.Timing_Events.Timing_Event;
package SBTE renames System.BB.Timing_Events;
---------------------
-- Handler_Wrapper --
---------------------
procedure Handler_Wrapper
(Event : in out System.BB.Timing_Events.Timing_Event'Class)
is
RT_Event : Timing_Event renames Timing_Event (Event);
-- View conversion on the parameter
Handler : constant Timing_Event_Handler := RT_Event.Real_Handler;
begin
if Handler /= null then
RT_Event.Real_Handler := null;
Handler.all (RT_Event);
end if;
end Handler_Wrapper;
-----------------
-- Set_Handler --
-----------------
procedure Set_Handler
(Event : in out Timing_Event;
At_Time : Time;
Handler : Timing_Event_Handler)
is
BB_Handler : constant System.BB.Timing_Events.Timing_Event_Handler :=
(if Handler = null then null else Handler_Wrapper'Access);
-- Keep a null low-level handler if we are setting a null handler
-- (meaning that we the event is to be cleared as per D.15 par. 11/3).
-- Otherwise, pass the address of the wrapper in charge of executing
-- the actual handler (we need a wrapper because in addition to execute
-- the handler we need to set the handler to null to indicate that it
-- has already been executed).
begin
-- The access to the event must be protected and atomic
System.BB.Protection.Enter_Kernel;
Event.Real_Handler := Handler;
SBTE.Set_Handler (SBTE.Timing_Event (Event),
System.BB.Time.Time (At_Time),
BB_Handler);
System.BB.Protection.Leave_Kernel;
end Set_Handler;
---------------------
-- Current_Handler --
---------------------
function Current_Handler
(Event : Timing_Event) return Timing_Event_Handler
is
Res : Timing_Event_Handler;
begin
-- The access to the event must be protected and atomic
System.BB.Protection.Enter_Kernel;
Res := Event.Real_Handler;
System.BB.Protection.Leave_Kernel;
return Res;
end Current_Handler;
--------------------
-- Cancel_Handler --
--------------------
procedure Cancel_Handler
(Event : in out Timing_Event;
Cancelled : out Boolean)
is
begin
-- The access to the event must be protected and atomic
System.BB.Protection.Enter_Kernel;
SBTE.Cancel_Handler (SBTE.Timing_Event (Event), Cancelled);
Event.Real_Handler := null;
System.BB.Protection.Leave_Kernel;
end Cancel_Handler;
-------------------
-- Time_Of_Event --
-------------------
function Time_Of_Event (Event : Timing_Event) return Time is
Res : Time;
begin
-- The access to the event must be protected and atomic
System.BB.Protection.Enter_Kernel;
Res := Time (SBTE.Time_Of_Event (SBTE.Timing_Event (Event)));
System.BB.Protection.Leave_Kernel;
return Res;
end Time_Of_Event;
end Ada.Real_Time.Timing_Events;
|
sungyeon/drake | Ada | 1,148 | ads | pragma License (Unrestricted);
-- implementation unit specialized for POSIX (Darwin, FreeBSD, or Linux)
package System.Native_Environment_Variables is
pragma Preelaborate;
subtype Cursor is Address;
function Value (Name : String) return String;
function Value (Name : String; Default : String) return String;
function Exists (Name : String) return Boolean;
procedure Set (Name : String; Value : String);
procedure Clear (Name : String);
procedure Clear;
function Has_Element (Position : Cursor) return Boolean;
pragma Inline (Has_Element);
function Name (Position : Cursor) return String;
function Value (Position : Cursor) return String;
Disable_Controlled : constant Boolean := True;
function Get_Block return Address is (Null_Address);
procedure Release_Block (Block : Address) is null;
pragma Inline (Release_Block);
-- [gcc-7] can not skip calling null procedure
function First (Block : Address) return Cursor;
function Next (Block : Address; Position : Cursor) return Cursor;
pragma Inline (First);
pragma Inline (Next);
end System.Native_Environment_Variables;
|
Aldmors/coinapi-sdk | Ada | 20,658 | ads | -- OEML _ REST API
-- This section will provide necessary information about the `CoinAPI OEML REST API` protocol. <br/> This API is also available in the Postman application: <a href=\"https://postman.coinapi.io/\" target=\"_blank\">https://postman.coinapi.io/</a> <br/><br/> Implemented Standards: * [HTTP1.0](https://datatracker.ietf.org/doc/html/rfc1945) * [HTTP1.1](https://datatracker.ietf.org/doc/html/rfc2616) * [HTTP2.0](https://datatracker.ietf.org/doc/html/rfc7540)
--
-- The version of the OpenAPI document: v1
-- Contact: [email protected]
--
-- NOTE: This package is auto generated by OpenAPI-Generator 5.2.1.
-- https://openapi-generator.tech
-- Do not edit the class manually.
with Swagger.Streams;
with Ada.Containers.Vectors;
package .Models is
pragma Style_Checks ("-mr");
type RejectReason_Type is
record
end record;
package RejectReason_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => RejectReason_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in RejectReason_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in RejectReason_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out RejectReason_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out RejectReason_Type_Vectors.Vector);
-- ------------------------------
-- MessageReject object.
-- ------------------------------
type MessageReject_Type is
record
P_Type : Swagger.Nullable_UString;
Reject_Reason : .Models.RejectReason_Type;
Exchange_Id : Swagger.Nullable_UString;
Message : Swagger.Nullable_UString;
Rejected_Message : Swagger.Nullable_UString;
end record;
package MessageReject_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => MessageReject_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in MessageReject_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in MessageReject_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out MessageReject_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out MessageReject_Type_Vectors.Vector);
-- ------------------------------
-- JSON validation error.
-- ------------------------------
type ValidationError_Type is
record
P_Type : Swagger.Nullable_UString;
Title : Swagger.Nullable_UString;
Status : Swagger.Number;
Trace_Id : Swagger.Nullable_UString;
Errors : Swagger.Nullable_UString;
end record;
package ValidationError_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => ValidationError_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in ValidationError_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in ValidationError_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out ValidationError_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out ValidationError_Type_Vectors.Vector);
type OrdType_Type is
record
end record;
package OrdType_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => OrdType_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrdType_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrdType_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrdType_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrdType_Type_Vectors.Vector);
type OrdStatus_Type is
record
end record;
package OrdStatus_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => OrdStatus_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrdStatus_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrdStatus_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrdStatus_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrdStatus_Type_Vectors.Vector);
type OrderCancelAllRequest_Type is
record
Exchange_Id : Swagger.UString;
end record;
package OrderCancelAllRequest_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => OrderCancelAllRequest_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderCancelAllRequest_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderCancelAllRequest_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderCancelAllRequest_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderCancelAllRequest_Type_Vectors.Vector);
type OrderCancelSingleRequest_Type is
record
Exchange_Id : Swagger.UString;
Exchange_Order_Id : Swagger.Nullable_UString;
Client_Order_Id : Swagger.Nullable_UString;
end record;
package OrderCancelSingleRequest_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => OrderCancelSingleRequest_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderCancelSingleRequest_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderCancelSingleRequest_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderCancelSingleRequest_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderCancelSingleRequest_Type_Vectors.Vector);
type OrdSide_Type is
record
end record;
package OrdSide_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => OrdSide_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrdSide_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrdSide_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrdSide_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrdSide_Type_Vectors.Vector);
type TimeInForce_Type is
record
end record;
package TimeInForce_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => TimeInForce_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in TimeInForce_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in TimeInForce_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out TimeInForce_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out TimeInForce_Type_Vectors.Vector);
type OrderNewSingleRequest_Type is
record
Exchange_Id : Swagger.UString;
Client_Order_Id : Swagger.UString;
Symbol_Id_Exchange : Swagger.Nullable_UString;
Symbol_Id_Coinapi : Swagger.Nullable_UString;
Amount_Order : Swagger.Number;
Price : Swagger.Number;
Side : .Models.OrdSide_Type;
Order_Type : .Models.OrdType_Type;
Time_In_Force : .Models.TimeInForce_Type;
Expire_Time : Swagger.Nullable_Date;
Exec_Inst : Swagger.UString_Vectors.Vector;
end record;
package OrderNewSingleRequest_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => OrderNewSingleRequest_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderNewSingleRequest_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderNewSingleRequest_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderNewSingleRequest_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderNewSingleRequest_Type_Vectors.Vector);
-- ------------------------------
-- Relay fill information on working orders.
-- ------------------------------
type Fills_Type is
record
Time : Swagger.Nullable_Date;
Price : Swagger.Number;
Amount : Swagger.Number;
end record;
package Fills_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Fills_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Fills_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Fills_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Fills_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Fills_Type_Vectors.Vector);
type OrderExecutionReport_Type is
record
Exchange_Id : Swagger.UString;
Client_Order_Id : Swagger.UString;
Symbol_Id_Exchange : Swagger.Nullable_UString;
Symbol_Id_Coinapi : Swagger.Nullable_UString;
Amount_Order : Swagger.Number;
Price : Swagger.Number;
Side : .Models.OrdSide_Type;
Order_Type : .Models.OrdType_Type;
Time_In_Force : .Models.TimeInForce_Type;
Expire_Time : Swagger.Nullable_Date;
Exec_Inst : Swagger.UString_Vectors.Vector;
Client_Order_Id_Format_Exchange : Swagger.UString;
Exchange_Order_Id : Swagger.Nullable_UString;
Amount_Open : Swagger.Number;
Amount_Filled : Swagger.Number;
Avg_Px : Swagger.Number;
Status : .Models.OrdStatus_Type;
Status_History : Swagger.UString_Vectors.Vector_Vectors.Vector;
Error_Message : Swagger.Nullable_UString;
Fills : .Models.Fills_Type_Vectors.Vector;
end record;
package OrderExecutionReport_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => OrderExecutionReport_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderExecutionReport_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderExecutionReport_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderExecutionReport_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderExecutionReport_Type_Vectors.Vector);
type OrderExecutionReportAllOf_Type is
record
Client_Order_Id_Format_Exchange : Swagger.UString;
Exchange_Order_Id : Swagger.Nullable_UString;
Amount_Open : Swagger.Number;
Amount_Filled : Swagger.Number;
Avg_Px : Swagger.Number;
Status : .Models.OrdStatus_Type;
Status_History : Swagger.UString_Vectors.Vector_Vectors.Vector;
Error_Message : Swagger.Nullable_UString;
Fills : .Models.Fills_Type_Vectors.Vector;
end record;
package OrderExecutionReportAllOf_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => OrderExecutionReportAllOf_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderExecutionReportAllOf_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in OrderExecutionReportAllOf_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderExecutionReportAllOf_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out OrderExecutionReportAllOf_Type_Vectors.Vector);
type BalanceData_Type is
record
Asset_Id_Exchange : Swagger.Nullable_UString;
Asset_Id_Coinapi : Swagger.Nullable_UString;
Balance : double;
Available : double;
Locked : double;
Last_Updated_By : Swagger.Nullable_UString;
Rate_Usd : double;
Traded : double;
end record;
package BalanceData_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => BalanceData_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in BalanceData_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in BalanceData_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out BalanceData_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out BalanceData_Type_Vectors.Vector);
type Balance_Type is
record
Exchange_Id : Swagger.Nullable_UString;
Data : .Models.BalanceData_Type_Vectors.Vector;
end record;
package Balance_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Balance_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Balance_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Balance_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Balance_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Balance_Type_Vectors.Vector);
type Position_Type is
record
Exchange_Id : Swagger.Nullable_UString;
Data : .Models.PositionData_Type_Vectors.Vector;
end record;
package Position_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => Position_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Position_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in Position_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Position_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out Position_Type_Vectors.Vector);
type PositionData_Type is
record
Symbol_Id_Exchange : Swagger.Nullable_UString;
Symbol_Id_Coinapi : Swagger.Nullable_UString;
Avg_Entry_Price : Swagger.Number;
Quantity : Swagger.Number;
Side : .Models.OrdSide_Type;
Unrealized_Pnl : Swagger.Number;
Leverage : Swagger.Number;
Cross_Margin : Swagger.Nullable_Boolean;
Liquidation_Price : Swagger.Number;
Raw_Data : Swagger.Object;
end record;
package PositionData_Type_Vectors is
new Ada.Containers.Vectors (Index_Type => Positive,
Element_Type => PositionData_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in PositionData_Type);
procedure Serialize (Into : in out Swagger.Streams.Output_Stream'Class;
Name : in String;
Value : in PositionData_Type_Vectors.Vector);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out PositionData_Type);
procedure Deserialize (From : in Swagger.Value_Type;
Name : in String;
Value : out PositionData_Type_Vectors.Vector);
end .Models;
|
AdaCore/libadalang | Ada | 174 | adb | procedure Test is
package Pkg is
type E is ('A', B);
end Pkg;
use Pkg;
begin
if Pkg.'A' = B then
null;
end if;
pragma Test_Statement;
end Test;
|
reznikmm/matreshka | Ada | 3,669 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Elements;
package ODF.DOM.Table_Deletion_Elements is
pragma Preelaborate;
type ODF_Table_Deletion is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Table_Deletion_Access is
access all ODF_Table_Deletion'Class
with Storage_Size => 0;
end ODF.DOM.Table_Deletion_Elements;
|
reznikmm/matreshka | Ada | 4,570 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
private package Matreshka.Internals.Text_Codecs.KOI8R is
pragma Preelaborate;
-------------------------
-- KOI8R_Decoder --
-------------------------
type KOI8R_Decoder is new Abstract_Decoder with private;
overriding function Is_Error (Self : KOI8R_Decoder) return Boolean;
overriding function Is_Mailformed
(Self : KOI8R_Decoder) return Boolean;
overriding procedure Decode_Append
(Self : in out KOI8R_Decoder;
Data : Ada.Streams.Stream_Element_Array;
String : in out Matreshka.Internals.Strings.Shared_String_Access);
function Decoder (Mode : Decoder_Mode) return Abstract_Decoder'Class;
-------------------------
-- KOI8R_Encoder --
-------------------------
type KOI8R_Encoder is new Abstract_Encoder with private;
overriding procedure Encode
(Self : in out KOI8R_Encoder;
String : not null Matreshka.Internals.Strings.Shared_String_Access;
Buffer : out MISEV.Shared_Stream_Element_Vector_Access);
function Encoder return Abstract_Encoder'Class;
private
type KOI8R_Decoder is new Abstract_Decoder with null record;
type KOI8R_Encoder is new Abstract_Encoder with null record;
end Matreshka.Internals.Text_Codecs.KOI8R;
|
gpicchiarelli/openbsd-ada | Ada | 4,528 | adb | -- OpenBSD - Provide high-level Ada interfaces to OpenBSD's pledge and unveil.
-- Written in 2019 by Prince Trippy [email protected] .
-- To the extent possible under law, the author(s) have dedicated all copyright and related and
-- neighboring rights to this software to the public domain worldwide.
-- This software is distributed without any warranty.
-- You should have received a copy of the CC0 Public Domain Dedication along with this software.
-- If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
pragma Profile(No_Implementation_Extensions);
pragma Assertion_Policy(Check);
with Interfaces.C.Strings, Ada.Strings.Maps.Constants, Ada.Strings.Bounded;
use Interfaces.C.Strings, Interfaces.C;
package body OpenBSD is
-- The pledge is documented as having three failure cases.
-- EFAULT, an invalid pointer, simply won't happen.
-- EINVAL, a malformed string, is similarly not a concern.
-- EPERM, a permissions error, is then the only failure case left.
-- So, having a single exception for this procedure is fine.
function C_Pledge (Promises, Exec_Promises : Chars_Ptr) return Int
with Import => True, Convention => C, External_Name => "pledge";
procedure Pledge (Promises : in Promise_Array) is
-- I'd prefer to have a bounded string only as large as necessary.
-- It should automatically be consistent with the Promise type.
-- How would I nicely calculate that at compilation, though?
package B is new Ada.Strings.Bounded.Generic_Bounded_Length(178);
use B; -- Perhaps I should use type here, instead.
S : Bounded_String;
begin
for P in Promise loop
if Promises(P) = Allowed then
-- Perhaps I should have this avoid the unnecessary last space.
S := S & Promise'Image(P) & ' ';
end if;
end loop;
-- It seems the promises are case-sensitive.
Translate(S, Ada.Strings.Maps.Constants.Lower_Case_Map);
declare
-- I need to fix this to avoid Unchecked_Access, later.
C : aliased Char_Array := To_C(To_String(S));
P : Chars_Ptr := To_Chars_Ptr(Char_Array_Access'(C'Unchecked_Access));
begin
if C_Pledge(P, Null_Ptr) /= 0 then
raise Pledge_Error;
end if;
end;
end Pledge;
-- A precondition that the limit for bounded strings is larger than the
-- largest possible promise string seems the best option available.
-- A precondition such as this could likely be determined at compilation.
-- I need to specify this precondition privately, though; how?
-- The unveil is documented as having four failure cases.
-- E2BIG, a storage exhaustion error, will be conflated with the others.
-- ENOENT, an invalid directory name, is also reasonable to conflate.
-- EINVAL, a malformed string, is not a concern.
-- EPERM, a permissions error, is similarly conflated with the others.
-- Having a single exception for this procedure isn't as fine as with pledge.
-- However, it's acceptable, given each case could be determined anyway.
function C_Unveil (Path, Permissions : Chars_Ptr) return Int
with Import => True, Convention => C, External_Name => "unveil";
procedure Unveil (Path : in String; Permissions : in Permission_Array) is
-- I'd similarly prefer to have a string that is consistent here.
-- Given the small size and whatnot, this is less of an issue, however.
package B is new Ada.Strings.Bounded.Generic_Bounded_Length(4);
use B; -- Perhaps I should use type here, instead.
S : Bounded_String;
C : constant array (Permission) of Character
:= (Read => 'r', Write => 'w', Execute => 'x', Create => 'c');
begin
for P in Permission loop
if Permissions(P) = Allowed then
S := S & C(P);
end if;
end loop;
declare
-- I need to fix this to avoid Unchecked_Access, later.
C : aliased Char_Array := To_C(To_String(S));
D : aliased Char_Array := To_C(Path);
P : Chars_Ptr := To_Chars_Ptr(Char_Array_Access'(C'Unchecked_Access));
Q : Chars_Ptr := To_Chars_Ptr(Char_Array_Access'(D'Unchecked_Access));
begin
if C_Unveil(Q, P) /= 0 then
raise Unveil_Error;
end if;
end;
end Unveil;
-- I could add a precondition here, but unveil isn't subject to the same issues.
-- The permission array of character won't compile if the enumeration is changed.
end OpenBSD;
|
reznikmm/matreshka | Ada | 3,671 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Attributes.Text.Label_Followed_By is
type ODF_Text_Label_Followed_By is
new XML.DOM.Attributes.DOM_Attribute with private;
private
type ODF_Text_Label_Followed_By is
new XML.DOM.Attributes.DOM_Attribute with null record;
end ODF.DOM.Attributes.Text.Label_Followed_By;
|
adammw/rtp_labs | Ada | 249 | adb | with Ada.Text_Io, Ada.Float_Text_IO;
use Ada.Text_Io, Ada.Float_Text_IO;
procedure Floats is
A, B : Float;
begin
Put("A=");
Get(A);
Put("B=");
Get(B);
if A > B then
Put_Line(A'img);
else
Put_Line(B'img);
end if;
end Floats;
|
reznikmm/matreshka | Ada | 3,887 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Testsuite Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.SAX.Writers;
with Web_Services.SOAP.Payloads.Encoders;
package SOAPConf.Encoders is
type Test_Payload_Encoder is
limited new Web_Services.SOAP.Payloads.Encoders.SOAP_Payload_Encoder
with null record;
overriding function Create
(Dummy : not null access Boolean) return Test_Payload_Encoder;
overriding procedure Encode
(Self : Test_Payload_Encoder;
Payload : Web_Services.SOAP.Payloads.Abstract_SOAP_Payload'Class;
Writer : in out XML.SAX.Writers.SAX_Writer'Class);
end SOAPConf.Encoders;
|
AdaCore/training_material | Ada | 533 | adb | with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
--$ begin cut
type A_F is access function (I : Integer) return Integer
with Post => A_F'Result > I;
--$ end cut
function Plus_One (I : Integer) return Integer is (I + 1)
with Inline, Static;
function Minus_One (I : Integer) return Integer is (I - 1)
with Inline, Static;
Acc : array (Positive range <>) of A_F := (Plus_One'Access, Minus_One'Access);
begin
for A of Acc loop
Put_Line (Integer'Image (A (1)));
end loop;
end Main;
|
jwarwick/aoc_2020 | Ada | 305 | adb | -- AOC 2020, Day 19
with Ada.Text_IO; use Ada.Text_IO;
with Day; use Day;
procedure main is
part1 : constant Natural := count_valid("input.txt");
part2 : constant Natural := count_valid_updated("input.txt");
begin
put_line("Part 1: " & part1'IMAGE);
put_line("Part 2: " & part2'IMAGE);
end main;
|
AdaCore/training_material | Ada | 802 | ads | package Perm.Lemma_Subprograms with
Ghost,
Annotate => (GNATprove, Always_Return)
is
function Is_Set
(A : Nat_Array; I : Index; V : Natural; R : Nat_Array) return Boolean
is
(R (I) = V
and then (for all J in A'Range =>
(if I /= J then R (J) = A (J))));
procedure Occ_Set (A : Nat_Array; I : Index; V : Natural; R : Nat_Array)
with
Global => null,
Pre => Is_Set (A, I, V, R),
Post =>
(if V = A (I) then Occurrences (R) = Occurrences (A)
else Occ (R, V) = Occ (A, V) + 1
and then Occ (R, A (I)) = Occ (A, A (I)) - 1
and then
(for all E of Union (Occurrences (R), Occurrences (A)) =>
(if E not in V | A (I) then Occ (R, E) = Occ (A, E))));
end Perm.Lemma_Subprograms;
|
AdaCore/libadalang | Ada | 196 | ads | private with Foo;
pragma Elaborate (Foo);
pragma Test_Statement;
package Pkg is
procedure Test;
package Nested is
procedure Test;
private
X : Foo.T;
end Nested;
end Pkg;
|
msrLi/portingSources | Ada | 1,115 | adb | -- Copyright 2007-2014 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
procedure Foo is
begin
begin
raise Constraint_Error; -- SPOT1
exception
when others =>
null;
end;
begin
raise Program_Error; -- SPOT2
exception
when others =>
null;
end;
begin
pragma Assert (False); -- SPOT3
null;
exception
when others =>
null;
end;
raise Constraint_Error; -- SPOT4
end Foo;
|
stcarrez/ada-util | Ada | 2,290 | ads | -- Generated by utildgen.c from system includes
with Interfaces.C;
package Util.Systems.Types is
subtype dev_t is Long_Long_Integer;
subtype ino_t is Long_Long_Integer;
subtype off_t is Long_Long_Integer;
subtype blksize_t is Interfaces.C.int;
subtype blkcnt_t is Long_Long_Integer;
subtype uid_t is Interfaces.C.unsigned;
subtype gid_t is Interfaces.C.unsigned;
subtype nlink_t is Interfaces.C.unsigned;
subtype mode_t is Interfaces.C.unsigned;
S_IFMT : constant mode_t := 8#00170000#;
S_IFDIR : constant mode_t := 8#00040000#;
S_IFCHR : constant mode_t := 8#00020000#;
S_IFBLK : constant mode_t := 8#00060000#;
S_IFREG : constant mode_t := 8#00100000#;
S_IFIFO : constant mode_t := 8#00010000#;
S_IFLNK : constant mode_t := 8#00120000#;
S_IFSOCK : constant mode_t := 8#00140000#;
S_ISUID : constant mode_t := 8#00004000#;
S_ISGID : constant mode_t := 8#00002000#;
S_IREAD : constant mode_t := 8#00000400#;
S_IWRITE : constant mode_t := 8#00000200#;
S_IEXEC : constant mode_t := 8#00000100#;
type File_Type is new Interfaces.C.int;
subtype Time_Type is Long_Long_Integer;
type Timespec is record
tv_sec : Time_Type;
tv_nsec : Long_Long_Integer;
end record;
pragma Convention (C_Pass_By_Copy, Timespec);
type Seek_Mode is (SEEK_SET, SEEK_CUR, SEEK_END);
for Seek_Mode use (SEEK_SET => 0, SEEK_CUR => 1, SEEK_END => 2);
STAT_NAME : constant String := "__stat50";
FSTAT_NAME : constant String := "__fstat50";
LSTAT_NAME : constant String := "__lstat50";
type Stat_Type is record
st_dev : dev_t;
st_mode : mode_t;
st_ino : ino_t;
st_nlink : nlink_t;
st_uid : uid_t;
st_gid : gid_t;
st_rdev : dev_t;
st_atim : Timespec;
st_mtim : Timespec;
st_ctim : Timespec;
st_birthtime : Timespec;
st_size : off_t;
st_blocks : blkcnt_t;
st_blksize : blksize_t;
st_flags : Interfaces.C.unsigned;
st_gen : Interfaces.C.unsigned;
st_spare1 : Interfaces.C.unsigned;
st_spare2 : Interfaces.C.unsigned;
end record;
pragma Convention (C_Pass_By_Copy, Stat_Type);
end Util.Systems.Types;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.