repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
optikos/ada-lsp
Ada
234
ads
-- Copyright (c) 2017 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package Ada_LSP is pragma Pure; end Ada_LSP;
Kurinkitos/Twizy-Security
Ada
7,423
adb
--with Spark.Float_Arithmetic_Lemmas; with Mathutil; with Ada.Float_Text_IO; use Ada.Float_Text_IO; with Ada.Text_IO; package body perception with SPARK_Mode is --use Spark.Float_Arithmetic_Lemmas; function breakingDistance (s : in Speed) return Distance is Dist : Distance; begin pragma Assert(BreakConstant > 0.0); Dist := Distance(S) * Distance(2); return abs (Dist / BreakConstant); end breakingDistance; function GetDangerZone(S : in Speed; SteeringAngle : in Steering_Angle; Obj_Type : in C_type) return DangerZone is -- These values chage when test for real values BreakingDist : Distance := BreakingDistance(S); LidarAngle : Lidar_Angle := 45.0; BreakingDistScale : constant Distance := 1.0; begin if Obj_Type /= UNKNOWN_UNMOVABLE then if (BreakingDist >= Distance'Last / BreakingDistScale) then BreakingDist := Distance'Last; else pragma Assume(BreakingDist * BreakingDistScale < Distance'Last); pragma Assume(BreakingDist * BreakingDistScale > 0.0); BreakingDist := BreakingDist * BreakingDistScale; -- Change this constant later end if; LidarAngle := 60.0; end if; return (ScopeAngle => LidarAngle, Radius => BreakingDist, SteeringAngleOffset => SteeringAngle); end GetDangerZone; function PointInDangerZone(P : in LocalPoint; DZ : in DangerZone) return Boolean is Ang : Lidar_Angle := 0.0; pragma Assume(P.X * P.X + P.Y * P.Y > 0.0); pragma Assume(P.X * P.X + P.Y * P.Y < 6000.0); Dist2 : constant Distance := Distance(P.X * P.X + P.Y * P.Y); pragma Assume(Dist2 > 0.0); Dist : constant Distance := Mathutil.Sqrt(Dist2); begin if Dist > DZ.Radius or P.Y < 0.0 then -- outside radius or behind us return False; else if P.X /= 0.0 and P.Y /= 0.0 then Ang := Lidar_Angle(Mathutil.ArcTan(P.X, P.Y)); elsif P.Y = 0.0 then pragma Assume(P.X / P.X = 1.0 or P.X / P.X = -1.0); Ang := 90.0 * Lidar_Angle(P.X / P.X); end if; end if; return (abs Ang) <= DZ.ScopeAngle; end PointInDangerZone; function GetDZEdge(DZ : DangerZone; Left : Boolean) return Line is Q : LocalPoint := (Mathutil.Cos(DZ.ScopeAngle) * DZ.Radius, Mathutil.Sin(DZ.ScopeAngle) * DZ.Radius, 0.0); begin if (Left) then Q.X := (-Q.X); end if; return (P => (0.0, 0.0, 0.0), Q => Q); end GetDZEdge; function GetOrientation(P1 : LocalPoint; P2 : LocalPoint; P3 : LocalPoint) return Orientation is Val : constant Cartesian_Coordinate := (P2.Y - P1.Y) * (P3.X - P2.X) - (P3.Y - P2.Y) * (P2.X - P1.X); begin if Val = 0.0 then return CL; elsif Val < 0.0 then return CCW; else return CW; end if; end GetOrientation; -- https://www.geeksforgeeks.org/check-if-two-given-line-segments-intersect/ function IsIntersecting(L1 : Line; L2 : Line) return Boolean is O1 : constant Orientation := GetOrientation(L1.P, L1.Q, L2.P); O2 : constant Orientation := GetOrientation(L1.P, L1.Q, L2.Q); O3 : constant Orientation := GetOrientation(L2.P, L2.Q, L1.P); O4 : constant Orientation := GetOrientation(L2.P, L2.Q, L1.Q); begin -- general case if O1 /= O2 and then O3 /= O4 then return True; end if; -- we ignore the special case with colinear orientations since -- that case is covered by the point in dz (we have a point on -- the edge return False; end IsIntersecting; function PerceptionCheck(Obstacle : in Perception_Obstacle_ada; Pose : in Pose_Ada; S : in Speed) return Boolean is DZ : constant DangerZone := GetDangerZone(S, 0.0, Obstacle.The_C_Type); GX : constant FloatingNumber := FloatingNumber(Obstacle.Position.X); GY : constant FloatingNumber := FloatingNumber(Obstacle.Position.Y); X : constant FloatingNumber := FloatingNumber(Obstacle.Length) / 2.0; Y : constant FloatingNumber := FloatingNumber(Obstacle.Width) / 2.0; Stw : constant FloatingNumber := Mathutil.Sin_r(FloatingNumber(Obstacle.Theta)); Ctw : constant FloatingNumber := Mathutil.Cos_r(FloatingNumber(Obstacle.Theta)); -- these points are in the "world" coordinate system, whatever that means P1w : constant Point := ( X * Ctw - Y * Stw + GX, X * Stw + Y * Ctw + GY, 0.0); -- top left P2w : constant Point := ( X * Ctw - (-Y) * Stw + GX, X * Stw + (-Y) * Ctw + GY, 0.0); -- top right P3w : constant Point := ((-X) * Ctw - (-Y) * Stw + GX, (-X) * Stw + (-Y) * Ctw + GY, 0.0); -- bot right P4w : constant Point := ((-X) * Ctw - Y * Stw + GX, (-X) * Stw + Y * Ctw + GY, 0.0); -- bot left XT : constant FloatingNumber := FloatingNumber(Pose.Position.X); YT : constant FloatingNumber := FloatingNumber(Pose.Position.Y); -- translated to the cars coordinate system P1t : constant Point := (P1w.X - XT, P1w.Y - YT, 0.0); -- top left P2t : constant Point := (P2w.X - XT, P2w.Y - YT, 0.0); -- top right P3t : constant Point := (P3w.X - XT, P3w.Y - YT, 0.0); -- bot right P4t : constant Point := (P4w.X - XT, P4w.Y - YT, 0.0); -- bot left PI : constant FloatingNumber := 3.14159265; St : constant FloatingNumber := Mathutil.Sin_r(-FloatingNumber(Pose.Heading) + PI/2.0); Ct : constant FloatingNumber := Mathutil.Cos_r(-FloatingNumber(Pose.Heading) + PI/2.0); -- these points are in the car's local coordinate system -- to be checked against the dangerZone P1 : constant Point := ( P1t.X * Ct - P1t.Y * St, P1t.X * St + P1t.Y * Ct, 0.0); -- top left P2 : constant Point := ( P2t.X * Ct - P2t.Y * St, P2t.X * St + P2t.Y * Ct, 0.0); -- top right P3 : constant Point := ( P3t.X * Ct - P3t.Y * St, P3t.X * St + P3t.Y * Ct, 0.0); -- bot right P4 : constant Point := ( P4t.X * Ct - P4t.Y * St, P4t.X * St + P4t.Y * Ct, 0.0); -- bot left -- Our lines to check for intersection with the dangerzone L1 : constant Line := (P1, P2); L2 : constant Line := (P2, P3); L3 : constant Line := (P3, P4); L4 : constant Line := (P4, P1); -- DEBUG STUFF -- procedure Print_Point(N : String; P : Point) is -- begin -- Ada.Text_IO.Put(N); -- Put(Float(P.X), Exp => 0); -- Ada.Text_IO.Put(","); -- Put(Float(P.Y), Exp => 0); -- Ada.Text_IO.New_Line(1); -- end Print_Point; begin -- Put(Float(GX)); Ada.Text_IO.New_Line(1); -- Put(Float(GY)); Ada.Text_IO.New_Line(1); -- Ada.Text_IO.Put("XT,XY: "); Put(Float(XT)); Ada.Text_IO.Put(","); Put(Float(YT)); Ada.Text_IO.New_Line(1); -- Ada.Text_IO.Put_Line("Points: "); -- Print_Point("1: ", P1); -- Print_Point("2: ", P2); -- Print_Point("3: ", P3); -- Print_Point("4: ", P4); -- Ada.Text_IO.Put(""); if PointInDangerZone(P1, DZ) or PointInDangerZone(P2, DZ) or PointInDangerZone(P3, DZ) or PointInDangerZone(P4, DZ) then -- Ada.Text_IO.Put_Line("Unsafe, point in DZ"); return False; end if; -- one optimization is to find the 2 closest lines, but that might be overkill if IsIntersecting(L1, GetDZEdge(DZ, False)) or IsIntersecting(L1, GetDZEdge(DZ, True)) or IsIntersecting(L2, GetDZEdge(DZ, False)) or IsIntersecting(L2, GetDZEdge(DZ, True)) or IsIntersecting(L3, GetDZEdge(DZ, False)) or IsIntersecting(L3, GetDZEdge(DZ, True)) or IsIntersecting(L4, GetDZEdge(DZ, False)) or IsIntersecting(L4, GetDZEdge(DZ, True)) then -- Ada.Text_IO.Put_Line("Unsafe, line crossing DZ"); return False; end if; return True; end PerceptionCheck; end;
zhmu/ananas
Ada
167
adb
-- { dg-do compile } -- { dg-options "-gnatN" } with Elab8_Gen; procedure Elab8 is package My_G is new Elab8_Gen (Integer); begin My_G.Compare (0, 1); end;
reznikmm/matreshka
Ada
5,053
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.UML.Elements; limited with AMF.UML.Elements.Collections; with League.Strings; package AMF.MOF.Tags is pragma Preelaborate; type MOF_Tag is limited interface and AMF.UML.Elements.UML_Element; type MOF_Tag_Access is access all MOF_Tag'Class; for MOF_Tag_Access'Storage_Size use 0; not overriding function Get_Name (Self : not null access constant MOF_Tag) return League.Strings.Universal_String is abstract; -- Getter of Tag::name. -- not overriding procedure Set_Name (Self : not null access MOF_Tag; To : League.Strings.Universal_String) is abstract; -- Setter of Tag::name. -- not overriding function Get_Value (Self : not null access constant MOF_Tag) return League.Strings.Universal_String is abstract; -- Getter of Tag::value. -- not overriding procedure Set_Value (Self : not null access MOF_Tag; To : League.Strings.Universal_String) is abstract; -- Setter of Tag::value. -- not overriding function Get_Element (Self : not null access constant MOF_Tag) return AMF.UML.Elements.Collections.Set_Of_UML_Element is abstract; -- Getter of Tag::element. -- not overriding function Get_Tag_Owner (Self : not null access constant MOF_Tag) return AMF.UML.Elements.UML_Element_Access is abstract; -- Getter of Tag::tagOwner. -- not overriding procedure Set_Tag_Owner (Self : not null access MOF_Tag; To : AMF.UML.Elements.UML_Element_Access) is abstract; -- Setter of Tag::tagOwner. -- end AMF.MOF.Tags;
bhayward93/Ada-Traffic-Light-Sim
Ada
1,098
adb
with HWIF;use HWIF; with HWIF_Types; use HWIF_Types; with Ada.Text_IO; use Ada.Text_IO; with TrafficLightSwitcher; procedure PedestrianLightSwitcher (dir : in Direction) is begin Pedestrian_Wait(dir) := 1; --Wait light on. loop exit when ((Traffic_Light(North) = 4) and (Traffic_Light(South) = 4) and (Traffic_Light(East) = 4) and (Traffic_Light(West) = 4)); delay 1.0; for directionItt in Direction loop if Traffic_Light(directionItt) = 1 then TrafficLightSwitcher(directionItt); end if; end loop; end loop; --Put_Line("PedWait off"); Pedestrian_Wait(dir) := 0; --Put_Line("PedLight green"); Pedestrian_Light(dir) := 1; --Green light on. delay 6.0; --Req: 6 seconds of pedestrian green time. Pedestrian_Light(dir) := 2; --Red light on. Pedestrian_Wait(dir) := 0; --Not Pressed Put_Line("PedLight red"); end; --red, amber and green lights for motor vehicles --red and green lights for pedestrians, --a button for pedestrians to press
ekoeppen/STM32_Generic_Ada_Drivers
Ada
436
adb
with Ada.Real_Time; use Ada.Real_Time; with STM32GD.Board; use STM32GD.Board; with Tasks; procedure Main is Next_Release : Time := Clock; Period : constant Time_Span := Milliseconds (500); begin Init; LED.Set; STM32GD.Board.Text_IO.Put_Line ("Main task starting"); loop Next_Release := Next_Release + Period; delay until Next_Release; LED.Toggle; Tasks.Protect.Go; end loop; end Main;
likai3g/afmt
Ada
997
ads
generic type Mod_Int_Type is mod <>; package Fmt.Generic_Mod_Int_Argument is function To_Argument (X : Mod_Int_Type) return Argument_Type'Class with Inline; function "&" (Args : Arguments; X : Mod_Int_Type) return Arguments with Inline; private type Digit_Style is (DS_Lowercase, DS_Uppercase); subtype Number_Base is Positive range 2 .. 36; type Mod_Int_Argument_Type is new Argument_Type with record Value : Mod_Int_Type; Width : Natural := 0; Align : Text_Align := 'R'; Fill : Character := ' '; Base : Number_Base := 10; Style : Digit_Style := DS_Lowercase; end record; overriding procedure Parse (Self : in out Mod_Int_Argument_Type; Edit : String); overriding function Get_Length (Self : in out Mod_Int_Argument_Type) return Natural; overriding procedure Put ( Self : in out Mod_Int_Argument_Type; Edit : String; To : in out String); end Fmt.Generic_Mod_Int_Argument;
zhmu/ananas
Ada
2,885
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- G N A T . S T R I N G _ S P L I T -- -- -- -- S p e c -- -- -- -- Copyright (C) 2002-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- Useful string-manipulation routines: given a set of separators, split -- a string wherever the separators appear, and provide direct access -- to the resulting slices. See GNAT.Array_Split for full documentation. with Ada.Strings.Maps; use Ada.Strings; with GNAT.Array_Split; package GNAT.String_Split is new GNAT.Array_Split (Element => Character, Element_Sequence => String, Element_Set => Maps.Character_Set, To_Set => Maps.To_Set, Is_In => Maps.Is_In);
mfkiwl/ewok-kernel-security-OS
Ada
3,068
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; use ewok.tasks_shared; with ewok.tasks; with soc.interrupts; with rings; package ewok.softirq with spark_mode => on is type t_isr_parameters is record handler : system_address := 0; interrupt : soc.interrupts.t_interrupt := soc.interrupts.INT_NONE; posthook_status : unsigned_32 := 0; posthook_data : unsigned_32 := 0; end record; type t_isr_request is record caller_id : ewok.tasks_shared.t_task_id := ID_UNUSED; params : t_isr_parameters := (others => <>); end record; type t_soft_parameters is record handler : system_address := 0; param1 : unsigned_32 := 0; param2 : unsigned_32 := 0; param3 : unsigned_32 := 0; end record; type t_soft_request is record caller_id : ewok.tasks_shared.t_task_id := ID_UNUSED; params : t_soft_parameters := (others => <>); end record; -- softirq input queue depth. Can be configured depending -- on the devices behavior (IRQ bursts) -- defaulting to 20 (see Kconfig) MAX_QUEUE_SIZE : constant := $CONFIG_KERNEL_SOFTIRQ_QUEUE_DEPTH; package p_isr_requests is new rings (t_isr_request, MAX_QUEUE_SIZE, t_isr_request'(others => <>)); use p_isr_requests; package p_soft_requests is new rings (t_soft_request, MAX_QUEUE_SIZE, t_soft_request'(others => <>)); use p_soft_requests; isr_queue : p_isr_requests.ring; soft_queue : p_soft_requests.ring; procedure init; procedure push_isr (task_id : in ewok.tasks_shared.t_task_id; params : in t_isr_parameters); procedure push_soft (task_id : in ewok.tasks_shared.t_task_id; params : in t_soft_parameters); procedure isr_handler (req : in t_isr_request) with global => (in_out => ewok.tasks.tasks_list); procedure soft_handler (req : in t_soft_request) with global => (in_out => ewok.tasks.tasks_list); procedure main_task with global => (in_out => ewok.tasks.tasks_list); private previous_isr_owner : t_task_id := ID_UNUSED; end ewok.softirq;
tum-ei-rcs/StratoX
Ada
9,144
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-2016, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of 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: -- -- -- -- @file stm32f429i_discovery.h -- -- @author MCD Application Team -- -- @version V1.1.0 -- -- @date 19-June-2014 -- -- @brief This file contains definitions for STM32F429I-Discovery Kit -- -- LEDs, push-buttons hardware resources. -- -- -- -- COPYRIGHT(c) 2014 STMicroelectronics -- ------------------------------------------------------------------------------ -- This file provides declarations for devices on the STM32F429 Discovery kits -- manufactured by ST Microelectronics. with STM32.Device; use STM32.Device; with STM32.GPIO; use STM32.GPIO; with STM32.SPI; use STM32.SPI; with STM32.FMC; use STM32.FMC; with L3GD20; with Framebuffer_ILI9341; with Touch_Panel_STMPE811; with Ada.Interrupts.Names; use Ada.Interrupts; package STM32.Board is pragma Elaborate_Body; ---------- -- LEDs -- ---------- subtype User_LED is GPIO_Point; Green : User_LED renames PG13; Red : User_LED renames PG14; LCH_LED : User_LED renames Red; All_LEDs : GPIO_Points := Green & Red; procedure Initialize_LEDs; -- MUST be called prior to any use of the LEDs unless initialization is -- done by the app elsewhere. procedure Turn_On (This : in out User_LED) renames STM32.GPIO.Set; procedure Turn_Off (This : in out User_LED) renames STM32.GPIO.Clear; procedure All_LEDs_Off with Inline; procedure All_LEDs_On with Inline; procedure Toggle_LEDs (These : in out GPIO_Points) renames STM32.GPIO.Toggle; --------- -- FMC -- --------- FMC_D : constant GPIO_Points := (PD14, PD15, PD0, PD1, PE7, PE8, PE9, PE10, PE11, PE12, PE13, PE14, PE15, PD8, PD9, PD10); FMC_A : constant GPIO_Points := (PF0, PF1, PF2, PF3, PF4, PF5, PF12, PF13, PF14, PF15, PG0, PG1); FMC_SDNWE : GPIO_Point renames PC0; FMC_SDNRAS : GPIO_Point renames PF11; FMC_SDNCAS : GPIO_Point renames PG15; FMC_SDCLK : GPIO_Point renames PG8; FMC_BA0 : GPIO_Point renames PG4; FMC_BA1 : GPIO_Point renames PG5; FMC_NBL0 : GPIO_Point renames PE0; FMC_NBL1 : GPIO_Point renames PE1; FMC_SDNE1 : GPIO_Point renames PB6; FMC_SDCKE1 : GPIO_Point renames PB5; SDRAM_PINS : constant GPIO_Points := FMC_A & FMC_D & FMC_SDNWE & FMC_SDNRAS & FMC_SDNCAS & FMC_SDCLK & FMC_BA0 & FMC_BA1 & FMC_SDNE1 & FMC_SDCKE1 & FMC_NBL0 & FMC_NBL1; -- SDRAM CONFIGURATION Parameters SDRAM_Base : constant := 16#D0000000#; SDRAM_Size : constant := 16#800000#; SDRAM_Bank : constant STM32.FMC.FMC_SDRAM_Cmd_Target_Bank := STM32.FMC.FMC_Bank2_SDRAM; SDRAM_Row_Bits : constant STM32.FMC.FMC_SDRAM_Row_Address_Bits := STM32.FMC.FMC_RowBits_Number_12b; SDRAM_Mem_Width : constant STM32.FMC.FMC_SDRAM_Memory_Bus_Width := STM32.FMC.FMC_SDMemory_Width_16b; SDRAM_CAS_Latency : constant STM32.FMC.FMC_SDRAM_CAS_Latency := STM32.FMC.FMC_CAS_Latency_3; SDRAM_CLOCK_Period : constant STM32.FMC.FMC_SDRAM_Clock_Configuration := STM32.FMC.FMC_SDClock_Period_2; SDRAM_Read_Burst : constant STM32.FMC.FMC_SDRAM_Burst_Read := STM32.FMC.FMC_Read_Burst_Disable; SDRAM_Read_Pipe : constant STM32.FMC.FMC_SDRAM_Read_Pipe_Delay := STM32.FMC.FMC_ReadPipe_Delay_1; SDRAM_Refresh_Cnt : constant := 1386; --------------- -- SPI5 Pins -- --------------- -- Required for the gyro and LCD so defined here SPI5_SCK : GPIO_Point renames PF7; SPI5_MISO : GPIO_Point renames PF8; SPI5_MOSI : GPIO_Point renames PF9; NCS_MEMS_SPI : GPIO_Point renames PC1; MEMS_INT1 : GPIO_Point renames PA1; MEMS_INT2 : GPIO_Point renames PA2; ------------------------- -- LCD and Touch Panel -- ------------------------- LCD_SPI : SPI_Port renames SPI_5; -- See the STM32F429I-Discovery board schematics for the actual pin -- assignments -- RGB connection LCD_VSYNC : GPIO_Point renames PA4; LCD_HSYNC : GPIO_Point renames PC6; LCD_ENABLE : GPIO_Point renames PF10; LCD_CLK : GPIO_Point renames PG7; -- See the STM32F427xx/STM32F429xx datasheet for the aleternate function -- mapping. LCD_RGB_AF9 : constant GPIO_Points := (PB0, PB1, PG10, PG12); LCD_RGB_AF14 : constant GPIO_Points := (PC10, PA11, PA12, PG6, PA6, PB10, PB11, PC7, PD3, PD6, PG11, PA3, PB8, PB9); LCD_PINS : constant GPIO_Points := LCD_RGB_AF14 & LCD_RGB_AF9 & LCD_VSYNC & LCD_HSYNC & LCD_ENABLE & LCD_CLK; LCD_Natural_Width : constant := 240; LCD_Natural_Height : constant := 320; Display : Framebuffer_ILI9341.Frame_Buffer; Touch_Panel : Touch_Panel_STMPE811.Touch_Panel; ----------------- -- User button -- ----------------- User_Button_Point : GPIO_Point renames PA0; User_Button_Interrupt : constant Interrupt_ID := Names.EXTI0_Interrupt; procedure Configure_User_Button_GPIO; -- Configures the GPIO port/pin for the blue user button. Sufficient -- for polling the button, and necessary for having the button generate -- interrupts. ---------- -- Gyro -- ---------- Gyro_SPI : SPI_Port renames LCD_SPI; -- The gyro and LCD use the same port and pins. See the STM32F429 Discovery -- kit User Manual (UM1670) pages 21 and 23. Gyro_Interrupt_1_Pin : GPIO_Point renames MEMS_INT1; Gyro_Interrupt_2_Pin : GPIO_Point renames MEMS_INT2; -- Theese are the GPIO pins on which the gyro generates interrupts if so -- commanded. The gyro package does not references these, only clients' -- interrupt handlers do. Gyro : L3GD20.Three_Axis_Gyroscope; procedure Initialize_Gyro_IO; -- This is a board-specific routine. It initializes and configures the -- GPIO, SPI, etc. for the on-board L3GD20 gyro as required for the F429 -- Disco board. See the STM32F429 Discovery kit User Manual (UM1670) for -- specifics. end STM32.Board;
zhmu/ananas
Ada
2,008
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- F R O N T E N D -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- Top level of the front-end. This procedure is used by the different -- gnat drivers. procedure Frontend;
micahwelf/FLTK-Ada
Ada
9,040
ads
with FLTK.Widgets.Groups.Windows; private with Interfaces.C; package FLTK.Static is type Awake_Handler is access procedure; type Timeout_Handler is access procedure; type Idle_Handler is access procedure; type Buffer_Kind is (Selection, Clipboard); type Clipboard_Notify_Handler is access procedure (Kind : in Buffer_Kind); type File_Descriptor is new Integer; type File_Mode is (Read, Write, Except); type File_Handler is access procedure (FD : in File_Descriptor); type Box_Draw_Function is access procedure (X, Y, W, H : in Integer; My_Color : in Color); type Option is (Arrow_Focus, Visible_Focus, DND_Text, Show_Tooltips, FNFC_Uses_GTK, Last); procedure Add_Awake_Handler (Func : in Awake_Handler); function Get_Awake_Handler return Awake_Handler; procedure Add_Check (Func : in Timeout_Handler); function Has_Check (Func : in Timeout_Handler) return Boolean; procedure Remove_Check (Func : in Timeout_Handler); procedure Add_Timeout (Seconds : in Long_Float; Func : in Timeout_Handler); function Has_Timeout (Func : in Timeout_Handler) return Boolean; procedure Remove_Timeout (Func : in Timeout_Handler); procedure Repeat_Timeout (Seconds : in Long_Float; Func : in Timeout_Handler); procedure Add_Clipboard_Notify (Func : in Clipboard_Notify_Handler); procedure Remove_Clipboard_Notify (Func : in Clipboard_Notify_Handler); procedure Add_File_Descriptor (FD : in File_Descriptor; Func : in File_Handler); procedure Add_File_Descriptor (FD : in File_Descriptor; Mode : in File_Mode; Func : in File_Handler); procedure Remove_File_Descriptor (FD : in File_Descriptor); procedure Remove_File_Descriptor (FD : in File_Descriptor; Mode : in File_Mode); procedure Add_Idle (Func : in Idle_Handler); function Has_Idle (Func : in Idle_Handler) return Boolean; procedure Remove_Idle (Func : in Idle_Handler); procedure Get_Color (From : in Color; R, G, B : out Color_Component); procedure Set_Color (To : in Color; R, G, B : in Color_Component); procedure Free_Color (Value : in Color; Overlay : in Boolean := False); procedure Own_Colormap; procedure Set_Foreground (R, G, B : in Color_Component); procedure Set_Background (R, G, B : in Color_Component); procedure Set_Alt_Background (R, G, B : in Color_Component); procedure System_Colors; function Font_Image (Kind : in Font_Kind) return String; function Font_Family_Image (Kind : in Font_Kind) return String; procedure Set_Font_Kind (To, From : in Font_Kind); function Font_Sizes (Kind : in Font_Kind) return Font_Size_Array; procedure Setup_Fonts (How_Many_Set_Up : out Natural); function Get_Box_Height_Offset (Kind : in Box_Kind) return Integer; function Get_Box_Width_Offset (Kind : in Box_Kind) return Integer; function Get_Box_X_Offset (Kind : in Box_Kind) return Integer; function Get_Box_Y_Offset (Kind : in Box_Kind) return Integer; procedure Set_Box_Kind (To, From : in Box_Kind); function Draw_Box_Active return Boolean; -- function Get_Box_Draw_Function -- (Kind : in Box_Kind) -- return Box_Draw_Function; -- procedure Set_Box_Draw_Function -- (Kind : in Box_Kind; -- Func : in Box_Draw_Function; -- Offset_X, Offset_Y : in Integer := 0; -- Offset_W, Offset_H : in Integer := 0); procedure Copy (Text : in String; Dest : in Buffer_Kind); procedure Paste (Receiver : in FLTK.Widgets.Widget'Class; Source : in Buffer_Kind); procedure Selection (Owner : in FLTK.Widgets.Widget'Class; Text : in String); procedure Drag_Drop_Start; function Get_Drag_Drop_Text_Support return Boolean; procedure Set_Drag_Drop_Text_Support (To : in Boolean); procedure Enable_System_Input; procedure Disable_System_Input; function Has_Visible_Focus return Boolean; procedure Set_Visible_Focus (To : in Boolean); procedure Default_Window_Close (Item : in out FLTK.Widgets.Widget'Class); function Get_First_Window return access FLTK.Widgets.Groups.Windows.Window'Class; procedure Set_First_Window (To : in FLTK.Widgets.Groups.Windows.Window'Class); function Get_Next_Window (From : in FLTK.Widgets.Groups.Windows.Window'Class) return access FLTK.Widgets.Groups.Windows.Window'Class; function Get_Top_Modal return access FLTK.Widgets.Groups.Windows.Window'Class; function Read_Queue return access FLTK.Widgets.Widget'Class; procedure Do_Widget_Deletion; function Get_Scheme return String; procedure Set_Scheme (To : in String); function Is_Scheme (Scheme : in String) return Boolean; procedure Reload_Scheme; function Get_Option (Opt : in Option) return Boolean; procedure Set_Option (Opt : in Option; To : in Boolean); function Get_Default_Scrollbar_Size return Natural; procedure Set_Default_Scrollbar_Size (To : in Natural); private File_Mode_Codes : array (File_Mode) of Interfaces.C.int := (Read => 1, Write => 4, Except => 8); pragma Import (C, Own_Colormap, "fl_static_own_colormap"); pragma Import (C, System_Colors, "fl_static_get_system_colors"); pragma Import (C, Drag_Drop_Start, "fl_static_dnd"); pragma Import (C, Enable_System_Input, "fl_static_enable_im"); pragma Import (C, Disable_System_Input, "fl_static_disable_im"); pragma Import (C, Do_Widget_Deletion, "fl_static_do_widget_deletion"); pragma Import (C, Reload_Scheme, "fl_static_reload_scheme"); pragma Inline (Add_Awake_Handler); pragma Inline (Get_Awake_Handler); pragma Inline (Add_Check); pragma Inline (Has_Check); pragma Inline (Remove_Check); pragma Inline (Add_Timeout); pragma Inline (Has_Timeout); pragma Inline (Remove_Timeout); pragma Inline (Repeat_Timeout); pragma Inline (Add_Clipboard_Notify); pragma Inline (Remove_Clipboard_Notify); pragma Inline (Add_File_Descriptor); pragma Inline (Remove_File_Descriptor); pragma Inline (Add_Idle); pragma Inline (Has_Idle); pragma Inline (Remove_Idle); pragma Inline (Get_Color); pragma Inline (Set_Color); pragma Inline (Free_Color); pragma Inline (Own_Colormap); pragma Inline (Set_Foreground); pragma Inline (Set_Background); pragma Inline (Set_Alt_Background); pragma Inline (System_Colors); pragma Inline (Font_Image); pragma Inline (Font_Family_Image); pragma Inline (Set_Font_Kind); pragma Inline (Font_Sizes); pragma Inline (Setup_Fonts); pragma Inline (Get_Box_Height_Offset); pragma Inline (Get_Box_Width_Offset); pragma Inline (Get_Box_X_Offset); pragma Inline (Get_Box_Y_Offset); pragma Inline (Set_Box_Kind); pragma Inline (Draw_Box_Active); -- pragma Inline (Get_Box_Draw_Function); -- pragma Inline (Set_Box_Draw_Function); pragma Inline (Copy); pragma Inline (Paste); pragma Inline (Selection); pragma Inline (Drag_Drop_Start); pragma Inline (Get_Drag_Drop_Text_Support); pragma Inline (Set_Drag_Drop_Text_Support); pragma Inline (Enable_System_Input); pragma Inline (Disable_System_Input); pragma Inline (Has_Visible_Focus); pragma Inline (Set_Visible_Focus); pragma Inline (Default_Window_Close); pragma Inline (Get_First_Window); pragma Inline (Set_First_Window); pragma Inline (Get_Next_Window); pragma Inline (Get_Top_Modal); pragma Inline (Read_Queue); pragma Inline (Do_Widget_Deletion); pragma Inline (Get_Scheme); pragma Inline (Set_Scheme); pragma Inline (Is_Scheme); pragma Inline (Reload_Scheme); pragma Inline (Get_Option); pragma Inline (Set_Option); pragma Inline (Get_Default_Scrollbar_Size); pragma Inline (Set_Default_Scrollbar_Size); end FLTK.Static;
reznikmm/matreshka
Ada
3,985
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.Smil_CalcMode_Attributes; package Matreshka.ODF_Smil.CalcMode_Attributes is type Smil_CalcMode_Attribute_Node is new Matreshka.ODF_Smil.Abstract_Smil_Attribute_Node and ODF.DOM.Smil_CalcMode_Attributes.ODF_Smil_CalcMode_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Smil_CalcMode_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Smil_CalcMode_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Smil.CalcMode_Attributes;
persan/AdaYaml
Ada
1,499
adb
-- part of AdaYaml, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "copying.txt" with Ada.Text_IO; with Ada.Command_Line; with Yaml.Source.Text_IO; with Yaml.Source.File; with Yaml.Dom.Loading; with Yaml.Dom.Node; pragma Unreferenced (Yaml.Dom.Node); procedure Yaml.To_Dom is use type Dom.Node_Kind; Input : Source.Pointer; begin if Ada.Command_Line.Argument_Count = 0 then Input := Source.Text_IO.As_Source (Ada.Text_IO.Standard_Input); else Input := Source.File.As_Source (Ada.Command_Line.Argument (1)); end if; declare Document : constant Dom.Document_Reference := Dom.Loading.From_Source (Input); Root_Node : constant not null access Dom.Node.Instance := Document.Root.Value.Data; procedure Visit_Pair (Key, Value : not null access Dom.Node.Instance) is begin Ada.Text_IO.Put_Line ("Key: " & Key.Kind'Img); if Key.Kind = Dom.Scalar then Ada.Text_IO.Put_Line (" """ & Key.Content.Value.Data.all & """"); end if; Ada.Text_IO.Put_Line ("Value: " & Value.Kind'Img); if Value.Kind = Dom.Scalar then Ada.Text_IO.Put_Line (" """ & Value.Content.Value.Data.all & """"); end if; end Visit_Pair; begin Ada.Text_IO.Put_Line ("Root is " & Root_Node.Kind'Img); if Root_Node.Kind = Dom.Mapping then Root_Node.Pairs.Iterate (Visit_Pair'Access); end if; end; end Yaml.To_Dom;
xeenta/learning-ada
Ada
4,668
adb
with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Numerics.Discrete_Random; --with Ada.Task_Identification; --use Ada; procedure Task_Type is subtype Player_Id_Type is Natural range 0 .. 100; task type Player is entry Punch (P : in Positive); entry Stamina (S : in Integer); entry Pass; entry Get_Id (Id : out Player_Id_Type); entry Get_Stamina (S : out Integer); entry Quit; end Player; Players : array (Positive range 1 .. 10) of Player; subtype Player_Index is Positive range Players'First .. Players'Last; task body Player is Personal_Id : Integer; package R is new Ada.Numerics.Discrete_Random (Player_Id_Type); G : R.Generator; My_Stamina : Integer := 80; Delay_Count : Natural := 0; begin R.Reset (G); Personal_Id := R.Random (G); Put ("Player "); Put (Personal_Id); Put_Line (" is born!"); loop select accept Get_Stamina (S : out Integer) do S := My_Stamina; end Get_Stamina; or accept Punch (P : in Positive) do Put ("Player "); Put (Personal_Id); Put (" punches "); declare Punched_Id : Player_Id_Type; begin select Players (P).Get_Id (Punched_Id); Put (Punched_Id); New_Line; or delay 1.0; Put ("> unknown < (goes by the idx of "); Put (P); Put_Line (")"); end select; end; select Players (P).Stamina (-40); My_Stamina := My_Stamina - 5; or delay 1.0; end select; My_Stamina := My_Stamina - 20; end Punch; or accept Stamina (S : in Integer) do My_Stamina := My_Stamina + S; end Stamina; or accept Pass do if My_Stamina < 0 then My_Stamina := My_Stamina + 3; end if; end Pass; or accept Get_Id (Id : out Player_Id_Type) do Id := Personal_Id; end Get_Id; or delay 2.5; if Delay_Count > 5 then Delay_Count := 0; My_Stamina := My_Stamina / 2; end if; Delay_Count := Delay_Count + 1; Put ("Player "); Put (Personal_Id); Put (" STAMINA "); Put (My_Stamina); New_Line; if My_Stamina < 30 then select accept Quit; Put ("Player "); Put (Personal_Id); Put_Line (" QUITS"); exit; or delay 1.0; Put_Line ("No quit request within 1 sec"); end select; end if; end select; if My_Stamina < 11 then Put_Line ("^^^^^ Spontaneous death ^^^^^^"); exit; end if; end loop; end Player; type Action_Type is (Punch_Someone, Peace, Check_Turn); package RP is new Ada.Numerics.Discrete_Random (Player_Index); package RA is new Ada.Numerics.Discrete_Random (Action_Type); Player_Gen : RP.Generator; I, J : Player_Index; Num_Of_Alive_Players : Natural; Action_Gen : RA.Generator; Action : Action_Type; begin RP.Reset (Player_Gen); RA.Reset (Action_Gen); loop Num_Of_Alive_Players := 0; for P of Players loop if not P'Terminated then Num_Of_Alive_Players := Num_Of_Alive_Players + 1; end if; end loop; Put ("ALIVE PLAYERS "); Put (Num_Of_Alive_Players); New_Line; exit when Num_Of_Alive_Players < 3; I := RP.Random (Player_Gen); if not Players (I)'Terminated then Action := RA.Random (Action_Gen); Put_Line (Action_Type'Image (Action)); case Action is when Punch_Someone => J := RP.Random (Player_Gen); if I /= J then select -- do not hang on punch delay 1.0; Put_Line ("Not punched!"); then abort Players (I).Punch (J); end select; end if; when Peace => select -- do not hang on pass delay 1.0; Put_Line ("No passed!"); then abort Players (I).Pass; end select; when Check_Turn => declare Stamina : Integer; begin select delay 1.0; Put ("WHAT Stamina "); Put (I); New_Line; then abort Players (I).Get_Stamina (Stamina); if Stamina < 30 then select delay 0.4; then abort Players (I).Quit; end select; end if; end select; end; end case; delay 0.5; Put_Line ("*** ANOTHER ROUND ***"); end if; end loop; Put_Line ("==================="); for P of Players loop if not P'Terminated then declare P_Id : Player_Id_Type; begin P.Get_Id (P_Id); Put ("##### PLAYER "); Put (P_Id); Put_Line (" #####"); P.Quit; end; end if; end loop; end;
burratoo/Acton
Ada
4,729
ads
------------------------------------------------------------------------------------------ -- -- -- OAK CORE SUPPORT PACKAGE -- -- ARM CORTEX M4F -- -- -- -- ISA.ARM.CORTEX_M4.NVIC -- -- -- -- Copyright (C) 2014-2021, Patrick Bernardi -- -- -- ------------------------------------------------------------------------------------------ with ISA.ARM.Cortex_M4.Exceptions; use ISA.ARM.Cortex_M4.Exceptions; with System; use System; package ISA.ARM.Cortex_M4.NVIC with Preelaborate is --------------------------- -- NVIC Memory Addresses -- --------------------------- NVIC_Base_Address : constant := 16#E000_E000#; ISER_Offset_Address : constant := 16#100#; ISCR_Offset_Address : constant := 16#180#; ISPR_Offset_Address : constant := 16#200#; ICPR_Offset_Address : constant := 16#280#; IABR_Offset_Address : constant := 16#300#; IPR_Offset_Address : constant := 16#400#; STIR_Offset_Address : constant := 16#F00#; ----------------------- -- Hardware Features -- ----------------------- subtype NVIC_Interrupt_Id is Exception_Id range 0 .. 240; ---------------- -- NVIC Types -- ---------------- type Interrupt_Enable_Set is array (NVIC_Interrupt_Id) of Enable_No_Change_Type with Pack; type Interrupt_Disable_Set is array (NVIC_Interrupt_Id) of Disable_No_Change_Type with Pack; type Interrupt_Enabled_Set is array (NVIC_Interrupt_Id) of Enabled_Type with Pack; type Set_Type is (No_Change, Set); type Interrupt_Set_Set is array (NVIC_Interrupt_Id) of Set_Type with Pack; type Clear_Type is (No_Change, Clear); type Interrupt_Clear_Set is array (NVIC_Interrupt_Id) of Clear_Type with Pack; type Pending_Type is (Not_Pending, Pending); type Interrupt_Pending_Set is array (NVIC_Interrupt_Id) of Pending_Type with Pack; type Active_Type is (Inactive, Active); type Interrupt_Active_Set is array (NVIC_Interrupt_Id) of Active_Type with Pack; type Software_Trigger_Interrupt_Type is record Interrupt : NVIC_Interrupt_Id; end record with Size => Word_Size; ------------------------------ -- Hardware Representations -- ------------------------------ for Software_Trigger_Interrupt_Type use record Interrupt at 0 range 0 .. 31; -- This should be 0 .. 8, but need to force a 32 bit access to the field end record; -------------------- -- NVIC Registers -- -------------------- Interrupt_Enable_Register : Interrupt_Enable_Set with Address => System'To_Address (NVIC_Base_Address + ISER_Offset_Address); Interrupt_Disable_Register : Interrupt_Disable_Set with Address => System'To_Address (NVIC_Base_Address + ISCR_Offset_Address); Interrupt_Enabled_Register : Interrupt_Enabled_Set with Address => System'To_Address (NVIC_Base_Address + ISER_Offset_Address); Interrupt_Set_Pending_Register : Interrupt_Set_Set with Address => System'To_Address (NVIC_Base_Address + ISPR_Offset_Address); Interrupt_Clear_Pending_Register : Interrupt_Clear_Set with Address => System'To_Address (NVIC_Base_Address + ICPR_Offset_Address); Interrupt_Pending_Register : Interrupt_Pending_Set with Address => System'To_Address (NVIC_Base_Address + ISPR_Offset_Address); Interrupt_Active_Register : Interrupt_Active_Set with Address => System'To_Address (NVIC_Base_Address + IABR_Offset_Address); Interrupt_Priority_Register : array (NVIC_Interrupt_Id) of Exception_Priority with Address => System'To_Address (NVIC_Base_Address + IPR_Offset_Address); Software_Trigger_Interrupt_Register : Software_Trigger_Interrupt_Type with Address => System'To_Address (NVIC_Base_Address + STIR_Offset_Address); end ISA.ARM.Cortex_M4.NVIC;
Gabriel-Degret/adalib
Ada
715
ads
-- Standard Ada library specification -- Copyright (c) 2004-2016 AXE Consultants -- Copyright (c) 2004, 2005, 2006 Ada-Europe -- Copyright (c) 2000 The MITRE Corporation, Inc. -- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc. -- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual --------------------------------------------------------------------------- package System.Multiprocessors is pragma Preelaborate(Multiprocessors); type CPU_Range is range 0 .. implementation_defined; Not_A_Specific_CPU : constant CPU_Range := 0; subtype CPU is CPU_Range range 1 .. CPU_Range'Last; function Number_Of_CPUs return CPU; end System.Multiprocessors;
stcarrez/mat
Ada
2,766
adb
----------------------------------------------------------------------- -- mat-readers-tests -- Unit tests for MAT readers -- Copyright (C) 2014, 2015, 2019, 2021 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Test_Caller; with MAT.Readers.Streams.Files; package body MAT.Targets.Tests is package Caller is new Util.Test_Caller (Test, "Files"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test MAT.Targets.Read_File", Test_Read_File'Access); Caller.Add_Test (Suite, "Test MAT.Types.Tick_Value", Test_Conversions'Access); end Add_Tests; -- ------------------------------ -- Test reading a file into a string -- Reads this ada source file and checks we have read it correctly -- ------------------------------ procedure Test_Read_File (T : in out Test) is pragma Unreferenced (T); Path : constant String := Util.Tests.Get_Path ("regtests/files/file-v1.dat"); Target : MAT.Targets.Target_Type; Reader : MAT.Readers.Streams.Files.File_Reader_Type; begin Target.Initialize (Reader); Reader.Open (Path); Reader.Read_All; end Test_Read_File; -- ------------------------------ -- Test various type conversions. -- ------------------------------ procedure Test_Conversions (T : in out Test) is use MAT.Types; Time : MAT.Types.Target_Tick_Ref; begin Time := MAT.Types.Tick_Value ("1.1"); Util.Tests.Assert_Equals (T, 1, Natural (Time / 1_000000), "Invalid Tick_Value conversion"); Util.Tests.Assert_Equals (T, 100_000, Natural (Time mod 1_000000), "Invalid Tick_Value conversion"); Time := MAT.Types.Tick_Value ("12.001234"); Util.Tests.Assert_Equals (T, 12, Natural (Time / 1_000000), "Invalid Tick_Value conversion"); Util.Tests.Assert_Equals (T, 1_234, Natural (Time mod 1_000000), "Invalid Tick_Value conversion"); end Test_Conversions; end MAT.Targets.Tests;
reznikmm/matreshka
Ada
7,001
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.Named_Expression_Elements is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters) return Table_Named_Expression_Element_Node is begin return Self : Table_Named_Expression_Element_Node do Matreshka.ODF_Table.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Table_Prefix); end return; end Create; ---------------- -- Enter_Node -- ---------------- overriding procedure Enter_Node (Self : not null access Table_Named_Expression_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Enter_Table_Named_Expression (ODF.DOM.Table_Named_Expression_Elements.ODF_Table_Named_Expression_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Enter_Node (Visitor, Control); end if; end Enter_Node; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Table_Named_Expression_Element_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Named_Expression_Element; end Get_Local_Name; ---------------- -- Leave_Node -- ---------------- overriding procedure Leave_Node (Self : not null access Table_Named_Expression_Element_Node; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then ODF.DOM.Visitors.Abstract_ODF_Visitor'Class (Visitor).Leave_Table_Named_Expression (ODF.DOM.Table_Named_Expression_Elements.ODF_Table_Named_Expression_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Leave_Node (Visitor, Control); end if; end Leave_Node; ---------------- -- Visit_Node -- ---------------- overriding procedure Visit_Node (Self : not null access Table_Named_Expression_Element_Node; Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class; Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class; Control : in out XML.DOM.Visitors.Traverse_Control) is begin if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then ODF.DOM.Iterators.Abstract_ODF_Iterator'Class (Iterator).Visit_Table_Named_Expression (Visitor, ODF.DOM.Table_Named_Expression_Elements.ODF_Table_Named_Expression_Access (Self), Control); else Matreshka.DOM_Elements.Abstract_Element_Node (Self.all).Visit_Node (Iterator, Visitor, Control); end if; end Visit_Node; begin Matreshka.DOM_Documents.Register_Element (Matreshka.ODF_String_Constants.Table_URI, Matreshka.ODF_String_Constants.Named_Expression_Element, Table_Named_Expression_Element_Node'Tag); end Matreshka.ODF_Table.Named_Expression_Elements;
tum-ei-rcs/StratoX
Ada
7,059
ads
-- This spec has been automatically generated from STM32F40x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; with HAL; with System; package STM32_SVD.FLASH is pragma Preelaborate; --------------- -- Registers -- --------------- ------------------ -- ACR_Register -- ------------------ subtype ACR_LATENCY_Field is HAL.UInt3; -- Flash access control register type ACR_Register is record -- Latency LATENCY : ACR_LATENCY_Field := 16#0#; -- unspecified Reserved_3_7 : HAL.UInt5 := 16#0#; -- Prefetch enable PRFTEN : Boolean := False; -- Instruction cache enable ICEN : Boolean := False; -- Data cache enable DCEN : Boolean := False; -- Write-only. Instruction cache reset ICRST : Boolean := False; -- Data cache reset DCRST : Boolean := False; -- unspecified Reserved_13_31 : HAL.UInt19 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ACR_Register use record LATENCY at 0 range 0 .. 2; Reserved_3_7 at 0 range 3 .. 7; PRFTEN at 0 range 8 .. 8; ICEN at 0 range 9 .. 9; DCEN at 0 range 10 .. 10; ICRST at 0 range 11 .. 11; DCRST at 0 range 12 .. 12; Reserved_13_31 at 0 range 13 .. 31; end record; ----------------- -- SR_Register -- ----------------- -- Status register type SR_Register is record -- End of operation EOP : Boolean := False; -- Operation error OPERR : Boolean := False; -- unspecified Reserved_2_3 : HAL.UInt2 := 16#0#; -- Write protection error WRPERR : Boolean := False; -- Programming alignment error PGAERR : Boolean := False; -- Programming parallelism error PGPERR : Boolean := False; -- Programming sequence error PGSERR : Boolean := False; -- unspecified Reserved_8_15 : HAL.Byte := 16#0#; -- Read-only. Busy BSY : Boolean := False; -- unspecified Reserved_17_31 : HAL.UInt15 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SR_Register use record EOP at 0 range 0 .. 0; OPERR at 0 range 1 .. 1; Reserved_2_3 at 0 range 2 .. 3; WRPERR at 0 range 4 .. 4; PGAERR at 0 range 5 .. 5; PGPERR at 0 range 6 .. 6; PGSERR at 0 range 7 .. 7; Reserved_8_15 at 0 range 8 .. 15; BSY at 0 range 16 .. 16; Reserved_17_31 at 0 range 17 .. 31; end record; ----------------- -- CR_Register -- ----------------- subtype CR_SNB_Field is HAL.UInt4; subtype CR_PSIZE_Field is HAL.UInt2; -- Control register type CR_Register is record -- Programming PG : Boolean := False; -- Sector Erase SER : Boolean := False; -- Mass Erase MER : Boolean := False; -- Sector number SNB : CR_SNB_Field := 16#0#; -- unspecified Reserved_7_7 : HAL.Bit := 16#0#; -- Program size PSIZE : CR_PSIZE_Field := 16#0#; -- unspecified Reserved_10_15 : HAL.UInt6 := 16#0#; -- Start STRT : Boolean := False; -- unspecified Reserved_17_23 : HAL.UInt7 := 16#0#; -- End of operation interrupt enable EOPIE : Boolean := False; -- Error interrupt enable ERRIE : Boolean := False; -- unspecified Reserved_26_30 : HAL.UInt5 := 16#0#; -- Lock LOCK : Boolean := True; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR_Register use record PG at 0 range 0 .. 0; SER at 0 range 1 .. 1; MER at 0 range 2 .. 2; SNB at 0 range 3 .. 6; Reserved_7_7 at 0 range 7 .. 7; PSIZE at 0 range 8 .. 9; Reserved_10_15 at 0 range 10 .. 15; STRT at 0 range 16 .. 16; Reserved_17_23 at 0 range 17 .. 23; EOPIE at 0 range 24 .. 24; ERRIE at 0 range 25 .. 25; Reserved_26_30 at 0 range 26 .. 30; LOCK at 0 range 31 .. 31; end record; -------------------- -- OPTCR_Register -- -------------------- subtype OPTCR_BOR_LEV_Field is HAL.UInt2; subtype OPTCR_RDP_Field is HAL.Byte; subtype OPTCR_nWRP_Field is HAL.UInt12; -- Flash option control register type OPTCR_Register is record -- Option lock OPTLOCK : Boolean := False; -- Option start OPTSTRT : Boolean := False; -- BOR reset Level BOR_LEV : OPTCR_BOR_LEV_Field := 16#1#; -- unspecified Reserved_4_4 : HAL.Bit := 16#1#; -- WDG_SW User option bytes WDG_SW : Boolean := False; -- nRST_STOP User option bytes nRST_STOP : Boolean := False; -- nRST_STDBY User option bytes nRST_STDBY : Boolean := False; -- Read protect RDP : OPTCR_RDP_Field := 16#0#; -- Not write protect nWRP : OPTCR_nWRP_Field := 16#0#; -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for OPTCR_Register use record OPTLOCK at 0 range 0 .. 0; OPTSTRT at 0 range 1 .. 1; BOR_LEV at 0 range 2 .. 3; Reserved_4_4 at 0 range 4 .. 4; WDG_SW at 0 range 5 .. 5; nRST_STOP at 0 range 6 .. 6; nRST_STDBY at 0 range 7 .. 7; RDP at 0 range 8 .. 15; nWRP at 0 range 16 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- FLASH type FLASH_Peripheral is record -- Flash access control register ACR : ACR_Register; -- Flash key register KEYR : HAL.Word; -- Flash option key register OPTKEYR : HAL.Word; -- Status register SR : SR_Register; -- Control register CR : CR_Register; -- Flash option control register OPTCR : OPTCR_Register; end record with Volatile; for FLASH_Peripheral use record ACR at 0 range 0 .. 31; KEYR at 4 range 0 .. 31; OPTKEYR at 8 range 0 .. 31; SR at 12 range 0 .. 31; CR at 16 range 0 .. 31; OPTCR at 20 range 0 .. 31; end record; -- FLASH FLASH_Periph : aliased FLASH_Peripheral with Import, Address => FLASH_Base; end STM32_SVD.FLASH;
zhmu/ananas
Ada
3,899
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . W C H _ W T S -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package contains the routine used to convert wide strings and wide -- wide strings to strings for use by wide and wide wide character attributes -- (value, image etc.) and also by the numeric IO subpackages of -- Ada.Text_IO.Wide_Text_IO and Ada.Text_IO.Wide_Wide_Text_IO. with System.WCh_Con; package System.WCh_WtS is pragma Pure; function Wide_String_To_String (S : Wide_String; EM : System.WCh_Con.WC_Encoding_Method) return String; -- This routine simply takes its argument and converts it to a string, -- using the internal compiler escape sequence convention (defined in -- package Widechar) to translate characters that are out of range -- of type String. In the context of the Wide_Value attribute, the -- argument is the original attribute argument, and the result is used -- in a call to the corresponding Value attribute function. If the method -- for encoding is a shift-in, shift-out convention, then it is assumed -- that normal (non-wide character) mode holds at the start and end of -- the result string. EM indicates the wide character encoding method. -- Note: in the WCEM_Brackets case, we only use the brackets encoding -- for characters greater than 16#FF#. The lowest index of the returned -- String is equal to S'First. function Wide_Wide_String_To_String (S : Wide_Wide_String; EM : System.WCh_Con.WC_Encoding_Method) return String; -- Same processing, except for Wide_Wide_String end System.WCh_WtS;
reznikmm/matreshka
Ada
5,031
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Generic_Collections; package AMF.UML.Reply_Actions.Collections is pragma Preelaborate; package UML_Reply_Action_Collections is new AMF.Generic_Collections (UML_Reply_Action, UML_Reply_Action_Access); type Set_Of_UML_Reply_Action is new UML_Reply_Action_Collections.Set with null record; Empty_Set_Of_UML_Reply_Action : constant Set_Of_UML_Reply_Action; type Ordered_Set_Of_UML_Reply_Action is new UML_Reply_Action_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_UML_Reply_Action : constant Ordered_Set_Of_UML_Reply_Action; type Bag_Of_UML_Reply_Action is new UML_Reply_Action_Collections.Bag with null record; Empty_Bag_Of_UML_Reply_Action : constant Bag_Of_UML_Reply_Action; type Sequence_Of_UML_Reply_Action is new UML_Reply_Action_Collections.Sequence with null record; Empty_Sequence_Of_UML_Reply_Action : constant Sequence_Of_UML_Reply_Action; private Empty_Set_Of_UML_Reply_Action : constant Set_Of_UML_Reply_Action := (UML_Reply_Action_Collections.Set with null record); Empty_Ordered_Set_Of_UML_Reply_Action : constant Ordered_Set_Of_UML_Reply_Action := (UML_Reply_Action_Collections.Ordered_Set with null record); Empty_Bag_Of_UML_Reply_Action : constant Bag_Of_UML_Reply_Action := (UML_Reply_Action_Collections.Bag with null record); Empty_Sequence_Of_UML_Reply_Action : constant Sequence_Of_UML_Reply_Action := (UML_Reply_Action_Collections.Sequence with null record); end AMF.UML.Reply_Actions.Collections;
reznikmm/matreshka
Ada
10,452
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-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$ ------------------------------------------------------------------------------ -- XXX It would be interesting to add support for syntax sugar of indexing -- operation. ------------------------------------------------------------------------------ pragma Ada_2012; private with Ada.Finalization; --with League.Characters; with League.Strings; with League.String_Vectors; private with Matreshka.Internals.Files; package League.Directories is pragma Preelaborate; -- pragma Remote_Types; type Directory_Information is tagged private; pragma Preelaborable_Initialization (Directory_Information); function To_Directory_Information (Path : League.Strings.Universal_String) return Directory_Information; -- Creates new object pointing to the given directory. Empty path points to -- program's working directory ("."). -- function Absolute_File_Path -- (Self : Directory_Information'Class; -- Name : League.Strings.Universal_String) -- return League.Strings.Universal_String; -- -- function Absolute_Path -- (Self : Directory_Information'Class) -- return League.Strings.Universal_String; -- -- function Canonical_Path -- (Self : Directory_Information'Class) -- return League.Strings.Universal_String; -- -- function Change_Directory -- (Self : Directory_Information'Class) return Boolean; -- -- function Change_Directory -- (Self : Directory_Information'Class; -- Directory : League.Strings.Universal_String) return Boolean; -- -- procedure Change_Directory (Self : Directory_Information'Class); -- ---- function Change_Directory_Up (Self : in out Directory_Information'Class) -- -- function Count (Directory : League.Strings.Universal_String) return Natural; -- -- function Create_Directory -- (Self : Directory_Information'Class) return Boolean; -- -- procedure Create_Directory (Self : Directory_Information'Class); -- -- function Create_Directory -- (Self : Directory_Information'Class; -- Name : League.Strings.Universal_String) return Boolean; -- -- procedure Create_Directory -- (Self : Directory_Information'Class; -- Name : League.Strings.Universal_String); -- -- function Create_Path -- (Self : Directory_Information'Class) return Boolean; -- -- procedure Create_Path (Self : Directory_Information'Class); -- -- function Create_Path -- (Self : Directory_Information'Class; -- Path : League.Strings.Universal_String) return Boolean; -- -- procedure Create_Path -- (Self : Directory_Information'Class; -- Path : League.Strings.Universal_String); -- ---- function Entry_Information_List ---- (Self : Directory_Information'Class) ---- return File_Information_Vector; function Entry_List (Self : Directory_Information'Class) return League.String_Vectors.Universal_String_Vector; -- Returns a list of the names of all the files and directories in the -- directory. -- function Exists (Self : Directory_Information'Class) return Boolean; -- -- function Exists -- (Self : Directory_Information'Class; -- Directory : League.Strings.Universal_String) return Boolean; -- -- function Is_Absolute (Self : Directory_Information'Class) return Boolean; -- -- function Is_Readable (Self : Directory_Information'Class) return Boolean; -- -- function Is_Relative (Self : Directory_Information'Class) return Boolean; -- -- function Is_Root (Self : Directory_Information'Class) return Boolean; -- -- function Make_Absolute -- (Self : in out Directory_Information'Class) return Boolean; -- -- procedure Make_Absolute (Self : in out Directory_Information'Class); -- -- function Name -- (Self : Directory_Information'Class) -- return League.Strings.Universal_String; -- -- function Path -- (Self : Directory_Information'Class) -- return League.Strings.Universal_String; -- -- procedure Refresh (Self : in out Directory_Information'Class); -- -- function Relative_File_Path -- (Self : Directory_Information'Class; -- Path : League.Strings.Universal_String) -- return League.Strings.Universal_String; -- -- function Remove -- (Self : Directory_Information'Class; -- File : League.Strings.Universal_String) return Boolean; -- -- procedure Remove -- (Self : Directory_Information'Class; -- File : League.Strings.Universal_String); -- -- function Remove_Directory -- (Self : Directory_Information'Class) return Boolean; -- -- procedure Remove_Directory (Self : Directory_Information'Class); -- -- function Remove_Directory -- (Self : Directory_Information'Class; -- Name : League.Strings.Universal_String) return Boolean; -- -- procedure Remove_Directory -- (Self : Directory_Information'Class; -- Name : League.Strings.Universal_String); -- -- function Remove_Path (Self : Directory_Information'Class) return Boolean; -- -- procedure Remove_Path (Self : Directory_Information'Class); -- -- function Remove_Path -- (Self : Directory_Information'Class; -- Path : League.Strings.Universal_String) return Boolean; -- -- procedure Remove_Path -- (Self : Directory_Information'Class; -- Path : League.Strings.Universal_String); -- -- procedure Set_Path -- (Self : in out Directory_Information'Class; -- Path : League.Strings.Universal_String); -- -- -- -- -- function Change_Directory -- (Directory : League.Strings.Universal_String) return Boolean; -- -- procedure Change_Directory -- (Directory : League.Strings.Universal_String); -- -- function Clean_Path -- (Path : League.Strings.Universal_String) -- return League.Strings.Universal_String; -- -- function Current_Directory return League.Strings.Universal_String; -- -- function Current_Directory return Directory_Information; -- ---- function Drives return File_Information_Vector; -- -- function Drives return League.String_Vectors.Universal_String_Vector; -- -- function From_Native_Separators -- (Path : League.Strings.Universal_String) -- return League.Strings.Universal_String; -- -- function Home return League.Strings.Universal_String; -- -- function Home return Directory_Information; -- -- function Is_Absolute_Path -- (Path : League.Strings.Universal_String) return Boolean; -- -- function Is_Relative_Path -- (Path : League.Strings.Universal_String) return Boolean; -- -- function Root return League.Strings.Universal_String; -- -- function Root return Directory_Information; -- -- function Separator return League.Characters.Universal_Character; -- -- function Temp return League.Strings.Universal_String; -- -- XXX Rename to be close to Ada conventions. -- -- function Temp return Directory_Information; -- -- function To_Native_Separators -- (Path : League.Strings.Universal_String) -- return League.Strings.Universal_String; private type Directory_Information is new Ada.Finalization.Controlled with record Data : Matreshka.Internals.Files.Shared_File_Information_Access; end record; procedure Adjust (Self : in out Directory_Information); procedure Finalize (Self : in out Directory_Information); end League.Directories;
reznikmm/matreshka
Ada
4,269
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Nodes; with XML.DOM.Attributes.Internals; package body ODF.DOM.Attributes.FO.Keep_With_Next.Internals is ------------ -- Create -- ------------ function Create (Node : Matreshka.ODF_Attributes.FO.Keep_With_Next.FO_Keep_With_Next_Access) return ODF.DOM.Attributes.FO.Keep_With_Next.ODF_FO_Keep_With_Next is begin return (XML.DOM.Attributes.Internals.Create (Matreshka.DOM_Nodes.Attribute_Access (Node)) with null record); end Create; ---------- -- Wrap -- ---------- function Wrap (Node : Matreshka.ODF_Attributes.FO.Keep_With_Next.FO_Keep_With_Next_Access) return ODF.DOM.Attributes.FO.Keep_With_Next.ODF_FO_Keep_With_Next is begin return (XML.DOM.Attributes.Internals.Wrap (Matreshka.DOM_Nodes.Attribute_Access (Node)) with null record); end Wrap; end ODF.DOM.Attributes.FO.Keep_With_Next.Internals;
pdaxrom/Kino2
Ada
4,283
ads
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- Sample.Menu_Demo.Aux -- -- -- -- S P E C -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Juergen Pfeifer, 1996 -- Contact: http://www.familiepfeifer.de/Contact.aspx?Lang=en -- Version Control -- $Revision: 1.8 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ with Terminal_Interface.Curses; use Terminal_Interface.Curses; with Terminal_Interface.Curses.Panels; use Terminal_Interface.Curses.Panels; with Terminal_Interface.Curses.Menus; use Terminal_Interface.Curses.Menus; package Sample.Menu_Demo.Aux is procedure Geometry (M : in Menu; L : out Line_Count; C : out Column_Count; Y : out Line_Position; X : out Column_Position); -- Calculate the geometry for a panel beeing able to be used to display -- the menu. function Create (M : Menu; Title : String; Lin : Line_Position; Col : Column_Position) return Panel; -- Create a panel decorated with a frame and the title at the specified -- position. The dimension of the panel is derived from the menus layout. procedure Destroy (M : in Menu; P : in out Panel); -- Destroy all the windowing structures associated with this menu and -- panel. function Get_Request (M : Menu; P : Panel) return Key_Code; -- Centralized request driver for all menus in this sample. This -- gives us a common key binding for all menus. end Sample.Menu_Demo.Aux;
reznikmm/matreshka
Ada
4,559
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Draw.Code_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Draw_Code_Attribute_Node is begin return Self : Draw_Code_Attribute_Node do Matreshka.ODF_Draw.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Draw_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Draw_Code_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Code_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Draw_URI, Matreshka.ODF_String_Constants.Code_Attribute, Draw_Code_Attribute_Node'Tag); end Matreshka.ODF_Draw.Code_Attributes;
reznikmm/matreshka
Ada
3,828
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_Attributes.Style.Rel_Width; package ODF.DOM.Attributes.Style.Rel_Width.Internals is function Create (Node : Matreshka.ODF_Attributes.Style.Rel_Width.Style_Rel_Width_Access) return ODF.DOM.Attributes.Style.Rel_Width.ODF_Style_Rel_Width; function Wrap (Node : Matreshka.ODF_Attributes.Style.Rel_Width.Style_Rel_Width_Access) return ODF.DOM.Attributes.Style.Rel_Width.ODF_Style_Rel_Width; end ODF.DOM.Attributes.Style.Rel_Width.Internals;
apple-oss-distributions/old_ncurses
Ada
4,642
ads
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- Sample.Function_Key_Setting -- -- -- -- S P E C -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Juergen Pfeifer <[email protected]> 1996 -- Version Control -- $Revision: 1.1.1.1 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ with Terminal_Interface.Curses; use Terminal_Interface.Curses; with Terminal_Interface.Curses.Panels; use Terminal_Interface.Curses.Panels; -- This package implements a simple stack of function key label environments. -- package Sample.Function_Key_Setting is procedure Push_Environment (Key : in String; Reset : in Boolean := True); -- Push the definition of the current function keys on an internal -- stack. If the reset flag is true, all labels are reset while -- pushed, so the new environment can assume a tabula rasa. -- The Key defines the new Help Context associated with the new -- Environment. This saves also the currently active Notepad. procedure Pop_Environment; -- Pop the Definitions from the stack and make them the current ones. -- This also restores the Help context and the previous Notepad. procedure Initialize (Mode : Soft_Label_Key_Format := PC_Style; Just : Label_Justification := Left); -- Initialize the environment function Context return String; -- Return the current context identitfier function Find_Context (Key : String) return Boolean; -- Look for a context, return true if it is in the stack, -- false otherwise. procedure Notepad_To_Context (Pan : in Panel); -- Add a panel representing a notepad to the current context. Function_Key_Stack_Error : exception; procedure Default_Labels; -- Set the default labels used in all environments function Notepad_Window return Window; -- Return the current notepad window or Null_Window if there is none. end Sample.Function_Key_Setting;
io7m/coreland-lua-ada
Ada
266
adb
package body Lua.Check_Raise is function Check_Raise (State : Lua.State_t) return Lua.Integer_t is use type Lua.State_t; begin pragma Assert (State /= Lua.State_Error); raise Check_Raise_Error; return 0; end Check_Raise; end Lua.Check_Raise;
zhmu/ananas
Ada
223
adb
package body Freezing1_Pack is function Create_Collection (Factory : in T_Factory) return I_Interface_Collection'Class is begin return Implem'(null record); end Create_Collection; end Freezing1_Pack;
onox/orka
Ada
1,707
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 Orka.SIMD.AVX.Doubles; private with Orka.SIMD.SSE2.Integers.Random; package Orka.SIMD.AVX.Longs.Random.Emulation with SPARK_Mode => On is pragma Pure; use Orka.SIMD.AVX.Doubles; type State is limited private; pragma Preelaborable_Initialization (State); procedure Next (S : in out State; Value : out m256l) with Inline_Always, Global => null, Depends => ((S, Value) => S); -- Use and modify the given state to generate multiple -- random unsigned integers procedure Next (S : in out State; Value : out m256d) with Inline_Always, Global => null, Depends => ((S, Value) => S); -- Use and modify the given state to generate multiple random -- floating-point numbers in the interval [0, 1). procedure Reset (S : out State; Seed : Duration) with Global => null, Depends => (S => Seed), Pre => Seed /= 0.0; private type State is new Orka.SIMD.SSE2.Integers.Random.State; end Orka.SIMD.AVX.Longs.Random.Emulation;
clairvoyant/anagram
Ada
3,400
ads
-- Copyright (c) 2010-2017 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Ada.Unchecked_Deallocation; package Anagram.Grammars.LR is pragma Preelaborate; -- LR item is place of "parsing point" inside production, like this: -- E := A . B C -- or -- E := . A B C -- Kernel LR items are those which point is NOT in the leftmost position, -- except dedicated starting production. type LR_Item is new Part_Count; -- LR_Item represent only kernel items. -- Items in form E := A . B C are encoded as (Part_Index (A)) -- Items in form S' := . S (only for start symbol) are encoded as 0 function To_Item (X : Part_Index) return LR_Item; -- Cast part into LR_Item that point after X. type LR_Item_Count is new Natural; subtype LR_Item_Index is LR_Item_Count range 1 .. LR_Item_Count'Last; type LR_Item_Set is array (LR_Item_Index range <>) of LR_Item; -- Represent set of LR_Items type State_Count is new Natural; subtype State_Index is State_Count range 1 .. State_Count'Last; -- State_Count and State_Index enumerates state of LR parser type Reference is new Integer; -- Represent both terminal or non-terminal symbol. -- Encode terminal reference as (-Terminal_Index) and non-terminal as -- (Non_Terminal_Index) function To_Reference (T : Terminal_Count) return Reference; function To_Reference (NT : Non_Terminal_Index) return Reference; function To_Reference (P : Part) return Reference; pragma Inline (To_Reference); type Go_To_Array is array (Reference range <>, State_Index range <>) of State_Count; type List_Range is record First : LR_Item_Index; Last : LR_Item_Index; end record; -- Boundaries inside LR_Item_Set type List_Range_Array is array (State_Index range <>) of List_Range; -- Boundaries indexed by state type Set_Of_LR_Item_Set (Max_States : State_Index; Max_Items : LR_Item_Index; First_Reference : Reference; Last_Reference : Reference) is record Last_State : State_Count; Last_Item : LR_Item_Count; Ranges : List_Range_Array (1 .. Max_States); List : LR_Item_Set (1 .. Max_Items); Go_To : Go_To_Array (First_Reference .. Last_Reference, 1 .. Max_States); -- Go_To - correspoding state for each symbols and state end record; type Set_Of_LR_Item_Set_Access is access all Set_Of_LR_Item_Set; procedure Free is new Ada.Unchecked_Deallocation (Set_Of_LR_Item_Set, Set_Of_LR_Item_Set_Access); function To_Set (Data : Set_Of_LR_Item_Set_Access; State : State_Index) return LR_Item_Set; -- Extract LR_Item set by State index function Go (Input : Grammar; Data : LR_Item_Set; Symbol : Reference) return LR_Item_Set; -- Find 'goto' set for given item set and terminal/non-terminal Symbol. -- This function expects only kernel items in Data and returns only -- kernel items in result. function Items (Input : Grammar) return Set_Of_LR_Item_Set_Access; -- Find set of sets of LR(0) items for given grammar function To_Production (Input : Grammar; Item : LR_Item) return Production_Index; end Anagram.Grammars.LR;
reznikmm/matreshka
Ada
3,724
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Dr3d_Texture_Mode_Attributes is pragma Preelaborate; type ODF_Dr3d_Texture_Mode_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Dr3d_Texture_Mode_Attribute_Access is access all ODF_Dr3d_Texture_Mode_Attribute'Class with Storage_Size => 0; end ODF.DOM.Dr3d_Texture_Mode_Attributes;
sebsgit/textproc
Ada
13,690
adb
with Ada.Text_IO; with Ada.Unchecked_Deallocation; with System.Address_To_Access_Conversions; package body cl_objects is procedure Find_Gpu_Device(platf: out Platform_ID; dev: out Device_ID) is cl_code: opencl.Status; platform_ids: constant opencl.Platforms := opencl.Get_Platforms(cl_code); begin if cl_code = opencl.SUCCESS then for p_id of platform_ids loop declare device_ids: constant opencl.Devices := opencl.Get_Devices(id => p_id, dev_type => opencl.DEVICE_TYPE_GPU, result_status => cl_code); begin if cl_code = opencl.SUCCESS and device_ids'Length > 0 then platf := p_id; dev := device_ids(1); exit; end if; end; end loop; end if; end Find_Gpu_Device; function Create(context_platform: in Platform_ID; context_device: in Device_ID; result_status: out Status) return Context is begin return ctx: Context do ctx.device := context_device; ctx.handle := opencl.Create_Context(context_platform => context_platform, context_device => context_device, result_status => result_status); end return; end Create; function Create_Gpu(result_status: out Status) return Context is platf_id: Platform_ID := 0; dev_id: Device_ID := 0; begin Find_Gpu_Device(platf_id, dev_id); return Create(platf_id, dev_id, result_status); end Create_Gpu; function Create_Program(ctx: in out Context'Class; source: in String; result_status: out Status) return Program is begin return prog: Program do prog.handle := opencl.Create_Program(ctx => ctx.handle, source => source, result_status => result_status); end return; end Create_Program; function Create_Command_Queue(ctx: in out Context'Class; dev: in Device_ID; result_status: out Status) return Command_Queue is begin return q: Command_Queue do q.handle := opencl.Create_Command_Queue(ctx => ctx.handle, dev => dev, result_status => result_status); end return; end Create_Command_Queue; function Create_Command_Queue(ctx: in out Context'Class; result_status: out Status) return Command_Queue is begin return Create_Command_Queue(ctx, ctx.device, result_status); end Create_Command_Queue; function Get_ID(ctx: in out Context'Class) return Context_ID is begin return ctx.handle; end Get_ID; function Create_Buffer(ctx: in out Context'Class; flags: in Mem_Flags; size: Positive; host_ptr: System.Address; result_status: out Status) return Buffer is begin return buff: Buffer do buff.handle := opencl.Create_Buffer(ctx => ctx.handle, flags => flags, size => size, host_ptr => host_ptr, result_status => result_status); end return; end Create_Buffer; function Enqueue_Write(queue: in out Command_Queue'Class; mem_ob: in out Buffer'Class; offset: Natural; size: Positive; ptr: System.Address; events_to_wait_for: in Events; code: out Status) return Event is ev_handle: Event_ID; begin return ev: Event do code := opencl.Enqueue_Write(queue => queue.handle, mem_ob => mem_ob.handle, block_write => False, offset => offset, size => size, ptr => ptr, events_to_wait_for => events_to_wait_for, event => ev_handle); ev.handle := ev_handle; end return; end Enqueue_Write; function Enqueue_Read(queue: in out Command_Queue'Class; mem_ob: in out Buffer'Class; offset: Natural; size: Positive; ptr: System.Address; events_to_wait_for: in Events; code: out Status) return Event is ev_handle: Event_ID; begin return ev: Event do code := opencl.Enqueue_Read(queue => queue.handle, mem_ob => mem_ob.handle, block_read => False, offset => offset, size => size, ptr => ptr, events_to_wait_for => events_to_wait_for, event => ev_handle); ev.handle := ev_handle; end return; end Enqueue_Read; function Enqueue_Read(queue: in out Command_Queue'Class; mem_ob: in out Buffer'Class; offset: Natural; size: Positive; ptr: System.Address; code: out Status) return Event is no_events: opencl.Events(1 .. 0); begin return Enqueue_Read(queue, mem_ob, offset, size, ptr, no_events, code); end Enqueue_Read; function Enqueue_Kernel(queue: in out Command_Queue'Class; kern: in out Kernel'Class; glob_ws: Dimensions; loc_ws: Dimensions; events_to_wait_for: in Events; code: out Status) return Event is ev_handle: Event_ID; glob_offs: constant Offsets(glob_ws'Range) := (others => 0); begin return ev: Event do code := opencl.Enqueue_Kernel(queue => queue.handle, kernel => kern.handle, global_offset => glob_offs, global_work_size => glob_ws, local_work_size => loc_ws, event_wait_list => events_to_wait_for, event => ev_handle); ev.handle := ev_handle; end return; end Enqueue_Kernel; function Enqueue_Kernel(queue: in out Command_Queue'Class; kern: in out Kernel'Class; glob_ws: Dimensions; loc_ws: Dimensions; code: out Status) return Event is no_events: Events(1 .. 0); begin return Enqueue_Kernel(queue, kern, glob_ws, loc_ws, no_events, code); end Enqueue_Kernel; function Build(prog: in out Program'Class; device: in Device_ID; options: in String) return Status is begin return opencl.Build_Program(id => prog.handle, device => device, options => options); end Build; function Build(ctx: in out Context'Class; prog: in out Program'Class; options: in String) return Status is begin return Build(prog, ctx.device, options); end Build; function Get_Build_Log(prog: in out Program'Class; device: in Device_ID) return String is cl_stat: opencl.Status; begin return opencl.Get_Program_Build_Log(id => prog.handle, device => device, result_status => cl_stat); end Get_Build_Log; function Get_Build_Log(ctx: in out Context'Class; prog: in out Program'Class) return String is begin return Get_Build_Log(prog, ctx.device); end Get_Build_Log; function Create_Kernel(prog: in out Program'Class; name: in String; result_status: out Status) return Kernel is begin return kern: Kernel do kern.handle := opencl.Create_Kernel(program => prog.handle, name => name, result_status => result_status); end return; end Create_Kernel; function Set_Arg(kern: in out Kernel; index: Natural; size: Positive; address: System.Address) return Status is begin return opencl.Set_Kernel_Arg(id => kern.handle, index => index, size => size, address => address); end Set_Arg; function Wait(ev: in out Event) return Status is event_ids: constant opencl.Events(1 .. 1) := (1 => ev.handle); begin return opencl.Wait_For_Events(event_ids); end Wait; function Get_Handle(ev: in Event) return opencl.Event_ID is begin return ev.handle; end Get_Handle; function Create_Empty return Event is begin return ev: Event do ev.handle := 0; end return; end Create_Empty; function Create_Event(id: in Event_ID) return Event is cl_code: opencl.Status; begin return ev: Event do ev.handle := id; if id /= 0 then cl_code := opencl.Retain_Event(id); end if; end return; end Create_Event; function Finish(queue: in out Command_Queue) return Status is begin return opencl.Finish(queue.handle); end Finish; function Get_Address(buff: in out Buffer'Class) return System.Address is package Addr_Conv is new System.Address_To_Access_Conversions(opencl.Mem_ID); begin return Addr_Conv.To_Address(buff.handle'Access); end Get_Address; function Get_ID(buff: in Buffer) return opencl.Mem_ID is begin return buff.handle; end Get_ID; procedure Set_ID(buff: in out Buffer; id: in opencl.Mem_ID) is begin buff.handle := id; end Set_ID; generic type Handle_Type is new Raw_Address; with function Release_Callback (handle: in Handle_Type) return opencl.Status; package Finalization_Impl is procedure Release (handle: Handle_Type); end Finalization_Impl; package body Finalization_Impl is procedure Release (handle: Handle_Type) is cl_code: opencl.Status; begin if handle /= 0 then cl_code := Release_Callback(handle); end if; end Release; end Finalization_Impl; procedure Finalize(This: in out Context) is package Cleanup is new Finalization_Impl(Handle_Type => opencl.Context_ID, Release_Callback => opencl.Release_Context); begin Cleanup.Release(This.handle); end Finalize; procedure Finalize(This: in out Program) is package Cleanup is new Finalization_Impl(Handle_Type => opencl.Program_ID, Release_Callback => opencl.Release_Program); begin Cleanup.Release(This.handle); end Finalize; procedure Finalize(This: in out Kernel) is package Cleanup is new Finalization_Impl(Handle_Type => opencl.Kernel_ID, Release_Callback => opencl.Release_Kernel); begin Cleanup.Release(This.handle); end Finalize; procedure Finalize(This: in out Event) is package Cleanup is new Finalization_Impl(Handle_Type => opencl.Event_ID, Release_Callback => opencl.Release_Event); begin Cleanup.Release(This.handle); end Finalize; procedure Finalize(This: in out Command_Queue) is package Cleanup is new Finalization_Impl(Handle_Type => opencl.Command_Queue, Release_Callback => opencl.Release_Command_Queue); begin Cleanup.Release(This.handle); end Finalize; procedure Finalize(This: in out Buffer) is package Cleanup is new Finalization_Impl(Handle_Type => opencl.Mem_ID, Release_Callback => opencl.Release); begin Cleanup.Release(This.handle); end Finalize; procedure Free_Context_Impl is new Ada.Unchecked_Deallocation(Object => Context, Name => Context_Access); procedure Free_Command_Queue_Impl is new Ada.Unchecked_Deallocation(Object => Command_Queue, Name => Command_Queue_Access); procedure Free_Program_Impl is new Ada.Unchecked_Deallocation(Object => Program, Name => Program_Access); procedure Free_Kernel_Impl is new Ada.Unchecked_Deallocation(Object => Kernel, Name => Kernel_Access); procedure Free_Buffer_Impl is new Ada.Unchecked_Deallocation(Object => Buffer, Name => Buffer_Access); procedure Free(ob: in out Context_Access) is begin Free_Context_Impl(ob); end Free; procedure Free(ob: in out Command_Queue_Access) is begin Free_Command_Queue_Impl(ob); end Free; procedure Free(ob: in out Program_Access) is begin Free_Program_Impl(ob); end Free; procedure Free(ob: in out Kernel_Access) is begin Free_Kernel_Impl(ob); end Free; procedure Free(ob: in out Buffer_Access) is begin Free_Buffer_Impl(ob); end Free; end cl_objects;
jam3st/edk2
Ada
3,016
adb
with HW.GFX; with HW.GFX.Framebuffer_Filler; with HW.GFX.GMA; with HW.GFX.GMA.Display_Probing; use HW.GFX; use HW.GFX.GMA; use HW.GFX.GMA.Display_Probing; with HW.Debug; with HW.Debug_Sink; with GMA.Mainboard; package body GMA is fb_valid : boolean := false; linear_fb_addr : word64; fb : Framebuffer_Type; function fill_lb_framebuffer (framebuffer : in out lb_framebuffer) return Interfaces.C.int is use type word64; use type Interfaces.C.int; begin if fb_valid then framebuffer := ( physical_address => linear_fb_addr, x_resolution => Word64(fb.Width), y_resolution => Word64(fb.Height), bpp => 32 ); Debug.Put ("fill_lb_framebuffer at "); Debug.Put_Word64(linear_fb_addr); Debug.Put (" and is "); Debug.Put_Int32(fb.Width); Debug.Put (" x "); Debug.Put_Int32(fb.Height); Debug.Put_Line (""); return 0; else return -1; end if; end fill_lb_framebuffer; ---------------------------------------------------------------------------- procedure gfxinit (lightup_ok : out Interfaces.C.int) is use type pos32; use type word64; ports : Port_List; configs : Pipe_Configs; success : boolean; min_h : pos16 := pos16'last; min_v : pos16 := pos16'last; begin lightup_ok := 0; HW.GFX.GMA.Initialize (Success => success); if success then ports := Mainboard.ports; HW.GFX.GMA.Display_Probing.Scan_Ports (configs, ports); if configs (Primary).Port /= Disabled then for i in Pipe_Index loop exit when configs (i).Port = Disabled; min_h := pos16'min (min_h, configs (i).Mode.H_Visible); min_v := pos16'min (min_v, configs (i).Mode.V_Visible); end loop; fb := configs (Primary).Framebuffer; fb.Width := Width_Type (min_h); fb.Height := Height_Type (min_v); fb.Stride := Div_Round_Up (fb.Width, 16) * 16; fb.V_Stride := fb.Height; for i in Pipe_Index loop exit when configs (i).Port = Disabled; configs (i).Framebuffer := fb; end loop; HW.GFX.GMA.Dump_Configs (configs); HW.GFX.GMA.Setup_Default_FB (FB => fb, Clear => true, Success => success); if success then HW.GFX.GMA.Update_Outputs (configs); HW.GFX.GMA.Map_Linear_FB (linear_fb_addr, fb); fb_valid := linear_fb_addr /= 0; lightup_ok := (if fb_valid then 1 else 0); end if; end if; end if; end gfxinit; procedure test_debugprint is begin HW.Debug_Sink.Put("\ngma test debug printt ok\n"); end test_debugprint; end GMA;
reznikmm/matreshka
Ada
3,594
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Elements.Generic_Hash; function AMF.OCL.If_Exps.Hash is new AMF.Elements.Generic_Hash (OCL_If_Exp, OCL_If_Exp_Access);
aeszter/lox-spark
Ada
728
ads
with SPARK.Text_IO; use SPARK.Text_IO; package Error_Reporter with SPARK_Mode, Abstract_State => State, Initializes => State is pragma Elaborate_Body; function Had_Error return Boolean with Global => (input => State); procedure Error (Line_No : Positive; Message : String) with Global => (in_out => (Standard_Error, State)), Pre => Message'Length <= 1_024, Post => Had_Error; procedure Report (Line_No : Positive; Where, Message : String) with Global => (in_out => (Standard_Error, State)), Pre => Message'Length <= 1_024 and then Where'Length <= 80, Post => Had_Error; procedure Clear_Error; private My_Error : Boolean := False with Part_Of => State; end Error_Reporter;
zhmu/ananas
Ada
764
adb
-- { dg-do run } -- -- This test checks that we can allocate more than 2GB on systems with word -- sizes larger than 32-bits with Ada.Strings.Fixed; use Ada.Strings.Fixed; procedure Sec_Stack1 is function Get_A_Big_String return String; -- Return a very close to 2GB string on the secondary stack that would -- overflow the secondary stack if we still had a 2GB limit. function Get_A_Big_String return String is String_Size : constant Natural := Natural'Last; begin return String_Size * 'a'; end Get_A_Big_String; begin -- This test only works on systems with more than 32-bits if Standard'Address_Size > 32 then declare R : String := Get_A_Big_String; begin null; end; end if; end Sec_Stack1;
zhmu/ananas
Ada
1,197
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . I N T E G E R _ T E X T _ I O -- -- -- -- S p e c -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- -- copy and modify this specification, provided that if you redistribute a -- -- modified version, any changes that you have made are clearly indicated. -- -- -- ------------------------------------------------------------------------------ with Ada.Text_IO; package Ada.Integer_Text_IO is new Ada.Text_IO.Integer_IO (Integer);
AdaCore/libadalang
Ada
120
adb
procedure Test is X, Y : Integer; for Y'Address use X'Address; pragma Test_Statement; begin null; end Test;
AdaCore/gpr
Ada
2,955
ads
-- -- Copyright (C) 2014-2022, AdaCore -- SPDX-License-Identifier: Apache-2.0 -- private with Ada.Containers.Hashed_Maps; private with Ada.Strings.Unbounded.Hash; -- This package provides a generic map type, mapping keys of type -- Gpr_Parser_Support.Names.Name to any value (see Element_Type below). generic type Element_Type is private; package Gpr_Parser_Support.Names.Maps is type Map (Casing : Casing_Convention := Camel_With_Underscores) is tagged limited private; type Lookup_Result (Present : Boolean := False) is record case Present is when False => null; when True => Element : Element_Type; end case; end record; Absent_Lookup_Result : constant Lookup_Result := (Present => False); function Create_Name_Map (Casing : Casing_Convention) return Map; -- Create an empty mapping from names using the given convention to -- ``Element_Type`` values. procedure Insert (Self : in out Map; Name : Name_Type; Element : Element_Type); -- Insert the ``Name``/``Element`` association into ``Self``. -- -- Raise a ``Constraint_Error`` if there is already an entry for ``Name``. procedure Include (Self : in out Map; Name : Name_Type; Element : Element_Type); -- Insert the ``Name``/``Element`` association into ``Self``. -- -- If there is already an entry for ``Name``, just replace its element with -- ``Element``. function Lookup (Self : Map; Name : Name_Type) return Lookup_Result; -- Look for the association corresponding to ``Name`` in ``Self``. If there -- is one, return the corresponding element, otherwise return -- ``Absent_Lookup_Result``. function Get (Self : Map; Name : Name_Type) return Element_Type; -- Like ``Lookup``, but return the element directly instead. Raise a -- ``Constraint_Error`` if there is no association. -- The following overloads take string names instead of ``Name_Type`` -- values: they work similarly to the overloads accepting ``Name_Type`` -- values, except that they first try to decode the string into a name -- according to the map convention, raising an ``Invalid_Name_Error`` if -- the name is invalid according to the casing convention. procedure Insert (Self : in out Map; Name : Text_Type; Element : Element_Type); procedure Include (Self : in out Map; Name : Text_Type; Element : Element_Type); function Lookup (Self : Map; Name : Text_Type) return Lookup_Result; function Get (Self : Map; Name : Text_Type) return Element_Type; private package Helper_Maps is new Ada.Containers.Hashed_Maps (Key_Type => Unbounded_String, Element_Type => Element_Type, Hash => Hash, Equivalent_Keys => "="); type Map (Casing : Casing_Convention := Camel_With_Underscores) is tagged limited record Map : Helper_Maps.Map; end record; end Gpr_Parser_Support.Names.Maps;
reznikmm/matreshka
Ada
3,714
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Number_Percentage_Style_Elements is pragma Preelaborate; type ODF_Number_Percentage_Style is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Number_Percentage_Style_Access is access all ODF_Number_Percentage_Style'Class with Storage_Size => 0; end ODF.DOM.Number_Percentage_Style_Elements;
stcarrez/ada-ado
Ada
1,849
ads
----------------------------------------------------------------------- -- ado-utils -- Utility operations for ADO -- Copyright (C) 2013, 2016 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Containers; with Ada.Containers.Vectors; with Util.Beans.Objects; package ADO.Utils is -- Build a bean object from the identifier. function To_Object (Id : in ADO.Identifier) return Util.Beans.Objects.Object; -- Build the identifier from the bean object. function To_Identifier (Value : in Util.Beans.Objects.Object) return ADO.Identifier; -- Compute the hash of the identifier. function Hash (Key : in ADO.Identifier) return Ada.Containers.Hash_Type; package Identifier_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => ADO.Identifier, "=" => "="); subtype Identifier_Vector is Identifier_Vectors.Vector; subtype Identifier_Cursor is Identifier_Vectors.Cursor; -- Return the identifier list as a comma separated list of identifiers. function To_Parameter_List (List : in Identifier_Vector) return String; end ADO.Utils;
tum-ei-rcs/StratoX
Ada
11,812
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015, 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: -- -- -- -- @file stm32f4xx_hal_gpio.c -- -- @author MCD Application Team -- -- @version V1.1.0 -- -- @date 19-June-2014 -- -- @brief GPIO HAL module driver. -- -- -- -- COPYRIGHT(c) 2014 STMicroelectronics -- ------------------------------------------------------------------------------ with System; use System; with STM32_SVD.GPIO; use STM32_SVD.GPIO; with STM32.RCC; with STM32.SYSCFG; with System.Machine_Code; package body STM32.GPIO is procedure Lock_The_Pin (Port : in out Internal_GPIO_Port; Pin : Short); -- This is the routine that actually locks the pin for the port. It is an -- internal routine and has no preconditions. We use it to avoid redundant -- calls to the precondition that checks that the pin is not already -- locked. The redundancy would otherwise occur because the routine that -- locks an array of pins is implemented by calling the routine that locks -- a single pin: both those Lock routines have a precondition that checks -- that the pin(s) is not already being locked. ------------- -- Any_Set -- ------------- function Any_Set (Pins : GPIO_Points) return Boolean is begin for Pin of Pins loop if Pin.Set then return True; end if; end loop; return False; end Any_Set; --------- -- Set -- --------- overriding function Set (This : GPIO_Point) return Boolean is (This.Periph.IDR.IDR.Arr (This.Pin)); ------------- -- All_Set -- ------------- function All_Set (Pins : GPIO_Points) return Boolean is begin for Pin of Pins loop if not Pin.Set then return False; end if; end loop; return True; end All_Set; --------- -- Set -- --------- overriding procedure Set (This : in GPIO_Point) is begin This.Periph.BSRR.BS.Arr (This.Pin) := True; end Set; --------- -- Set -- --------- procedure Set (Pins : in out GPIO_Points) is begin for Pin of Pins loop Pin.Set; end loop; end Set; ----------- -- Clear -- ----------- overriding procedure Clear (This : in out GPIO_Point) is begin This.Periph.BSRR.BR.Arr (This.Pin) := True; end Clear; ----------- -- Clear -- ----------- procedure Clear (Pins : in out GPIO_Points) is begin for Pin of Pins loop Pin.Clear; end loop; end Clear; ------------ -- Toggle -- ------------ overriding procedure Toggle (This : in out GPIO_Point) is begin This.Periph.ODR.ODR.Arr (This.Pin) := not This.Periph.ODR.ODR.Arr (This.Pin); end Toggle; ------------ -- Toggle -- ------------ procedure Toggle (Points : in out GPIO_Points) is begin for Point of Points loop Point.Toggle; end loop; end Toggle; ------------ -- Locked -- ------------ function Locked (Pin : GPIO_Point) return Boolean is (Pin.Periph.LCKR.LCK.Arr (Pin.Pin)); ------------------ -- Lock_The_Pin -- ------------------ procedure Lock_The_Pin (Port : in out Internal_GPIO_Port; Pin : Short) is Temp : Word; pragma Volatile (Temp); use System.Machine_Code; use ASCII; begin -- As per the Reference Manual (RM0090; Doc ID 018909 Rev 6) pg 282, -- a specific sequence is required to set the Lock bit. Throughout the -- sequence the same value for the lower 15 bits of the word must be -- used (ie the pin number). The lock bit is referred to as LCKK in -- the doc. -- Temp := LCCK or Pin'Enum_Rep; -- -- -- set the lock bit -- Port.LCKR := Temp; -- -- -- clear the lock bit -- Port.LCKR := Pin'Enum_Rep; -- -- -- set the lock bit again -- Port.LCKR := Temp; -- -- -- read the lock bit -- Temp := Port.LCKR; -- -- -- read the lock bit again -- Temp := Port.LCKR; -- We use the following assembly language sequence because the above -- high-level version in Ada works only if the optimizer is enabled. -- This is not an issue specific to Ada. If you need a specific sequence -- of instructions you should really specify those instructions. -- We don't want the functionality to depend on the switches, and we -- don't want to preclude debugging, hence the following: Asm ("orr r3, %2, #65536" & LF & HT & "str r3, %0" & LF & HT & "ldr r3, %0" & LF & HT & -- temp <- pin or LCCK "str r3, [%1, #28]" & LF & HT & -- temp -> lckr "str %2, [%1, #28]" & LF & HT & -- pin -> lckr "ldr r3, %0" & LF & HT & "str r3, [%1, #28]" & LF & HT & -- temp -> lckr "ldr r3, [%1, #28]" & LF & HT & "str r3, %0" & LF & HT & -- temp <- lckr "ldr r3, [%1, #28]" & LF & HT & "str r3, %0" & LF & HT, -- temp <- lckr Inputs => (Address'Asm_Input ("r", Port'Address), -- %1 (Short'Asm_Input ("r", Pin))), -- %2 Outputs => (Word'Asm_Output ("=m", Temp)), -- %0 Volatile => True, Clobber => ("r2, r3")); end Lock_The_Pin; ---------- -- Lock -- ---------- procedure Lock (Point : GPIO_Point) is begin Lock_The_Pin (Point.Periph.all, Shift_Left (1, Point.Pin)); end Lock; ---------- -- Lock -- ---------- procedure Lock (Points : GPIO_Points) is begin for Point of Points loop Point.Lock; end loop; end Lock; ------------------ -- Configure_IO -- ------------------ procedure Configure_IO (Point : GPIO_Point; Config : GPIO_Port_Configuration) is MODER : MODER_Register := Point.Periph.MODER; OTYPER : OTYPER_Register := Point.Periph.OTYPER; OSPEEDR : OSPEEDR_Register := Point.Periph.OSPEEDR; PUPDR : PUPDR_Register := Point.Periph.PUPDR; begin MODER.Arr (Point.Pin) := Pin_IO_Modes'Enum_Rep (Config.Mode); OTYPER.OT.Arr (Point.Pin) := Config.Output_Type = Open_Drain; OSPEEDR.Arr (Point.Pin) := Pin_Output_Speeds'Enum_Rep (Config.Speed); PUPDR.Arr (Point.Pin) := Internal_Pin_Resistors'Enum_Rep (Config.Resistors); Point.Periph.MODER := MODER; Point.Periph.OTYPER := OTYPER; Point.Periph.OSPEEDR := OSPEEDR; Point.Periph.PUPDR := PUPDR; end Configure_IO; ------------------ -- Configure_IO -- ------------------ procedure Configure_IO (Points : GPIO_Points; Config : GPIO_Port_Configuration) is begin for Point of Points loop Point.Configure_IO (Config); end loop; end Configure_IO; ---------------------------------- -- Configure_Alternate_Function -- ---------------------------------- procedure Configure_Alternate_Function (Point : GPIO_Point; AF : GPIO_Alternate_Function) is begin if Point.Pin < 8 then Point.Periph.AFRL.Arr (Point.Pin) := UInt4 (AF); else Point.Periph.AFRH.Arr (Point.Pin) := UInt4 (AF); end if; end Configure_Alternate_Function; ---------------------------------- -- Configure_Alternate_Function -- ---------------------------------- procedure Configure_Alternate_Function (Points : GPIO_Points; AF : GPIO_Alternate_Function) is begin for Point of Points loop Point.Configure_Alternate_Function (AF); end loop; end Configure_Alternate_Function; ------------------------------- -- Get_Interrupt_Line_Number -- ------------------------------- function Get_Interrupt_Line_Number (Point : GPIO_Point) return EXTI.External_Line_Number is begin return EXTI.External_Line_Number'Val (Point.Pin); end Get_Interrupt_Line_Number; ----------------------- -- Configure_Trigger -- ----------------------- procedure Configure_Trigger (Point : GPIO_Point; Trigger : EXTI.External_Triggers) is use STM32.EXTI; Line : constant External_Line_Number := External_Line_Number'Val (Point.Pin); use STM32.SYSCFG, STM32.RCC; begin SYSCFG_Clock_Enable; Connect_External_Interrupt (Point); if Trigger in Interrupt_Triggers then Enable_External_Interrupt (Line, Trigger); else Enable_External_Event (Line, Trigger); end if; end Configure_Trigger; ----------------------- -- Configure_Trigger -- ----------------------- procedure Configure_Trigger (Points : GPIO_Points; Trigger : EXTI.External_Triggers) is begin for Point of Points loop Point.Configure_Trigger (Trigger); end loop; end Configure_Trigger; end STM32.GPIO;
reznikmm/matreshka
Ada
6,114
adb
------------------------------------------------------------------------------ -- -- -- 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 Matreshka.XML_Schema.AST.Attribute_Uses; with XML.Schema.Objects.Attribute_Declarations.Internals; package body XML.Schema.Objects.Attribute_Uses is use type Matreshka.XML_Schema.AST.Attribute_Use_Access; ------------------- -- Get_Actual_VC -- ------------------- function Get_Actual_VC (Self : XS_Attribute_Use'Class) return League.Holders.Holder is begin raise Program_Error; return League.Holders.Empty_Holder; end Get_Actual_VC; ------------------------ -- Get_Actual_VC_Type -- ------------------------ function Get_Actual_VC_Type (Self : XS_Attribute_Use'Class) return XML.Schema.Built_In_Type is begin raise Program_Error; return XML.Schema.Unavailable_DT; end Get_Actual_VC_Type; -------------------------- -- Get_Attr_Declaration -- -------------------------- function Get_Attr_Declaration (Self : XS_Attribute_Use'Class) return XML.Schema.Objects.Attribute_Declarations.XS_Attribute_Declaration is Node : constant Matreshka.XML_Schema.AST.Attribute_Use_Access := Matreshka.XML_Schema.AST.Attribute_Use_Access (Self.Node); begin if Node = null then return XML.Schema.Objects.Attribute_Declarations .Null_XS_Attribute_Declaration; else return XML.Schema.Objects.Attribute_Declarations.Internals.Create (Node.Attribute_Declaration); end if; end Get_Attr_Declaration; ------------------------- -- Get_Constraint_Type -- ------------------------- function Get_Constraint_Type (Self : XS_Attribute_Use'Class) return XML.Schema.Value_Constraint is begin raise Program_Error; return XML.Schema.VC_Fixed; end Get_Constraint_Type; -------------------------- -- Get_Constraint_Value -- -------------------------- function Get_Constraint_Value (Self : XS_Attribute_Use'Class) return League.Strings.Universal_String is begin raise Program_Error; return League.Strings.Empty_Universal_String; end Get_Constraint_Value; -------------------------- -- Get_Item_Value_Types -- -------------------------- -- function Get_Item_Value_Types -- (Self : XS_Attribute_Use'Class) return XML.Schema.Built_In_Type_List; ------------------ -- Get_Required -- ------------------ function Get_Required (Self : XS_Attribute_Use'Class) return Boolean is Node : constant Matreshka.XML_Schema.AST.Attribute_Use_Access := Matreshka.XML_Schema.AST.Attribute_Use_Access (Self.Node); begin if Node = null then return False; else return Node.Required; end if; end Get_Required; end XML.Schema.Objects.Attribute_Uses;
persan/AdaYaml
Ada
1,527
ads
-- part of AdaYaml, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "copying.txt" private with Yaml.Events.Queue; package Yaml.Transformator.Annotation.Vars is type Instance is limited new Transformator.Instance with private; overriding procedure Put (Object : in out Instance; E : Event); overriding function Has_Next (Object : Instance) return Boolean; overriding function Next (Object : in out Instance) return Event; function New_Vars (Pool : Text.Pool.Reference; Node_Context : Node_Context_Type; Processor_Context : Events.Context.Reference; Swallows_Previous : out Boolean) return not null Pointer; private type State_Type is not null access procedure (Object : in out Instance; E : Event); procedure Initial (Object : in out Instance; E : Event); procedure After_Annotation_Start (Object : in out Instance; E : Event); procedure After_Annotation_End (Object : in out Instance; E : Event); procedure At_Mapping_Level (Object : in out Instance; E : Event); procedure Inside_Value (Object : in out Instance; E : Event); procedure After_Mapping_End (Object : in out Instance; E : Event); type Instance is limited new Transformator.Instance with record Context : Events.Context.Reference; Depth : Natural := 0; State : State_Type := Initial'Access; Cur_Queue : Events.Queue.Instance; Cur_Name : Text.Reference; end record; end Yaml.Transformator.Annotation.Vars;
zhmu/ananas
Ada
4,880
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . W I D E _ T E X T _ I O . D E C I M A L _ A U X -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Ada.Wide_Text_IO.Generic_Aux; use Ada.Wide_Text_IO.Generic_Aux; package body Ada.Wide_Text_IO.Decimal_Aux is --------- -- Get -- --------- function Get (File : File_Type; Width : Field; Scale : Integer) return Int is Buf : String (1 .. Field'Last); Ptr : aliased Integer; Stop : Integer := 0; Item : Int; begin if Width /= 0 then Load_Width (File, Width, Buf, Stop); String_Skip (Buf, Ptr); else Load_Real (File, Buf, Stop); Ptr := 1; end if; Item := Scan (Buf, Ptr'Access, Stop, Scale); Check_End_Of_Field (Buf, Stop, Ptr, Width); return Item; end Get; ---------- -- Gets -- ---------- function Gets (From : String; Last : out Positive; Scale : Integer) return Int is Pos : aliased Integer; Item : Int; begin String_Skip (From, Pos); Item := Scan (From, Pos'Access, From'Last, Scale); Last := Pos - 1; return Item; exception when Constraint_Error => Last := Pos - 1; raise Data_Error; end Gets; --------- -- Put -- --------- procedure Put (File : File_Type; Item : Int; Fore : Field; Aft : Field; Exp : Field; Scale : Integer) is Buf : String (1 .. Field'Last); Ptr : Natural := 0; begin Set_Image (Item, Buf, Ptr, Scale, Fore, Aft, Exp); Put_Item (File, Buf (1 .. Ptr)); end Put; ---------- -- Puts -- ---------- procedure Puts (To : out String; Item : Int; Aft : Field; Exp : Field; Scale : Integer) is Buf : String (1 .. Positive'Max (Field'Last, To'Length)); Fore : Integer; Ptr : Natural := 0; begin -- Compute Fore, allowing for the decimal dot and Aft digits Fore := To'Length - 1 - Field'Max (1, Aft); -- Allow for Exp and one more for E if exponent present if Exp /= 0 then Fore := Fore - 1 - Field'Max (2, Exp); end if; -- Make sure we have enough room if Fore < 1 + Boolean'Pos (Item < 0) then raise Layout_Error; end if; -- Do the conversion and check length of result Set_Image (Item, Buf, Ptr, Scale, Fore, Aft, Exp); if Ptr > To'Length then raise Layout_Error; else To := Buf (1 .. Ptr); end if; end Puts; end Ada.Wide_Text_IO.Decimal_Aux;
AdaCore/libadalang
Ada
182
adb
procedure Testnull is type Int_Ptr is access Integer; A : Integer := 12; B : Int_Ptr := A'Access; pragma Test_Statement; begin A := null; B := null; end Testnull;
reznikmm/jwt
Ada
321
ads
-- Copyright (c) 2020 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- function JWS.To_Base_64_URL (Data : League.Stream_Element_Vectors.Stream_Element_Vector) return League.Strings.Universal_String;
reznikmm/matreshka
Ada
3,890
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2016-2017, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ package body WUI.Events.Mouse.Move is ------------------ -- Constructors -- ------------------ package body Constructors is ---------------- -- Initialize -- ---------------- procedure Initialize (Self : in out Mouse_Move_Event'Class; Event : not null access WebAPI.UI_Events.Mouse.Mouse_Event'Class) is begin WUI.Events.Mouse.Constructors.Initialize (Abstract_Mouse_Event'Class (Self), Event); end Initialize; end Constructors; end WUI.Events.Mouse.Move;
AdaCore/libadalang
Ada
380
adb
procedure Test is type I is limited interface; protected type T is new I with procedure Foo; end T; pragma Test_Statement; protected body T is procedure Foo is null; end T; protected O is new I with procedure Foo; end O; pragma Test_Statement; protected body O is procedure Foo is null; end O; begin null; end Test;
persan/AdaYaml
Ada
17,656
adb
-- part of AdaYaml, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "copying.txt" with Ada.Unchecked_Deallocation; package body Yaml.Events.Context is use type Store.Optional_Reference; use type Text.Reference; use type Store.Anchor_Cursor; use type Store.Element_Cursor; procedure Free_Scope_Array is new Ada.Unchecked_Deallocation (Scope_Array, Scope_Array_Pointer); procedure Free_Data_Array is new Ada.Unchecked_Deallocation (Data_Array, Data_Array_Pointer); procedure Free_Symbol_Table is new Ada.Unchecked_Deallocation (Symbol_Tables.Map, Symbol_Table_Pointer); function Create (External : Store.Reference := Store.New_Store) return Reference is ((Ada.Finalization.Controlled with Data => new Instance'(Refcount_Base with Generated_Data => null, Generated_Data_Count => 0, Document_Data => Store.New_Store, Stream_Data => Store.New_Store, Transformed_Data => Store.New_Store, External_Data => External, Local_Scopes => null, Local_Scope_Count => 0))); function External_Store (Object : Reference) return Store.Accessor is (Object.Data.External_Data.Value); function Stream_Store (Object : Reference) return Store.Accessor is (Object.Data.Stream_Data.Value); function Document_Store (Object : Reference) return Store.Accessor is (Object.Data.Document_Data.Value); function Transformed_Store (Object : Reference) return Store.Accessor is (Object.Data.Transformed_Data.Value); function Local_Store (Object : Reference; Position : Local_Scope_Cursor) return Store.Accessor is begin if (Object.Data.Local_Scopes = null or Object.Data.Local_Scope_Count < Natural (Position)) then raise Constraint_Error with "no local store at this position"; elsif Object.Data.Local_Scopes (Positive (Position)).Events = Store.Null_Reference then Object.Data.Local_Scopes (Positive (Position)).Events := Store.New_Store.Optional; end if; return Object.Data.Local_Scopes (Positive (Position)).Events.Value; end Local_Store; function Local_Store_Ref (Object : Reference; Position : Local_Scope_Cursor) return Store.Optional_Reference is begin if Object.Data.Local_Scopes = null or Object.Data.Local_Scope_Count < Natural (Position) then return Store.Null_Reference; elsif Object.Data.Local_Scopes (Positive (Position)).Events = Store.Null_Reference then Object.Data.Local_Scopes (Positive (Position)).Events := Store.New_Store.Optional; end if; return Object.Data.Local_Scopes (Positive (Position)).Events; end Local_Store_Ref; function Generated_Store (Object : Reference; Position : Generated_Store_Cursor) return Store.Accessor is begin if Object.Data.Generated_Data = null or Object.Data.Generated_Data_Count < Natural (Position) then raise Constraint_Error with "no generated store at this position"; elsif Object.Data.Generated_Data (Positive (Position)) = Store.Null_Reference then raise Program_Error with "internal error: expected generated store at position" & Position'Img; end if; return Object.Data.Generated_Data (Positive (Position)).Value; end Generated_Store; function Generated_Store_Ref (Object : Reference; Position : Generated_Store_Cursor) return Store.Optional_Reference is begin if Object.Data.Generated_Data = null or Object.Data.Generated_Data_Count < Natural (Position) then return Store.Null_Reference; elsif Object.Data.Generated_Data (Positive (Position)) = Store.Null_Reference then raise Program_Error with "internal error: expected generated store at position" & Position'Img; end if; return Object.Data.Generated_Data (Positive (Position)); end Generated_Store_Ref; procedure Grow_Scopes (Object : in out Instance) is begin if Object.Local_Scopes = null then Object.Local_Scopes := new Scope_Array (1 .. 16); elsif Object.Local_Scope_Count = Object.Local_Scopes'Last then declare New_Array : constant not null Scope_Array_Pointer := new Scope_Array (1 .. Object.Local_Scope_Count * 2); begin New_Array (Object.Local_Scopes'Range) := Object.Local_Scopes.all; Free_Scope_Array (Object.Local_Scopes); Object.Local_Scopes := New_Array; end; end if; Object.Local_Scope_Count := Object.Local_Scope_Count + 1; end Grow_Scopes; procedure Create_Local_Store (Object : Reference; Position : out Local_Scope_Cursor) is begin Grow_Scopes (Instance (Object.Data.all)); Object.Data.Local_Scopes (Object.Data.Local_Scope_Count).Events := Store.New_Store.Optional; Position := Local_Scope_Cursor (Object.Data.Local_Scope_Count); end Create_Local_Store; procedure Create_Local_Symbol_Scope (Object : Reference; Position : out Local_Scope_Cursor) is begin Grow_Scopes (Instance (Object.Data.all)); Object.Data.Local_Scopes (Object.Data.Local_Scope_Count).Symbols := new Symbol_Tables.Map; Position := Local_Scope_Cursor (Object.Data.Local_Scope_Count); end Create_Local_Symbol_Scope; procedure Release_Local_Store (Object : Reference; Position : Local_Scope_Cursor) is begin if Object.Data.Local_Scopes (Positive (Position)).Symbols /= null then Free_Symbol_Table (Object.Data.Local_Scopes (Positive (Position)).Symbols); end if; Object.Data.Local_Scopes (Positive (Position)).Events := Store.Null_Reference; while Object.Data.Local_Scope_Count > 0 and then (Object.Data.Local_Scopes (Object.Data.Local_Scope_Count).Events = Store.Null_Reference and Object.Data.Local_Scopes (Object.Data.Local_Scope_Count).Symbols = null) loop Object.Data.Local_Scope_Count := Object.Data.Local_Scope_Count - 1; end loop; end Release_Local_Store; procedure Create_Generated_Store (Object : Reference; Position : out Generated_Store_Cursor) is begin if Object.Data.Generated_Data = null then Object.Data.Generated_Data := new Data_Array (1 .. 16); elsif Object.Data.Generated_Data_Count = Object.Data.Generated_Data'Last then declare New_Array : constant not null Data_Array_Pointer := new Data_Array (1 .. Object.Data.Generated_Data_Count * 2); begin New_Array (Object.Data.Generated_Data'Range) := Object.Data.Generated_Data.all; Free_Data_Array (Object.Data.Generated_Data); Object.Data.Generated_Data := New_Array; end; end if; Object.Data.Generated_Data_Count := Object.Data.Generated_Data_Count + 1; Object.Data.Generated_Data (Object.Data.Generated_Data_Count) := Store.New_Store.Optional; Position := Generated_Store_Cursor (Object.Data.Generated_Data_Count); end Create_Generated_Store; procedure Release_Generated_Store (Object : Reference; Position : Generated_Store_Cursor) is begin Object.Data.Generated_Data (Positive (Position)) := Store.Null_Reference; while Object.Data.Generated_Data_Count > 0 and then (Object.Data.Generated_Data (Object.Data.Generated_Data_Count) = Store.Null_Reference) loop Object.Data.Generated_Data_Count := Object.Data.Generated_Data_Count - 1; end loop; end Release_Generated_Store; procedure Create_Symbol (Object : Reference; Scope : Local_Scope_Cursor; Name : Text.Reference; Position : out Symbol_Cursor) is Inserted : Boolean; begin if Object.Data.Local_Scopes (Positive (Scope)).Symbols = null then Object.Data.Local_Scopes (Positive (Scope)).Symbols := new Symbol_Tables.Map; end if; Object.Data.Local_Scopes (Positive (Scope)).Symbols.Insert (Name, No_Element, Symbol_Tables.Cursor (Position), Inserted); if not Inserted then raise Constraint_Error with "Symbol """ & Name & """ already exists!"; end if; end Create_Symbol; procedure Update_Symbol (Object : Reference; Scope : Local_Scope_Cursor; Position : Symbol_Cursor; New_Value : Cursor) is function Try_Update_With_Anchored (Anchor : Text.Reference) return Boolean is begin if Anchor = Text.Empty then return False; end if; Object.Data.Local_Scopes (Positive (Scope)).Symbols.Replace_Element (Symbol_Tables.Cursor (Position), Object.Position (Anchor)); return True; end Try_Update_With_Anchored; Target_Event : constant Event := First (New_Value); begin case Target_Event.Kind is when Scalar => if Try_Update_With_Anchored (Target_Event.Scalar_Properties.Anchor) then return; end if; when Mapping_Start | Sequence_Start => if Try_Update_With_Anchored (Target_Event.Collection_Properties.Anchor) then return; end if; when Alias => Object.Data.Local_Scopes (Positive (Scope)).Symbols.Replace_Element (Symbol_Tables.Cursor (Position), Object.Position (Target_Event.Target)); return; when others => null; end case; Object.Data.Local_Scopes (Positive (Scope)).Symbols.Replace_Element (Symbol_Tables.Cursor (Position), New_Value); end Update_Symbol; function Symbol_Name (Position : Symbol_Cursor) return Text.Reference is (Symbol_Tables.Key (Symbol_Tables.Cursor (Position))); function Position (Object : Reference; Alias : Text.Reference) return Cursor is Pos : Store.Anchor_Cursor := Store.No_Anchor; function Resolved (Position : Cursor) return Cursor is begin return Pos : Cursor := Position do if Pos /= No_Element then declare Target_Event : constant Event := First (Pos); begin if Target_Event.Kind = Annotation_Start and then Target_Event.Annotation_Properties.Anchor /= Text.Empty then declare Resolved_Target : constant Store.Anchor_Cursor := Object.Data.Transformed_Data.Value.Find (Target_Event.Annotation_Properties.Anchor); begin if Resolved_Target /= Store.No_Anchor then Pos.Target := Object.Data.Transformed_Data.Optional; Pos.Anchored_Position := Resolved_Target; Pos.Element_Position := Store.No_Element; end if; end; end if; end; end if; end return; end Resolved; begin for Index in reverse 1 .. Object.Data.Generated_Data_Count loop Pos := Object.Data.Generated_Data (Index).Value.Find (Alias); if Pos /= Store.No_Anchor then return Resolved ((Target => Object.Data.Generated_Data (Index), Anchored_Position => Pos, Element_Position => Events.Store.No_Element, Target_Location => Generated)); end if; end loop; for Index in reverse 1 .. Object.Data.Local_Scope_Count loop if Object.Data.Local_Scopes (Index).Symbols /= null then declare Symbol_Pos : constant Symbol_Tables.Cursor := Object.Data.Local_Scopes (Index).Symbols.Find (Alias); begin if Symbol_Tables.Has_Element (Symbol_Pos) then return Resolved (Symbol_Tables.Element (Symbol_Pos)); end if; end; end if; if Object.Data.Local_Scopes (Index).Events /= Store.Null_Reference then Pos := Object.Data.Local_Scopes (Index).Events.Value.Find (Alias); if Pos /= Store.No_Anchor then return Resolved ((Target => Object.Data.Local_Scopes (Index).Events, Anchored_Position => Pos, Element_Position => Events.Store.No_Element, Target_Location => Local)); end if; end if; end loop; Pos := Object.Data.Document_Data.Value.Find (Alias); if Pos = Store.No_Anchor then Pos := Object.Data.Stream_Data.Value.Find (Alias); if Pos = Store.No_Anchor then Pos := Object.Data.External_Data.Value.Find (Alias); if Pos = Store.No_Anchor then return No_Element; else return Resolved ((Target => Object.Data.External_Data.Optional, Anchored_Position => Pos, Element_Position => Events.Store.No_Element, Target_Location => External)); end if; else return Resolved ((Target => Object.Data.Stream_Data.Optional, Anchored_Position => Pos, Element_Position => Events.Store.No_Element, Target_Location => Stream)); end if; else return Resolved ((Target => Object.Data.Document_Data.Optional, Anchored_Position => Pos, Element_Position => Events.Store.No_Element, Target_Location => Document)); end if; end Position; function Location (Position : Cursor) return Location_Type is (Position.Target_Location); function Is_Anchored (Pos : Cursor) return Boolean is (Pos.Anchored_Position /= Store.No_Anchor); function Retrieve (Pos : Cursor) return Store.Stream_Reference is (if Pos.Element_Position /= Store.No_Element then Pos.Target.Required.Retrieve (Pos.Element_Position) else Pos.Target.Required.Retrieve (Pos.Anchored_Position)); function First (Pos : Cursor) return Event is (if Pos.Element_Position /= Store.No_Element then Pos.Target.Value.Element (Pos.Element_Position) else Pos.Target.Value.First (Pos.Anchored_Position)); procedure Adjust (Object : in out Reference) is begin Object.Data.Increase_Refcount; end Adjust; procedure Finalize (Object : in out Reference) is begin Object.Data.Decrease_Refcount; end Finalize; function Exists_In_Ouput (Position : Cursor) return Boolean is (if Position.Element_Position = Store.No_Element then Store.Exists_In_Output (Position.Anchored_Position) else False); procedure Set_Exists_In_Output (Position : in out Cursor) is begin if Position.Anchored_Position /= Events.Store.No_Anchor then Store.Set_Exists_In_Output (Position.Target.Value, Position.Anchored_Position); end if; end Set_Exists_In_Output; procedure Finalize (Object : in out Instance) is begin if Object.Local_Scopes /= null then for Index in 1 .. Object.Local_Scope_Count loop if Object.Local_Scopes (Index).Symbols /= null then Free_Symbol_Table (Object.Local_Scopes (Index).Symbols); end if; end loop; Free_Scope_Array (Object.Local_Scopes); end if; if Object.Generated_Data /= null then Free_Data_Array (Object.Generated_Data); end if; end Finalize; procedure Get_Store_And_Cursor (Position : Cursor; Target : out Store.Optional_Reference; Element_Position : out Events.Store.Element_Cursor) is begin Target := Position.Target; if Position.Anchored_Position /= Store.No_Anchor then Element_Position := Store.To_Element_Cursor (Position.Anchored_Position); else Element_Position := Position.Element_Position; end if; end Get_Store_And_Cursor; function To_Cursor (Object : Reference; Parent : Store.Optional_Reference; Element_Position : Events.Store.Element_Cursor) return Cursor is ((Target => Parent, Anchored_Position => Store.No_Anchor, Element_Position => Element_Position, Target_Location => (if Parent.Value.Data = Object.External_Store.Data then External elsif Parent.Value.Data = Object.Stream_Store.Data then Stream elsif Parent.Value.Data = Object.Document_Store.Data then Document elsif Parent.Value.Data = null then None else Local))); end Yaml.Events.Context;
zhmu/ananas
Ada
8,745
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- ADA.STRINGS.TEXT_BUFFERS.UNBOUNDED -- -- -- -- B o d y -- -- -- -- Copyright (C) 2020-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Ada.Unchecked_Deallocation; with Ada.Strings.UTF_Encoding.Conversions; with Ada.Strings.UTF_Encoding.Strings; with Ada.Strings.UTF_Encoding.Wide_Strings; with Ada.Strings.UTF_Encoding.Wide_Wide_Strings; package body Ada.Strings.Text_Buffers.Unbounded is function Get (Buffer : in out Buffer_Type) return String is -- If all characters are 7 bits, we don't need to decode; -- this is an optimization. -- Otherwise, if all are 8 bits, we need to decode to get Latin-1. -- Otherwise, the result is implementation defined, so we return a -- String encoded as UTF-8. Note that the RM says "if any character -- in the sequence is not defined in Character, the result is -- implementation-defined", so we are not obliged to decode ANY -- Latin-1 characters if ANY character is bigger than 8 bits. begin if Buffer.All_8_Bits and not Buffer.All_7_Bits then return UTF_Encoding.Strings.Decode (Get_UTF_8 (Buffer)); else return Get_UTF_8 (Buffer); end if; end Get; function Wide_Get (Buffer : in out Buffer_Type) return Wide_String is begin return UTF_Encoding.Wide_Strings.Decode (Get_UTF_8 (Buffer)); end Wide_Get; function Wide_Wide_Get (Buffer : in out Buffer_Type) return Wide_Wide_String is begin return UTF_Encoding.Wide_Wide_Strings.Decode (Get_UTF_8 (Buffer)); end Wide_Wide_Get; function Get_UTF_8 (Buffer : in out Buffer_Type) return UTF_Encoding.UTF_8_String is begin return Result : UTF_Encoding.UTF_8_String (1 .. Buffer.UTF_8_Length) do declare Target_First : Positive := 1; Ptr : Chunk_Access := Buffer.List.First_Chunk'Unchecked_Access; Target_Last : Positive; begin while Ptr /= null loop Target_Last := Target_First + Ptr.Chars'Length - 1; if Target_Last <= Result'Last then -- all of chunk is assigned to Result Result (Target_First .. Target_Last) := Ptr.Chars; Target_First := Target_First + Ptr.Chars'Length; else -- only part of (last) chunk is assigned to Result declare Final_Target : UTF_Encoding.UTF_8_String renames Result (Target_First .. Result'Last); begin Final_Target := Ptr.Chars (1 .. Final_Target'Length); end; pragma Assert (Ptr.Next = null); Target_First := Integer'Last; end if; Ptr := Ptr.Next; end loop; end; -- Reset buffer to default initial value. declare Defaulted : Buffer_Type; -- If this aggregate becomes illegal due to new field, don't -- forget to add corresponding assignment statement below. Dummy : array (1 .. 0) of Buffer_Type := [others => [Indentation => <>, Indent_Pending => <>, UTF_8_Length => <>, UTF_8_Column => <>, All_7_Bits => <>, All_8_Bits => <>, List => <>, Last_Used => <>]]; begin Buffer.Indentation := Defaulted.Indentation; Buffer.Indent_Pending := Defaulted.Indent_Pending; Buffer.UTF_8_Length := Defaulted.UTF_8_Length; Buffer.UTF_8_Column := Defaulted.UTF_8_Column; Buffer.All_7_Bits := Defaulted.All_7_Bits; Buffer.All_8_Bits := Defaulted.All_8_Bits; Buffer.Last_Used := Defaulted.Last_Used; Finalize (Buffer.List); -- free any allocated chunks end; end return; end Get_UTF_8; function Wide_Get_UTF_16 (Buffer : in out Buffer_Type) return UTF_Encoding.UTF_16_Wide_String is begin return UTF_Encoding.Conversions.Convert (Get_UTF_8 (Buffer), Input_Scheme => UTF_Encoding.UTF_8); end Wide_Get_UTF_16; procedure Put_UTF_8_Implementation (Buffer : in out Root_Buffer_Type'Class; Item : UTF_Encoding.UTF_8_String) is procedure Buffer_Type_Implementation (Buffer : in out Buffer_Type); -- View the passed-in Buffer parameter as being of type Buffer_Type, -- not of type Root_Buffer_Type'Class. procedure Buffer_Type_Implementation (Buffer : in out Buffer_Type) is begin for Char of Item loop Buffer.All_7_Bits := @ and then Character'Pos (Char) < 128; if Buffer.Last_Used = Buffer.List.Current_Chunk.Length then -- Current chunk is full; allocate a new one with doubled size declare Cc : Chunk renames Buffer.List.Current_Chunk.all; Max : constant Positive := Integer'Last / 2; Length : constant Natural := Integer'Min (Max, 2 * Cc.Length); begin pragma Assert (Cc.Next = null); Cc.Next := new Chunk (Length => Length); Buffer.List.Current_Chunk := Cc.Next; Buffer.Last_Used := 0; end; end if; Buffer.UTF_8_Length := @ + 1; Buffer.UTF_8_Column := @ + 1; Buffer.Last_Used := @ + 1; Buffer.List.Current_Chunk.Chars (Buffer.Last_Used) := Char; end loop; end Buffer_Type_Implementation; begin Buffer_Type_Implementation (Buffer_Type (Buffer)); end Put_UTF_8_Implementation; procedure Initialize (List : in out Managed_Chunk_List) is begin List.Current_Chunk := List.First_Chunk'Unchecked_Access; end Initialize; procedure Finalize (List : in out Managed_Chunk_List) is procedure Free is new Ada.Unchecked_Deallocation (Chunk, Chunk_Access); Ptr : Chunk_Access := List.First_Chunk.Next; begin while Ptr /= null loop declare Old_Ptr : Chunk_Access := Ptr; begin Ptr := Ptr.Next; Free (Old_Ptr); end; end loop; List.First_Chunk.Next := null; Initialize (List); end Finalize; end Ada.Strings.Text_Buffers.Unbounded;
AdaCore/gpr
Ada
39,194
adb
------------------------------------------------------------------------------ -- -- -- GPR2 PROJECT MANAGER -- -- -- -- Copyright (C) 2019-2023, AdaCore -- -- -- -- This is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. This software is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- -- License for more details. You should have received a copy of the GNU -- -- General Public License distributed with GNAT; see file COPYING. If not, -- -- see <http://www.gnu.org/licenses/>. -- -- -- ------------------------------------------------------------------------------ with Ada.Calendar; with Ada.Command_Line; with Ada.Containers.Indefinite_Ordered_Sets; with Ada.Directories; with Ada.Text_IO; with GPR2.Unit; with GPR2.Containers; with GPR2.Log; with GPR2.Message; with GPR2.Path_Name; with GPR2.Path_Name.Set; with GPR2.Project.Source.Artifact; with GPR2.Project.Source.Part_Set; with GPR2.Project.Source.Set; with GPR2.Project.Tree; with GPR2.Project.Unit_Info; with GPR2.Project.View; with GPR2.Source_Info.Parser.Registry; with GPR2.Version; with GPRtools.Options; with GPRtools.Util; with GPRls.Common; with GPRls.Gnatdist; with GPRls.Options; function GPRls.Process (Opt : in out GPRls.Options.Object) return Ada.Command_Line.Exit_Status is use Ada; use GPR2; use GPR2.Project.Source.Set; use all type GPR2.Unit.Library_Unit_Type; use GPRls.Common; use GPRls.Options; use GPRtools; use GPRtools.Util; Tree : Project.Tree.Object renames Opt.Tree.all; procedure Display_Paths; procedure Put (Str : String; Lvl : Verbosity_Level); pragma Unreferenced (Put); -- Call Ada.Text_IO.Put (Str) if Opt.Verbosity is at least Lvl procedure Put_Line (Str : String; Lvl : Verbosity_Level); -- Call Ada.Text_IO.Put_Line (Str) if Opt.Verbosity is at least Lvl procedure Show_Tree_Load_Errors; -- Print errors/warnings following a project tree load ------------------- -- Display_Paths -- ------------------- procedure Display_Paths is Curr_Dir : constant String := Directories.Current_Directory; Obj_Path : Path_Name.Set.Object; function Mask_Current (Dir : String) return String is (if Dir (Dir'First .. Dir'Last - 1) = Curr_Dir then "<Current_Directory>" else Dir); begin Text_IO.New_Line; Version.Display ("GPRLS", "2018", Version_String => Version.Long_Value); -- Source search path Text_IO.New_Line; Text_IO.Put_Line ("Source Search Path:"); for V of Tree loop if V.Kind in With_Source_Dirs_Kind then for Src of V.Source_Directories loop Text_IO.Put_Line (" " & String (Src.Dir_Name)); end loop; end if; end loop; if Tree.Has_Runtime_Project then for Src of Tree.Runtime_Project.Source_Directories loop Text_IO.Put_Line (" " & String (Src.Dir_Name)); end loop; end if; -- Object search path for V of Tree loop case V.Kind is when K_Standard => Obj_Path.Append (V.Object_Directory); when K_Library | K_Aggregate_Library => Obj_Path.Append (V.Library_Ali_Directory); when others => null; end case; end loop; if Tree.Has_Runtime_Project then Obj_Path.Append (Tree.Runtime_Project.Object_Directory); end if; Text_IO.New_Line; Text_IO.Put_Line ("Object Search Path:"); for P of Obj_Path loop Text_IO.Put_Line (" " & P.Dir_Name); end loop; -- Project search path Text_IO.New_Line; Text_IO.Put_Line ("Project Search Path:"); for P of Tree.Project_Search_Paths loop Text_IO.Put_Line (" " & Mask_Current (P.Dir_Name)); end loop; Text_IO.New_Line; end Display_Paths; --------- -- Put -- --------- procedure Put (Str : String; Lvl : Verbosity_Level) is begin if Opt.Verbosity >= Lvl then Text_IO.Put (Str); end if; end Put; -------------- -- Put_Line -- -------------- procedure Put_Line (Str : String; Lvl : Verbosity_Level) is begin if Opt.Verbosity >= Lvl then Text_IO.Put_Line (Str); end if; end Put_Line; --------------------------- -- Show_Tree_Load_Errors -- --------------------------- procedure Show_Tree_Load_Errors is begin if Tree.Log_Messages.Has_Error then -- In case both warnings and errors are present, only displpay the -- errors as they are probably responsible for the warnings. for C in Tree.Log_Messages.Iterate (Information => False, Warning => False, Error => True, Read => False, Unread => True) loop Put_Line (Log.Element (C).Format, Quiet); end loop; else for C in Tree.Log_Messages.Iterate (Information => Opt.Verbose, Warning => Opt.Warnings, Error => False, Read => False, Unread => True) loop Put_Line (Log.Element (C).Format, Regular); end loop; end if; end Show_Tree_Load_Errors; begin -- Load the project tree if not GPRtools.Options.Load_Project (Opt, Absent_Dir_Error => Project.Tree.Warning, Handle_Information => Opt.Verbose, Handle_Lint => Opt.Verbose) then if Opt.Project_File.Is_Defined then Text_IO.Put_Line ("gprls: unable to process project file " & String (Opt.Filename.Name)); else Text_IO.Put_Line ("gprls: unable to process default project file in " & String (Opt.Filename.Name)); end if; return Command_Line.Failure; end if; if Opt.Only_Display_Paths then -- For the "gprls -v" usage Display_Paths; return Command_Line.Success; end if; Show_Tree_Load_Errors; pragma Assert (not Opt.Source_Parser or else GPR2.Source_Info.Parser.Registry.Exists (Ada_Language, Source_Info.Source), "Source parser is not registered"); pragma Assert (GPR2.Source_Info.Parser.Registry.Exists (Ada_Language, Source_Info.LI), "ALI parser is not registered"); -- Make sure the sources are up to date Tree.Update_Sources (Backends => (Source_Info.Source => Opt.Source_Parser, Source_Info.LI => True), With_Runtime => (Opt.Gnatdist or else Opt.With_Predefined_Units)); -- -- Main processing -- declare -- Cache some data to speed up later processing. -- The maps should have Value_Path keys to support case-insensitive FS. use type Project.Source.Object; use type Project.View.Object; use all type Project.Source.Naming_Exception_Kind; function Path_Equal (Left, Right : Project.Source.Source_Part) return Boolean is (Left.Source = Right.Source and then Left.Source.View.Namespace_Roots.First_Element = Right.Source.View.Namespace_Roots.First_Element and then Left.Index = Right.Index); type One_Type is range -1 .. 1; function Compare (Left, Right : Project.View.Object) return One_Type is (if Left < Right then -1 elsif Left = Right then 0 else 1); -- function Compare (Left, Right : Path_Name.Full_Name) return One_Type -- is (if Left < Right then -1 elsif Left = Right then 0 else 1); function Compare (Left, Right : Project.Source.Object) return One_Type is (if Left < Right then -1 elsif Left = Right then 0 else 1); function Compare (Left, Right : Unit_Index) return One_Type is (if Left < Right then -1 elsif Left = Right then 0 else 1); function Path_Less (Left, Right : Project.Source.Source_Part) return Boolean is (case Compare (Left.Source.View.Namespace_Roots.First_Element, Right.Source.View.Namespace_Roots.First_Element) is when -1 => True, when 1 => False, when 0 => (case Compare (Left.Source, Right.Source) is when -1 => True, when 1 => False, when 0 => Compare (Left.Index, Right.Index) = -1)); package Sources_By_Path is new Ada.Containers.Indefinite_Ordered_Sets (Project.Source.Source_Part, "<" => Path_Less, "=" => Path_Equal); type File_Status is (OK, -- matching timestamp Not_Same); -- non matching timestamp No_Obj : constant String := "<no_obj>"; Position : Sources_By_Path.Cursor; Inserted : Boolean; Remains : GPR2.Containers.Value_Set := Opt.Files; Sources : Sources_By_Path.Set; -- The sources that we will browse. This set may be: -- - All the project sources when not in closure mode, possibly from -- the full project tree if All_Projects is True -- - The sources associated with the files given on the CL -- - In closure mode and no file given on the CL, the root project's -- main sources. procedure Display_Closures; procedure Display_Gnatdist; procedure Display_Normal; ---------------------- -- Display_Closures -- ---------------------- procedure Display_Closures is Closures : Project.Source.Part_Set.Object (Sorted => True); begin if Sources.Is_Empty then Finish_Program (E_Errors, "no main specified for closure"); end if; for S of Sources loop declare Deps : constant Project.Source.Part_Set.Object := S.Source.Dependencies (Closure => True, Sorted => False); begin if Deps.Is_Empty then -- If no dependencies, use only this one because without ALI -- file we don't know dependency even on itself. Closures.Insert (S); else Closures.Union (Deps); end if; end; end loop; declare package String_Sorting is new String_Vector.Generic_Sorting; Output : String_Vector.Vector; begin for R of Closures loop if not R.Source.Is_Runtime then if not GPR2.Project.Source.Artifact.Dependency (R.Source, R.Index).Is_Defined then Text_IO.Put_Line (File => Text_IO.Standard_Error, Item => String (R.Source.View.Path_Name.Simple_Name) & ": WARNING: the closure for " & String (R.Source.Path_Name.Simple_Name) & " is incomplete"); end if; if R.Index not in Multi_Unit_Index then Output.Append (R.Source.Path_Name.Value); else Output.Append (R.Source.Path_Name.Value & " @" & R.Index'Image); end if; end if; end loop; String_Sorting.Sort (Output); for O of Output loop Text_IO.Put_Line (O); end loop; end; end Display_Closures; ---------------------- -- Display_Gnatdist -- ---------------------- procedure Display_Gnatdist is function Has_Dependency (S : Project.Source.Source_Part) return Boolean; -------------------- -- Has_Dependency -- -------------------- function Has_Dependency (S : Project.Source.Source_Part) return Boolean is begin return GPR2.Project.Source.Artifact.Dependency (S.Source, S.Index).Is_Defined; end Has_Dependency; No_ALI : Boolean := True; begin for S of Sources loop if S.Index = 0 then for CU of S.Source.Units loop if Has_Dependency ((S.Source, Index => CU.Index)) then No_ALI := False; Gnatdist.Output_ALI (S.Source, CU.Index); end if; end loop; elsif Has_Dependency (S) then No_ALI := False; Gnatdist.Output_ALI (S.Source, S.Index); end if; if No_ALI then Gnatdist.Output_No_ALI (S.Source, S.Index); end if; end loop; end Display_Gnatdist; -------------------- -- Display_Normal -- -------------------- procedure Display_Normal is use type Source_Info.Backend; procedure Output_Source (S : Project.Source.Object; Idx : Unit_Index; Build_Time : Ada.Calendar.Time; A : Project.Source.Artifact.Object := Project.Source.Artifact.Undefined); ------------------- -- Output_Source -- ------------------- procedure Output_Source (S : Project.Source.Object; Idx : Unit_Index; Build_Time : Ada.Calendar.Time; A : Project.Source.Artifact.Object := Project.Source.Artifact.Undefined) is use type Calendar.Time; package SI renames GPR2.Source_Info; Status : File_Status; Artifacts : Project.Source.Artifact.Object; function Check_Object_Code return Boolean; -- Returns true if source has object code and set Artifacts function No_Trail_Zero (Item : String) return String; -- Remove trailing zeroes with possible dot and leading space ----------------------- -- Check_Object_Code -- ----------------------- function Check_Object_Code return Boolean is package PSA renames Project.Source.Artifact; begin if A.Is_Defined then Artifacts := A; else Artifacts := PSA.Create (S, Filter => (PSA.Object_File => True, others => False)); end if; return Artifacts.Has_Object_Code; end Check_Object_Code; ------------------- -- No_Trail_Zero -- ------------------- function No_Trail_Zero (Item : String) return String is begin for J in reverse Item'Range loop if Item (J) /= '0' then return Item (Item'First + (if Item (Item'First) = ' ' then 1 else 0) .. J - (if Item (J) = '.' then 1 else 0)); end if; end loop; return Item; end No_Trail_Zero; begin -- For now we stick to the timestamp-based logic: if time stamps -- are equal, assume the file didn't change. if Build_Time = S.Timestamp (ALI => True) or else (not SI.Parser.Registry.Exists (S.Language, SI.None) and then Check_Object_Code and then Artifacts.Object_Code (Index => Idx).Exists and then S.Timestamp (ALI => False) < Artifacts.Object_Code (Index => Idx).Modification_Time) then Status := OK; else Status := Not_Same; end if; if Opt.Verbose then Text_IO.Put (" Source => "); Text_IO.Put (S.Path_Name.Value); if S.Has_Index then Text_IO.Put (" @"); Text_IO.Put (Idx'Image); end if; case Status is when OK => Text_IO.Put (" unchanged"); when Not_Same => Text_IO.Put (" modified"); end case; else if not Opt.Selective_Output then Text_IO.Put (" "); case Status is when OK => Text_IO.Put (" OK "); when Not_Same => Text_IO.Put (" DIF "); if GPR2.Is_Debug ('F') then if S.Is_Parsed (Idx) then Text_IO.Put (S.Used_Backend (Idx)'Img); Text_IO.Put (' '); if S.Build_Timestamp (Idx) /= S.Timestamp (ALI => True) then Text_IO.Put (No_Trail_Zero (Duration'Image (S.Timestamp (ALI => True) - S.Build_Timestamp (Idx)))); Text_IO.Put (' '); end if; else Text_IO.Put ("not parsed "); end if; end if; end case; end if; Text_IO.Put (if S.Is_Runtime and then Opt.Hide_Runtime_Directory then String (S.Path_Name.Simple_Name) else S.Path_Name.Value); if Idx /= No_Index then Text_IO.Put (" at index" & Idx'Image); end if; end if; Text_IO.New_Line; end Output_Source; begin for S of Sources loop declare use Project.Source; View : constant Project.View.Object := S.Source.View; Artifacts : constant Project.Source.Artifact.Object := Project.Source.Artifact.Create (S.Source, Filter => (Artifact.Dependency_File => True, Artifact.Object_File => True, others => False)); Main_Unit : GPR2.Unit.Object; procedure Print_Unit_From (Src : GPR2.Unit.Source_Unit_Identifier); function Print_Unit (U_Sec : GPR2.Unit.Object) return Boolean; procedure Print_Object (Index : Unit_Index); procedure Print_Object (U_Sec : GPR2.Unit.Object); procedure Dependency_Output (Dep_Source : Project.Source.Object; Index : Unit_Index; Timestamp : Ada.Calendar.Time); function Has_Dependency (Index : Unit_Index) return Boolean is (Artifacts.Has_Dependency (Index) and then (Artifacts.Dependency (Index).Exists or else Opt.Source_Parser)); ----------------------- -- Dependency_Output -- ----------------------- procedure Dependency_Output (Dep_Source : Project.Source.Object; Index : Unit_Index; Timestamp : Ada.Calendar.Time) is begin if Opt.With_Predefined_Units or else not Dep_Source.Is_Runtime then Text_IO.Put (" "); Output_Source (S => Dep_Source, Idx => Index, Build_Time => Timestamp); end if; end Dependency_Output; ------------------ -- Print_Object -- ------------------ procedure Print_Object (Index : GPR2.Unit_Index) is Obj_File : GPR2.Path_Name.Object; begin if Opt.Print_Object_Files and then not S.Source.Is_Aggregated then Obj_File := Artifacts.Object_Code (Index); if Obj_File.Exists then Text_IO.Put_Line (Obj_File.Value); else Text_IO.Put_Line (No_Obj); end if; end if; end Print_Object; ------------------ -- Print_Object -- ------------------ procedure Print_Object (U_Sec : GPR2.Unit.Object) is Unit_Info : Project.Unit_Info.Object; begin Print_Object (U_Sec.Index); if Opt.Print_Units and then Print_Unit (U_Sec) then null; end if; if Opt.Print_Sources and then not Opt.Dependency_Mode then Output_Source (S.Source, S.Index, S.Source.Build_Timestamp (S.Index), Artifacts); end if; if Opt.Verbose then Unit_Info := S.Source.View.Unit (U_Sec.Name); if Unit_Info.Has_Spec then Print_Unit_From (Unit_Info.Spec); end if; if Unit_Info.Has_Body then Print_Unit_From (Unit_Info.Main_Body); end if; for S of Unit_Info.Separates loop Print_Unit_From (S); end loop; end if; end Print_Object; ---------------- -- Print_Unit -- ---------------- function Print_Unit (U_Sec : GPR2.Unit.Object) return Boolean is use type GPR2.Unit.Object; begin if not Main_Unit.Is_Defined then Main_Unit := U_Sec; elsif Main_Unit = U_Sec then return False; end if; if Opt.Verbose then Text_IO.Put_Line (" Unit =>"); Text_IO.Put (" Name => "); Text_IO.Put (String (U_Sec.Name)); Text_IO.New_Line; Text_IO.Put_Line (" Kind => " & (case U_Sec.Library_Item_Kind is when GPR2.Unit.Is_Package => "package", when GPR2.Unit.Is_Subprogram => "subprogram", when GPR2.Unit.Is_No_Body => "no-body") & ' ' & (case U_Sec.Kind is when GPR2.Unit.Spec_Kind => "spec", when GPR2.Unit.Body_Kind => "body", when GPR2.Unit.S_Separate => "separate")); if U_Sec.Is_Any_Flag_Set then Text_IO.Put (" Flags =>"); for Flag in GPR2.Unit.Flag'Range loop if U_Sec.Is_Flag_Set (Flag) then Text_IO.Put (' ' & GPR2.Unit.Image (Flag)); end if; end loop; Text_IO.New_Line; end if; else Text_IO.Put_Line (" " & String (U_Sec.Name)); end if; return True; end Print_Unit; --------------------- -- Print_Unit_From -- --------------------- procedure Print_Unit_From (Src : GPR2.Unit.Source_Unit_Identifier) is U_Src : constant Project.Source.Object := View.Source (Src.Source); begin if not Opt.Print_Units or else (Print_Unit (U_Src.Unit (Src.Index)) and then not Opt.Dependency_Mode and then Opt.Print_Sources) then Output_Source (U_Src, Src.Index, U_Src.Build_Timestamp (Src.Index)); end if; end Print_Unit_From; begin if not S.Source.Has_Units then Print_Object (No_Index); if Opt.Print_Sources and then not Opt.Dependency_Mode then Output_Source (S.Source, No_Index, S.Source.Build_Timestamp (No_Index), Artifacts); end if; elsif S.Index = No_Index then for U_Sec of S.Source.Units loop if Has_Dependency (U_Sec.Index) then Print_Object (U_Sec); exit when not Opt.Verbose; end if; end loop; elsif Has_Dependency (S.Index) then Print_Object (S.Source.Unit (S.Index)); end if; if Opt.Dependency_Mode and then Opt.Print_Sources then if Opt.Verbose then Text_IO.Put_Line (" depends upon"); end if; S.Source.Dependencies (S.Index, Dependency_Output'Access); end if; end; end loop; end Display_Normal; View : GPR2.Project.View.Object; Filter : GPR2.Project.Iterator_Control := GPR2.Project.Default_Iterator; begin if Opt.Verbose then Display_Paths; end if; if not Opt.Files.Is_Empty then -- Fill the various caches to get the sources from simple filenames -- and artefacts. for CV in Tree.Iterate ((Project.I_Extended => False, others => True)) loop for S of Project.Tree.Element (CV).Sources loop declare use Project.Source.Artifact; Artifacts : Project.Source.Artifact.Object; Dismiss : Boolean with Unreferenced; function Insert_Prefer_Body (Key : Filename_Type; Kind : GPR2.Unit.Library_Unit_Type; Index : Unit_Index) return Boolean; ------------------------ -- Insert_Prefer_Body -- ------------------------ function Insert_Prefer_Body (Key : Filename_Type; Kind : GPR2.Unit.Library_Unit_Type; Index : Unit_Index) return Boolean is procedure Do_Insert (Index : Unit_Index); --------------- -- Do_Insert -- --------------- procedure Do_Insert (Index : Unit_Index) is Position : Sources_By_Path.Cursor; Inserted : Boolean; begin Sources.Insert ((S, Index), Position, Inserted); if not Inserted and then S.Is_Aggregated < Sources (Position).Source.Is_Aggregated then -- Prefer none aggregated, more information there Sources.Replace_Element (Position, (S, Index)); end if; end Do_Insert; begin if Kind /= GPR2.Unit.S_Spec and then Opt.Files.Contains (String (Key)) then Remains.Exclude (String (Key)); if S.Has_Units and then Index = No_Index then for CU of S.Units loop if CU.Kind not in GPR2.Unit.S_Spec | GPR2.Unit.S_Separate then Do_Insert (CU.Index); end if; end loop; else Do_Insert (Index); end if; return True; end if; return False; end Insert_Prefer_Body; function Insert_Prefer_Body (Kind : GPR2.Unit.Library_Unit_Type; Index : Unit_Index) return Boolean is ((Artifacts.Has_Dependency (Index) and then (Insert_Prefer_Body (Artifacts.Dependency (Index).Simple_Name, Kind, Index) or else Insert_Prefer_Body (Artifacts.Dependency (Index).Base_Filename, Kind, Index))) or else (Artifacts.Has_Object_Code (Index) and then Insert_Prefer_Body (Artifacts.Object_Code (Index).Simple_Name, Kind, Index))); use GPR2.Project.Source; begin if not Insert_Prefer_Body (S.Path_Name.Simple_Name, GPR2.Unit.S_Body, No_Index) then Artifacts := GPR2.Project.Source.Artifact.Create (S, Filter => (Artifact.Dependency_File => True, Artifact.Object_File => True, others => False)); if S.Has_Units then for CU of S.Units loop exit when Insert_Prefer_Body (CU.Kind, CU.Index); end loop; else Dismiss := Insert_Prefer_Body (S.Kind, No_Index); end if; end if; end; end loop; end loop; -- -- All along, we will exclude non-ada sources. -- -- Fill the Sources set with the files given on the CL. -- Print "Can't find source for ..." if a file can't be matched with -- a compilable source from the root project (or from the project -- tree if All_Projects is set). for F of Remains loop Text_IO.Put_Line ("Can't find source for " & F); end loop; elsif Opt.Closure_Mode then -- If none was provided, then: -- - Either we're in closure mode, and we want to use the mains -- from the root project. for S of Tree.Root_Project.Sources loop if Tree.Root_Project.Has_Mains and then S.Is_Main and then (not GPR2.Is_Debug ('1') or else S.Language = Ada_Language) then Sources.Insert ((S, No_Index)); end if; end loop; elsif Opt.All_Projects then -- - Or we're not, and we will use all the compilable sources (from -- the root project or the entire tree, depending on All_Sources). Filter (GPR2.Project.I_Runtime) := Opt.With_Predefined_Units; for C in Tree.Iterate (Kind => Filter) loop View := GPR2.Project.Tree.Element (C); if not View.Is_Extended then for Src of View.Sources (Compilable_Only => True) loop if not GPR2.Is_Debug ('1') or else Src.Language = Ada_Language then if Src.Has_Units then for CU of Src.Units loop if Src.Is_Compilable (CU.Index) then Sources.Insert ((Src, CU.Index), Position, Inserted); end if; end loop; else Sources.Insert ((Src, No_Index), Position, Inserted); end if; -- Source could be already in the set because we -- can have the same project in the All_Views -- twice, one time for aggregated project another -- time for the imported project. Besides that we -- can have the same source in the aggregated -- project and in the aggregating library project. if not Inserted and then Src.Is_Aggregated < Sources_By_Path.Element (Position).Source.Is_Aggregated then -- We prefer Is_Aggregated = False because it -- has object files. if Src.Has_Units then for CU of Src.Units loop Sources.Replace_Element (Position, (Src, CU.Index)); end loop; else Sources.Replace_Element (Position, (Src, No_Index)); end if; end if; end if; end loop; end if; end loop; else for Src of Tree.Root_Project.Sources (Compilable_Only => True) loop if not GPR2.Is_Debug ('1') or else Src.Language = Ada_Language then if Src.Has_Units then for CU of Src.Units loop if Src.Is_Compilable (CU.Index) then Sources.Insert ((Src, CU.Index)); end if; end loop; else Sources.Insert ((Src, No_Index)); end if; end if; end loop; end if; -- Do nothing if no source was found if Sources.Is_Empty then return Command_Line.Success; end if; -- Check all sources and notify when no ALI file is present if not Opt.Source_Parser and then not Opt.Gnatdist then for S of Sources loop if S.Source.Has_Units then declare Other : constant GPR2.Project.Source.Source_Part := S.Source.Other_Part_Unchecked (S.Index); begin if S.Source.Kind (S.Index) /= Unit.S_Separate and then not S.Source.Is_Parsed (S.Index) and then (not Other.Source.Is_Defined or else not Other.Source.Is_Parsed (Other.Index)) then if Opt.Closure_Mode then Text_IO.Put_Line (File => Text_IO.Standard_Error, Item => String (S.Source.View.Path_Name.Simple_Name) & ": WARNING: the closure for " & String (S.Source.Path_Name.Simple_Name) & " is incomplete"); end if; if S.Source.Has_Naming_Exception and then S.Source.Naming_Exception = Project.Source.Multi_Unit then -- In case of multi-unit we have no information -- until the unit is compiled. There is no need to -- report that there is missing ALI in this case. -- But we report that the status for this file is -- unknown. Text_IO.Put_Line ("UNKNOWN status for unit " & String (S.Source.Unit_Name (S.Index)) & " in " & S.Source.Path_Name.Value & " at index" & S.Index'Image); else Text_IO.Put_Line ("Can't find ALI file for " & S.Source.Path_Name.Value); end if; end if; end; end if; end loop; end if; -- We gathered all the sources: -- Process them according to the chosen mode. if Opt.Closure_Mode then Display_Closures; elsif Opt.Gnatdist then Display_Gnatdist; else Display_Normal; -- List the project sources (or the subset given in the CL) that have -- compilation artifacts (.o/.ali) i.e. only the bodies. -- -- The options -o, -u, -s are used to select specific information to -- print. -- -- With -d, for every item listed (in non-closure mode) we also -- develop the dependencies (D lines of ALI) with their status. end if; end; return Command_Line.Success; exception when Project_Error | Processing_Error => Show_Tree_Load_Errors; Finish_Program (E_Errors, "unable to process project file " & String (Opt.Filename.Name)); return Command_Line.Failure; end GPRls.Process;
ytomino/vampire
Ada
5,280
ads
-- The Village of Vampire by YT, このソースコードはNYSLです with Vampire.Forms; with Vampire.Villages; package Vampire.Configurations is Temporary_Directory : constant String := "_data/tmp"; -- locking Lock_Name : aliased constant String := "_data/tmp/lock-vampire"; -- for debug Debug_Log_File_Name : aliased constant String := "_data/log/debug-log.txt"; -- for uses Users_Directory : aliased constant String := "_data/users"; -- temporary file for users Users_Log_File_Name : aliased constant String := "_data/log/users-log"; -- for casts Cast_File_Name : constant String := "cast"; -- for villages Villages_Data_Directory : aliased constant String := "_data/villages"; Villages_HTML_Directory : aliased constant String := "villages"; Villages_Index_HTML_File_Name : aliased constant String := "villages/index.html"; Villages_Index_RSS_File_Name : aliased constant String := "villages/wanted.rdf"; -- temporary file for villages Villages_Cache_File_Name : aliased constant String := "_data/cache/cache-villages"; Villages_Blocking_Short_Term_File_Name : aliased constant String := "_data/config/disabled-short"; -- for rendering Style_Sheet_File_Name : aliased constant String := "style.css"; Image_Directory : aliased constant String := "image"; Background_Image_File_Name : aliased constant String := Image_Directory & "/" & "background.png"; Relative_Role_Image_File_Names : aliased constant Villages.Role_Images := ( Villages.Gremlin => new String'("gremlin.png"), Villages.Vampire_Role => new String'("vampire.png"), Villages.Servant => new String'("servant.png"), Villages.Inhabitant | Villages.Loved_Inhabitant | Villages.Unfortunate_Inhabitant => new String'("inhabitant.png"), Villages.Detective => new String'("detective.png"), Villages.Doctor => new String'("doctor.png"), Villages.Astronomer => new String'("astronomer.png"), Villages.Hunter => new String'("hunter.png"), Villages.Lover | Villages.Sweetheart_M | Villages.Sweetheart_F => new String'("sweetheart.png")); -- templates type Template_Names_Type is record Style_Sheet_File_Name : not null Static_String_Access; Image_Directory : not null Static_String_Access; Background_Image_File_Name : not null Static_String_Access; Relative_Role_Image_File_Names : not null access constant Villages.Role_Images; Template_Index_File_Name : not null access constant String; Template_Register_File_Name : not null access constant String; Template_User_File_Name : not null access constant String; Template_User_List_File_Name : not null access constant String; Template_Village_File_Name : not null access constant String; Template_Preview_File_Name : not null access constant String; Template_Target_File_Name : not null access constant String; Template_Message_File_Name : not null access constant String; Template_Log_Index_File_Name : not null access constant String; end record; Template_Names : constant array (Forms.Template_Set_Type) of aliased Template_Names_Type := ( Forms.For_Full => ( Style_Sheet_File_Name => Style_Sheet_File_Name'Access, Image_Directory => Image_Directory'Access, Background_Image_File_Name => Background_Image_File_Name'Access, Relative_Role_Image_File_Names => Relative_Role_Image_File_Names'Access, Template_Index_File_Name => new String'("template-index.html"), Template_Register_File_Name => new String'("template-register.html"), Template_User_File_Name => new String'("template-user.html"), Template_User_List_File_Name => new String'("template-userlist.html"), Template_Village_File_Name => new String'("template-village.html"), Template_Preview_File_Name => new String'("template-preview.html"), Template_Target_File_Name => new String'("template-target.html"), Template_Message_File_Name => new String'("template-message.html"), Template_Log_Index_File_Name => new String'("template-logindex.html")), Forms.For_Mobile => ( Style_Sheet_File_Name => Style_Sheet_File_Name'Access, Image_Directory => Image_Directory'Access, Background_Image_File_Name => Background_Image_File_Name'Access, Relative_Role_Image_File_Names => Relative_Role_Image_File_Names'Access, Template_Index_File_Name => new String'("template-index-simple.html"), Template_Register_File_Name => new String'("template-register-simple.html"), Template_User_File_Name => new String'("template-user-simple.html"), Template_User_List_File_Name => new String'("template-userlist-simple.html"), Template_Village_File_Name => new String'("template-village-simple.html"), Template_Preview_File_Name => new String'("template-preview-simple.html"), Template_Target_File_Name => new String'("template-target-simple.html"), Template_Message_File_Name => new String'("template-message-simple.html"), Template_Log_Index_File_Name => new String'("template-logindex-simple.html"))); -- 携帯版で1ページに表示する発言数 Speeches_Per_Page : constant := 12; -- cookie有効期限 Cookie_Duration : constant Duration := 4 * 24 * 60 * 60 * 1.0; -- ムラムラスカウター(仮) Muramura_Duration : constant Duration := 24 * 60 * 60 * 1.0; end Vampire.Configurations;
reznikmm/ada-skynet
Ada
1,468
ads
-- Copyright (c) 2020 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with League.Strings; package Skynet is function "+" (Text : Wide_Wide_String) return League.Strings.Universal_String renames League.Strings.To_Universal_String; URI_Skynet_Prefix : constant Wide_Wide_String := "sia://"; type Portal_Upload_Options is record URL : League.Strings.Universal_String := +"https://siasky.net"; Upload_Path : League.Strings.Universal_String := +"skynet/skyfile"; File_Fieldname : League.Strings.Universal_String := +"file"; Directory_File_Fieldname : League.Strings.Universal_String := +"files[]"; end record; type Upload_Options is record Portal : Portal_Upload_Options; Custom_Filename : League.Strings.Universal_String; end record; procedure Upload_File (Path : League.Strings.Universal_String; Skylink : out League.Strings.Universal_String; Options : Upload_Options := (others => <>)) with Post => Skylink.Starts_With (URI_Skynet_Prefix); procedure Download_File (Path : League.Strings.Universal_String; Skylink : League.Strings.Universal_String; Portal_URL : League.Strings.Universal_String := +"https://siasky.net") with Pre => Skylink.Starts_With (URI_Skynet_Prefix); end Skynet;
stcarrez/dynamo
Ada
53,032
adb
------------------------------------------------------------------------------ -- -- -- ASIS-for-GNAT IMPLEMENTATION COMPONENTS -- -- -- -- A 4 G . K N D _ C O N V -- -- -- -- B o d y -- -- -- -- Copyright (C) 1995-2012, Free Software Foundation, Inc. -- -- -- -- ASIS-for-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 -- -- Software Foundation; either version 2, or (at your option) any later -- -- version. ASIS-for-GNAT is distributed in the hope that it will be use- -- -- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- -- -- CHANTABILITY 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 ASIS-for-GNAT; see file -- -- COPYING. If not, write to the Free Software Foundation, 51 Franklin -- -- Street, Fifth Floor, Boston, MA 02110-1301, USA. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the -- -- Software Engineering Laboratory of the Swiss Federal Institute of -- -- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the -- -- Scientific Research Computer Center of Moscow State University (SRCC -- -- MSU), Russia, with funding partially provided by grants from the Swiss -- -- National Science Foundation and the Swiss Academy of Engineering -- -- Sciences. ASIS-for-GNAT is now maintained by AdaCore -- -- (http://www.adacore.com). -- -- -- ------------------------------------------------------------------------------ package body A4G.Knd_Conv is use Asis; -------------------------------------- -- Element Classification Functions -- -------------------------------------- -- Most of the Conversion Functions use the table-driven switching to -- define the result of the conversion. Switches are implemented as -- one-dimension arrays indexed by the corresponding Internal_Element_Kinds -- subtype and having components of the target type of the conversion ------------------------------------------------------- -- Conversion Switches Definition and Initialization -- ------------------------------------------------------- Pragma_Kind_Switch : constant array (Internal_Pragma_Kinds) of Pragma_Kinds := (An_All_Calls_Remote_Pragma => An_All_Calls_Remote_Pragma, An_Asynchronous_Pragma => An_Asynchronous_Pragma, An_Atomic_Pragma => An_Atomic_Pragma, An_Atomic_Components_Pragma => An_Atomic_Components_Pragma, An_Attach_Handler_Pragma => An_Attach_Handler_Pragma, A_Controlled_Pragma => A_Controlled_Pragma, A_Convention_Pragma => A_Convention_Pragma, A_Discard_Names_Pragma => A_Discard_Names_Pragma, -- added An_Elaborate_Pragma => An_Elaborate_Pragma, -- added An_Elaborate_All_Pragma => An_Elaborate_All_Pragma, An_Elaborate_Body_Pragma => An_Elaborate_Body_Pragma, An_Export_Pragma => An_Export_Pragma, An_Import_Pragma => An_Import_Pragma, An_Inline_Pragma => An_Inline_Pragma, An_Inspection_Point_Pragma => An_Inspection_Point_Pragma, An_Interrupt_Handler_Pragma => An_Interrupt_Handler_Pragma, An_Interrupt_Priority_Pragma => An_Interrupt_Priority_Pragma, A_Linker_Options_Pragma => A_Linker_Options_Pragma, -- added A_List_Pragma => A_List_Pragma, A_Locking_Policy_Pragma => A_Locking_Policy_Pragma, A_Normalize_Scalars_Pragma => A_Normalize_Scalars_Pragma, An_Optimize_Pragma => An_Optimize_Pragma, A_Pack_Pragma => A_Pack_Pragma, A_Page_Pragma => A_Page_Pragma, A_Preelaborate_Pragma => A_Preelaborate_Pragma, A_Priority_Pragma => A_Priority_Pragma, A_Pure_Pragma => A_Pure_Pragma, A_Queuing_Policy_Pragma => A_Queuing_Policy_Pragma, A_Remote_Call_Interface_Pragma => A_Remote_Call_Interface_Pragma, A_Remote_Types_Pragma => A_Remote_Types_Pragma, A_Restrictions_Pragma => A_Restrictions_Pragma, A_Reviewable_Pragma => A_Reviewable_Pragma, A_Shared_Passive_Pragma => A_Shared_Passive_Pragma, A_Storage_Size_Pragma => A_Storage_Size_Pragma, -- added A_Suppress_Pragma => A_Suppress_Pragma, A_Task_Dispatching_Policy_Pragma => A_Task_Dispatching_Policy_Pragma, A_Volatile_Pragma => A_Volatile_Pragma, A_Volatile_Components_Pragma => A_Volatile_Components_Pragma, -- --|A2005 start -- New Ada 2005 pragmas. To be alphabetically ordered later: An_Assert_Pragma => An_Assert_Pragma, An_Assertion_Policy_Pragma => An_Assertion_Policy_Pragma, A_Detect_Blocking_Pragma => A_Detect_Blocking_Pragma, A_No_Return_Pragma => A_No_Return_Pragma, A_Partition_Elaboration_Policy_Pragma => A_Partition_Elaboration_Policy_Pragma, A_Preelaborable_Initialization_Pragma => A_Preelaborable_Initialization_Pragma, A_Priority_Specific_Dispatching_Pragma => A_Priority_Specific_Dispatching_Pragma, A_Profile_Pragma => A_Profile_Pragma, A_Relative_Deadline_Pragma => A_Relative_Deadline_Pragma, An_Unchecked_Union_Pragma => An_Unchecked_Union_Pragma, An_Unsuppress_Pragma => An_Unsuppress_Pragma, -- --|A2005 end -- --|A2012 start -- New Ada 2012 pragmas. To be alphabetically ordered later A_Default_Storage_Pool_Pragma => A_Default_Storage_Pool_Pragma, A_Dispatching_Domain_Pragma => A_Dispatching_Domain_Pragma, A_CPU_Pragma => A_CPU_Pragma, An_Independent_Pragma => An_Independent_Pragma, A_Independent_Components_Pragma => A_Independent_Components_Pragma, -- To be continued... -- --|A2012 end An_Implementation_Defined_Pragma => An_Implementation_Defined_Pragma, An_Unknown_Pragma => An_Unknown_Pragma); ------------------------------------------------------------------------------ Defining_Name_Kind_Switch : constant array (Internal_Defining_Name_Kinds) of Defining_Name_Kinds := (A_Defining_Identifier => A_Defining_Identifier, A_Defining_Character_Literal => A_Defining_Character_Literal, A_Defining_Enumeration_Literal => A_Defining_Enumeration_Literal, -- A_Defining_Operator_Symbol A_Defining_And_Operator .. A_Defining_Not_Operator => A_Defining_Operator_Symbol, A_Defining_Expanded_Name => A_Defining_Expanded_Name); ------------------------------------------------------------------------------ Declaration_Kind_Switch : constant array (Internal_Declaration_Kinds) of Declaration_Kinds := (An_Ordinary_Type_Declaration => An_Ordinary_Type_Declaration, A_Task_Type_Declaration => A_Task_Type_Declaration, A_Protected_Type_Declaration => A_Protected_Type_Declaration, An_Incomplete_Type_Declaration => An_Incomplete_Type_Declaration, A_Tagged_Incomplete_Type_Declaration => A_Tagged_Incomplete_Type_Declaration, A_Private_Type_Declaration => A_Private_Type_Declaration, A_Private_Extension_Declaration => A_Private_Extension_Declaration, A_Subtype_Declaration => A_Subtype_Declaration, A_Variable_Declaration => A_Variable_Declaration, A_Constant_Declaration => A_Constant_Declaration, A_Deferred_Constant_Declaration => A_Deferred_Constant_Declaration, A_Single_Task_Declaration => A_Single_Task_Declaration, A_Single_Protected_Declaration => A_Single_Protected_Declaration, An_Integer_Number_Declaration => An_Integer_Number_Declaration, A_Real_Number_Declaration => A_Real_Number_Declaration, An_Enumeration_Literal_Specification => An_Enumeration_Literal_Specification, A_Discriminant_Specification => A_Discriminant_Specification, A_Component_Declaration => A_Component_Declaration, A_Loop_Parameter_Specification => A_Loop_Parameter_Specification, A_Generalized_Iterator_Specification => A_Generalized_Iterator_Specification, An_Element_Iterator_Specification => An_Element_Iterator_Specification, A_Procedure_Declaration => A_Procedure_Declaration, A_Function_Declaration => A_Function_Declaration, A_Parameter_Specification => A_Parameter_Specification, A_Procedure_Body_Declaration => A_Procedure_Body_Declaration, A_Function_Body_Declaration => A_Function_Body_Declaration, A_Return_Variable_Specification => A_Return_Variable_Specification, A_Return_Constant_Specification => A_Return_Constant_Specification, A_Null_Procedure_Declaration => A_Null_Procedure_Declaration, An_Expression_Function_Declaration => An_Expression_Function_Declaration, A_Package_Declaration => A_Package_Declaration, A_Package_Body_Declaration => A_Package_Body_Declaration, An_Object_Renaming_Declaration => An_Object_Renaming_Declaration, An_Exception_Renaming_Declaration => An_Exception_Renaming_Declaration, A_Package_Renaming_Declaration => A_Package_Renaming_Declaration, A_Procedure_Renaming_Declaration => A_Procedure_Renaming_Declaration, A_Function_Renaming_Declaration => A_Function_Renaming_Declaration, A_Generic_Package_Renaming_Declaration => A_Generic_Package_Renaming_Declaration, A_Generic_Procedure_Renaming_Declaration => A_Generic_Procedure_Renaming_Declaration, A_Generic_Function_Renaming_Declaration => A_Generic_Function_Renaming_Declaration, A_Task_Body_Declaration => A_Task_Body_Declaration, A_Protected_Body_Declaration => A_Protected_Body_Declaration, An_Entry_Declaration => An_Entry_Declaration, An_Entry_Body_Declaration => An_Entry_Body_Declaration, An_Entry_Index_Specification => An_Entry_Index_Specification, A_Procedure_Body_Stub => A_Procedure_Body_Stub, A_Function_Body_Stub => A_Function_Body_Stub, A_Package_Body_Stub => A_Package_Body_Stub, A_Task_Body_Stub => A_Task_Body_Stub, A_Protected_Body_Stub => A_Protected_Body_Stub, An_Exception_Declaration => An_Exception_Declaration, A_Choice_Parameter_Specification => A_Choice_Parameter_Specification, A_Generic_Procedure_Declaration => A_Generic_Procedure_Declaration, A_Generic_Function_Declaration => A_Generic_Function_Declaration, A_Generic_Package_Declaration => A_Generic_Package_Declaration, A_Package_Instantiation => A_Package_Instantiation, A_Procedure_Instantiation => A_Procedure_Instantiation, A_Function_Instantiation => A_Function_Instantiation, A_Formal_Object_Declaration => A_Formal_Object_Declaration, A_Formal_Type_Declaration => A_Formal_Type_Declaration, A_Formal_Incomplete_Type_Declaration => A_Formal_Incomplete_Type_Declaration, A_Formal_Procedure_Declaration => A_Formal_Procedure_Declaration, A_Formal_Function_Declaration => A_Formal_Function_Declaration, A_Formal_Package_Declaration => A_Formal_Package_Declaration, A_Formal_Package_Declaration_With_Box => A_Formal_Package_Declaration_With_Box); ------------------------------------------------------------------------------ Definition_Kind_Switch : constant array (Internal_Definition_Kinds) of Definition_Kinds := (A_Derived_Type_Definition .. An_Access_To_Protected_Function => A_Type_Definition, A_Subtype_Indication => A_Subtype_Indication, -- A_Constraint, -- 3.2.2 -> Constraint_Kinds A_Range_Attribute_Reference .. A_Discriminant_Constraint => A_Constraint, A_Component_Definition => A_Component_Definition, -- A_Discrete_Subtype_Definition, -- 3.6 -> Discrete_Range_Kinds A_Discrete_Subtype_Indication_As_Subtype_Definition .. A_Discrete_Simple_Expression_Range_As_Subtype_Definition => A_Discrete_Subtype_Definition, -- A_Discrete_Range, -- 3.6.1 -> Discrete_Range_Kinds A_Discrete_Subtype_Indication .. A_Discrete_Simple_Expression_Range => A_Discrete_Range, An_Unknown_Discriminant_Part => An_Unknown_Discriminant_Part, A_Known_Discriminant_Part => A_Known_Discriminant_Part, A_Record_Definition => A_Record_Definition, A_Null_Record_Definition => A_Null_Record_Definition, A_Null_Component => A_Null_Component, A_Variant_Part => A_Variant_Part, A_Variant => A_Variant, An_Others_Choice => An_Others_Choice, -- --|A2005 start -- An_Access_Definition, -- 3.10(6/2) -> Access_Definition_Kinds An_Anonymous_Access_To_Variable .. An_Anonymous_Access_To_Protected_Function => An_Access_Definition, -- --|A2005 end A_Private_Type_Definition => A_Private_Type_Definition, A_Tagged_Private_Type_Definition => A_Tagged_Private_Type_Definition, A_Private_Extension_Definition => A_Private_Extension_Definition, A_Task_Definition => A_Task_Definition, A_Protected_Definition => A_Protected_Definition, -- A_Formal_Type_Definition, -- 12.5 -> Formal_Type_Kinds A_Formal_Private_Type_Definition .. A_Formal_Access_To_Protected_Function => A_Formal_Type_Definition, An_Aspect_Specification => An_Aspect_Specification); ------------------------------------------------------------------------------ Type_Kind_Switch : constant array (Internal_Type_Kinds) of Type_Kinds := (A_Derived_Type_Definition => A_Derived_Type_Definition, A_Derived_Record_Extension_Definition => A_Derived_Record_Extension_Definition, An_Enumeration_Type_Definition => An_Enumeration_Type_Definition, A_Signed_Integer_Type_Definition => A_Signed_Integer_Type_Definition, A_Modular_Type_Definition => A_Modular_Type_Definition, -- A_Root_Type_Definition, -- 3.5.4(10), 3.5.6(4) -- -> Root_Type_Kinds A_Root_Integer_Definition .. A_Universal_Fixed_Definition => A_Root_Type_Definition, A_Floating_Point_Definition => A_Floating_Point_Definition, An_Ordinary_Fixed_Point_Definition => An_Ordinary_Fixed_Point_Definition, A_Decimal_Fixed_Point_Definition => A_Decimal_Fixed_Point_Definition, An_Unconstrained_Array_Definition => An_Unconstrained_Array_Definition, A_Constrained_Array_Definition => A_Constrained_Array_Definition, A_Record_Type_Definition => A_Record_Type_Definition, A_Tagged_Record_Type_Definition => A_Tagged_Record_Type_Definition, -- --|A2005 start -- An_Interface_Type_Definition, -- 3.9.4 -> Interface_Kinds -- --|A2005 end An_Ordinary_Interface .. A_Synchronized_Interface => An_Interface_Type_Definition, -- An_Access_Type_Definition, -- 3.10 -> Access_Type_Kinds A_Pool_Specific_Access_To_Variable .. An_Access_To_Protected_Function => An_Access_Type_Definition); ------------------------------------------------------------------------------ Formal_Type_Kind_Switch : constant array (Internal_Formal_Type_Kinds) of Formal_Type_Kinds := (A_Formal_Private_Type_Definition => A_Formal_Private_Type_Definition, A_Formal_Tagged_Private_Type_Definition => A_Formal_Tagged_Private_Type_Definition, A_Formal_Derived_Type_Definition => A_Formal_Derived_Type_Definition, A_Formal_Discrete_Type_Definition => A_Formal_Discrete_Type_Definition, A_Formal_Signed_Integer_Type_Definition => A_Formal_Signed_Integer_Type_Definition, A_Formal_Modular_Type_Definition => A_Formal_Modular_Type_Definition, A_Formal_Floating_Point_Definition => A_Formal_Floating_Point_Definition, A_Formal_Ordinary_Fixed_Point_Definition => A_Formal_Ordinary_Fixed_Point_Definition, A_Formal_Decimal_Fixed_Point_Definition => A_Formal_Decimal_Fixed_Point_Definition, -- --|A2005 start -- A_Formal_Interface_Type_Definition, -- 12.5.5(2) -> Interface_Kinds A_Formal_Ordinary_Interface .. A_Formal_Synchronized_Interface => A_Formal_Interface_Type_Definition, -- --|A2005 end A_Formal_Unconstrained_Array_Definition => A_Formal_Unconstrained_Array_Definition, A_Formal_Constrained_Array_Definition => A_Formal_Constrained_Array_Definition, -- A_Formal_Access_Type_Definition, -- 12.5.4 -> Access_Type_Kinds A_Formal_Pool_Specific_Access_To_Variable .. A_Formal_Access_To_Protected_Function => A_Formal_Access_Type_Definition); ------------------------------------------------------------------------------ Access_Type_Kind_Switch : constant array (Internal_Access_Type_Kinds) of Access_Type_Kinds := (A_Pool_Specific_Access_To_Variable => A_Pool_Specific_Access_To_Variable, An_Access_To_Variable => An_Access_To_Variable, An_Access_To_Constant => An_Access_To_Constant, An_Access_To_Procedure => An_Access_To_Procedure, An_Access_To_Protected_Procedure => An_Access_To_Protected_Procedure, An_Access_To_Function => An_Access_To_Function, An_Access_To_Protected_Function => An_Access_To_Protected_Function); ------------------------------------------------------------------------------ -- --|A2005 start Access_Definition_Kind_Switch : constant array (Internal_Access_Definition_Kinds) of Access_Definition_Kinds := (An_Anonymous_Access_To_Variable => An_Anonymous_Access_To_Variable, An_Anonymous_Access_To_Constant => An_Anonymous_Access_To_Constant, An_Anonymous_Access_To_Procedure => An_Anonymous_Access_To_Procedure, An_Anonymous_Access_To_Protected_Procedure => An_Anonymous_Access_To_Protected_Procedure, An_Anonymous_Access_To_Function => An_Anonymous_Access_To_Function, An_Anonymous_Access_To_Protected_Function => An_Anonymous_Access_To_Protected_Function); Interface_Kind_Switch : constant array (Internal_Interface_Kinds) of Interface_Kinds := (An_Ordinary_Interface => An_Ordinary_Interface, A_Limited_Interface => A_Limited_Interface, A_Task_Interface => A_Task_Interface, A_Protected_Interface => A_Protected_Interface, A_Synchronized_Interface => A_Synchronized_Interface); Formal_Interface_Kind_Switch : constant array (Internal_Formal_Interface_Kinds) of Interface_Kinds := (A_Formal_Ordinary_Interface => An_Ordinary_Interface, A_Formal_Limited_Interface => A_Limited_Interface, A_Formal_Task_Interface => A_Task_Interface, A_Formal_Protected_Interface => A_Protected_Interface, A_Formal_Synchronized_Interface => A_Synchronized_Interface); -- --|A2005 end ------------------------------------------------------------------------------ Formal_Access_Type_Kind_Switch : constant array (Internal_Formal_Access_Type_Kinds) of Access_Type_Kinds := (A_Formal_Pool_Specific_Access_To_Variable => A_Pool_Specific_Access_To_Variable, A_Formal_Access_To_Variable => An_Access_To_Variable, A_Formal_Access_To_Constant => An_Access_To_Constant, A_Formal_Access_To_Procedure => An_Access_To_Procedure, A_Formal_Access_To_Protected_Procedure => An_Access_To_Protected_Procedure, A_Formal_Access_To_Function => An_Access_To_Function, A_Formal_Access_To_Protected_Function => An_Access_To_Protected_Function); ------------------------------------------------------------------------------ Root_Type_Kind_Switch : constant array (Internal_Root_Type_Kinds) of Root_Type_Kinds := (A_Root_Integer_Definition => A_Root_Integer_Definition, A_Root_Real_Definition => A_Root_Real_Definition, A_Universal_Integer_Definition => A_Universal_Integer_Definition, A_Universal_Real_Definition => A_Universal_Real_Definition, A_Universal_Fixed_Definition => A_Universal_Fixed_Definition); ------------------------------------------------------------------------------ Constraint_Kind_Switch : constant array (Internal_Constraint_Kinds) of Constraint_Kinds := (A_Range_Attribute_Reference => A_Range_Attribute_Reference, A_Simple_Expression_Range => A_Simple_Expression_Range, A_Digits_Constraint => A_Digits_Constraint, A_Delta_Constraint => A_Delta_Constraint, An_Index_Constraint => An_Index_Constraint, A_Discriminant_Constraint => A_Discriminant_Constraint); ------------------------------------------------------------------------------ Discrete_Range_Kind_Switch : constant array (Internal_Element_Kinds) of Discrete_Range_Kinds := -- This switch array (as well as Operator_Kind_Switch) differs from all -- the others, because it is to be used for two different internal -- classification subtypes: -- Internal_Discrete_Subtype_Definition_Kinds and -- Internal_Discrete_Range_Kinds (A_Discrete_Subtype_Indication_As_Subtype_Definition | A_Discrete_Subtype_Indication => A_Discrete_Subtype_Indication, A_Discrete_Range_Attribute_Reference_As_Subtype_Definition | A_Discrete_Range_Attribute_Reference => A_Discrete_Range_Attribute_Reference, A_Discrete_Simple_Expression_Range_As_Subtype_Definition | A_Discrete_Simple_Expression_Range => A_Discrete_Simple_Expression_Range, others => Not_A_Discrete_Range); ------------------------------------------------------------------------------ Expression_Kind_Switch : constant array (Internal_Expression_Kinds) of Expression_Kinds := (An_Integer_Literal => An_Integer_Literal, A_Real_Literal => A_Real_Literal, A_String_Literal => A_String_Literal, An_Identifier => An_Identifier, -- An_Operator_Symbol An_And_Operator .. A_Not_Operator => An_Operator_Symbol, A_Character_Literal => A_Character_Literal, An_Enumeration_Literal => An_Enumeration_Literal, An_Explicit_Dereference => An_Explicit_Dereference, A_Function_Call => A_Function_Call, An_Indexed_Component => An_Indexed_Component, A_Slice => A_Slice, A_Selected_Component => A_Selected_Component, An_Access_Attribute .. An_Unknown_Attribute => An_Attribute_Reference, A_Record_Aggregate => A_Record_Aggregate, An_Extension_Aggregate => An_Extension_Aggregate, A_Positional_Array_Aggregate => A_Positional_Array_Aggregate, A_Named_Array_Aggregate => A_Named_Array_Aggregate, An_And_Then_Short_Circuit => An_And_Then_Short_Circuit, An_Or_Else_Short_Circuit => An_Or_Else_Short_Circuit, An_In_Membership_Test => An_In_Membership_Test, A_Not_In_Membership_Test => A_Not_In_Membership_Test, A_Null_Literal => A_Null_Literal, A_Parenthesized_Expression => A_Parenthesized_Expression, A_Type_Conversion => A_Type_Conversion, A_Qualified_Expression => A_Qualified_Expression, An_Allocation_From_Subtype => An_Allocation_From_Subtype, An_Allocation_From_Qualified_Expression => An_Allocation_From_Qualified_Expression, A_Case_Expression => A_Case_Expression, An_If_Expression => An_If_Expression, A_For_All_Quantified_Expression => A_For_All_Quantified_Expression, A_For_Some_Quantified_Expression => A_For_Some_Quantified_Expression); ------------------------------------------------------------------------------ Operator_Kind_Switch : constant array (Internal_Element_Kinds) of Operator_Kinds := -- This switch array (as well as Discrete_Range_Kind_Switch) differs from -- all the others, because it is to be used for two different internal -- classification subtypes: -- Internal_Defining_Operator_Kinds and Internal_Operator_Symbol_Kinds (A_Defining_And_Operator | An_And_Operator => An_And_Operator, A_Defining_Or_Operator | An_Or_Operator => An_Or_Operator, A_Defining_Xor_Operator | An_Xor_Operator => An_Xor_Operator, A_Defining_Equal_Operator | An_Equal_Operator => An_Equal_Operator, A_Defining_Not_Equal_Operator | A_Not_Equal_Operator => A_Not_Equal_Operator, A_Defining_Less_Than_Operator | A_Less_Than_Operator => A_Less_Than_Operator, A_Defining_Less_Than_Or_Equal_Operator | A_Less_Than_Or_Equal_Operator => A_Less_Than_Or_Equal_Operator, A_Defining_Greater_Than_Operator | A_Greater_Than_Operator => A_Greater_Than_Operator, A_Defining_Greater_Than_Or_Equal_Operator | A_Greater_Than_Or_Equal_Operator => A_Greater_Than_Or_Equal_Operator, A_Defining_Plus_Operator | A_Plus_Operator => A_Plus_Operator, A_Defining_Minus_Operator | A_Minus_Operator => A_Minus_Operator, A_Defining_Concatenate_Operator | A_Concatenate_Operator => A_Concatenate_Operator, A_Defining_Unary_Plus_Operator | A_Unary_Plus_Operator => A_Unary_Plus_Operator, A_Defining_Unary_Minus_Operator | A_Unary_Minus_Operator => A_Unary_Minus_Operator, A_Defining_Multiply_Operator | A_Multiply_Operator => A_Multiply_Operator, A_Defining_Divide_Operator | A_Divide_Operator => A_Divide_Operator, A_Defining_Mod_Operator | A_Mod_Operator => A_Mod_Operator, A_Defining_Rem_Operator | A_Rem_Operator => A_Rem_Operator, A_Defining_Exponentiate_Operator | An_Exponentiate_Operator => An_Exponentiate_Operator, A_Defining_Abs_Operator | An_Abs_Operator => An_Abs_Operator, A_Defining_Not_Operator | A_Not_Operator => A_Not_Operator, others => Not_An_Operator); ------------------------------------------------------------------------------ Attribute_Kind_Switch : constant array (Internal_Attribute_Reference_Kinds) of Attribute_Kinds := ( An_Access_Attribute => An_Access_Attribute, An_Address_Attribute => An_Address_Attribute, An_Adjacent_Attribute => An_Adjacent_Attribute, An_Aft_Attribute => An_Aft_Attribute, An_Alignment_Attribute => An_Alignment_Attribute, A_Base_Attribute => A_Base_Attribute, A_Bit_Order_Attribute => A_Bit_Order_Attribute, A_Body_Version_Attribute => A_Body_Version_Attribute, A_Callable_Attribute => A_Callable_Attribute, A_Caller_Attribute => A_Caller_Attribute, A_Ceiling_Attribute => A_Ceiling_Attribute, A_Class_Attribute => A_Class_Attribute, A_Component_Size_Attribute => A_Component_Size_Attribute, A_Compose_Attribute => A_Compose_Attribute, A_Constrained_Attribute => A_Constrained_Attribute, A_Copy_Sign_Attribute => A_Copy_Sign_Attribute, A_Count_Attribute => A_Count_Attribute, A_Definite_Attribute => A_Definite_Attribute, A_Delta_Attribute => A_Delta_Attribute, A_Denorm_Attribute => A_Denorm_Attribute, A_Digits_Attribute => A_Digits_Attribute, An_Exponent_Attribute => An_Exponent_Attribute, An_External_Tag_Attribute => An_External_Tag_Attribute, A_First_Attribute => A_First_Attribute, A_First_Bit_Attribute => A_First_Bit_Attribute, A_Floor_Attribute => A_Floor_Attribute, A_Fore_Attribute => A_Fore_Attribute, A_Fraction_Attribute => A_Fraction_Attribute, An_Identity_Attribute => An_Identity_Attribute, An_Image_Attribute => An_Image_Attribute, An_Input_Attribute => An_Input_Attribute, A_Last_Attribute => A_Last_Attribute, A_Last_Bit_Attribute => A_Last_Bit_Attribute, A_Leading_Part_Attribute => A_Leading_Part_Attribute, A_Length_Attribute => A_Length_Attribute, A_Machine_Attribute => A_Machine_Attribute, A_Machine_Emax_Attribute => A_Machine_Emax_Attribute, A_Machine_Emin_Attribute => A_Machine_Emin_Attribute, A_Machine_Mantissa_Attribute => A_Machine_Mantissa_Attribute, A_Machine_Overflows_Attribute => A_Machine_Overflows_Attribute, A_Machine_Radix_Attribute => A_Machine_Radix_Attribute, A_Machine_Rounds_Attribute => A_Machine_Rounds_Attribute, A_Max_Attribute => A_Max_Attribute, A_Max_Size_In_Storage_Elements_Attribute => A_Max_Size_In_Storage_Elements_Attribute, A_Min_Attribute => A_Min_Attribute, A_Model_Attribute => A_Model_Attribute, A_Model_Emin_Attribute => A_Model_Emin_Attribute, A_Model_Epsilon_Attribute => A_Model_Epsilon_Attribute, A_Model_Mantissa_Attribute => A_Model_Mantissa_Attribute, A_Model_Small_Attribute => A_Model_Small_Attribute, A_Modulus_Attribute => A_Modulus_Attribute, An_Output_Attribute => An_Output_Attribute, A_Partition_ID_Attribute => A_Partition_ID_Attribute, A_Pos_Attribute => A_Pos_Attribute, A_Position_Attribute => A_Position_Attribute, A_Pred_Attribute => A_Pred_Attribute, A_Range_Attribute => A_Range_Attribute, A_Read_Attribute => A_Read_Attribute, A_Remainder_Attribute => A_Remainder_Attribute, A_Round_Attribute => A_Round_Attribute, A_Rounding_Attribute => A_Rounding_Attribute, A_Safe_First_Attribute => A_Safe_First_Attribute, A_Safe_Last_Attribute => A_Safe_Last_Attribute, A_Scale_Attribute => A_Scale_Attribute, A_Scaling_Attribute => A_Scaling_Attribute, A_Signed_Zeros_Attribute => A_Signed_Zeros_Attribute, A_Size_Attribute => A_Size_Attribute, A_Small_Attribute => A_Small_Attribute, A_Storage_Pool_Attribute => A_Storage_Pool_Attribute, A_Storage_Size_Attribute => A_Storage_Size_Attribute, A_Succ_Attribute => A_Succ_Attribute, A_Tag_Attribute => A_Tag_Attribute, A_Terminated_Attribute => A_Terminated_Attribute, A_Truncation_Attribute => A_Truncation_Attribute, An_Unbiased_Rounding_Attribute => An_Unbiased_Rounding_Attribute, An_Unchecked_Access_Attribute => An_Unchecked_Access_Attribute, A_Val_Attribute => A_Val_Attribute, A_Valid_Attribute => A_Valid_Attribute, A_Value_Attribute => A_Value_Attribute, A_Version_Attribute => A_Version_Attribute, A_Wide_Image_Attribute => A_Wide_Image_Attribute, A_Wide_Value_Attribute => A_Wide_Value_Attribute, A_Wide_Width_Attribute => A_Wide_Width_Attribute, A_Width_Attribute => A_Width_Attribute, A_Write_Attribute => A_Write_Attribute, -- |A2005/2012 start -- New Ada 2005/2012 attributes. To be alphabetically ordered later A_Machine_Rounding_Attribute => A_Machine_Rounding_Attribute, A_Mod_Attribute => A_Mod_Attribute, A_Priority_Attribute => A_Priority_Attribute, A_Stream_Size_Attribute => A_Stream_Size_Attribute, A_Wide_Wide_Image_Attribute => A_Wide_Wide_Image_Attribute, A_Wide_Wide_Value_Attribute => A_Wide_Wide_Value_Attribute, A_Wide_Wide_Width_Attribute => A_Wide_Wide_Width_Attribute, A_Max_Alignment_For_Allocation_Attribute => A_Max_Alignment_For_Allocation_Attribute, An_Overlaps_Storage_Attribute => An_Overlaps_Storage_Attribute, -- |A2005/2012 end An_Implementation_Defined_Attribute => An_Implementation_Defined_Attribute, An_Unknown_Attribute => An_Unknown_Attribute); ------------------------------------------------------------------------------ Association_Kind_Switch : constant array (Internal_Association_Kinds) of Association_Kinds := ( A_Pragma_Argument_Association => A_Pragma_Argument_Association, A_Discriminant_Association => A_Discriminant_Association, A_Record_Component_Association => A_Record_Component_Association, An_Array_Component_Association => An_Array_Component_Association, A_Parameter_Association => A_Parameter_Association, A_Generic_Association => A_Generic_Association); ------------------------------------------------------------------------------ Statement_Kind_Switch : constant array (Internal_Statement_Kinds) of Statement_Kinds := (A_Null_Statement => A_Null_Statement, An_Assignment_Statement => An_Assignment_Statement, An_If_Statement => An_If_Statement, A_Case_Statement => A_Case_Statement, A_Loop_Statement => A_Loop_Statement, A_While_Loop_Statement => A_While_Loop_Statement, A_For_Loop_Statement => A_For_Loop_Statement, A_Block_Statement => A_Block_Statement, An_Exit_Statement => An_Exit_Statement, A_Goto_Statement => A_Goto_Statement, A_Procedure_Call_Statement => A_Procedure_Call_Statement, A_Return_Statement => A_Return_Statement, -- --|A2005 start An_Extended_Return_Statement => An_Extended_Return_Statement, -- --|A2005 end An_Accept_Statement => An_Accept_Statement, An_Entry_Call_Statement => An_Entry_Call_Statement, A_Requeue_Statement => A_Requeue_Statement, A_Requeue_Statement_With_Abort => A_Requeue_Statement_With_Abort, A_Delay_Until_Statement => A_Delay_Until_Statement, A_Delay_Relative_Statement => A_Delay_Relative_Statement, A_Terminate_Alternative_Statement => A_Terminate_Alternative_Statement, A_Selective_Accept_Statement => A_Selective_Accept_Statement, A_Timed_Entry_Call_Statement => A_Timed_Entry_Call_Statement, A_Conditional_Entry_Call_Statement => A_Conditional_Entry_Call_Statement, An_Asynchronous_Select_Statement => An_Asynchronous_Select_Statement, An_Abort_Statement => An_Abort_Statement, A_Raise_Statement => A_Raise_Statement, A_Code_Statement => A_Code_Statement); ------------------------------------------------------------------------------ Path_Kind_Switch : constant array (Internal_Path_Kinds) of Path_Kinds := (An_If_Path => An_If_Path, An_Elsif_Path => An_Elsif_Path, An_Else_Path => An_Else_Path, A_Case_Path => A_Case_Path, A_Select_Path => A_Select_Path, An_Or_Path => An_Or_Path, A_Then_Abort_Path => A_Then_Abort_Path, A_Case_Expression_Path => A_Case_Expression_Path, An_If_Expression_Path => An_If_Expression_Path, An_Elsif_Expression_Path => An_Elsif_Expression_Path, An_Else_Expression_Path => An_Else_Expression_Path); ------------------------------------------------------------------------------ Clause_Kind_Switch : constant array (Internal_Clause_Kinds) of Clause_Kinds := (A_Use_Package_Clause => A_Use_Package_Clause, A_Use_Type_Clause => A_Use_Type_Clause, A_Use_All_Type_Clause => A_Use_All_Type_Clause, -- Ada 2012 A_With_Clause => A_With_Clause, -- A_Representation_Clause, -- 13.1 -> Representation_Clause_Kinds An_Attribute_Definition_Clause .. An_At_Clause => A_Representation_Clause, A_Component_Clause => A_Component_Clause); ------------------------------------------------------------------------------ Representation_Clause_Kind_Switch : constant array (Internal_Representation_Clause_Kinds) of Representation_Clause_Kinds := (An_Attribute_Definition_Clause => An_Attribute_Definition_Clause, An_Enumeration_Representation_Clause => An_Enumeration_Representation_Clause, A_Record_Representation_Clause => A_Record_Representation_Clause, An_At_Clause => An_At_Clause); ------------------------------------------------------------------------------ Def_Op_Switch : constant array (Internal_Operator_Symbol_Kinds) of Internal_Defining_Operator_Kinds := (An_And_Operator => A_Defining_And_Operator, An_Or_Operator => A_Defining_Or_Operator, An_Xor_Operator => A_Defining_Xor_Operator, An_Equal_Operator => A_Defining_Equal_Operator, A_Not_Equal_Operator => A_Defining_Not_Equal_Operator, A_Less_Than_Operator => A_Defining_Less_Than_Operator, A_Less_Than_Or_Equal_Operator => A_Defining_Less_Than_Or_Equal_Operator, A_Greater_Than_Operator => A_Defining_Greater_Than_Operator, A_Greater_Than_Or_Equal_Operator => A_Defining_Greater_Than_Or_Equal_Operator, A_Plus_Operator => A_Defining_Plus_Operator, A_Minus_Operator => A_Defining_Minus_Operator, A_Concatenate_Operator => A_Defining_Concatenate_Operator, A_Unary_Plus_Operator => A_Defining_Unary_Plus_Operator, A_Unary_Minus_Operator => A_Defining_Unary_Minus_Operator, A_Multiply_Operator => A_Defining_Multiply_Operator, A_Divide_Operator => A_Defining_Divide_Operator, A_Mod_Operator => A_Defining_Mod_Operator, A_Rem_Operator => A_Defining_Rem_Operator, An_Exponentiate_Operator => A_Defining_Exponentiate_Operator, An_Abs_Operator => A_Defining_Abs_Operator, A_Not_Operator => A_Defining_Not_Operator); ------------------------------------------------------------------------------ ------------------------------------------------- -- Internal Element Kinds Conversion Functions -- ------------------------------------------------- ------------------------------------ -- Access_Type_Kind_From_Internal -- ------------------------------------ function Access_Type_Kind_From_Internal (Internal_Kind : Internal_Element_Kinds) return Asis.Access_Type_Kinds is begin if Internal_Kind in Internal_Access_Type_Kinds then return Access_Type_Kind_Switch (Internal_Kind); elsif Internal_Kind in Internal_Formal_Access_Type_Kinds then return Formal_Access_Type_Kind_Switch (Internal_Kind); else return Not_An_Access_Type_Definition; end if; end Access_Type_Kind_From_Internal; ----------------------------- -- Asis_From_Internal_Kind -- ----------------------------- function Asis_From_Internal_Kind (Internal_Kind : Internal_Element_Kinds) return Asis.Element_Kinds is begin case Internal_Kind is when Internal_Pragma_Kinds => return A_Pragma; when Internal_Defining_Name_Kinds => return A_Defining_Name; when Internal_Declaration_Kinds => return A_Declaration; when Internal_Definition_Kinds => return A_Definition; when Internal_Expression_Kinds => return An_Expression; when Internal_Association_Kinds => return An_Association; when Internal_Statement_Kinds => return A_Statement; when Internal_Path_Kinds => return A_Path; when Internal_Clause_Kinds => return A_Clause; when An_Exception_Handler => return An_Exception_Handler; when others => -- Not_An_Element and Not_A_XXX values return Not_An_Element; end case; end Asis_From_Internal_Kind; ------------------------------------ -- Association_Kind_From_Internal -- ------------------------------------ function Association_Kind_From_Internal (Internal_Kind : Internal_Element_Kinds) return Asis.Association_Kinds is begin if Internal_Kind not in Internal_Association_Kinds then return Not_An_Association; else return Association_Kind_Switch (Internal_Kind); end if; end Association_Kind_From_Internal; ---------------------------------- -- Attribute_Kind_From_Internal -- ---------------------------------- function Attribute_Kind_From_Internal (Internal_Kind : Internal_Element_Kinds) return Asis.Attribute_Kinds is begin if Internal_Kind not in Internal_Attribute_Reference_Kinds then return Not_An_Attribute; else return Attribute_Kind_Switch (Internal_Kind); end if; end Attribute_Kind_From_Internal; ------------------------------- -- Clause_Kind_From_Internal -- ------------------------------- function Clause_Kind_From_Internal (Internal_Kind : Internal_Element_Kinds) return Asis.Clause_Kinds is begin if Internal_Kind not in Internal_Clause_Kinds then return Not_A_Clause; else return Clause_Kind_Switch (Internal_Kind); end if; end Clause_Kind_From_Internal; ----------------------------------- -- Constraint_Kind_From_Internal -- ----------------------------------- function Constraint_Kind_From_Internal (Internal_Kind : Internal_Element_Kinds) return Asis.Constraint_Kinds is begin if Internal_Kind not in Internal_Constraint_Kinds then return Not_A_Constraint; else return Constraint_Kind_Switch (Internal_Kind); end if; end Constraint_Kind_From_Internal; ------------------------------------ -- Declaration_Kind_From_Internal -- ------------------------------------ function Declaration_Kind_From_Internal (Internal_Kind : Internal_Element_Kinds) return Asis.Declaration_Kinds is begin if Internal_Kind not in Internal_Declaration_Kinds then return Not_A_Declaration; else return Declaration_Kind_Switch (Internal_Kind); end if; end Declaration_Kind_From_Internal; ------------------------------------- -- Defining_Name_Kind_From_Internal-- ------------------------------------- function Defining_Name_Kind_From_Internal (Internal_Kind : Internal_Element_Kinds) return Asis.Defining_Name_Kinds is begin if Internal_Kind not in Internal_Defining_Name_Kinds then return Not_A_Defining_Name; else return Defining_Name_Kind_Switch (Internal_Kind); end if; end Defining_Name_Kind_From_Internal; ----------------------------------- -- Definition_Kind_From_Internal -- ----------------------------------- function Definition_Kind_From_Internal (Internal_Kind : Internal_Element_Kinds) return Asis.Definition_Kinds is begin if Internal_Kind not in Internal_Definition_Kinds then return Not_A_Definition; else return Definition_Kind_Switch (Internal_Kind); end if; end Definition_Kind_From_Internal; --------------------------------------- -- Discrete_Range_Kind_From_Internal -- --------------------------------------- function Discrete_Range_Kind_From_Internal (Internal_Kind : Internal_Element_Kinds) return Asis.Discrete_Range_Kinds is begin return Discrete_Range_Kind_Switch (Internal_Kind); end Discrete_Range_Kind_From_Internal; ----------------------------------- -- Expression_Kind_From_Internal -- ----------------------------------- function Expression_Kind_From_Internal (Internal_Kind : Internal_Element_Kinds) return Asis.Expression_Kinds is begin if Internal_Kind not in Internal_Expression_Kinds then return Not_An_Expression; else return Expression_Kind_Switch (Internal_Kind); end if; end Expression_Kind_From_Internal; ------------------------------------ -- Formal_Type_Kind_From_Internal -- ------------------------------------ function Formal_Type_Kind_From_Internal (Internal_Kind : Internal_Element_Kinds) return Asis.Formal_Type_Kinds is begin if Internal_Kind not in Internal_Formal_Type_Kinds then return Not_A_Formal_Type_Definition; else return Formal_Type_Kind_Switch (Internal_Kind); end if; end Formal_Type_Kind_From_Internal; -- --|A2005 start ------------------------------------------ -- Access_Definition_Kind_From_Internal -- ------------------------------------------ function Access_Definition_Kind_From_Internal (Internal_Kind : Internal_Element_Kinds) return Asis.Access_Definition_Kinds is begin if Internal_Kind not in Internal_Access_Definition_Kinds then return Not_An_Access_Definition; else return Access_Definition_Kind_Switch (Internal_Kind); end if; end Access_Definition_Kind_From_Internal; ---------------------------------- -- Interface_Kind_From_Internal -- ---------------------------------- function Interface_Kind_From_Internal (Internal_Kind : Internal_Element_Kinds) return Asis.Interface_Kinds is begin if Internal_Kind in Internal_Interface_Kinds then return Interface_Kind_Switch (Internal_Kind); elsif Internal_Kind in Internal_Formal_Interface_Kinds then return Formal_Interface_Kind_Switch (Internal_Kind); else return Not_An_Interface; end if; end Interface_Kind_From_Internal; -- --|A2005 end --------------------------------- -- Operator_Kind_From_Internal -- --------------------------------- function Operator_Kind_From_Internal (Internal_Kind : Internal_Element_Kinds) return Asis.Operator_Kinds is begin return Operator_Kind_Switch (Internal_Kind); end Operator_Kind_From_Internal; ----------------------------- -- Path_Kind_From_Internal -- ----------------------------- function Path_Kind_From_Internal (Internal_Kind : Internal_Element_Kinds) return Asis.Path_Kinds is begin if Internal_Kind not in Internal_Path_Kinds then return Not_A_Path; else return Path_Kind_Switch (Internal_Kind); end if; end Path_Kind_From_Internal; ------------------------------- -- Pragma_Kind_From_Internal -- ------------------------------- function Pragma_Kind_From_Internal (Internal_Kind : Internal_Element_Kinds) return Asis.Pragma_Kinds is begin if Internal_Kind not in Internal_Pragma_Kinds then return Not_A_Pragma; else return Pragma_Kind_Switch (Internal_Kind); end if; end Pragma_Kind_From_Internal; ---------------------------------------------- -- Representation_Clause_Kind_From_Internal -- ----------------------------------------------- function Representation_Clause_Kind_From_Internal (Internal_Kind : Internal_Element_Kinds) return Asis.Representation_Clause_Kinds is begin if Internal_Kind not in Internal_Representation_Clause_Kinds then return Not_A_Representation_Clause; else return Representation_Clause_Kind_Switch (Internal_Kind); end if; end Representation_Clause_Kind_From_Internal; ---------------------------------- -- Root_Type_Kind_From_Internal -- ---------------------------------- function Root_Type_Kind_From_Internal (Internal_Kind : Internal_Element_Kinds) return Asis.Root_Type_Kinds is begin if Internal_Kind not in Internal_Root_Type_Kinds then return Not_A_Root_Type_Definition; else return Root_Type_Kind_Switch (Internal_Kind); end if; end Root_Type_Kind_From_Internal; ---------------------------------- -- Statement_Kind_From_Internal -- ---------------------------------- function Statement_Kind_From_Internal (Internal_Kind : Internal_Element_Kinds) return Asis.Statement_Kinds is begin if Internal_Kind not in Internal_Statement_Kinds then return Not_A_Statement; else return Statement_Kind_Switch (Internal_Kind); end if; end Statement_Kind_From_Internal; ----------------------------- -- Type_Kind_From_Internal -- ----------------------------- function Type_Kind_From_Internal (Internal_Kind : Internal_Element_Kinds) return Asis.Type_Kinds is begin if Internal_Kind not in Internal_Type_Kinds then return Not_A_Type_Definition; else return Type_Kind_Switch (Internal_Kind); end if; end Type_Kind_From_Internal; ------------------------------------- -- Additional Classification items -- ------------------------------------- ----------------------- -- Def_Operator_Kind -- ----------------------- function Def_Operator_Kind (Op_Kind : Internal_Element_Kinds) return Internal_Element_Kinds is begin return Def_Op_Switch (Op_Kind); end Def_Operator_Kind; ------------------------------------------------------------------------------ end A4G.Knd_Conv;
stcarrez/babel
Ada
1,178
ads
----------------------------------------------------------------------- -- babel-stores-local-tests - Unit tests for babel streams -- Copyright (C) 2016 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; package Babel.Stores.Local.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new Util.Tests.Test with null record; -- Test the Read_File and Write_File operations. procedure Test_Read_File (T : in out Test); end Babel.Stores.Local.Tests;
reznikmm/matreshka
Ada
31,799
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-2015, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ pragma Restrictions (No_Elaboration_Code); -- GNAT: enforce generation of preinitialized data section instead of -- generation of elaboration code. package Matreshka.Internals.Unicode.Ucd.Core_0020 is pragma Preelaborate; Group_0020 : aliased constant Core_Second_Stage := (16#00# .. 16#06# => -- 2000 .. 2006 (Space_Separator, Neutral, Other, Other, Sp, Break_After, (White_Space | Grapheme_Base | Changes_When_NFKC_Casefolded => True, others => False)), 16#07# => -- 2007 (Space_Separator, Neutral, Other, Other, Sp, Glue, (White_Space | Grapheme_Base | Changes_When_NFKC_Casefolded => True, others => False)), 16#08# .. 16#0A# => -- 2008 .. 200A (Space_Separator, Neutral, Other, Other, Sp, Break_After, (White_Space | Grapheme_Base | Changes_When_NFKC_Casefolded => True, others => False)), 16#0B# => -- 200B (Format, Neutral, Control, Other, Format, ZW_Space, (Case_Ignorable | Default_Ignorable_Code_Point | Changes_When_NFKC_Casefolded => True, others => False)), 16#0C# .. 16#0D# => -- 200C .. 200D (Format, Neutral, Extend, Extend, Extend, Combining_Mark, (Join_Control | Other_Grapheme_Extend | Case_Ignorable | Default_Ignorable_Code_Point | Grapheme_Extend | Changes_When_NFKC_Casefolded => True, others => False)), 16#0E# .. 16#0F# => -- 200E .. 200F (Format, Neutral, Control, Format, Format, Combining_Mark, (Bidi_Control | Pattern_White_Space | Case_Ignorable | Default_Ignorable_Code_Point | Changes_When_NFKC_Casefolded => True, others => False)), 16#10# => -- 2010 (Dash_Punctuation, Ambiguous, Other, Other, Other, Break_After, (Dash | Hyphen | Pattern_Syntax | Grapheme_Base => True, others => False)), 16#11# => -- 2011 (Dash_Punctuation, Neutral, Other, Other, Other, Glue, (Dash | Hyphen | Pattern_Syntax | Grapheme_Base | Changes_When_NFKC_Casefolded => True, others => False)), 16#12# => -- 2012 (Dash_Punctuation, Neutral, Other, Other, Other, Break_After, (Dash | Pattern_Syntax | Grapheme_Base => True, others => False)), 16#13# => -- 2013 (Dash_Punctuation, Ambiguous, Other, Other, S_Continue, Break_After, (Dash | Pattern_Syntax | Grapheme_Base => True, others => False)), 16#14# => -- 2014 (Dash_Punctuation, Ambiguous, Other, Other, S_Continue, Break_Both, (Dash | Pattern_Syntax | Grapheme_Base => True, others => False)), 16#15# => -- 2015 (Dash_Punctuation, Ambiguous, Other, Other, Other, Ambiguous, (Dash | Pattern_Syntax | Grapheme_Base => True, others => False)), 16#16# => -- 2016 (Other_Punctuation, Ambiguous, Other, Other, Other, Ambiguous, (Other_Math | Pattern_Syntax | Grapheme_Base | Math => True, others => False)), 16#17# => -- 2017 (Other_Punctuation, Neutral, Other, Other, Other, Alphabetic, (Pattern_Syntax | Grapheme_Base | Changes_When_NFKC_Casefolded => True, others => False)), 16#18# => -- 2018 (Initial_Punctuation, Ambiguous, Other, Mid_Num_Let, Close, Quotation, (Pattern_Syntax | Quotation_Mark | Case_Ignorable | Grapheme_Base => True, others => False)), 16#19# => -- 2019 (Final_Punctuation, Ambiguous, Other, Mid_Num_Let, Close, Quotation, (Pattern_Syntax | Quotation_Mark | Case_Ignorable | Grapheme_Base => True, others => False)), 16#1A# => -- 201A (Open_Punctuation, Neutral, Other, Other, Close, Open_Punctuation, (Pattern_Syntax | Quotation_Mark | Grapheme_Base => True, others => False)), 16#1B# => -- 201B (Initial_Punctuation, Neutral, Other, Other, Close, Quotation, (Pattern_Syntax | Quotation_Mark | Grapheme_Base => True, others => False)), 16#1C# => -- 201C (Initial_Punctuation, Ambiguous, Other, Other, Close, Quotation, (Pattern_Syntax | Quotation_Mark | Grapheme_Base => True, others => False)), 16#1D# => -- 201D (Final_Punctuation, Ambiguous, Other, Other, Close, Quotation, (Pattern_Syntax | Quotation_Mark | Grapheme_Base => True, others => False)), 16#1E# => -- 201E (Open_Punctuation, Neutral, Other, Other, Close, Open_Punctuation, (Pattern_Syntax | Quotation_Mark | Grapheme_Base => True, others => False)), 16#1F# => -- 201F (Initial_Punctuation, Neutral, Other, Other, Close, Quotation, (Pattern_Syntax | Quotation_Mark | Grapheme_Base => True, others => False)), 16#20# .. 16#21# => -- 2020 .. 2021 (Other_Punctuation, Ambiguous, Other, Other, Other, Ambiguous, (Pattern_Syntax | Grapheme_Base => True, others => False)), 16#22# => -- 2022 (Other_Punctuation, Ambiguous, Other, Other, Other, Alphabetic, (Pattern_Syntax | Grapheme_Base => True, others => False)), 16#23# => -- 2023 (Other_Punctuation, Neutral, Other, Other, Other, Alphabetic, (Pattern_Syntax | Grapheme_Base => True, others => False)), 16#24# => -- 2024 (Other_Punctuation, Ambiguous, Other, Mid_Num_Let, A_Term, Inseparable, (Pattern_Syntax | Case_Ignorable | Grapheme_Base | Changes_When_NFKC_Casefolded => True, others => False)), 16#25# .. 16#26# => -- 2025 .. 2026 (Other_Punctuation, Ambiguous, Other, Other, Other, Inseparable, (Pattern_Syntax | Grapheme_Base | Changes_When_NFKC_Casefolded => True, others => False)), 16#27# => -- 2027 (Other_Punctuation, Ambiguous, Other, Mid_Letter, Other, Break_After, (Pattern_Syntax | Case_Ignorable | Grapheme_Base => True, others => False)), 16#28# => -- 2028 (Line_Separator, Neutral, Control, Newline, Sep, Mandatory_Break, (Pattern_White_Space | White_Space => True, others => False)), 16#29# => -- 2029 (Paragraph_Separator, Neutral, Control, Newline, Sep, Mandatory_Break, (Pattern_White_Space | White_Space => True, others => False)), 16#2A# .. 16#2E# => -- 202A .. 202E (Format, Neutral, Control, Format, Format, Combining_Mark, (Bidi_Control | Case_Ignorable | Default_Ignorable_Code_Point | Changes_When_NFKC_Casefolded => True, others => False)), 16#2F# => -- 202F (Space_Separator, Neutral, Other, Other, Sp, Glue, (White_Space | Grapheme_Base | Changes_When_NFKC_Casefolded => True, others => False)), 16#30# => -- 2030 (Other_Punctuation, Ambiguous, Other, Other, Other, Postfix_Numeric, (Pattern_Syntax | Grapheme_Base => True, others => False)), 16#31# => -- 2031 (Other_Punctuation, Neutral, Other, Other, Other, Postfix_Numeric, (Pattern_Syntax | Grapheme_Base => True, others => False)), 16#32# => -- 2032 (Other_Punctuation, Ambiguous, Other, Other, Other, Postfix_Numeric, (Other_Math | Pattern_Syntax | Grapheme_Base | Math => True, others => False)), 16#33# => -- 2033 (Other_Punctuation, Ambiguous, Other, Other, Other, Postfix_Numeric, (Other_Math | Pattern_Syntax | Grapheme_Base | Math | Changes_When_NFKC_Casefolded => True, others => False)), 16#34# => -- 2034 (Other_Punctuation, Neutral, Other, Other, Other, Postfix_Numeric, (Other_Math | Pattern_Syntax | Grapheme_Base | Math | Changes_When_NFKC_Casefolded => True, others => False)), 16#35# => -- 2035 (Other_Punctuation, Ambiguous, Other, Other, Other, Postfix_Numeric, (Pattern_Syntax | Grapheme_Base => True, others => False)), 16#36# .. 16#37# => -- 2036 .. 2037 (Other_Punctuation, Neutral, Other, Other, Other, Postfix_Numeric, (Pattern_Syntax | Grapheme_Base | Changes_When_NFKC_Casefolded => True, others => False)), 16#38# => -- 2038 (Other_Punctuation, Neutral, Other, Other, Other, Alphabetic, (Pattern_Syntax | Grapheme_Base => True, others => False)), 16#39# => -- 2039 (Initial_Punctuation, Neutral, Other, Other, Close, Quotation, (Pattern_Syntax | Quotation_Mark | Grapheme_Base => True, others => False)), 16#3A# => -- 203A (Final_Punctuation, Neutral, Other, Other, Close, Quotation, (Pattern_Syntax | Quotation_Mark | Grapheme_Base => True, others => False)), 16#3B# => -- 203B (Other_Punctuation, Ambiguous, Other, Other, Other, Ambiguous, (Pattern_Syntax | Grapheme_Base => True, others => False)), 16#3C# => -- 203C (Other_Punctuation, Neutral, Other, Other, S_Term, Nonstarter, (Pattern_Syntax | STerm | Terminal_Punctuation | Grapheme_Base | Changes_When_NFKC_Casefolded => True, others => False)), 16#3D# => -- 203D (Other_Punctuation, Neutral, Other, Other, S_Term, Nonstarter, (Pattern_Syntax | STerm | Terminal_Punctuation | Grapheme_Base => True, others => False)), 16#3E# => -- 203E (Other_Punctuation, Ambiguous, Other, Other, Other, Alphabetic, (Pattern_Syntax | Grapheme_Base | Changes_When_NFKC_Casefolded => True, others => False)), 16#3F# => -- 203F (Connector_Punctuation, Neutral, Other, Extend_Num_Let, Other, Alphabetic, (Grapheme_Base | ID_Continue | XID_Continue => True, others => False)), 16#40# => -- 2040 (Connector_Punctuation, Neutral, Other, Extend_Num_Let, Other, Alphabetic, (Other_Math | Grapheme_Base | ID_Continue | Math | XID_Continue => True, others => False)), 16#41# .. 16#43# => -- 2041 .. 2043 (Other_Punctuation, Neutral, Other, Other, Other, Alphabetic, (Pattern_Syntax | Grapheme_Base => True, others => False)), 16#44# => -- 2044 (Math_Symbol, Neutral, Other, Mid_Num, Other, Infix_Numeric, (Pattern_Syntax | Grapheme_Base | Math => True, others => False)), 16#45# => -- 2045 (Open_Punctuation, Neutral, Other, Other, Close, Open_Punctuation, (Pattern_Syntax | Grapheme_Base => True, others => False)), 16#46# => -- 2046 (Close_Punctuation, Neutral, Other, Other, Close, Close_Punctuation, (Pattern_Syntax | Grapheme_Base => True, others => False)), 16#47# .. 16#49# => -- 2047 .. 2049 (Other_Punctuation, Neutral, Other, Other, S_Term, Nonstarter, (Pattern_Syntax | STerm | Terminal_Punctuation | Grapheme_Base | Changes_When_NFKC_Casefolded => True, others => False)), 16#4A# .. 16#51# => -- 204A .. 2051 (Other_Punctuation, Neutral, Other, Other, Other, Alphabetic, (Pattern_Syntax | Grapheme_Base => True, others => False)), 16#52# => -- 2052 (Math_Symbol, Neutral, Other, Other, Other, Alphabetic, (Pattern_Syntax | Grapheme_Base | Math => True, others => False)), 16#53# => -- 2053 (Other_Punctuation, Neutral, Other, Other, Other, Alphabetic, (Dash | Pattern_Syntax | Grapheme_Base => True, others => False)), 16#54# => -- 2054 (Connector_Punctuation, Neutral, Other, Extend_Num_Let, Other, Alphabetic, (Grapheme_Base | ID_Continue | XID_Continue => True, others => False)), 16#55# => -- 2055 (Other_Punctuation, Neutral, Other, Other, Other, Alphabetic, (Pattern_Syntax | Grapheme_Base => True, others => False)), 16#56# => -- 2056 (Other_Punctuation, Neutral, Other, Other, Other, Break_After, (Pattern_Syntax | Grapheme_Base => True, others => False)), 16#57# => -- 2057 (Other_Punctuation, Neutral, Other, Other, Other, Alphabetic, (Pattern_Syntax | Grapheme_Base | Changes_When_NFKC_Casefolded => True, others => False)), 16#58# .. 16#5B# => -- 2058 .. 205B (Other_Punctuation, Neutral, Other, Other, Other, Break_After, (Pattern_Syntax | Grapheme_Base => True, others => False)), 16#5C# => -- 205C (Other_Punctuation, Neutral, Other, Other, Other, Alphabetic, (Pattern_Syntax | Grapheme_Base => True, others => False)), 16#5D# .. 16#5E# => -- 205D .. 205E (Other_Punctuation, Neutral, Other, Other, Other, Break_After, (Pattern_Syntax | Grapheme_Base => True, others => False)), 16#5F# => -- 205F (Space_Separator, Neutral, Other, Other, Sp, Break_After, (White_Space | Grapheme_Base | Changes_When_NFKC_Casefolded => True, others => False)), 16#60# => -- 2060 (Format, Neutral, Control, Format, Format, Word_Joiner, (Case_Ignorable | Default_Ignorable_Code_Point | Changes_When_NFKC_Casefolded => True, others => False)), 16#61# .. 16#64# => -- 2061 .. 2064 (Format, Neutral, Control, Format, Format, Alphabetic, (Other_Math | Case_Ignorable | Default_Ignorable_Code_Point | Math | Changes_When_NFKC_Casefolded => True, others => False)), 16#65# => -- 2065 (Unassigned, Neutral, Control, Other, Other, Unknown, (Other_Default_Ignorable_Code_Point | Default_Ignorable_Code_Point | Changes_When_NFKC_Casefolded => True, others => False)), 16#66# .. 16#69# => -- 2066 .. 2069 (Format, Neutral, Control, Format, Format, Combining_Mark, (Bidi_Control | Case_Ignorable | Default_Ignorable_Code_Point | Changes_When_NFKC_Casefolded => True, others => False)), 16#6A# .. 16#6F# => -- 206A .. 206F (Format, Neutral, Control, Format, Format, Combining_Mark, (Deprecated | Case_Ignorable | Default_Ignorable_Code_Point | Changes_When_NFKC_Casefolded => True, others => False)), 16#70# => -- 2070 (Other_Number, Neutral, Other, Other, Other, Alphabetic, (Grapheme_Base | Changes_When_NFKC_Casefolded => True, others => False)), 16#71# => -- 2071 (Modifier_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Other_Lowercase | Soft_Dotted | Alphabetic | Cased | Case_Ignorable | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#72# .. 16#73# => -- 2072 .. 2073 (Unassigned, Neutral, Other, Other, Other, Unknown, (others => False)), 16#74# => -- 2074 (Other_Number, Ambiguous, Other, Other, Other, Ambiguous, (Grapheme_Base | Changes_When_NFKC_Casefolded => True, others => False)), 16#75# .. 16#79# => -- 2075 .. 2079 (Other_Number, Neutral, Other, Other, Other, Alphabetic, (Grapheme_Base | Changes_When_NFKC_Casefolded => True, others => False)), 16#7A# => -- 207A (Math_Symbol, Neutral, Other, Other, Other, Alphabetic, (Grapheme_Base | Math | Changes_When_NFKC_Casefolded => True, others => False)), 16#7B# => -- 207B (Math_Symbol, Neutral, Other, Other, Other, Alphabetic, (Dash | Grapheme_Base | Math | Changes_When_NFKC_Casefolded => True, others => False)), 16#7C# => -- 207C (Math_Symbol, Neutral, Other, Other, Other, Alphabetic, (Grapheme_Base | Math | Changes_When_NFKC_Casefolded => True, others => False)), 16#7D# => -- 207D (Open_Punctuation, Neutral, Other, Other, Close, Open_Punctuation, (Other_Math | Grapheme_Base | Math | Changes_When_NFKC_Casefolded => True, others => False)), 16#7E# => -- 207E (Close_Punctuation, Neutral, Other, Other, Close, Close_Punctuation, (Other_Math | Grapheme_Base | Math | Changes_When_NFKC_Casefolded => True, others => False)), 16#7F# => -- 207F (Modifier_Letter, Ambiguous, Other, A_Letter, Lower, Ambiguous, (Other_Lowercase | Alphabetic | Cased | Case_Ignorable | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#80# => -- 2080 (Other_Number, Neutral, Other, Other, Other, Alphabetic, (Grapheme_Base | Changes_When_NFKC_Casefolded => True, others => False)), 16#81# .. 16#84# => -- 2081 .. 2084 (Other_Number, Ambiguous, Other, Other, Other, Ambiguous, (Grapheme_Base | Changes_When_NFKC_Casefolded => True, others => False)), 16#85# .. 16#89# => -- 2085 .. 2089 (Other_Number, Neutral, Other, Other, Other, Alphabetic, (Grapheme_Base | Changes_When_NFKC_Casefolded => True, others => False)), 16#8A# => -- 208A (Math_Symbol, Neutral, Other, Other, Other, Alphabetic, (Grapheme_Base | Math | Changes_When_NFKC_Casefolded => True, others => False)), 16#8B# => -- 208B (Math_Symbol, Neutral, Other, Other, Other, Alphabetic, (Dash | Grapheme_Base | Math | Changes_When_NFKC_Casefolded => True, others => False)), 16#8C# => -- 208C (Math_Symbol, Neutral, Other, Other, Other, Alphabetic, (Grapheme_Base | Math | Changes_When_NFKC_Casefolded => True, others => False)), 16#8D# => -- 208D (Open_Punctuation, Neutral, Other, Other, Close, Open_Punctuation, (Other_Math | Grapheme_Base | Math | Changes_When_NFKC_Casefolded => True, others => False)), 16#8E# => -- 208E (Close_Punctuation, Neutral, Other, Other, Close, Close_Punctuation, (Other_Math | Grapheme_Base | Math | Changes_When_NFKC_Casefolded => True, others => False)), 16#8F# => -- 208F (Unassigned, Neutral, Other, Other, Other, Unknown, (others => False)), 16#90# .. 16#9C# => -- 2090 .. 209C (Modifier_Letter, Neutral, Other, A_Letter, Lower, Alphabetic, (Other_Lowercase | Alphabetic | Cased | Case_Ignorable | Grapheme_Base | ID_Continue | ID_Start | Lowercase | XID_Continue | XID_Start | Changes_When_NFKC_Casefolded => True, others => False)), 16#9D# .. 16#9F# => -- 209D .. 209F (Unassigned, Neutral, Other, Other, Other, Unknown, (others => False)), 16#A7# => -- 20A7 (Currency_Symbol, Neutral, Other, Other, Other, Postfix_Numeric, (Grapheme_Base => True, others => False)), 16#A8# => -- 20A8 (Currency_Symbol, Neutral, Other, Other, Other, Prefix_Numeric, (Grapheme_Base | Changes_When_NFKC_Casefolded => True, others => False)), 16#A9# => -- 20A9 (Currency_Symbol, Halfwidth, Other, Other, Other, Prefix_Numeric, (Grapheme_Base => True, others => False)), 16#AC# => -- 20AC (Currency_Symbol, Ambiguous, Other, Other, Other, Prefix_Numeric, (Grapheme_Base => True, others => False)), 16#B6# => -- 20B6 (Currency_Symbol, Neutral, Other, Other, Other, Postfix_Numeric, (Grapheme_Base => True, others => False)), 16#BB# => -- 20BB (Currency_Symbol, Neutral, Other, Other, Other, Postfix_Numeric, (Grapheme_Base => True, others => False)), 16#BE# .. 16#CF# => -- 20BE .. 20CF (Unassigned, Neutral, Other, Other, Other, Prefix_Numeric, (others => False)), 16#D0# .. 16#DC# => -- 20D0 .. 20DC (Nonspacing_Mark, Neutral, Extend, Extend, Extend, Combining_Mark, (Other_Math | Case_Ignorable | Grapheme_Extend | ID_Continue | Math | XID_Continue => True, others => False)), 16#DD# .. 16#E0# => -- 20DD .. 20E0 (Enclosing_Mark, Neutral, Extend, Extend, Extend, Combining_Mark, (Case_Ignorable | Grapheme_Extend => True, others => False)), 16#E1# => -- 20E1 (Nonspacing_Mark, Neutral, Extend, Extend, Extend, Combining_Mark, (Other_Math | Case_Ignorable | Grapheme_Extend | ID_Continue | Math | XID_Continue => True, others => False)), 16#E2# .. 16#E4# => -- 20E2 .. 20E4 (Enclosing_Mark, Neutral, Extend, Extend, Extend, Combining_Mark, (Case_Ignorable | Grapheme_Extend => True, others => False)), 16#E5# .. 16#E6# => -- 20E5 .. 20E6 (Nonspacing_Mark, Neutral, Extend, Extend, Extend, Combining_Mark, (Other_Math | Case_Ignorable | Grapheme_Extend | ID_Continue | Math | XID_Continue => True, others => False)), 16#E7# .. 16#EA# => -- 20E7 .. 20EA (Nonspacing_Mark, Neutral, Extend, Extend, Extend, Combining_Mark, (Case_Ignorable | Grapheme_Extend | ID_Continue | XID_Continue => True, others => False)), 16#EB# .. 16#EF# => -- 20EB .. 20EF (Nonspacing_Mark, Neutral, Extend, Extend, Extend, Combining_Mark, (Other_Math | Case_Ignorable | Grapheme_Extend | ID_Continue | Math | XID_Continue => True, others => False)), 16#F0# => -- 20F0 (Nonspacing_Mark, Neutral, Extend, Extend, Extend, Combining_Mark, (Case_Ignorable | Grapheme_Extend | ID_Continue | XID_Continue => True, others => False)), 16#F1# .. 16#FF# => -- 20F1 .. 20FF (Unassigned, Neutral, Other, Other, Other, Unknown, (others => False)), others => (Currency_Symbol, Neutral, Other, Other, Other, Prefix_Numeric, (Grapheme_Base => True, others => False))); end Matreshka.Internals.Unicode.Ucd.Core_0020;
shintakezou/drake
Ada
24,963
adb
with Ada.Exception_Identification.From_Here; with System.Storage_Elements; with System.UTF_Conversions; package body Ada.Strings.UTF_Encoding.Conversions is use Exception_Identification.From_Here; use type System.Storage_Elements.Storage_Offset; use type System.UTF_Conversions.From_Status_Type; use type System.UTF_Conversions.To_Status_Type; use type System.UTF_Conversions.UCS_4; -- binary to Wide_String, Wide_Wide_String function To_UTF_16_Wide_String (Item : System.Address; Length : Natural) return UTF_16_Wide_String; function To_UTF_16_Wide_String (Item : System.Address; Length : Natural) return UTF_16_Wide_String is pragma Assert (Length rem 2 = 0); pragma Assert (Item mod 2 = 0); -- stack may be aligned Item_All : UTF_16_Wide_String (1 .. Length / 2); for Item_All'Address use Item; begin return Item_All; end To_UTF_16_Wide_String; function To_UTF_32_Wide_Wide_String ( Item : System.Address; Length : Natural) return UTF_32_Wide_Wide_String; function To_UTF_32_Wide_Wide_String ( Item : System.Address; Length : Natural) return UTF_32_Wide_Wide_String is pragma Assert (Length rem 4 = 0); pragma Assert (Item mod 4 = 0); -- stack may be aligned Item_All : UTF_32_Wide_Wide_String (1 .. Length / 4); for Item_All'Address use Item; begin return Item_All; end To_UTF_32_Wide_Wide_String; -- binary version subprograms of System.UTF_Conversions procedure To_UTF_8 ( Code : System.UTF_Conversions.UCS_4; Result : out UTF_String; Last : out Natural; Status : out System.UTF_Conversions.To_Status_Type) renames System.UTF_Conversions.To_UTF_8; procedure From_UTF_8 ( Data : UTF_String; Last : out Natural; Result : out System.UTF_Conversions.UCS_4; Status : out System.UTF_Conversions.From_Status_Type) renames System.UTF_Conversions.From_UTF_8; procedure To_UTF_16BE ( Code : System.UTF_Conversions.UCS_4; Result : out UTF_String; Last : out Natural; Status : out System.UTF_Conversions.To_Status_Type); procedure To_UTF_16BE ( Code : System.UTF_Conversions.UCS_4; Result : out UTF_String; Last : out Natural; Status : out System.UTF_Conversions.To_Status_Type) is W_Result : Wide_String (1 .. System.UTF_Conversions.UTF_16_Max_Length); W_Last : Natural; begin System.UTF_Conversions.To_UTF_16 (Code, W_Result, W_Last, Status); Last := Result'First - 1; for I in 1 .. W_Last loop declare type U16 is mod 2 ** 16; E : constant U16 := Wide_Character'Pos (W_Result (I)); begin Last := Last + 1; Result (Last) := Character'Val (E / 256); Last := Last + 1; Result (Last) := Character'Val (E rem 256); end; end loop; end To_UTF_16BE; procedure From_UTF_16BE ( Data : UTF_String; Last : out Natural; Result : out System.UTF_Conversions.UCS_4; Status : out System.UTF_Conversions.From_Status_Type); procedure From_UTF_16BE ( Data : UTF_String; Last : out Natural; Result : out System.UTF_Conversions.UCS_4; Status : out System.UTF_Conversions.From_Status_Type) is begin if Data'Length < 2 then Last := Data'Last; Status := System.UTF_Conversions.Truncated; else declare Leading : constant Wide_Character := Wide_Character'Val ( Character'Pos (Data (Data'First)) * 256 + Character'Pos (Data (Data'First + 1))); Length : Natural; begin Last := Data'First + 1; System.UTF_Conversions.UTF_16_Sequence (Leading, Length, Status); if Status = System.UTF_Conversions.Success then if Length = 2 then if Data'Length < 4 then Last := Data'Last; Status := System.UTF_Conversions.Truncated; else declare Trailing : constant Wide_Character := Wide_Character'Val ( Character'Pos (Data (Data'First + 2)) * 256 + Character'Pos (Data (Data'First + 3))); W_Data : constant Wide_String ( 1 .. System.UTF_Conversions.UTF_16_Max_Length) := (Leading, Trailing); W_Last : Natural; begin Last := Data'First + 3; System.UTF_Conversions.From_UTF_16 ( W_Data, W_Last, Result, Status); end; end if; else pragma Assert (Length = 1); Result := Wide_Character'Pos (Leading); end if; end if; end; end if; end From_UTF_16BE; procedure To_UTF_16LE ( Code : System.UTF_Conversions.UCS_4; Result : out UTF_String; Last : out Natural; Status : out System.UTF_Conversions.To_Status_Type); procedure To_UTF_16LE ( Code : System.UTF_Conversions.UCS_4; Result : out UTF_String; Last : out Natural; Status : out System.UTF_Conversions.To_Status_Type) is W_Result : Wide_String (1 .. System.UTF_Conversions.UTF_16_Max_Length); W_Last : Natural; begin System.UTF_Conversions.To_UTF_16 (Code, W_Result, W_Last, Status); Last := Result'First - 1; for I in 1 .. W_Last loop declare type U16 is mod 2 ** 16; E : constant U16 := Wide_Character'Pos (W_Result (I)); begin Last := Last + 1; Result (Last) := Character'Val (E rem 256); Last := Last + 1; Result (Last) := Character'Val (E / 256); end; end loop; end To_UTF_16LE; procedure From_UTF_16LE ( Data : UTF_String; Last : out Natural; Result : out System.UTF_Conversions.UCS_4; Status : out System.UTF_Conversions.From_Status_Type); procedure From_UTF_16LE ( Data : UTF_String; Last : out Natural; Result : out System.UTF_Conversions.UCS_4; Status : out System.UTF_Conversions.From_Status_Type) is begin if Data'Length < 2 then Last := Data'Last; Status := System.UTF_Conversions.Truncated; else declare Leading : constant Wide_Character := Wide_Character'Val ( Character'Pos (Data (Data'First)) + Character'Pos (Data (Data'First + 1)) * 256); Length : Natural; begin Last := Data'First + 1; System.UTF_Conversions.UTF_16_Sequence (Leading, Length, Status); if Status = System.UTF_Conversions.Success then if Length = 2 then if Data'Length < 4 then Last := Data'Last; Status := System.UTF_Conversions.Truncated; else declare Trailing : constant Wide_Character := Wide_Character'Val ( Character'Pos (Data (Data'First + 2)) + Character'Pos (Data (Data'First + 3)) * 256); W_Data : constant Wide_String ( 1 .. System.UTF_Conversions.UTF_16_Max_Length) := (Leading, Trailing); W_Last : Natural; begin Last := Data'First + 3; System.UTF_Conversions.From_UTF_16 ( W_Data, W_Last, Result, Status); end; end if; else pragma Assert (Length = 1); Result := Wide_Character'Pos (Leading); end if; end if; end; end if; end From_UTF_16LE; procedure To_UTF_32BE ( Code : System.UTF_Conversions.UCS_4; Result : out UTF_String; Last : out Natural; Status : out System.UTF_Conversions.To_Status_Type); procedure To_UTF_32BE ( Code : System.UTF_Conversions.UCS_4; Result : out UTF_String; Last : out Natural; Status : out System.UTF_Conversions.To_Status_Type) is begin Last := Result'First; Result (Last) := Character'Val (Code / 16#1000000#); Last := Last + 1; Result (Last) := Character'Val (Code / 16#10000# rem 16#100#); Last := Last + 1; Result (Last) := Character'Val (Code / 16#100# rem 16#100#); Last := Last + 1; Result (Last) := Character'Val (Code rem 16#100#); Status := System.UTF_Conversions.Success; end To_UTF_32BE; procedure From_UTF_32BE ( Data : UTF_String; Last : out Natural; Result : out System.UTF_Conversions.UCS_4; Status : out System.UTF_Conversions.From_Status_Type); procedure From_UTF_32BE ( Data : UTF_String; Last : out Natural; Result : out System.UTF_Conversions.UCS_4; Status : out System.UTF_Conversions.From_Status_Type) is begin if Data'Length < 4 then Last := Data'Last; Status := System.UTF_Conversions.Truncated; else declare type U32 is mod 2 ** 32; -- Wide_Wide_Character'Size = 31(?) Leading : constant U32 := Character'Pos (Data (Data'First)) * 16#1000000# + Character'Pos (Data (Data'First + 1)) * 16#10000# + Character'Pos (Data (Data'First + 2)) * 16#100# + Character'Pos (Data (Data'First + 3)); Length : Natural; begin Last := Data'First + 3; if Leading > U32 (System.UTF_Conversions.UCS_4'Last) then Status := System.UTF_Conversions.Illegal_Sequence; else Result := System.UTF_Conversions.UCS_4 (Leading); System.UTF_Conversions.UTF_32_Sequence ( Wide_Wide_Character'Val (Leading), Length, Status); -- checking surrogate pair end if; end; end if; end From_UTF_32BE; procedure To_UTF_32LE ( Code : System.UTF_Conversions.UCS_4; Result : out UTF_String; Last : out Natural; Status : out System.UTF_Conversions.To_Status_Type); procedure To_UTF_32LE ( Code : System.UTF_Conversions.UCS_4; Result : out UTF_String; Last : out Natural; Status : out System.UTF_Conversions.To_Status_Type) is begin Last := Result'First; Result (Last) := Character'Val (Code rem 16#100#); Last := Last + 1; Result (Last) := Character'Val (Code / 16#100# rem 16#100#); Last := Last + 1; Result (Last) := Character'Val (Code / 16#10000# rem 16#100#); Last := Last + 1; Result (Last) := Character'Val (Code / 16#1000000#); Status := System.UTF_Conversions.Success; end To_UTF_32LE; procedure From_UTF_32LE ( Data : UTF_String; Last : out Natural; Result : out System.UTF_Conversions.UCS_4; Status : out System.UTF_Conversions.From_Status_Type); procedure From_UTF_32LE ( Data : UTF_String; Last : out Natural; Result : out System.UTF_Conversions.UCS_4; Status : out System.UTF_Conversions.From_Status_Type) is begin if Data'Length < 4 then Last := Data'Last; Status := System.UTF_Conversions.Truncated; else declare type U32 is mod 2 ** 32; -- Wide_Wide_Character'Size = 31(?) Leading : constant U32 := Character'Pos (Data (Data'First)) + Character'Pos (Data (Data'First + 1)) * 16#100# + Character'Pos (Data (Data'First + 2)) * 16#10000# + Character'Pos (Data (Data'First + 3)) * 16#1000000#; Length : Natural; begin Last := Data'First + 3; if Leading > U32 (System.UTF_Conversions.UCS_4'Last) then Status := System.UTF_Conversions.Illegal_Sequence; else Result := System.UTF_Conversions.UCS_4 (Leading); System.UTF_Conversions.UTF_32_Sequence ( Wide_Wide_Character'Val (Leading), Length, Status); -- checking surrogate pair end if; end; end if; end From_UTF_32LE; type To_UTF_Type is access procedure ( Code : System.UTF_Conversions.UCS_4; Result : out UTF_String; Last : out Natural; Status : out System.UTF_Conversions.To_Status_Type); pragma Favor_Top_Level (To_UTF_Type); To_UTF : constant array (Encoding_Scheme) of not null To_UTF_Type := ( UTF_8 => To_UTF_8'Access, UTF_16BE => To_UTF_16BE'Access, UTF_16LE => To_UTF_16LE'Access, UTF_32BE => To_UTF_32BE'Access, UTF_32LE => To_UTF_32LE'Access); type From_UTF_Type is access procedure ( Data : UTF_String; Last : out Natural; Result : out System.UTF_Conversions.UCS_4; Status : out System.UTF_Conversions.From_Status_Type); pragma Favor_Top_Level (From_UTF_Type); From_UTF : constant array (Encoding_Scheme) of not null From_UTF_Type := ( UTF_8 => From_UTF_8'Access, UTF_16BE => From_UTF_16BE'Access, UTF_16LE => From_UTF_16LE'Access, UTF_32BE => From_UTF_32BE'Access, UTF_32LE => From_UTF_32LE'Access); -- conversions between various encoding schemes procedure Do_Convert ( Item : UTF_String; Input_Scheme : Encoding_Scheme; Output_Scheme : Encoding_Scheme; Output_BOM : Boolean := False; Result : out UTF_String; Last : out Natural); procedure Do_Convert ( Item : UTF_String; Input_Scheme : Encoding_Scheme; Output_Scheme : Encoding_Scheme; Output_BOM : Boolean := False; Result : out UTF_String; Last : out Natural) is In_BOM : constant not null access constant UTF_String := BOM_Table (Input_Scheme); In_BOM_Length : constant Natural := In_BOM'Length; Out_BOM : constant not null access constant UTF_String := BOM_Table (Output_Scheme); Item_Last : Natural := Item'First - 1; begin declare L : constant Natural := Item_Last + In_BOM_Length; begin if L <= Item'Last and then Item (Item_Last + 1 .. L) = In_BOM.all then Item_Last := L; end if; end; Last := Result'First - 1; if Output_BOM then Last := Last + Out_BOM'Length; Result (Result'First .. Last) := Out_BOM.all; end if; while Item_Last < Item'Last loop declare Code : System.UTF_Conversions.UCS_4; From_Status : System.UTF_Conversions.From_Status_Type; To_Status : System.UTF_Conversions.To_Status_Type; begin From_UTF (Input_Scheme) ( Item (Item_Last + 1 .. Item'Last), Item_Last, Code, From_Status); case From_Status is when System.UTF_Conversions.Success | System.UTF_Conversions.Non_Shortest => -- AARM A.4.11(54.a/4), CXA4036 null; when System.UTF_Conversions.Illegal_Sequence | System.UTF_Conversions.Truncated => Raise_Exception (Encoding_Error'Identity); end case; To_UTF (Output_Scheme) ( Code, Result (Last + 1 .. Result'Last), Last, To_Status); if To_Status /= System.UTF_Conversions.Success then Raise_Exception (Encoding_Error'Identity); end if; end; end loop; end Do_Convert; -- implementation function Convert ( Item : UTF_String; Input_Scheme : Encoding_Scheme; Output_Scheme : Encoding_Scheme; Output_BOM : Boolean := False) return UTF_String is Result : UTF_String (1 .. 4 * Item'Length + 4); -- from 8 to 8 : Item'Length + 3 -- from 16 to 8 : 3 * Item'Length / 2 + 3 = 3/2 * Item'Length + 3 -- from 32 to 8 : 6 * Item'Length / 4 + 3 = 2 * Item'Length + 3 -- from 8 to 16 : (Item'Length + 1) * 2 = 2 * Item'Length + 2 -- from 16 to 16 : (Item'Length / 2 + 1) * 2 = Item'Length + 2 -- from 32 to 16 : (2 * Item'Length / 4 + 1) * 2 = Item'Length + 2 -- from 8 to 32 : (Item'Length + 1) * 4 = 4 * Item'Length + 4 (max) -- from 16 to 32 : (Item'Length / 2 + 1) * 4 = 2 * Item'Length + 4 -- from 32 to 32 : (Item'Length / 4 + 1) * 4 = Item'Length + 4 Last : Natural; begin Do_Convert ( Item, Input_Scheme, Output_Scheme, Output_BOM, Result, Last); return Result (1 .. Last); end Convert; function Convert ( Item : UTF_String; Input_Scheme : Encoding_Scheme; Output_BOM : Boolean := False) return UTF_16_Wide_String is -- from 8 to 16 : (Item'Length + 1) * 2 = 2 * Item'Length + 2 (max) -- from 16 to 16 : (Item'Length / 2 + 1) * 2 = Item'Length + 2 -- from 32 to 16 : (2 * Item'Length / 4 + 1) * 2 = Item'Length + 2 Result : UTF_String (1 .. 2 * Item'Length + 2); for Result'Alignment use 16 / Standard'Storage_Unit; Last : Natural; begin Do_Convert ( Item, Input_Scheme, UTF_16_Wide_String_Scheme, Output_BOM, Result, Last); return To_UTF_16_Wide_String (Result'Address, Last); end Convert; function Convert ( Item : UTF_String; Input_Scheme : Encoding_Scheme; Output_BOM : Boolean := False) return UTF_32_Wide_Wide_String is -- from 8 to 32 : (Item'Length + 1) * 4 = 4 * Item'Length + 4 (max) -- from 16 to 32 : (Item'Length / 2 + 1) * 4 = 2 * Item'Length + 4 -- from 32 to 32 : (Item'Length / 4 + 1) * 4 = Item'Length + 4 Result : UTF_String (1 .. 4 * Item'Length + 4); for Result'Alignment use 32 / Standard'Storage_Unit; Last : Natural; begin Do_Convert ( Item, Input_Scheme, UTF_32_Wide_Wide_String_Scheme, Output_BOM, Result, Last); return To_UTF_32_Wide_Wide_String (Result'Address, Last); end Convert; function Convert ( Item : UTF_8_String; Output_BOM : Boolean := False) return UTF_16_Wide_String is Result : UTF_String ( 1 .. (Item'Length * System.UTF_Conversions.Expanding_From_8_To_16 + 1) * 2); for Result'Alignment use 16 / Standard'Storage_Unit; Last : Natural; begin -- it should be specialized version ? Do_Convert ( Item, UTF_8, UTF_16_Wide_String_Scheme, Output_BOM, Result, Last); return To_UTF_16_Wide_String (Result'Address, Last); end Convert; function Convert ( Item : UTF_8_String; Output_BOM : Boolean := False) return UTF_32_Wide_Wide_String is Result : UTF_String ( 1 .. (Item'Length * System.UTF_Conversions.Expanding_From_8_To_32 + 1) * 4); for Result'Alignment use 32 / Standard'Storage_Unit; Last : Natural; begin -- it should be specialized version ? Do_Convert ( Item, UTF_8, UTF_32_Wide_Wide_String_Scheme, Output_BOM, Result, Last); return To_UTF_32_Wide_Wide_String (Result'Address, Last); end Convert; function Convert ( Item : UTF_16_Wide_String; Output_Scheme : Encoding_Scheme; Output_BOM : Boolean := False) return UTF_String is Item_Length : constant Natural := Item'Length; Item_As_UTF : UTF_String (1 .. Item_Length * 2); for Item_As_UTF'Address use Item'Address; -- from 16 to 8 : 3 * Item'Length + 3 -- from 16 to 16 : (Item'Length + 1) * 2 = 2 * Item'Length + 2 -- from 16 to 32 : (Item'Length + 1) * 4 = 4 * Item'Length + 4 (max) Result : UTF_String (1 .. 4 * Item_Length + 4); Last : Natural; begin Do_Convert ( Item_As_UTF, UTF_16_Wide_String_Scheme, Output_Scheme, Output_BOM, Result, Last); return Result (1 .. Last); end Convert; function Convert ( Item : UTF_16_Wide_String; Output_BOM : Boolean := False) return UTF_8_String is Item_Length : constant Natural := Item'Length; Item_As_UTF : UTF_String (1 .. Item_Length * 2); for Item_As_UTF'Address use Item'Address; Result : UTF_String ( 1 .. Item_Length * System.UTF_Conversions.Expanding_From_16_To_8 + 3); Last : Natural; begin -- it should be specialized version ? Do_Convert ( Item_As_UTF, UTF_16_Wide_String_Scheme, UTF_8, Output_BOM, Result, Last); return Result (1 .. Last); end Convert; function Convert ( Item : UTF_16_Wide_String; Output_BOM : Boolean := False) return UTF_32_Wide_Wide_String is Item_Length : constant Natural := Item'Length; Item_As_UTF : UTF_String (1 .. Item_Length * 2); for Item_As_UTF'Address use Item'Address; Result : UTF_String ( 1 .. (Item_Length * System.UTF_Conversions.Expanding_From_16_To_32 + 1) * 4); for Result'Alignment use 32 / Standard'Storage_Unit; Last : Natural; begin -- it should be specialized version ? Do_Convert ( Item_As_UTF, UTF_16_Wide_String_Scheme, UTF_32_Wide_Wide_String_Scheme, Output_BOM, Result, Last); return To_UTF_32_Wide_Wide_String (Result'Address, Last); end Convert; function Convert ( Item : UTF_32_Wide_Wide_String; Output_Scheme : Encoding_Scheme; Output_BOM : Boolean := False) return UTF_String is Item_Length : constant Natural := Item'Length; Item_As_UTF : UTF_String (1 .. Item_Length * 4); for Item_As_UTF'Address use Item'Address; -- from 32 to 8 : 6 * Item'Length + 3 (max rate) -- from 32 to 16 : (2 * Item'Length + 1) * 2 = 4 * Item'Length + 2 -- from 32 to 32 : (Item'Length + 1) * 4 = 4 * Item'Length + 4 (max BOM) Result : UTF_String (1 .. 6 * Item_Length + 4); Last : Natural; begin Do_Convert ( Item_As_UTF, UTF_32_Wide_Wide_String_Scheme, Output_Scheme, Output_BOM, Result, Last); return Result (1 .. Last); end Convert; function Convert ( Item : UTF_32_Wide_Wide_String; Output_BOM : Boolean := False) return UTF_8_String is Item_Length : constant Natural := Item'Length; Item_As_UTF : UTF_String (1 .. Item_Length * 4); for Item_As_UTF'Address use Item'Address; Result : UTF_String ( 1 .. Item_Length * System.UTF_Conversions.Expanding_From_32_To_8 + 3); Last : Natural; begin -- it should be specialized version ? Do_Convert ( Item_As_UTF, UTF_32_Wide_Wide_String_Scheme, UTF_8, Output_BOM, Result, Last); return Result (1 .. Last); end Convert; function Convert ( Item : UTF_32_Wide_Wide_String; Output_BOM : Boolean := False) return UTF_16_Wide_String is Item_Length : constant Natural := Item'Length; Item_As_UTF : UTF_String (1 .. Item_Length * 4); for Item_As_UTF'Address use Item'Address; Result : UTF_String ( 1 .. (Item_Length * System.UTF_Conversions.Expanding_From_32_To_16 + 1) * 2); for Result'Alignment use 16 / Standard'Storage_Unit; Last : Natural; begin -- it should be specialized version ? Do_Convert ( Item_As_UTF, UTF_32_Wide_Wide_String_Scheme, UTF_16_Wide_String_Scheme, Output_BOM, Result, Last); return To_UTF_16_Wide_String (Result'Address, Last); end Convert; end Ada.Strings.UTF_Encoding.Conversions;
zhmu/ananas
Ada
581
adb
-- { dg-do run } procedure Slice4 is type Varray is array (1 .. 1) of Natural; -- SImode type Rec is record Values : Varray; end record; type Sample is record Maybe : Boolean; R : Rec; end record; pragma Pack (Sample); function Match (X, Y: Sample; Length : Positive) return Boolean is begin return X.R.Values (1 .. Length) = Y.R.Values (1 .. Length); end; X, Y : Sample := (Maybe => True, R => (Values => (1 => 1))); begin X.Maybe := False; if not Match (X, Y, 1) then raise Program_Error; end if; end;
AdaCore/libadalang
Ada
449
adb
procedure Testop is type My_Int is range 1 .. 1205497; function "+" (A, B : Integer) return Boolean is (True); function "+" (A, B : Integer) return Integer is (12); function "abs" (A : Integer) return Integer is (12); A, B, C, D, E, F : Integer; O, P, Q : My_Int; Foo : Boolean; begin A := B + C; pragma Test_Statement; Foo := B < C; pragma Test_Statement; O := P + Q; pragma Test_Statement; end Testop;
reznikmm/matreshka
Ada
4,415
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This package provides abstract root type for all reflective collections. -- -- Children packages provides derived types for different types of items. ------------------------------------------------------------------------------ with League.Holders; package AMF.Internals.Collections is pragma Preelaborate; type Shared_Collection is abstract tagged limited null record; type Shared_Collection_Access is access all Shared_Collection'Class; not overriding procedure Reference (Self : not null access Shared_Collection) is abstract; not overriding procedure Unreference (Self : not null access Shared_Collection) is abstract; not overriding function Length (Self : not null access constant Shared_Collection) return Natural is abstract; not overriding function Element (Self : not null access constant Shared_Collection; Index : Positive) return League.Holders.Holder is abstract; not overriding procedure Clear (Self : not null access Shared_Collection) is abstract; end AMF.Internals.Collections;
OhYea777/Minix
Ada
13,592
ads
------------------------------------------------------------------------------ -- ZLib for Ada thick binding. -- -- -- -- Copyright (C) 2002-2004 Dmitriy Anisimkov -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under the terms of the GNU General Public License as published by -- -- the Free Software Foundation; either version 2 of the License, or (at -- -- your option) any later version. -- -- -- -- 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 -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU 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. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- ------------------------------------------------------------------------------ -- $Id: zlib.ads,v 1.1 2005/09/23 22:39:01 beng Exp $ with Ada.Streams; with Interfaces; package ZLib is ZLib_Error : exception; Status_Error : exception; type Compression_Level is new Integer range -1 .. 9; type Flush_Mode is private; type Compression_Method is private; type Window_Bits_Type is new Integer range 8 .. 15; type Memory_Level_Type is new Integer range 1 .. 9; type Unsigned_32 is new Interfaces.Unsigned_32; type Strategy_Type is private; type Header_Type is (None, Auto, Default, GZip); -- Header type usage have a some limitation for inflate. -- See comment for Inflate_Init. subtype Count is Ada.Streams.Stream_Element_Count; Default_Memory_Level : constant Memory_Level_Type := 8; Default_Window_Bits : constant Window_Bits_Type := 15; ---------------------------------- -- Compression method constants -- ---------------------------------- Deflated : constant Compression_Method; -- Only one method allowed in this ZLib version --------------------------------- -- Compression level constants -- --------------------------------- No_Compression : constant Compression_Level := 0; Best_Speed : constant Compression_Level := 1; Best_Compression : constant Compression_Level := 9; Default_Compression : constant Compression_Level := -1; -------------------------- -- Flush mode constants -- -------------------------- No_Flush : constant Flush_Mode; -- Regular way for compression, no flush Partial_Flush : constant Flush_Mode; -- Will be removed, use Z_SYNC_FLUSH instead Sync_Flush : constant Flush_Mode; -- All pending output is flushed to the output buffer and the output -- is aligned on a byte boundary, so that the decompressor can get all -- input data available so far. (In particular avail_in is zero after the -- call if enough output space has been provided before the call.) -- Flushing may degrade compression for some compression algorithms and so -- it should be used only when necessary. Block_Flush : constant Flush_Mode; -- Z_BLOCK requests that inflate() stop -- if and when it get to the next deflate block boundary. When decoding the -- zlib or gzip format, this will cause inflate() to return immediately -- after the header and before the first block. When doing a raw inflate, -- inflate() will go ahead and process the first block, and will return -- when it gets to the end of that block, or when it runs out of data. Full_Flush : constant Flush_Mode; -- All output is flushed as with SYNC_FLUSH, and the compression state -- is reset so that decompression can restart from this point if previous -- compressed data has been damaged or if random access is desired. Using -- Full_Flush too often can seriously degrade the compression. Finish : constant Flush_Mode; -- Just for tell the compressor that input data is complete. ------------------------------------ -- Compression strategy constants -- ------------------------------------ -- RLE stategy could be used only in version 1.2.0 and later. Filtered : constant Strategy_Type; Huffman_Only : constant Strategy_Type; RLE : constant Strategy_Type; Default_Strategy : constant Strategy_Type; Default_Buffer_Size : constant := 4096; type Filter_Type is tagged limited private; -- The filter is for compression and for decompression. -- The usage of the type is depend of its initialization. function Version return String; pragma Inline (Version); -- Return string representation of the ZLib version. procedure Deflate_Init (Filter : in out Filter_Type; Level : in Compression_Level := Default_Compression; Strategy : in Strategy_Type := Default_Strategy; Method : in Compression_Method := Deflated; Window_Bits : in Window_Bits_Type := Default_Window_Bits; Memory_Level : in Memory_Level_Type := Default_Memory_Level; Header : in Header_Type := Default); -- Compressor initialization. -- When Header parameter is Auto or Default, then default zlib header -- would be provided for compressed data. -- When Header is GZip, then gzip header would be set instead of -- default header. -- When Header is None, no header would be set for compressed data. procedure Inflate_Init (Filter : in out Filter_Type; Window_Bits : in Window_Bits_Type := Default_Window_Bits; Header : in Header_Type := Default); -- Decompressor initialization. -- Default header type mean that ZLib default header is expecting in the -- input compressed stream. -- Header type None mean that no header is expecting in the input stream. -- GZip header type mean that GZip header is expecting in the -- input compressed stream. -- Auto header type mean that header type (GZip or Native) would be -- detected automatically in the input stream. -- Note that header types parameter values None, GZip and Auto are -- supported for inflate routine only in ZLib versions 1.2.0.2 and later. -- Deflate_Init is supporting all header types. function Is_Open (Filter : in Filter_Type) return Boolean; pragma Inline (Is_Open); -- Is the filter opened for compression or decompression. procedure Close (Filter : in out Filter_Type; Ignore_Error : in Boolean := False); -- Closing the compression or decompressor. -- If stream is closing before the complete and Ignore_Error is False, -- The exception would be raised. generic with procedure Data_In (Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); with procedure Data_Out (Item : in Ada.Streams.Stream_Element_Array); procedure Generic_Translate (Filter : in out Filter_Type; In_Buffer_Size : in Integer := Default_Buffer_Size; Out_Buffer_Size : in Integer := Default_Buffer_Size); -- Compress/decompress data fetch from Data_In routine and pass the result -- to the Data_Out routine. User should provide Data_In and Data_Out -- for compression/decompression data flow. -- Compression or decompression depend on Filter initialization. function Total_In (Filter : in Filter_Type) return Count; pragma Inline (Total_In); -- Returns total number of input bytes read so far function Total_Out (Filter : in Filter_Type) return Count; pragma Inline (Total_Out); -- Returns total number of bytes output so far function CRC32 (CRC : in Unsigned_32; Data : in Ada.Streams.Stream_Element_Array) return Unsigned_32; pragma Inline (CRC32); -- Compute CRC32, it could be necessary for make gzip format procedure CRC32 (CRC : in out Unsigned_32; Data : in Ada.Streams.Stream_Element_Array); pragma Inline (CRC32); -- Compute CRC32, it could be necessary for make gzip format ------------------------------------------------- -- Below is more complex low level routines. -- ------------------------------------------------- procedure Translate (Filter : in out Filter_Type; In_Data : in Ada.Streams.Stream_Element_Array; In_Last : out Ada.Streams.Stream_Element_Offset; Out_Data : out Ada.Streams.Stream_Element_Array; Out_Last : out Ada.Streams.Stream_Element_Offset; Flush : in Flush_Mode); -- Compress/decompress the In_Data buffer and place the result into -- Out_Data. In_Last is the index of last element from In_Data accepted by -- the Filter. Out_Last is the last element of the received data from -- Filter. To tell the filter that incoming data are complete put the -- Flush parameter to Finish. function Stream_End (Filter : in Filter_Type) return Boolean; pragma Inline (Stream_End); -- Return the true when the stream is complete. procedure Flush (Filter : in out Filter_Type; Out_Data : out Ada.Streams.Stream_Element_Array; Out_Last : out Ada.Streams.Stream_Element_Offset; Flush : in Flush_Mode); pragma Inline (Flush); -- Flushing the data from the compressor. generic with procedure Write (Item : in Ada.Streams.Stream_Element_Array); -- User should provide this routine for accept -- compressed/decompressed data. Buffer_Size : in Ada.Streams.Stream_Element_Offset := Default_Buffer_Size; -- Buffer size for Write user routine. procedure Write (Filter : in out Filter_Type; Item : in Ada.Streams.Stream_Element_Array; Flush : in Flush_Mode := No_Flush); -- Compress/Decompress data from Item to the generic parameter procedure -- Write. Output buffer size could be set in Buffer_Size generic parameter. generic with procedure Read (Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset); -- User should provide data for compression/decompression -- thru this routine. Buffer : in out Ada.Streams.Stream_Element_Array; -- Buffer for keep remaining data from the previous -- back read. Rest_First, Rest_Last : in out Ada.Streams.Stream_Element_Offset; -- Rest_First have to be initialized to Buffer'Last + 1 -- Rest_Last have to be initialized to Buffer'Last -- before usage. Allow_Read_Some : in Boolean := False; -- Is it allowed to return Last < Item'Last before end of data. procedure Read (Filter : in out Filter_Type; Item : out Ada.Streams.Stream_Element_Array; Last : out Ada.Streams.Stream_Element_Offset; Flush : in Flush_Mode := No_Flush); -- Compress/Decompress data from generic parameter procedure Read to the -- Item. User should provide Buffer and initialized Rest_First, Rest_Last -- indicators. If Allow_Read_Some is True, Read routines could return -- Last < Item'Last only at end of stream. private use Ada.Streams; pragma Assert (Ada.Streams.Stream_Element'Size = 8); pragma Assert (Ada.Streams.Stream_Element'Modulus = 2**8); type Flush_Mode is new Integer range 0 .. 5; type Compression_Method is new Integer range 8 .. 8; type Strategy_Type is new Integer range 0 .. 3; No_Flush : constant Flush_Mode := 0; Partial_Flush : constant Flush_Mode := 1; Sync_Flush : constant Flush_Mode := 2; Full_Flush : constant Flush_Mode := 3; Finish : constant Flush_Mode := 4; Block_Flush : constant Flush_Mode := 5; Filtered : constant Strategy_Type := 1; Huffman_Only : constant Strategy_Type := 2; RLE : constant Strategy_Type := 3; Default_Strategy : constant Strategy_Type := 0; Deflated : constant Compression_Method := 8; type Z_Stream; type Z_Stream_Access is access all Z_Stream; type Filter_Type is tagged limited record Strm : Z_Stream_Access; Compression : Boolean; Stream_End : Boolean; Header : Header_Type; CRC : Unsigned_32; Offset : Stream_Element_Offset; -- Offset for gzip header/footer output. end record; end ZLib;
zhmu/ananas
Ada
2,864
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- A D A . T A S K _ I N I T I A L I Z A T I O N -- -- -- -- S p e c -- -- -- -- Copyright (C) 2020-2022, Free Software Foundation, Inc. -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- ------------------------------------------------------------------------------ -- This package provides a way to set up a global initialization handler -- when tasks start. package Ada.Task_Initialization is pragma Preelaborate; pragma No_Elaboration_Code_All; type Initialization_Handler is access procedure; procedure Set_Initialization_Handler (Handler : Initialization_Handler); -- Set the global task initialization handler to Handler. -- Note that only tasks created after this procedure is called will trigger -- a call to Handler. You can use Ada's elaboration rules and pragma -- Elaborate_All, or the pragma Linker_Constructor to ensure this -- procedure is called early. private pragma Favor_Top_Level (Initialization_Handler); end Ada.Task_Initialization;
burratoo/Acton
Ada
9,012
adb
------------------------------------------------------------------------------------------ -- -- -- ACTON SCHEDULER AGENT -- -- -- -- ACTON.SCHEDULER_AGENTS.FIFO_WITHIN_PRIORITIES -- -- -- -- Copyright (C) 2010-2021, Patrick Bernardi -- -- -- ------------------------------------------------------------------------------------------ with Oak.Message; use Oak.Message; with Oak.Oak_Time; use Oak.Oak_Time; with Oak.States; use Oak.States; with Oak.Agent.Kernel; use Oak.Agent.Kernel; with Oak.Agent.Schedulers; use Oak.Agent.Schedulers; with Oak.Core; use Oak.Core; with Oak.Storage; use Oak.Storage; with Oak.Timers; use Oak.Timers; with Oak.Core_Support_Package.Task_Support; package body Acton.Scheduler_Agents.FIFO_Within_Priorities is ----------------------- -- Local Subprograms -- ----------------------- procedure Run_Loop with No_Return; ------------------------- -- New_Scheduler_Agent -- ------------------------- procedure New_Scheduler_Agent (Agent : out Scheduler_Id; Min_Priority : in Any_Priority; Max_Priority : in Any_Priority) is begin New_Scheduler_Agent (Agent => Agent, Name => Agent_Name, Call_Stack_Size => Stack_Size, Run_Loop => Run_Loop'Address, Lowest_Priority => Min_Priority, Highest_Priority => Max_Priority); Add_Scheduler_To_Scheduler_Table (Oak_Kernel => This_Oak_Kernel, Scheduler => Agent); Activate_Timer (Timer_For_Scheduler_Agent (Agent)); end New_Scheduler_Agent; -------------- -- Run_Loop -- -------------- procedure Run_Loop is Runnable_Queue : Priority_Queue.Queue_Type; Sleep_Queue : Time_Queue.Queue_Type; -------------------------- -- Run Loop Subprograms -- -------------------------- procedure Add_Agent_To_End_Of_Runnable_Queue (Agent : in Oak_Agent_Id); procedure Add_Agent_To_Scheduler (Agent : in Oak_Agent_Id); procedure Agent_Changed (Agent : in Oak_Agent_Id); procedure Insert_Into_Sleep_Queue (Agent : in Oak_Agent_Id); procedure Move_Woken_Tasks; procedure Remove_Agent_From_Scheduler (Agent : in Oak_Agent_Id); procedure Select_Next_Task (Message : out Oak_Message); procedure Service_Agent (Message : in out Oak_Message); ---------------------------------------- -- Add_Agent_To_End_Of_Runnable_Queue -- ---------------------------------------- procedure Add_Agent_To_End_Of_Runnable_Queue (Agent : in Oak_Agent_Id) is begin Enqueue_Item (To_Queue => Runnable_Queue, Item => Agent); end Add_Agent_To_End_Of_Runnable_Queue; ---------------------------- -- Add_Agent_To_Scheduler -- ---------------------------- procedure Add_Agent_To_Scheduler (Agent : in Oak_Agent_Id) is begin if Wake_Time (Agent) <= Clock then Add_Agent_To_End_Of_Runnable_Queue (Agent); else Insert_Into_Sleep_Queue (Agent); end if; end Add_Agent_To_Scheduler; ------------------- -- Agent_Changed -- ------------------- procedure Agent_Changed (Agent : in Oak_Agent_Id) is Pulled_Agent : Oak_Agent_Id; begin -- Assumes that the task was in a runnable state before and is the -- head of its runnable queue. pragma Assert (Agent = Head_Of_Queue (Runnable_Queue)); case State (Agent) is when Sleeping => Remove_Queue_Head (From_Queue => Runnable_Queue, Item => Pulled_Agent); Add_Agent_To_Scheduler (Agent); when Activation_Pending | Activation_Complete | Activation_Successful | Update_Task_Property => null; when Runnable => Remove_Queue_Head (From_Queue => Runnable_Queue, Item => Pulled_Agent); Add_Agent_To_Scheduler (Agent); when others => raise Scheduler_Error; end case; end Agent_Changed; -------------------------------- -- Insert_Into_Sleep_Queue -- -------------------------------- procedure Insert_Into_Sleep_Queue (Agent : in Oak_Agent_Id) is begin Enqueue_Item (To_Queue => Sleep_Queue, Item => Agent); end Insert_Into_Sleep_Queue; ---------------------- -- Move_Woken_Tasks -- ---------------------- procedure Move_Woken_Tasks is Current_Time : constant Time := Clock; Agent : Oak_Agent_Id; begin loop Agent := Find_Earliest_Item (Sleep_Queue); exit when Agent = No_Agent or else Wake_Time (Agent) > Current_Time; Remove_Item (Sleep_Queue, Item => Agent); Add_Agent_To_End_Of_Runnable_Queue (Agent); end loop; end Move_Woken_Tasks; --------------------------------- -- Remove_Agent_From_Scheduler -- --------------------------------- procedure Remove_Agent_From_Scheduler (Agent : in Oak_Agent_Id) is begin -- The state of the agent determines which queue it is on. case State (Agent) is when Runnable | Entering_PO | Waiting_For_Event | Inactive | Waiting_For_Protected_Object | Allowance_Exhausted => Remove_Item (Runnable_Queue, Agent); when Sleeping => -- Not supported at this point. Support for it would need -- a double linked list or a tree to ease its removal. raise Scheduler_Error; when others => raise Scheduler_Error; end case; end Remove_Agent_From_Scheduler; ---------------------- -- Select_Next_Task -- ---------------------- procedure Select_Next_Task (Message : out Oak_Message) is Next_Agent_To_Wake : Oak_Agent_Id; Next_Agent_To_Run : Oak_Agent_Id; WT : Time; begin Move_Woken_Tasks; Next_Agent_To_Run := Head_Of_Queue (Runnable_Queue); Next_Agent_To_Wake := Find_Earliest_Item (In_Queue => Sleep_Queue, Above_Priority => Normal_Priority (Next_Agent_To_Run)); if Next_Agent_To_Wake = No_Agent then WT := Time_Last; else WT := Wake_Time (Next_Agent_To_Wake); end if; Message := (Message_Type => Scheduler_Agent_Done, Next_Agent => Next_Agent_To_Run, Wake_Priority => Normal_Priority (Next_Agent_To_Wake), Wake_Scheduler_At => WT); end Select_Next_Task; ------------------- -- Service_Agent -- ------------------- procedure Service_Agent (Message : in out Oak_Message) is begin case Message.Message_Type is when Agent_State_Change => Agent_Changed (Message.Agent_That_Changed); when Adding_Agent => Add_Agent_To_Scheduler (Message.Agent_To_Add); when Removing_Agent => Remove_Agent_From_Scheduler (Message.Agent_To_Remove); when others => null; end case; Select_Next_Task (Message); end Service_Agent; Message : Oak_Message := (Message_Type => Selecting_Next_Agent); begin loop Service_Agent (Message); Oak.Core_Support_Package.Task_Support.Context_Switch_To_Oak (Reason_For_Run => Agent_Request, Message => Message); end loop; end Run_Loop; function Priority_Greater_Than (Left, Right : in Oak_Agent_Id) return Boolean is (Normal_Priority (Left) > Normal_Priority (Right)); function Priority_Greater_Than_Equal (Left, Right : in Oak_Agent_Id) return Boolean is (Normal_Priority (Left) >= Normal_Priority (Right)); function Wake_Less_Than (Left, Right : in Oak_Agent_Id) return Boolean is (Wake_Time (Left) < Wake_Time (Right)); end Acton.Scheduler_Agents.FIFO_Within_Priorities;
Fabien-Chouteau/samd51-hal
Ada
11,233
ads
pragma Style_Checks (Off); -- This spec has been automatically generated from ATSAMD51G19A.svd pragma Restrictions (No_Elaboration_Code); with HAL; with System; package SAM_SVD.CMCC is pragma Preelaborate; --------------- -- Registers -- --------------- -- Number of Way type TYPE_WAYNUMSelect is (-- Direct Mapped Cache DMAPPED, -- 2-WAY set associative ARCH2WAY, -- 4-WAY set associative ARCH4WAY) with Size => 2; for TYPE_WAYNUMSelect use (DMAPPED => 0, ARCH2WAY => 1, ARCH4WAY => 2); -- Cache Size type TYPE_CSIZESelect is (-- Cache Size is 1 KB CSIZE_1KB, -- Cache Size is 2 KB CSIZE_2KB, -- Cache Size is 4 KB CSIZE_4KB, -- Cache Size is 8 KB CSIZE_8KB, -- Cache Size is 16 KB CSIZE_16KB, -- Cache Size is 32 KB CSIZE_32KB, -- Cache Size is 64 KB CSIZE_64KB) with Size => 3; for TYPE_CSIZESelect use (CSIZE_1KB => 0, CSIZE_2KB => 1, CSIZE_4KB => 2, CSIZE_8KB => 3, CSIZE_16KB => 4, CSIZE_32KB => 5, CSIZE_64KB => 6); -- Cache Line Size type TYPE_CLSIZESelect is (-- Cache Line Size is 4 bytes CLSIZE_4B, -- Cache Line Size is 8 bytes CLSIZE_8B, -- Cache Line Size is 16 bytes CLSIZE_16B, -- Cache Line Size is 32 bytes CLSIZE_32B, -- Cache Line Size is 64 bytes CLSIZE_64B, -- Cache Line Size is 128 bytes CLSIZE_128B) with Size => 3; for TYPE_CLSIZESelect use (CLSIZE_4B => 0, CLSIZE_8B => 1, CLSIZE_16B => 2, CLSIZE_32B => 3, CLSIZE_64B => 4, CLSIZE_128B => 5); -- Cache Type Register type CMCC_TYPE_Register is record -- unspecified Reserved_0_0 : HAL.Bit; -- Read-only. dynamic Clock Gating supported GCLK : Boolean; -- unspecified Reserved_2_3 : HAL.UInt2; -- Read-only. Round Robin Policy supported RRP : Boolean; -- Read-only. Number of Way WAYNUM : TYPE_WAYNUMSelect; -- Read-only. Lock Down supported LCKDOWN : Boolean; -- Read-only. Cache Size CSIZE : TYPE_CSIZESelect; -- Read-only. Cache Line Size CLSIZE : TYPE_CLSIZESelect; -- unspecified Reserved_14_31 : HAL.UInt18; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CMCC_TYPE_Register use record Reserved_0_0 at 0 range 0 .. 0; GCLK at 0 range 1 .. 1; Reserved_2_3 at 0 range 2 .. 3; RRP at 0 range 4 .. 4; WAYNUM at 0 range 5 .. 6; LCKDOWN at 0 range 7 .. 7; CSIZE at 0 range 8 .. 10; CLSIZE at 0 range 11 .. 13; Reserved_14_31 at 0 range 14 .. 31; end record; -- Cache size configured by software type CFG_CSIZESWSelect is (-- The Cache Size is configured to 1KB CONF_CSIZE_1KB, -- The Cache Size is configured to 2KB CONF_CSIZE_2KB, -- The Cache Size is configured to 4KB CONF_CSIZE_4KB, -- The Cache Size is configured to 8KB CONF_CSIZE_8KB, -- The Cache Size is configured to 16KB CONF_CSIZE_16KB, -- The Cache Size is configured to 32KB CONF_CSIZE_32KB, -- The Cache Size is configured to 64KB CONF_CSIZE_64KB) with Size => 3; for CFG_CSIZESWSelect use (CONF_CSIZE_1KB => 0, CONF_CSIZE_2KB => 1, CONF_CSIZE_4KB => 2, CONF_CSIZE_8KB => 3, CONF_CSIZE_16KB => 4, CONF_CSIZE_32KB => 5, CONF_CSIZE_64KB => 6); -- Cache Configuration Register type CMCC_CFG_Register is record -- unspecified Reserved_0_0 : HAL.Bit := 16#0#; -- Instruction Cache Disable ICDIS : Boolean := False; -- Data Cache Disable DCDIS : Boolean := False; -- unspecified Reserved_3_3 : HAL.Bit := 16#0#; -- Cache size configured by software CSIZESW : CFG_CSIZESWSelect := SAM_SVD.CMCC.CONF_CSIZE_4KB; -- unspecified Reserved_7_31 : HAL.UInt25 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CMCC_CFG_Register use record Reserved_0_0 at 0 range 0 .. 0; ICDIS at 0 range 1 .. 1; DCDIS at 0 range 2 .. 2; Reserved_3_3 at 0 range 3 .. 3; CSIZESW at 0 range 4 .. 6; Reserved_7_31 at 0 range 7 .. 31; end record; -- Cache Control Register type CMCC_CTRL_Register is record -- Write-only. Cache Controller Enable CEN : Boolean := False; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CMCC_CTRL_Register use record CEN at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; -- Cache Status Register type CMCC_SR_Register is record -- Read-only. Cache Controller Status CSTS : Boolean; -- unspecified Reserved_1_31 : HAL.UInt31; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CMCC_SR_Register use record CSTS at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; subtype CMCC_LCKWAY_LCKWAY_Field is HAL.UInt4; -- Cache Lock per Way Register type CMCC_LCKWAY_Register is record -- Lockdown way Register LCKWAY : CMCC_LCKWAY_LCKWAY_Field := 16#0#; -- unspecified Reserved_4_31 : HAL.UInt28 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CMCC_LCKWAY_Register use record LCKWAY at 0 range 0 .. 3; Reserved_4_31 at 0 range 4 .. 31; end record; -- Cache Maintenance Register 0 type CMCC_MAINT0_Register is record -- Write-only. Cache Controller invalidate All INVALL : Boolean := False; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CMCC_MAINT0_Register use record INVALL at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; subtype CMCC_MAINT1_INDEX_Field is HAL.UInt8; -- Invalidate Way type MAINT1_WAYSelect is (-- Way 0 is selection for index invalidation WAY0, -- Way 1 is selection for index invalidation WAY1, -- Way 2 is selection for index invalidation WAY2, -- Way 3 is selection for index invalidation WAY3) with Size => 4; for MAINT1_WAYSelect use (WAY0 => 0, WAY1 => 1, WAY2 => 2, WAY3 => 3); -- Cache Maintenance Register 1 type CMCC_MAINT1_Register is record -- unspecified Reserved_0_3 : HAL.UInt4 := 16#0#; -- Write-only. Invalidate Index INDEX : CMCC_MAINT1_INDEX_Field := 16#0#; -- unspecified Reserved_12_27 : HAL.UInt16 := 16#0#; -- Write-only. Invalidate Way WAY : MAINT1_WAYSelect := SAM_SVD.CMCC.WAY0; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CMCC_MAINT1_Register use record Reserved_0_3 at 0 range 0 .. 3; INDEX at 0 range 4 .. 11; Reserved_12_27 at 0 range 12 .. 27; WAY at 0 range 28 .. 31; end record; -- Cache Controller Monitor Counter Mode type MCFG_MODESelect is (-- Cycle counter CYCLE_COUNT, -- Instruction hit counter IHIT_COUNT, -- Data hit counter DHIT_COUNT) with Size => 2; for MCFG_MODESelect use (CYCLE_COUNT => 0, IHIT_COUNT => 1, DHIT_COUNT => 2); -- Cache Monitor Configuration Register type CMCC_MCFG_Register is record -- Cache Controller Monitor Counter Mode MODE : MCFG_MODESelect := SAM_SVD.CMCC.CYCLE_COUNT; -- unspecified Reserved_2_31 : HAL.UInt30 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CMCC_MCFG_Register use record MODE at 0 range 0 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; -- Cache Monitor Enable Register type CMCC_MEN_Register is record -- Cache Controller Monitor Enable MENABLE : Boolean := False; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CMCC_MEN_Register use record MENABLE at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; -- Cache Monitor Control Register type CMCC_MCTRL_Register is record -- Write-only. Cache Controller Software Reset SWRST : Boolean := False; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CMCC_MCTRL_Register use record SWRST at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Cortex M Cache Controller type CMCC_Peripheral is record -- Cache Type Register TYPE_k : aliased CMCC_TYPE_Register; -- Cache Configuration Register CFG : aliased CMCC_CFG_Register; -- Cache Control Register CTRL : aliased CMCC_CTRL_Register; -- Cache Status Register SR : aliased CMCC_SR_Register; -- Cache Lock per Way Register LCKWAY : aliased CMCC_LCKWAY_Register; -- Cache Maintenance Register 0 MAINT0 : aliased CMCC_MAINT0_Register; -- Cache Maintenance Register 1 MAINT1 : aliased CMCC_MAINT1_Register; -- Cache Monitor Configuration Register MCFG : aliased CMCC_MCFG_Register; -- Cache Monitor Enable Register MEN : aliased CMCC_MEN_Register; -- Cache Monitor Control Register MCTRL : aliased CMCC_MCTRL_Register; -- Cache Monitor Status Register MSR : aliased HAL.UInt32; end record with Volatile; for CMCC_Peripheral use record TYPE_k at 16#0# range 0 .. 31; CFG at 16#4# range 0 .. 31; CTRL at 16#8# range 0 .. 31; SR at 16#C# range 0 .. 31; LCKWAY at 16#10# range 0 .. 31; MAINT0 at 16#20# range 0 .. 31; MAINT1 at 16#24# range 0 .. 31; MCFG at 16#28# range 0 .. 31; MEN at 16#2C# range 0 .. 31; MCTRL at 16#30# range 0 .. 31; MSR at 16#34# range 0 .. 31; end record; -- Cortex M Cache Controller CMCC_Periph : aliased CMCC_Peripheral with Import, Address => CMCC_Base; end SAM_SVD.CMCC;
MinimSecure/unum-sdk
Ada
771
ads
-- Copyright 2013-2016 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. package Pck is procedure Put(S : String); end Pck;
charlie5/cBound
Ada
1,326
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with xcb.xcb_render_spanfix_t; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_render_trap_t is -- Item -- type Item is record top : aliased xcb.xcb_render_spanfix_t.Item; bot : aliased xcb.xcb_render_spanfix_t.Item; end record; -- Item_Array -- type Item_Array is array (Interfaces.C.size_t range <>) of aliased xcb.xcb_render_trap_t.Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_render_trap_t.Item, Element_Array => xcb.xcb_render_trap_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_trap_t.Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_render_trap_t.Pointer, Element_Array => xcb.xcb_render_trap_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_render_trap_t;
etorri/protobuf-ada
Ada
3,033
adb
pragma Ada_2012; package body Protocol_Buffers.Generated_Message_Utilities is ------------------------ -- Positive_Infinity -- ------------------------ function Positive_Infinity return Protocol_Buffers.Wire_Format.PB_Float is Inf : Protocol_Buffers.Wire_Format.PB_Float := Protocol_Buffers.Wire_Format.PB_Float'Last; begin if not Protocol_Buffers.Wire_Format.PB_Float'Machine_Overflows then Inf := Protocol_Buffers.Wire_Format.PB_Float'Succ (Inf); end if; return Inf; end Positive_Infinity; ----------------------- -- Negative_Infinity -- ----------------------- function Negative_Infinity return Protocol_Buffers.Wire_Format.PB_Float is Neg_Inf : Protocol_Buffers.Wire_Format.PB_Float := Protocol_Buffers.Wire_Format.PB_Float'First; begin if not Protocol_Buffers.Wire_Format.PB_Float'Machine_Overflows then Neg_Inf := Protocol_Buffers.Wire_Format.PB_Float'Pred (Neg_Inf); end if; return Neg_Inf; end Negative_Infinity; --------- -- NaN -- --------- function NaN return Protocol_Buffers.Wire_Format.PB_Float is use type Protocol_Buffers.Wire_Format.PB_Float; Zero : Protocol_Buffers.Wire_Format.PB_Float := 0.0; A_NaN : Protocol_Buffers.Wire_Format.PB_Float := 0.0; begin if not Protocol_Buffers.Wire_Format.PB_Float'Machine_Overflows then A_NaN := 0.0 / Zero; end if; return A_NaN; end NaN; ------------------------ -- Positive_Infinity -- ------------------------ function Positive_Infinity return Protocol_Buffers.Wire_Format.PB_Double is Inf : Protocol_Buffers.Wire_Format.PB_Double := Protocol_Buffers.Wire_Format.PB_Double'Last; begin if not Protocol_Buffers.Wire_Format.PB_Double'Machine_Overflows then Inf := Protocol_Buffers.Wire_Format.PB_Double'Succ (Inf); end if; return Inf; end Positive_Infinity; ----------------------- -- Negative_Infinity -- ----------------------- function Negative_Infinity return Protocol_Buffers.Wire_Format.PB_Double is Neg_Inf : Protocol_Buffers.Wire_Format.PB_Double := Protocol_Buffers.Wire_Format.PB_Double'First; begin if not Protocol_Buffers.Wire_Format.PB_Double'Machine_Overflows then Neg_Inf := Protocol_Buffers.Wire_Format.PB_Double'Pred (Neg_Inf); end if; return Neg_Inf; end Negative_Infinity; --------- -- NaN -- --------- function NaN return Protocol_Buffers.Wire_Format.PB_Double is use type Protocol_Buffers.Wire_Format.PB_Double; Zero : Protocol_Buffers.Wire_Format.PB_Double := 0.0; A_NaN : Protocol_Buffers.Wire_Format.PB_Double := 0.0; begin if not Protocol_Buffers.Wire_Format.PB_Double'Machine_Overflows then A_NaN := 0.0 / Zero; end if; return A_NaN; end NaN; end Protocol_Buffers.Generated_Message_Utilities;
albertklee/SPARKZumo
Ada
7,994
ads
-- pragma SPARK_Mode; with Types; use Types; with Interfaces.C; use Interfaces.C; -- @summary -- Interface for the LSM303 accelerometer and magnetometer -- -- @description -- This is the interface to the 3D accelerometer and 3D magnetometer -- package Zumo_LSM303 is -- Gain to be applied to magnetometer M_Sensitivity : constant Float := 0.000080; -- gauss/LSB -- Gain to be applied to accelerometer A_Sensitivity : constant Float := 0.000061; -- g/LSB -- True if package is init'd Initd : Boolean := False; -- Inits the package. procedure Init with Global => (In_Out => Initd), Pre => not Initd, Post => Initd; -- Read the temperature from the sensor -- @return a 16 bit temperature value function Read_Temp return short with Pre => Initd; -- Read the status of the magnetometer -- @return the status of the magnetometer function Read_M_Status return Byte with Pre => Initd; -- Read the status of the accelerometer -- @return the status of the accelerometer function Read_A_Status return Byte with Pre => Initd; -- Read the magnetic reading from the sensor -- @param Data the data read from the sensor procedure Read_Mag (Data : out Axis_Data) with Pre => Initd; -- Read the acceleration from the sensor -- @param Data the acceleration reading from the sensor procedure Read_Acc (Data : out Axis_Data) with Pre => Initd; LSM303_Exception : exception; private -- Read the WHOAMI register in the sensor and check against known value procedure Check_WHOAMI; -- The mapping of registers in the sensor -- @value TEMP_OUT_L The low register of the sensors temperature -- @value TEMP_OUT_H the high register of the sensors temperature -- @value STATUS_M the status of the magnetometer -- @value OUT_X_L_M the low register of the x axis of the magnetometer -- @value OUT_X_H_M the high register of the x axis of the magnetometer -- @value OUT_Y_L_M the low register of the Y axis of the magnetometer -- @value OUT_Y_H_M the high register of the Y axis of the magnetometer -- @value OUT_Z_L_M the low register of the Z axis of the magnetometer -- @value OUT_Z_H_M the high register of the Z axis of the magnetometer -- @value WHO_AM_I the who am i register -- @value STATUS_A the status of the accelerometer -- @value OUT_X_L_A the low register of the x axis of the accelerometer -- @value OUT_X_H_A the high register of the x axis of the accelerometer -- @value OUT_Y_L_A the low register of the Y axis of the accelerometer -- @value OUT_Y_H_A the high register of the Y axis of the accelerometer -- @value OUT_Z_L_A the low register of the Z axis of the accelerometer -- @value OUT_Z_H_A the high register of the Z axis of the accelerometer type Reg_Index is (TEMP_OUT_L, TEMP_OUT_H, STATUS_M, OUT_X_L_M, OUT_X_H_M, OUT_Y_L_M, OUT_Y_H_M, OUT_Z_L_M, OUT_Z_H_M, WHO_AM_I, INT_CTRL_M, INT_SRC_M, INT_THS_L_M, INT_THS_H_M, OFFSET_X_L_M, OFFSET_X_H_M, OFFSET_Y_L_M, OFFSET_Y_H_M, OFFSET_Z_L_M, OFFSET_Z_H_M, REFERENCE_X, REFERENCE_Y, REFERENCE_Z, CTRL0, CTRL1, CTRL2, CTRL3, CTRL4, CTRL5, CTRL6, CTRL7, STATUS_A, OUT_X_L_A, OUT_X_H_A, OUT_Y_L_A, OUT_Y_H_A, OUT_Z_L_A, OUT_Z_H_A, FIFO_CTRL, FIFO_SRC, IG_CFG1, IG_SRC1, IG_THS1, IG_DUR1, IG_CFG2, IG_SRC2, IG_THS2, IG_DUR2, CLICK_CFG, CLICK_SRC, CLICK_THS, TIME_LIMIT, TIME_LATENCY, TIME_WINDOW, ACT_THS, ACT_DUR); -- The mapping of the enum to the actual register addresses Regs : constant array (Reg_Index) of Byte := (TEMP_OUT_L => 16#05#, TEMP_OUT_H => 16#06#, STATUS_M => 16#07#, OUT_X_L_M => 16#08#, OUT_X_H_M => 16#09#, OUT_Y_L_M => 16#0A#, OUT_Y_H_M => 16#0B#, OUT_Z_L_M => 16#0C#, OUT_Z_H_M => 16#0D#, WHO_AM_I => 16#0F#, INT_CTRL_M => 16#12#, INT_SRC_M => 16#13#, INT_THS_L_M => 16#14#, INT_THS_H_M => 16#15#, OFFSET_X_L_M => 16#16#, OFFSET_X_H_M => 16#17#, OFFSET_Y_L_M => 16#18#, OFFSET_Y_H_M => 16#19#, OFFSET_Z_L_M => 16#1A#, OFFSET_Z_H_M => 16#1B#, REFERENCE_X => 16#1C#, REFERENCE_Y => 16#1D#, REFERENCE_Z => 16#1E#, CTRL0 => 16#1F#, CTRL1 => 16#20#, CTRL2 => 16#21#, CTRL3 => 16#22#, CTRL4 => 16#23#, CTRL5 => 16#24#, CTRL6 => 16#25#, CTRL7 => 16#26#, STATUS_A => 16#27#, OUT_X_L_A => 16#28#, OUT_X_H_A => 16#29#, OUT_Y_L_A => 16#2A#, OUT_Y_H_A => 16#2B#, OUT_Z_L_A => 16#2C#, OUT_Z_H_A => 16#2D#, FIFO_CTRL => 16#2E#, FIFO_SRC => 16#2F#, IG_CFG1 => 16#30#, IG_SRC1 => 16#31#, IG_THS1 => 16#32#, IG_DUR1 => 16#33#, IG_CFG2 => 16#34#, IG_SRC2 => 16#35#, IG_THS2 => 16#36#, IG_DUR2 => 16#37#, CLICK_CFG => 16#38#, CLICK_SRC => 16#39#, CLICK_THS => 16#3A#, TIME_LIMIT => 16#3B#, TIME_LATENCY => 16#3C#, TIME_WINDOW => 16#3D#, ACT_THS => 16#3E#, ACT_DUR => 16#3F#); end Zumo_LSM303;
apple-oss-distributions/old_ncurses
Ada
3,043
adb
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- tour -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 1998 Free Software Foundation, Inc. -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, distribute with modifications, sublicense, and/or sell -- -- copies of the Software, and to permit persons to whom the Software is -- -- furnished to do so, subject to the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -- -- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -- -- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR -- -- THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- -- -- -- Except as contained in this notice, the name(s) of the above copyright -- -- holders shall not be used in advertising or otherwise to promote the -- -- sale, use or other dealings in this Software without prior written -- -- authorization. -- ------------------------------------------------------------------------------ -- Author: Juergen Pfeifer <[email protected]> 1996 -- Version Control -- $Revision: 1.1.1.1 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ with Sample; use Sample; procedure Tour is begin Whow; end Tour;
zhmu/ananas
Ada
212
ads
with Ada.Finalization; generic type T is private; package Controlled6_Pkg is type Node_Type is record Item : T; end record; type Node_Access_Type is access Node_Type; end Controlled6_Pkg;
godunko/adawebui
Ada
4,689
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2017-2020, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision: 5716 $ $Date: 2017-01-24 16:35:18 +0300 (Tue, 24 Jan 2017) $ ------------------------------------------------------------------------------ generic package Web.Core.Connectables.Slots_0.Slots_1.Generic_Emitters is pragma Preelaborate; type Emitter (Owner : not null access Connectable_Object'Class) is limited new Slots_1.Signal with private; procedure Emit (Self : in out Emitter'Class; Parameter_1 : Parameter_1_Type); private type Signal_End is abstract new Signal_End_Base with null record; not overriding procedure Invoke (Self : in out Signal_End; Parameter_1 : Parameter_1_Type) is abstract; type Signal_End_0 is new Signal_End with null record; overriding procedure Invoke (Self : in out Signal_End_0; Parameter_1 : Parameter_1_Type); type Signal_End_1 is new Signal_End with null record; overriding procedure Invoke (Self : in out Signal_End_1; Parameter_1 : Parameter_1_Type); ------------- -- Emitter -- ------------- type Emitter (Owner : not null access Connectable_Object'Class) is limited new Emitter_Base and Slots_1.Signal with null record; overriding procedure Connect (Self : in out Emitter; Slot : Slots_0.Slot'Class); overriding procedure Connect (Self : in out Emitter; Slot : Slots_1.Slot'Class); end Web.Core.Connectables.Slots_0.Slots_1.Generic_Emitters;
stcarrez/ada-awa
Ada
4,820
adb
----------------------------------------------------------------------- -- awa-users-model -- User management module -- Copyright (C) 2009, 2010, 2011, 2012, 2015, 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 AWA.Modules.Beans; with AWA.Modules.Get; with AWA.Applications; with AWA.Users.Beans; with Util.Log.Loggers; package body AWA.Users.Modules is Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Users.Module"); package Register is new AWA.Modules.Beans (Module => User_Module, Module_Access => User_Module_Access); -- ------------------------------ -- Initialize the user module. -- ------------------------------ overriding procedure Initialize (Plugin : in out User_Module; App : in AWA.Modules.Application_Access; Props : in ASF.Applications.Config) is begin Log.Info ("Initializing the users module"); -- Setup the resource bundles. App.Register ("userMsg", "users"); -- Register the OpenID servlets. App.Add_Servlet (Name => "openid-auth", Server => Plugin.Auth'Unchecked_Access); App.Add_Servlet (Name => "openid-verify", Server => Plugin.Verify_Auth'Unchecked_Access); App.Add_Servlet (Name => "verify-access-key", Server => Plugin.Verify_Key'Unchecked_Access); -- Setup the verify access key filter. App.Add_Filter ("auth-filter", Plugin.Auth_Filter'Unchecked_Access); Register.Register (Plugin => Plugin, Name => "AWA.Users.Beans.Authenticate_Bean", Handler => AWA.Users.Beans.Create_Authenticate_Bean'Access); Register.Register (Plugin => Plugin, Name => "AWA.Users.Beans.Current_User_Bean", Handler => AWA.Users.Beans.Create_Current_User_Bean'Access); AWA.Modules.Module (Plugin).Initialize (App, Props); end Initialize; -- ------------------------------ -- Configures the module after its initialization and after having read its XML configuration. -- ------------------------------ overriding procedure Configure (Plugin : in out User_Module; Props : in ASF.Applications.Config) is pragma Unreferenced (Props); begin -- Create the user manager when everything is initialized. Plugin.Manager := Plugin.Create_User_Manager; end Configure; -- ------------------------------ -- Get the user manager. -- ------------------------------ function Get_User_Manager (Plugin : in User_Module) return Services.User_Service_Access is begin return Plugin.Manager; end Get_User_Manager; -- ------------------------------ -- Create a user manager. This operation can be overridden to provide another -- user service implementation. -- ------------------------------ function Create_User_Manager (Plugin : in User_Module) return Services.User_Service_Access is Result : constant Services.User_Service_Access := new Services.User_Service; begin Result.Initialize (Plugin); return Result; end Create_User_Manager; -- ------------------------------ -- Get the user module instance associated with the current application. -- ------------------------------ function Get_User_Module return User_Module_Access is function Get is new AWA.Modules.Get (User_Module, User_Module_Access, NAME); begin return Get; end Get_User_Module; -- ------------------------------ -- Get the user manager instance associated with the current application. -- ------------------------------ function Get_User_Manager return Services.User_Service_Access is Module : constant User_Module_Access := Get_User_Module; begin if Module = null then Log.Error ("There is no active User_Module"); return null; else return Module.Get_User_Manager; end if; end Get_User_Manager; end AWA.Users.Modules;
dkm/atomic
Ada
1,183
adb
with System.Machine_Code; use System.Machine_Code; package body Atomic.Critical_Section is ----------- -- Enter -- ----------- procedure Enter (State : out Interrupt_State) is NL : constant String := ASCII.CR & ASCII.LF; begin System.Machine_Code.Asm (Template => "dsb" & NL & -- Ensure completion of memory accesses "mrs %0, PRIMASK" & NL & -- Save PRIMASK State "cpsid i", -- Clear PRIMASK Outputs => Interrupt_State'Asm_Output ("=r", State), Inputs => No_Input_Operands, Clobber => "", Volatile => True); end Enter; ----------- -- Leave -- ----------- procedure Leave (State : Interrupt_State) is NL : constant String := ASCII.CR & ASCII.LF; begin System.Machine_Code.Asm (Template => "dsb" & NL & -- Ensure completion of memory accesses "msr PRIMASK, %0", -- restore PRIMASK Outputs => No_Output_Operands, Inputs => Interrupt_State'Asm_Input ("r", State), Clobber => "", Volatile => True); end Leave; end Atomic.Critical_Section;
AdaCore/gpr
Ada
5,555
ads
-- -- Copyright (C) 2014-2022, AdaCore -- SPDX-License-Identifier: Apache-2.0 -- with Ada.Containers; use Ada.Containers; with System; with Gpr_Parser_Support.Hashes; use Gpr_Parser_Support.Hashes; with Gpr_Parser_Support.Lexical_Envs; use Gpr_Parser_Support.Lexical_Envs; with Gpr_Parser_Support.Token_Data_Handlers; use Gpr_Parser_Support.Token_Data_Handlers; with Gpr_Parser_Support.Types; use Gpr_Parser_Support.Types; -- This package provides common implementation details for Langkit-generated -- libraries. Even though it is not private (to allow Langkit-generated -- libraries to use it), it is not meant to be used beyond this. As such, this -- API is considered unsafe and unstable. package Gpr_Parser_Support.Internal.Analysis is -- Bare pointers to library-specific resources. For contexts, units and -- nodes, these correspond to the access types defined in $.Implementation. type Internal_Context is new System.Address; type Internal_Unit is new System.Address; type Internal_Node is new System.Address; No_Internal_Context : constant Internal_Context := Internal_Context (System.Null_Address); No_Internal_Unit : constant Internal_Unit := Internal_Unit (System.Null_Address); No_Internal_Node : constant Internal_Node := Internal_Node (System.Null_Address); type Internal_Node_Metadata is new System.Address; -- The contents and size of the node metadata record is different from one -- Langkit-generated library to another, so this generic API needs to refer -- to it by reference, with ref-counting for lifetime handling. Null -- addresses mean "default metadata", and the language descriptor table -- provides ref-counting primitives. -- As everywhere else, entities are made up of bare nodes and entity -- information, with regular types from Gpr_Parser_Support.Lexical_Envs. The -- metadata has a special representation: see above (Internal_Node_Metadata -- type). type Internal_Entity is record Node : Internal_Node; Rebindings : Env_Rebindings; From_Rebound : Boolean; Metadata : Internal_Node_Metadata; end record; function "=" (L, R : Internal_Entity) return Boolean is abstract; -- We hide the equal operator on internal entities, because since null -- metadata can be either null or a pointer to language specific null -- metadata, we generally don't want our implementation to compare the -- whole Internal_Entity, but rather individual fields. No_Internal_Entity : constant Internal_Entity := (No_Internal_Node, null, False, Internal_Node_Metadata (System.Null_Address)); type Internal_Entity_Array is array (Positive range <>) of Internal_Entity; type Internal_Token is record TDH : Token_Data_Handler_Access; Index : Token_Or_Trivia_Index; end record; -- Safety nets keep track of information at "public reference value" -- creation so that later use can check whether the reference is still -- valid (used to ensure memory safety). type Node_Safety_Net is record Context : Internal_Context; Context_Version : Version_Number; -- Analysis context and version number at the time this safety net was -- produced. Unit : Internal_Unit; Unit_Version : Version_Number; -- Analysis unit and unit version at the time this safety net was -- produced. Rebindings_Version : Version_Number; -- Version of the associated rebinding at the time this safety net was -- produced. end record; No_Node_Safety_Net : constant Node_Safety_Net := (No_Internal_Context, 0, No_Internal_Unit, 0, 0); function Create_Node_Safety_Net (Id : Language_Id; Context : Internal_Context; Unit : Internal_Unit; Rebindings : Env_Rebindings) return Node_Safety_Net; -- Return the safety net for a node given its owning context and unit, and -- its rebindings. type Token_Safety_Net is record Context : Internal_Context; Context_Version : Version_Number; -- Analysis context and version number at the time this safety net was -- produced. TDH_Version : Version_Number; -- Version of the token data handler at the time this safety net was -- produced. end record; No_Token_Safety_Net : constant Token_Safety_Net := (No_Internal_Context, 0, 0); -- Contexts, units and token data handlers are implementing with big -- records, at least 256 bytes long, so we can ignore the 8 least -- significant bits of their addresses. Nodes can be much smaller, but -- they are still at least 32 bytes long, so ignore the 5 least significant -- bits of their addresses. function Hash_Context is new Hash_Address (8); function Hash_Unit is new Hash_Address (8); function Hash_Node is new Hash_Address (5); function Hash_TDH is new Hash_Address (8); function Hash (Self : Internal_Context) return Hash_Type is (Hash_Context (System.Address (Self))); function Hash (Self : Internal_Unit) return Hash_Type is (Hash_Unit (System.Address (Self))); function Hash (Self : Internal_Node) return Hash_Type is (Hash_Node (System.Address (Self))); function Hash (Self : Token_Data_Handler_Access) return Hash_Type is (Hash_TDH (if Self = null then System.Null_Address else Self.all'Address)); end Gpr_Parser_Support.Internal.Analysis;
reznikmm/matreshka
Ada
4,105
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Text_Caption_Sequence_Format_Attributes; package Matreshka.ODF_Text.Caption_Sequence_Format_Attributes is type Text_Caption_Sequence_Format_Attribute_Node is new Matreshka.ODF_Text.Abstract_Text_Attribute_Node and ODF.DOM.Text_Caption_Sequence_Format_Attributes.ODF_Text_Caption_Sequence_Format_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Text_Caption_Sequence_Format_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Text_Caption_Sequence_Format_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Text.Caption_Sequence_Format_Attributes;
optikos/oasis
Ada
3,396
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Lexical_Elements; with Program.Elements.Expressions; with Program.Elements.Modular_Types; with Program.Element_Visitors; package Program.Nodes.Modular_Types is pragma Preelaborate; type Modular_Type is new Program.Nodes.Node and Program.Elements.Modular_Types.Modular_Type and Program.Elements.Modular_Types.Modular_Type_Text with private; function Create (Mod_Token : not null Program.Lexical_Elements.Lexical_Element_Access; Modulus : not null Program.Elements.Expressions.Expression_Access) return Modular_Type; type Implicit_Modular_Type is new Program.Nodes.Node and Program.Elements.Modular_Types.Modular_Type with private; function Create (Modulus : not null Program.Elements.Expressions .Expression_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False) return Implicit_Modular_Type with Pre => Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance; private type Base_Modular_Type is abstract new Program.Nodes.Node and Program.Elements.Modular_Types.Modular_Type with record Modulus : not null Program.Elements.Expressions.Expression_Access; end record; procedure Initialize (Self : aliased in out Base_Modular_Type'Class); overriding procedure Visit (Self : not null access Base_Modular_Type; Visitor : in out Program.Element_Visitors.Element_Visitor'Class); overriding function Modulus (Self : Base_Modular_Type) return not null Program.Elements.Expressions.Expression_Access; overriding function Is_Modular_Type_Element (Self : Base_Modular_Type) return Boolean; overriding function Is_Type_Definition_Element (Self : Base_Modular_Type) return Boolean; overriding function Is_Definition_Element (Self : Base_Modular_Type) return Boolean; type Modular_Type is new Base_Modular_Type and Program.Elements.Modular_Types.Modular_Type_Text with record Mod_Token : not null Program.Lexical_Elements.Lexical_Element_Access; end record; overriding function To_Modular_Type_Text (Self : aliased in out Modular_Type) return Program.Elements.Modular_Types.Modular_Type_Text_Access; overriding function Mod_Token (Self : Modular_Type) return not null Program.Lexical_Elements.Lexical_Element_Access; type Implicit_Modular_Type is new Base_Modular_Type with record Is_Part_Of_Implicit : Boolean; Is_Part_Of_Inherited : Boolean; Is_Part_Of_Instance : Boolean; end record; overriding function To_Modular_Type_Text (Self : aliased in out Implicit_Modular_Type) return Program.Elements.Modular_Types.Modular_Type_Text_Access; overriding function Is_Part_Of_Implicit (Self : Implicit_Modular_Type) return Boolean; overriding function Is_Part_Of_Inherited (Self : Implicit_Modular_Type) return Boolean; overriding function Is_Part_Of_Instance (Self : Implicit_Modular_Type) return Boolean; end Program.Nodes.Modular_Types;
Tim-Tom/project-euler
Ada
3,993
adb
with Ada.Text_IO; with Ada.Containers.Ordered_Maps; with PrimeUtilities; package body Problem_51 is package IO renames Ada.Text_IO; type Number_Range is new Integer range 0 .. 999_999_999; type Converted_Range is new Integer range 0 .. Integer(Number_Range'Last + 1)*11/10; type Magnitude is new Positive range 1 .. 9; type Family_Count is Record base_example : Number_Range; count : Positive; end Record; package Family_Map is new Ada.Containers.Ordered_Maps(Key_Type => Converted_Range, Element_Type => Family_Count); package Range_Primes is new PrimeUtilities(Num => Number_Range); procedure Solve is gen : Range_Primes.Prime_Generator := Range_Primes.Make_Generator; families : Family_Map.Map; prime : Number_Range; prime_magnitude : Magnitude := 1; function Get_Magnitude(num : Number_Range) return Magnitude is begin if num >= 100_000_000 then return 9; elsif num >= 10_000_000 then return 8; elsif num >= 1_000_000 then return 7; elsif num >= 100_000 then return 6; elsif num >= 10_000 then return 5; elsif num >= 1_000 then return 4; elsif num >= 100 then return 3; elsif num >= 10 then return 2; else return 1; end if; end; pragma Pure_Function(Get_Magnitude); Function Generate_Families(prime : Number_Range) return Number_Range is Function Gen_Families_Rec(number : Number_Range; so_far : Converted_Range; Keep : Number_Range) return Number_Range is found : Number_Range := 0; begin if number /= 0 then declare quotient : constant Number_Range := number / 10; remainder : constant Number_Range := number mod 10; begin found := Gen_Families_Rec(quotient, (so_far*11) + Converted_Range(remainder), keep); if found /= 0 then return found; elsif keep = 11 or keep = remainder then found := Gen_Families_Rec(quotient, so_far*11 + 10, remainder); if found /= 0 then return found; end if; end if; end; elsif keep /= 11 then declare use Family_Map; location : constant Family_Map.Cursor := families.Find(so_far); element : Family_Count; begin if location = Family_Map.No_Element then element.base_example := prime; element.count := 1; families.Insert(so_far, element); else element := Family_Map.Element(location); element.count := element.count + 1; families.Replace_Element(location, element); if element.count = 8 then return element.base_example; end if; end if; end; end if; return 0; end Gen_Families_Rec; begin return Gen_Families_Rec(prime, 0, 11); end Generate_Families; begin loop Range_Primes.Next_Prime(gen, prime); exit when prime = 1; if prime_magnitude /= Get_Magnitude(prime) then prime_magnitude := Get_Magnitude(prime); families.Clear; end if; declare found : constant Number_Range := Generate_Families(prime); begin if found /= 0 then IO.Put_Line(Number_Range'Image(found)); exit; end if; end; end loop; end Solve; end Problem_51;
rogermc2/GA_Ada
Ada
6,874
adb
with Interfaces; with Ada.Text_IO; use Ada.Text_IO; with GL.Attributes; with GL.Framebuffer; with GL.Objects.Buffers; with GL.Objects.Programs; with GL.Objects.Shaders; with GL.Pixels; with GL.Types.Colors; with GL.Uniforms; with Program_Loader; with Utilities; package body Pick_Manager is type GL_Pick is record Picking_Program : GL.Objects.Programs.Program; Picking_Colour_ID : GL.Uniforms.Uniform; Picking_Matrix_ID : GL.Uniforms.Uniform; Pick_Active : Boolean := False; -- set to true during picking -- set to picking window (x, y, w, h) during picking OpenGL_Pick : GL.Types.Int_Array (1 .. 4) := (0, 0, 0, 0); -- Must be set correctly by caller of pick() to get correct distances returned Frustum_Near : GL.Types.Single := 1.0; -- Must be set correctly by caller of pick() to get correct distances returned Frustum_Far : GL.Types.Single := 100.0; -- not required for pick(), provided for completenes FrustumWidth : GL.Types.Single := 0.0; -- not required for pick(), provided for completenes Frustum_Height : GL.Types.Single := 0.0; Pick_Window_Size : GL.Types.Int := 4; end record; type Pixels_Array is array (Positive range <>) of aliased GL.Types.UByte; Max_Items : constant GL.Types.Int := 100; White : constant GL.Types.Colors.Color := (1.0, 1.0, 1.0, 1.0); Vertex_Buffer : GL.Objects.Buffers.Buffer; Element_Buffer : GL.Objects.Buffers.Buffer; Pick_Data : GL_Pick; -- ------------------------------------------------------------------------ procedure Init_Pick_Manager is use GL.Objects.Shaders; begin Pick_Data.Picking_Program := Program_Loader.Program_From ((Program_Loader.Src ("src/shaders/picking_vertex_shader.glsl", Vertex_Shader), Program_Loader.Src ("src/shaders/picking_fragment_shader.glsl", Fragment_Shader))); Pick_Data.Picking_Colour_ID := GL.Objects.Programs.Uniform_Location (Pick_Data.Picking_Program, "Picking_Colour"); Pick_Data.Picking_Matrix_ID := GL.Objects.Programs.Uniform_Location (Pick_Data.Picking_Program, "MVP"); exception when others => Put_Line ("An exception occurred in Init_Pick_Manager."); raise; end Init_Pick_Manager; -- ------------------------------------------------------------------------ procedure Read_Pix is new GL.Framebuffer.Read_Pixels (Element_Type => GL.Types.UByte, Index_Type => Positive, Array_Type => Pixels_Array); -- ------------------------------------------------------------------------ procedure Pick (Window : in out Glfw.Windows.Window; Positions : GL.Types.Singles.Vector3_Array; Orientations : Orientation_Array; Indices_Size : GL.Types.Int; View_Matrix, Projection_Matrix : GL.Types.Singles.Matrix4) is use Interfaces; use GL.Types; use GL.Types.Singles; Model_Matrix : Matrix4; Rot_Matrix : Matrix4; Trans_Matrix : Matrix4; MVP_Matrix : Singles.Matrix4; R : Single; G : Single; B : Single; Window_Width : Glfw.Size; Window_Height : Glfw.Size; Pixel_Data : Pixels_Array (1 .. 4); Picked_ID : Int; -- Message : Ada.Strings.Unbounded.Unbounded_String; begin Utilities.Clear_Background_Colour_And_Depth (White); GL.Objects.Programs.Use_Program (Pick_Data.Picking_Program); -- Only the positions are needed (not the UVs and normals) GL.Attributes.Enable_Vertex_Attrib_Array (0); for count in GL.Types.Int range 1 .. Max_Items loop Rot_Matrix := Maths.Rotation_Matrix (Orientations (count).Angle, Orientations (count).Axis); Trans_Matrix := Maths.Translation_Matrix (Positions (count)); Model_Matrix := Trans_Matrix * Rot_Matrix; MVP_Matrix := Projection_Matrix * View_Matrix * Model_Matrix; GL.Uniforms.Set_Single (Pick_Data.Picking_Matrix_ID, MVP_Matrix); -- Convert count, the integer mesh ID, into an RGB color R := Single (Unsigned_32 (count) and 16#FF#) / 255.0; G := Single (Shift_Right (Unsigned_32 (count) and 16#FF00#, 8)) / 255.0; B := Single (Shift_Right (Unsigned_32 (count) and 16#FF0000#, 16)) / 255.0; GL.Uniforms.Set_Single (Pick_Data.Picking_Colour_ID, R, G, B, 1.0); GL.Objects.Buffers.Array_Buffer.Bind (Vertex_Buffer); GL.Attributes.Set_Vertex_Attrib_Pointer (0, 3, Single_Type, True, 0, 0); GL.Objects.Buffers.Element_Array_Buffer.Bind (Element_Buffer); GL.Objects.Buffers.Draw_Elements (Mode => Triangles, Count => Indices_Size, Index_Type => UInt_Type); end loop; GL.Attributes.Disable_Vertex_Attrib_Array (0); GL.Flush; GL.Pixels.Set_Pack_Alignment (GL.Pixels.Unpack_Alignment); Window'Access.Get_Size (Window_Width, Window_Height); -- Read the pixel at the center of the screen Read_Pix (Int (Window_Width) / 2, Int (Window_Height) / 2, 1, 1, GL.Pixels.RGBA, GL.Pixels.Float, Pixel_Data); Put_Line ("Pick R" & UByte'Image (Pixel_Data (1)) & UByte'Image (Pixel_Data (2)) & UByte'Image (Pixel_Data (3))); -- Convert the color back to an integer ID Picked_ID := Int (Pixel_Data (1)) + 256 * Int (Pixel_Data (2)) + 256 * 256 * Int (Pixel_Data (3)); if Picked_ID = 16#00FFFFFF# then -- Full white, must be the background! Put_Line ("Background " & Int'Image (Picked_ID)); -- Message := Ada.Strings.Unbounded.To_Unbounded_String ("background"); else Put_Line ("Mesh " & Int'Image (Picked_ID)); -- Message := Ada.Strings.Unbounded.To_Unbounded_String (""); end if; exception when others => Put_Line ("An exception occurred in Pick."); raise; end Pick; -- ------------------------------------------------------------------------ function Pick_Active return Boolean is begin return Pick_Data.Pick_Active; end Pick_Active; -- ------------------------------------------------------------------------ end Pick_Manager;
charlie5/lace
Ada
1,750
ads
with gel.Keyboard, lace.Event, lace.Subject; package gel.Mouse with remote_Types -- -- Provides an interface to a mouse. -- is type Item is limited interface and lace.Subject.item; type View is access all Item'class; ---------- --- Events -- type Button_Id is range 1 .. 5; type Site is new math.Integers (1 .. 2); -- Window pixel (x,y) site. type button_press_Event is new lace.Event.item with record Button : button_Id; modifier_Set : keyboard.modifier_Set; Site : mouse.Site; end record; type button_release_Event is new lace.Event.item with record Button : button_Id; modifier_Set : keyboard.modifier_Set; Site : mouse.Site; end record; type motion_Event is new lace.Event.item with record Site : mouse.Site; end record; -------------- --- Attributes -- -- Nil. -------------- --- Operations -- procedure emit_button_press_Event (Self : in out Item'Class; Button : in mouse.button_Id; Modifiers : in keyboard.modifier_Set; Site : in mouse.Site); procedure emit_button_release_Event (Self : in out Item'Class; Button : in mouse.button_Id; Modifiers : in keyboard.modifier_Set; Site : in mouse.Site); procedure emit_motion_Event (Self : in out Item'Class; Site : in mouse.Site); end gel.Mouse;
onox/orka
Ada
4,441
adb
-- 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 Ada.Unchecked_Conversion; with AUnit.Assertions; with AUnit.Test_Caller; with AUnit.Test_Fixtures; with Orka.SIMD.SSE2.Integers; with Orka.SIMD.SSE4_1.Integers.Logical; package body Test_SIMD_SSE4_1_Logical is use Orka; use Orka.SIMD.SSE2.Integers; use Orka.SIMD.SSE4_1.Integers.Logical; use AUnit.Assertions; type Test is new AUnit.Test_Fixtures.Test_Fixture with null record; function Convert is new Ada.Unchecked_Conversion (Unsigned_32, Integer_32); type Is_True_Array is array (Index_4D) of Boolean; function To_Mask (Mask : Is_True_Array) return m128i is (Convert (if Mask (X) then Unsigned_32'Last else 0), Convert (if Mask (Y) then Unsigned_32'Last else 0), Convert (if Mask (Z) then Unsigned_32'Last else 0), Convert (if Mask (W) then Unsigned_32'Last else 0)); procedure Test_Test_All_Zero (Object : in out Test) is Values : constant m128i := (Convert (Unsigned_32'First), Convert (Unsigned_32'Last), Convert (0), Convert (0)); Mask_1 : constant m128i := To_Mask ((True, False, True, False)); Mask_2 : constant m128i := To_Mask ((True, True, True, True)); Result_1 : constant Boolean := Test_All_Zero (Values, Mask_1); Result_2 : constant Boolean := Test_All_Zero (Values, Mask_2); begin Assert (Result_1, "Vector not all zero"); Assert (not Result_2, "Vector all zero"); end Test_Test_All_Zero; procedure Test_Test_All_Ones (Object : in out Test) is Values : constant m128i := (Convert (Unsigned_32'Last), Convert (0), Convert (Unsigned_32'Last), Convert (Unsigned_32'Last / 2)); Mask_1 : constant m128i := To_Mask ((True, False, True, False)); Mask_2 : constant m128i := To_Mask ((True, True, True, True)); Result_1 : constant Boolean := Test_All_Ones (Values, Mask_1); Result_2 : constant Boolean := Test_All_Ones (Values, Mask_2); begin Assert (Result_1, "Vector not all ones"); Assert (not Result_2, "Vector all ones"); end Test_Test_All_Ones; procedure Test_Test_Min_Ones_Zeros (Object : in out Test) is Values : constant m128i := (Convert (Unsigned_32'Last), Convert (0), Convert (Unsigned_32'Last / 2), Convert (Unsigned_32'Last / 2)); Mask_1 : constant m128i := To_Mask ((False, False, True, False)); Mask_2 : constant m128i := To_Mask ((True, True, False, True)); Mask_3 : constant m128i := To_Mask ((False, True, False, False)); Result_1 : constant Boolean := Test_Mix_Ones_Zeros (Values, Mask_1); Result_2 : constant Boolean := Test_Mix_Ones_Zeros (Values, Mask_2); Result_3 : constant Boolean := Test_Mix_Ones_Zeros (Values, Mask_3); begin Assert (Result_1, "Vector not mix of ones and zeros"); Assert (Result_2, "Vector not mix of ones and zeros"); Assert (not Result_3, "Vector mix of ones and zeros"); end Test_Test_Min_Ones_Zeros; ---------------------------------------------------------------------------- package Caller is new AUnit.Test_Caller (Test); Test_Suite : aliased AUnit.Test_Suites.Test_Suite; function Suite return AUnit.Test_Suites.Access_Test_Suite is Name : constant String := "(SIMD - SSE4.1 - Integers - Logical) "; begin Test_Suite.Add_Test (Caller.Create (Name & "Test Test_All_Zero function", Test_Test_All_Zero'Access)); Test_Suite.Add_Test (Caller.Create (Name & "Test Test_All_Ones function", Test_Test_All_Ones'Access)); Test_Suite.Add_Test (Caller.Create (Name & "Test Test_Mix_Ones_Zeros function", Test_Test_Min_Ones_Zeros'Access)); return Test_Suite'Access; end Suite; end Test_SIMD_SSE4_1_Logical;
stcarrez/ada-ado
Ada
20,977
adb
----------------------------------------------------------------------- -- ado-statements-tests -- Test statements package -- Copyright (C) 2015, 2017, 2018, 2019, 2021 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Test_Caller; with Util.Strings.Transforms; with ADO.Utils; with ADO.Sessions; with Regtests.Statements.Model; package body ADO.Statements.Tests is procedure Populate (Tst : in out Test); function Get_Sum (T : in Test; Table : in String) return Natural; function Get_Sum (T : in Test; Table : in String; Ids : in ADO.Utils.Identifier_Vector) return Natural; -- Test the query statement Get_Xxx operation for various types. generic type T (<>) is private; with function Get_Value (Stmt : in ADO.Statements.Query_Statement; Column : in Natural) return T is <>; Name : String; Column : String; procedure Test_Query_Get_Value_T (Tst : in out Test); -- Test the query statement Get_Xxx operation called on a null column. generic type T (<>) is private; with function Get_Value (Stmt : in ADO.Statements.Query_Statement; Column : in Natural) return T is <>; Name : String; Column : String; procedure Test_Query_Get_Value_On_Null_T (Tst : in out Test); procedure Populate (Tst : in out Test) is DB : ADO.Sessions.Master_Session := Regtests.Get_Master_Database; begin DB.Begin_Transaction; for I in 1 .. 10 loop declare Item : Regtests.Statements.Model.Table_Ref; begin Item.Set_Id_Value (ADO.Identifier (I * I)); Item.Set_Int_Value (I); Item.Set_Bool_Value ((I mod 2) = 0); Item.Set_String_Value ("Item" & Integer'Image (I)); Item.Set_Time_Value (Ada.Calendar.Clock); Item.Set_Entity_Value (ADO.Entity_Type (10 - I)); Item.Save (DB); Tst.Assert (Item.Is_Inserted, "Item inserted in database"); end; declare Item : Regtests.Statements.Model.Nullable_Table_Ref; begin Item.Set_Id_Value (ADO.Identifier (I * I)); Item.Set_Int_Value (ADO.Null_Integer); Item.Set_Bool_Value (ADO.Null_Boolean); Item.Set_String_Value (ADO.Null_String); Item.Set_Time_Value (ADO.Null_Time); Item.Set_Entity_Value (ADO.Null_Entity_Type); Item.Save (DB); Tst.Assert (Item.Is_Inserted, "Item inserted in database"); end; end loop; DB.Commit; end Populate; -- ------------------------------ -- Test the query statement Get_Xxx operation for various types. -- ------------------------------ procedure Test_Query_Get_Value_T (Tst : in out Test) is Stmt : ADO.Statements.Query_Statement; DB : constant ADO.Sessions.Session := Regtests.Get_Database; begin Populate (Tst); -- Check that Get_Value raises an exception if the statement is invalid. begin declare V : T := Get_Value (Stmt, 0); pragma Unreferenced (V); begin Util.Tests.Fail (Tst, "No Invalid_Statement exception raised for " & Name); end; exception when Invalid_Statement => null; end; -- Execute a query to fetch one column. Stmt := DB.Create_Statement ("SELECT " & Column & " FROM test_table WHERE id = 1"); Stmt.Execute; -- Verify the query result and the Get_Value operation. Tst.Assert (Stmt.Has_Elements, "The query statement must return a value for " & Name & ":" & Column); Tst.Assert (not Stmt.Is_Null (0), "The query statement must return a non null value for " & Name & ":" & Column); Util.Tests.Assert_Equals (Tst, Column, Util.Strings.Transforms.To_Lower_Case (Stmt.Get_Column_Name (0)), "The query returns an invalid column name"); declare V : T := Get_Value (Stmt, 0); pragma Unreferenced (V); begin Stmt.Clear; end; end Test_Query_Get_Value_T; -- ------------------------------ -- Test the query statement Get_Xxx operation for various types. -- ------------------------------ procedure Test_Query_Get_Value_On_Null_T (Tst : in out Test) is Stmt : ADO.Statements.Query_Statement; DB : constant ADO.Sessions.Session := Regtests.Get_Database; begin Populate (Tst); -- Execute a query to fetch one column as NULL and one row. Stmt := DB.Create_Statement ("SELECT " & Column & ", id FROM test_nullable_table " & "WHERE " & Column & " IS NULL"); Stmt.Execute; -- Verify the query result and the Get_Value operation. Tst.Assert (Stmt.Has_Elements, "The query statement must return a value " & Name); Tst.Assert (Stmt.Is_Null (0), "The query statement must return null value for " & Name & ":" & Column); Tst.Assert (not Stmt.Is_Null (1), "The query statement must return non null value for " & Name & " and the id"); Util.Tests.Assert_Equals (Tst, Column, Util.Strings.Transforms.To_Lower_Case (Stmt.Get_Column_Name (0)), "The query returns an invalid column name"); declare V : T := Get_Value (Stmt, 0); pragma Unreferenced (V); begin Tst.Fail ("No Invalid_Type exception is raised for " & Name); Stmt.Clear; end; exception when ADO.Statements.Invalid_Type => null; end Test_Query_Get_Value_On_Null_T; procedure Test_Query_Get_Int64 is new Test_Query_Get_Value_T (Int64, ADO.Statements.Get_Int64, "Get_Int64", "id_value"); procedure Test_Query_Get_Int64_On_Null is new Test_Query_Get_Value_On_Null_T (Int64, ADO.Statements.Get_Int64, "Get_Int64", "int_value"); procedure Test_Query_Get_Integer is new Test_Query_Get_Value_T (Integer, ADO.Statements.Get_Integer, "Get_Integer", "int_value"); procedure Test_Query_Get_Nullable_Integer is new Test_Query_Get_Value_T (Nullable_Integer, ADO.Statements.Get_Nullable_Integer, "Get_Nullable_Integer", "int_value"); procedure Test_Query_Get_Nullable_Boolean is new Test_Query_Get_Value_T (Nullable_Boolean, ADO.Statements.Get_Nullable_Boolean, "Get_Nullable_Boolean", "bool_value"); procedure Test_Query_Get_Nullable_Entity_Type is new Test_Query_Get_Value_T (Nullable_Entity_Type, ADO.Statements.Get_Nullable_Entity_Type, "Get_Nullable_Entity_Type", "entity_value"); procedure Test_Query_Get_Natural is new Test_Query_Get_Value_T (Natural, ADO.Statements.Get_Natural, "Get_Natural", "int_value"); procedure Test_Query_Get_Identifier is new Test_Query_Get_Value_T (ADO.Identifier, ADO.Statements.Get_Identifier, "Get_Identifier", "id_value"); procedure Test_Query_Get_Boolean is new Test_Query_Get_Value_T (Boolean, ADO.Statements.Get_Boolean, "Get_Boolean", "bool_value"); procedure Test_Query_Get_String is new Test_Query_Get_Value_T (String, ADO.Statements.Get_String, "Get_String", "string_value"); procedure Test_Query_Get_Time is new Test_Query_Get_Value_T (Ada.Calendar.Time, ADO.Statements.Get_Time, "Get_Time", "time_value"); procedure Test_Query_Get_String_On_Null is new Test_Query_Get_Value_On_Null_T (Int64, ADO.Statements.Get_Int64, "Get_String", "string_value"); package Caller is new Util.Test_Caller (Test, "ADO.Statements"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test ADO.Statements.Save", Test_Save'Access); Caller.Add_Test (Suite, "Test ADO.Statements.Get_Int64", Test_Query_Get_Int64'Access); Caller.Add_Test (Suite, "Test ADO.Statements.Get_Int64 (NULL)", Test_Query_Get_Int64_On_Null'Access); Caller.Add_Test (Suite, "Test ADO.Statements.Get_Integer", Test_Query_Get_Integer'Access); Caller.Add_Test (Suite, "Test ADO.Statements.Get_Nullable_Integer", Test_Query_Get_Nullable_Integer'Access); Caller.Add_Test (Suite, "Test ADO.Statements.Get_Nullable_Boolean", Test_Query_Get_Nullable_Boolean'Access); Caller.Add_Test (Suite, "Test ADO.Statements.Get_Natural", Test_Query_Get_Natural'Access); Caller.Add_Test (Suite, "Test ADO.Statements.Get_Identifier", Test_Query_Get_Identifier'Access); Caller.Add_Test (Suite, "Test ADO.Statements.Get_Boolean", Test_Query_Get_Boolean'Access); Caller.Add_Test (Suite, "Test ADO.Statements.Get_String", Test_Query_Get_String'Access); Caller.Add_Test (Suite, "Test ADO.Statements.Get_String (NULL)", Test_Query_Get_String_On_Null'Access); Caller.Add_Test (Suite, "Test ADO.Statements.Get_Time", Test_Query_Get_Time'Access); Caller.Add_Test (Suite, "Test ADO.Statements.Get_Nullable_Entity_Type", Test_Query_Get_Nullable_Entity_Type'Access); Caller.Add_Test (Suite, "Test ADO.Statements.Create_Statement (using $entity_type[])", Test_Entity_Types'Access); Caller.Add_Test (Suite, "Test ADO.Statements.Get_Integer (raise Invalid_Column)", Test_Invalid_Column'Access); Caller.Add_Test (Suite, "Test ADO.Statements.Get_Integer (raise Invalid_Type)", Test_Invalid_Type'Access); Caller.Add_Test (Suite, "Test ADO.Statements.Query (raise Invalid_Statement)", Test_Invalid_Statement'Access); end Add_Tests; function Get_Sum (T : in Test; Table : in String) return Natural is DB : constant ADO.Sessions.Session := Regtests.Get_Database; Stmt : ADO.Statements.Query_Statement := DB.Create_Statement ("SELECT SUM(id_value) FROM " & Table); begin Stmt.Execute; T.Assert (Stmt.Has_Elements, "The query statement must return a value for table " & Table); if Stmt.Is_Null (0) then return 0; else return Stmt.Get_Integer (0); end if; end Get_Sum; function Get_Sum (T : in Test; Table : in String; Ids : in ADO.Utils.Identifier_Vector) return Natural is DB : constant ADO.Sessions.Session := Regtests.Get_Database; Stmt : ADO.Statements.Query_Statement := DB.Create_Statement ("SELECT SUM(id_value) FROM " & Table & " WHERE id IN (:ids)"); begin Stmt.Bind_Param ("ids", Ids); Stmt.Execute; T.Assert (Stmt.Has_Elements, "The query statement must return a value for table " & Table); if Stmt.Is_Null (0) then return 0; else return Stmt.Get_Integer (0); end if; end Get_Sum; -- ------------------------------ -- Test creation of several rows in test_table with different column type. -- ------------------------------ procedure Test_Save (T : in out Test) is First : constant Natural := Get_Sum (T, "test_table"); DB : ADO.Sessions.Master_Session := Regtests.Get_Master_Database; List : ADO.Utils.Identifier_Vector; begin DB.Begin_Transaction; for I in 1 .. 10 loop declare Item : Regtests.Statements.Model.Table_Ref; begin Item.Set_Id_Value (ADO.Identifier (I * I)); Item.Set_Int_Value (I); Item.Set_Bool_Value ((I mod 2) = 0); Item.Set_String_Value ("Item" & Integer'Image (I)); Item.Set_Time_Value (Ada.Calendar.Clock); Item.Set_Entity_Value (ADO.Entity_Type (10 - I)); Item.Save (DB); List.Append (Item.Get_Id); end; end loop; DB.Commit; Util.Tests.Assert_Equals (T, First + 385, Get_Sum (T, "test_table"), "The SUM query returns an invalid value for test_table"); Util.Tests.Assert_Equals (T, 385, Get_Sum (T, "test_table", List), "The SUM query returns an invalid value for test_table"); end Test_Save; -- ------------------------------ -- Test queries using the $entity_type[] cache group. -- ------------------------------ procedure Test_Entity_Types (T : in out Test) is DB : constant ADO.Sessions.Master_Session := Regtests.Get_Master_Database; Stmt : ADO.Statements.Query_Statement; Count : Natural := 0; begin Stmt := DB.Create_Statement ("SELECT name FROM ado_entity_type " & "WHERE ado_entity_type.id = $entity_type[test_user]"); Stmt.Execute; while Stmt.Has_Elements loop Util.Tests.Assert_Equals (T, "test_user", Stmt.Get_String (0), "Invalid query response"); Count := Count + 1; Stmt.Next; end loop; Util.Tests.Assert_Equals (T, 1, Count, "Query must return one row"); end Test_Entity_Types; -- ------------------------------ -- Test executing a SQL query and getting an invalid column. -- ------------------------------ procedure Test_Invalid_Column (T : in out Test) is use type ADO.Schemas.Column_Type; DB : constant ADO.Sessions.Session := Regtests.Get_Database; Stmt : ADO.Statements.Query_Statement; Count : Natural := 0; Name : Ada.Strings.Unbounded.Unbounded_String; Value : Integer := 123456789; begin begin T.Assert (Stmt.Get_Column_Name (1) = "", "Value returned"); T.Fail ("No exception raised"); exception when Invalid_Statement => null; end; begin T.Assert (Stmt.Get_Column_Count = 0, "Value returned"); T.Fail ("No exception raised"); exception when Invalid_Statement => null; end; begin T.Assert (Stmt.Get_Column_Type (1) = ADO.Schemas.T_DOUBLE, "Value returned"); T.Fail ("No exception raised"); exception when Invalid_Statement => null; end; Stmt := DB.Create_Statement ("SELECT name FROM ado_entity_type"); Stmt.Execute; while Stmt.Has_Elements loop Name := Stmt.Get_Unbounded_String (0); T.Assert (Ada.Strings.Unbounded.Length (Name) > 0, "Invalid entity_type name"); begin Value := Stmt.Get_Integer (1); Util.Tests.Fail (T, "No exception raised for Stmt.Get_Integer"); exception when ADO.Statements.Invalid_Column => null; end; begin Name := Stmt.Get_Unbounded_String (1); Util.Tests.Fail (T, "No exception raised for Stmt.Get_Unbounded_String"); exception when ADO.Statements.Invalid_Column => null; end; begin T.Assert (Stmt.Get_Boolean (1), "Get_Boolean"); Util.Tests.Fail (T, "No exception raised for Stmt.Get_Unbounded_String"); exception when ADO.Statements.Invalid_Column => null; end; begin Util.Tests.Assert_Equals (T, "?", Stmt.Get_Column_Name (1), "Get_Column_Name should raise an exception"); Util.Tests.Fail (T, "No exception raised for Stmt.Get_Column_Name"); exception when ADO.Statements.Invalid_Column => null; end; begin T.Assert (ADO.Schemas.T_NULL = Stmt.Get_Column_Type (1), "Get_Column_Type should raise an exception"); Util.Tests.Fail (T, "No exception raised for Stmt.Get_Column_Name"); exception when ADO.Statements.Invalid_Column => null; end; Util.Tests.Assert_Equals (T, 123456789, Value, "Value was corrupted"); Count := Count + 1; Stmt.Next; end loop; T.Assert (Count > 0, "Query must return at least on entity_type"); end Test_Invalid_Column; -- ------------------------------ -- Test executing a SQL query and getting an invalid value. -- ------------------------------ procedure Test_Invalid_Type (T : in out Test) is DB : constant ADO.Sessions.Session := Regtests.Get_Database; Stmt : ADO.Statements.Query_Statement; Count : Natural := 0; Name : Ada.Strings.Unbounded.Unbounded_String; Value : Integer := 123456789; Time : Ada.Calendar.Time with Unreferenced; begin Stmt := DB.Create_Statement ("SELECT name, id FROM ado_entity_type"); Stmt.Execute; while Stmt.Has_Elements loop Name := Stmt.Get_Unbounded_String (0); T.Assert (Ada.Strings.Unbounded.Length (Name) > 0, "Invalid entity_type name"); begin Value := Stmt.Get_Integer (0); Util.Tests.Fail (T, "No exception raised for Stmt.Get_Integer on a String"); exception when ADO.Statements.Invalid_Type => null; end; begin Time := Stmt.Get_Time (1); Util.Tests.Fail (T, "No exception raised for Stmt.Get_Time on an Integer"); exception when ADO.Statements.Invalid_Type => null; end; begin T.Assert (Stmt.Get_Boolean (0), "Get_Boolean"); Util.Tests.Fail (T, "No exception raised for Stmt.Get_Boolean on a String"); exception when ADO.Statements.Invalid_Type => null; end; Util.Tests.Assert_Equals (T, 123456789, Value, "Value was corrupted"); Count := Count + 1; Stmt.Next; end loop; T.Assert (Count > 0, "Query must return at least on entity_type"); end Test_Invalid_Type; -- ------------------------------ -- Test executing a SQL query with an invalid SQL. -- ------------------------------ procedure Test_Invalid_Statement (T : in out Test) is DB : ADO.Sessions.Master_Session := Regtests.Get_Master_Database; begin declare Stmt : ADO.Statements.Query_Statement := DB.Create_Statement ("SELECT name FROM "); begin Stmt.Execute; Util.Tests.Fail (T, "No SQL_Error exception was raised"); exception when ADO.Statements.SQL_Error => null; end; declare Stmt : ADO.Statements.Query_Statement := DB.Create_Statement ("INSERT name FROM "); begin Stmt.Execute; Util.Tests.Fail (T, "No SQL_Error exception was raised"); exception when ADO.Statements.SQL_Error => null; end; declare Stmt : ADO.Statements.Query_Statement := DB.Create_Statement ("DELETE name FROM "); begin Stmt.Execute; Util.Tests.Fail (T, "No SQL_Error exception was raised"); exception when ADO.Statements.SQL_Error => null; end; declare DB2 : constant ADO.Sessions.Master_Session := DB; Stmt : ADO.Statements.Query_Statement; begin DB.Close; Stmt := DB2.Create_Statement ("SELECT name FROM test_table"); Stmt.Execute; Util.Tests.Fail (T, "No SQL_Error exception was raised"); exception when ADO.Sessions.Session_Error => null; end; end Test_Invalid_Statement; end ADO.Statements.Tests;
reznikmm/matreshka
Ada
11,113
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with AMF.Internals.UML_Named_Elements; with AMF.UML.Connection_Point_References; with AMF.UML.Dependencies.Collections; with AMF.UML.Named_Elements; with AMF.UML.Namespaces; with AMF.UML.Packages.Collections; with AMF.UML.Pseudostates.Collections; with AMF.UML.Regions; with AMF.UML.State_Machines; with AMF.UML.States; with AMF.UML.String_Expressions; with AMF.UML.Transitions.Collections; with AMF.Visitors; package AMF.Internals.UML_Connection_Point_References is type UML_Connection_Point_Reference_Proxy is limited new AMF.Internals.UML_Named_Elements.UML_Named_Element_Proxy and AMF.UML.Connection_Point_References.UML_Connection_Point_Reference with null record; overriding function Get_Entry (Self : not null access constant UML_Connection_Point_Reference_Proxy) return AMF.UML.Pseudostates.Collections.Set_Of_UML_Pseudostate; -- Getter of ConnectionPointReference::entry. -- -- The entryPoint kind pseudo states corresponding to this connection -- point. overriding function Get_Exit (Self : not null access constant UML_Connection_Point_Reference_Proxy) return AMF.UML.Pseudostates.Collections.Set_Of_UML_Pseudostate; -- Getter of ConnectionPointReference::exit. -- -- The exitPoints kind pseudo states corresponding to this connection -- point. overriding function Get_State (Self : not null access constant UML_Connection_Point_Reference_Proxy) return AMF.UML.States.UML_State_Access; -- Getter of ConnectionPointReference::state. -- -- The State in which the connection point refreshens are defined. overriding procedure Set_State (Self : not null access UML_Connection_Point_Reference_Proxy; To : AMF.UML.States.UML_State_Access); -- Setter of ConnectionPointReference::state. -- -- The State in which the connection point refreshens are defined. overriding function Get_Container (Self : not null access constant UML_Connection_Point_Reference_Proxy) return AMF.UML.Regions.UML_Region_Access; -- Getter of Vertex::container. -- -- The region that contains this vertex. overriding procedure Set_Container (Self : not null access UML_Connection_Point_Reference_Proxy; To : AMF.UML.Regions.UML_Region_Access); -- Setter of Vertex::container. -- -- The region that contains this vertex. overriding function Get_Incoming (Self : not null access constant UML_Connection_Point_Reference_Proxy) return AMF.UML.Transitions.Collections.Set_Of_UML_Transition; -- Getter of Vertex::incoming. -- -- Specifies the transitions entering this vertex. overriding function Get_Outgoing (Self : not null access constant UML_Connection_Point_Reference_Proxy) return AMF.UML.Transitions.Collections.Set_Of_UML_Transition; -- Getter of Vertex::outgoing. -- -- Specifies the transitions departing from this vertex. overriding function Get_Client_Dependency (Self : not null access constant UML_Connection_Point_Reference_Proxy) return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency; -- Getter of NamedElement::clientDependency. -- -- Indicates the dependencies that reference the client. overriding function Get_Name_Expression (Self : not null access constant UML_Connection_Point_Reference_Proxy) return AMF.UML.String_Expressions.UML_String_Expression_Access; -- Getter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding procedure Set_Name_Expression (Self : not null access UML_Connection_Point_Reference_Proxy; To : AMF.UML.String_Expressions.UML_String_Expression_Access); -- Setter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding function Get_Namespace (Self : not null access constant UML_Connection_Point_Reference_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Getter of NamedElement::namespace. -- -- Specifies the namespace that owns the NamedElement. overriding function Get_Qualified_Name (Self : not null access constant UML_Connection_Point_Reference_Proxy) return AMF.Optional_String; -- Getter of NamedElement::qualifiedName. -- -- A name which allows the NamedElement to be identified within a -- hierarchy of nested Namespaces. It is constructed from the names of the -- containing namespaces starting at the root of the hierarchy and ending -- with the name of the NamedElement itself. overriding function Containing_State_Machine (Self : not null access constant UML_Connection_Point_Reference_Proxy) return AMF.UML.State_Machines.UML_State_Machine_Access; -- Operation Vertex::containingStateMachine. -- -- The operation containingStateMachine() returns the state machine in -- which this Vertex is defined overriding function Incoming (Self : not null access constant UML_Connection_Point_Reference_Proxy) return AMF.UML.Transitions.Collections.Set_Of_UML_Transition; -- Operation Vertex::incoming. -- -- Missing derivation for Vertex::/incoming : Transition overriding function Outgoing (Self : not null access constant UML_Connection_Point_Reference_Proxy) return AMF.UML.Transitions.Collections.Set_Of_UML_Transition; -- Operation Vertex::outgoing. -- -- Missing derivation for Vertex::/outgoing : Transition overriding function All_Owning_Packages (Self : not null access constant UML_Connection_Point_Reference_Proxy) return AMF.UML.Packages.Collections.Set_Of_UML_Package; -- Operation NamedElement::allOwningPackages. -- -- The query allOwningPackages() returns all the directly or indirectly -- owning packages. overriding function Is_Distinguishable_From (Self : not null access constant UML_Connection_Point_Reference_Proxy; N : AMF.UML.Named_Elements.UML_Named_Element_Access; Ns : AMF.UML.Namespaces.UML_Namespace_Access) return Boolean; -- Operation NamedElement::isDistinguishableFrom. -- -- The query isDistinguishableFrom() determines whether two NamedElements -- may logically co-exist within a Namespace. By default, two named -- elements are distinguishable if (a) they have unrelated types or (b) -- they have related types but different names. overriding function Namespace (Self : not null access constant UML_Connection_Point_Reference_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Operation NamedElement::namespace. -- -- Missing derivation for NamedElement::/namespace : Namespace overriding procedure Enter_Element (Self : not null access constant UML_Connection_Point_Reference_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Leave_Element (Self : not null access constant UML_Connection_Point_Reference_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Visit_Element (Self : not null access constant UML_Connection_Point_Reference_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of iterator interface. end AMF.Internals.UML_Connection_Point_References;
optikos/oasis
Ada
3,928
adb
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- package body Program.Nodes.Range_Attribute_References is function Create (Range_Attribute : not null Program.Elements.Attribute_References .Attribute_Reference_Access) return Range_Attribute_Reference is begin return Result : Range_Attribute_Reference := (Range_Attribute => Range_Attribute, Enclosing_Element => null) do Initialize (Result); end return; end Create; function Create (Range_Attribute : not null Program.Elements.Attribute_References .Attribute_Reference_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False) return Implicit_Range_Attribute_Reference is begin return Result : Implicit_Range_Attribute_Reference := (Range_Attribute => Range_Attribute, Is_Part_Of_Implicit => Is_Part_Of_Implicit, Is_Part_Of_Inherited => Is_Part_Of_Inherited, Is_Part_Of_Instance => Is_Part_Of_Instance, Enclosing_Element => null) do Initialize (Result); end return; end Create; overriding function Range_Attribute (Self : Base_Range_Attribute_Reference) return not null Program.Elements.Attribute_References .Attribute_Reference_Access is begin return Self.Range_Attribute; end Range_Attribute; overriding function Is_Part_Of_Implicit (Self : Implicit_Range_Attribute_Reference) return Boolean is begin return Self.Is_Part_Of_Implicit; end Is_Part_Of_Implicit; overriding function Is_Part_Of_Inherited (Self : Implicit_Range_Attribute_Reference) return Boolean is begin return Self.Is_Part_Of_Inherited; end Is_Part_Of_Inherited; overriding function Is_Part_Of_Instance (Self : Implicit_Range_Attribute_Reference) return Boolean is begin return Self.Is_Part_Of_Instance; end Is_Part_Of_Instance; procedure Initialize (Self : aliased in out Base_Range_Attribute_Reference'Class) is begin Set_Enclosing_Element (Self.Range_Attribute, Self'Unchecked_Access); null; end Initialize; overriding function Is_Range_Attribute_Reference_Element (Self : Base_Range_Attribute_Reference) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Range_Attribute_Reference_Element; overriding function Is_Constraint_Element (Self : Base_Range_Attribute_Reference) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Constraint_Element; overriding function Is_Definition_Element (Self : Base_Range_Attribute_Reference) return Boolean is pragma Unreferenced (Self); begin return True; end Is_Definition_Element; overriding procedure Visit (Self : not null access Base_Range_Attribute_Reference; Visitor : in out Program.Element_Visitors.Element_Visitor'Class) is begin Visitor.Range_Attribute_Reference (Self); end Visit; overriding function To_Range_Attribute_Reference_Text (Self : aliased in out Range_Attribute_Reference) return Program.Elements.Range_Attribute_References .Range_Attribute_Reference_Text_Access is begin return Self'Unchecked_Access; end To_Range_Attribute_Reference_Text; overriding function To_Range_Attribute_Reference_Text (Self : aliased in out Implicit_Range_Attribute_Reference) return Program.Elements.Range_Attribute_References .Range_Attribute_Reference_Text_Access is pragma Unreferenced (Self); begin return null; end To_Range_Attribute_Reference_Text; end Program.Nodes.Range_Attribute_References;
reznikmm/matreshka
Ada
3,749
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.Text_Count_Empty_Lines_Attributes is pragma Preelaborate; type ODF_Text_Count_Empty_Lines_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Text_Count_Empty_Lines_Attribute_Access is access all ODF_Text_Count_Empty_Lines_Attribute'Class with Storage_Size => 0; end ODF.DOM.Text_Count_Empty_Lines_Attributes;
charlie5/cBound
Ada
1,801
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_materialfv_reply_t is -- Item -- type Item is record response_type : aliased Interfaces.Unsigned_8; pad0 : aliased Interfaces.Unsigned_8; sequence : aliased Interfaces.Unsigned_16; length : aliased Interfaces.Unsigned_32; pad1 : aliased swig.int8_t_Array (0 .. 3); n : aliased Interfaces.Unsigned_32; datum : aliased xcb.xcb_glx_float32_t; pad2 : aliased swig.int8_t_Array (0 .. 11); end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_glx_get_materialfv_reply_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_materialfv_reply_t.Item, Element_Array => xcb.xcb_glx_get_materialfv_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_materialfv_reply_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_get_materialfv_reply_t.Pointer, Element_Array => xcb.xcb_glx_get_materialfv_reply_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_glx_get_materialfv_reply_t;
faelys/natools
Ada
20,133
adb
------------------------------------------------------------------------------ -- Copyright (c) 2013-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 Natools.S_Expressions.Encodings; package body Natools.S_Expressions.Parsers is ---------------------- -- Parser Interface -- ---------------------- procedure Reset (Self : in out Parser; Hard : in Boolean := False) is Null_Stack : Lockable.Lock_Stack; begin Self.Internal := (State => Waiting); Self.Next_Event := Events.End_Of_Input; Self.Latest := Events.Error; Self.Level := 0; Self.Lock_Stack := Null_Stack; Self.Locked := False; if Hard then Self.Pending.Hard_Reset; Self.Buffer.Hard_Reset; else Self.Pending.Soft_Reset; Self.Buffer.Soft_Reset; end if; end Reset; overriding function Current_Event (Self : in Parser) return Events.Event is begin if Self.Locked then return Events.End_Of_Input; else return Self.Latest; end if; end Current_Event; overriding function Current_Atom (Self : in Parser) return Atom is begin if Self.Locked or Self.Latest /= Events.Add_Atom then raise Program_Error; end if; return Self.Buffer.Data; end Current_Atom; overriding function Current_Level (Self : in Parser) return Natural is begin if Self.Locked then return 0; else return Self.Level - Lockable.Current_Level (Self.Lock_Stack); end if; end Current_Level; overriding procedure Query_Atom (Self : in Parser; Process : not null access procedure (Data : in Atom)) is begin if Self.Locked or Self.Latest /= Events.Add_Atom then raise Program_Error; end if; Self.Buffer.Query (Process); end Query_Atom; overriding procedure Read_Atom (Self : in Parser; Data : out Atom; Length : out Count) is begin if Self.Locked or Self.Latest /= Events.Add_Atom then raise Program_Error; end if; Self.Buffer.Peek (Data, Length); end Read_Atom; overriding procedure Next (Self : in out Parser; Event : out Events.Event) is O : Octet; begin if Self.Locked then Event := Events.End_Of_Input; return; end if; Self.Latest := Events.Error; loop -- Process pending events if Self.Next_Event /= Events.End_Of_Input then Self.Latest := Self.Next_Event; Self.Next_Event := Events.End_Of_Input; case Self.Latest is when Events.Open_List => Self.Level := Self.Level + 1; when Events.Close_List => if Self.Level > 0 then Self.Level := Self.Level - 1; end if; when others => null; end case; exit; end if; -- Read a single octet from source if Self.Pending.Length = 0 then Read_More (Parser'Class (Self), Self.Pending); if Self.Pending.Length = 0 then Self.Latest := Events.End_Of_Input; exit; end if; Self.Pending.Invert; end if; Self.Pending.Pop (O); -- Process octet case Self.Internal.State is when Waiting => Self.Buffer.Soft_Reset; case O is when 0 | Encodings.Space | Encodings.HT | Encodings.CR | Encodings.LF | Encodings.VT | Encodings.FF => null; when Encodings.List_Begin => Self.Latest := Events.Open_List; Self.Level := Self.Level + 1; when Encodings.List_End => Self.Latest := Events.Close_List; if Self.Level > 0 then Self.Level := Self.Level - 1; end if; when Encodings.Base64_Atom_Begin => Self.Internal := (State => Base64_Atom, Chunk => (Data => <>, Length => 0)); when Encodings.Base64_Expr_Begin => Self.Internal := (State => Base64_Expr, Chunk => (Data => <>, Length => 0)); when Encodings.Hex_Atom_Begin => Self.Internal := (State => Hex_Atom, Nibble_Buffer => 0); when Encodings.Quoted_Atom_Begin => Self.Internal := (State => Quoted_Atom, Escape => (Data => <>, Length => 0)); when Encodings.Digit_0 .. Encodings.Digit_9 => Self.Internal := (State => Number); Atom_Buffers.Append (Self.Buffer, O); when others => Self.Internal := (State => Token); Atom_Buffers.Append (Self.Buffer, O); end case; when Base64_Atom | Base64_Expr => if Encodings.Is_Base64_Digit (O) then Self.Internal.Chunk.Data (Self.Internal.Chunk.Length) := O; Self.Internal.Chunk.Length := Self.Internal.Chunk.Length + 1; if Self.Internal.Chunk.Length = 4 then Self.Buffer.Append (Encodings.Decode_Base64 (Self.Internal.Chunk.Data)); Self.Internal.Chunk.Length := 0; end if; elsif (O = Encodings.Base64_Atom_End and Self.Internal.State = Base64_Atom) or (O = Encodings.Base64_Expr_End and Self.Internal.State = Base64_Expr) then Self.Buffer.Append (Encodings.Decode_Base64 (Self.Internal.Chunk.Data (0 .. Self.Internal.Chunk.Length - 1))); if Self.Internal.State = Base64_Atom then Self.Latest := Events.Add_Atom; else Self.Pending.Append_Reverse (Self.Buffer.Data); Self.Buffer.Soft_Reset; end if; Self.Internal := (State => Waiting); end if; when Hex_Atom => if Encodings.Is_Hex_Digit (O) then if Encodings.Is_Hex_Digit (Self.Internal.Nibble_Buffer) then Self.Buffer.Append (Encodings.Decode_Hex (Self.Internal.Nibble_Buffer, O)); Self.Internal.Nibble_Buffer := 0; else Self.Internal.Nibble_Buffer := O; end if; elsif O = Encodings.Hex_Atom_End then Self.Latest := Events.Add_Atom; Self.Internal := (State => Waiting); end if; when Number => case O is when Encodings.Digit_0 .. Encodings.Digit_9 => Self.Buffer.Append (O); when Encodings.Verbatim_Begin => Self.Internal := (State => Verbatim_Atom, Size => 0); for I in 1 .. Self.Buffer.Length loop Self.Internal.Size := Self.Internal.Size * 10 + Count (Self.Buffer.Element (I) - Encodings.Digit_0); end loop; Self.Buffer.Soft_Reset; if Self.Internal.Size = 0 then Self.Latest := Events.Add_Atom; Self.Internal := (State => Waiting); else Self.Buffer.Preallocate (Self.Internal.Size); end if; when 0 | Encodings.Space | Encodings.HT | Encodings.CR | Encodings.LF | Encodings.VT | Encodings.FF => Self.Latest := Events.Add_Atom; Self.Internal := (State => Waiting); when Encodings.List_Begin => Self.Internal := (State => Waiting); Self.Next_Event := Events.Open_List; Self.Latest := Events.Add_Atom; when Encodings.List_End => Self.Internal := (State => Waiting); Self.Next_Event := Events.Close_List; Self.Latest := Events.Add_Atom; when Encodings.Base64_Atom_Begin => Self.Internal := (State => Base64_Atom, Chunk => (Data => <>, Length => 0)); Self.Buffer.Soft_Reset; when Encodings.Base64_Expr_Begin => Self.Internal := (State => Base64_Expr, Chunk => (Data => <>, Length => 0)); Self.Buffer.Soft_Reset; when Encodings.Hex_Atom_Begin => Self.Internal := (State => Hex_Atom, Nibble_Buffer => 0); Self.Buffer.Soft_Reset; when Encodings.Quoted_Atom_Begin => Self.Internal := (State => Quoted_Atom, Escape => (Data => <>, Length => 0)); Self.Buffer.Soft_Reset; when others => Self.Buffer.Append (O); Self.Internal := (State => Token); end case; when Quoted_Atom => case Self.Internal.Escape.Length is when 0 => case O is when Encodings.Escape => Self.Internal.Escape.Data (0) := O; Self.Internal.Escape.Length := 1; when Encodings.Quoted_Atom_End => Self.Internal := (State => Waiting); Self.Latest := Events.Add_Atom; when others => Self.Buffer.Append (O); end case; when 1 => case O is when Character'Pos ('b') => Self.Buffer.Append (8); Self.Internal.Escape.Length := 0; when Character'Pos ('t') => Self.Buffer.Append (9); Self.Internal.Escape.Length := 0; when Character'Pos ('n') => Self.Buffer.Append (10); Self.Internal.Escape.Length := 0; when Character'Pos ('v') => Self.Buffer.Append (11); Self.Internal.Escape.Length := 0; when Character'Pos ('f') => Self.Buffer.Append (12); Self.Internal.Escape.Length := 0; when Character'Pos ('r') => Self.Buffer.Append (13); Self.Internal.Escape.Length := 0; when Character'Pos (''') | Encodings.Escape | Encodings.Quoted_Atom_End => Self.Buffer.Append (O); Self.Internal.Escape.Length := 0; when Encodings.Digit_0 .. Encodings.Digit_0 + 3 | Character'Pos ('x') | Encodings.CR | Encodings.LF => Self.Internal.Escape.Data (1) := O; Self.Internal.Escape.Length := 2; when others => Self.Buffer.Append (Self.Internal.Escape.Data (0)); Self.Pending.Append (O); Self.Internal.Escape.Length := 0; end case; when 2 => if (Self.Internal.Escape.Data (1) in Encodings.Digit_0 .. Encodings.Digit_0 + 3 and O in Encodings.Digit_0 .. Encodings.Digit_0 + 7) or (Self.Internal.Escape.Data (1) = Character'Pos ('x') and then Encodings.Is_Hex_Digit (O)) then Self.Internal.Escape.Data (2) := O; Self.Internal.Escape.Length := 3; elsif Self.Internal.Escape.Data (1) = Encodings.CR or Self.Internal.Escape.Data (1) = Encodings.LF then Self.Internal.Escape.Length := 0; if not ((O = Encodings.CR or O = Encodings.LF) and O /= Self.Internal.Escape.Data (1)) then Self.Pending.Append (O); end if; else Self.Buffer.Append ((Self.Internal.Escape.Data (0), Self.Internal.Escape.Data (1))); Self.Pending.Append (O); Self.Internal.Escape.Length := 0; end if; when 3 => if Self.Internal.Escape.Data (1) = Character'Pos ('x') then if Encodings.Is_Hex_Digit (O) then Self.Buffer.Append (Encodings.Decode_Hex (Self.Internal.Escape.Data (2), O)); else Self.Buffer.Append ((Self.Internal.Escape.Data (0), Self.Internal.Escape.Data (1), Self.Internal.Escape.Data (2))); Self.Pending.Append (O); end if; else pragma Assert (Self.Internal.Escape.Data (1) in Encodings.Digit_0 .. Encodings.Digit_0 + 3); if O in Encodings.Digit_0 .. Encodings.Digit_0 + 7 then Atom_Buffers.Append (Self.Buffer, (Self.Internal.Escape.Data (1) - Encodings.Digit_0) * 2**6 + (Self.Internal.Escape.Data (2) - Encodings.Digit_0) * 2**3 + (O - Encodings.Digit_0)); else Self.Buffer.Append ((Self.Internal.Escape.Data (0), Self.Internal.Escape.Data (1), Self.Internal.Escape.Data (2))); Self.Pending.Append (O); end if; end if; Self.Internal.Escape.Length := 0; when 4 => raise Program_Error; end case; when Token => case O is when 0 | Encodings.Space | Encodings.HT | Encodings.CR | Encodings.LF | Encodings.VT | Encodings.FF => Self.Internal := (State => Waiting); Self.Latest := Events.Add_Atom; when Encodings.List_Begin => Self.Internal := (State => Waiting); Self.Next_Event := Events.Open_List; Self.Latest := Events.Add_Atom; when Encodings.List_End => Self.Internal := (State => Waiting); Self.Next_Event := Events.Close_List; Self.Latest := Events.Add_Atom; when others => Self.Buffer.Append (O); end case; when Verbatim_Atom => Self.Buffer.Append (O); pragma Assert (Self.Buffer.Length <= Self.Internal.Size); if Self.Buffer.Length = Self.Internal.Size then Self.Internal := (State => Waiting); Self.Latest := Events.Add_Atom; end if; end case; exit when Self.Latest /= Events.Error; end loop; if Self.Latest = Events.Close_List and then Self.Level < Lockable.Current_Level (Self.Lock_Stack) then Self.Locked := True; Event := Events.End_Of_Input; else Event := Self.Latest; end if; end Next; overriding procedure Lock (Self : in out Parser; State : out Lockable.Lock_State) is begin Lockable.Push_Level (Self.Lock_Stack, Self.Level, State); end Lock; overriding procedure Unlock (Self : in out Parser; State : in out Lockable.Lock_State; Finish : in Boolean := True) is Previous_Level : constant Natural := Lockable.Current_Level (Self.Lock_Stack); Event : Events.Event; begin Lockable.Pop_Level (Self.Lock_Stack, State); State := Lockable.Null_State; if Finish then Event := Self.Current_Event; loop case Event is when Events.Open_List | Events.Add_Atom => null; when Events.Close_List => exit when Self.Level < Previous_Level; when Events.Error | Events.End_Of_Input => exit; end case; Self.Next (Event); end loop; end if; Self.Locked := Self.Level < Lockable.Current_Level (Self.Lock_Stack); end Unlock; ------------------- -- Stream Parser -- ------------------- overriding procedure Read_More (Self : in out Stream_Parser; Buffer : out Atom_Buffers.Atom_Buffer) is Item : Ada.Streams.Stream_Element_Array (1 .. 128); Last : Ada.Streams.Stream_Element_Offset; begin Self.Input.Read (Item, Last); if Last in Item'Range then Buffer.Append (Item (Item'First .. Last)); end if; end Read_More; ------------------- -- Memory Parser -- ------------------- not overriding function Create (Data : in Ada.Streams.Stream_Element_Array) return Memory_Parser is begin return P : Memory_Parser do P.Pending.Append (Data); P.Pending.Invert; end return; end Create; not overriding function Create_From_String (Data : in String) return Memory_Parser is begin return Create (To_Atom (Data)); end Create_From_String; end Natools.S_Expressions.Parsers;
reznikmm/matreshka
Ada
6,663
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Elements; with AMF.Internals.Helpers; with AMF.Internals.Tables.Utp_Attributes; with AMF.UML.Dependencies; with AMF.Visitors.Utp_Iterators; with AMF.Visitors.Utp_Visitors; package body AMF.Internals.Utp_Test_Log_Applications is ------------------------- -- Get_Base_Dependency -- ------------------------- overriding function Get_Base_Dependency (Self : not null access constant Utp_Test_Log_Application_Proxy) return AMF.UML.Dependencies.UML_Dependency_Access is begin return AMF.UML.Dependencies.UML_Dependency_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.Utp_Attributes.Internal_Get_Base_Dependency (Self.Element))); end Get_Base_Dependency; ------------------------- -- Set_Base_Dependency -- ------------------------- overriding procedure Set_Base_Dependency (Self : not null access Utp_Test_Log_Application_Proxy; To : AMF.UML.Dependencies.UML_Dependency_Access) is begin AMF.Internals.Tables.Utp_Attributes.Internal_Set_Base_Dependency (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Base_Dependency; ------------------- -- Enter_Element -- ------------------- overriding procedure Enter_Element (Self : not null access constant Utp_Test_Log_Application_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.Utp_Visitors.Utp_Visitor'Class then AMF.Visitors.Utp_Visitors.Utp_Visitor'Class (Visitor).Enter_Test_Log_Application (AMF.Utp.Test_Log_Applications.Utp_Test_Log_Application_Access (Self), Control); end if; end Enter_Element; ------------------- -- Leave_Element -- ------------------- overriding procedure Leave_Element (Self : not null access constant Utp_Test_Log_Application_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.Utp_Visitors.Utp_Visitor'Class then AMF.Visitors.Utp_Visitors.Utp_Visitor'Class (Visitor).Leave_Test_Log_Application (AMF.Utp.Test_Log_Applications.Utp_Test_Log_Application_Access (Self), Control); end if; end Leave_Element; ------------------- -- Visit_Element -- ------------------- overriding procedure Visit_Element (Self : not null access constant Utp_Test_Log_Application_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Iterator in AMF.Visitors.Utp_Iterators.Utp_Iterator'Class then AMF.Visitors.Utp_Iterators.Utp_Iterator'Class (Iterator).Visit_Test_Log_Application (Visitor, AMF.Utp.Test_Log_Applications.Utp_Test_Log_Application_Access (Self), Control); end if; end Visit_Element; end AMF.Internals.Utp_Test_Log_Applications;
AdaCore/langkit
Ada
589
adb
with Ada.Text_IO; use Ada.Text_IO; with Libfoolang.Analysis; use Libfoolang.Analysis; procedure Main is Ctx : constant Analysis_Context := Create_Context; U : constant Analysis_Unit := Ctx.Get_From_Buffer (Filename => "main.txt", Buffer => "example example example"); N : constant Foo_Node := U.Root; begin if U.Has_Diagnostics then for D of U.Diagnostics loop Put_Line (U.Format_GNU_Diagnostic (D)); end loop; raise Program_Error; end if; Put_Line ("P_Resolve (" & N.Image & ") = " & Value (N.P_Resolve).Image); end Main;
stcarrez/ada-security
Ada
24,024
adb
----------------------------------------------------------------------- -- security-oauth-servers -- OAuth Server Authentication Support -- Copyright (C) 2016, 2017, 2018, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Calendar.Conversions; with Interfaces.C; with Util.Log.Loggers; with Util.Encoders.Base64; with Util.Encoders.SHA256; with Util.Encoders.HMAC.SHA256; package body Security.OAuth.Servers is use type Ada.Calendar.Time; Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Security.OAuth.Servers"); -- ------------------------------ -- Check if the application has the given permission. -- ------------------------------ function Has_Permission (App : in Application; Permission : in Permissions.Permission_Index) return Boolean is begin return Security.Permissions.Has_Permission (App.Permissions, Permission); end Has_Permission; protected body Token_Cache is procedure Authenticate (Token : in String; Grant : in out Grant_Type) is Pos : Cache_Map.Cursor := Entries.Find (Token); begin if Cache_Map.Has_Element (Pos) then if Grant.Expires < Ada.Calendar.Clock then Entries.Delete (Pos); Grant.Status := Expired_Grant; else Grant.Auth := Cache_Map.Element (Pos).Auth; Grant.Expires := Cache_Map.Element (Pos).Expire; Grant.Status := Valid_Grant; end if; end if; end Authenticate; procedure Insert (Token : in String; Expire : in Ada.Calendar.Time; Principal : in Principal_Access) is begin Entries.Insert (Token, Cache_Entry '(Expire, Principal)); end Insert; procedure Remove (Token : in String) is begin Entries.Delete (Token); end Remove; procedure Timeout is begin null; end Timeout; end Token_Cache; -- ------------------------------ -- Set the auth private key. -- ------------------------------ procedure Set_Private_Key (Manager : in out Auth_Manager; Key : in String; Decode : in Boolean := False) is begin if Decode then declare Decoder : constant Util.Encoders.Decoder := Util.Encoders.Create (Util.Encoders.BASE_64_URL); Content : constant String := Decoder.Decode (Key); begin Manager.Private_Key := To_Unbounded_String (Content); end; else Manager.Private_Key := To_Unbounded_String (Key); end if; end Set_Private_Key; -- ------------------------------ -- Set the application manager to use and and applications. -- ------------------------------ procedure Set_Application_Manager (Manager : in out Auth_Manager; Repository : in Application_Manager_Access) is begin Manager.Repository := Repository; end Set_Application_Manager; -- ------------------------------ -- Set the realm manager to authentify users. -- ------------------------------ procedure Set_Realm_Manager (Manager : in out Auth_Manager; Realm : in Realm_Manager_Access) is begin Manager.Realm := Realm; end Set_Realm_Manager; -- ------------------------------ -- Authorize the access to the protected resource by the application and for the -- given principal. The resource owner has been verified and is represented by the -- <tt>Auth</tt> principal. Extract from the request parameters represented by -- <tt>Params</tt> the application client id, the scope and the expected response type. -- Handle the "Authorization Code Grant" and "Implicit Grant" defined in RFC 6749. -- ------------------------------ procedure Authorize (Realm : in out Auth_Manager; Params : in Security.Auth.Parameters'Class; Auth : in Principal_Access; Grant : out Grant_Type) is Method : constant String := Params.Get_Parameter (Security.OAuth.RESPONSE_TYPE); Client_Id : constant String := Params.Get_Parameter (Security.OAuth.CLIENT_ID); begin if Client_Id'Length = 0 then Grant.Status := Invalid_Grant; Grant.Error := INVALID_REQUEST'Access; return; end if; declare App : constant Application'Class := Realm.Repository.Find_Application (Client_Id); begin if Method = "code" then Realm.Authorize_Code (App, Params, Auth, Grant); elsif Method = "token" then Realm.Authorize_Token (App, Params, Auth, Grant); else Grant.Status := Invalid_Grant; Grant.Error := UNSUPPORTED_RESPONSE_TYPE'Access; Log.Warn ("Authorize method '{0}' is not supported", Method); end if; end; exception when Invalid_Application => Log.Warn ("Invalid client_id {0}", Client_Id); Grant.Status := Invalid_Grant; Grant.Error := INVALID_CLIENT'Access; return; when E : others => Log.Error ("Error while doing authorization for client_id " & Client_Id, E); Grant.Status := Invalid_Grant; Grant.Error := SERVER_ERROR'Access; end Authorize; -- ------------------------------ -- The <tt>Token</tt> procedure is the main entry point to get the access token and -- refresh token. The request parameters are accessed through the <tt>Params</tt> interface. -- The operation looks at the "grant_type" parameter to identify the access method. -- It also looks at the "client_id" to find the application for which the access token -- is created. Upon successful authentication, the operation returns a grant. -- ------------------------------ procedure Token (Realm : in out Auth_Manager; Params : in Security.Auth.Parameters'Class; Grant : out Grant_Type) is Method : constant String := Params.Get_Parameter (Security.OAuth.GRANT_TYPE); Client_Id : constant String := Params.Get_Parameter (Security.OAuth.CLIENT_ID); begin if Length (Realm.Private_Key) < MIN_KEY_LENGTH then Log.Error ("The private key is too short to generate a secure token"); Grant.Status := Invalid_Grant; Grant.Error := SERVER_ERROR'Access; return; end if; if Client_Id'Length = 0 then Grant.Status := Invalid_Grant; Grant.Error := INVALID_REQUEST'Access; return; end if; declare App : constant Application'Class := Realm.Repository.Find_Application (Client_Id); begin if Method = "authorization_code" then Realm.Token_From_Code (App, Params, Grant); elsif Method = "password" then Realm.Token_From_Password (App, Params, Grant); elsif Method = "refresh_token" then Grant.Error := UNSUPPORTED_GRANT_TYPE'Access; elsif Method = "client_credentials" then Grant.Error := UNSUPPORTED_GRANT_TYPE'Access; else Grant.Error := UNSUPPORTED_GRANT_TYPE'Access; Log.Warn ("Grant type '{0}' is not supported", Method); end if; end; exception when Invalid_Application => Log.Warn ("Invalid client_id '{0}'", Client_Id); Grant.Status := Invalid_Grant; Grant.Error := INVALID_CLIENT'Access; return; end Token; -- ------------------------------ -- Format the expiration date to a compact string. The date is transformed to a Unix -- date and encoded in LEB128 + base64url. -- ------------------------------ function Format_Expire (Expire : in Ada.Calendar.Time) return String is T : constant Interfaces.C.long := Ada.Calendar.Conversions.To_Unix_Time (Expire); begin return Util.Encoders.Base64.Encode (Interfaces.Unsigned_64 (T)); end Format_Expire; -- ------------------------------ -- Decode the expiration date that was extracted from the token. -- ------------------------------ function Parse_Expire (Expire : in String) return Ada.Calendar.Time is V : constant Interfaces.Unsigned_64 := Util.Encoders.Base64.Decode (Expire); begin return Ada.Calendar.Conversions.To_Ada_Time (Interfaces.C.long (V)); end Parse_Expire; -- Implement the RFC 6749: 4.1.1. Authorization Request for the authorization code grant. procedure Authorize_Code (Realm : in out Auth_Manager; App : in Application'Class; Params : in Security.Auth.Parameters'Class; Auth : in Principal_Access; Grant : out Grant_Type) is Callback : constant String := Params.Get_Parameter (Security.OAuth.REDIRECT_URI); Scope : constant String := Params.Get_Parameter (Security.OAuth.SCOPE); begin Grant.Request := Code_Grant; Grant.Status := Invalid_Grant; if Auth = null then Log.Info ("Authorization is denied"); Grant.Error := ACCESS_DENIED'Access; elsif App.Callback /= Callback then Log.Info ("Invalid application callback"); Grant.Error := UNAUTHORIZED_CLIENT'Access; else -- Manager'Class (Realm).Authorize (Auth, Scope); Grant.Expires := Ada.Calendar.Clock + Realm.Expire_Code; Grant.Expires_In := Realm.Expire_Code; Grant.Status := Valid_Grant; Grant.Auth := Auth; Realm.Create_Token (Realm.Realm.Authorize (App, Scope, Auth), Grant); end if; end Authorize_Code; -- Implement the RFC 6749: 4.2.1. Authorization Request for the implicit grant. procedure Authorize_Token (Realm : in out Auth_Manager; App : in Application'Class; Params : in Security.Auth.Parameters'Class; Auth : in Principal_Access; Grant : out Grant_Type) is Callback : constant String := Params.Get_Parameter (Security.OAuth.REDIRECT_URI); Scope : constant String := Params.Get_Parameter (Security.OAuth.SCOPE); begin Grant.Request := Implicit_Grant; Grant.Status := Invalid_Grant; if Auth = null then Log.Info ("Authorization is denied"); Grant.Error := ACCESS_DENIED'Access; elsif App.Callback /= Callback then Log.Info ("Invalid application callback"); Grant.Error := UNAUTHORIZED_CLIENT'Access; else Grant.Expires := Ada.Calendar.Clock + App.Expire_Timeout; Grant.Expires_In := App.Expire_Timeout; Grant.Status := Valid_Grant; Grant.Auth := Auth; Realm.Create_Token (Realm.Realm.Authorize (App, Scope, Grant.Auth), Grant); end if; end Authorize_Token; -- Make the access token from the authorization code that was created by the -- <tt>Authorize</tt> operation. Verify the client application, the redirect uri, the -- client secret and the validity of the authorization code. Extract from the -- authorization code the auth principal that was used for the grant and make the -- access token. procedure Token_From_Code (Realm : in out Auth_Manager; App : in Application'Class; Params : in Security.Auth.Parameters'Class; Grant : out Grant_Type) is Code : constant String := Params.Get_Parameter (Security.OAuth.CODE); Callback : constant String := Params.Get_Parameter (Security.OAuth.REDIRECT_URI); Secret : constant String := Params.Get_Parameter (Security.OAuth.CLIENT_SECRET); Token : Token_Validity; begin Grant.Request := Code_Grant; Grant.Status := Invalid_Grant; if Code'Length = 0 then Log.Info ("Missing authorization code request parameter"); Grant.Error := INVALID_REQUEST'Access; elsif App.Secret /= Secret then Log.Info ("Invalid application secret"); Grant.Error := UNAUTHORIZED_CLIENT'Access; elsif App.Callback /= Callback then Log.Info ("Invalid application callback"); Grant.Error := UNAUTHORIZED_CLIENT'Access; else Token := Realm.Validate (To_String (App.Client_Id), Code); Grant.Status := Token.Status; if Token.Status /= Valid_Grant then Log.Info ("Invalid authorization code {0}", Code); Grant.Error := ACCESS_DENIED'Access; else -- Verify the identification token and get the principal. Realm.Realm.Verify (Code (Token.Ident_Start .. Token.Ident_End), Grant.Auth); if Grant.Auth = null then Log.Info ("Access denied for authorization code {0}", Code); Grant.Error := ACCESS_DENIED'Access; else -- Extract user/session ident from code. Grant.Expires := Ada.Calendar.Clock + App.Expire_Timeout; Grant.Expires_In := App.Expire_Timeout; Grant.Error := null; Realm.Create_Token (Realm.Realm.Authorize (App, SCOPE, Grant.Auth), Grant); end if; end if; end if; end Token_From_Code; -- ------------------------------ -- Make the access token from the resource owner password credentials. The username, -- password and scope are extracted from the request and they are verified through the -- <tt>Verify</tt> procedure to obtain an associated principal. When successful, the -- principal describes the authorization and it is used to forge the access token. -- This operation implements the RFC 6749: 4.3. Resource Owner Password Credentials Grant. -- ------------------------------ procedure Token_From_Password (Realm : in out Auth_Manager; App : in Application'Class; Params : in Security.Auth.Parameters'Class; Grant : out Grant_Type) is Username : constant String := Params.Get_Parameter (Security.OAuth.USERNAME); Password : constant String := Params.Get_Parameter (Security.OAuth.PASSWORD); Scope : constant String := Params.Get_Parameter (Security.OAuth.SCOPE); Secret : constant String := Params.Get_Parameter (Security.OAuth.CLIENT_SECRET); begin Grant.Request := Password_Grant; Grant.Status := Invalid_Grant; if Username'Length = 0 then Log.Info ("Missing username request parameter"); Grant.Error := INVALID_REQUEST'Access; elsif Password'Length = 0 then Log.Info ("Missing password request parameter"); Grant.Error := INVALID_REQUEST'Access; elsif App.Secret /= Secret then Log.Info ("Invalid application secret"); Grant.Error := UNAUTHORIZED_CLIENT'Access; else -- Verify the username and password to get the principal. Realm.Realm.Verify (Username, Password, Grant.Auth); if Grant.Auth = null then Log.Info ("Access denied for {0}", Username); Grant.Error := ACCESS_DENIED'Access; else Grant.Status := Valid_Grant; Grant.Expires := Ada.Calendar.Clock + App.Expire_Timeout; Grant.Expires_In := App.Expire_Timeout; Grant.Error := null; Realm.Create_Token (Realm.Realm.Authorize (App, Scope, Grant.Auth), Grant); end if; end if; end Token_From_Password; -- ------------------------------ -- Create a HMAC-SHA1 of the data with the private key. -- This function can be overridden to use another signature algorithm. -- ------------------------------ function Sign (Realm : in Auth_Manager; Data : in String) return String is Ctx : Util.Encoders.HMAC.SHA256.Context; Result : Util.Encoders.SHA256.Base64_Digest; begin Util.Encoders.HMAC.SHA256.Set_Key (Ctx, To_String (Realm.Private_Key)); Util.Encoders.HMAC.SHA256.Update (Ctx, Data); Util.Encoders.HMAC.SHA256.Finish_Base64 (Ctx, Result, True); return Result; end Sign; -- ------------------------------ -- Forge an access token. The access token is signed by an HMAC-SHA256 signature. -- The returned token is formed as follows: -- <expiration>.<ident>.HMAC-SHA256(<private-key>, <expiration>.<ident>) -- See also RFC 6749: 5. Issuing an Access Token -- ------------------------------ procedure Create_Token (Realm : in Auth_Manager; Ident : in String; Grant : in out Grant_Type) is Exp : constant String := Format_Expire (Grant.Expires); Data : constant String := Exp & "." & Ident; Hmac : constant String := Auth_Manager'Class (Realm).Sign (Data); begin Grant.Token := Ada.Strings.Unbounded.To_Unbounded_String (Data & "." & Hmac); end Create_Token; -- Validate the token by checking that it is well formed, it has not expired -- and the HMAC-SHA256 signature is valid. Return the set of information to allow -- the extraction of the auth identification from the token public part. function Validate (Realm : in Auth_Manager; Client_Id : in String; Token : in String) return Token_Validity is Pos1 : constant Natural := Util.Strings.Index (Token, '.'); Pos2 : constant Natural := Util.Strings.Rindex (Token, '.'); Result : Token_Validity := (Status => Invalid_Grant, others => <>); begin -- Verify the access token validity. if Pos1 = 0 or else Pos2 = 0 or else Pos1 = Pos2 then Log.Info ("Authenticate bad formed access token {0}", Token); return Result; end if; -- Build the HMAC signature with the private key. declare Hmac : constant String := Auth_Manager'Class (Realm).Sign (Token (Token'First .. Pos2 - 1)); begin -- Check the HMAC signature part. if Token (Pos2 + 1 .. Token'Last) /= Hmac then Log.Info ("Bad signature for access token {0}", Token); return Result; end if; -- Signature is valid we can check the token expiration date. Result.Expire := Parse_Expire (Token (Token'First .. Pos1 - 1)); if Result.Expire < Ada.Calendar.Clock then Log.Info ("Token {0} has expired", Token); Result.Status := Expired_Grant; return Result; end if; Result.Ident_Start := Pos1 + 1; Result.Ident_End := Pos2 - 1; -- When an identifier is passed, verify it. if Client_Id'Length > 0 then Result.Ident_Start := Util.Strings.Index (Token, '.', Pos1 + 1); if Result.Ident_Start = 0 or else Client_Id /= Token (Pos1 + 1 .. Result.Ident_Start - 1) then Log.Info ("Token {0} was stealed for another application", Token); Result.Status := Stealed_Grant; return Result; end if; end if; -- The access token is valid. Result.Status := Valid_Grant; return Result; end; exception when E : others => -- No exception should ever be raised because we verify the signature first. Log.Error ("Token " & Token & " raised an exception", E); Result.Status := Invalid_Grant; return Result; end Validate; -- ------------------------------ -- Authenticate the access token and get a security principal that identifies the app/user. -- See RFC 6749, 7. Accessing Protected Resources. -- The access token is first searched in the cache. If it was found, it means the access -- token was already verified in the past, it is granted and associated with a principal. -- Otherwise, we have to verify the token signature first, then the expiration date and -- we extract from the token public part the auth identification. The <tt>Authenticate</tt> -- operation is then called to obtain the principal from the auth identification. -- When access token is invalid or authentification cannot be verified, a null principal -- is returned. The <tt>Grant</tt> data will hold the result of the grant with the reason -- of failures (if any). -- ------------------------------ procedure Authenticate (Realm : in out Auth_Manager; Token : in String; Grant : out Grant_Type) is Cacheable : Boolean; Check : Token_Validity; begin Check := Realm.Validate ("", Token); Grant.Status := Check.Status; Grant.Request := Access_Grant; Grant.Expires := Check.Expire; Grant.Auth := null; if Check.Status = Expired_Grant then Log.Info ("Access token {0} has expired", Token); elsif Check.Status /= Valid_Grant then Log.Info ("Access token {0} is invalid", Token); else Realm.Cache.Authenticate (Token, Grant); if Grant.Auth /= null then Log.Debug ("Authenticate access token {0} succeeded from cache", Token); return; end if; -- The access token is valid, well formed and has not expired. -- Get the associated principal (the only possibility it could fail is -- that it was revoked). Realm.Realm.Authenticate (Token (Check.Ident_Start .. Check.Ident_End), Grant.Auth, Cacheable); if Grant.Auth = null then Log.Info ("Access token {0} was revoked", Token); Grant.Status := Revoked_Grant; -- We are allowed to keep the token in the cache, insert it. elsif Cacheable then Realm.Cache.Insert (Token, Check.Expire, Grant.Auth); Log.Debug ("Access token {0} is granted and inserted in the cache", Token); else Log.Debug ("Access token {0} is granted", Token); end if; end if; end Authenticate; procedure Revoke (Realm : in out Auth_Manager; Token : in String) is Check : Token_Validity; Auth : Principal_Access; Cacheable : Boolean; begin Check := Realm.Validate ("", Token); if Check.Status = Valid_Grant then -- The access token is valid, well formed and has not expired. -- Get the associated principal (the only possibility it could fail is -- that it was revoked). Realm.Realm.Authenticate (Token (Check.Ident_Start .. Check.Ident_End), Auth, Cacheable); if Auth /= null then Realm.Cache.Remove (Token); Realm.Realm.Revoke (Auth); end if; end if; end Revoke; end Security.OAuth.Servers;
stcarrez/ada-util
Ada
9,181
adb
----------------------------------------------------------------------- -- mapping -- Example of serialization mappings -- Copyright (C) 2010, 2011, 2012, 2014 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; package body Mapping is use Util.Beans.Objects; Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Mapping"); type Property_Fields is (FIELD_NAME, FIELD_VALUE); type Property_Access is access all Property; type Address_Fields is (FIELD_CITY, FIELD_STREET, FIELD_COUNTRY, FIELD_ZIP); type Address_Access is access all Address; procedure Proxy_Address (Attr : in Util.Serialize.Mappers.Mapping'Class; Element : in out Person; Value : in Util.Beans.Objects.Object); function Get_Address_Member (Addr : in Address; Field : in Address_Fields) return Util.Beans.Objects.Object; procedure Set_Member (Addr : in out Address; Field : in Address_Fields; Value : in Util.Beans.Objects.Object); procedure Set_Member (P : in out Property; Field : in Property_Fields; Value : in Util.Beans.Objects.Object); procedure Set_Member (P : in out Property; Field : in Property_Fields; Value : in Util.Beans.Objects.Object) is begin case Field is when FIELD_NAME => P.Name := To_Unbounded_String (Value); when FIELD_VALUE => P.Value := To_Unbounded_String (Value); end case; end Set_Member; package Property_Mapper is new Util.Serialize.Mappers.Record_Mapper (Element_Type => Property, Element_Type_Access => Property_Access, Fields => Property_Fields, Set_Member => Set_Member); -- ------------------------------ -- Set the name/value pair on the current object. -- ------------------------------ procedure Set_Member (P : in out Person; Field : in Person_Fields; Value : in Util.Beans.Objects.Object) is begin Log.Debug ("Person field {0} - {0}", Person_Fields'Image (Field), To_String (Value)); case Field is when FIELD_FIRST_NAME => P.First_Name := To_Unbounded_String (Value); when FIELD_LAST_NAME => P.Last_Name := To_Unbounded_String (Value); when FIELD_AGE => P.Age := To_Integer (Value); when FIELD_ID => P.Id := To_Long_Long_Integer (Value); when FIELD_NAME => P.Name := To_Unbounded_String (Value); when FIELD_USER_NAME => P.Username := To_Unbounded_String (Value); when FIELD_GENDER => P.Gender := To_Unbounded_String (Value); when FIELD_LINK => P.Link := To_Unbounded_String (Value); end case; end Set_Member; -- ------------------------------ -- Set the name/value pair on the current object. -- ------------------------------ function Get_Person_Member (From : in Person; Field : in Person_Fields) return Util.Beans.Objects.Object is begin case Field is when FIELD_FIRST_NAME => return Util.Beans.Objects.To_Object (From.First_Name); when FIELD_LAST_NAME => return Util.Beans.Objects.To_Object (From.Last_Name); when FIELD_AGE => return Util.Beans.Objects.To_Object (From.Age); when FIELD_NAME => return Util.Beans.Objects.To_Object (From.Name); when FIELD_USER_NAME => return Util.Beans.Objects.To_Object (From.Username); when FIELD_LINK => return Util.Beans.Objects.To_Object (From.Link); when FIELD_GENDER => return Util.Beans.Objects.To_Object (From.Gender); when FIELD_ID => return Util.Beans.Objects.To_Object (From.Id); end case; end Get_Person_Member; -- ------------------------------ -- Set the name/value pair on the current object. -- ------------------------------ procedure Set_Member (Addr : in out Address; Field : in Address_Fields; Value : in Util.Beans.Objects.Object) is begin case Field is when FIELD_CITY => Addr.City := To_Unbounded_String (Value); when FIELD_STREET => Addr.Street := To_Unbounded_String (Value); when FIELD_COUNTRY => Addr.Country := To_Unbounded_String (Value); when FIELD_ZIP => Addr.Zip := To_Integer (Value); end case; end Set_Member; function Get_Address_Member (Addr : in Address; Field : in Address_Fields) return Util.Beans.Objects.Object is begin case Field is when FIELD_CITY => return Util.Beans.Objects.To_Object (Addr.City); when FIELD_STREET => return Util.Beans.Objects.To_Object (Addr.Street); when FIELD_COUNTRY => return Util.Beans.Objects.To_Object (Addr.Country); when FIELD_ZIP => return Util.Beans.Objects.To_Object (Addr.Zip); end case; end Get_Address_Member; package Address_Mapper is new Util.Serialize.Mappers.Record_Mapper (Element_Type => Address, Element_Type_Access => Address_Access, Fields => Address_Fields, Set_Member => Set_Member); -- Mapping for the Property record. Property_Mapping : aliased Property_Mapper.Mapper; -- Mapping for the Address record. Address_Mapping : aliased Address_Mapper.Mapper; -- Mapping for the Person record. Person_Mapping : aliased Person_Mapper.Mapper; -- ------------------------------ -- Get the address mapper which describes how to load an Address. -- ------------------------------ function Get_Address_Mapper return Util.Serialize.Mappers.Mapper_Access is begin return Address_Mapping'Access; end Get_Address_Mapper; -- ------------------------------ -- Get the person mapper which describes how to load a Person. -- ------------------------------ function Get_Person_Mapper return Person_Mapper.Mapper_Access is begin return Person_Mapping'Access; end Get_Person_Mapper; -- ------------------------------ -- Helper to give access to the <b>Address</b> member of a <b>Person</b>. -- ------------------------------ procedure Proxy_Address (Attr : in Util.Serialize.Mappers.Mapping'Class; Element : in out Person; Value : in Util.Beans.Objects.Object) is begin Address_Mapper.Set_Member (Attr, Element.Addr, Value); end Proxy_Address; begin Property_Mapping.Add_Default_Mapping; -- XML: JSON: -- ---- ----- -- <city>Paris</city> "city" : "Paris" -- <street>Champs de Mars</street> "street" : "Champs de Mars" -- <country>France</country> "country" : "France" -- <zip>75</zip> "zip" : 75 Address_Mapping.Bind (Get_Address_Member'Access); -- Address_Mapping.Add_Mapping ("info", Property_Mapping'Access, Proxy_Info'Access); Address_Mapping.Add_Default_Mapping; -- XML: -- ---- -- <xxx id='23'> -- <address> -- <city>...</city> -- <street number='44'>..</street> -- <country>..</country> -- <zip>..</zip> -- </address> -- <name>John</name> -- <last_name>Harry</last_name> -- <age>23</age> -- <info><facebook><id>...</id></facebook></info> -- </xxx> -- Person_Mapper.Add_Mapping ("@id"); Person_Mapping.Bind (Get_Person_Member'Access); Person_Mapping.Add_Mapping ("address", Address_Mapping'Access, Proxy_Address'Access); Person_Mapping.Add_Default_Mapping; -- Person_Mapper.Add_Mapping ("info/*"); -- Person_Mapper.Add_Mapping ("address/street/@number"); end Mapping;
AdaCore/gpr
Ada
1,738
adb
-- -- Copyright (C) 2019-2023, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 -- with Ada.Text_IO; with Ada.Strings.Fixed; with GPR2.Context; with GPR2.Log; with GPR2.Message; with GPR2.Project.Tree; with GPR2.Project.Typ; procedure Main is use Ada; use GPR2; use GPR2.Project; procedure Load (Filename : String); ---------- -- Load -- ---------- procedure Load (Filename : String) is Prj : Project.Tree.Object; Ctx : Context.Object; begin Project.Tree.Load (Prj, Create (Filename_Type (Filename)), Ctx); Text_IO.Put_Line ("All good, no message."); for T of Prj.Root_Project.Types loop Text_IO.Put ("Type : " & String (T.Name.Text) & " -"); for V of T.Values loop Text_IO.Put (' ' & V.Text); end loop; Text_IO.New_Line; end loop; exception when GPR2.Project_Error => if Prj.Has_Messages then Text_IO.Put_Line ("Messages found:"); for C in Prj.Log_Messages.Iterate (False, False, True, True, True) loop declare M : constant Message.Object := Log.Element (C); Mes : constant String := M.Format; L : constant Natural := Strings.Fixed.Index (Mes, "/types"); begin if L /= 0 then Text_IO.Put_Line (Mes (L .. Mes'Last)); else Text_IO.Put_Line (Mes); end if; end; end loop; end if; end Load; begin Load ("demo.gpr"); Load ("demo2.gpr"); Load ("demo3.gpr"); Load ("demo4-child.gpr"); end Main;
devkw/Amass
Ada
472
ads
-- Copyright 2017 Jeff Foley. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. name = "LoCArchive" type = "archive" function start() setratelimit(1) end function vertical(ctx, domain) crawl(ctx, buildurl(domain)) end function resolved(ctx, name) crawl(ctx, buildurl(name)) end function buildurl(domain) return "http://webarchive.loc.gov/all/" .. os.date("%Y") .. "/" .. domain end
reznikmm/matreshka
Ada
3,773
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.Constants; package body Matreshka.ODF_Attributes.Style.Writing_Mode is -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Style_Writing_Mode_Node) return League.Strings.Universal_String is begin return ODF.Constants.Writing_Mode_Name; end Get_Local_Name; end Matreshka.ODF_Attributes.Style.Writing_Mode;
stcarrez/ada-wiki
Ada
4,227
adb
----------------------------------------------------------------------- -- wiki-filters-toc -- Filter for the creation of Table Of Contents -- Copyright (C) 2016, 2018, 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 Ada.Strings.Wide_Wide_Fixed; with Wiki.Nodes.Lists; package body Wiki.Filters.TOC is use type Wiki.Nodes.Node_Kind; -- ------------------------------ -- Add a text content with the given format to the document. -- ------------------------------ overriding procedure Add_Text (Filter : in out TOC_Filter; Document : in out Wiki.Documents.Document; Text : in Wiki.Strings.WString; Format : in Wiki.Format_Map) is use Ada.Strings.Wide_Wide_Fixed; First : Natural := Text'First; Pos : Natural; begin if Filter.Header_Level >= 0 then Wiki.Strings.Append (Filter.Header, Text); Filter_Type (Filter).Add_Text (Document, Text, Format); return; end if; while First <= Text'Last loop Pos := Index (Text (First .. Text'Last), "__TOC__"); if Pos > 0 then Filter_Type (Filter).Add_Text (Document, Text (First .. Pos - 1), Format); Filter.Add_Node (Document, Wiki.Nodes.N_TOC_DISPLAY); First := Pos + 7; else Pos := Index (Text (First .. Text'Last), "__NOTOC__"); if Pos > 0 then Filter_Type (Filter).Add_Text (Document, Text (First .. Pos - 1), Format); Document.Hide_TOC; First := Pos + 9; else Filter_Type (Filter).Add_Text (Document, Text (First .. Text'Last), Format); exit; end if; end if; end loop; end Add_Text; -- ------------------------------ -- Add a section header with the given level in the document. -- ------------------------------ overriding procedure Start_Block (Filter : in out TOC_Filter; Document : in out Wiki.Documents.Document; Kind : in Wiki.Nodes.Node_Kind; Level : in Natural) is begin if Kind = Nodes.N_HEADER then Filter.Header_Level := Level; end if; Filter.Header_Level := Level; Filter_Type (Filter).Start_Block (Document, Kind, Level); end Start_Block; overriding procedure End_Block (Filter : in out TOC_Filter; Document : in out Wiki.Documents.Document; Kind : in Wiki.Nodes.Node_Kind) is begin if Kind = Nodes.N_HEADER then declare T : Wiki.Nodes.Lists.Node_List_Ref; Header : constant Wiki.Strings.WString := Wiki.Strings.To_WString (Filter.Header); begin Document.Get_TOC (T); Wiki.Nodes.Lists.Append (T, new Wiki.Nodes.Node_Type '(Kind => Wiki.Nodes.N_TOC_ENTRY, Len => Header'Length, Header => Header, Parent => null, Toc_Level => Filter.Header_Level)); Filter.Header_Level := -1; Filter.Header := Wiki.Strings.To_UString (""); end; end if; Filter_Type (Filter).End_Block (Document, Kind); end End_Block; end Wiki.Filters.TOC;
tum-ei-rcs/StratoX
Ada
319
ads
package Altunits with Spark_Mode is -- Base Units subtype Length_Type is Float; subtype Time_Type is Float; subtype Linear_Velocity_Type is Float; -- Base units --Meter : constant Length_Type := Length_Type (1.0); --Second : constant Time_Type := Time_Type (1.0); end Altunits;
MinimSecure/unum-sdk
Ada
1,316
ads
-- Copyright 2018-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/>. package Enum_With_Gap is type Enum_With_Gaps is ( LIT0, LIT1, LIT2, LIT3, LIT4 ); for Enum_With_Gaps use ( LIT0 => 3, LIT1 => 5, LIT2 => 8, LIT3 => 13, LIT4 => 21 ); for Enum_With_Gaps'size use 16; type MyWord is range 0 .. 16#FFFF# ; for MyWord'Size use 16; type AR is array (Enum_With_Gaps range <>) of MyWord; type AR_Access is access AR; type String_Access is access String; procedure Do_Nothing (E : AR_Access); procedure Do_Nothing (E : String_Access); end Enum_With_Gap;
stcarrez/ada-awa
Ada
3,817
adb
----------------------------------------------------------------------- -- awa-votes-beans -- Beans for module votes -- Copyright (C) 2013, 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 AWA.Helpers.Requests; package body AWA.Votes.Beans is -- ------------------------------ -- Action to vote up. -- ------------------------------ overriding procedure Vote_Up (Bean : in out Vote_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is pragma Unreferenced (Outcome); begin Bean.Entity_Id := AWA.Helpers.Requests.Get_Parameter ("id"); Bean.Rating := 1; Bean.Module.Vote_For (Permission => Ada.Strings.Unbounded.To_String (Bean.Permission), Entity_Type => Ada.Strings.Unbounded.To_String (Bean.Entity_Type), Id => Bean.Entity_Id, Value => Bean.Rating, Total => Bean.Total); end Vote_Up; -- ------------------------------ -- Action to vote down. -- ------------------------------ overriding procedure Vote_Down (Bean : in out Vote_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is pragma Unreferenced (Outcome); begin Bean.Entity_Id := AWA.Helpers.Requests.Get_Parameter ("id"); Bean.Rating := -1; Bean.Module.Vote_For (Permission => Ada.Strings.Unbounded.To_String (Bean.Permission), Entity_Type => Ada.Strings.Unbounded.To_String (Bean.Entity_Type), Id => Bean.Entity_Id, Value => Bean.Rating, Total => Bean.Total); end Vote_Down; -- ------------------------------ -- Action to vote. -- ------------------------------ overriding procedure Vote (Bean : in out Vote_Bean; Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is pragma Unreferenced (Outcome); begin Bean.Entity_Id := AWA.Helpers.Requests.Get_Parameter ("id"); Bean.Rating := AWA.Helpers.Requests.Get_Parameter ("rating", 0); if Bean.Rating /= 0 and then Bean.Rating /= -1 and then Bean.Rating /= 1 then Bean.Rating := 0; end if; Bean.Module.Vote_For (Permission => Ada.Strings.Unbounded.To_String (Bean.Permission), Entity_Type => Ada.Strings.Unbounded.To_String (Bean.Entity_Type), Id => Bean.Entity_Id, Value => Bean.Rating, Total => Bean.Total); end Vote; -- ------------------------------ -- Create the Vote_Bean bean instance. -- ------------------------------ function Create_Vote_Bean (Module : in AWA.Votes.Modules.Vote_Module_Access) return Util.Beans.Basic.Readonly_Bean_Access is Object : constant Vote_Bean_Access := new Vote_Bean; begin Object.Module := Module; return Object.all'Access; end Create_Vote_Bean; end AWA.Votes.Beans;