id
int64 0
30.9k
| extension
stringclasses 1
value | max_stars_count
int64 0
17k
| max_stars_repo_name
stringlengths 7
106
| max_stars_repo_path
stringlengths 5
136
| text
stringlengths 9
1M
|
|---|---|---|---|---|---|
30,400
|
ada
| 79
|
Roldak/OpenGLAda
|
tests/gl/gl_test-context.adb
|
<filename>tests/gl/gl_test-context.adb
-- part of OpenGLAda, (c) 2017 <NAME>
-- released under the terms of the MIT license, see the file "COPYING"
with Ada.Strings.Unbounded;
with Ada.Text_IO;
with GL.Context;
with GL_Test.Display_Backend;
procedure GL_Test.Context is
procedure Display_Context_Information is
use Ada.Strings.Unbounded;
use Ada.Text_IO;
begin
begin
Put_Line ("Major version: " & GL.Context.Major_Version'Img);
Put_Line ("Minor version: " & GL.Context.Minor_Version'Img);
exception
when others =>
Put_Line ("OpenGL version too old for querying major and minor");
end;
Put_Line ("Whole version string: " & GL.Context.Version_String);
Put_Line ("Vendor: " & GL.Context.Renderer);
Put_Line ("Renderer: " & GL.Context.Renderer);
Put_Line ("Extensions: ");
declare
List : constant GL.Context.String_List := GL.Context.Extensions;
begin
for I in List'Range loop
declare
Name : constant String := To_String (List (I));
begin
Put_Line (" " & Name);
if not GL.Context.Has_Extension (Name) then
Put_Line
("!!! Has_Extension returns false (should not happen)");
end if;
end;
end loop;
end;
begin
Put_Line ("Primary shading language version: " &
GL.Context.Primary_Shading_Language_Version);
exception
when others =>
Put_Line ("OpenGL version too old for querying " &
"Primary shading language version");
return;
end;
begin
declare
List : constant GL.Context.String_List :=
GL.Context.Supported_Shading_Language_Versions;
begin
Put_Line ("Supported shading language versions:");
for I in List'Range loop
declare
Version : constant String := To_String (List (I));
begin
Put_Line (" " & Version);
if not GL.Context.Supports_Shading_Language_Version
(Version)
then
Put_Line ("!!! Supports_Shading_Language_Version " &
"returns false (should not happen)");
end if;
end;
end loop;
end;
exception
when others =>
Put_Line ("OpenGL version too old for querying supported versions");
end;
end Display_Context_Information;
begin
Display_Backend.Init;
Ada.Text_IO.Put_Line
("Getting information without request for OpenGL version.");
-- create a window so we have a context
Display_Backend.Open_Window (Width => 500, Height => 500);
Display_Context_Information;
Ada.Text_IO.New_Line;
Display_Backend.Close_Window;
Ada.Text_IO.Put_Line
("Getting information with requested OpenGL version 2.1:");
Display_Backend.Configure_Minimum_OpenGL_Version (Major => 2, Minor => 1);
Display_Backend.Open_Window (Width => 500, Height => 500);
Display_Context_Information;
Display_Backend.Close_Window;
Ada.Text_IO.Put_Line
("Getting information with requested OpenGL version 3.2:");
Display_Backend.Configure_Minimum_OpenGL_Version (Major => 3, Minor => 2);
Display_Backend.Open_Window (Width => 500, Height => 500);
Display_Context_Information;
Display_Backend.Shutdown;
end GL_Test.Context;
|
30,401
|
ada
| 0
|
xeenta/learning-ada
|
src/006/tictac.adb
|
<reponame>xeenta/learning-ada
with Ada.Text_IO; use Ada.Text_IO;
procedure TicTac is
task Count is
entry Start;
entry Stop;
entry Reset;
end Count;
task body Count is
Counter : Natural := 0;
Is_Counting : Boolean := FALSE;
begin
loop
select
when Is_Counting =>
accept Stop do
Is_Counting := FALSE;
end Stop;
-- accept Start do
-- Put_Line ("What?");
-- end Start;
or
when not Is_Counting =>
accept Start do
Is_Counting := TRUE;
end Start;
or
accept Reset do
Put_Line ("RESET");
Counter := 0;
end Reset;
else
if Is_Counting then
Put_Line (Integer'Image (Counter) & ", counting...");
delay 1.0;
Counter := Counter + 1;
end if;
end select;
end loop;
end Count;
begin
Count.Start;
delay 5.5;
Put_Line ("5.5!");
delay 1.5;
Count.Stop;
Put_Line ("Stop");
delay 3.0;
Count.Start;
Put_Line ("Start");
delay 2.5;
Count.Reset;
delay 1.5;
Put_Line ("Start again while counting...?");
Count.Start; -- hang here!
-- never reached
Put_Line ("Restarted?");
delay 3.0;
Put_Line ("End of Main");
end TicTac;
|
30,402
|
ada
| 0
|
jrfondren/adventofcode
|
2018/9/ada/day9.adb
|
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Command_Line; use Ada.Command_Line;
with GNAT.OS_Lib;
with Marble_Mania;
procedure Day9 is
Players : Positive;
Last_Marble : Positive;
begin
if Argument_Count /= 2 then
Put_Line
(Standard_Error,
"usage: " & Command_Name & " <#players> <marble-worth>");
GNAT.OS_Lib.OS_Exit (1);
end if;
Players := Positive'Value (Argument (1));
Last_Marble := Positive'Value (Argument (2));
Put_Line
(Positive'Image (Players) & " players; last marble is worth " &
Positive'Image (Last_Marble) & " points: high score is " &
Marble_Mania.Score_Count'Image
(Marble_Mania.Play_Until (Players, Last_Marble)));
end Day9;
|
30,403
|
ada
| 13
|
Fabien-Chouteau/GESTE
|
src/geste-text.ads
|
------------------------------------------------------------------------------
-- --
-- GESTE --
-- --
-- Copyright (C) 2018 <NAME> --
-- --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with GESTE_Fonts;
package GESTE.Text is
subtype Parent is Layer.Instance;
type Instance (Da_Font : not null GESTE_Fonts.Bitmap_Font_Ref;
Number_Of_Columns : Positive;
Number_Of_Lines : Positive;
Foreground : Output_Color;
Background : Output_Color)
is new Parent with private;
subtype Class is Instance'Class;
type Ref is access all Class;
type Const_Ref is access constant Class;
procedure Clear (This : in out Instance);
-- Erase all text and set the cursor to (1, 1)
procedure Cursor (This : in out Instance;
X, Y : Positive);
procedure Put (This : in out Instance;
C : Character);
procedure Put (This : in out Instance;
Str : String);
function Char (This : in out Instance;
X, Y : Positive)
return Character;
procedure Set_Colors (This : in out Instance;
X, Y : Positive;
Foreground : Output_Color;
Background : Output_Color);
procedure Set_Colors_All (This : in out Instance;
Foreground : Output_Color;
Background : Output_Color);
procedure Invert (This : in out Instance;
X, Y : Positive;
Inverted : Boolean := True);
procedure Invert_All (This : in out Instance;
Inverted : Boolean := True);
private
type Char_Property is record
C : Character;
Inverted : Boolean;
FG : Output_Color;
BG : Output_Color;
end record;
type Char_Matrix is array (Positive range <>, Positive range <>)
of Char_Property;
type Instance (Da_Font : not null GESTE_Fonts.Bitmap_Font_Ref;
Number_Of_Columns : Positive;
Number_Of_Lines : Positive;
Foreground : Output_Color;
Background : Output_Color)
is new Parent with record
Matrix : Char_Matrix (1 .. Number_Of_Columns, 1 .. Number_Of_Lines) :=
(others => (others => (' ', False, Foreground, Background)));
CX : Positive := 1;
CY : Positive := 1;
end record;
function Text_Bitmap_Set (This : Instance;
X, Y : Integer;
C : out Char_Property)
return Boolean;
overriding
procedure Update_Size (This : in out Instance);
overriding
function Pix (This : Instance; X, Y : Integer) return Output_Color
with Pre => X in 0 .. This.Width - 1 and then Y in 0 .. This.Height - 1;
overriding
function Collides (This : Instance; X, Y : Integer) return Boolean;
end GESTE.Text;
|
30,404
|
ada
| 24
|
svn2github/matreshka
|
source/league/league-application.adb
|
<filename>source/league/league-application.adb<gh_stars>10-100
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010-2011, <NAME> <<EMAIL>> --
-- 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.Internals.Strings.Configuration;
package body League.Application is
procedure Initialize_Arguments_Environment;
-- Initialize arguments list and process environment.
Args : League.String_Vectors.Universal_String_Vector;
Env : League.Environment_Variables.Environment_Variable_Set;
App_Name : League.Strings.Universal_String;
App_Version : League.Strings.Universal_String;
Org_Name : League.Strings.Universal_String;
Org_Domain : League.Strings.Universal_String;
----------------------
-- Application_Name --
----------------------
function Application_Name return League.Strings.Universal_String is
begin
return App_Name;
end Application_Name;
-------------------------
-- Application_Version --
-------------------------
function Application_Version return League.Strings.Universal_String is
begin
return App_Version;
end Application_Version;
---------------
-- Arguments --
---------------
function Arguments return League.String_Vectors.Universal_String_Vector is
begin
return Args;
end Arguments;
-----------------
-- Environment --
-----------------
function Environment
return League.Environment_Variables.Environment_Variable_Set is
begin
return Env;
end Environment;
--------------------------------------
-- Initialize_Arguments_Environment --
--------------------------------------
procedure Initialize_Arguments_Environment is separate;
-------------------------
-- Organization_Domain --
-------------------------
function Organization_Domain return League.Strings.Universal_String is
begin
return Org_Domain;
end Organization_Domain;
-----------------------
-- Organization_Name --
-----------------------
function Organization_Name return League.Strings.Universal_String is
begin
return Org_Name;
end Organization_Name;
--------------------------
-- Set_Application_Name --
--------------------------
procedure Set_Application_Name (Name : League.Strings.Universal_String) is
begin
App_Name := Name;
end Set_Application_Name;
-----------------------------
-- Set_Application_Version --
-----------------------------
procedure Set_Application_Version
(Name : League.Strings.Universal_String) is
begin
App_Version := Name;
end Set_Application_Version;
-----------------------------
-- Set_Organization_Domain --
-----------------------------
procedure Set_Organization_Domain
(Name : League.Strings.Universal_String) is
begin
Org_Domain := Name;
end Set_Organization_Domain;
---------------------------
-- Set_Organization_Name --
---------------------------
procedure Set_Organization_Name (Name : League.Strings.Universal_String) is
begin
Org_Name := Name;
end Set_Organization_Name;
begin
-- Setup most optimal string handler.
Matreshka.Internals.Strings.Configuration.Initialize;
-- Initialize arguments and environment.
Initialize_Arguments_Environment;
end League.Application;
|
30,405
|
ada
| 7
|
best08618/asylo
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/controlled2.ads
|
with controlled1; use controlled1;
package controlled2 is
procedure Test_Suite;
end controlled2;
|
30,406
|
ada
| 7
|
best08618/asylo
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/opt6.ads
|
<gh_stars>1-10
package Opt6 is
type String_Access is access all String;
type String_List is array (Positive range <>) of String_Access;
type String_List_Access is access all String_List;
type Command_Line_Iterator is record
Params : String_List_Access;
Current : Natural;
end record;
function Current_Parameter (Iter : Command_Line_Iterator) return String;
end Opt6;
|
30,407
|
ada
| 2
|
morbos/Ada_Drivers_Library
|
arch/ARM/STM32/svd/stm32l0x3/stm32_svd-rcc.ads
|
<reponame>morbos/Ada_Drivers_Library
-- This spec has been automatically generated from STM32L0x3.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package STM32_SVD.RCC is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype CR_RTCPRE_Field is HAL.UInt2;
-- Clock control register
type CR_Register is record
-- 16 MHz high-speed internal clock enable
HSI16ON : Boolean := False;
-- Read-only. High-speed internal clock enable bit for some IP kernels
HSI16KERON : Boolean := False;
-- Internal high-speed clock ready flag
HSI16RDYF : Boolean := False;
-- HSI16DIVEN
HSI16DIVEN : Boolean := False;
-- Read-only. HSI16DIVF
HSI16DIVF : Boolean := False;
-- 16 MHz high-speed internal clock output enable
HSI16OUTEN : Boolean := False;
-- unspecified
Reserved_6_7 : HAL.UInt2 := 16#0#;
-- MSI clock enable bit
MSION : Boolean := True;
-- Read-only. MSI clock ready flag
MSIRDY : Boolean := True;
-- unspecified
Reserved_10_15 : HAL.UInt6 := 16#0#;
-- HSE clock enable bit
HSEON : Boolean := False;
-- Read-only. HSE clock ready flag
HSERDY : Boolean := False;
-- HSE clock bypass bit
HSEBYP : Boolean := False;
-- Clock security system on HSE enable bit
CSSLSEON : Boolean := False;
-- TC/LCD prescaler
RTCPRE : CR_RTCPRE_Field := 16#0#;
-- unspecified
Reserved_22_23 : HAL.UInt2 := 16#0#;
-- PLL enable bit
PLLON : Boolean := False;
-- Read-only. PLL clock ready flag
PLLRDY : Boolean := False;
-- unspecified
Reserved_26_31 : HAL.UInt6 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR_Register use record
HSI16ON at 0 range 0 .. 0;
HSI16KERON at 0 range 1 .. 1;
HSI16RDYF at 0 range 2 .. 2;
HSI16DIVEN at 0 range 3 .. 3;
HSI16DIVF at 0 range 4 .. 4;
HSI16OUTEN at 0 range 5 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
MSION at 0 range 8 .. 8;
MSIRDY at 0 range 9 .. 9;
Reserved_10_15 at 0 range 10 .. 15;
HSEON at 0 range 16 .. 16;
HSERDY at 0 range 17 .. 17;
HSEBYP at 0 range 18 .. 18;
CSSLSEON at 0 range 19 .. 19;
RTCPRE at 0 range 20 .. 21;
Reserved_22_23 at 0 range 22 .. 23;
PLLON at 0 range 24 .. 24;
PLLRDY at 0 range 25 .. 25;
Reserved_26_31 at 0 range 26 .. 31;
end record;
subtype ICSCR_HSI16CAL_Field is HAL.UInt8;
subtype ICSCR_HSI16TRIM_Field is HAL.UInt5;
subtype ICSCR_MSIRANGE_Field is HAL.UInt3;
subtype ICSCR_MSICAL_Field is HAL.UInt8;
subtype ICSCR_MSITRIM_Field is HAL.UInt8;
-- Internal clock sources calibration register
type ICSCR_Register is record
-- Read-only. nternal high speed clock calibration
HSI16CAL : ICSCR_HSI16CAL_Field := 16#0#;
-- High speed internal clock trimming
HSI16TRIM : ICSCR_HSI16TRIM_Field := 16#10#;
-- MSI clock ranges
MSIRANGE : ICSCR_MSIRANGE_Field := 16#5#;
-- Read-only. MSI clock calibration
MSICAL : ICSCR_MSICAL_Field := 16#0#;
-- MSI clock trimming
MSITRIM : ICSCR_MSITRIM_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ICSCR_Register use record
HSI16CAL at 0 range 0 .. 7;
HSI16TRIM at 0 range 8 .. 12;
MSIRANGE at 0 range 13 .. 15;
MSICAL at 0 range 16 .. 23;
MSITRIM at 0 range 24 .. 31;
end record;
subtype CRRCR_HSI48CAL_Field is HAL.UInt8;
-- Clock recovery RC register
type CRRCR_Register is record
-- 48MHz HSI clock enable bit
HSI48ON : Boolean := False;
-- Read-only. 48MHz HSI clock ready flag
HSI48RDY : Boolean := False;
-- 48 MHz HSI clock divided by 6 output enable
HSI48DIV6EN : Boolean := False;
-- unspecified
Reserved_3_7 : HAL.UInt5 := 16#0#;
-- Read-only. 48 MHz HSI clock calibration
HSI48CAL : CRRCR_HSI48CAL_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CRRCR_Register use record
HSI48ON at 0 range 0 .. 0;
HSI48RDY at 0 range 1 .. 1;
HSI48DIV6EN at 0 range 2 .. 2;
Reserved_3_7 at 0 range 3 .. 7;
HSI48CAL at 0 range 8 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype CFGR_SW_Field is HAL.UInt2;
subtype CFGR_SWS_Field is HAL.UInt2;
subtype CFGR_HPRE_Field is HAL.UInt4;
-- CFGR_PPRE array element
subtype CFGR_PPRE_Element is HAL.UInt3;
-- CFGR_PPRE array
type CFGR_PPRE_Field_Array is array (1 .. 2) of CFGR_PPRE_Element
with Component_Size => 3, Size => 6;
-- Type definition for CFGR_PPRE
type CFGR_PPRE_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PPRE as a value
Val : HAL.UInt6;
when True =>
-- PPRE as an array
Arr : CFGR_PPRE_Field_Array;
end case;
end record
with Unchecked_Union, Size => 6;
for CFGR_PPRE_Field use record
Val at 0 range 0 .. 5;
Arr at 0 range 0 .. 5;
end record;
subtype CFGR_PLLMUL_Field is HAL.UInt4;
subtype CFGR_PLLDIV_Field is HAL.UInt2;
subtype CFGR_MCOSEL_Field is HAL.UInt4;
subtype CFGR_MCOPRE_Field is HAL.UInt3;
-- Clock configuration register
type CFGR_Register is record
-- System clock switch
SW : CFGR_SW_Field := 16#0#;
-- Read-only. System clock switch status
SWS : CFGR_SWS_Field := 16#0#;
-- AHB prescaler
HPRE : CFGR_HPRE_Field := 16#0#;
-- APB low-speed prescaler (APB1)
PPRE : CFGR_PPRE_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_14_14 : HAL.Bit := 16#0#;
-- Wake-up from stop clock selection
STOPWUCK : Boolean := False;
-- PLL entry clock source
PLLSRC : Boolean := False;
-- unspecified
Reserved_17_17 : HAL.Bit := 16#0#;
-- PLL multiplication factor
PLLMUL : CFGR_PLLMUL_Field := 16#0#;
-- PLL output division
PLLDIV : CFGR_PLLDIV_Field := 16#0#;
-- Microcontroller clock output selection
MCOSEL : CFGR_MCOSEL_Field := 16#0#;
-- Microcontroller clock output prescaler
MCOPRE : CFGR_MCOPRE_Field := 16#0#;
-- unspecified
Reserved_31_31 : HAL.Bit := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CFGR_Register use record
SW at 0 range 0 .. 1;
SWS at 0 range 2 .. 3;
HPRE at 0 range 4 .. 7;
PPRE at 0 range 8 .. 13;
Reserved_14_14 at 0 range 14 .. 14;
STOPWUCK at 0 range 15 .. 15;
PLLSRC at 0 range 16 .. 16;
Reserved_17_17 at 0 range 17 .. 17;
PLLMUL at 0 range 18 .. 21;
PLLDIV at 0 range 22 .. 23;
MCOSEL at 0 range 24 .. 27;
MCOPRE at 0 range 28 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
-- Clock interrupt enable register
type CIER_Register is record
-- Read-only. LSI ready interrupt flag
LSIRDYIE : Boolean;
-- Read-only. LSE ready interrupt flag
LSERDYIE : Boolean;
-- Read-only. HSI16 ready interrupt flag
HSI16RDYIE : Boolean;
-- Read-only. HSE ready interrupt flag
HSERDYIE : Boolean;
-- Read-only. PLL ready interrupt flag
PLLRDYIE : Boolean;
-- Read-only. MSI ready interrupt flag
MSIRDYIE : Boolean;
-- Read-only. HSI48 ready interrupt flag
HSI48RDYIE : Boolean;
-- Read-only. LSE CSS interrupt flag
CSSLSE : Boolean;
-- unspecified
Reserved_8_31 : HAL.UInt24;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CIER_Register use record
LSIRDYIE at 0 range 0 .. 0;
LSERDYIE at 0 range 1 .. 1;
HSI16RDYIE at 0 range 2 .. 2;
HSERDYIE at 0 range 3 .. 3;
PLLRDYIE at 0 range 4 .. 4;
MSIRDYIE at 0 range 5 .. 5;
HSI48RDYIE at 0 range 6 .. 6;
CSSLSE at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-- Clock interrupt flag register
type CIFR_Register is record
-- Read-only. LSI ready interrupt flag
LSIRDYF : Boolean;
-- Read-only. LSE ready interrupt flag
LSERDYF : Boolean;
-- Read-only. HSI16 ready interrupt flag
HSI16RDYF : Boolean;
-- Read-only. HSE ready interrupt flag
HSERDYF : Boolean;
-- Read-only. PLL ready interrupt flag
PLLRDYF : Boolean;
-- Read-only. MSI ready interrupt flag
MSIRDYF : Boolean;
-- Read-only. HSI48 ready interrupt flag
HSI48RDYF : Boolean;
-- Read-only. LSE Clock Security System Interrupt flag
CSSLSEF : Boolean;
-- Read-only. Clock Security System Interrupt flag
CSSHSEF : Boolean;
-- unspecified
Reserved_9_31 : HAL.UInt23;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CIFR_Register use record
LSIRDYF at 0 range 0 .. 0;
LSERDYF at 0 range 1 .. 1;
HSI16RDYF at 0 range 2 .. 2;
HSERDYF at 0 range 3 .. 3;
PLLRDYF at 0 range 4 .. 4;
MSIRDYF at 0 range 5 .. 5;
HSI48RDYF at 0 range 6 .. 6;
CSSLSEF at 0 range 7 .. 7;
CSSHSEF at 0 range 8 .. 8;
Reserved_9_31 at 0 range 9 .. 31;
end record;
-- Clock interrupt clear register
type CICR_Register is record
-- Read-only. LSI ready Interrupt clear
LSIRDYC : Boolean;
-- Read-only. LSE ready Interrupt clear
LSERDYC : Boolean;
-- Read-only. HSI16 ready Interrupt clear
HSI16RDYC : Boolean;
-- Read-only. HSE ready Interrupt clear
HSERDYC : Boolean;
-- Read-only. PLL ready Interrupt clear
PLLRDYC : Boolean;
-- Read-only. MSI ready Interrupt clear
MSIRDYC : Boolean;
-- Read-only. HSI48 ready Interrupt clear
HSI48RDYC : Boolean;
-- Read-only. LSE Clock Security System Interrupt clear
CSSLSEC : Boolean;
-- Read-only. Clock Security System Interrupt clear
CSSHSEC : Boolean;
-- unspecified
Reserved_9_31 : HAL.UInt23;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CICR_Register use record
LSIRDYC at 0 range 0 .. 0;
LSERDYC at 0 range 1 .. 1;
HSI16RDYC at 0 range 2 .. 2;
HSERDYC at 0 range 3 .. 3;
PLLRDYC at 0 range 4 .. 4;
MSIRDYC at 0 range 5 .. 5;
HSI48RDYC at 0 range 6 .. 6;
CSSLSEC at 0 range 7 .. 7;
CSSHSEC at 0 range 8 .. 8;
Reserved_9_31 at 0 range 9 .. 31;
end record;
-- GPIO reset register
type IOPRSTR_Register is record
-- I/O port A reset
IOPARST : Boolean := False;
-- I/O port B reset
IOPBRST : Boolean := False;
-- I/O port A reset
IOPCRST : Boolean := False;
-- I/O port D reset
IOPDRST : Boolean := False;
-- I/O port E reset
IOPERST : Boolean := False;
-- unspecified
Reserved_5_6 : HAL.UInt2 := 16#0#;
-- I/O port H reset
IOPHRST : Boolean := False;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for IOPRSTR_Register use record
IOPARST at 0 range 0 .. 0;
IOPBRST at 0 range 1 .. 1;
IOPCRST at 0 range 2 .. 2;
IOPDRST at 0 range 3 .. 3;
IOPERST at 0 range 4 .. 4;
Reserved_5_6 at 0 range 5 .. 6;
IOPHRST at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-- AHB peripheral reset register
type AHBRSTR_Register is record
-- DMA reset
DMARST : Boolean := False;
-- unspecified
Reserved_1_7 : HAL.UInt7 := 16#0#;
-- Memory interface reset
MIFRST : Boolean := False;
-- unspecified
Reserved_9_11 : HAL.UInt3 := 16#0#;
-- Test integration module reset
CRCRST : Boolean := False;
-- unspecified
Reserved_13_15 : HAL.UInt3 := 16#0#;
-- Touch Sensing reset
TOUCHRST : Boolean := False;
-- unspecified
Reserved_17_19 : HAL.UInt3 := 16#0#;
-- Random Number Generator module reset
RNGRST : Boolean := False;
-- unspecified
Reserved_21_23 : HAL.UInt3 := 16#0#;
-- Crypto module reset
CRYPRST : Boolean := False;
-- unspecified
Reserved_25_31 : HAL.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for AHBRSTR_Register use record
DMARST at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
MIFRST at 0 range 8 .. 8;
Reserved_9_11 at 0 range 9 .. 11;
CRCRST at 0 range 12 .. 12;
Reserved_13_15 at 0 range 13 .. 15;
TOUCHRST at 0 range 16 .. 16;
Reserved_17_19 at 0 range 17 .. 19;
RNGRST at 0 range 20 .. 20;
Reserved_21_23 at 0 range 21 .. 23;
CRYPRST at 0 range 24 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
-- APB2 peripheral reset register
type APB2RSTR_Register is record
-- System configuration controller reset
SYSCFGRST : Boolean := False;
-- unspecified
Reserved_1_1 : HAL.Bit := 16#0#;
-- TIM21 timer reset
TIM21RST : Boolean := False;
-- unspecified
Reserved_3_4 : HAL.UInt2 := 16#0#;
-- TIM22 timer reset
TM12RST : Boolean := False;
-- unspecified
Reserved_6_8 : HAL.UInt3 := 16#0#;
-- ADC interface reset
ADCRST : Boolean := False;
-- unspecified
Reserved_10_11 : HAL.UInt2 := 16#0#;
-- SPI 1 reset
SPI1RST : Boolean := False;
-- unspecified
Reserved_13_13 : HAL.Bit := 16#0#;
-- USART1 reset
USART1RST : Boolean := False;
-- unspecified
Reserved_15_21 : HAL.UInt7 := 16#0#;
-- DBG reset
DBGRST : Boolean := False;
-- unspecified
Reserved_23_31 : HAL.UInt9 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for APB2RSTR_Register use record
SYSCFGRST at 0 range 0 .. 0;
Reserved_1_1 at 0 range 1 .. 1;
TIM21RST at 0 range 2 .. 2;
Reserved_3_4 at 0 range 3 .. 4;
TM12RST at 0 range 5 .. 5;
Reserved_6_8 at 0 range 6 .. 8;
ADCRST at 0 range 9 .. 9;
Reserved_10_11 at 0 range 10 .. 11;
SPI1RST at 0 range 12 .. 12;
Reserved_13_13 at 0 range 13 .. 13;
USART1RST at 0 range 14 .. 14;
Reserved_15_21 at 0 range 15 .. 21;
DBGRST at 0 range 22 .. 22;
Reserved_23_31 at 0 range 23 .. 31;
end record;
-- APB1 peripheral reset register
type APB1RSTR_Register is record
-- Timer2 reset
TIM2RST : Boolean := False;
-- Timer3 reset
TIM3RST : Boolean := False;
-- unspecified
Reserved_2_3 : HAL.UInt2 := 16#0#;
-- Timer 6 reset
TIM6RST : Boolean := False;
-- Timer 7 reset
TIM7RST : Boolean := False;
-- unspecified
Reserved_6_10 : HAL.UInt5 := 16#0#;
-- Window watchdog reset
WWDRST : Boolean := False;
-- unspecified
Reserved_12_13 : HAL.UInt2 := 16#0#;
-- SPI2 reset
SPI2RST : Boolean := False;
-- unspecified
Reserved_15_16 : HAL.UInt2 := 16#0#;
-- UART2 reset
LPUART12RST : Boolean := False;
-- LPUART1 reset
LPUART1RST : Boolean := False;
-- USART4 reset
USART4RST : Boolean := False;
-- USART5 reset
USART5RST : Boolean := False;
-- I2C1 reset
I2C1RST : Boolean := False;
-- I2C2 reset
I2C2RST : Boolean := False;
-- USB reset
USBRST : Boolean := False;
-- unspecified
Reserved_24_26 : HAL.UInt3 := 16#0#;
-- Clock recovery system reset
CRSRST : Boolean := False;
-- Power interface reset
PWRRST : Boolean := False;
-- DAC interface reset
DACRST : Boolean := False;
-- I2C3 reset
I2C3RST : Boolean := False;
-- Low power timer reset
LPTIM1RST : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for APB1RSTR_Register use record
TIM2RST at 0 range 0 .. 0;
TIM3RST at 0 range 1 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
TIM6RST at 0 range 4 .. 4;
TIM7RST at 0 range 5 .. 5;
Reserved_6_10 at 0 range 6 .. 10;
WWDRST at 0 range 11 .. 11;
Reserved_12_13 at 0 range 12 .. 13;
SPI2RST at 0 range 14 .. 14;
Reserved_15_16 at 0 range 15 .. 16;
LPUART12RST at 0 range 17 .. 17;
LPUART1RST at 0 range 18 .. 18;
USART4RST at 0 range 19 .. 19;
USART5RST at 0 range 20 .. 20;
I2C1RST at 0 range 21 .. 21;
I2C2RST at 0 range 22 .. 22;
USBRST at 0 range 23 .. 23;
Reserved_24_26 at 0 range 24 .. 26;
CRSRST at 0 range 27 .. 27;
PWRRST at 0 range 28 .. 28;
DACRST at 0 range 29 .. 29;
I2C3RST at 0 range 30 .. 30;
LPTIM1RST at 0 range 31 .. 31;
end record;
-- GPIO clock enable register
type IOPENR_Register is record
-- IO port A clock enable bit
IOPAEN : Boolean := False;
-- IO port B clock enable bit
IOPBEN : Boolean := False;
-- IO port A clock enable bit
IOPCEN : Boolean := False;
-- I/O port D clock enable bit
IOPDEN : Boolean := False;
-- I/O port E clock enable bit
IOPEEN : Boolean := False;
-- unspecified
Reserved_5_6 : HAL.UInt2 := 16#0#;
-- I/O port H clock enable bit
IOPHEN : Boolean := False;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for IOPENR_Register use record
IOPAEN at 0 range 0 .. 0;
IOPBEN at 0 range 1 .. 1;
IOPCEN at 0 range 2 .. 2;
IOPDEN at 0 range 3 .. 3;
IOPEEN at 0 range 4 .. 4;
Reserved_5_6 at 0 range 5 .. 6;
IOPHEN at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-- AHB peripheral clock enable register
type AHBENR_Register is record
-- DMA clock enable bit
DMAEN : Boolean := False;
-- unspecified
Reserved_1_7 : HAL.UInt7 := 16#0#;
-- NVM interface clock enable bit
MIFEN : Boolean := True;
-- unspecified
Reserved_9_11 : HAL.UInt3 := 16#0#;
-- CRC clock enable bit
CRCEN : Boolean := False;
-- unspecified
Reserved_13_15 : HAL.UInt3 := 16#0#;
-- Touch Sensing clock enable bit
TOUCHEN : Boolean := False;
-- unspecified
Reserved_17_19 : HAL.UInt3 := 16#0#;
-- Random Number Generator clock enable bit
RNGEN : Boolean := False;
-- unspecified
Reserved_21_23 : HAL.UInt3 := 16#0#;
-- Crypto clock enable bit
CRYPEN : Boolean := False;
-- unspecified
Reserved_25_31 : HAL.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for AHBENR_Register use record
DMAEN at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
MIFEN at 0 range 8 .. 8;
Reserved_9_11 at 0 range 9 .. 11;
CRCEN at 0 range 12 .. 12;
Reserved_13_15 at 0 range 13 .. 15;
TOUCHEN at 0 range 16 .. 16;
Reserved_17_19 at 0 range 17 .. 19;
RNGEN at 0 range 20 .. 20;
Reserved_21_23 at 0 range 21 .. 23;
CRYPEN at 0 range 24 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
-- APB2 peripheral clock enable register
type APB2ENR_Register is record
-- System configuration controller clock enable bit
SYSCFGEN : Boolean := False;
-- unspecified
Reserved_1_1 : HAL.Bit := 16#0#;
-- TIM21 timer clock enable bit
TIM21EN : Boolean := False;
-- unspecified
Reserved_3_4 : HAL.UInt2 := 16#0#;
-- TIM22 timer clock enable bit
TIM22EN : Boolean := False;
-- unspecified
Reserved_6_6 : HAL.Bit := 16#0#;
-- MiFaRe Firewall clock enable bit
MIFIEN : Boolean := False;
-- unspecified
Reserved_8_8 : HAL.Bit := 16#0#;
-- ADC clock enable bit
ADCEN : Boolean := False;
-- unspecified
Reserved_10_11 : HAL.UInt2 := 16#0#;
-- SPI1 clock enable bit
SPI1EN : Boolean := False;
-- unspecified
Reserved_13_13 : HAL.Bit := 16#0#;
-- USART1 clock enable bit
USART1EN : Boolean := False;
-- unspecified
Reserved_15_21 : HAL.UInt7 := 16#0#;
-- DBG clock enable bit
DBGEN : Boolean := False;
-- unspecified
Reserved_23_31 : HAL.UInt9 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for APB2ENR_Register use record
SYSCFGEN at 0 range 0 .. 0;
Reserved_1_1 at 0 range 1 .. 1;
TIM21EN at 0 range 2 .. 2;
Reserved_3_4 at 0 range 3 .. 4;
TIM22EN at 0 range 5 .. 5;
Reserved_6_6 at 0 range 6 .. 6;
MIFIEN at 0 range 7 .. 7;
Reserved_8_8 at 0 range 8 .. 8;
ADCEN at 0 range 9 .. 9;
Reserved_10_11 at 0 range 10 .. 11;
SPI1EN at 0 range 12 .. 12;
Reserved_13_13 at 0 range 13 .. 13;
USART1EN at 0 range 14 .. 14;
Reserved_15_21 at 0 range 15 .. 21;
DBGEN at 0 range 22 .. 22;
Reserved_23_31 at 0 range 23 .. 31;
end record;
-- APB1 peripheral clock enable register
type APB1ENR_Register is record
-- Timer2 clock enable bit
TIM2EN : Boolean := False;
-- Timer3 clock enable bit
TIM3EN : Boolean := False;
-- unspecified
Reserved_2_3 : HAL.UInt2 := 16#0#;
-- Timer 6 clock enable bit
TIM6EN : Boolean := False;
-- Timer 7 clock enable bit
TIM7EN : Boolean := False;
-- unspecified
Reserved_6_10 : HAL.UInt5 := 16#0#;
-- Window watchdog clock enable bit
WWDGEN : Boolean := False;
-- unspecified
Reserved_12_13 : HAL.UInt2 := 16#0#;
-- SPI2 clock enable bit
SPI2EN : Boolean := False;
-- unspecified
Reserved_15_16 : HAL.UInt2 := 16#0#;
-- UART2 clock enable bit
USART2EN : Boolean := False;
-- LPUART1 clock enable bit
LPUART1EN : Boolean := False;
-- USART4 clock enable bit
USART4EN : Boolean := False;
-- USART5 clock enable bit
USART5EN : Boolean := False;
-- I2C1 clock enable bit
I2C1EN : Boolean := False;
-- I2C2 clock enable bit
I2C2EN : Boolean := False;
-- USB clock enable bit
USBEN : Boolean := False;
-- unspecified
Reserved_24_26 : HAL.UInt3 := 16#0#;
-- Clock recovery system clock enable bit
CRSEN : Boolean := False;
-- Power interface clock enable bit
PWREN : Boolean := False;
-- DAC interface clock enable bit
DACEN : Boolean := False;
-- I2C3 clock enable bit
I2C3EN : Boolean := False;
-- Low power timer clock enable bit
LPTIM1EN : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for APB1ENR_Register use record
TIM2EN at 0 range 0 .. 0;
TIM3EN at 0 range 1 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
TIM6EN at 0 range 4 .. 4;
TIM7EN at 0 range 5 .. 5;
Reserved_6_10 at 0 range 6 .. 10;
WWDGEN at 0 range 11 .. 11;
Reserved_12_13 at 0 range 12 .. 13;
SPI2EN at 0 range 14 .. 14;
Reserved_15_16 at 0 range 15 .. 16;
USART2EN at 0 range 17 .. 17;
LPUART1EN at 0 range 18 .. 18;
USART4EN at 0 range 19 .. 19;
USART5EN at 0 range 20 .. 20;
I2C1EN at 0 range 21 .. 21;
I2C2EN at 0 range 22 .. 22;
USBEN at 0 range 23 .. 23;
Reserved_24_26 at 0 range 24 .. 26;
CRSEN at 0 range 27 .. 27;
PWREN at 0 range 28 .. 28;
DACEN at 0 range 29 .. 29;
I2C3EN at 0 range 30 .. 30;
LPTIM1EN at 0 range 31 .. 31;
end record;
-- GPIO clock enable in sleep mode register
type IOPSMEN_Register is record
-- IOPASMEN
IOPASMEN : Boolean := True;
-- IOPBSMEN
IOPBSMEN : Boolean := True;
-- IOPCSMEN
IOPCSMEN : Boolean := True;
-- IOPDSMEN
IOPDSMEN : Boolean := True;
-- Port E clock enable during Sleep mode bit
IOPESMEN : Boolean := False;
-- unspecified
Reserved_5_6 : HAL.UInt2 := 16#0#;
-- IOPHSMEN
IOPHSMEN : Boolean := True;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for IOPSMEN_Register use record
IOPASMEN at 0 range 0 .. 0;
IOPBSMEN at 0 range 1 .. 1;
IOPCSMEN at 0 range 2 .. 2;
IOPDSMEN at 0 range 3 .. 3;
IOPESMEN at 0 range 4 .. 4;
Reserved_5_6 at 0 range 5 .. 6;
IOPHSMEN at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-- AHB peripheral clock enable in sleep mode register
type AHBSMENR_Register is record
-- DMA clock enable during sleep mode bit
DMASMEN : Boolean := True;
-- unspecified
Reserved_1_7 : HAL.UInt7 := 16#0#;
-- NVM interface clock enable during sleep mode bit
MIFSMEN : Boolean := True;
-- SRAM interface clock enable during sleep mode bit
SRAMSMEN : Boolean := True;
-- unspecified
Reserved_10_11 : HAL.UInt2 := 16#0#;
-- CRC clock enable during sleep mode bit
CRCSMEN : Boolean := True;
-- unspecified
Reserved_13_15 : HAL.UInt3 := 16#0#;
-- Touch Sensing clock enable during sleep mode bit
TOUCHSMEN : Boolean := True;
-- unspecified
Reserved_17_19 : HAL.UInt3 := 16#0#;
-- Random Number Generator clock enable during sleep mode bit
RNGSMEN : Boolean := True;
-- unspecified
Reserved_21_23 : HAL.UInt3 := 16#0#;
-- Crypto clock enable during sleep mode bit
CRYPSMEN : Boolean := True;
-- unspecified
Reserved_25_31 : HAL.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for AHBSMENR_Register use record
DMASMEN at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
MIFSMEN at 0 range 8 .. 8;
SRAMSMEN at 0 range 9 .. 9;
Reserved_10_11 at 0 range 10 .. 11;
CRCSMEN at 0 range 12 .. 12;
Reserved_13_15 at 0 range 13 .. 15;
TOUCHSMEN at 0 range 16 .. 16;
Reserved_17_19 at 0 range 17 .. 19;
RNGSMEN at 0 range 20 .. 20;
Reserved_21_23 at 0 range 21 .. 23;
CRYPSMEN at 0 range 24 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
-- APB2 peripheral clock enable in sleep mode register
type APB2SMENR_Register is record
-- System configuration controller clock enable during sleep mode bit
SYSCFGSMEN : Boolean := True;
-- unspecified
Reserved_1_1 : HAL.Bit := 16#0#;
-- TIM21 timer clock enable during sleep mode bit
TIM21SMEN : Boolean := True;
-- unspecified
Reserved_3_4 : HAL.UInt2 := 16#0#;
-- TIM22 timer clock enable during sleep mode bit
TIM22SMEN : Boolean := True;
-- unspecified
Reserved_6_8 : HAL.UInt3 := 16#0#;
-- ADC clock enable during sleep mode bit
ADCSMEN : Boolean := True;
-- unspecified
Reserved_10_11 : HAL.UInt2 := 16#0#;
-- SPI1 clock enable during sleep mode bit
SPI1SMEN : Boolean := True;
-- unspecified
Reserved_13_13 : HAL.Bit := 16#0#;
-- USART1 clock enable during sleep mode bit
USART1SMEN : Boolean := True;
-- unspecified
Reserved_15_21 : HAL.UInt7 := 16#0#;
-- DBG clock enable during sleep mode bit
DBGSMEN : Boolean := True;
-- unspecified
Reserved_23_31 : HAL.UInt9 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for APB2SMENR_Register use record
SYSCFGSMEN at 0 range 0 .. 0;
Reserved_1_1 at 0 range 1 .. 1;
TIM21SMEN at 0 range 2 .. 2;
Reserved_3_4 at 0 range 3 .. 4;
TIM22SMEN at 0 range 5 .. 5;
Reserved_6_8 at 0 range 6 .. 8;
ADCSMEN at 0 range 9 .. 9;
Reserved_10_11 at 0 range 10 .. 11;
SPI1SMEN at 0 range 12 .. 12;
Reserved_13_13 at 0 range 13 .. 13;
USART1SMEN at 0 range 14 .. 14;
Reserved_15_21 at 0 range 15 .. 21;
DBGSMEN at 0 range 22 .. 22;
Reserved_23_31 at 0 range 23 .. 31;
end record;
-- APB1 peripheral clock enable in sleep mode register
type APB1SMENR_Register is record
-- Timer2 clock enable during sleep mode bit
TIM2SMEN : Boolean := True;
-- Timer3 clock enable during Sleep mode bit
TIM3SMEN : Boolean := False;
-- unspecified
Reserved_2_3 : HAL.UInt2 := 16#0#;
-- Timer 6 clock enable during sleep mode bit
TIM6SMEN : Boolean := True;
-- Timer 7 clock enable during Sleep mode bit
TIM7SMEN : Boolean := False;
-- unspecified
Reserved_6_10 : HAL.UInt5 := 16#8#;
-- Window watchdog clock enable during sleep mode bit
WWDGSMEN : Boolean := True;
-- unspecified
Reserved_12_13 : HAL.UInt2 := 16#0#;
-- SPI2 clock enable during sleep mode bit
SPI2SMEN : Boolean := True;
-- unspecified
Reserved_15_16 : HAL.UInt2 := 16#0#;
-- UART2 clock enable during sleep mode bit
USART2SMEN : Boolean := True;
-- LPUART1 clock enable during sleep mode bit
LPUART1SMEN : Boolean := True;
-- USART4 clock enable during Sleep mode bit
USART4SMEN : Boolean := False;
-- USART5 clock enable during Sleep mode bit
USART5SMEN : Boolean := False;
-- I2C1 clock enable during sleep mode bit
I2C1SMEN : Boolean := True;
-- I2C2 clock enable during sleep mode bit
I2C2SMEN : Boolean := True;
-- USB clock enable during sleep mode bit
USBSMEN : Boolean := True;
-- unspecified
Reserved_24_26 : HAL.UInt3 := 16#0#;
-- Clock recovery system clock enable during sleep mode bit
CRSSMEN : Boolean := True;
-- Power interface clock enable during sleep mode bit
PWRSMEN : Boolean := True;
-- DAC interface clock enable during sleep mode bit
DACSMEN : Boolean := True;
-- 2C3 clock enable during Sleep mode bit
I2C3SMEN : Boolean := False;
-- Low power timer clock enable during sleep mode bit
LPTIM1SMEN : Boolean := True;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for APB1SMENR_Register use record
TIM2SMEN at 0 range 0 .. 0;
TIM3SMEN at 0 range 1 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
TIM6SMEN at 0 range 4 .. 4;
TIM7SMEN at 0 range 5 .. 5;
Reserved_6_10 at 0 range 6 .. 10;
WWDGSMEN at 0 range 11 .. 11;
Reserved_12_13 at 0 range 12 .. 13;
SPI2SMEN at 0 range 14 .. 14;
Reserved_15_16 at 0 range 15 .. 16;
USART2SMEN at 0 range 17 .. 17;
LPUART1SMEN at 0 range 18 .. 18;
USART4SMEN at 0 range 19 .. 19;
USART5SMEN at 0 range 20 .. 20;
I2C1SMEN at 0 range 21 .. 21;
I2C2SMEN at 0 range 22 .. 22;
USBSMEN at 0 range 23 .. 23;
Reserved_24_26 at 0 range 24 .. 26;
CRSSMEN at 0 range 27 .. 27;
PWRSMEN at 0 range 28 .. 28;
DACSMEN at 0 range 29 .. 29;
I2C3SMEN at 0 range 30 .. 30;
LPTIM1SMEN at 0 range 31 .. 31;
end record;
-- CCIPR_USART1SEL array
type CCIPR_USART1SEL_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for CCIPR_USART1SEL
type CCIPR_USART1SEL_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- USART1SEL as a value
Val : HAL.UInt2;
when True =>
-- USART1SEL as an array
Arr : CCIPR_USART1SEL_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for CCIPR_USART1SEL_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- CCIPR_USART2SEL array
type CCIPR_USART2SEL_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for CCIPR_USART2SEL
type CCIPR_USART2SEL_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- USART2SEL as a value
Val : HAL.UInt2;
when True =>
-- USART2SEL as an array
Arr : CCIPR_USART2SEL_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for CCIPR_USART2SEL_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- CCIPR_LPUART1SEL array
type CCIPR_LPUART1SEL_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for CCIPR_LPUART1SEL
type CCIPR_LPUART1SEL_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- LPUART1SEL as a value
Val : HAL.UInt2;
when True =>
-- LPUART1SEL as an array
Arr : CCIPR_LPUART1SEL_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for CCIPR_LPUART1SEL_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- CCIPR_I2C1SEL array
type CCIPR_I2C1SEL_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for CCIPR_I2C1SEL
type CCIPR_I2C1SEL_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- I2C1SEL as a value
Val : HAL.UInt2;
when True =>
-- I2C1SEL as an array
Arr : CCIPR_I2C1SEL_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for CCIPR_I2C1SEL_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
subtype CCIPR_I2C3SEL_Field is HAL.UInt2;
-- CCIPR_LPTIM1SEL array
type CCIPR_LPTIM1SEL_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for CCIPR_LPTIM1SEL
type CCIPR_LPTIM1SEL_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- LPTIM1SEL as a value
Val : HAL.UInt2;
when True =>
-- LPTIM1SEL as an array
Arr : CCIPR_LPTIM1SEL_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for CCIPR_LPTIM1SEL_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Clock configuration register
type CCIPR_Register is record
-- USART1SEL0
USART1SEL : CCIPR_USART1SEL_Field :=
(As_Array => False, Val => 16#0#);
-- USART2SEL0
USART2SEL : CCIPR_USART2SEL_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_4_9 : HAL.UInt6 := 16#0#;
-- LPUART1SEL0
LPUART1SEL : CCIPR_LPUART1SEL_Field :=
(As_Array => False, Val => 16#0#);
-- I2C1SEL0
I2C1SEL : CCIPR_I2C1SEL_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_14_15 : HAL.UInt2 := 16#0#;
-- I2C3 clock source selection bits
I2C3SEL : CCIPR_I2C3SEL_Field := 16#0#;
-- LPTIM1SEL0
LPTIM1SEL : CCIPR_LPTIM1SEL_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_20_25 : HAL.UInt6 := 16#0#;
-- 48 MHz HSI48 clock source selection bit
HSI48MSEL : Boolean := False;
-- unspecified
Reserved_27_31 : HAL.UInt5 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCIPR_Register use record
USART1SEL at 0 range 0 .. 1;
USART2SEL at 0 range 2 .. 3;
Reserved_4_9 at 0 range 4 .. 9;
LPUART1SEL at 0 range 10 .. 11;
I2C1SEL at 0 range 12 .. 13;
Reserved_14_15 at 0 range 14 .. 15;
I2C3SEL at 0 range 16 .. 17;
LPTIM1SEL at 0 range 18 .. 19;
Reserved_20_25 at 0 range 20 .. 25;
HSI48MSEL at 0 range 26 .. 26;
Reserved_27_31 at 0 range 27 .. 31;
end record;
subtype CSR_LSEDRV_Field is HAL.UInt2;
subtype CSR_RTCSEL_Field is HAL.UInt2;
-- Control and status register
type CSR_Register is record
-- Internal low-speed oscillator enable
LSION : Boolean := False;
-- Internal low-speed oscillator ready bit
LSIRDY : Boolean := False;
-- unspecified
Reserved_2_7 : HAL.UInt6 := 16#0#;
-- External low-speed oscillator enable bit
LSEON : Boolean := False;
-- Read-only. External low-speed oscillator ready bit
LSERDY : Boolean := False;
-- External low-speed oscillator bypass bit
LSEBYP : Boolean := False;
-- LSEDRV
LSEDRV : CSR_LSEDRV_Field := 16#0#;
-- CSSLSEON
CSSLSEON : Boolean := False;
-- CSS on LSE failure detection flag
CSSLSED : Boolean := False;
-- unspecified
Reserved_15_15 : HAL.Bit := 16#0#;
-- RTC and LCD clock source selection bits
RTCSEL : CSR_RTCSEL_Field := 16#0#;
-- RTC clock enable bit
RTCEN : Boolean := False;
-- RTC software reset bit
RTCRST : Boolean := False;
-- unspecified
Reserved_20_23 : HAL.UInt4 := 16#0#;
-- Remove reset flag
RMVF : Boolean := False;
-- OBLRSTF
OBLRSTF : Boolean := False;
-- PIN reset flag
PINRSTF : Boolean := True;
-- POR/PDR reset flag
PORRSTF : Boolean := True;
-- Software reset flag
SFTRSTF : Boolean := False;
-- Independent watchdog reset flag
IWDGRSTF : Boolean := False;
-- Window watchdog reset flag
WWDGRSTF : Boolean := False;
-- Low-power reset flag
LPWRSTF : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CSR_Register use record
LSION at 0 range 0 .. 0;
LSIRDY at 0 range 1 .. 1;
Reserved_2_7 at 0 range 2 .. 7;
LSEON at 0 range 8 .. 8;
LSERDY at 0 range 9 .. 9;
LSEBYP at 0 range 10 .. 10;
LSEDRV at 0 range 11 .. 12;
CSSLSEON at 0 range 13 .. 13;
CSSLSED at 0 range 14 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
RTCSEL at 0 range 16 .. 17;
RTCEN at 0 range 18 .. 18;
RTCRST at 0 range 19 .. 19;
Reserved_20_23 at 0 range 20 .. 23;
RMVF at 0 range 24 .. 24;
OBLRSTF at 0 range 25 .. 25;
PINRSTF at 0 range 26 .. 26;
PORRSTF at 0 range 27 .. 27;
SFTRSTF at 0 range 28 .. 28;
IWDGRSTF at 0 range 29 .. 29;
WWDGRSTF at 0 range 30 .. 30;
LPWRSTF at 0 range 31 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Reset and clock control
type RCC_Peripheral is record
-- Clock control register
CR : aliased CR_Register;
-- Internal clock sources calibration register
ICSCR : aliased ICSCR_Register;
-- Clock recovery RC register
CRRCR : aliased CRRCR_Register;
-- Clock configuration register
CFGR : aliased CFGR_Register;
-- Clock interrupt enable register
CIER : aliased CIER_Register;
-- Clock interrupt flag register
CIFR : aliased CIFR_Register;
-- Clock interrupt clear register
CICR : aliased CICR_Register;
-- GPIO reset register
IOPRSTR : aliased IOPRSTR_Register;
-- AHB peripheral reset register
AHBRSTR : aliased AHBRSTR_Register;
-- APB2 peripheral reset register
APB2RSTR : aliased APB2RSTR_Register;
-- APB1 peripheral reset register
APB1RSTR : aliased APB1RSTR_Register;
-- GPIO clock enable register
IOPENR : aliased IOPENR_Register;
-- AHB peripheral clock enable register
AHBENR : aliased AHBENR_Register;
-- APB2 peripheral clock enable register
APB2ENR : aliased APB2ENR_Register;
-- APB1 peripheral clock enable register
APB1ENR : aliased APB1ENR_Register;
-- GPIO clock enable in sleep mode register
IOPSMEN : aliased IOPSMEN_Register;
-- AHB peripheral clock enable in sleep mode register
AHBSMENR : aliased AHBSMENR_Register;
-- APB2 peripheral clock enable in sleep mode register
APB2SMENR : aliased APB2SMENR_Register;
-- APB1 peripheral clock enable in sleep mode register
APB1SMENR : aliased APB1SMENR_Register;
-- Clock configuration register
CCIPR : aliased CCIPR_Register;
-- Control and status register
CSR : aliased CSR_Register;
end record
with Volatile;
for RCC_Peripheral use record
CR at 16#0# range 0 .. 31;
ICSCR at 16#4# range 0 .. 31;
CRRCR at 16#8# range 0 .. 31;
CFGR at 16#C# range 0 .. 31;
CIER at 16#10# range 0 .. 31;
CIFR at 16#14# range 0 .. 31;
CICR at 16#18# range 0 .. 31;
IOPRSTR at 16#1C# range 0 .. 31;
AHBRSTR at 16#20# range 0 .. 31;
APB2RSTR at 16#24# range 0 .. 31;
APB1RSTR at 16#28# range 0 .. 31;
IOPENR at 16#2C# range 0 .. 31;
AHBENR at 16#30# range 0 .. 31;
APB2ENR at 16#34# range 0 .. 31;
APB1ENR at 16#38# range 0 .. 31;
IOPSMEN at 16#3C# range 0 .. 31;
AHBSMENR at 16#40# range 0 .. 31;
APB2SMENR at 16#44# range 0 .. 31;
APB1SMENR at 16#48# range 0 .. 31;
CCIPR at 16#4C# range 0 .. 31;
CSR at 16#50# range 0 .. 31;
end record;
-- Reset and clock control
RCC_Periph : aliased RCC_Peripheral
with Import, Address => System'To_Address (16#40021000#);
end STM32_SVD.RCC;
|
30,408
|
ada
| 1
|
faelys/natools-web
|
generated/natools-static_maps-web-error_pages-commands.ads
|
package Natools.Static_Maps.Web.Error_Pages.Commands is
pragma Pure;
function Hash (S : String) return Natural;
end Natools.Static_Maps.Web.Error_Pages.Commands;
|
30,409
|
ada
| 7
|
best08618/asylo
|
gcc-gcc-7_3_0-release/gcc/ada/s-vxwext-kernel.adb
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . V X W O R K S . E X T --
-- --
-- B o d y --
-- --
-- Copyright (C) 2008-2015, Free Software Foundation, Inc. --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. 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 vxworks specific support functions needed
-- by System.OS_Interface.
-- This is the VxWorks <= 6.5 kernel version of this package
-- Also works for 6.6 uniprocessor
package body System.VxWorks.Ext is
ERROR : constant := -1;
--------------
-- Int_Lock --
--------------
function intLock return int;
pragma Import (C, intLock, "intLock");
function Int_Lock return int renames intLock;
----------------
-- Int_Unlock --
----------------
function intUnlock (Old : int) return int;
pragma Import (C, intUnlock, "intUnlock");
function Int_Unlock (Old : int) return int renames intUnlock;
---------------
-- semDelete --
---------------
function semDelete (Sem : SEM_ID) return int is
function Os_Sem_Delete (Sem : SEM_ID) return int;
pragma Import (C, Os_Sem_Delete, "semDelete");
begin
return Os_Sem_Delete (Sem);
end semDelete;
------------------------
-- taskCpuAffinitySet --
------------------------
function taskCpuAffinitySet (tid : t_id; CPU : int) return int is
pragma Unreferenced (tid, CPU);
begin
return ERROR;
end taskCpuAffinitySet;
-------------------------
-- taskMaskAffinitySet --
-------------------------
function taskMaskAffinitySet (tid : t_id; CPU_Set : unsigned) return int is
pragma Unreferenced (tid, CPU_Set);
begin
return ERROR;
end taskMaskAffinitySet;
--------------
-- taskCont --
--------------
function Task_Cont (tid : t_id) return int is
function taskCont (tid : t_id) return int;
pragma Import (C, taskCont, "taskCont");
begin
return taskCont (tid);
end Task_Cont;
--------------
-- taskStop --
--------------
function Task_Stop (tid : t_id) return int is
function taskStop (tid : t_id) return int;
pragma Import (C, taskStop, "taskStop");
begin
return taskStop (tid);
end Task_Stop;
end System.VxWorks.Ext;
|
30,410
|
ada
| 0
|
stevancorre/advent-of-code-2021
|
day-01/solve_part_2.adb
|
<filename>day-01/solve_part_2.adb
with Solve; use Solve;
with Ada.Text_IO; use Ada.Text_IO;
procedure Solve_Part_2 is
Input_File : File_Type;
A : Integer;
B : Integer;
C : Integer;
Previous_Sum : Integer := 16#7FFF_FFFF#;
Answer : Integer := 0;
begin
Open (Input_File, In_File, "input.txt");
A := Get_Line_Integer (Input_File);
B := Get_Line_Integer (Input_File);
C := Get_Line_Integer (Input_File);
loop
if A + B + C > Previous_Sum then
Answer := Answer + 1;
end if;
exit when End_Of_File (Input_File);
Previous_Sum := A + B + C;
A := B;
B := C;
C := Get_Line_Integer (Input_File);
end loop;
Put ("ANSWER:" & Integer'Image (Answer));
New_Line;
Close (Input_File);
end Solve_Part_2;
|
30,411
|
ada
| 2
|
skordal/ada-regex
|
src/regex.ads
|
-- Ada regular expression library
-- (c) <NAME> 2020 <<EMAIL>>
-- Report bugs and issues on <https://github.com/skordal/ada-regex>
package Regex is
pragma Pure;
-- Main package for the regular expression library.
-- Include Regex.Regular_Expressions to get the main library functionality.
end Regex;
|
30,412
|
ada
| 15
|
My-Colaborations/dynamo
|
src/gnat/prj-ext.adb
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- P R J . E X T --
-- --
-- B o d y --
-- --
-- Copyright (C) 2000-2013, 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. --
-- --
------------------------------------------------------------------------------
with Osint; use Osint;
with Ada.Unchecked_Deallocation;
package body Prj.Ext is
----------------
-- Initialize --
----------------
procedure Initialize
(Self : out External_References;
Copy_From : External_References := No_External_Refs)
is
N : Name_To_Name_Ptr;
N2 : Name_To_Name_Ptr;
begin
if Self.Refs = null then
Self.Refs := new Name_To_Name_HTable.Instance;
if Copy_From.Refs /= null then
N := Name_To_Name_HTable.Get_First (Copy_From.Refs.all);
while N /= null loop
N2 := new Name_To_Name'
(Key => N.Key,
Value => N.Value,
Source => N.Source,
Next => null);
Name_To_Name_HTable.Set (Self.Refs.all, N2);
N := Name_To_Name_HTable.Get_Next (Copy_From.Refs.all);
end loop;
end if;
end if;
end Initialize;
---------
-- Add --
---------
procedure Add
(Self : External_References;
External_Name : String;
Value : String;
Source : External_Source := External_Source'First;
Silent : Boolean := False)
is
Key : Name_Id;
N : Name_To_Name_Ptr;
begin
-- For external attribute, set the environment variable
if Source = From_External_Attribute and then External_Name /= "" then
declare
Env_Var : String_Access := Getenv (External_Name);
begin
if Env_Var = null or else Env_Var.all = "" then
Setenv (Name => External_Name, Value => Value);
if not Silent then
Debug_Output
("Environment variable """ & External_Name
& """ = """ & Value & '"');
end if;
elsif not Silent then
Debug_Output
("Not overriding existing environment variable """
& External_Name & """, value is """ & Env_Var.all & '"');
end if;
Free (Env_Var);
end;
end if;
Name_Len := External_Name'Length;
Name_Buffer (1 .. Name_Len) := External_Name;
Canonical_Case_Env_Var_Name (Name_Buffer (1 .. Name_Len));
Key := Name_Find;
-- Check whether the value is already defined, to properly respect the
-- overriding order.
if Source /= External_Source'First then
N := Name_To_Name_HTable.Get (Self.Refs.all, Key);
if N /= null then
if External_Source'Pos (N.Source) <
External_Source'Pos (Source)
then
if not Silent then
Debug_Output
("Not overridding existing external reference '"
& External_Name & "', value was defined in "
& N.Source'Img);
end if;
return;
end if;
end if;
end if;
Name_Len := Value'Length;
Name_Buffer (1 .. Name_Len) := Value;
N := new Name_To_Name'
(Key => Key,
Source => Source,
Value => Name_Find,
Next => null);
if not Silent then
Debug_Output ("Add external (" & External_Name & ") is", N.Value);
end if;
Name_To_Name_HTable.Set (Self.Refs.all, N);
end Add;
-----------
-- Check --
-----------
function Check
(Self : External_References;
Declaration : String) return Boolean
is
begin
for Equal_Pos in Declaration'Range loop
if Declaration (Equal_Pos) = '=' then
exit when Equal_Pos = Declaration'First;
Add
(Self => Self,
External_Name =>
Declaration (Declaration'First .. Equal_Pos - 1),
Value =>
Declaration (Equal_Pos + 1 .. Declaration'Last),
Source => From_Command_Line);
return True;
end if;
end loop;
return False;
end Check;
-----------
-- Reset --
-----------
procedure Reset (Self : External_References) is
begin
if Self.Refs /= null then
Debug_Output ("Reset external references");
Name_To_Name_HTable.Reset (Self.Refs.all);
end if;
end Reset;
--------------
-- Value_Of --
--------------
function Value_Of
(Self : External_References;
External_Name : Name_Id;
With_Default : Name_Id := No_Name)
return Name_Id
is
Value : Name_To_Name_Ptr;
Val : Name_Id;
Name : String := Get_Name_String (External_Name);
begin
Canonical_Case_Env_Var_Name (Name);
if Self.Refs /= null then
Name_Len := Name'Length;
Name_Buffer (1 .. Name_Len) := Name;
Value := Name_To_Name_HTable.Get (Self.Refs.all, Name_Find);
if Value /= null then
Debug_Output ("Value_Of (" & Name & ") is in cache", Value.Value);
return Value.Value;
end if;
end if;
-- Find if it is an environment, if it is, put value in the hash table
declare
Env_Value : String_Access := Getenv (Name);
begin
if Env_Value /= null and then Env_Value'Length > 0 then
Name_Len := Env_Value'Length;
Name_Buffer (1 .. Name_Len) := Env_Value.all;
Val := Name_Find;
if Current_Verbosity = High then
Debug_Output ("Value_Of (" & Name & ") is", Val);
end if;
if Self.Refs /= null then
Value := new Name_To_Name'
(Key => External_Name,
Value => Val,
Source => From_Environment,
Next => null);
Name_To_Name_HTable.Set (Self.Refs.all, Value);
end if;
Free (Env_Value);
return Val;
else
if Current_Verbosity = High then
Debug_Output
("Value_Of (" & Name & ") is default", With_Default);
end if;
Free (Env_Value);
return With_Default;
end if;
end;
end Value_Of;
----------
-- Free --
----------
procedure Free (Self : in out External_References) is
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Name_To_Name_HTable.Instance, Instance_Access);
begin
if Self.Refs /= null then
Reset (Self);
Unchecked_Free (Self.Refs);
end if;
end Free;
--------------
-- Set_Next --
--------------
procedure Set_Next (E : Name_To_Name_Ptr; Next : Name_To_Name_Ptr) is
begin
E.Next := Next;
end Set_Next;
----------
-- Next --
----------
function Next (E : Name_To_Name_Ptr) return Name_To_Name_Ptr is
begin
return E.Next;
end Next;
-------------
-- Get_Key --
-------------
function Get_Key (E : Name_To_Name_Ptr) return Name_Id is
begin
return E.Key;
end Get_Key;
end Prj.Ext;
|
30,413
|
ada
| 10
|
Ada-Audio/wavefiles
|
src/audio-riff-wav-formats.adb
|
------------------------------------------------------------------------------
-- --
-- AUDIO / RIFF / WAV --
-- --
-- RIFF format information for wavefiles --
-- --
-- The MIT License (MIT) --
-- --
-- Copyright (c) 2015 -- 2020 <NAME> --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining --
-- a copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, sublicense, and / or sell copies of the Software, and to --
-- permit persons to whom the Software is furnished to do so, subject to --
-- the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be --
-- included in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, --
-- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY --
-- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, --
-- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE --
-- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
------------------------------------------------------------------------------
with Audio.RIFF.Wav.GUIDs;
with Audio.RIFF.Wav.Formats.Standard_Channel_Configurations;
package body Audio.RIFF.Wav.Formats is
type Channel_Configuration_Integer is mod 2 ** Channel_Configuration_Size;
------------------------
-- To_RIFF_Identifier --
------------------------
function To_RIFF_Identifier (FOURCC : FOURCC_String) return RIFF_Identifier
is
begin
if FOURCC = "RIFF" then return RIFF_Identifier_Standard;
elsif FOURCC = "RIFX" then return RIFF_Identifier_Big_Endian;
elsif FOURCC = "LIST" then return RIFF_Identifier_List;
elsif FOURCC = "RF64" then return RIFF_Identifier_RIFF_64;
elsif FOURCC = "BW64" then return RIFF_Identifier_Broadcast_Wave_64;
else return RIFF_Identifier_Unknown;
end if;
end To_RIFF_Identifier;
--------------------
-- To_RIFF_Format --
--------------------
function To_RIFF_Format (FOURCC : FOURCC_String) return RIFF_Format is
begin
if FOURCC = "WAVE" then return RIFF_Format_Wave;
elsif FOURCC = "AVI " then return RIFF_Format_AVI;
elsif FOURCC = "MIDI" then return RIFF_Format_MIDI;
elsif FOURCC = "PAL " then return RIFF_Format_Pallete;
elsif FOURCC = "RDIB" then return RIFF_Format_DIB;
elsif FOURCC = "RMMP" then return RIFF_Format_MMP;
else return RIFF_Format_Unknown;
end if;
end To_RIFF_Format;
----------------------
-- To_Wav_Chunk_Tag --
----------------------
function To_Wav_Chunk_Tag (FOURCC : FOURCC_String) return Wav_Chunk_Tag is
begin
if FOURCC = "fmt " then return Wav_Chunk_Fmt;
elsif FOURCC = "data" then return Wav_Chunk_Data;
elsif FOURCC = "INFO" then return Wav_Chunk_Info;
elsif FOURCC = "JUNK" then return Wav_Chunk_Junk;
elsif FOURCC = "PAD " then return Wav_Chunk_Pad;
elsif FOURCC = "fact" then return Wav_Chunk_Fact;
elsif FOURCC = "cue " then return Wav_Chunk_Cue;
elsif FOURCC = "wavl" then return Wav_Chunk_Wave_List;
elsif FOURCC = "slnt" then return Wav_Chunk_Silent;
elsif FOURCC = "plst" then return Wav_Chunk_Playlist;
elsif FOURCC = "list" then return Wav_Chunk_Associated_Data_List;
elsif FOURCC = "labl" then return Wav_Chunk_Label;
elsif FOURCC = "ltxt" then return Wav_Chunk_Labeled_Text;
elsif FOURCC = "note" then return Wav_Chunk_Note;
elsif FOURCC = "smpl" then return Wav_Chunk_Sample;
elsif FOURCC = "inst" then return Wav_Chunk_Instrument;
elsif FOURCC = "bext" then return Wav_Chunk_Broadcast_Extension;
elsif FOURCC = "iXML" then return Wav_Chunk_IXML;
elsif FOURCC = "axml" then return Wav_Chunk_AXML;
elsif FOURCC = "qlty" then return Wav_Chunk_Quality;
elsif FOURCC = "mext" then return Wav_Chunk_MPEG_Audio_Extension;
elsif FOURCC = "levl" then return Wav_Chunk_Peak_Envelope;
elsif FOURCC = "link" then return Wav_Chunk_Link;
elsif FOURCC = "ds64" then return Wav_Chunk_Data_Size_64;
elsif FOURCC = "bxml" then return
Wav_Chunk_Compressed_Broadcast_Extension;
elsif FOURCC = "sxml" then return Wav_Chunk_Sound_Related_XML;
elsif FOURCC = "chna" then return Wav_Chunk_Channel_Info;
else return Wav_Chunk_Unknown;
end if;
end To_Wav_Chunk_Tag;
-------------
-- Default --
-------------
function Default return Wave_Format_16 is
begin
return W : Wave_Format_16 do
W.Format_Tag := Wav_Format_PCM;
W.Channels := 2;
W.Samples_Per_Sec := Sample_Rate_44100;
W.Bits_Per_Sample := Bit_Depth_16;
W.Block_Align := ((To_Unsigned_16 (W.Bits_Per_Sample) + 7)
/ 8) * W.Channels;
W.Avg_Bytes_Per_Sec := 0;
end return;
end Default;
-------------
-- Default --
-------------
overriding function Default return Wave_Format_18 is
begin
return W : Wave_Format_18 do
Wave_Format_16 (W) := Default;
W.Size := 0;
end return;
end Default;
-------------
-- Default --
-------------
overriding function Default return Wave_Format_Extensible is
use Audio.RIFF.Wav.GUIDs;
use Audio.RIFF.Wav.Formats.Standard_Channel_Configurations;
begin
return W : Wave_Format_Extensible do
Wave_Format_18 (W) := Default;
W.Size := 22;
W.Valid_Bits_Per_Sample := To_Unsigned_16 (W.Bits_Per_Sample);
W.Sub_Format := GUID_Undefined;
W.Channel_Config := Channel_Config_2_0;
end return;
end Default;
------------------------------
-- Reset_For_Wave_Format_16 --
------------------------------
procedure Reset_For_Wave_Format_16 (W : in out Wave_Format_Extensible) is
begin
W.Size := 0;
Reset_For_Wave_Format_18 (W);
end Reset_For_Wave_Format_16;
------------------------------
-- Reset_For_Wave_Format_18 --
------------------------------
procedure Reset_For_Wave_Format_18 (W : in out Wave_Format_Extensible) is
use Audio.RIFF.Wav.GUIDs;
use Audio.RIFF.Wav.Formats.Standard_Channel_Configurations;
begin
W.Valid_Bits_Per_Sample := To_Unsigned_16 (W.Bits_Per_Sample);
W.Sub_Format := GUID_Undefined;
W.Channel_Config := Channel_Config_Empty;
end Reset_For_Wave_Format_18;
-------------
-- To_GUID --
-------------
function To_GUID (Format : Wav_Format_Tag) return GUID is
use Audio.RIFF.Wav.GUIDs;
begin
case Format is
when Wav_Format_PCM => return GUID_PCM;
when Wav_Format_IEEE_Float => return GUID_IEEE_Float;
when Wav_Format_A_Law => return GUID_ALAW;
when Wav_Format_Mu_Law => return GUID_MULAW;
when Wav_Format_ADPCM => return GUID_ADPCM;
when Wav_Format_MPEG => return GUID_MPEG;
when Wav_Format_Dolby_AC3_SPDIF => return GUID_DOLBY_AC3_SPDIF;
when Wav_Format_MPEG_Layer_3 => return GUID_MPEG_LAYER_3;
when others => return GUID_Undefined;
end case;
end To_GUID;
-----------------------
-- To_Wav_Format_Tag --
-----------------------
function To_Wav_Format_Tag (ID : GUID) return Wav_Format_Tag is
use Audio.RIFF.Wav.GUIDs;
begin
if ID = GUID_Undefined then
return Wav_Format_Unknown;
elsif ID = GUID_PCM then
return Wav_Format_PCM;
elsif ID = GUID_IEEE_Float then
return Wav_Format_IEEE_Float;
-- elsif ID = GUID_DRM then
-- return Wav_Format_Unknown;
elsif ID = GUID_ALAW then
return Wav_Format_A_Law;
elsif ID = GUID_MULAW then
return Wav_Format_Mu_Law;
elsif ID = GUID_ADPCM then
return Wav_Format_ADPCM;
elsif ID = GUID_MPEG then
return Wav_Format_MPEG;
elsif ID = GUID_DOLBY_AC3_SPDIF then
return Wav_Format_Dolby_AC3_SPDIF;
-- elsif ID = GUID_WMA_SPDIF then
-- return Wav_Format_Unknown;
-- elsif ID = GUID_DTS then
-- return Wav_Format_Unknown;
elsif ID = GUID_MPEG_LAYER_3 then
return Wav_Format_MPEG_Layer_3;
-- elsif ID = GUID_MPEG_HE_AAC then
-- return Wav_Format_Unknown
-- elsif ID = GUID_WMA_2 then
-- return Wav_Format_Unknown;
-- elsif ID = GUID_WMA_3 then
-- return Wav_Format_Unknown;
-- elsif ID = GUID_WMA_LOSSLESS then
-- return Wav_Format_Unknown;
else
return Wav_Format_Unknown;
end if;
end To_Wav_Format_Tag;
-------------------
-- Is_Consistent --
-------------------
function Is_Consistent
(Channel_Config : Channel_Configuration;
Number_Of_Channels : Positive) return Boolean
is
Counted_Channels : Natural := 0;
begin
for Channel_Is_Active of Channel_Config loop
if Channel_Is_Active then
Counted_Channels := Counted_Channels + 1;
end if;
end loop;
return Number_Of_Channels = Counted_Channels;
end Is_Consistent;
----------------------------------
-- Should_Use_Extensible_Format --
----------------------------------
function Should_Use_Extensible_Format
(Bit_Depth : Wav_Bit_Depth;
Number_Of_Channels : Positive) return Boolean is
begin
if Bit_Depth not in Bit_Depth_8 | Bit_Depth_16 then
return True;
elsif Number_Of_Channels > 2 then
return True;
else
return False;
end if;
end Should_Use_Extensible_Format;
-----------------
-- Block_Align --
-----------------
function Block_Align
(Bit_Depth : Wav_Bit_Depth;
Number_Of_Channels : Positive) return Unsigned_16 is
(((To_Unsigned_16 (Bit_Depth) + 7) / 8)
* Unsigned_16 (Number_Of_Channels));
------------------------------
-- Average_Bytes_Per_Second --
------------------------------
function Average_Bytes_Per_Second
(Block_Align : Unsigned_16;
Sample_Rate : Wav_Sample_Rate) return Unsigned_32 is
(Unsigned_32 (Block_Align) * To_Unsigned_32 (Sample_Rate));
----------
-- Init --
----------
function Init
(Bit_Depth : Wav_Bit_Depth;
Sample_Rate : Wav_Sample_Rate;
Number_Of_Channels : Positive;
Use_Float : Boolean := False) return Wave_Format_Extensible
is
Format : constant Wav_Format_Tag
:= (if Use_Float then Wav_Format_IEEE_Float else Wav_Format_PCM);
Use_Wav_Extensible : constant Boolean
:= Should_Use_Extensible_Format (Bit_Depth, Number_Of_Channels);
use Audio.RIFF.Wav.GUIDs;
use Audio.RIFF.Wav.Formats.Standard_Channel_Configurations;
begin
return W : Wave_Format_Extensible do
W.Channels := Unsigned_16 (Number_Of_Channels);
W.Samples_Per_Sec := Sample_Rate;
W.Bits_Per_Sample := Bit_Depth;
W.Block_Align := Block_Align (Bit_Depth, Number_Of_Channels);
W.Avg_Bytes_Per_Sec := Average_Bytes_Per_Second (W.Block_Align,
Sample_Rate);
if not Use_Wav_Extensible then
W.Format_Tag := Format;
W.Size := 0;
W.Valid_Bits_Per_Sample := 0;
W.Sub_Format := GUID_Undefined;
W.Channel_Config := Channel_Config_Empty;
else
W.Size := 22;
W.Valid_Bits_Per_Sample := To_Unsigned_16 (W.Bits_Per_Sample);
W.Channel_Config := Channel_Config_Empty;
Init_Formats : declare
Sub_Format : constant GUID := To_GUID (Format);
begin
if Sub_Format /= GUID_Undefined then
W.Format_Tag := Wav_Format_Extensible;
W.Sub_Format := Sub_Format;
else
W.Format_Tag := Format;
W.Sub_Format := GUID_Undefined;
end if;
end Init_Formats;
end if;
end return;
end Init;
---------------------
-- Is_Float_Format --
---------------------
function Is_Float_Format
(W : Wave_Format_Extensible) return Boolean
is
use Audio.RIFF.Wav.GUIDs;
begin
return W.Format_Tag = Wav_Format_IEEE_Float or
W.Sub_Format = GUID_IEEE_Float;
end Is_Float_Format;
--------------------------------
-- Read_Channel_Configuration --
--------------------------------
procedure Read_Channel_Configuration
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : out Channel_Configuration)
is
V : Channel_Configuration_Integer;
X : Channel_Configuration;
for X'Address use V'Address;
begin
Channel_Configuration_Integer'Read (Stream, V);
Item := X;
end Read_Channel_Configuration;
---------------------------------
-- Write_Channel_Configuration --
---------------------------------
procedure Write_Channel_Configuration
(Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : Channel_Configuration)
is
V : Channel_Configuration_Integer;
X : Channel_Configuration;
for X'Address use V'Address;
begin
X := Item;
Channel_Configuration_Integer'Write (Stream, V);
end Write_Channel_Configuration;
end Audio.RIFF.Wav.Formats;
|
30,414
|
ada
| 0
|
thierr26/ada-apsepp
|
src/_test/harness/apsepp_test_harness.ads
|
<gh_stars>0
-- Copyright (C) 2019 <NAME> <<EMAIL>>
-- MIT license. Please refer to the LICENSE file.
private with Apsepp.Test_Reporter_Class.Instant_Standard,
Apsepp_Test_Suite;
package Apsepp_Test_Harness is
procedure Apsepp_Test_Procedure;
private
use Apsepp.Test_Reporter_Class.Instant_Standard,
Apsepp_Test_Suite;
Reporter : aliased Test_Reporter_Instant_Standard;
Test_Suite : aliased Apsepp_T_S;
end Apsepp_Test_Harness;
|
30,415
|
ada
| 12
|
TUM-EI-RCS/StratoX
|
tests/remainder/src/main.adb
|
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Float_Text_IO;
with Units; use Units;
procedure main with SPARK_Mode is
a : Angle_Type;
w : Angle_Type;
w2 : Angle_Type;
amin : constant Angle_Type := -1.3 * Radian;
amax : constant Angle_Type := 1.3 * Radian;
L : constant Angle_Type := 2.0 * (amax - amin);
STEPS : constant := 10_000;
step : constant Angle_Type := L / 10_000.0;
begin
a := 1.5 * amin;
for k in 1 .. STEPS loop
a := a + step;
w := wrap_Angle (angle => a, min => amin, max => amax);
w2 := wrap_Angle2 (angle => a, min => amin, max => amax);
Ada.Float_Text_IO.Put (Item => Float (a), Aft => 3, Exp => 0);
Put (",");
Ada.Float_Text_IO.Put (Item => Float (w), Aft => 3, Exp => 0);
Put (",");
Ada.Float_Text_IO.Put (Item => Float (w2), Aft => 3, Exp => 0);
declare
err : constant Angle_Type := w2 - w;
begin
Put (",");
Ada.Float_Text_IO.Put (Item => Float (err), Aft => 3, Exp => 0);
end;
New_Line;
end loop;
end main;
|
30,416
|
ada
| 6
|
jquorning/ada-servlet
|
samples/rest/monitor.adb
|
-----------------------------------------------------------------------
-- monitor - A simple monitor API
-- Copyright (C) 2016, 2018, 2021 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- 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 Servlet.Responses;
package body Monitor is
type Monitor_Array is array (1 .. MAX_MONITOR) of Monitor_Data;
Monitors : Monitor_Array;
-- Get values of the monitor.
procedure Get_Values (Req : in out Servlet.Rest.Request'Class;
Reply : in out Servlet.Rest.Response'Class;
Stream : in out Servlet.Rest.Output_Stream'Class) is
Id : constant String := Req.Get_Path_Parameter (1);
Pos : Positive;
begin
Pos := Positive'Value (Id);
-- Monitors (Pos).Put (0);
-- Get the monitor values.
declare
Values : constant Value_Array := Monitors (Pos).Get_Values;
begin
-- Write the JSON/XML document.
Stream.Start_Document;
Stream.Start_Array ("values");
for V of Values loop
Stream.Write_Long_Entity ("value", Long_Long_Integer (V));
end loop;
Stream.End_Array ("values");
Stream.End_Document;
end;
exception
when others =>
Reply.Set_Status (Servlet.Responses.SC_NOT_FOUND);
end Get_Values;
-- PUT /mon/:id
procedure Put_Value (Req : in out Servlet.Rest.Request'Class;
Reply : in out Servlet.Rest.Response'Class;
Stream : in out Servlet.Rest.Output_Stream'Class) is
pragma Unreferenced (Stream);
Id : constant String := Req.Get_Path_Parameter (1);
Pos : Positive;
Val : Natural;
begin
Pos := Positive'Value (Id);
begin
Val := Natural'Value (Req.Get_Parameter ("value"));
Monitors (Pos).Put (Val);
exception
when others =>
Reply.Set_Status (Servlet.Responses.SC_BAD_REQUEST);
end;
exception
when others =>
Reply.Set_Status (Servlet.Responses.SC_NOT_FOUND);
end Put_Value;
protected body Monitor_Data is
procedure Put (Value : in Natural) is
use type Ada.Calendar.Time;
Now : constant Ada.Calendar.Time := Ada.Calendar.Clock;
Dt : constant Duration := Now - Slot_Start;
Cnt : Natural := Natural (Dt / Slot_Size);
begin
if Cnt > 0 then
while Cnt > 0 loop
Cnt := Cnt - 1;
Pos := Pos + 1;
if Pos > Values'Last then
Pos := Values'First;
Value_Count := Values'Length;
elsif Value_Count < Values'Length then
Value_Count := Value_Count + 1;
end if;
Slot_Start := Slot_Start + Slot_Size;
end loop;
end if;
Values (Pos) := Value;
end Put;
procedure Put (Value : in Natural; Slot : in Natural) is
begin
null;
end Put;
function Get_Values return Value_Array is
Result : Value_Array (1 .. Value_Count);
Cnt : Natural;
N : Natural;
begin
if Value_Count = Values'Length then
Cnt := Values'Last - Pos;
else
Cnt := 0;
end if;
if Cnt > 0 then
Result (1 .. Cnt) := Values (Pos + 1 .. Pos + 1 + Cnt - 1);
N := Cnt + 1;
else
N := 1;
end if;
if Value_Count = Values'Length then
Cnt := Pos;
else
Cnt := Pos - 1;
end if;
if Cnt > 0 then
Result (N .. N + Cnt - 1) := Values (1 .. Cnt);
end if;
return Result;
end Get_Values;
end Monitor_Data;
end Monitor;
|
30,417
|
ada
| 7
|
98devin/ada-gba-dev
|
src/GBA.Display.Backgrounds.Refs.ads
|
<reponame>98devin/ada-gba-dev<gh_stars>1-10
-- Copyright (c) 2021 <NAME>
-- zlib License -- see LICENSE for details.
limited with GBA.Refs;
package GBA.Display.Backgrounds.Refs is
type BG_Ref (<>) is abstract tagged limited private;
function ID (This : BG_Ref'Class) return BG_ID
with Inline;
function Priority (This : BG_Ref'Class) return Display_Priority
with Inline;
function Mosaic_Enabled (This : BG_Ref'Class) return Boolean
with Inline;
procedure Set_Priority
(This : in out BG_Ref'Class; Priority : Display_Priority);
procedure Enable_Mosaic
(This : in out BG_Ref'Class; Enable : Boolean := True);
generic
with procedure Update (Control : in out BG_Control_Info);
procedure Update_Control_Info (This : in out BG_Ref'Class);
type Reg_BG_Ref (<>) is new BG_Ref with private;
function Offset (This : Reg_BG_Ref'Class) return BG_Offset_Info
with Inline;
procedure Set_Offset
(This : in out Reg_BG_Ref'Class; Offset : BG_Offset_Info);
procedure Set_Offset
(This : in out Reg_BG_Ref'Class; X, Y : BG_Scroll_Offset)
with Inline_Always;
procedure Set_Offset_X
(This : in out Reg_BG_Ref'Class; Value : BG_Scroll_Offset);
procedure Set_Offset_Y
(This : in out Reg_BG_Ref'Class; Value : BG_Scroll_Offset);
procedure Move_Offset
(This : in out Reg_BG_Ref'Class; DX, DY : BG_Scroll_Offset := 0);
generic
with procedure Update (Offset : in out BG_Offset_Info);
procedure Update_Offset (This : in out Reg_BG_Ref'Class);
type Aff_BG_Ref (<>) is new BG_Ref with private;
function Transform (This : Aff_BG_Ref'Class)
return Affine_Transform_Matrix with Inline;
function Reference_Point (This : Aff_BG_Ref'Class)
return BG_Reference_Point with Inline;
procedure Set_Reference_Point
(This : in out Aff_BG_Ref'Class;
Reference_Point : BG_Reference_Point);
procedure Set_Reference_Point
(This : in out Aff_BG_Ref'Class; X, Y : BG_Reference_Point_Coordinate);
procedure Set_Reference_X
(This : in out Aff_BG_Ref'Class; Value : BG_Reference_Point_Coordinate);
procedure Set_Reference_Y
(This : in out Aff_BG_Ref'Class; Value : BG_Reference_Point_Coordinate);
procedure Move_Reference_Point
(This : in out Aff_BG_Ref'Class; DX, DY : BG_Reference_Point_Coordinate := 0.0);
generic
with procedure Update (Transform : in out BG_Transform_Info);
procedure Update_Transform (This : in out Aff_BG_Ref'Class);
private
type Volatile_BG_Control_Info is
new BG_Control_Info with Volatile;
type BG_Ref (Control : access Volatile_BG_Control_Info) is
tagged limited record
ID : BG_ID;
end record;
type Reg_BG_Ref is new BG_Ref with
record
Offset : BG_Offset_Info;
end record;
type Aff_BG_Ref is new BG_Ref with
record
Transform_Info : BG_Transform_Info;
end record;
end GBA.Display.Backgrounds.Refs;
|
30,418
|
ada
| 0
|
likai3g/afmt
|
src/fmt-generic_float_argument.ads
|
<reponame>likai3g/afmt
generic
type Float_Type is digits <>;
package Fmt.Generic_Float_Argument is
-- float to string
-- https://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/printf.pdf
-- https://github.com/jk-jeon/dragonbox/blob/master/other_files/Dragonbox.pdf
-- Edit format
-- "w=" width
-- "a=" width after decimal point
-- "e=" width of exponent
-- "f=" width before decimal point
function To_Argument (X : Float_Type) return Argument_Type'Class
with Inline;
function "&" (Args : Arguments; X : Float_Type) return Arguments
with Inline;
private
type Float_Argument_Type is new Argument_Type with record
Value : Float_Type;
Width : Natural;
Fore : Natural := 2;
Aft : Natural := Float_Type'Digits - 1;
Exp : Natural := 3;
end record;
overriding
procedure Parse (Self : in out Float_Argument_Type; Edit : String);
overriding
function Get_Length (Self : in out Float_Argument_Type) return Natural;
overriding
procedure Put (
Self : in out Float_Argument_Type;
Edit : String;
To : in out String);
end Fmt.Generic_Float_Argument;
|
30,419
|
ada
| 20
|
charlie5/lace
|
4-high/gel/source/interface/gel-mouse.ads
|
<filename>4-high/gel/source/interface/gel-mouse.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;
|
30,420
|
ada
| 3
|
charlie5/aIDE
|
attic/asis/find_entities/adam-assist-query-find_entities-unit_processing.adb
|
<filename>attic/asis/find_entities/adam-assist-query-find_entities-unit_processing.adb<gh_stars>1-10
with asis.Elements,
asis.Compilation_Units,
AdaM.compilation_Unit,
AdaM.library_Item,
AdaM.library_Unit.declaration,
AdaM.Assist.Query.find_Entities.element_Processing,
AdaM.Assist.Query.find_Entities.Metrics,
Ada.Characters.Handling;
with Ada.Text_IO; use Ada.Text_IO;
package body AdaM.Assist.Query.find_Entities.unit_Processing
is
procedure Process_Unit (The_Unit : Asis.Compilation_Unit)
is
use Asis, ada.Characters.Handling;
Cont_Clause_Elements : constant Asis.Element_List
:= Asis.Elements.Context_Clause_Elements (Compilation_Unit => The_Unit,
Include_Pragmas => True);
-- This is the list of the context clauses, including pragmas, if any.
-- If you do not want to process pragmas, set Include_Pragmas OFF when
-- calling Asis.Elements.Context_Clause_Elements.
Unit_Decl : constant Asis.Element := Asis.Elements.Unit_Declaration (The_Unit);
-- The top-level structural element of the library item or subunit
-- contained in The_Unit.
the_Name : constant String := to_String (asis.Compilation_Units.Unit_Full_Name (The_Unit));
Kind : constant asis.Unit_Kinds := asis.Compilation_Units.Unit_Kind (the_Unit);
begin
-- Metrics.new_Unit := adam.compilation_Unit.new_Unit ("anon");
put_Line ("Processing compilation unit ***" & the_Name & "*** of kind " & asis.Unit_Kinds'Image (Kind));
if Kind = asis.a_Package
then
Metrics.current_compilation_Unit := AdaM.compilation_Unit.new_compilation_Unit;
-- := adam.compilation_Unit.new_library_Unit
-- (the_Name,
-- library_Item.new_Item (adam.library_Unit.declaration.new_Package.all'Access));
--
-- Metrics.current_package_Declaration
-- := AdaM.library_Unit.declaration.view (Metrics.current_compilation_Unit.library_Item.Unit).my_Package;
end if;
-- Metrics.compilation_Unit.clear;
Metrics.compilation_Unit.Name_is (the_Name);
for J in Cont_Clause_Elements'Range
loop
AdaM.Assist.Query.find_Entities.element_Processing.Process_Construct (Cont_Clause_Elements (J));
end loop;
AdaM.Assist.Query.find_Entities.element_Processing.Process_Construct (Unit_Decl);
-- This procedure does not contain any exception handler because it
-- supposes that Element_Processing.Process_Construct should handle
-- all the exceptions which can be raised when processing the element
-- hierarchy.
-- declare
-- new_Unit : constant AdaM.compilation_Unit.view
-- := AdaM.compilation_Unit.new_Unit (Name => "",
-- of_Kind => compilation_Unit.library_unit_Kind);
-- begin
-- AdaM.compilation_Unit.item (new_Unit.all) := Metrics.compilation_Unit;
-- Metrics.Environment.add (new_Unit);
-- end;
declare
new_Unit : constant AdaM.compilation_Unit.view := AdaM.compilation_Unit.new_compilation_Unit;
begin
AdaM.compilation_Unit.item (new_Unit.all) := Metrics.compilation_Unit;
Metrics.Environment.add (new_Unit);
end;
put_Line ("End of processing compilation unit ***" & the_Name & "*** of kind " & asis.Unit_Kinds'Image (Kind));
new_Line (2);
end Process_Unit;
end AdaM.Assist.Query.find_Entities.unit_Processing;
|
30,421
|
ada
| 0
|
reznikmm/gela
|
source/oasis/program-elements-formal_unconstrained_array_types.ads
|
-- SPDX-FileCopyrightText: 2019 <NAME> <<EMAIL>>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Elements.Formal_Type_Definitions;
with Program.Lexical_Elements;
with Program.Elements.Expressions;
with Program.Elements.Component_Definitions;
package Program.Elements.Formal_Unconstrained_Array_Types is
pragma Pure (Program.Elements.Formal_Unconstrained_Array_Types);
type Formal_Unconstrained_Array_Type is
limited interface
and Program.Elements.Formal_Type_Definitions.Formal_Type_Definition;
type Formal_Unconstrained_Array_Type_Access is
access all Formal_Unconstrained_Array_Type'Class with Storage_Size => 0;
not overriding function Index_Subtypes
(Self : Formal_Unconstrained_Array_Type)
return not null Program.Elements.Expressions.Expression_Vector_Access
is abstract;
not overriding function Component_Definition
(Self : Formal_Unconstrained_Array_Type)
return not null Program.Elements.Component_Definitions
.Component_Definition_Access is abstract;
type Formal_Unconstrained_Array_Type_Text is limited interface;
type Formal_Unconstrained_Array_Type_Text_Access is
access all Formal_Unconstrained_Array_Type_Text'Class
with Storage_Size => 0;
not overriding function To_Formal_Unconstrained_Array_Type_Text
(Self : in out Formal_Unconstrained_Array_Type)
return Formal_Unconstrained_Array_Type_Text_Access is abstract;
not overriding function Array_Token
(Self : Formal_Unconstrained_Array_Type_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Left_Bracket_Token
(Self : Formal_Unconstrained_Array_Type_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Right_Bracket_Token
(Self : Formal_Unconstrained_Array_Type_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Of_Token
(Self : Formal_Unconstrained_Array_Type_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
end Program.Elements.Formal_Unconstrained_Array_Types;
|
30,422
|
ada
| 8
|
mhatzl/spark_unbound
|
src/spark_unbound-arrays.ads
|
with Ada.Numerics.Big_Numbers.Big_Integers; use Ada.Numerics.Big_Numbers.Big_Integers;
--- @summary
--- This package is intended as a safe and proven alternative to `Ada.Containers.Vector`.
---
--- @description
--- This package offers proven functions/procedures for an unbound array that are inspired by the `Ada.Containers.Vector` package.
---
--- Note: The range of `Index_Type` must be smaller than `Natural'Range_Length` since `Capacity' and `Length` return type `Natural`.
--- This is NOT enforced by the compiler!
generic
type Element_Type is private;
type Index_Type is range <>;
with function "=" (Left, Right : Element_Type) return Boolean is <>;
--- Function used to compare elements inside `Unbound_Array`s.
--- @param Left Element that is compared against `Right`.
--- @param Right Element that is comparef against `Left`.
--- @return `True` if `Left` and `Right` are equal.
package Spark_Unbound.Arrays with SPARK_Mode is
use Spark_Unbound;
package Index_Type_To_Big is new Signed_Conversions(Int => Index_Type);
-- needed to use `Self.Arr.all'Old` to prove some contracts
pragma Unevaluated_Use_Of_Old (Allow);
-- Type and variabble definitions ------------------------------------------------------------------------------------
-- Note: Having Last and Arr of some private type would be better, but then Pre and Post contracts get really messy
--- Type to provide the possibility of one invalid index.
subtype Extended_Index is
Index_Type'Base range
Index_Type'First-1 .. Index_Type'Min (Index_Type'Base'Last - 1, Index_Type'Last) + 1;
--- Index used to indicate 'out of range`.
No_Index : constant Extended_Index := Extended_Index'First;
--- Note: Type should be treated as private.
type Array_Type is array(Index_Type range <>) of Element_Type;
--- Note: Type should be treated as private.
type Array_Acc is access Array_Type;
--- Main type for `Unbound_Array` handling.
---
--- Note: `Last` and `Arr` should not be changed manually.
--- @field Last Index of the last valid entry in Arr.all.
--- @field Arr Reference to the underlying allocated array.
type Unbound_Array is record
Last : Extended_Index := No_Index;
Arr : Array_Acc := null;
end record
with Dynamic_Predicate => (if Arr = null then
Last = No_Index
else
(Arr.all'First = Index_Type'First
and then Arr.all'First <= Arr.all'Last
and then (if Arr.all'Length <= 0 then Last = No_Index else Last <= Arr.all'Last)));
-- Unbound_Array creations ------------------------------------------------------------------------------
--- Sets up a new `Unbound_Array` with `Initial_Capacity` as capacity.
---
--- Complexity: O(1) => Only allocates the array without setting any value
--- @param Initial_Capacity Tries to allocate an `Unbound_Array` with `Capacity(To_Unbound_Array'Result) = Initial_Capacity`.
--- @return `Unbound_Array` with `Capacity(To_Unbound_Array'Result) = Initial_Capacity` if allocation was successful, or `To_Unbound_Array'Result.Arr = null`.
function To_Unbound_Array (Initial_Capacity : Long_Positive) return Unbound_Array
with Pre => Ghost_In_Index_Range(Initial_Capacity),
Post => (if To_Unbound_Array'Result.Arr /= null then Capacity(To_Unbound_Array'Result) = Long_Natural(Initial_Capacity)
and then To_Unbound_Array'Result.Arr.all'First = Index_Type'First and then To_Unbound_Array'Result.Arr.all'Last = Get_Capacity_Offset(Initial_Capacity)
else Capacity(To_Unbound_Array'Result) = Long_Natural'First);
-- Procedures/Functions ----------------------------------------------------------------------------------
--- This function calculates the `Index_Type` for `Offset + Index_Type'Last`.
---
--- Complexity: O(1) => Integer calculation.
--- @param Offset The vallue added to `Index_Type'First`.
--- @return `Offset + Index_Type'First`.
function Get_Capacity_Offset (Offset : Long_Positive) return Index_Type
with Pre => Ghost_In_Index_Range(Offset),
Post => Index_Type_To_Big.To_Big_Integer(Get_Capacity_Offset'Result)
= Index_Type_To_Big.To_Big_Integer(Index_Type'First) + (Long_Positive_To_Big.To_Big_Integer(Offset) - Long_Positive_To_Big.To_Big_Integer(Long_Positive'First));
--- This function compares two `Unbound_Array`s by comparing each element (using the generic formal equality operator)
--- if `Left` and `Right` have the same length.
---
--- Note: The capacity can be different and `Left` and `Right` are still considered equal.
---
--- Complexity: O(n) => All elements might be compared.
--- @param Left `Unbound_Array` compared against `Right`.
--- @param Right `Unbound_Array` compared against `Left`.
--- @return `True` if `Left` and `Right` have the same elements in the same sequence. Otherwise, `False` is returned.
function "=" (Left, Right : Unbound_Array) return Boolean
with Global => null, Post => (if "="'Result then (Left.Arr = null and then Right.Arr = null)
or else (Last_Index(Left) = Last_Index(Right) and then First_Index(Left) = First_Index(Right)
and then (Left.Arr /= null and then Right.Arr /= null
and then (for all I in First_Index(Left) .. Last_Index(Left)
=> Element(Left,I) = Element(Right,I))))
else ((Left.Arr = null and then Right.Arr /= null)
or else (Left.Arr /= null and then Right.Arr = null)
or else Last_Index(Left) /= Last_Index(Right)
or else First_Index(Left) /= First_Index(Right)
or else (for some I in First_Index(Left) .. Last_Index(Left) => Element(Left,I) /= Element(Right,I))));
--- This function returns the capacity of `Self`.
---
--- Complexity: O(1) => Size of underlying array is always known.
--- @param Self Instance of an `Unbound_Array`.
--- @return The capacity of `Self` (More precise: The length of the underlying allocated array).
function Capacity (Self : Unbound_Array) return Long_Natural
with Post => (if Self.Arr /= null then Capacity'Result = Ghost_Acc_Length(Self.Arr) else Capacity'Result = Long_Natural'First);
-- procedure Reserve_Capacity (Self : in out Unbound_Array; New_Capacity : in Positive; Default_Item : Element_Type; Success: out Boolean)
-- with Pre => New_Capacity > Length(Self),
-- Post => (if Success then Capacity(Self) = New_Capacity else Ghost_Last_Array'Length = Capacity(Self));
--- This procedure tries to move the content of `Self` to an `Unbound_Array` of a smaller capacity.
---
--- Note: `Self` remains unchanged if `Success = False`.
---
--- Complexity: O(n) => All elements are moved, but allocation might fail before.
--- @param Self Instance of an `Unbound_Array`.
--- @param New_Capacity The new capacity `Self` should be shrunken to.
--- @param Success `True` if `Self` got shrunken or `False` if the content of `Self` could not be moved.
procedure Shrink (Self : in out Unbound_Array; New_Capacity : Long_Natural; Success : out Boolean)
with Pre => Self.Arr /= null and then New_Capacity >= Length(Self) and then New_Capacity < Capacity(Self),
Post => (If New_Capacity = 0 and then Success then Capacity(Self) = Long_Natural'First and then Last_Index(Self) = No_Index
else Self.Arr /= null and then Self.Last = Self.Last'Old
and then (if Self.Last'Old > No_Index then Ghost_Arr_Equals(Left => Self.Arr.all, Right => Self.Arr.all'Old, First => First_Index(Self), Last => Last_Index(Self)))
and then (if Success then Capacity(Self) = New_Capacity));
--- This function returns the number of elements inside `Self`.
---
--- Complexity: O(1) => First_Index(Self) and Last_Index(Self) is always known.
--- @param Self Instance of an `Unbound_Array`.
--- @return Number of elements inside `Self`.
function Length (Self : Unbound_Array) return Long_Natural
with Post => (if Last_Index(Self) = No_Index or else Capacity(Self) = Long_Natural'First then Length'Result = Long_Natural'First
else (if First_Index(Self) > Last_Index(Self) then Length'Result = Long_Natural'First
else Length'Result = Long_Natural(abs(Long_Integer(Last_Index(Self)) - Long_Integer(First_Index(Self))) + 1)));
--- This function denotes if `Self` as no elements.
---
--- Complexity: O(1) => Length(Self) is always known.
--- @param Self Instance of an `Unbound_Array`.
--- @return `True` if `Self` has no elements, or `False` if `Self` has at least one element.
function Is_Empty (Self : Unbound_Array) return Boolean
with Post => (if Last_Index(Self) = No_Index then Is_Empty'Result = True else Is_Empty'Result = False);
--- This procedure deallocates the underlying array of `Self` and sets `Self.Last = No_Index`.
---
--- Complexity: O(1) => Unchecked_Deallocation of underlying array.
--- @param Self Instance of an `Unbound_Array`.
procedure Clear (Self : in out Unbound_Array)
with Post => Self.Arr = null and then Self.Last = No_Index;
--- This function returns the element inside `Self` at index `Index`.
---
--- Complexity: O(1) => Index access on array is constant time.
--- @param Self Instance of an `Unbound_Array`.
--- @param Index Array index for the element that should be returned.
--- @return The element inside `Self` at index `Index`.
function Element (Self : Unbound_Array; Index : Index_Type) return Element_Type
with Pre => Last_Index(Self) > No_Index and then Last_Index(Self) >= Index and then First_Index(Self) <= Index,
Post => Element'Result = Self.Arr.all(Index);
--- This procedure replaces the element inside `Self` at index `Index` with `New_Item`.
---
--- Complexity: O(1) => Index access on array is constant time.
--- @param Self Instance of an `Unbound_Array`.
--- @param Index Array index for the element that should be replaced.
--- @param New_Item Value that is set for the element at index `Index`.
procedure Replace_Element (Self : in out Unbound_Array; Index : in Index_Type; New_Item : in Element_Type)
with Pre => Last_Index(Self) > No_Index and then Last_Index(Self) >= Index and then First_Index(Self) <= Index,
Post => Element(Self, Index) = New_Item;
-- procedure Update_Element
-- (Self : in out Unbound_Array;
-- Index : in Index_Type;
-- Process : not null access procedure (Process_Element : in out Element_Type))
-- with Pre => First_Index <= Index and then Last_Index(Self) >= Index; --,
-- Post => Element(Self, Index) = Process_Element; -- Not sure how to prove that Process_Element got changed correctly
--- Procedure that tries to copy elements of `Source` to `Target`.
---
--- Note: `Target` is set to `Target.Arr = null` and `Target.Last = No_Index` if `Success = False`. `Source` remains unchanged.
---
--- Complexity: O(n) => All elements must be copied, but allocation might fail before.
--- @param Target Instance of an `Unbound_Array` with `Target = Source` and `Capacity(Target) = Capacity(Source)` on `Success = True`.
--- @param Source Instance of an `Unbound_Array` that is copied to `Target`.
--- @param Success `True` if all elements of `Source` were copied to `Target`.
procedure Copy (Target : out Unbound_Array; Source : Unbound_Array; Success: out Boolean)
with Post => (if Success then Target = Source and then Capacity(Target) = Capacity(Source)
else (Target.Last = No_Index and then Target.Arr = null));
--- Procedure that tries to move elements of `Source` to `Target`.
---
--- Note: `Capacity(Target)` can be different to `Capacity(Source)`, but all elements of `Source` must fit inside `Target`.
---
--- Complexity: Theta(n) => Alle elements of `Source` must be copied.
--- @param Target Instance of `Unbound_Array` with all elements of `Source` being moved to.
--- @param Source Instance of `Unbound_Array` that is cleared at the end of `Move`.
procedure Move (Target : in out Unbound_Array; Source : in out Unbound_Array)
with Pre => Source.Arr /= null and then Target.Arr /= null and then Last_Index(Source) /= No_Index
and then Capacity(Target) > Long_Natural'First and then First_Index(Source) = First_Index(Target)
and then Ghost_In_Index_Range(Long_Positive(Capacity(Target))) and then Last_Index(Source) <= Get_Capacity_Offset(Long_Positive(Capacity(Target))),
Post => Capacity(Target) = Ghost_Arr_Length(Target.Arr.all'Old)
and then Source.Arr = null and then Source.Last = No_Index
and then Target.Last = Source.Last'Old and then Ghost_Arr_Equals(Left => Target.Arr.all, Right => Source.Arr.all'Old, First => First_Index(Target), Last => Last_Index(Target));
-- else (Target.Last = Target.Last'Old and then Ghost_Arr_Equals(Left => Target.Arr.all'Old, Right => Target.Arr.all, First => Target.Arr.all'First, Last => Target.Arr.all'Last)
-- and then Source.Last = Source.Last'Old and then Ghost_Arr_Equals(Left => Source.Arr.all'Old, Right => Source.Arr.all, First => Source.Arr.all'First, Last => Source.Arr.all'Last)));
-- procedure Insert (Self : in out Unbound_Array;
-- Before : in Extended_Index;
-- New_Item : in Unbound_Array; Success: out Boolean);
--
-- procedure Insert (Container : in out Unbound_Array;
-- Before : in Extended_Index;
-- New_Item : in Element_Type; Success: out Boolean);
--
-- procedure Prepend (Self : in out Unbound_Array;
-- New_Item : in Unbound_Array; Success: out Boolean);
--
-- procedure Prepend (Self : in out Unbound_Array;
-- New_Item : in Element_Type; Success: out Boolean);
--
-- procedure Append (Self : in out Unbound_Array;
-- New_Item : in Unbound_Array; Success: out Boolean);
--- Procedure that tries to append `New_Item` to `Self`.
---
--- Note: The underlying array of `Self` is tried to be increased automatically if `Capacity(Self) = Length(Self)`.
---
--- Complexity: O(n) => `Capacity(Self)` is tried to be doubled if `Capacity(Self) = Length(Self)` is reached.
--- @param Self Instance of an `Unbound_Array`.
--- @param New_Item Element that is appended to `Self` if `Success = True`.
--- @param Success `True` if `New_Item` got appended to `Self`.
procedure Append (Self : in out Unbound_Array; New_Item : in Element_Type; Success: out Boolean)
with Pre => Self.Arr /= null and then In_Range(Arg => Long_Natural_To_Big.To_Big_Integer(Capacity(Self)),
Low => Long_Natural_To_Big.To_Big_Integer(Long_Natural'First),
High => abs(Index_Type_To_Big.To_Big_Integer(Index_Type'Last) - Index_Type_To_Big.To_Big_Integer(Index_Type'First))),
Post => (if Success then
Self.Arr /= null and then Last_Element(Self) = New_Item and then Self.Last = Self.Last'Old + 1
and then (if Self.Last'Old /= No_Index then Ghost_Arr_Equals(Left => Self.Arr.all, Right => Self.Arr.all'Old, First => First_Index(Self), Last => Self.Last'Old))
elsif Self.Arr = null then Self.Last = No_Index
else (Self.Last = Self.Last'Old and then Ghost_Arr_Equals(Left => Self.Arr.all, Right => Self.Arr.all'Old, First => First_Index(Self), Last => Last_Index(Self))));
-- procedure Delete (Self : in out Unbound_Array;
-- Index : in Extended_Index;
-- Count : in Positive := 1)
-- with Pre => (Extended_Index'Last >= Extended_Index(Count) and then Index <= (Extended_Index'Last - Extended_Index(Count)) and then
-- First_Index <= Index and then Last_Index(Self) >= (Index + Extended_Index(Count))),
-- Post => (Length(Ghost_Last_Array) - Count_Type(Count) = Length(Self) and then
-- (for all I in First_Index .. Last_Index(Self)
-- => Element(Self, I) = Element(Ghost_Last_Array,I)));
-- mhatzl
-- procedure Delete_First (Self : in out Unbound_Array;
-- Count : in Positive := 1);
--- This procedure deletes the last `Count` elements inside `Self`.
---
--- Complexity: O(1) => Only `Last_Index(Self)` is reduced.
--- @param Self Instance of an `Unbound_Array`.
--- @param Count Number of elements to delete.
procedure Delete_Last (Self : in out Unbound_Array; Count : in Long_Positive := 1)
with Pre => Self.Arr /= null and then Length(Self) >= Long_Natural(Count),
Post => Long_Integer(Self.Last'Old) - Long_Integer(Self.Last) = Count
and then (if Last_Index(Self) > No_Index then
Ghost_Arr_Equals(Left => Self.Arr.all, Right => Self.Arr.all'Old, First => First_Index(Self), Last => Last_Index(Self))
else Is_Empty(Self));
-- procedure Reverse_Elements (Self : in out Unbound_Array);
--
-- procedure Swap (Self : in out Unbound_Array;
-- I, J : in Index_Type);
--- This function returns the first index of `Self`.
---
--- Complexity: O(1) => First index is fixed.
--- @param Self Instance of an `Unbound_Array`.
--- @return The first index of `Self`.
function First_Index (Self : Unbound_Array) return Index_Type
with Inline, Post => (if Self.Arr = null then First_Index'Result = Index_Type'First else First_Index'Result = Self.Arr.all'First);
--- This function returns the element at `First_Index(Self)`.
---
--- Complexity: O(1) => Array access is constant time.
--- @param Self Instance of an `Unbound_Array`.
--- @return The first element of `Self`.
function First_Element (Self : Unbound_Array) return Element_Type
with Pre => Self.Arr /= null and then Self.Last /= No_Index and then Length(Self) > Long_Natural'First,
Post => First_Element'Result = Self.Arr.all(First_Index(Self));
--- This function returns the last index of `Self`.
---
--- Complexity: O(1) => `Last_Index(Self)` is kept with `Self.Last`.
--- @param Self Instance of an `Unbound_Array`.
--- @return The last index of `Self`.
function Last_Index (Self : Unbound_Array) return Extended_Index
with Post => (Last_Index'Result = Self.Last and then (if Self.Arr = null then Last_Index'Result = No_Index
elsif Self.Arr.all'Length > 0 then Last_Index'Result <= Self.Arr.all'Last else Last_Index'Result = No_Index)), Inline;
--- This function returns the element at `Last_Index(Self)`.
---
--- Complexity: O(1) => Array access is constant time.
--- @param Self Instance of an `Unbound_Array`.
--- @return The last element of `Self`.
function Last_Element (Self : Unbound_Array) return Element_Type
with Pre => Self.Arr /= null and then Last_Index(Self) > No_Index and then Length(Self) > Long_Natural'First,
Post => Last_Element'Result = Self.Arr.all(Last_Index(Self));
--- This function searches the elements of `Self` for an element equal to `Item` (using the generic formal equality operator).
--- The search starts at position `Index` and proceeds towards `Last_Index(Self)`.
--- If no equal element is found, then `Find_Index` returns `No_Index`. Otherwise, it returns the index of the first equal element encountered.
---
--- Note: Same behavior as `Find_Index` defined in `Ada.Containers.Vectors` [RM-A-18-2].
---
--- Complexity: O(n) => All elements might get compared against `Item`.
--- @param Self Instance of an `Unbound_Array`.
--- @param Item Element that is searched for in `Self`.
--- @param Index Array index to start searching towards `Last_Index(Self)` for `Item`.
--- @return `No_Index` if `Item` was not found, or the index `I` where `Element(Self, I) = Item`.
function Find_Index (Self : Unbound_Array; Item : Element_Type; Index : Index_Type := Index_Type'First) return Extended_Index
with Pre => Last_Index(Self) >= Index and then First_Index(Self) <= Index,
Post => (if Find_Index'Result /= No_Index then Element(Self,Find_Index'Result) = Item
else (Last_Index(Self) = No_Index or else (for all I in Index .. Last_Index(Self) => Element(Self, I) /= Item)));
-- mhatzl
-- function Reverse_Find_Index (Self : Unbound_Array;
-- Item : Element_Type;
-- Index : Index_Type := Index_Type'Last)
-- return Extended_Index;
--- This function searches the elements of `Self` for an element equal to `Item` (using the generic formal equality operator).
--- The search starts at position `Index` and proceeds towards `Last_Index(Self)`.
--- If no equal element is found, then `Contains` returns `False`. Otherwise, `Contains` returns true.
---
--- Complexity: O(n) => All elements might get compared against `Item`.
--- @param Self Instance of an `Unbound_Array`.
--- @param Item Element that is searched for in `Self`.
--- @param Index Array index to start searching towards `Last_Index(Self)` for `Item`.
function Contains (Self : Unbound_Array; Item : Element_Type; Index : Index_Type := Index_Type'First) return Boolean
with Post => (if Contains'Result then Self.Arr /= null and then Self.Last /= No_Index
and then (for some I in Index .. Last_Index(Self) => Element(Self, I) = Item));
-- function Reverse_Contains (Self : Unbound_Array;
-- Item : Element_Type;
-- Index : Index_Type := Index_Type'Last)
-- return Boolean;
-- mhatzl
-- generic
-- with function "<" (Left, Right : Element_Type) return Boolean is <>;
-- package Generic_Sorting with SPARK_Mode is
--
-- function Is_Sorted (Self : Unbound_Array) return Boolean;
--
-- procedure Sort (Self : in out Unbound_Array; Success: out Boolean);
--
-- procedure Merge (Target : in out Unbound_Array;
-- Source : in out Unbound_Array; Success: out Boolean);
--
-- function Sorted_Contains (Self : Unbound_Array;
-- Item : Element_Type) return Boolean
-- with Post => (if Contains'Result then
-- (for some I in First_Index(Self) .. Last_Index(Self)
-- => Element(Self, I) = Item)
-- else (for all I in First_Index(Self) .. Last_Index(Self)
-- => Element(Self, I) /= Item));
--
-- procedure Sorted_Add (Self : in out Unbound_Array; New_Item : in Element_Type; Success: out Boolean)
--
-- function Sorted_Find_Index (Self : Unbound_Array; Item : Element_Type; Index : Index_Type := Index_Type'First) return Extended_Index
-- with Pre => Last_Index(Self) /= No_Index and then Last_Index(Self) >= Index and then First_Index(Self) <= Index,
-- Post => (if Find_Index'Result /= No_Index then Element(Self,Find_Index'Result) = Item
-- else (for all I in First_Index(Self) .. Index => Element(Self, I) /= Item));
--
-- function Sorted_Reverse_Find_Index (Self : Unbound_Array; Item : Element_Type; Index : Index_Type := Index_Type'First) return Extended_Index
-- with Pre => Last_Index(Self) /= No_Index and then Last_Index(Self) >= Index and then First_Index(Self) <= Index,
-- Post => (if Find_Index'Result /= No_Index then Element(Self,Find_Index'Result) = Item
-- else (for all I in First_Index(Self) .. Index => Element(Self, I) /= Item));
--
-- end Generic_Sorting;
-- Ghost --------------------------------------------------------------------------------------------------------------
-- This ghost function checks if `Offset + Index_Type'First` is still in the range of `Index_Type`.
-- Note: Not to be used for anything but proves
-- @param Offset The value added to `Index_Type'First`.
-- @return `True` if `Offset + Index_Type'First` is still inside the range of `Index_Type`, `False` otherwise.
function Ghost_In_Index_Range (Offset : Long_Positive) return Boolean is
(In_Range(Arg => (Index_Type_To_Big.To_Big_Integer(Index_Type'First) + Long_Positive_To_Big.To_Big_Integer(Offset) - Long_Positive_To_Big.To_Big_Integer(Long_Positive'First)),
Low => Index_Type_To_Big.To_Big_Integer(Index_Type'First),
High => Index_Type_To_Big.To_Big_Integer(Index_Type'Last))) with Ghost;
-- Ghost function needed for some proves.
-- Note: Not to be used for anything but proves.
function Ghost_Acc_Length (Self : Array_Acc) return Long_Natural
with Ghost,
Post => ((if Self = null then Ghost_Acc_Length'Result = Long_Natural'First else Ghost_Acc_Length'Result = Self.all'Length));
-- Ghost function needed for some proves.
-- Note: Not to be used for anything but proves.
function Ghost_Arr_Equals (Left, Right : Array_Type; First, Last : Index_Type) return Boolean
with Ghost,
Post => (if Ghost_Arr_Equals'Result then (for all I in First .. Last => Left(I) = Right(I))
else (Left'First > First or else Right'First > First or else Left'Last < Last or else Right'Last < Last
or else (for some I in First .. Last => Left(I) /= Right(I))));
-- Ghost function needed for some proves.
-- Note: Not to be used for anything but proves.
function Ghost_Arr_Length (Self : Array_Type) return Long_Natural
with Ghost,
Post => Ghost_Arr_Length'Result = Self'Length;
end Spark_Unbound.Arrays;
|
30,423
|
ada
| 1
|
LaudateCorpus1/RosettaCodeData
|
Task/Langtons-ant/Ada/langtons-ant.ada
|
<filename>Task/Langtons-ant/Ada/langtons-ant.ada
with Ada.Text_IO;
procedure Langtons_Ant is
Size: constant Positive := 100; -- change this to extend the playground
subtype Step is Integer range -1 .. +1;
procedure Right(N, W: in out Step) is
Tmp: Step := W;
begin
W := - N;
N := Tmp;
end Right;
procedure Left(N, W: in out Step) is
begin
for I in 1 .. 3 loop
Right(N, W);
end loop;
end Left;
Color_Character: array(Boolean) of Character :=
(False => ' ', True => '#');
Is_Black: array (1 .. Size, 1 .. Size) of Boolean :=
(others => (others => False)); -- initially, the world is white;
Ant_X, Ant_Y: Natural := Size/2; -- Position of Ant;
Ant_North: Step := 1; Ant_West: Step := 0; -- initially, Ant looks northward
Iteration: Positive := 1;
begin
loop -- iterate the loop until an exception is raised
if Is_Black(Ant_X, Ant_Y) then
Left(Ant_North, Ant_West);
else
Right(Ant_North, Ant_West);
end if;
Is_Black(Ant_X, Ant_Y) := not Is_Black(Ant_X, Ant_Y);
Ant_X := Ant_X - Ant_North; -- this may raise an exception
Ant_Y := Ant_Y - Ant_West; -- this may raise an exception
Iteration := Iteration + 1;
end loop;
exception
when Constraint_Error => -- Ant has left its playground ... now output
for X in 1 .. Size loop
for Y in 1 .. Size loop
Ada.Text_IO.Put(Color_Character(Is_Black(X, Y)));
end loop;
Ada.Text_IO.New_Line;
end loop;
Ada.Text_IO.Put_Line("# Iteration:" & Integer'Image(Iteration));
end Langtons_Ant;
|
30,424
|
ada
| 24
|
svn2github/matreshka
|
source/web/tools/a2js/engines-generic_engines.ads
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2015, <NAME> <<EMAIL>> --
-- 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 <NAME>, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Ada.Containers.Hashed_Maps;
with Asis.Extensions.Flat_Kinds;
generic
type Propert_Name is (<>);
type Property_Type is private;
type Abstract_Context;
package Engines.Generic_Engines is
type Engine (Context : access Abstract_Context) is
tagged limited private;
function Get_Property
(Self : access Engine;
Element : Asis.Element;
Name : Propert_Name) return Property_Type;
function Get_Property
(Self : access Engine;
List : Asis.Element_List;
Name : Propert_Name;
Empty : Property_Type;
Sum : access
function (Left, Right : Property_Type) return Property_Type)
return Property_Type;
procedure Register_Calculator
(Self : in out Engine;
Kind : Asis.Extensions.Flat_Kinds.Flat_Element_Kinds;
Name : Propert_Name;
Action : access function
(Engine : access Abstract_Context;
Element : Asis.Element;
Name : Propert_Name) return Property_Type);
private
type Property_Key is record
Element : Asis.Element;
Name : Propert_Name;
end record;
function Hash (Value : Property_Key) return Ada.Containers.Hash_Type;
overriding function "=" (Left, Right : Property_Key) return Boolean;
package Property_Maps is new Ada.Containers.Hashed_Maps
(Key_Type => Property_Key,
Element_Type => Property_Type,
Hash => Hash,
Equivalent_Keys => "=",
"=" => "=");
type Action_Key is record
Kind : Asis.Extensions.Flat_Kinds.Flat_Element_Kinds;
Name : Propert_Name;
end record;
function Hash (Value : Action_Key) return Ada.Containers.Hash_Type;
type Action_Callback is access function
(Engine : access Abstract_Context;
Element : Asis.Element;
Name : Propert_Name) return Property_Type;
package Action_Maps is new Ada.Containers.Hashed_Maps
(Key_Type => Action_Key,
Element_Type => Action_Callback,
Hash => Hash,
Equivalent_Keys => "=",
"=" => "=");
type Engine (Context : access Abstract_Context) is tagged limited
record
Property_Cache : Property_Maps.Map;
Actions : Action_Maps.Map;
end record;
end Engines.Generic_Engines;
|
30,425
|
ada
| 6
|
jonashaggstrom/ada-canopen
|
examples/linux/src/app.ads
|
package App is
procedure Run_Local;
procedure Run_Remote;
end App;
|
30,426
|
ada
| 79
|
Roldak/OpenGLAda
|
src/gl/interface/gl-files.ads
|
<filename>src/gl/interface/gl-files.ads
-- part of OpenGLAda, (c) 2017 <NAME>
-- released under the terms of the MIT license, see the file "COPYING"
with GL.Objects.Shaders;
-- This package is an addition to the original OpenGL API and simplifies
-- the handling of ressources located in files, like shader sources.
package GL.Files is
procedure Load_Shader_Source_From_File (Object : Objects.Shaders.Shader;
File_Name : String);
end GL.Files;
|
30,427
|
ada
| 5
|
docandrew/troodon
|
src/render-shaders.ads
|
<filename>src/render-shaders.ads<gh_stars>1-10
with GL;
package Render.Shaders is
ShaderException : Exception;
---------------------------------------------------------------------------
-- Shader Variables. Consider moving these into their own record types
---------------------------------------------------------------------------
-- Text shader
textShaderProg : GL.GLuint := 0;
textAttribCoord : GL.GLint;
textUniformTex : GL.GLint;
textUniformColor : GL.GLint;
textUniformOrtho : GL.GLint;
textUniformAOnly : GL.GLint; -- if font texture is alpha channel only (monochrome fonts)
textVBO : aliased GL.GLuint;
-- Circle shader
circleShaderProg : GL.GLuint := 0;
circleAttribCoord : GL.GLint;
circleUniformColor : GL.GLint;
circleUniformCenter : GL.GLint;
circleUniformRadius : GL.GLint;
circleUniformOrtho : GL.GLint;
circleUniformScrH : GL.GLint;
circleVBO : aliased GL.GLuint;
-- Line shader
lineShaderProg : GL.GLuint := 0;
lineAttribCoord : GL.GLint;
lineUniformOrtho : GL.GLint;
lineUniformFrom : GL.GLint;
lineUniformTo : GL.GLint;
lineUniformWidth : GL.GLint;
lineUniformColor : GL.GLint;
lineUniformScrH : GL.GLint;
lineUniformAA : GL.GLint;
lineVBO : aliased GL.GLuint;
-- Compositor/Window Shader
winShaderProg : GL.GLuint := 0;
winAttribCoord : GL.GLint;
winUniformOrtho : GL.GLint;
winUniformTex : GL.GLint;
winUniformAlpha : GL.GLint;
winVBO : aliased GL.GLuint;
-- Shadow Shader
shadowShaderProg : GL.GLuint := 0;
shadowAttribCoord : GL.GLint;
shadowUniformOrtho : GL.GLint;
shadowUniformColor : GL.GLint;
shadowUniformShadow : GL.GLint; -- coords/dimensions of shadow
shadowUniformScreenH : GL.GLint;
---------------------------------------------------------------------------
-- Part of Troodon's philosophy is being distributed as a single
-- executable. We bake shaders into the final binary and extract them
-- here.
---------------------------------------------------------------------------
---------------------------------------------------------------------------
-- start
-- Load, compile shaders into their respective programs
---------------------------------------------------------------------------
procedure start;
---------------------------------------------------------------------------
-- stop
-- Delete shader programs
---------------------------------------------------------------------------
procedure stop;
--procedure printShaderErrors (obj : GL.GLUint);
end Render.Shaders;
|
30,428
|
ada
| 0
|
fintatarta/protypo
|
test/interpreter-test/prova_interpreter.adb
|
<filename>test/interpreter-test/prova_interpreter.adb
with Protypo.Api.Interpreters;
with Protypo.Api.Consumers.File_Writer;
with Protypo.Api.Engine_Values.Engine_Value_Array_Wrappers;
with Protypo.Api.Engine_Values.Engine_Value_Holders;
with User_Records;
with Integer_Arrays;
with Ada.Command_Line;
with Ada.Text_Io; use Ada.Text_Io;
with Ada.Exceptions;
with Protypo.Api.Engine_Values;
with Protypo.Api.Engine_Values.Handlers;
use Protypo.Api.Engine_Values.Handlers;
procedure Prova_Interpreter is
use Protypo.Api.Engine_Values;
use Ada.Command_Line;
use Protypo.Api.Interpreters;
use Protypo.Api.Engine_Values;
use Protypo.Api.Consumers;
use Protypo.Api;
use User_Records;
use User_Records.User_Record_Package;
function Source_File return String
is (if Argument_Count = 0 then
"test-data/interprete.txt"
else
Argument (1));
function Create_Holder (X : String) return Engine_Value_Holders.Holder
is (Engine_Value_Holders.To_Holder (Create (X)));
Program : constant Template_Type := Slurp (Source_File);
Code : Compiled_Code;
Consumer : constant Consumer_Access :=
File_Writer.Open (File_Writer.Standard_Error_Special_Name);
Db : constant Multi_Aggregate :=
(1 => (First_Name => Create_Holder ("Pippo"),
Last_Name => Create_Holder ("Recupero"),
Telephone => Create_Holder ("3204365972")),
2 => (First_Name => Create_Holder ("Diego"),
Last_Name => Create_Holder ("<NAME>"),
Telephone => Create_Holder ("zzzzzz")),
3 => (First_Name => Create_Holder ("Topolino"),
Last_Name => Create_Holder ("<NAME>"),
Telephone => Create_Holder ("12345")),
4 => (First_Name => Create_Holder ("Paolino"),
Last_Name => Create_Holder ("Paperino"),
Telephone => Create_Holder ("1313")));
Scores : constant Engine_Value :=
Integer_Arrays.Wrappers.Create (Value => (1 => 18,
2 => 33,
3 => 42,
4 => -5));
User_Dir : constant Ambivalent_Interface_Access :=
Engine_Value_Array_Wrappers.Make_Wrapper (To_Array (Db));
Engine : Interpreter_Type;
begin
Engine.Define (Name => "users",
Value => Create (User_Dir));
Engine.Define (Name => "scores",
Value => Scores);
Engine.Define (Name => "splitbit",
Value => Handlers.Create (Val => User_Records.Split_Bit'Access,
Min_Parameters => 1,
Max_Parameters => 2));
Compile (Target => Code,
Program => Program);
Engine.Run (Program => Code,
Consumer => Consumer);
Set_Exit_Status (Success);
exception
when E : Protypo.Run_Time_Error =>
Put_Line (Standard_Error, "Run time error: " & Ada.Exceptions.Exception_Message (E));
Set_Exit_Status (Failure);
when E : Protypo.Parsing_Error =>
Put_Line (Standard_Error, "parsing error: " & Ada.Exceptions.Exception_Message (E));
Set_Exit_Status (Failure);
when E : others =>
Put_Line (Standard_Error, "other: " & Ada.Exceptions.Exception_Message (E)
& Ada.Exceptions.Exception_Information (E));
end Prova_Interpreter;
|
30,429
|
ada
| 3
|
albinjal/ada_basic
|
tentaplugg_albin/stonehedge/henge?.adb
|
<gh_stars>1-10
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
procedure henge
|
30,430
|
ada
| 1
|
LaudateCorpus1/RosettaCodeData
|
Task/URL-decoding/Ada/url-decoding-2.ada
|
package URL is
function Decode (URL : in String) return String;
end URL;
|
30,431
|
ada
| 79
|
Roldak/OpenGLAda
|
src/glfw/v3/glfw-errors.ads
|
<gh_stars>10-100
-- part of OpenGLAda, (c) 2017 <NAME>
-- released under the terms of the MIT license, see the file "COPYING"
package Glfw.Errors is
type Kind is (Not_Initialized,
No_Current_Context,
Invalid_Enum,
Invalid_Value,
Out_Of_Memory,
API_Unavailable,
Version_Unavailable,
Platform_Error,
Format_Unavailable);
for Kind use (Not_Initialized => 16#00010001#,
No_Current_Context => 16#00010002#,
Invalid_Enum => 16#00010003#,
Invalid_Value => 16#00010004#,
Out_Of_Memory => 16#00010005#,
API_Unavailable => 16#00010006#,
Version_Unavailable => 16#00010007#,
Platform_Error => 16#00010008#,
Format_Unavailable => 16#00010009#);
for Kind'Size use Interfaces.C.int'Size;
type Callback is access procedure (Error : Kind; Description : String);
procedure Set_Callback (Handler : Callback);
end Glfw.Errors;
|
30,432
|
ada
| 20
|
charlie5/lace
|
3-mid/opengl/source/lean/opengl-viewport.ads
|
<gh_stars>10-100
package openGL.Viewport
--
-- Models an opendGL viewport.
--
is
function Extent return Extent_2d;
procedure Extent_is (Now : in Extent_2d);
end openGL.Viewport;
|
30,433
|
ada
| 1
|
brucegua/moocos
|
tools/scitools/conf/understand/ada/ada05/s-crtl.ads
|
<gh_stars>1-10
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . C R T L --
-- --
-- S p e c --
-- --
-- Copyright (C) 2003-2006, 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 2, 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 COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
--
--
--
--
--
--
--
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides the low level interface to the C Run Time Library
-- on non-VMS systems.
with System.Parameters;
package System.CRTL is
pragma Preelaborate;
subtype chars is System.Address;
-- Pointer to null-terminated array of characters
subtype DIRs is System.Address;
-- Corresponds to the C type DIR*
subtype FILEs is System.Address;
-- Corresponds to the C type FILE*
subtype int is Integer;
type long is range -(2 ** (System.Parameters.long_bits - 1))
.. +(2 ** (System.Parameters.long_bits - 1)) - 1;
subtype off_t is Long_Integer;
type size_t is mod 2 ** Standard'Address_Size;
function atoi (A : System.Address) return Integer;
pragma Import (C, atoi, "atoi");
procedure clearerr (stream : FILEs);
pragma Import (C, clearerr, "clearerr");
function dup (handle : int) return int;
pragma Import (C, dup, "dup");
function dup2 (from, to : int) return int;
pragma Import (C, dup2, "dup2");
function fclose (stream : FILEs) return int;
pragma Import (C, fclose, "fclose");
function fdopen (handle : int; mode : chars) return FILEs;
pragma Import (C, fdopen, "fdopen");
function fflush (stream : FILEs) return int;
pragma Import (C, fflush, "fflush");
function fgetc (stream : FILEs) return int;
pragma Import (C, fgetc, "fgetc");
function fgets (strng : chars; n : int; stream : FILEs) return chars;
pragma Import (C, fgets, "fgets");
function fopen (filename : chars; Mode : chars) return FILEs;
pragma Import (C, fopen, "__gnat_fopen");
function fputc (C : int; stream : FILEs) return int;
pragma Import (C, fputc, "fputc");
function fputs (Strng : chars; Stream : FILEs) return int;
pragma Import (C, fputs, "fputs");
procedure free (Ptr : System.Address);
pragma Import (C, free, "free");
function freopen
(filename : chars;
mode : chars;
stream : FILEs)
return FILEs;
pragma Import (C, freopen, "__gnat_freopen");
function fseek
(stream : FILEs;
offset : long;
origin : int)
return int;
pragma Import (C, fseek, "fseek");
function ftell (stream : FILEs) return long;
pragma Import (C, ftell, "ftell");
function getenv (S : String) return System.Address;
pragma Import (C, getenv, "getenv");
function isatty (handle : int) return int;
pragma Import (C, isatty, "isatty");
function lseek (fd : int; offset : off_t; direction : int) return off_t;
pragma Import (C, lseek, "lseek");
function malloc (Size : size_t) return System.Address;
pragma Import (C, malloc, "malloc");
procedure memcpy (S1 : System.Address; S2 : System.Address; N : size_t);
pragma Import (C, memcpy, "memcpy");
procedure memmove (S1 : System.Address; S2 : System.Address; N : size_t);
pragma Import (C, memmove, "memmove");
procedure mktemp (template : chars);
pragma Import (C, mktemp, "mktemp");
function pclose (stream : System.Address) return int;
pragma Import (C, pclose, "pclose");
function popen (command, mode : System.Address) return System.Address;
pragma Import (C, popen, "popen");
function read (fd : int; buffer : chars; nbytes : int) return int;
pragma Import (C, read, "read");
function realloc
(Ptr : System.Address; Size : size_t) return System.Address;
pragma Import (C, realloc, "realloc");
procedure rewind (stream : FILEs);
pragma Import (C, rewind, "rewind");
procedure rmdir (dir_name : String);
pragma Import (C, rmdir, "rmdir");
function setvbuf
(stream : FILEs;
buffer : chars;
mode : int;
size : size_t)
return int;
pragma Import (C, setvbuf, "setvbuf");
procedure tmpnam (string : chars);
pragma Import (C, tmpnam, "tmpnam");
function tmpfile return FILEs;
pragma Import (C, tmpfile, "tmpfile");
function ungetc (c : int; stream : FILEs) return int;
pragma Import (C, ungetc, "ungetc");
function unlink (filename : chars) return int;
pragma Import (C, unlink, "unlink");
function write (fd : int; buffer : chars; nbytes : int) return int;
pragma Import (C, write, "write");
end System.CRTL;
|
30,434
|
ada
| 0
|
luk9400/nsi
|
list1/task2/src/poly.ads
|
package Poly with SPARK_Mode is
type Vector is array (Natural range <>) of Integer;
function Horner (X: Integer; A: Vector) return Integer;
end Poly;
|
30,435
|
ada
| 4
|
faelys/gela-asis
|
source/asis/asis-gela-visibility.adb
|
------------------------------------------------------------------------------
-- G E L A A S I S --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of this file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $:
with Ada.Wide_Text_IO;
with Asis.Elements;
with Asis.Iterator;
with Asis.Statements;
with Asis.Gela.Lists;
with Asis.Gela.Errors;
with Asis.Expressions;
with Asis.Declarations;
with Asis.Gela.Debug;
with Asis.Gela.Utils;
with Asis.Gela.Element_Utils;
with Asis.Gela.Visibility.Utils;
with Asis.Gela.Visibility.Create;
with XASIS.Utils;
with Gela.Containers.Stacks; use Gela;
package body Asis.Gela.Visibility is
type Stack_Item is record
Element : Asis.Element;
Point : Visibility.Point;
end record;
package Region_Stacks is new Containers.Stacks (Stack_Item);
use Region_Stacks;
Region_Stack : Stack;
procedure Enter_Each_Construction
(Element : in Asis.Element;
Point : in out Visibility.Point);
procedure Resolve_Profile
(Construct : in Asis.Element;
Point : in out Visibility.Point);
procedure Resolve_RR_Name
(Construct : in Asis.Element;
Point : in out Visibility.Point);
procedure Pre_Op (Element : in Asis.Element;
Control : in out Asis.Traverse_Control;
State : in out Visibility.Point);
procedure Post_Op (Element : in Asis.Element;
Control : in out Asis.Traverse_Control;
State : in out Visibility.Point);
procedure Resolve_Names is
new Asis.Iterator.Traverse_Element
(State_Information => Visibility.Point,
Pre_Operation => Pre_Op,
Post_Operation => Post_Op);
function Get_Name (Element : Asis.Element) return Asis.Program_Text;
function Lookup_Operators
(Item : Asis.Element;
Tipe : Asis.Declaration) return Asis.Defining_Name_List;
function Print_Region (Point : Visibility.Point) return Boolean;
procedure Print_Region
(Point : Visibility.Point;
Prefix : Wide_String := "";
Mark : Visibility.Point);
--------------------
-- End_Of_Package --
--------------------
function End_Of_Package
(The_Package : Asis.Declaration)
return Asis.Element
is
use Asis.Elements;
begin
case Declaration_Kind (The_Package) is
when A_Package_Declaration |
A_Package_Body_Declaration |
A_Generic_Package_Declaration =>
return Declarations.Names (The_Package) (1);
when others =>
raise Internal_Error;
end case;
end End_Of_Package;
------------------------
-- Enter_Construction --
------------------------
procedure Enter_Construction
(Element : in Asis.Element;
Point : in out Visibility.Point)
is
begin
if not Utils.Is_Top_Declaration (Element) then
Enter_Each_Construction (Element, Point);
end if;
end Enter_Construction;
-----------------------------
-- Enter_Each_Construction --
-----------------------------
procedure Enter_Each_Construction
(Element : in Asis.Element;
Point : in out Visibility.Point)
is
use Asis.Elements;
procedure Try_Unhide_Parent is
Decl : constant Asis.Declaration :=
XASIS.Utils.Parent_Declaration (Element);
begin
if not Is_Nil (Decl) then
case Declaration_Kind (Decl) is
when A_Package_Declaration |
A_Generic_Package_Declaration |
A_Procedure_Body_Declaration |
A_Function_Body_Declaration =>
Utils.Unhide_Declaration (Decl, Point);
when others =>
null;
end case;
end if;
end Try_Unhide_Parent;
Kind : constant Asis.Element_Kinds := Element_Kind (Element);
Stmt : Asis.Statement_Kinds;
Needed : Boolean := False;
Is_Compl : Boolean := False;
Is_Instance : Boolean := False;
Skip_Formal : Boolean := False;
RR_Clause : Boolean := False;
Overridden : Boolean := False;
begin
Utils.Set_Place (Element, Point);
case Kind is
when Asis.A_Declaration =>
Try_Unhide_Parent;
Resolve_Profile (Element, Point);
Needed := True;
if XASIS.Utils.Can_Be_Completion (Element) then
Utils.Check_Completion (Element, Point);
Is_Compl := XASIS.Utils.Is_Completion (Element)
or Asis.Declarations.Is_Subunit (Element);
end if;
if Utils.Is_Template (Element) then
Is_Instance := True;
end if;
if Declaration_Kind (Element) in A_Formal_Declaration and then
Is_Part_Of_Instance (Element)
then
declare
Expr : constant Asis.Expression :=
Element_Utils.Generic_Actual (Element);
begin
if Assigned (Expr) and
Expression_Kind (Expr) /= A_Box_Expression
then
Skip_Formal := True;
end if;
end;
end if;
when Asis.An_Exception_Handler =>
Needed := True;
when Asis.A_Statement =>
Try_Unhide_Parent;
Resolve_Profile (Element, Point);
Stmt := Asis.Elements.Statement_Kind (Element);
if Stmt in Asis.A_Loop_Statement .. Asis.A_Block_Statement or
Stmt = Asis.An_Accept_Statement or
Stmt = Asis.An_Extended_Return_Statement
then
Needed := True;
end if;
when A_Definition =>
case Definition_Kind (Element) is
when A_Record_Definition |
A_Null_Record_Definition |
A_Task_Definition |
A_Protected_Definition =>
Utils.Unhide_Declaration
(XASIS.Utils.Parent_Declaration (Element), Point);
when others =>
null;
end case;
when A_Pragma =>
Try_Unhide_Parent;
when A_Clause =>
case Representation_Clause_Kind (Element) is
when A_Record_Representation_Clause =>
Resolve_RR_Name (Element, Point);
RR_Clause := True;
Needed := True;
when others =>
null;
end case;
when others =>
null;
end case;
if not Skip_Formal then
Create.Region_Items (Element, Point, Asis.Nil_Element, Overridden);
end if;
if Overridden then
Errors.Report (Element, Errors.Error_Name_Redeclaration);
end if;
if not Needed then
return;
end if;
if Utils.Need_New_Region (Element) or RR_Clause then
if Is_Compl or Is_Instance or RR_Clause then
Push (Region_Stack, (Element, Point));
Create.Completion_Region (Element, Point, Is_Instance, RR_Clause);
else
Push (Region_Stack, (Element, Point));
Create.Region (Element, Point);
end if;
end if;
if Kind /= A_Defining_Name then
Utils.Set_Place (Element, Point); -- set place to deeper region
end if;
end Enter_Each_Construction;
----------------
-- Enter_Unit --
----------------
function Enter_Unit (Unit : Asis.Compilation_Unit) return Point is
Point : Visibility.Point;
Element : Asis.Element;
begin
Utils.Find_Parent_Region (Unit, Point);
Element := Asis.Elements.Unit_Declaration (Unit);
Enter_Each_Construction (Element, Point);
return Point;
end Enter_Unit;
--------------
-- Get_Name --
--------------
function Get_Name (Element : Asis.Element) return Asis.Program_Text is
begin
if Asis.Elements.Element_Kind (Element) = An_Expression then
return Asis.Expressions.Name_Image (Element);
else
return XASIS.Utils.Direct_Name (Element);
end if;
end Get_Name;
-----------------
-- Is_Declared --
-----------------
function Is_Declared (Name : in Asis.Defining_Name) return Boolean
renames Utils.Is_Declared;
------------------------
-- Leave_Construction --
------------------------
procedure Leave_Construction
(Element : in Asis.Element;
Point : in out Visibility.Point)
is
use XASIS.Utils;
use Asis.Elements;
Kind : constant Asis.Element_Kinds := Element_Kind (Element);
Item : Stack_Item;
Part : Part_Access;
begin
case Kind is
when Asis.A_Declaration =>
Utils.Unhide_Declaration (Element, Point);
case Declaration_Kind (Element) is
when A_Package_Declaration =>
if Point.Item.Part.Kind = A_Visible_Part and not
Is_Part_Of_Implicit (Element)
then
Create.New_Part
(Region => Point.Item.Part.Region,
Kind => A_Private_Part,
Parent_Item => Point.Item.Part.Parent_Item,
Element => Declaration_Name (Element),
Check_Private => True,
Result => Part);
end if;
when others =>
null;
end case;
when Asis.A_Clause =>
Create.Use_Clause (Element, Point);
when others =>
null;
end case;
if not Is_Empty (Region_Stack)
and then Is_Equal (Top (Region_Stack).Element, Element)
then
Pop (Region_Stack, Item);
Point := Item.Point;
elsif Utils.Need_New_Region (Element) then
raise Internal_Error;
end if;
end Leave_Construction;
------------
-- Lookup --
------------
function Lookup
(Item : Asis.Element;
Point : Visibility.Point)
return Asis.Defining_Name_List
is
pragma Assert (Debug.Run (Item, Debug.Lookup)
or else Print_Region (Point));
Direct : constant Asis.Defining_Name_List := Lookup_Direct (Item, Point);
begin
return Direct & Lookup_Use (Item, Direct, Point);
end Lookup;
-------------------
-- Lookup_Direct --
-------------------
function Lookup_Direct
(Item : Asis.Element;
Point : Visibility.Point)
return Asis.Defining_Name_List
is
use Asis.Elements;
Name : constant Asis.Program_Text := Get_Name (Item);
First : constant Region_Item_Access := Utils.Find_Name (Name, Point);
Unit : constant Asis.Compilation_Unit :=
Enclosing_Compilation_Unit (Item);
begin
if First = null then
return Asis.Nil_Element_List;
end if;
declare
Result : Asis.Defining_Name_List (1 .. First.Count);
Index : Asis.ASIS_Natural := 0;
begin
Utils.Find_All (First, Index, Result, Unit, Point);
if Index /= 0 then
Utils.Strip_Homograph (Index, Result, Item);
end if;
return Result (1 .. Index);
end;
end Lookup_Direct;
-----------------------------
-- Lookup_In_Parent_Region --
-----------------------------
function Lookup_In_Parent_Region
(Item : Asis.Element;
Element : Asis.Element) return Asis.Defining_Name_List
is
Point : Visibility.Point := Utils.Find_Region (Element);
begin
Point :=
(Item => Point.Item.Part.Parent_Item.Part.Region.Last_Part.Last_Item);
return Lookup_In_Region (Item, Point, Point);
end Lookup_In_Parent_Region;
----------------------
-- Lookup_In_Region --
----------------------
function Lookup_In_Region
(Item : Asis.Element;
Reg : Visibility.Point;
Point : Visibility.Point)
return Asis.Defining_Name_List
is
use Asis.Elements;
Name : constant Asis.Program_Text := Get_Name (Item);
Unit : constant Asis.Compilation_Unit :=
Enclosing_Compilation_Unit (Item);
First : constant Region_Item_Access :=
Utils.Find_Name (Name, Reg, No_Parent_Region => True);
begin
if First = null or else First.Part.Region /= Reg.Item.Part.Region then
return Asis.Nil_Element_List;
end if;
declare
Result : Asis.Defining_Name_List (1 .. First.Count);
Index : Asis.ASIS_Natural := 0;
begin
Utils.Find_All
(First, Index, Result, Unit, Point, No_Parent_Region => True);
return Result (1 .. Index);
end;
end Lookup_In_Region;
----------------------
-- Lookup_In_Region --
----------------------
function Lookup_In_Region
(Item : Asis.Element;
Element : Asis.Element;
Point : Visibility.Point)
return Asis.Defining_Name_List
is
Reg : constant Visibility.Point := Utils.Find_Region (Element);
begin
return Lookup_In_Region (Item, Reg, Point);
end Lookup_In_Region;
----------------------
-- Lookup_Operators --
----------------------
function Lookup_Operators
(Item : Asis.Element;
Tipe : Asis.Declaration) return Asis.Defining_Name_List
is
Name : constant Asis.Program_Text := Get_Name (Item);
Def : constant Asis.Definition :=
Asis.Declarations.Type_Declaration_View (Tipe);
List : constant Asis.Declaration_List :=
Corresponding_Type_Operators (Def.all);
-- Asis.Definitions.Corresponding_Type_Operators (Def);
-- because we want Private_Type_Definition, etc
Result : Asis.Defining_Name_List (List'Range);
Index : Asis.List_Index := 1;
begin
for I in List'Range loop
Result (Index) := XASIS.Utils.Get_Defining_Name (List (I), Name);
if Assigned (Result (Index))
and then Visible_From (Result (Index), Item)
then
Index := Index + 1;
end if;
end loop;
return Result (1 .. Index - 1);
end Lookup_Operators;
----------------
-- Lookup_Use --
----------------
function Lookup_Use
(Item : Asis.Element;
Direct : Asis.Defining_Name_List;
Point : Visibility.Point)
return Asis.Defining_Name_List
is
use Asis.Gela.Utils;
use Asis.Gela.Lists.Secondary_Definition_Lists;
procedure Check_And_Add
(Local : in Asis.Defining_Name_List;
List : in out List_Node;
Item : in Asis.Defining_Name;
Fail : out Boolean)
is
begin
for I in Local'Range loop
if Are_Homographs (Local (I), Item, Lookup_Use.Item) then
Fail := False;
return;
end if;
end loop;
for I in 1 .. Length (List) loop
if Are_Homographs (Get (List, I), Item, Lookup_Use.Item) then
Fail := False;
return;
end if;
end loop;
if Length (List) = 1 then
if not XASIS.Utils.Overloadable (Get (List, 1)) then
Fail := True;
return;
end if;
end if;
if not XASIS.Utils.Overloadable (Item) and Length (List) > 0 then
Fail := True;
return;
end if;
Add (List, Item);
Fail := False;
end Check_And_Add;
List : List_Node;
Next : Region_Item_Access := Point.Item;
Part : Part_Access := Next.Part;
Region : Region_Access := Part.Region;
Stored_Item : Region_Item_Access;
With_Private : Boolean := True;
From_Visible : Boolean;
Fail : Boolean;
begin
-- loop over regions (Region)
while Region /= null loop
Stored_Item := Next;
From_Visible := Is_Visible (Next.Part.Kind);
-- loop over region items (Item)
while Next /= null loop
if not With_Private
and Region.Library_Unit
and not Is_Visible (Next.Part.Kind)
then
null;
elsif Next.Kind = Use_Package then
declare
Names : constant Asis.Defining_Name_List :=
Lookup_In_Region (Item, Next.Declaration, Point);
begin
for I in Names'Range loop
Check_And_Add (Direct, List, Names (I), Fail);
if Fail then
return Asis.Nil_Element_List;
end if;
end loop;
end;
elsif Next.Kind = Use_Type then
declare
Names : constant Asis.Defining_Name_List :=
Lookup_Operators (Item,
Classes.Get_Declaration (Next.Tipe));
begin
for I in reverse Names'Range loop
Check_And_Add (Direct, List, Names (I), Fail);
if Fail then
return Asis.Nil_Element_List;
end if;
end loop;
end;
end if;
Next := Next.Next;
if Next = null then
Part := Part.Next;
if Part /= null then
Next := Part.Last_Item;
end if;
end if;
end loop;
if Region.Library_Unit
and Region.Public_Child
and From_Visible
then
With_Private := False;
else
With_Private := True;
end if;
Next := Stored_Item.Part.Parent_Item;
if Next /= null then
Part := Next.Part;
Region := Part.Region;
else
Part := null;
Region := null;
end if;
end loop;
return To_Element_List (List);
end Lookup_Use;
------------------------------
-- New_Implicit_Declaration --
------------------------------
procedure New_Implicit_Declaration
(Element : in Asis.Declaration;
Point : in out Visibility.Point;
Tipe : in Asis.Declaration;
Overridden : out Boolean)
is
begin
Utils.Set_Place (Element, Point);
Create.Region_Items (Element, Point, Tipe, Overridden);
if not Overridden then
Utils.Unhide_Declaration (Element, Point);
end if;
end New_Implicit_Declaration;
-------------
-- Post_Op --
-------------
procedure Post_Op (Element : in Asis.Element;
Control : in out Asis.Traverse_Control;
State : in out Visibility.Point) is
begin
null;
end Post_Op;
------------
-- Pre_Op --
------------
procedure Pre_Op (Element : in Asis.Element;
Control : in out Asis.Traverse_Control;
State : in out Visibility.Point)
is
Expr : constant Expression_Kinds :=
Asis.Elements.Expression_Kind (Element);
begin
if (Expr = An_Identifier or
Expr = An_Operator_Symbol or
Expr = A_Character_Literal) and
not Elements.Is_Part_Of_Implicit (Element) and
not Elements.Is_Part_Of_Instance (Element)
then
Try_To_Resolve (Element, State);
end if;
end Pre_Op;
------------------
-- Print_Region --
------------------
function Print_Region (Point : Visibility.Point) return Boolean is
begin
Print_Region ((Item => Utils.Top_Region.First_Part.Last_Item),
Mark => Point);
return True;
end Print_Region;
------------------
-- Print_Region --
------------------
procedure Print_Region
(Point : Visibility.Point;
Prefix : Wide_String := "";
Mark : Visibility.Point)
is
use Asis.Elements;
use Ada.Wide_Text_IO;
Item : Region_Item_Access := Point.Item;
Part : constant Part_Access := Item.Part;
Region : Region_Access := Part.Region;
Part_I : Part_Access := Region.Last_Part;
Lib_Unit : Wide_Character := ' ';
Public : Wide_Character := ' ';
Current : Wide_Character := ' ';
Visible : Wide_Character := ' ';
Depth : constant Wide_String := Integer'Wide_Image (Region.Depth);
begin
if Point.Item = null then
return;
end if;
if Region.Library_Unit then
Lib_Unit := 'L';
end if;
if Region.Public_Child then
Public := 'P';
end if;
Put_Line (Prefix & "<region lib='" & Lib_Unit &
"' pub='" & Public & "' depth='" & Depth & "'>");
while Part_I /= null loop
Put_Line (Prefix & "<part kind='" &
Part_Kinds'Wide_Image (Part_I.Kind) & "'>");
Put_Line (Prefix & " <element img='" &
Debug_Image (Part_I.Element) & "'/>");
if Part_I.Parent_Item /= null then
Put_Line (Prefix & "<parent name='" &
Debug_Image (Part_I.Parent_Item.Defining_Name) &
"'/>");
end if;
Item := Part_I.Last_Item;
while Item /= null loop
if Item = Mark.Item then
Current := 'C';
else
Current := ' ';
end if;
case Item.Kind is
when Definition | Char | Wide_Char | Wide_Wide_Char =>
if Item.Kind = Definition and then Item.Still_Hidden then
Visible := 'H';
else
Visible := ' ';
end if;
if Item.Kind = Definition and then Item.Library_Unit then
Lib_Unit := 'L';
else
Lib_Unit := ' ';
end if;
Put_Line (Prefix & "<item cur='" & Current
& "' vis='" & Visible & "' lib='" & Lib_Unit
& "' name='" & Debug_Image (Item.Defining_Name)
& "' cnt='"
& ASIS_Natural'Wide_Image (Item.Count)
& "'/>");
when Use_Package =>
Put_Line (Prefix & "<use_pkg cur='" & Current
& "' decl='"
& Debug_Image (Item.Declaration) & "'/>");
when Use_Type =>
Put_Line (Prefix & "<use_type cur='" & Current
& "' tipe='"
& Classes.Debug_Image (Item.Tipe) & "'/>");
when Dummy =>
Put_Line (Prefix & "<dummy cur='" & Current & "'/>");
end case;
Item := Item.Next;
end loop;
Put_Line (Prefix & "</part>");
Part_I := Part_I.Next;
end loop;
Region := Region.First_Child;
while Region /= null loop
Print_Region ((Item => Region.First_Part.Last_Item),
Prefix & " ", Mark);
Region := Region.Next;
end loop;
Put_Line (Prefix & "</region>");
end Print_Region;
------------------
-- Print_Region --
------------------
procedure Print_Region
(Point : Visibility.Point;
Prefix : Wide_String := "")
is
begin
Print_Region (Point, Prefix, (Item => null));
end Print_Region;
---------------------------
-- Print_Standard_Region --
---------------------------
procedure Print_Standard_Region is
begin
Print_Region ((Item => Utils.Top_Region.First_Part.Last_Item));
end Print_Standard_Region;
---------------------
-- Resolve_Profile --
---------------------
procedure Resolve_Profile
(Construct : in Asis.Element;
Point : in out Visibility.Point)
is
use Asis.Elements;
use Asis.Statements;
use Asis.Declarations;
Control : Asis.Traverse_Control := Continue;
procedure Resolve_Profile (List : Asis.Parameter_Specification_List) is
Mark : Asis.Expression;
begin
for I in List'Range loop
Mark := Object_Declaration_Subtype (List (I));
Resolve_Names (Mark, Control, Point);
end loop;
end Resolve_Profile;
Kind : constant Asis.Declaration_Kinds :=
Declaration_Kind (Construct);
begin
if Kind = A_Function_Declaration or
Kind = A_Function_Body_Declaration or
Kind = A_Function_Renaming_Declaration or
Kind = A_Function_Body_Stub or
Kind = A_Generic_Function_Declaration or
Kind = A_Formal_Function_Declaration
then
Resolve_Names (Result_Subtype (Construct), Control, Point);
end if;
if Kind = A_Function_Declaration or
Kind = A_Function_Body_Declaration or
Kind = A_Function_Renaming_Declaration or
Kind = A_Function_Body_Stub or
Kind = A_Generic_Function_Declaration or
Kind = A_Formal_Function_Declaration or
Kind = A_Procedure_Declaration or
Kind = A_Procedure_Body_Declaration or
Kind = A_Procedure_Renaming_Declaration or
Kind = An_Entry_Declaration or
Kind = An_Entry_Body_Declaration or
Kind = A_Procedure_Body_Stub or
Kind = A_Generic_Procedure_Declaration or
Kind = A_Formal_Procedure_Declaration
then
Resolve_Profile (Parameter_Profile (Construct));
elsif Statement_Kind (Construct) = An_Accept_Statement then
Resolve_Profile (Accept_Parameters (Construct));
end if;
end Resolve_Profile;
---------------------
-- Resolve_RR_Name --
---------------------
procedure Resolve_RR_Name
(Construct : in Asis.Element;
Point : in out Visibility.Point)
is
Name : constant Asis.Expression :=
Representation_Clause_Name (Construct.all);
Control : Asis.Traverse_Control := Continue;
begin
Resolve_Names (Name, Control, Point);
end Resolve_RR_Name;
----------------------
-- Set_Not_Declared --
----------------------
procedure Set_Not_Declared (Name : in Asis.Defining_Name) is
begin
Utils.Set_Name_Place (Name, (Item => null));
end Set_Not_Declared;
--------------------
-- Try_To_Resolve --
--------------------
procedure Try_To_Resolve
(Element : Asis.Expression;
Point : Visibility.Point)
is
use Asis.Elements;
use Asis.Expressions;
type Resolution is record
Allowed : Boolean;
In_Region : Boolean;
Construct : Asis.Element;
end record;
procedure Check (Result : out Resolution);
procedure Set_Region
(Result : in out Resolution;
Parent : in Asis.Expression);
function Is_Enclosing_Named_Construct
(Parent : Asis.Element;
Name : Asis.Defining_Name) return Boolean;
procedure Check (Result : out Resolution) is
Parent : constant Asis.Element := Enclosing_Element (Element);
begin
Result.Allowed := True;
Result.In_Region := False;
case Element_Kind (Parent) is
when A_Pragma =>
Result.Allowed := False;
when An_Association =>
case Association_Kind (Parent) is
when A_Record_Component_Association |
An_Array_Component_Association =>
-- if not Is_Equal (Element, Component_Expression (Parent))
-- then
-- Result.Allowed := False;
-- end if;
null;
when others =>
if not Is_Equal (Element, Actual_Parameter (Parent)) then
Result.Allowed := False;
end if;
end case;
when An_Expression =>
case Expression_Kind (Parent) is
when A_Selected_Component =>
if Is_Equal (Element, Selector (Parent)) then
Set_Region (Result, Prefix (Parent));
end if;
when An_Attribute_Reference =>
if Is_Equal (Element,
Attribute_Designator_Identifier (Parent))
then
Result.Allowed := False;
end if;
when others =>
null;
end case;
when others =>
null;
end case;
end Check;
function Is_Enclosing_Named_Construct
(Parent : Asis.Element;
Name : Asis.Defining_Name) return Boolean
is
use Asis.Statements;
use Asis.Declarations;
Declaration : Asis.Declaration := Nil_Element;
Parent_Name : Asis.Defining_Name := Nil_Element;
begin
if Is_Nil (Parent) then
return False;
end if;
case Element_Kind (Parent) is
when A_Declaration =>
case Declaration_Kind (Parent) is
when A_Task_Type_Declaration |
A_Protected_Type_Declaration |
A_Single_Task_Declaration |
A_Single_Protected_Declaration |
A_Procedure_Declaration |
A_Function_Declaration |
A_Procedure_Body_Declaration |
A_Function_Body_Declaration |
A_Task_Body_Declaration |
A_Protected_Body_Declaration |
An_Entry_Declaration |
An_Entry_Body_Declaration |
A_Generic_Procedure_Declaration |
A_Generic_Function_Declaration |
An_Ordinary_Type_Declaration =>
Parent_Name := Names (Parent) (1);
when others =>
null;
end case;
when A_Statement =>
case Statement_Kind (Parent) is
when A_Loop_Statement .. A_Block_Statement =>
Parent_Name := Statement_Identifier (Parent);
when An_Accept_Statement =>
Declaration := Corresponding_Name_Declaration (
Accept_Entry_Direct_Name (Parent));
Parent_Name := Names (Declaration) (1);
when others =>
null;
end case;
when others =>
null;
end case;
if Is_Equal (Parent_Name, Name) then
return True;
else
return Is_Enclosing_Named_Construct
(Enclosing_Element (Parent), Name);
end if;
end Is_Enclosing_Named_Construct;
procedure Set_Region
(Result : in out Resolution;
Parent : in Asis.Expression)
is
Identifier : Asis.Expression;
begin
Result.Allowed := False;
case Expression_Kind (Parent) is
when An_Identifier =>
Identifier := Parent;
when A_Selected_Component =>
Identifier := Selector (Parent);
when others =>
return;
end case;
declare
use Asis.Declarations;
Target : constant Asis.Declaration :=
Corresponding_Name_Declaration (Identifier);
begin
if Declaration_Kind (Target) in A_Renaming_Declaration then
Set_Region (Result,
Corresponding_Base_Entity (Target));
return;
end if;
end;
declare
Names : constant Asis.Defining_Name_List :=
Corresponding_Name_Definition_List (Identifier);
Found : Boolean := False;
begin
for I in Names'Range loop
if XASIS.Utils.Is_Package_Name (Names (I)) or else
XASIS.Utils.Is_Enclosing_Named_Construct (Parent, Names (I))
then
if not Found then
Found := True;
Result.Construct := Enclosing_Element (Names (I));
Result.In_Region := True;
Result.Allowed := True;
else
Result.Allowed := False;
-- Put_Line ("Ambigous prefix");
end if;
end if;
end loop;
end;
end Set_Region;
Res : Resolution;
Expr : constant Expression_Kinds :=
Asis.Elements.Expression_Kind (Element);
begin
pragma Assert (Expr = An_Identifier or
Expr = An_Operator_Symbol or
Expr = A_Character_Literal,
"Unexpected element in Try_To_Resolve");
Check (Res);
if not Res.Allowed then
return;
end if;
if Res.In_Region then
Element_Utils.Set_Resolved
(Element, Lookup_In_Region (Element, Res.Construct, Point));
else
Element_Utils.Set_Resolved
(Element, Lookup (Element, Point));
end if;
end Try_To_Resolve;
-------------------------
-- Try_To_Resolve_Goto --
-------------------------
procedure Try_To_Resolve_Goto
(Element : Asis.Expression;
Stmt : Asis.Statement)
is
Point : constant Visibility.Point := Utils.Goto_Enclosing_Region (Stmt);
begin
Try_To_Resolve (Element, Point);
end Try_To_Resolve_Goto;
------------------
-- Visible_From --
------------------
function Visible_From
(Name : in Asis.Defining_Name;
Point : in Asis.Identifier) return Boolean
renames Utils.Visible_From;
-----------------
-- Unique_Name --
-----------------
function Unique_Name (Name : in Asis.Defining_Name) return Wide_String is
use Asis.Elements;
function Get_Parent (Reg : Region_Access) return Region_Access is
begin
if Reg = Utils.Top_Region'Access then
return null;
else
return Reg.Last_Part.Parent_Item.Part.Region;
end if;
end Get_Parent;
function Count_Siblings (Reg : Region_Access) return Positive is
Parent : constant Region_Access := Get_Parent (Reg);
Current : Region_Access := Parent.First_Child;
Result : Positive := 1;
begin
while Current /= Reg loop
Result := Result + 1;
Current := Current.Next;
end loop;
return Result;
end Count_Siblings;
function Region_Name (Reg : Region_Access) return Wide_String is
use XASIS.Utils;
Parent : constant Region_Access := Get_Parent (Reg);
begin
if Parent = null or Parent = Utils.Top_Region'Access then
return "";
elsif Element_Kind (Reg.First_Part.Element) = A_Declaration then
return Unique_Name (Declaration_Name (Reg.First_Part.Element))
& ".";
else
declare
Img : Wide_String := Positive'Wide_Image (Count_Siblings (Reg));
begin
Img (1) := '_';
return Region_Name (Parent) & Img & '.';
end;
end if;
end Region_Name;
-- Go from completion to declaration
function Declaration_Name return Asis.Defining_Name is
use XASIS.Utils;
Comp : Asis.Declaration := Enclosing_Element (Name);
Decl : Asis.Declaration;
begin
if Is_Completion (Comp) then
Decl := Declaration_For_Completion (Comp);
return Get_Defining_Name (Decl, Direct_Name (Name));
else
return Name;
end if;
end Declaration_Name;
Target : constant Asis.Defining_Name := Declaration_Name;
Item : constant Region_Item_Access := Utils.Get_Place (Target);
Point : constant Visibility.Point := (Item => Item);
Reg : constant Region_Access := Item.Part.Region;
Reg_Name : constant Wide_String := Region_Name (Reg);
Result : constant Asis.Defining_Name_List :=
Lookup_In_Region (Target, Point, Point);
begin
if Result'Length = 1 then
return Reg_Name & XASIS.Utils.Direct_Name (Target);
else
declare
Img : Wide_String := Positive'Wide_Image (Result'Length);
begin
Img (1) := '$';
return Reg_Name & XASIS.Utils.Direct_Name (Target) & Img;
end;
end if;
end Unique_Name;
end Asis.Gela.Visibility;
------------------------------------------------------------------------------
-- Copyright (c) 2006-2013, <NAME>
-- 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 <NAME>, 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 OWNER OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
|
30,436
|
ada
| 0
|
skill-lang/adaCommon
|
src/skill-field_types-builtin-string_type_p.adb
|
-- ___ _ ___ _ _ --
-- / __| |/ (_) | | Common SKilL implementation --
-- \__ \ ' <| | | |__ implementation of builtin field types --
-- |___/_|\_\_|_|____| by: <NAME> --
-- --
pragma Ada_2012;
with Ada.Containers;
with Ada.Containers.Doubly_Linked_Lists;
with Ada.Containers.Hashed_Maps;
with Ada.Containers.Hashed_Sets;
with Ada.Containers.Vectors;
with Skill.Types;
with Skill.Hashes; use Skill.Hashes;
with Skill.Types.Pools;
with Ada.Tags;
package body Skill.Field_Types.Builtin.String_Type_P is
function Get_Id_Map (THis : access Field_Type_T) return ID_Map is
begin
return THis.String_IDs'Access;
end Get_Id_Map;
procedure Write_Box
(This : access Field_Type_T;
Output : Streams.Writer.Sub_Stream;
Target : Types.Box)
is
V : Types.String_Access := Unboxed (Target);
use type Types.String_Access;
begin
if null = V then
Output.I8 (0);
else
Output.V64 (Types.v64 (This.String_IDs.Element (V)));
end if;
end Write_Box;
procedure Write_Single_Field
(THis : access Field_Type_T;
V : Types.String_Access;
Output : Skill.Streams.Writer.Sub_Stream)
is
use type Types.String_Access;
begin
if null = V then
Output.I8 (0);
else
Output.V64 (Types.v64 (THis.String_IDs.Element (V)));
end if;
end Write_Single_Field;
end Skill.Field_Types.Builtin.String_Type_P;
|
30,437
|
ada
| 13
|
annexi-strayline/AURA
|
unit_names.ads
|
------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- ANNEXI-STRAYLINE Reference Implementation --
-- --
-- Command Line Interface --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2019-2020, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * <NAME> (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- This package provides a standardized Unit/Subsystem name facility
-- All names going into a Unit_Name will be come from the Ada Lexical Parser,
-- and so will always have Unicode Simple Case Folding applied
with Ada.Strings.Wide_Wide_Unbounded;
package Unit_Names is
type Unit_Name is tagged private;
function "<" (Left, Right: Unit_Name) return Boolean;
-- Lexicographical
function Match_Initial (Name: Unit_Name; Initial: Wide_Wide_String)
return Boolean;
-- Returns True if Initial matches the head portion of the name.
--
-- eg: Name => abcde, Initial => abcd returns True
-- Initial => abcdef returns False
function Valid_Unit_Name (Candidate: in Wide_Wide_String) return Boolean;
-- Returns True iff Candidate is a valid unit name, according to the RM,
-- which means an expanded name, or if the name is a properly formatted
-- AURA "external unit" name.
--
-- Valid_Unit_Name is not a precondition to Set_Name because AURA constructs
-- names while parsing, and often times they transition through invalid
-- states.
--
-- Unit names sources externaly should be checked via this function whenever
-- it is possible that the user could provide an invalid unit name
function Is_External_Unit (Name: Unit_Name) return Boolean with
Pre => Valid_Unit_Name (Name.To_String);
-- Returns True if Name is for an "external unit"
function To_String (Name: Unit_Name) return Wide_Wide_String;
function To_UTF8_String (Name: Unit_Name) return String;
function Set_Name (S: Wide_Wide_String) return Unit_Name;
procedure Set_Name (Name: out Unit_Name;
S : in Wide_Wide_String);
-- Returns or Sets Name after applying Simple Case Folding to
-- S.
procedure Prepend (Name: in out Unit_Name; S: in Wide_Wide_String);
procedure Append (Name: in out Unit_Name; S: in Wide_Wide_String);
-- Prepends/Appends S to the end of Unit_Name
-- Mainly used when building a name during parsing.
function "&" (Left: Unit_Name; Right: Wide_Wide_String) return Unit_Name;
function "&" (Left: Wide_Wide_String; Right: Unit_Name) return Unit_Name;
function "&" (Left, Right: Unit_Name) return Unit_Name;
function Empty (Name: Unit_Name) return Boolean;
function Parent_Name (Name: Unit_Name) return Unit_Name;
-- Returns the unit name for the parent of an Ada unit. If
-- Name is already a top-level name (a subsystem), the returned
-- Unit_Name is empty.
--
-- This subprogram should not be invoked on non-Ada unit names
--
-- E.g. for N: Name = "a.b.c.d":
-- N.Parent_Unit = "a.b.c"
--
-- For N: Name = "p":
-- N.Parent_Unit = ""
function Subsystem_Name (Name: Unit_Name) return Unit_Name;
-- Extracts the Subsystem name from a full name. This simply means
-- it extracts the identifier that consists of the first prefixed portion.
--
-- E.g. For N: Name := "a.b.c.d":
-- N.Subsystem_Name = "a"
--
-- For N: Name := "p":
-- N.Subsystem_Name = "p"
--
-- For the external dependency where N: Name := "p%binding.c"
-- N.Subsystem_Name = "p"
function Self_Direct_Name (Name: Unit_Name) return Unit_Name;
-- Returns the direct name of Name from the perspective of that unit. I.e:
--
-- For N: Name := "a.b.c.d":
-- N.Self_Direct_Name = "d"
--
-- For N: Name := "p":
-- N.Self_Direct_Name = "p"
--
-- For N: Name := "p%binding.c"
-- N.Self_Direct_Name = "binding.c"
private
package WWU renames Ada.Strings.Wide_Wide_Unbounded;
type Unit_Name is tagged
record
Name_String: WWU.Unbounded_Wide_Wide_String;
end record;
end Unit_Names;
|
30,438
|
ada
| 0
|
RREE/Ada_Drivers_Library
|
examples/shared/serial_ports/src/serial_io-blocking.ads
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2022, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- This package defines an abstract data type for a "serial port" providing
-- blocking input (Get) and output (Put) procedures. The procedures are
-- considered blocking in that they do not return to the caller until the
-- entire message is received or sent.
--
-- The serial port abstraction is a wrapper around a USART peripheral,
-- described by a value of type Peripheral_Descriptor.
--
-- Polling is used within the procedures to determine when characters are sent
-- and received.
with Message_Buffers; use Message_Buffers;
package Serial_IO.Blocking is
pragma Elaborate_Body;
type Serial_Port (Device : not null access Peripheral_Descriptor) is
tagged limited private;
procedure Initialize_Hardware (This : out Serial_Port);
procedure Configure
(This : in out Serial_Port;
Baud_Rate : Baud_Rates;
Parity : Parities := No_Parity;
Data_Bits : Word_Lengths := Word_Length_8;
End_Bits : Stop_Bits := Stopbits_1;
Control : Flow_Control := No_Flow_Control);
procedure Send (This : in out Serial_Port; Msg : not null access Message);
-- Sends Msg.Length characters of Msg via USART attached to This. Callers
-- wait until all characters are sent.
procedure Receive (This : in out Serial_Port; Msg : not null access Message) with
Post => Msg.Length <= Msg.Physical_Size and
(if Msg.Length > 0 then Msg.Content_At (Msg.Length) /= Msg.Terminator);
-- Callers wait until all characters are received.
private
type Serial_Port (Device : access Peripheral_Descriptor) is tagged limited null record;
procedure Await_Send_Ready (This : USART) with Inline;
procedure Await_Data_Available (This : USART) with Inline;
end Serial_IO.Blocking;
|
30,439
|
ada
| 80
|
enfoTek/tomato.linksys.e2000.nvram-mod
|
tools-src/gnu/gcc/gcc/ada/g-socket.ads
|
<filename>tools-src/gnu/gcc/gcc/ada/g-socket.ads
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . S O C K E T S --
-- --
-- S p e c --
-- --
-- $Revision$
-- --
-- Copyright (C) 2001 Ada Core Technologies, 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 2, 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 COPYING. If not, write --
-- to the Free Software Foundation, 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. --
-- --
-- GNAT is maintained by Ada Core Technologies Inc (http://www.gnat.com). --
-- --
------------------------------------------------------------------------------
-- This package provides an interface to the sockets communication facility
-- provided on many operating systems. Currently this is implemented on all
-- native GNAT ports except for VMS. It is not yet implemented for any of
-- the cross-ports (e.g. it is not available for VxWorks or LynxOS).
-- Another restriction is that there is no multicast support under Windows
-- or under any system on which the multicast support is not available or
-- installed.
with Ada.Exceptions;
with Ada.Streams;
package GNAT.Sockets is
-- Sockets are designed to provide a consistent communication
-- facility between applications. This package provides an
-- Ada-like interface similar to the one proposed as part of the
-- BSD socket layer. This is a system independent thick binding.
-- Here is a typical example of what you can do.
-- with GNAT.Sockets; use GNAT.Sockets;
--
-- with Ada.Text_IO;
-- with Ada.Exceptions; use Ada.Exceptions;
--
-- procedure PingPong is
--
-- Group : constant String := "172.16.58.3";
-- -- Multicast groupe: administratively scoped IP address
--
-- task Pong is
-- entry Start;
-- entry Stop;
-- end Pong;
--
-- task body Pong is
-- Address : Sock_Addr_Type;
-- Server : Socket_Type;
-- Socket : Socket_Type;
-- Channel : Stream_Access;
--
-- begin
-- accept Start;
--
-- -- Get an Internet address of a host (here "localhost").
-- -- Note that a host can have several addresses. Here we get
-- -- the first one which is supposed to be the official one.
--
-- Address.Addr := Addresses (Get_Host_By_Name ("localhost"), 1);
--
-- -- Get a socket address that is an Internet address and a port
--
-- Address.Port := 5432;
--
-- -- The first step is to create a socket. Once created, this
-- -- socket must be associated to with an address. Usually only a
-- -- server (Pong here) needs to bind an address explicitly.
-- -- Most of the time clients can skip this step because the
-- -- socket routines will bind an arbitrary address to an unbound
-- -- socket.
--
-- Create_Socket (Server);
--
-- -- Allow reuse of local addresses.
--
-- Set_Socket_Option
-- (Server,
-- Socket_Level,
-- (Reuse_Address, True));
--
-- Bind_Socket (Server, Address);
--
-- -- A server marks a socket as willing to receive connect events.
--
-- Listen_Socket (Server);
--
-- -- Once a server calls Listen_Socket, incoming connects events
-- -- can be accepted. The returned Socket is a new socket that
-- -- represents the server side of the connection. Server remains
-- -- available to receive further connections.
--
-- Accept_Socket (Server, Socket, Address);
--
-- -- Return a stream associated to the connected socket.
--
-- Channel := Stream (Socket);
--
-- -- Force Pong to block
--
-- delay 0.2;
--
-- -- Receive and print message from client Ping.
--
-- declare
-- Message : String := String'Input (Channel);
--
-- begin
-- Ada.Text_IO.Put_Line (Message);
--
-- -- Send same message to server Pong.
--
-- String'Output (Channel, Message);
-- end;
--
-- Close_Socket (Server);
-- Close_Socket (Socket);
--
-- -- Part of the multicast example
--
-- -- Create a datagram socket to send connectionless, unreliable
-- -- messages of a fixed maximum length.
--
-- Create_Socket (Socket, Family_Inet, Socket_Datagram);
--
-- -- Allow reuse of local addresses.
--
-- Set_Socket_Option
-- (Socket,
-- Socket_Level,
-- (Reuse_Address, True));
--
-- -- Join a multicast group.
--
-- Set_Socket_Option
-- (Socket,
-- IP_Protocol_For_IP_Level,
-- (Add_Membership, Inet_Addr (Group), Any_Inet_Addr));
--
-- -- Controls the live time of the datagram to avoid it being
-- -- looped forever due to routing errors. Routers decrement
-- -- the TTL of every datagram as it traverses from one network
-- -- to another and when its value reaches 0 the packet is
-- -- dropped. Default is 1.
--
-- Set_Socket_Option
-- (Socket,
-- IP_Protocol_For_IP_Level,
-- (Multicast_TTL, 1));
--
-- -- Want the data you send to be looped back to your host.
--
-- Set_Socket_Option
-- (Socket,
-- IP_Protocol_For_IP_Level,
-- (Multicast_Loop, True));
--
-- -- If this socket is intended to receive messages, bind it to a
-- -- given socket address.
--
-- Address.Addr := Any_Inet_Addr;
-- Address.Port := 55505;
--
-- Bind_Socket (Socket, Address);
--
-- -- If this socket is intended to send messages, provide the
-- -- receiver socket address.
--
-- Address.Addr := Inet_Addr (Group);
-- Address.Port := 55506;
--
-- Channel := Stream (Socket, Address);
--
-- -- Receive and print message from client Ping.
--
-- declare
-- Message : String := String'Input (Channel);
--
-- begin
--
-- -- Get the address of the sender.
--
-- Address := Get_Address (Channel);
-- Ada.Text_IO.Put_Line (Message & " from " & Image (Address));
--
-- -- Send same message to server Pong.
--
-- String'Output (Channel, Message);
-- end;
--
-- Close_Socket (Socket);
--
-- accept Stop;
--
-- exception when E : others =>
-- Ada.Text_IO.Put_Line
-- (Exception_Name (E) & ": " & Exception_Message (E));
-- end Pong;
--
-- task Ping is
-- entry Start;
-- entry Stop;
-- end Ping;
--
-- task body Ping is
-- Address : Sock_Addr_Type;
-- Socket : Socket_Type;
-- Channel : Stream_Access;
--
-- begin
-- accept Start;
--
-- -- See comments in Ping section for the first steps.
--
-- Address.Addr := Addresses (Get_Host_By_Name ("localhost"), 1);
-- Address.Port := 5432;
-- Create_Socket (Socket);
--
-- Set_Socket_Option
-- (Socket,
-- Socket_Level,
-- (Reuse_Address, True));
--
-- -- Force Pong to block
--
-- delay 0.2;
--
-- -- If the client's socket is not bound, Connect_Socket will
-- -- bind to an unused address. The client uses Connect_Socket to
-- -- create a logical connection between the client's socket and
-- -- a server's socket returned by Accept_Socket.
--
-- Connect_Socket (Socket, Address);
--
-- Channel := Stream (Socket);
--
-- -- Send message to server Pong.
--
-- String'Output (Channel, "Hello world");
--
-- -- Force Ping to block
--
-- delay 0.2;
--
-- -- Receive and print message from server Pong.
--
-- Ada.Text_IO.Put_Line (String'Input (Channel));
-- Close_Socket (Socket);
--
-- -- Part of multicast example. Code similar to Pong's one.
--
-- Create_Socket (Socket, Family_Inet, Socket_Datagram);
--
-- Set_Socket_Option
-- (Socket,
-- Socket_Level,
-- (Reuse_Address, True));
--
-- Set_Socket_Option
-- (Socket,
-- IP_Protocol_For_IP_Level,
-- (Add_Membership, Inet_Addr (Group), Any_Inet_Addr));
--
-- Set_Socket_Option
-- (Socket,
-- IP_Protocol_For_IP_Level,
-- (Multicast_TTL, 1));
--
-- Set_Socket_Option
-- (Socket,
-- IP_Protocol_For_IP_Level,
-- (Multicast_Loop, True));
--
-- Address.Addr := Any_Inet_Addr;
-- Address.Port := 55506;
--
-- Bind_Socket (Socket, Address);
--
-- Address.Addr := Inet_Addr (Group);
-- Address.Port := 55505;
--
-- Channel := Stream (Socket, Address);
--
-- -- Send message to server Pong.
--
-- String'Output (Channel, "Hello world");
--
-- -- Receive and print message from server Pong.
--
-- declare
-- Message : String := String'Input (Channel);
--
-- begin
-- Address := Get_Address (Channel);
-- Ada.Text_IO.Put_Line (Message & " from " & Image (Address));
-- end;
--
-- Close_Socket (Socket);
--
-- accept Stop;
--
-- exception when E : others =>
-- Ada.Text_IO.Put_Line
-- (Exception_Name (E) & ": " & Exception_Message (E));
-- end Ping;
--
-- begin
-- -- Indicate whether the thread library provides process
-- -- blocking IO. Basically, if you are not using FSU threads
-- -- the default is ok.
--
-- Initialize (Process_Blocking_IO => False);
-- Ping.Start;
-- Pong.Start;
-- Ping.Stop;
-- Pong.Stop;
-- Finalize;
-- end PingPong;
procedure Initialize (Process_Blocking_IO : Boolean := False);
-- Initialize must be called before using any socket routines. If
-- the thread library provides process blocking IO - basically
-- with FSU threads - GNAT.Sockets should be initialized with a
-- value of True to simulate thread blocking IO. Further calls to
-- Initialize will be ignored.
procedure Finalize;
-- After Finalize is called it is not possible to use any routines
-- exported in by this package. This procedure is idempotent.
type Socket_Type is private;
-- Sockets are used to implement a reliable bi-directional
-- point-to-point, stream-based connections between
-- hosts. No_Socket provides a special value to denote
-- uninitialized sockets.
No_Socket : constant Socket_Type;
Socket_Error : exception;
-- There is only one exception in this package to deal with an
-- error during a socket routine. Once raised, its message
-- contains a string describing the error code.
function Image (Socket : Socket_Type) return String;
-- Return a printable string for Socket
function To_C (Socket : Socket_Type) return Integer;
-- Return a file descriptor to be used by external subprograms
-- especially the C functions that are not yet interfaced in this
-- package.
type Family_Type is (Family_Inet, Family_Inet6);
-- Address family (or protocol family) identifies the
-- communication domain and groups protocols with similar address
-- formats. IPv6 will soon be supported.
type Mode_Type is (Socket_Stream, Socket_Datagram);
-- Stream sockets provide connection-oriented byte
-- streams. Datagram sockets support unreliable connectionless
-- message based communication.
type Shutmode_Type is (Shut_Read, Shut_Write, Shut_Read_Write);
-- When a process closes a socket, the policy is to retain any
-- data queued until either a delivery or a timeout expiration (in
-- this case, the data are discarded). A finer control is
-- available through shutdown. With Shut_Read, no more data can be
-- received from the socket. With_Write, no more data can be
-- transmitted. Neither transmission nor reception can be
-- performed with Shut_Read_Write.
type Port_Type is new Natural;
-- Classical port definition. No_Port provides a special value to
-- denote uninitialized port. Any_Port provides a special value
-- enabling all ports.
Any_Port : constant Port_Type;
No_Port : constant Port_Type;
type Inet_Addr_Type (Family : Family_Type := Family_Inet) is private;
-- An Internet address depends on an address family (IPv4 contains
-- 4 octets and Ipv6 contains 16 octets). Any_Inet_Address is a
-- special value treated like a wildcard enabling all addresses.
-- No_Inet_Addr provides a special value to denote uninitialized
-- inet addresses.
Any_Inet_Addr : constant Inet_Addr_Type;
No_Inet_Addr : constant Inet_Addr_Type;
type Sock_Addr_Type (Family : Family_Type := Family_Inet) is record
Addr : Inet_Addr_Type (Family);
Port : Port_Type;
end record;
-- Socket addresses fully define a socket connection with a
-- protocol family, an Internet address and a port. No_Sock_Addr
-- provides a special value for uninitialized socket addresses.
No_Sock_Addr : constant Sock_Addr_Type;
function Image (Value : Inet_Addr_Type) return String;
-- Return an image of an Internet address. IPv4 notation consists
-- in 4 octets in decimal format separated by dots. IPv6 notation
-- consists in 16 octets in hexadecimal format separated by
-- colons (and possibly dots).
function Image (Value : Sock_Addr_Type) return String;
-- Return inet address image and port image separated by a colon.
function Inet_Addr (Image : String) return Inet_Addr_Type;
-- Convert address image from numbers-and-dots notation into an
-- inet address.
-- Host entries provide a complete information on a given host:
-- the official name, an array of alternative names or aliases and
-- array of network addresses.
type Host_Entry_Type
(Aliases_Length, Addresses_Length : Natural) is private;
function Official_Name (E : Host_Entry_Type) return String;
-- Return official name in host entry
function Aliases_Length (E : Host_Entry_Type) return Natural;
-- Return number of aliases in host entry
function Addresses_Length (E : Host_Entry_Type) return Natural;
-- Return number of addresses in host entry
function Aliases
(E : Host_Entry_Type;
N : Positive := 1)
return String;
-- Return N'th aliases in host entry. The first index is 1.
function Addresses
(E : Host_Entry_Type;
N : Positive := 1)
return Inet_Addr_Type;
-- Return N'th addresses in host entry. The first index is 1.
Host_Error : exception;
-- Exception raised by the two following procedures. Once raised,
-- its message contains a string describing the error code. This
-- exception is raised when an host entry can not be retrieved.
function Get_Host_By_Address
(Address : Inet_Addr_Type;
Family : Family_Type := Family_Inet)
return Host_Entry_Type;
-- Return host entry structure for the given inet address
function Get_Host_By_Name
(Name : String)
return Host_Entry_Type;
-- Return host entry structure for the given host name
function Host_Name return String;
-- Return the name of the current host
-- Errors are described by an enumeration type. There is only one
-- exception Socket_Error in this package to deal with an error
-- during a socket routine. Once raised, its message contains the
-- error code between brackets and a string describing the error
-- code.
type Error_Type is
(Permission_Denied,
Address_Already_In_Use,
Cannot_Assign_Requested_Address,
Address_Family_Not_Supported_By_Protocol,
Operation_Already_In_Progress,
Bad_File_Descriptor,
Connection_Refused,
Bad_Address,
Operation_Now_In_Progress,
Interrupted_System_Call,
Invalid_Argument,
Input_Output_Error,
Transport_Endpoint_Already_Connected,
Message_Too_Long,
Network_Is_Unreachable,
No_Buffer_Space_Available,
Protocol_Not_Available,
Transport_Endpoint_Not_Connected,
Operation_Not_Supported,
Protocol_Not_Supported,
Socket_Type_Not_Supported,
Connection_Timed_Out,
Resource_Temporarily_Unavailable,
Unknown_Host,
Host_Name_Lookup_Failure,
No_Address_Associated_With_Name,
Unknown_Server_Error,
Cannot_Resolve_Error);
-- Get_Socket_Options and Set_Socket_Options manipulate options
-- associated with a socket. Options may exist at multiple
-- protocol levels in the communication stack. Socket_Level is the
-- uppermost socket level.
type Level_Type is (
Socket_Level,
IP_Protocol_For_IP_Level,
IP_Protocol_For_UDP_Level,
IP_Protocol_For_TCP_Level);
-- There are several options available to manipulate sockets. Each
-- option has a name and several values available. Most of the
-- time, the value is a boolean to enable or disable this option.
type Option_Name is (
Keep_Alive, -- Enable sending of keep-alive messages
Reuse_Address, -- Allow bind to reuse local address
Broadcast, -- Enable datagram sockets to recv/send broadcast packets
Send_Buffer, -- Set/get the maximum socket send buffer in bytes
Receive_Buffer, -- Set/get the maximum socket recv buffer in bytes
Linger, -- Shutdown wait for msg to be sent or timeout occur
Error, -- Get and clear the pending socket error
No_Delay, -- Do not delay send to coalesce packets (TCP_NODELAY)
Add_Membership, -- Join a multicast group
Drop_Membership, -- Leave a multicast group
Multicast_TTL, -- Indicates the time-to-live of sent multicast packets
Multicast_Loop); -- Sent multicast packets are looped to the local socket
type Option_Type (Name : Option_Name := Keep_Alive) is record
case Name is
when Keep_Alive |
Reuse_Address |
Broadcast |
Linger |
No_Delay |
Multicast_Loop =>
Enabled : Boolean;
case Name is
when Linger =>
Seconds : Natural;
when others =>
null;
end case;
when Send_Buffer |
Receive_Buffer =>
Size : Natural;
when Error =>
Error : Error_Type;
when Add_Membership |
Drop_Membership =>
Multiaddr : Inet_Addr_Type;
Interface : Inet_Addr_Type;
when Multicast_TTL =>
Time_To_Live : Natural;
end case;
end record;
-- There are several controls available to manipulate
-- sockets. Each option has a name and several values available.
-- These controls differ from the socket options in that they are
-- not specific to sockets but are available for any device.
type Request_Name is (
Non_Blocking_IO, -- Cause a caller not to wait on blocking operations.
N_Bytes_To_Read); -- Return the number of bytes available to read
type Request_Type (Name : Request_Name := Non_Blocking_IO) is record
case Name is
when Non_Blocking_IO =>
Enabled : Boolean;
when N_Bytes_To_Read =>
Size : Natural;
end case;
end record;
procedure Create_Socket
(Socket : out Socket_Type;
Family : Family_Type := Family_Inet;
Mode : Mode_Type := Socket_Stream);
-- Create an endpoint for communication. Raise Socket_Error on error.
procedure Accept_Socket
(Server : Socket_Type;
Socket : out Socket_Type;
Address : out Sock_Addr_Type);
-- Extract the first connection request on the queue of pending
-- connections, creates a new connected socket with mostly the
-- same properties as Server, and allocates a new socket. The
-- returned Address is filled in with the address of the
-- connection. Raise Socket_Error on error.
procedure Bind_Socket
(Socket : Socket_Type;
Address : Sock_Addr_Type);
-- Once a socket is created, assign a local address to it. Raise
-- Socket_Error on error.
procedure Close_Socket (Socket : Socket_Type);
-- Close a socket and more specifically a non-connected socket.
procedure Connect_Socket
(Socket : Socket_Type;
Server : in out Sock_Addr_Type);
-- Make a connection to another socket which has the address of
-- Server. Raise Socket_Error on error.
procedure Control_Socket
(Socket : Socket_Type;
Request : in out Request_Type);
-- Obtain or set parameter values that control the socket. This
-- control differs from the socket options in that they are not
-- specific to sockets but are avaiable for any device.
function Get_Peer_Name (Socket : Socket_Type) return Sock_Addr_Type;
-- Return the peer or remote socket address of a socket. Raise
-- Socket_Error on error.
function Get_Socket_Name (Socket : Socket_Type) return Sock_Addr_Type;
-- Return the local or current socket address of a socket. Raise
-- Socket_Error on error.
function Get_Socket_Option
(Socket : Socket_Type;
Level : Level_Type := Socket_Level;
Name : Option_Name)
return Option_Type;
-- Get the options associated with a socket. Raise Socket_Error on
-- error.
procedure Listen_Socket
(Socket : Socket_Type;
Length : Positive := 15);
-- To accept connections, a socket is first created with
-- Create_Socket, a willingness to accept incoming connections and
-- a queue Length for incoming connections are specified. Raise
-- Socket_Error on error.
procedure Receive_Socket
(Socket : Socket_Type;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
-- Receive message from Socket. Last is the index value such that
-- Item (Last) is the last character assigned. Note that Last is
-- set to Item'First - 1 when the socket has been closed by
-- peer. This is not an error and no exception is raised. Raise
-- Socket_Error on error.
procedure Receive_Socket
(Socket : Socket_Type;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
From : out Sock_Addr_Type);
-- Receive message from Socket. If Socket is not
-- connection-oriented, the source address From of the message is
-- filled in. Last is the index value such that Item (Last) is the
-- last character assigned. Raise Socket_Error on error.
function Resolve_Exception
(Occurrence : Ada.Exceptions.Exception_Occurrence)
return Error_Type;
-- When Socket_Error or Host_Error are raised, the exception
-- message contains the error code between brackets and a string
-- describing the error code. Resolve_Error extracts the error
-- code from an exception message and translate it into an
-- enumeration value.
procedure Send_Socket
(Socket : Socket_Type;
Item : Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
-- Transmit a message to another socket. Note that Last is set to
-- Item'First when socket has been closed by peer. This is not an
-- error and no exception is raised. Raise Socket_Error on error;
procedure Send_Socket
(Socket : Socket_Type;
Item : Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
To : Sock_Addr_Type);
-- Transmit a message to another socket. The address is given by
-- To. Raise Socket_Error on error;
procedure Set_Socket_Option
(Socket : Socket_Type;
Level : Level_Type := Socket_Level;
Option : Option_Type);
-- Manipulate socket options. Raise Socket_Error on error.
procedure Shutdown_Socket
(Socket : Socket_Type;
How : Shutmode_Type := Shut_Read_Write);
-- Shutdown a connected socket. If How is Shut_Read, further
-- receives will be disallowed. If How is Shut_Write, further
-- sends will be disallowed. If how is Shut_Read_Write, further
-- sends and receives will be disallowed.
type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class;
-- Same interface as Ada.Streams.Stream_IO
function Stream
(Socket : Socket_Type)
return Stream_Access;
-- Associate a stream with a stream-based socket that is already
-- connected.
function Stream
(Socket : Socket_Type;
Send_To : Sock_Addr_Type)
return Stream_Access;
-- Associate a stream with a datagram-based socket that is already
-- bound. Send_To is the socket address to which messages are
-- being sent.
function Get_Address
(Stream : Stream_Access)
return Sock_Addr_Type;
-- Return the socket address from which the last message was
-- received.
type Socket_Set_Type is private;
-- This type allows to manipulate sets of sockets. It allows to
-- wait for events on multiple endpoints at one time. This is an
-- access type on a system dependent structure. To avoid memory
-- leaks it is highly recommended to clean the access value with
-- procedure Empty.
procedure Clear (Item : in out Socket_Set_Type; Socket : Socket_Type);
-- Remove Socket from Item
procedure Set (Item : in out Socket_Set_Type; Socket : Socket_Type);
-- Insert Socket into Item
procedure Empty (Item : in out Socket_Set_Type);
-- Remove all Sockets from Item and deallocate internal data
function Is_Empty
(Item : Socket_Set_Type)
return Boolean;
-- Return True if Item is empty
function Is_Set
(Item : Socket_Set_Type;
Socket : Socket_Type)
return Boolean;
-- Return True if Socket is present in Item
-- C select() waits for a number of file descriptors to change
-- status. Usually, three independent sets of descriptors are
-- watched (read, write and exception). A timeout gives an upper
-- bound on the amount of time elapsed before select returns.
-- This function blocks until an event occurs. On some platforms,
-- C select can block the full process.
--
-- Check_Selector provides the very same behaviour. The only
-- difference is that it does not watch for exception events. Note
-- that on some platforms it is kept process blocking in purpose.
-- The timeout parameter allows the user to have the behaviour he
-- wants. Abort_Selector allows to abort safely a Check_Selector
-- that is blocked forever. A special file descriptor is opened by
-- Create_Selector and included in each call to
-- Check_Selector. Abort_Selector causes an event to occur on this
-- descriptor in order to unblock Check_Selector. The user must
-- call Close_Selector to discard this special file. A reason to
-- abort a select operation is typically to add a socket in one of
-- the socket sets when the timeout is set to forever.
Forever : constant Duration;
type Selector_Type is limited private;
type Selector_Access is access all Selector_Type;
procedure Create_Selector (Selector : out Selector_Type);
-- Create a new selector
procedure Close_Selector (Selector : in out Selector_Type);
-- Close Selector and all internal descriptors associated
type Selector_Status is (Completed, Expired, Aborted);
procedure Check_Selector
(Selector : in out Selector_Type;
R_Socket_Set : in out Socket_Set_Type;
W_Socket_Set : in out Socket_Set_Type;
Status : out Selector_Status;
Timeout : Duration := Forever);
-- Return when one Socket in R_Socket_Set has some data to be read
-- or if one Socket in W_Socket_Set is ready to receive some
-- data. In these cases Status is set to Completed and sockets
-- that are ready are set in R_Socket_Set or W_Socket_Set. Status
-- is set to Expired if no socket was ready after a Timeout
-- expiration. Status is set to Aborted if an abort signal as been
-- received while checking socket status. As this procedure
-- returns when Timeout occurs, it is a design choice to keep this
-- procedure process blocking. Note that a Timeout of 0.0 returns
-- immediatly.
procedure Abort_Selector (Selector : Selector_Type);
-- Send an abort signal to the selector.
private
type Socket_Type is new Integer;
No_Socket : constant Socket_Type := -1;
Forever : constant Duration := Duration'Last;
type Selector_Type is limited record
R_Sig_Socket : Socket_Type;
W_Sig_Socket : Socket_Type;
In_Progress : Boolean := False;
end record;
-- The two signalling sockets are used to abort a select
-- operation.
type Socket_Set_Record;
type Socket_Set_Type is access all Socket_Set_Record;
subtype Inet_Addr_Comp_Type is Natural range 0 .. 255;
-- Octet for Internet address
type Inet_Addr_VN_Type is array (Natural range <>) of Inet_Addr_Comp_Type;
subtype Inet_Addr_V4_Type is Inet_Addr_VN_Type (1 .. 4);
subtype Inet_Addr_V6_Type is Inet_Addr_VN_Type (1 .. 16);
type Inet_Addr_Type (Family : Family_Type := Family_Inet) is record
case Family is
when Family_Inet =>
Sin_V4 : Inet_Addr_V4_Type := (others => 0);
when Family_Inet6 =>
Sin_V6 : Inet_Addr_V6_Type := (others => 0);
end case;
end record;
Any_Port : constant Port_Type := 0;
No_Port : constant Port_Type := 0;
Any_Inet_Addr : constant Inet_Addr_Type := (Family_Inet, (others => 0));
No_Inet_Addr : constant Inet_Addr_Type := (Family_Inet, (others => 0));
No_Sock_Addr : constant Sock_Addr_Type := (Family_Inet, No_Inet_Addr, 0);
Max_Host_Name_Length : constant := 64;
-- The constant MAXHOSTNAMELEN is usually set to 64
subtype Host_Name_Index is Natural range 1 .. Max_Host_Name_Length;
type Host_Name_Type
(Length : Host_Name_Index := Max_Host_Name_Length)
is record
Name : String (1 .. Length);
end record;
-- We need fixed strings to avoid access types in host entry type
type Host_Name_Array is array (Natural range <>) of Host_Name_Type;
type Inet_Addr_Array is array (Natural range <>) of Inet_Addr_Type;
type Host_Entry_Type (Aliases_Length, Addresses_Length : Natural) is record
Official : Host_Name_Type;
Aliases : Host_Name_Array (1 .. Aliases_Length);
Addresses : Inet_Addr_Array (1 .. Addresses_Length);
end record;
end GNAT.Sockets;
|
30,440
|
ada
| 19
|
jquorning/ada-security
|
src/security-oauth-servers.ads
|
<filename>src/security-oauth-servers.ads
-----------------------------------------------------------------------
-- security-oauth-servers -- OAuth Server Authentication Support
-- Copyright (C) 2016, 2017, 2018 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- 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.Unbounded;
with Ada.Calendar;
with Ada.Finalization;
with Ada.Strings.Hash;
with Ada.Containers.Indefinite_Hashed_Maps;
with Util.Strings;
with Security.Auth;
with Security.Permissions;
-- == OAuth Server ==
-- OAuth server side is provided by the <tt>Security.OAuth.Servers</tt> package.
-- This package allows to implement the authorization framework described in RFC 6749
-- "The OAuth 2.0 Authorization Framework".
--
-- The authorization method produces a <tt>Grant_Type</tt> object that contains the result
-- of the grant (successful or denied). It is the responsibility of the caller to format
-- the result in JSON/XML and return it to the client.
--
-- Three important operations are defined for the OAuth 2.0 framework. They will be used
-- in the following order:
--
-- <tt>Authorize</tt> is used to obtain an authorization request. This operation is
-- optional in the OAuth 2.0 framework since some authorization method directly return
-- the access token. This operation is used by the "Authorization Code Grant" and the
-- "Implicit Grant".
--
-- <tt>Token</tt> is used to get the access token and optional refresh token. Each time it
-- is called, a new token is generated.
--
-- <tt>Authenticate</tt> is used for the API request to verify the access token
-- and authenticate the API call. This operation can be called several times with the same
-- token until the token is revoked or it has expired.
--
-- Several grant types are supported.
--
-- === Application Manager ===
-- The application manager maintains the repository of applications which are known by
-- the server and which can request authorization. Each application is identified by
-- a client identifier (represented by the <tt>client_id</tt> request parameter).
-- The application defines the authorization methods which are allowed as well as
-- the parameters to control and drive the authorization. This includes the redirection
-- URI, the application secret, the expiration delay for the access token.
--
-- The application manager is implemented by the application server and it must
-- implement the <tt>Application_Manager</tt> interface with the <tt>Find_Application</tt>
-- method. The <tt>Find_Application</tt> is one of the first call made during the
-- authenticate and token generation phases.
--
-- === Resource Owner Password Credentials Grant ===
-- The password grant is one of the easiest grant method to understand but it is also one
-- of the less secure. In this grant method, the username and user password are passed in
-- the request parameter together with the application client identifier. The realm verifies
-- the username and password and when they are correct it generates the access token with
-- an optional refresh token. The realm also returns in the grant the user principal that
-- identifies the user.
--
-- Realm : Security.OAuth.Servers.Auth_Manager;
-- Grant : Security.OAuth.Servers.Grant_Type;
--
-- Realm.Token (Params, Grant);
--
-- === Accessing Protected Resources ===
-- When accessing a protected resource, the API implementation will use the
-- <tt>Authenticate</tt> operation to verify the access token and get a security principal.
-- The security principal will identify the resource owner as well as the application
-- that is doing the call.
--
-- Realm : Security.OAuth.Servers.Auth_Manager;
-- Grant : Security.OAuth.Servers.Grant_Type;
-- Token : String := ...;
--
-- Realm.Authenticate (Token, Grant);
--
-- When a security principal is returned, the access token was validated and the
-- request is granted for the application.
--
package Security.OAuth.Servers is
-- Minimum length for the server private key (160 bits min length).
-- (See NIST Special Publication 800-107)
MIN_KEY_LENGTH : constant Positive := 20;
Invalid_Application : exception;
type Application is new Security.OAuth.Application with private;
-- Check if the application has the given permission.
function Has_Permission (App : in Application;
Permission : in Security.Permissions.Permission_Index) return Boolean;
type Principal is limited interface and Security.Principal;
type Principal_Access is access all Principal'Class;
-- Check if the permission was granted.
function Has_Permission (Auth : in Principal;
Permission : in Security.Permissions.Permission_Index)
return Boolean is abstract;
-- Define the status of the grant.
type Grant_Status is (Invalid_Grant, Expired_Grant, Revoked_Grant,
Stealed_Grant, Valid_Grant);
-- Define the grant type.
type Grant_Kind is (No_Grant, Access_Grant, Code_Grant,
Implicit_Grant, Password_Grant, Credential_Grant,
Extension_Grant);
-- The <tt>Grant_Type</tt> holds the results of the authorization.
-- When the grant is refused, the type holds information about the refusal.
type Grant_Type is record
-- The request grant type.
Request : Grant_Kind := No_Grant;
-- The response status.
Status : Grant_Status := Invalid_Grant;
-- When success, the token to return.
Token : Ada.Strings.Unbounded.Unbounded_String;
-- When success, the token expiration date.
Expires : Ada.Calendar.Time;
-- The token expiration date in seconds.
Expires_In : Duration := 0.0;
-- When success, the authentication principal.
Auth : Principal_Access;
-- When error, the type of error to return.
Error : Util.Strings.Name_Access;
end record;
type Application_Manager is limited interface;
type Application_Manager_Access is access all Application_Manager'Class;
-- Find the application that correspond to the given client id.
-- The <tt>Invalid_Application</tt> exception should be raised if there is no such application.
function Find_Application (Realm : in Application_Manager;
Client_Id : in String) return Application'Class is abstract;
type Realm_Manager is limited interface;
type Realm_Manager_Access is access all Realm_Manager'Class;
-- Authenticate the token and find the associated authentication principal.
-- The access token has been verified and the token represents the identifier
-- of the Tuple (client_id, user, session) that describes the authentication.
-- The <tt>Authenticate</tt> procedure should look in its database (internal
-- or external) to find the authentication principal that was granted for
-- the token Tuple. When the token was not found (because it was revoked),
-- the procedure should return a null principal. If the authentication
-- principal can be cached, the <tt>Cacheable</tt> value should be set.
-- In that case, the access token and authentication principal are inserted
-- in a cache.
procedure Authenticate (Realm : in out Realm_Manager;
Token : in String;
Auth : out Principal_Access;
Cacheable : out Boolean) is abstract;
-- Create an auth token string that identifies the given principal. The returned
-- token will be used by <tt>Authenticate</tt> to retrieve back the principal. The
-- returned token does not need to be signed. It will be inserted in the public part
-- of the returned access token.
function Authorize (Realm : in Realm_Manager;
App : in Application'Class;
Scope : in String;
Auth : in Principal_Access) return String is abstract;
procedure Verify (Realm : in out Realm_Manager;
Username : in String;
Password : in <PASSWORD>;
Auth : out Principal_Access) is abstract;
procedure Verify (Realm : in out Realm_Manager;
Token : in String;
Auth : out Principal_Access) is abstract;
procedure Revoke (Realm : in out Realm_Manager;
Auth : in Principal_Access) is abstract;
type Auth_Manager is tagged limited private;
type Auth_Manager_Access is access all Auth_Manager'Class;
-- Set the auth private key.
procedure Set_Private_Key (Manager : in out Auth_Manager;
Key : in String;
Decode : in Boolean := False);
-- Set the application manager to use and and applications.
procedure Set_Application_Manager (Manager : in out Auth_Manager;
Repository : in Application_Manager_Access);
-- Set the realm manager to authentify users.
procedure Set_Realm_Manager (Manager : in out Auth_Manager;
Realm : in Realm_Manager_Access);
-- 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);
-- 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);
-- 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);
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);
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);
-- 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);
-- Create a HMAC-SHA1 of the data with the private key.
-- This function can be overriden to use another signature algorithm.
function Sign (Realm : in Auth_Manager;
Data : in String) return String;
-- Forge an access token. The access token is signed by an HMAC-SHA1 signature.
-- The returned token is formed as follows:
-- <expiration>.<ident>.HMAC-SHA1(<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);
-- 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);
procedure Revoke (Realm : in out Auth_Manager;
Token : in String);
private
use Ada.Strings.Unbounded;
function Format_Expire (Expire : in Ada.Calendar.Time) return String;
-- Decode the expiration date that was extracted from the token.
function Parse_Expire (Expire : in String) return Ada.Calendar.Time;
type Application is new Security.OAuth.Application with record
Expire_Timeout : Duration := 3600.0;
Permissions : Security.Permissions.Permission_Index_Set := Security.Permissions.EMPTY_SET;
end record;
type Cache_Entry is record
Expire : Ada.Calendar.Time;
Auth : Principal_Access;
end record;
package Cache_Map is
new Ada.Containers.Indefinite_Hashed_Maps (Key_Type => String,
Element_Type => Cache_Entry,
Hash => Ada.Strings.Hash,
Equivalent_Keys => "=",
"=" => "=");
-- The access token cache is used to speed up the access token verification
-- when a request to a protected resource is made.
protected type Token_Cache is
procedure Authenticate (Token : in String;
Grant : in out Grant_Type);
procedure Insert (Token : in String;
Expire : in Ada.Calendar.Time;
Principal : in Principal_Access);
procedure Remove (Token : in String);
procedure Timeout;
private
Entries : Cache_Map.Map;
end Token_Cache;
type Auth_Manager is new Ada.Finalization.Limited_Controlled with record
-- The repository of applications.
Repository : Application_Manager_Access;
-- The realm for user authentication.
Realm : Realm_Manager_Access;
-- The server private key used by the HMAC signature.
Private_Key : Ada.Strings.Unbounded.Unbounded_String;
-- The access token cache.
Cache : Token_Cache;
-- The expiration time for the generated authorization code.
Expire_Code : Duration := 300.0;
end record;
-- The <tt>Token_Validity</tt> record provides information about a token to find out
-- the different components it is made of and verify its validity. The <tt>Validate</tt>
-- procedure is in charge of checking the components and verifying the HMAC signature.
-- The token has the following format:
-- <expiration>.<client_id>.<auth-ident>.hmac(<public>.<private-key>)
type Token_Validity is record
Status : Grant_Status := Invalid_Grant;
Ident_Start : Natural := 0;
Ident_End : Natural := 0;
Expire : Ada.Calendar.Time;
end record;
function Validate (Realm : in Auth_Manager;
Client_Id : in String;
Token : in String) return Token_Validity;
end Security.OAuth.Servers;
|
30,441
|
ada
| 3
|
stcarrez/ada-css
|
tools/css-analysis-classes.ads
|
<gh_stars>1-10
-----------------------------------------------------------------------
-- css-analysis-classes -- CSS Class Analysis
-- Copyright (C) 2017 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- 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.Indefinite_Ordered_Maps;
with CSS.Core.Errors;
with CSS.Core.Sets;
with CSS.Core.Selectors;
with CSS.Core.Sheets;
with CSS.Tools.Location_Sets;
-- == Analysis of CSS Classes ==
-- The <tt>CSS.Analysis.Classes</tt> package defines some simple analysis
-- arround the CSS classes defined and used by the CSS rule selectors.
package CSS.Analysis.Classes is
type Class_Information is record
Name : CSS.Core.Selectors.CSSSelector;
List : CSS.Core.Sets.Set;
Loc : CSS.Tools.Location_Sets.Set;
end record;
package Class_Maps is
new Ada.Containers.Indefinite_Ordered_Maps (Key_Type => String,
Element_Type => Class_Information);
subtype Map is Class_Maps.Map;
subtype Cursor is Class_Maps.Cursor;
-- Analyze the CSS selectors used by the stylesheet and collect the class
-- information with the associated CSS rules.
procedure Analyze (Sheet : in CSS.Core.Sheets.CSSStylesheet;
Result : in out Class_Maps.Map;
Report : in out CSS.Core.Errors.Error_Handler'Class);
end CSS.Analysis.Classes;
|
30,442
|
ada
| 0
|
annexi-strayline/ASAP-Modular_Hashing
|
modular_hashing-xxhash64.ads
|
<gh_stars>0
------------------------------------------------------------------------------
-- --
-- Modular Hash Infrastructure --
-- --
-- xxHash64 --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2021, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * <NAME> (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- This engine implements Yann Collet's xxHash32 hash algorithm that is freely
-- available at https://github.com/Cyan4973/xxHash (v 0.8.0)
-- Specific implementations (package bodies) contain further specific licenses
-- as needed.
with Ada.Streams;
with Interfaces;
package Modular_Hashing.xxHash64 is
type XXH64_Hash is new Hash with private;
-- xxHash is a non-cryptographic fixed-sized hash for arbitrary message
-- lengths. The digest is 64 bits (8 bytes).
overriding function "<" (Left, Right: XXH64_Hash) return Boolean;
overriding function ">" (Left, Right: XXH64_Hash) return Boolean;
overriding function "=" (Left, Right: XXH64_Hash) return Boolean;
XXH64_Hash_Bytes: constant := 8;
overriding function Binary_Bytes (Value: XXH64_Hash) return Positive is
(XXH64_Hash_Bytes);
overriding function Binary (Value: XXH64_Hash)
return Hash_Binary_Value
with Post => Binary'Result'Length = XXH64_Hash_Bytes;
type XXH64_Engine is new Hash_Algorithm with private;
overriding
procedure Write (Engine: in out XXH64_Engine;
Item : in Ada.Streams.Stream_Element_Array);
overriding procedure Reset (Engine: in out XXH64_Engine);
overriding function Digest (Engine: in out XXH64_Engine)
return Hash'Class;
private
use Ada.Streams, Interfaces;
subtype Accumulator_Type is Unsigned_64;
type XXH64_Hash is new Hash with
record
Digest: Accumulator_Type;
end record;
------------------
-- XXH64_Engine --
------------------
-- Prime constants
PRIME64_1: constant := 16#9E3779B185EBCA87#;
PRIME64_2: constant := 16#C2B2AE3D27D4EB4F#;
PRIME64_3: constant := 16#165667B19E3779F9#;
PRIME64_4: constant := 16#85EBCA77C2B2AE63#;
PRIME64_5: constant := 16#27D4EB2F165667C5#;
pragma Assert (Stream_Element'Size = 8);
type Accumulator_Array is array (1 .. 4) of Accumulator_Type;
Accumulators_Initial: constant Accumulator_Array
:= (1 => PRIME64_1 + PRIME64_2,
2 => PRIME64_2,
3 => 0,
4 => 0 - PRIME64_1);
type XXH64_Engine is new Hash_Algorithm with
record
Buffer : Stream_Element_Array(1 .. 32);
Last_Element: Stream_Element_Offset := 0;
-- XXH64 works on "stripes" of 16 bytes
Input_Total : Accumulator_Type := 0;
-- Total input length. Note that the xxHash specification says:
-- "If input length is so large that it requires more than 32-bits,
-- only the lower 32-bits are added to the accumulator". This applies
-- to xxHash64 as well.
--
-- In other words: wrap-around is OK
Accumulators: Accumulator_Array := Accumulators_Initial;
end record;
end Modular_Hashing.xxHash64;
|
30,443
|
ada
| 7
|
best08618/asylo
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/vect12.adb
|
-- { dg-do compile { target i?86-*-* x86_64-*-* } }
-- { dg-options "-O3 -msse2 -fdump-tree-vect-details" }
package body Vect12 is
function "+" (X, Y : Sarray) return Sarray is
R : Sarray;
begin
for I in Sarray'Range loop
pragma Loop_Optimize (No_Vector);
R(I) := X(I) + Y(I);
end loop;
return R;
end;
procedure Add (X, Y : Sarray; R : out Sarray) is
begin
for I in Sarray'Range loop
pragma Loop_Optimize (No_Vector);
R(I) := X(I) + Y(I);
end loop;
end;
end Vect12;
-- { dg-final { scan-tree-dump-not "vectorized 1 loops" "vect" } }
|
30,444
|
ada
| 0
|
JCGobbi/Nucleo-STM32F334R8
|
SVD2ada/svd/stm32_svd.ads
|
pragma Style_Checks (Off);
-- This spec has been automatically generated from STM32F3x4.svd
pragma Restrictions (No_Elaboration_Code);
with System;
-- STM32F3x4
package STM32_SVD is
pragma Preelaborate;
--------------------
-- Base addresses --
--------------------
GPIOA_Base : constant System.Address := System'To_Address (16#48000000#);
GPIOB_Base : constant System.Address := System'To_Address (16#48000400#);
GPIOC_Base : constant System.Address := System'To_Address (16#48000800#);
GPIOD_Base : constant System.Address := System'To_Address (16#48000C00#);
GPIOF_Base : constant System.Address := System'To_Address (16#48001400#);
TSC_Base : constant System.Address := System'To_Address (16#40024000#);
CRC_Base : constant System.Address := System'To_Address (16#40023000#);
Flash_Base : constant System.Address := System'To_Address (16#40022000#);
RCC_Base : constant System.Address := System'To_Address (16#40021000#);
DMA_Base : constant System.Address := System'To_Address (16#40020000#);
TIM2_Base : constant System.Address := System'To_Address (16#40000000#);
TIM15_Base : constant System.Address := System'To_Address (16#40014000#);
TIM16_Base : constant System.Address := System'To_Address (16#40014400#);
TIM17_Base : constant System.Address := System'To_Address (16#40014800#);
USART1_Base : constant System.Address := System'To_Address (16#40013800#);
USART2_Base : constant System.Address := System'To_Address (16#40004400#);
USART3_Base : constant System.Address := System'To_Address (16#40004800#);
SPI_Base : constant System.Address := System'To_Address (16#40013000#);
EXTI_Base : constant System.Address := System'To_Address (16#40010400#);
PWR_Base : constant System.Address := System'To_Address (16#40007000#);
I2C_Base : constant System.Address := System'To_Address (16#40005400#);
IWDG_Base : constant System.Address := System'To_Address (16#40003000#);
WWDG_Base : constant System.Address := System'To_Address (16#40002C00#);
RTC_Base : constant System.Address := System'To_Address (16#40002800#);
TIM6_Base : constant System.Address := System'To_Address (16#40001000#);
TIM7_Base : constant System.Address := System'To_Address (16#40001400#);
DAC1_Base : constant System.Address := System'To_Address (16#40007400#);
DAC2_Base : constant System.Address := System'To_Address (16#40009800#);
DBGMCU_Base : constant System.Address := System'To_Address (16#E0042000#);
TIM1_Base : constant System.Address := System'To_Address (16#40012C00#);
ADC1_Base : constant System.Address := System'To_Address (16#50000000#);
ADC2_Base : constant System.Address := System'To_Address (16#50000100#);
SYSCFG_COMP_OPAMP_Base : constant System.Address := System'To_Address (16#40010000#);
TIM3_Base : constant System.Address := System'To_Address (16#40000400#);
CAN_Base : constant System.Address := System'To_Address (16#40006400#);
ADC_Common_Base : constant System.Address := System'To_Address (16#50000300#);
HRTIM_Master_Base : constant System.Address := System'To_Address (16#40017400#);
HRTIM_TIMA_Base : constant System.Address := System'To_Address (16#40017480#);
HRTIM_TIMB_Base : constant System.Address := System'To_Address (16#40017500#);
HRTIM_TIMC_Base : constant System.Address := System'To_Address (16#40017580#);
HRTIM_TIMD_Base : constant System.Address := System'To_Address (16#40017600#);
HRTIM_TIME_Base : constant System.Address := System'To_Address (16#40017680#);
HRTIM_Common_Base : constant System.Address := System'To_Address (16#40017780#);
NVIC_Base : constant System.Address := System'To_Address (16#E000E100#);
NVIC_STIR_Base : constant System.Address := System'To_Address (16#E000EF00#);
FPU_Base : constant System.Address := System'To_Address (16#E000EF34#);
MPU_Base : constant System.Address := System'To_Address (16#E000ED90#);
STK_Base : constant System.Address := System'To_Address (16#E000E010#);
SCB_Base : constant System.Address := System'To_Address (16#E000ED00#);
FPU_CPACR_Base : constant System.Address := System'To_Address (16#E000ED88#);
SCB_ACTRL_Base : constant System.Address := System'To_Address (16#E000E008#);
end STM32_SVD;
|
30,445
|
ada
| 4
|
ytomino/gmp-ada
|
source/gmp-z.ads
|
<filename>source/gmp-z.ads<gh_stars>1-10
private with Ada.Finalization;
private with Ada.Streams;
package GMP.Z is
pragma Preelaborate;
type MP_Integer is private;
-- conversions
function To_MP_Integer (X : Long_Long_Integer) return MP_Integer;
-- formatting
function Image (Value : MP_Integer; Base : Number_Base := 10) return String;
function Value (Image : String; Base : Number_Base := 10) return MP_Integer;
-- relational operators
function "=" (Left, Right : MP_Integer) return Boolean;
function "<" (Left, Right : MP_Integer) return Boolean;
function ">" (Left, Right : MP_Integer) return Boolean;
function "<=" (Left, Right : MP_Integer) return Boolean;
function ">=" (Left, Right : MP_Integer) return Boolean;
-- unary adding operators
function "+" (Right : MP_Integer) return MP_Integer;
function "-" (Right : MP_Integer) return MP_Integer;
-- binary adding operators
function "+" (Left, Right : MP_Integer) return MP_Integer;
function "-" (Left, Right : MP_Integer) return MP_Integer;
-- multiplying operators
function "*" (Left, Right : MP_Integer) return MP_Integer;
function "/" (Left, Right : MP_Integer) return MP_Integer;
-- highest precedence operators
function "**" (Left : MP_Integer; Right : Natural) return MP_Integer;
-- subprograms of a scalar type
function Copy_Sign (Value, Sign : MP_Integer) return MP_Integer;
function Copy_Sign (Value : MP_Integer; Sign : Integer) return MP_Integer;
function Copy_Sign (Value : Integer; Sign : MP_Integer) return Integer;
private
package Controlled is
type MP_Integer is private;
function Reference (Item : in out Z.MP_Integer)
return not null access C.gmp.mpz_struct;
function Constant_Reference (Item : Z.MP_Integer)
return not null access constant C.gmp.mpz_struct;
pragma Inline (Reference);
pragma Inline (Constant_Reference);
private
type MP_Integer is new Ada.Finalization.Controlled
with record
Raw : aliased C.gmp.mpz_t := (others => (others => <>));
end record;
overriding procedure Initialize (Object : in out MP_Integer);
overriding procedure Adjust (Object : in out MP_Integer);
overriding procedure Finalize (Object : in out MP_Integer);
end Controlled;
type MP_Integer is new Controlled.MP_Integer;
procedure Read (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : out MP_Integer);
procedure Write (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : in MP_Integer);
for MP_Integer'Read use Read;
for MP_Integer'Write use Write;
procedure Read (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : not null access C.gmp.mpz_struct);
procedure Write (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : not null access constant C.gmp.mpz_struct);
end GMP.Z;
|
30,446
|
ada
| 0
|
Robert-Tice/AdaFractalCPP
|
src/router_cb.adb
|
with Ada.Calendar; use Ada.Calendar;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Unchecked_Conversion;
with AWS.MIME;
with AWS.Messages;
with AWS.Response;
with AWS.Utils; use AWS.Utils;
with Fractal;
with Interfaces.C.Strings; use Interfaces.C.Strings;
with Interfaces.C.Extensions; use Interfaces.C.Extensions;
package body Router_Cb is
procedure Init
is
begin
Float_Julia_Fractal.Init (Viewport => Viewport);
Fixed_Julia_Fractal.Init (Viewport => Viewport);
Class_Uri_Router.Register_Path (This => Route'Access,
Rgx_Str => New_String (Str => "^\/$"),
Cb => Index_Worker'Access);
Class_Uri_Router.Register_Path (This => Route'Access,
Rgx_Str => New_String (Str => "^\/(fixed|float)_fractal$"),
Cb => Fractal_Worker'Access);
Class_Uri_Router.Register_Path (This => Route'Access,
Rgx_Str => New_String (Str => "^\/reset$"),
Cb => Reset_Worker'Access);
Class_Uri_Router.Register_Path (This => Route'Access,
Rgx_Str => New_String (Str => "^\/quit$"),
Cb => Quit_Worker'Access);
Class_Uri_Router.Register_Path (This => Route'Access,
Rgx_Str => New_String (Str => "^\/compute_time$"),
Cb => Compute_Time_Worker'Access);
Class_Uri_Router.Register_Path (This => Route'Access,
Rgx_Str => New_String (Str => "^\/window\|(\d+)\|(\d+)\|(\d+)\|(\d+)\|(\d+)$"),
Cb => Window_Worker'Access);
-- Class_Uri_Router.Register_Default (This => Route'Access,
-- Cb => Default_Worker'Access);
end Init;
procedure Color_Pixel (Z_Escape : Boolean;
Iter_Escape : Natural;
Px : out RGB888_Pixel)
is
Value : constant Integer := 765 * (Iter_Escape - 1) / Max_Iterations;
begin
if Z_Escape then
if Value > 510 then
Px := RGB888_Pixel'(Red => Color'Last - Frame_Counter,
Green => Color'Last,
Blue => Color (Value rem Integer (Color'Last)),
Alpha => Color'Last);
elsif Value > 255 then
Px := RGB888_Pixel'(Red => Color'Last - Frame_Counter,
Green => Color (Value rem Integer (Color'Last)),
Blue => Color'First + Frame_Counter,
Alpha => Color'Last);
else
Px := RGB888_Pixel'(Red => Color (Value rem Integer (Color'Last)),
Green => Color'First + Frame_Counter,
Blue => Color'First,
Alpha => Color'Last);
end if;
else
Px := RGB888_Pixel'(Red => Color'First + Frame_Counter,
Green => Color'First + Frame_Counter,
Blue => Color'First + Frame_Counter,
Alpha => Color'Last);
end if;
end Color_Pixel;
function Router (Request : AWS.Status.Data) return AWS.Response.Data
is
URI : constant String := AWS.Status.URI (Request);
Filename : constant String := "web/" & URI (2 .. URI'Last);
Response : aliased AWS.Response.Data
with Volatile;
begin
if not Class_Uri_Router.Match_Path (This => Route'Access,
Path => New_String (Str => URI),
Response => Response'Address) then
if AWS.Utils.Is_Regular_File (Filename) then
Response := AWS.Response.File
(Content_Type => AWS.MIME.Content_Type (Filename),
Filename => Filename);
-- 404 not found
else
Put_Line ("Could not find file: " & Filename);
Response := AWS.Response.Acknowledge
(AWS.Messages.S404,
"<p>Page '" & URI & "' Not found.");
end if;
end if;
return Response;
end Router;
procedure Default_Worker (arg1 : Interfaces.C.Strings.chars_ptr; arg2 : System.Address)
is
Response : AWS.Response.Data
with Address => Arg2, Import;
URI : String := Value (Item => Arg1);
Filename : constant String := "web/" & URI (2 .. URI'Last);
begin
if AWS.Utils.Is_Regular_File (Filename) then
Response:= AWS.Response.File
(Content_Type => AWS.MIME.Content_Type (Filename),
Filename => Filename);
-- 404 not found
else
Put_Line ("Could not find file: " & Filename);
Response := AWS.Response.Acknowledge
(AWS.Messages.S404,
"<p>Page '" & URI & "' Not found.");
end if;
end Default_Worker;
procedure Index_Worker (arg1 : access Class_Capture_Groups.capture_groups; arg2 : System.Address)
is
Response : aliased AWS.Response.Data
with Address => Arg2, Import;
begin
Response := AWS.Response.File (AWS.MIME.Text_HTML, "web/html/index.html");
end Index_Worker;
procedure Fractal_Worker (arg1 : access Class_Capture_Groups.capture_groups; arg2 : System.Address)
is
Response : AWS.Response.Data
with Address => Arg2, Import;
Fractal_Type : Computation_Enum;
function Buffer_To_Stream is new
Ada.Unchecked_Conversion (Source => Buffer_Access,
Target => Stream_Element_Array_Access);
Data_Stream : constant Stream_Element_Array_Access :=
Buffer_To_Stream (RawData);
Buffer_Size : Stream_Element_Offset;
Fixed_String : constant String := "fixed";
begin
if Value (Item => Class_Capture_Groups.Get_Match (this => Arg1,
Index => 1)) = Fixed_String then
Fractal_Type := Fixed_Type;
else
Fractal_Type := Float_Type;
end if;
Buffer_Size := Stream_Element_Offset (Compute_Image (Comp_Type => Fractal_Type));
Response := AWS.Response.Build
(Content_Type => AWS.MIME.Application_Octet_Stream,
Message_Body => Data_Stream (Data_Stream'First ..
Data_Stream'First + Buffer_Size));
end Fractal_Worker;
procedure Reset_Worker (arg1 : access Class_Capture_Groups.capture_groups; arg2 : System.Address)
is
Response : AWS.Response.Data
with Address => Arg2, Import;
begin
Viewport.Zoom := 10;
Viewport.Center.X := Viewport.Width / 2;
Viewport.Center.Y := Viewport.Height / 2;
Float_Julia_Fractal.Set_Size (Viewport => Viewport);
Fixed_Julia_Fractal.Set_Size (Viewport => Viewport);
Put_Line ("Width:" & Viewport.Width'Img &
" Height:" & Viewport.Height'Img &
" Zoom:" & Viewport.Zoom'Img &
" MouseX:" & Viewport.Center.X'Img &
" MouseY:" & Viewport.Center.Y'Img);
Response := AWS.Response.Build (AWS.MIME.Text_HTML, "reset");
end Reset_Worker;
procedure Quit_Worker (arg1 : access Class_Capture_Groups.capture_groups; arg2 : System.Address)
is
Response : AWS.Response.Data
with Address => Arg2, Import;
begin
Router_Cb.Server_Alive := False;
Put_Line ("quitting...");
Response := AWS.Response.Build (AWS.MIME.Text_HTML, "quitting...");
end Quit_Worker;
procedure Compute_Time_Worker (arg1 : access Class_Capture_Groups.capture_groups; arg2 : System.Address)
is
Response : AWS.Response.Data
with Address => Arg2, Import;
begin
Response := AWS.Response.Build
(AWS.MIME.Text_HTML, Duration'Image (Compute_Time));
end Compute_Time_Worker;
procedure Window_Worker (Arg1 : access Class_Capture_Groups.Capture_Groups; Arg2 : System.Address)
is
Response : AWS.Response.Data
with Address => Arg2, Import;
Width : Natural := Natural'Value (Value (Item => Class_Capture_Groups.Get_Match (This => Arg1,
Index => 1)));
Height : Natural := Natural'Value (Value (Item => Class_Capture_Groups.Get_Match (This => Arg1,
Index => 2)));
Zoom : Natural := Natural'Value (Value (Item => Class_Capture_Groups.Get_Match (This => Arg1,
Index => 3)));
MouseX : Natural := Natural'Value (Value (Item => Class_Capture_Groups.Get_Match (This => Arg1,
Index => 4)));
MouseY : Natural := Natural'Value (Value (Item => Class_Capture_Groups.Get_Match (This => Arg1,
Index => 5)));
begin
if Width >= 0 then
if Width > ImgWidth'Last then
Width := ImgWidth'Last;
end if;
Viewport.Width := Width;
end if;
if Height >= 0 then
if Height > ImgHeight'Last then
Height := ImgHeight'Last;
end if;
Viewport.Height := Height;
end if;
if Zoom /= 0 then
Zoom := Viewport.Zoom + Zoom;
if Zoom > ImgZoom'Last then
Zoom := ImgZoom'Last;
elsif Zoom < ImgZoom'First then
Zoom := ImgZoom'First;
end if;
Viewport.Zoom := Zoom;
end if;
if MouseX >= 0 then
if MouseX > ImgWidth'Last then
MouseX := ImgWidth'Last;
elsif MouseX < ImgWidth'First then
MouseX := ImgWidth'First;
end if;
Viewport.Center.X := MouseX;
end if;
if MouseY >= 0 then
if MouseY > ImgHeight'Last then
MouseY := ImgHeight'Last;
elsif MouseY < ImgHeight'First then
MouseY := ImgHeight'First;
end if;
Viewport.Center.Y := MouseY;
end if;
Put_Line ("Float");
Float_Julia_Fractal.Set_Size (Viewport => Viewport);
Put_Line ("Fixed");
Fixed_Julia_Fractal.Set_Size (Viewport => Viewport);
Put_Line ("Width:" & Viewport.Width'Img &
" Height:" & Viewport.Height'Img &
" Zoom:" & Viewport.Zoom'Img &
" MouseX:" & Viewport.Center.X'Img &
" MouseY:" & Viewport.Center.Y'Img);
Response := AWS.Response.Build (AWS.MIME.Text_HTML, "Success");
end Window_Worker;
procedure Increment_Frame
is
begin
if Cnt_Up then
if Frame_Counter = Color'Last then
Cnt_Up := not Cnt_Up;
return;
else
Frame_Counter := Frame_Counter + 5;
return;
end if;
end if;
if Frame_Counter = Color'First then
Cnt_Up := not Cnt_Up;
return;
end if;
Frame_Counter := Frame_Counter - 5;
end Increment_Frame;
function Compute_Image (Comp_Type : Computation_Enum)
return Buffer_Offset
is
Start_Time : constant Time := Clock;
Ret : Buffer_Offset;
begin
case Comp_Type is
when Fixed_Type =>
Increment_Frame;
Fixed_Julia_Fractal.Calculate_Image
(Buffer => RawData);
Ret := Fixed_Julia_Fractal.Get_Buffer_Size;
when Float_Type =>
Increment_Frame;
Float_Julia_Fractal.Calculate_Image
(Buffer => RawData);
Ret := Float_Julia_Fractal.Get_Buffer_Size;
end case;
Compute_Time := (Clock - Start_Time) * 1000.0;
-- Put_Line ("Time:" & Duration'Image (Compute_Time) & " ms");
return Ret;
end Compute_Image;
end Router_Cb;
|
30,447
|
ada
| 0
|
fintatarta/protypo
|
src/API/protypo-api-engine_values-engine_value_vector_wrappers.adb
|
pragma Ada_2012;
with Ada.Containers;
with Protypo.Api.Engine_Values.Constant_Wrappers;
with Protypo.Api.Engine_Values.Range_Iterators;
with Protypo.Api.Field_Names;
pragma Warnings (Off, "no entities of ""Ada.Text_IO"" are referenced");
with Ada.Text_Io; use Ada.Text_Io;
package body Protypo.Api.Engine_Values.Engine_Value_Vector_Wrappers is
type Field_Name is
(
Field_First,
Field_Last,
Field_Range,
Field_Iterate,
Field_Length
);
package Field_Names_Package is
new Field_Names (Field_Enumerator => Field_Name,
Prefix => "Field_");
function To_Field (X : Id) return Field_Name
is (Field_Names_Package.To_Field (X));
type Array_Iterator is
new Handlers.Iterator_Interface
with
record
Cursor : Engine_Value_Vectors.Cursor;
First : Engine_Value_Vectors.Cursor;
end record;
overriding procedure Reset (Iter : in out Array_Iterator);
overriding procedure Next (Iter : in out Array_Iterator);
overriding function End_Of_Iteration (Iter : Array_Iterator) return Boolean;
overriding function Element (Iter : Array_Iterator) return Handler_Value;
-- function Force_Handler (Item : Engine_Value) return Handler_Value
-- is (case Item.Class is
-- when Handler_Classes =>
-- Item,
--
-- when Int =>
-- Constant_Wrappers.To_Handler_Value (Get_Integer (Item)),
--
-- when Real =>
-- Constant_Wrappers.To_Handler_Value (Get_Float (Item)),
--
-- when Text =>
-- Constant_Wrappers.To_Handler_Value (Get_String (Item)),
--
-- when logical =>
-- Constant_Wrappers.To_Handler_Value (Get_Logical (Item)),
--
-- when Void | Iterator =>
-- raise Constraint_Error);
overriding procedure Reset (Iter : in out Array_Iterator)
is
begin
Iter.Cursor := Iter.First;
end Reset;
overriding procedure Next (Iter : in out Array_Iterator)
is
begin
Engine_Value_Vectors.Next (Iter.Cursor);
end Next;
overriding function End_Of_Iteration (Iter : Array_Iterator) return Boolean
is (not Engine_Value_Vectors.Has_Element (Iter.Cursor));
overriding function Element (Iter : Array_Iterator) return Handler_Value
is (Handlers.Force_Handler (Engine_Value_Vectors.Element (Iter.Cursor)));
---------
-- Get --
---------
function Get
(X : Vector_Handler; Index : Engine_Value_Vectors.Vector) return Handler_Value
is
use type Ada.Containers.Count_Type;
begin
if Index.Length /= 1 then
raise Handlers.Out_Of_Range with "Array access with /= 1 index";
end if;
if Index.First_Element.Class /= Int then
raise Handlers.Out_Of_Range with "Array access with non-integer index";
end if;
declare
Idx : constant Positive := Get_Integer (Index.First_Element);
begin
if Idx < X.Vect.First_Index or Idx > X.Vect.Last_Index then
raise Handlers.Out_Of_Range with "Out of bounds index";
end if;
return Constant_Wrappers.To_Handler_Value (X.Vect.all (Idx));
end;
end Get;
---------
-- Get --
---------
function Get (X : Vector_Handler; Field : Id) return Handler_Value is
use Constant_Wrappers;
begin
case To_Field (Field) is
when Field_First =>
return To_Handler_Value (Integer (X.Vect.First_Index));
when Field_Last =>
return To_Handler_Value (Integer (X.Vect.Last_Index));
when Field_Length =>
return To_Handler_Value (Integer (X.Vect.Length));
when Field_Iterate =>
return To_Handler_Value
(Handlers.Create
(Handlers.Iterator_Interface_Access'
(new Array_Iterator'(Cursor => X.Vect.First,
First => X.Vect.First))));
when Field_Range =>
return To_Handler_Value
(Handlers.Create
(Range_Iterators.Create (Start => Integer (X.Vect.First_Index),
Stop => Integer (X.Vect.Last_Index))));
end case;
end Get;
--------------
-- Is_Field --
--------------
function Is_Field (X : Vector_Handler; Field : Id) return Boolean
is (Field_Names_Package.Is_Field (Field));
----------------
-- Initialize --
----------------
overriding procedure Initialize (Object : in out Vector_Handler)
is
begin
Object.Vect := new Engine_Value_Vectors.Vector'(Engine_Value_Vectors.Empty_Vector);
end Initialize;
end Protypo.Api.Engine_Values.Engine_Value_Vector_Wrappers;
|
30,448
|
ada
| 20
|
charlie5/lace
|
3-mid/impact/source/3d/collision/shapes/impact-d3-shape-compound.ads
|
<gh_stars>10-100
with impact.d3.Shape;
-- btBvt,
with impact.d3.collision.bounding_volume_Tree;
with ada.Containers.Vectors;
with impact.d3.collision.Proxy;
-- #include "impact.d3.Shape.h"
--
-- #include "LinearMath/impact.d3.Vector.h"
-- #include "LinearMath/impact.d3.Transform.h"
-- #include "LinearMath/impact.d3.Matrix.h"
-- #include "impact.d3.collision.Margin.h"
-- #include "LinearMath/btAlignedObjectArray.h"
-- //class impact.d3.collision.quantized_Bvh.optimized;
-- struct impact.d3.collision.bounding_volume_Tree;
package impact.d3.Shape.compound
--
-- The impact.d3.Shape.compound allows to store multiple other impact.d3.Shapes
-- This allows for moving concave collision objects. This is more general then the static concave impact.d3.Shape.concave.triangle_mesh.bvh.
-- It has an (optional) dynamic aabb tree to accelerate early rejection tests.
-- @todo: This aabb tree can also be use to speed up ray tests on impact.d3.Shape.compound, see http://code.google.com/p/bullet/issues/detail?id=25
-- Currently, removal of child shapes is only supported when disabling the aabb tree (pass 'false' in the constructor of impact.d3.Shape.compound)
--
is
type Item is new impact.d3.Shape.item with private;
type View is access all Item'Class;
--- Forge
--
function to_compound_Shape (enableDynamicAabbTree : in Boolean := True) return Item;
overriding procedure destruct (Self : in out Item);
--- impact.d3.Shape.compoundChild
--
type Child is
record
m_transform : access Transform_3d := new Transform_3d;
m_childShape : access impact.d3.Shape.Item'Class;
m_childShapeType : impact.d3.collision.Proxy.BroadphaseNativeTypes;
m_childMargin : math.Real;
m_node : access impact.d3.collision.bounding_volume_Tree.Node'Class;
end record;
overriding function "=" (L, R : in impact.d3.Shape.compound.Child) return Boolean;
package Child_Vectors is new ada.Containers.Vectors (Positive, impact.d3.Shape.compound.Child);
subtype Child_Vector is impact.d3.Shape.compound.Child_Vectors.Vector;
--- Attributes
--
overriding
procedure getAabb (Self : in Item; t : in Transform_3d;
aabbMin, aabbMax : out math.Vector_3);
--
-- getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version
overriding procedure setLocalScaling (Self : in out Item; scaling : in math.Vector_3) ;
overriding function getLocalScaling (Self : in Item) return math.Vector_3 ;
overriding procedure calculateLocalInertia (Self : in Item; mass : in math.Real;
inertia : out math.Vector_3);
overriding function getName (Self : in Item) return String;
overriding procedure setMargin (Self : in out Item; margin : in math.Real);
overriding function getMargin (Self : in Item) return math.Real;
function getChildShape (Self : in Item; index : in Integer) return access impact.d3.Shape.Item'Class;
function getChildTransform (Self : in Item; index : in Integer) return access Transform_3d;
function getDynamicAabbTree (Self : in Item) return access impact.d3.collision.bounding_volume_Tree.Item'Class;
function getNumChildShapes (Self : in Item) return Natural;
procedure addChildShape (Self : in out Item; localTransform : in Transform_3d;
shape : access impact.d3.Shape.Item'Class);
procedure removeChildShape (Self : in out Item; shape : access impact.d3.Shape.Item'Class);
--
-- Remove all children shapes that contain the specified shape.
procedure removeChildShapeByIndex (Self : in out Item; childShapeindex : in Integer);
procedure updateChildTransform (Self : in out Item; childIndex : in Integer;
newChildTransform : in Transform_3d;
shouldRecalculateLocalAabb : in Boolean := True);
--
-- Set a new transform for a child, and update internal data structures (local aabb and dynamic tree).
function getChildList (Self : access Item) return access impact.d3.Shape.compound.Child_Vector;
procedure recalculateLocalAabb (Self : in out Item);
--
-- Re-calculate the local Aabb. Is called at the end of removeChildShapes.
-- Use this yourself if you modify the children or their transforms.
procedure createAabbTreeFromChildren (Self : in out Item);
procedure calculatePrincipalAxisTransform (Self : in Item; masses : in math.Vector; -- impact.d3.Scalar* masses
principal : access Transform_3d;
inertia : in out math.Vector_3);
--
-- Computes the exact moment of inertia and the transform from the coordinate system defined by the principal axes of the moment of inertia
-- and the center of mass to the current coordinate system. "masses" points to an array of masses of the children. The resulting transform
-- "principal" has to be applied inversely to all children transforms in order for the local coordinate system of the compound
-- shape to be centered at the center of mass and to coincide with the principal axes. This also necessitates a correction of the world transform
-- of the collision object by the principal transform.
function getUpdateRevision (Self : in Item) return Integer;
private
type Item is new impact.d3.Shape.item with
record
m_children : aliased impact.d3.Shape.compound.Child_Vector; -- btAlignedObjectArray<impact.d3.Shape.compoundChild> ;
m_localAabbMin,
m_localAabbMax : math.Vector_3;
m_dynamicAabbTree : impact.d3.collision.bounding_volume_Tree.view;
m_updateRevision : Integer; -- increment m_updateRevision when adding/removing/replacing child shapes, so that some caches can be updated
m_collisionMargin : math.Real;
m_localScaling : math.Vector_3;
end record;
end impact.d3.Shape.compound;
|
30,449
|
ada
| 0
|
sourceryinstitute/rose-sourcery-institute
|
src/frontend/Experimental_Ada_ROSE_Connection/dot_asis/dot_asis_library/source/asis_tool_2-element.ads
|
<gh_stars>0
with Asis;
-- GNAT-specific:
with A4G.Int_Knds;
with Types;
with a_nodes_h;
with Dot;
private with Ada.Containers.Doubly_Linked_Lists;
package Asis_Tool_2.Element is
type Class is tagged private; -- Initialized
-- Process an element and all of its components:
procedure Process_Element_Tree
(This : in out Class;
Element : in Asis.Element;
Outputs : in Outputs_Record);
-----------------------------------------------------------------------------
-- This encapsulates the identity of an Element, since sometimes a
-- Node_ID gets reused!
--
type Element_ID is record
Node_ID : Types.Node_ID := Types.Error;
Kind : A4G.Int_Knds.Internal_Element_Kinds :=
A4G.Int_Knds.Not_An_Element;
end record;
-- To get an a_nodes_h.Element_ID:
-- Asis.Element -> Get_Element_ID -> To_Element_ID -> a_nodes_h.Element_ID
-- or
-- Asis.Element -> Get_Element_ID -> a_nodes_h.Element_ID
--
-- To get a string for DOT or text output:
-- a_nodes_h.Element_ID -> To_String -> String (e.g. Element_12001)
--
function Get_Element_ID
(Element : in Asis.Element)
return Element_ID;
-- Turns Node_ID and Kind into one number. Currently (GNAT GPL 2017 ASIS)
-- there are about 800 values in A4G.Int_Knds.Internal_Element_Kinds, so
-- we multiply Node_ID by 1000 and add Kind. Assuming a 32-bit int for
-- a_nodes_h.Element_ID, this means we cannot process Elements with a Node_ID
-- over 1,000,000.
--
-- TODO: Move to anhS
function To_Element_ID
(This : in Element_ID)
return a_nodes_h.Element_ID;
function Get_Element_ID
(Element : in Asis.Element)
return a_nodes_h.Element_ID;
function To_String
(This : in a_nodes_h.Element_ID)
return String;
-- END Element_ID support
-----------------------------------------------------------------------------
-- Add an array of Element IDs to Dot_Label and maybe Dot_Edge, and return
-- an Element_ID_List:
-- LEAKS:
function To_Element_ID_List
(Dot_Label : in out Dot.HTML_Like_Labels.Class;
Outputs : in out Outputs_Record;
This_Element_ID : in a_nodes_h.Element_ID;
Elements_In : in Asis.Element_List;
Dot_Label_Name : in String;
Add_Edges : in Boolean := False;
This_Is_Unit : in Boolean := False)
return a_nodes_h.Element_ID_List;
private
package Element_ID_Lists is new
Ada.Containers.Doubly_Linked_Lists
(Element_Type => a_nodes_h.Element_ID,
"=" => IC."=");
-- Make type and operations directly visible:
type Element_ID_List is new Element_ID_Lists.List with null record;
-- Can't be limited because generic Asis.Iterator.Traverse_Element doesn't
-- want limited state information:
type Class is tagged -- Initialized
record
-- Current, in-progress intermediate output products. These need to be
-- turned into stacks if they are ever used in Post_Operation. Now
-- their usage ends at the end of Pre_Operation:
Dot_Node : Dot.Node_Stmt.Class; -- Initialized
Dot_Label : Dot.HTML_Like_Labels.Class; -- Initialized
A_Element : a_nodes_h.Element_Struct := anhS.Default_Element_Struct;
-- Used when making dot edges to child nodes. Treated s a stack:
Element_IDs : Element_ID_List;
-- Element_ID : a_nodes_h.Element_ID := anhS.Invalid_Element_ID;
-- I would like to just pass Outputs through and not store it in the
-- object, since it is all pointers and we doesn't need to store their
-- values between calls to Process_Element_Tree. Outputs has to go into
-- State_Information in the Traverse_Element instatiation, though, so
-- we'll put it in the object and pass that:
Outputs : Outputs_Record; -- Initialized
end record;
end Asis_Tool_2.Element;
|
30,450
|
ada
| 0
|
fintatarta/eugen
|
src/Line_Array/src/line_arrays-regexp_classifiers.adb
|
<filename>src/Line_Array/src/line_arrays-regexp_classifiers.adb
pragma Ada_2012;
package body Line_Arrays.Regexp_Classifiers is
---------
-- Add --
---------
procedure Add (To : in out Classifier_Type;
Regexp : String;
Callback : Callback_Type)
is
Matcher : constant Gnat.Regpat.Pattern_Matcher := Gnat.Regpat.Compile (Regexp);
begin
To.Exprs.Append (New_Item => Regexp_Descriptor'(Size => Matcher.Size,
Matcher => Matcher,
Callback => Callback));
end Add;
-----------------
-- Add_Default --
-----------------
procedure Add_Default
(To : in out Classifier_Type; Callback : Callback_Type)
is
begin
if To.Default /= null then
raise Double_Default;
end if;
To.Default := Callback;
end Add_Default;
------------
-- Create --
------------
function Create (Regexps : Regexp_Array) return Classifier_Type
is
Result : Classifier_Type;
begin
for R of Regexps loop
if Is_Default (R) then
Result.Add_Default (R.Callback);
else
Result.Add (Regexp => To_String (R.Regexp),
Callback => R.Callback);
end if;
end loop;
return Result;
end Create;
--------------
-- Classify --
--------------
function Classify
(Classifier : Classifier_Type; Line : String) return Classified_Line
is
use Gnat.Regpat;
begin
for Regexp of Classifier.Exprs loop
declare
Matched : Match_Array (0 .. Paren_Count (Regexp.Matcher));
begin
Gnat.Regpat.Match (Self => Regexp.Matcher,
Data => Line,
Matches => Matched);
if Matched (0) /= No_Match then
return Regexp.Callback (Line, Matched);
end if;
end;
end loop;
if Classifier.Default = null then
raise Constraint_Error;
else
declare
Matched : constant Match_Array (0 .. 0) :=
(0 => Match_Location'(First => Line'First,
Last => Line'Last));
begin
return Classifier.Default (Line, Matched);
end;
end if;
end Classify;
end Line_Arrays.Regexp_Classifiers;
|
30,451
|
ada
| 26
|
damaki/libkeccak
|
src/common/keccak-generic_parallel_hash.ads
|
-------------------------------------------------------------------------------
-- Copyright (c) 2019, <NAME>
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
-- * Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * The name of the copyright holder may not be used to endorse or promote
-- Products derived from this software without specific prior written
-- permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
with Keccak.Generic_CSHAKE;
with Keccak.Generic_XOF;
with Keccak.Generic_Parallel_XOF;
with Keccak.Types;
-- @summary
-- Generic implementation of the ParallelHash algorithm as defined in NIST SP 800-185.
--
-- @description
-- The purpose of ParallelHash10 is to support the efficient hashing of very long
-- strings, by taking advantage of the parallelism available in modern processors.
-- ParallelHash provides variable-length output. Changing any input parameter to
-- ParallelHash, even the requested output length, will result in unrelated output.
-- Like the other functions defined in this document, ParallelHash also supports
-- user-selected customization strings.
--
-- The block size defines the size of each input block that is processed in parallel.
-- It can be any positive value up to Block_Size_Number'Last / 8. Since Block_Size_Number
-- is defined as a subtype of Positive, this guaranteeds the maximum block size to
-- be at least 4095 bytes when Integer is at least a 16-bit signed type. On most systems
-- is likely to be at least 268_435_455 bytes (256 MiB - 1 B) when Integer is a
-- 32-bit signed type.
--
-- This API is used as follows:
--
-- 1 Call Init to initialise a new context. The block size and an optional
-- customisation string (for domain separation) are provided here.
--
-- 2 Call Update one or more times to input an arbitrary amount of data into
-- the ParallelHash context.
--
-- 3 Call either Finish or Extract to produce the desired type of output
-- (ParallelHash or ParallelHashXOF):
--
-- * Finish is used to produce a single output of arbitrary length (ParallelHash).
-- The requested output length affects the output. For example, requesting
-- a 10-byte output will produce an unrelated hash to requesting a 20-byte
-- output.
--
-- * Extract can be called one or more times to produce an arbitrary number
-- of output bytes (ParallelHashXOF). In this case, the total output length is
-- unknown in advance so the output does not change based on the overall length.
-- For example, a 10-byte output is the truncated version of a 20-byte output.
--
-- @group ParallelHash
generic
CV_Size_Bytes : Positive;
-- Length of the Chaining Values, in bytes.
with package CSHAKE_Serial is new Keccak.Generic_CSHAKE (<>);
-- This CSHAKE must be configured with NO SUFFIX BITS.
-- The Generic_KangarooTwelve implementation takes care of the appropriate
-- suffix bits when using this CSHAKE_Serial.
with package SHAKE_Serial is new Keccak.Generic_XOF (<>);
with package SHAKE_Parallel_2 is new Keccak.Generic_Parallel_XOF (<>);
-- This CSHAKE must be configured to add the 3 suffix bits 2#011#.
with package SHAKE_Parallel_4 is new Keccak.Generic_Parallel_XOF (<>);
-- This CSHAKE must be configured to add the 3 suffix bits 2#011#.
with package SHAKE_Parallel_8 is new Keccak.Generic_Parallel_XOF (<>);
-- This CSHAKE must be configured to add the 3 suffix bits 2#011#.
package Keccak.Generic_Parallel_Hash
is
-- Assertions to check that the correct parallel instances have
-- been provided.
pragma Assert (SHAKE_Parallel_2.Num_Parallel_Instances = 2);
pragma Assert (SHAKE_Parallel_4.Num_Parallel_Instances = 4);
pragma Assert (SHAKE_Parallel_8.Num_Parallel_Instances = 8);
type Context is private;
type States is (Updating, Extracting, Finished);
-- @value Updating When in this state additional data can be input into the
-- ParallelHash context.
--
-- @value Extracting When in this state, the ParallelHash context can generate
-- output bytes by calling the Extract procedure.
--
-- @value Finished When in this state the context is finished and no more data
-- can be input or output.
type Byte_Count is new Long_Long_Integer
range 0 .. Long_Long_Integer'Last;
subtype Block_Size_Number is Positive range 1 .. Positive'Last / 8;
procedure Init (Ctx : out Context;
Block_Size : in Block_Size_Number;
Customization : in String)
with Global => null,
Post => State_Of (Ctx) = Updating;
-- Initialise the ParallelHash instance.
--
-- @param Ctx The context to initialise.
--
-- @param Block_Size The block size in bytes for parallel hashing.
procedure Update (Ctx : in out Context;
Data : in Types.Byte_Array)
with Global => null,
Pre => (State_Of (Ctx) = Updating
and Byte_Count (Data'Length) <= Max_Input_Length (Ctx)),
Post => (State_Of (Ctx) = Updating
and Num_Bytes_Processed (Ctx) =
Num_Bytes_Processed (Ctx'Old) + Byte_Count (Data'Length));
-- Process input bytes with ParallelHash.
--
-- This procedure is most efficient when the input Data buffer is
-- at least 8 times larger than the ParallelHash block size.
--
-- This may be called multiple times to process a large amount of data.
--
-- Note that there is an overall limit to the maximum amount of data that
-- can be processed with ParallelHash. The maximum input size is returned
-- by calling the Max_Input_Length function.
--
-- @param Ctx The context to update with new input data.
--
-- @param Data The data to process with ParallelHash.
procedure Finish (Ctx : in out Context;
Data : out Types.Byte_Array)
with Global => null,
Pre => State_Of (Ctx) = Updating,
Post => State_Of (Ctx) = Finished;
-- Extract a fixed number of output bytes.
--
-- This procedure finalizes the ParallelHash and outputs a fixed number
-- of output bytes. The ParallelHash parameter L is the requested output
-- length, and is determined by the length of the @Data@ array.
-- I.e. Data'Length is used as the ParallelHash parameter L.
--
-- After calling this procedure the ParallelHash instance cannot be used
-- further.
procedure Extract (Ctx : in out Context;
Data : out Types.Byte_Array)
with Global => null,
Pre => State_Of (Ctx) in Updating | Extracting,
Post => State_Of (Ctx) = Extracting;
-- Extract an arbitrary number of output bytes.
--
-- This procedure finalizes the ParallelHash and puts it into XOF mode
-- where an arbitary number of bytes can be output. When this parameter
-- is called for the first time after inputting data, the value 0 is used
-- as the ParallelHash parameter L.
--
-- This procedure can be called multiple times to produce any output length.
function State_Of (Ctx : in Context) return States
with Global => null;
function Num_Bytes_Processed (Ctx : in Context) return Byte_Count
with Global => null;
-- Get the total number of bytes that have been input to the ParllelHash
-- instance so far.
--
-- This restricts the maximum permitted input length to a maximum of
-- Byte_Count'Last bytes.
function Max_Input_Length (Ctx : in Context) return Byte_Count
with Global => null;
-- Gets the maximum number of bytes that may be input into the ParallelHash context.
--
-- This value decreases as the context is updated with additional input data.
function Block_Size_Of (Ctx : in Context) return Block_Size_Number
with Global => null;
-- Get the configured block size parameter of the ParallelHash instance.
private
use type CSHAKE_Serial.States;
use type SHAKE_Serial.States;
type Context is record
Outer_CSHAKE : CSHAKE_Serial.Context;
Partial_Block_CSHAKE : SHAKE_Serial.Context;
Input_Len : Byte_Count;
Block_Size : Block_Size_Number;
Partial_Block_Length : Natural;
Finished : Boolean;
end record
with Predicate => Context.Partial_Block_Length < Context.Block_Size;
function State_Of (Ctx : in Context) return States
is (if (Ctx.Finished
or SHAKE_Serial.State_Of (Ctx.Partial_Block_CSHAKE) /= SHAKE_Serial.Updating
or CSHAKE_Serial.State_Of (Ctx.Outer_CSHAKE) = CSHAKE_Serial.Ready_To_Extract)
then Finished
elsif CSHAKE_Serial.State_Of (Ctx.Outer_CSHAKE) = CSHAKE_Serial.Updating
then Updating
else Extracting);
function Num_Bytes_Processed (Ctx : in Context) return Byte_Count
is (Ctx.Input_Len);
function Max_Input_Length (Ctx : in Context) return Byte_Count
is (Byte_Count'Last - Num_Bytes_Processed (Ctx));
function Block_Size_Of (Ctx : in Context) return Block_Size_Number
is (Ctx.Block_Size);
end Keccak.Generic_Parallel_Hash;
|
30,452
|
ada
| 0
|
JeremyGrosser/arm_cmsis_dsp
|
src/complex_math_functions_h.ads
|
<reponame>JeremyGrosser/arm_cmsis_dsp
pragma Ada_2012;
pragma Style_Checks (Off);
pragma Warnings ("U");
with Interfaces.C; use Interfaces.C;
with arm_math_types_h;
with sys_ustdint_h;
package complex_math_functions_h is
procedure arm_cmplx_conj_f32
(pSrc : access arm_math_types_h.float32_t;
pDst : access arm_math_types_h.float32_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:58
with Import => True,
Convention => C,
External_Name => "arm_cmplx_conj_f32";
procedure arm_cmplx_conj_q31
(pSrc : access arm_math_types_h.q31_t;
pDst : access arm_math_types_h.q31_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:69
with Import => True,
Convention => C,
External_Name => "arm_cmplx_conj_q31";
procedure arm_cmplx_conj_q15
(pSrc : access arm_math_types_h.q15_t;
pDst : access arm_math_types_h.q15_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:81
with Import => True,
Convention => C,
External_Name => "arm_cmplx_conj_q15";
procedure arm_cmplx_mag_squared_f32
(pSrc : access arm_math_types_h.float32_t;
pDst : access arm_math_types_h.float32_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:93
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mag_squared_f32";
procedure arm_cmplx_mag_squared_f64
(pSrc : access arm_math_types_h.float64_t;
pDst : access arm_math_types_h.float64_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:105
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mag_squared_f64";
procedure arm_cmplx_mag_squared_q31
(pSrc : access arm_math_types_h.q31_t;
pDst : access arm_math_types_h.q31_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:117
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mag_squared_q31";
procedure arm_cmplx_mag_squared_q15
(pSrc : access arm_math_types_h.q15_t;
pDst : access arm_math_types_h.q15_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:129
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mag_squared_q15";
procedure arm_cmplx_mag_f32
(pSrc : access arm_math_types_h.float32_t;
pDst : access arm_math_types_h.float32_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:141
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mag_f32";
procedure arm_cmplx_mag_f64
(pSrc : access arm_math_types_h.float64_t;
pDst : access arm_math_types_h.float64_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:153
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mag_f64";
procedure arm_cmplx_mag_q31
(pSrc : access arm_math_types_h.q31_t;
pDst : access arm_math_types_h.q31_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:165
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mag_q31";
procedure arm_cmplx_mag_q15
(pSrc : access arm_math_types_h.q15_t;
pDst : access arm_math_types_h.q15_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:177
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mag_q15";
procedure arm_cmplx_mag_fast_q15
(pSrc : access arm_math_types_h.q15_t;
pDst : access arm_math_types_h.q15_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:188
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mag_fast_q15";
procedure arm_cmplx_dot_prod_q15
(pSrcA : access arm_math_types_h.q15_t;
pSrcB : access arm_math_types_h.q15_t;
numSamples : sys_ustdint_h.uint32_t;
realResult : access arm_math_types_h.q31_t;
imagResult : access arm_math_types_h.q31_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:202
with Import => True,
Convention => C,
External_Name => "arm_cmplx_dot_prod_q15";
procedure arm_cmplx_dot_prod_q31
(pSrcA : access arm_math_types_h.q31_t;
pSrcB : access arm_math_types_h.q31_t;
numSamples : sys_ustdint_h.uint32_t;
realResult : access arm_math_types_h.q63_t;
imagResult : access arm_math_types_h.q63_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:218
with Import => True,
Convention => C,
External_Name => "arm_cmplx_dot_prod_q31";
procedure arm_cmplx_dot_prod_f32
(pSrcA : access arm_math_types_h.float32_t;
pSrcB : access arm_math_types_h.float32_t;
numSamples : sys_ustdint_h.uint32_t;
realResult : access arm_math_types_h.float32_t;
imagResult : access arm_math_types_h.float32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:234
with Import => True,
Convention => C,
External_Name => "arm_cmplx_dot_prod_f32";
procedure arm_cmplx_mult_real_q15
(pSrcCmplx : access arm_math_types_h.q15_t;
pSrcReal : access arm_math_types_h.q15_t;
pCmplxDst : access arm_math_types_h.q15_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:249
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mult_real_q15";
procedure arm_cmplx_mult_real_q31
(pSrcCmplx : access arm_math_types_h.q31_t;
pSrcReal : access arm_math_types_h.q31_t;
pCmplxDst : access arm_math_types_h.q31_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:263
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mult_real_q31";
procedure arm_cmplx_mult_real_f32
(pSrcCmplx : access arm_math_types_h.float32_t;
pSrcReal : access arm_math_types_h.float32_t;
pCmplxDst : access arm_math_types_h.float32_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:277
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mult_real_f32";
procedure arm_cmplx_mult_cmplx_q15
(pSrcA : access arm_math_types_h.q15_t;
pSrcB : access arm_math_types_h.q15_t;
pDst : access arm_math_types_h.q15_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:290
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mult_cmplx_q15";
procedure arm_cmplx_mult_cmplx_q31
(pSrcA : access arm_math_types_h.q31_t;
pSrcB : access arm_math_types_h.q31_t;
pDst : access arm_math_types_h.q31_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:304
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mult_cmplx_q31";
procedure arm_cmplx_mult_cmplx_f32
(pSrcA : access arm_math_types_h.float32_t;
pSrcB : access arm_math_types_h.float32_t;
pDst : access arm_math_types_h.float32_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:318
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mult_cmplx_f32";
procedure arm_cmplx_mult_cmplx_f64
(pSrcA : access arm_math_types_h.float64_t;
pSrcB : access arm_math_types_h.float64_t;
pDst : access arm_math_types_h.float64_t;
numSamples : sys_ustdint_h.uint32_t) -- ../CMSIS_5/CMSIS/DSP/Include/dsp/complex_math_functions.h:333
with Import => True,
Convention => C,
External_Name => "arm_cmplx_mult_cmplx_f64";
end complex_math_functions_h;
|
30,453
|
ada
| 3
|
daveshields/AdaEd
|
demos/spath.ada
|
<reponame>daveshields/AdaEd
-- A parallel single-source, all-destinations shortest-path finder.
-- Each task is assigned a node, and tries to extend the path by
-- cloning new tasks that explore all successors of that node.
-- The graph is represented by adjacency lists. This representation
-- is fixed, and global to all tasks.
-- The minimum distances at each step of the computation are kept in
-- arrays RESULT and COMING_FROM. These objects are monitored by an
-- array of tasks, one for each node, to yield greater concurrency.
with TEXT_IO; use TEXT_IO;
procedure shortest_path is
package i_io is new integer_io(integer);
use i_io;
n: integer := 4; -- cardinality of graph
subtype graph_size is integer range 1..n;
subtype graph_node is graph_size ;
inf: integer := 9999; -- Infinite distance
type config is array(graph_size) of integer;
adjacency: array(graph_size) of config; -- To describe the graph
result: config := (graph_size => inf); -- Shortest distances
coming_from: config; -- To reconstruct paths
begin
declare
task type monitor_node is
entry init(node: graph_node) ;
entry go_on(pred: graph_node;
pathlength: integer;
shorter: out boolean);
end monitor_node;
monitor: array(graph_size) of monitor_node ;
task type path is
entry init(node, pred: graph_node;
pathlength, size: integer);
end path;
type path_name is access path;
start: path_name;
subtype s_path is path;
task body monitor_node is
here: graph_node ; -- node monitored by this task
begin
accept init(node: graph_node) do
here := node ;
end init ;
loop select
accept go_on(pred: graph_node;
pathlength: integer;
shorter: out boolean)
do
if pathlength < result(here) then
-- new path is shorter than previous attempts.
result(here) := pathlength;
coming_from(here) := pred;
shorter := true;
else
shorter := false;
end if;
end go_on;
or
terminate;
end select;
end loop;
end monitor_node;
task body path is
source, from: graph_node;
cost,edge: integer;
options: config;
x: path_name;
response: boolean;
begin
accept init(node, pred: graph_node;
pathlength,size: integer)
do
source := node;
from := pred;
cost := pathlength;
edge := size;
end init;
cost:=cost+edge;
monitor(source).go_on(from, cost, response);
if response then
-- found shorter path than previous attempts.
-- Clone successors to explore edges out of this node.
options := adjacency(source) ;
for j in graph_size loop
if options(j) /= inf then -- edge exists;
x := new s_path ; -- new task for it
x.init(j, source, cost, options(j));
end if;
end loop;
end if;
end path;
begin
adjacency :=((inf, 9, 2, inf), (inf, 1, 1, 2),
(inf, 2, inf, 5), (inf, 1, inf, 2) );
for j in graph_size loop
-- Attach a monitor_node to each graph node.
monitor(j).init(j) ;
end loop ;
start := new path;
start.init(1, 1, 0, 0); -- start from node 1, distance 0.
end; -- and wait for tasks to terminate.
put_line("Final distances from source") ;
new_line;
for j in graph_size'succ(graph_size'first).. graph_size'last
loop
put(result(j));
put(" to ") ; put(j) ;
put(" reached via ") ; put(coming_from(j)) ;
new_line;
end loop;
end shortest_path;
|
30,454
|
ada
| 4
|
faelys/gela-asis
|
source/asis/asis-gela-visibility.ads
|
<filename>source/asis/asis-gela-visibility.ads
------------------------------------------------------------------------------
-- G E L A A S I S --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of this file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $
-- Purpose:
-- Resolve names and fill Corresponding_Defining_Name_List with
-- possible defining names
-- This package stores symbol table as hierarchy of declarative regions
-- starting from parent of Standard and includes regions of all unit
-- of context.
with Asis;
with Asis.Gela.Classes;
package Asis.Gela.Visibility is
type Point is private;
-- Represent point in source. Used to lookup names and to point to
-- place in declarative region.
Null_Point : constant Point;
function Enter_Unit (Unit : Asis.Compilation_Unit) return Point;
-- For given unit find corresponding declarative region.
-- Result used as initial value to traverse AST and construct
-- nested regions.
procedure Enter_Construction
(Element : in Asis.Element;
Point : in out Visibility.Point);
-- Create declarative region for given construct if it need it.
-- Jump to correspondong region if Element is completion.
procedure Leave_Construction
(Element : in Asis.Element;
Point : in out Visibility.Point);
-- Leave declarative region if construction has it.
function Lookup
(Item : Asis.Element;
Point : Visibility.Point) return Asis.Defining_Name_List;
-- Return defining names for given name or operator symbol.
-- Search starts from given point.
function Lookup_Direct
(Item : Asis.Element;
Point : Visibility.Point) return Asis.Defining_Name_List;
-- Return direct names for given name or operator symbol.
function Lookup_In_Region
(Item : Asis.Element;
Reg : Visibility.Point;
Point : Visibility.Point) return Asis.Defining_Name_List;
-- Return names from given region only.
function Lookup_In_Region
(Item : Asis.Element;
Element : Asis.Element;
Point : Visibility.Point)
return Asis.Defining_Name_List;
function Lookup_In_Parent_Region
(Item : Asis.Element;
Element : Asis.Element) return Asis.Defining_Name_List;
function Lookup_Use
(Item : Asis.Element;
Direct : Asis.Defining_Name_List;
Point : Visibility.Point) return Asis.Defining_Name_List;
-- Return names visible through use clauses.
procedure Print_Region
(Point : Visibility.Point;
Prefix : Wide_String := "");
-- Dump given region to stdout
procedure Print_Standard_Region;
procedure Try_To_Resolve
(Element : Asis.Expression;
Point : Visibility.Point);
-- Resolve name and collect in corresponfing_defining_name_list
procedure Try_To_Resolve_Goto
(Element : Asis.Expression;
Stmt : Asis.Statement);
procedure New_Implicit_Declaration
(Element : in Asis.Declaration;
Point : in out Visibility.Point;
Tipe : in Asis.Declaration;
Overridden : out Boolean);
-- Declare implicit declaration to given declarative region.
function Visible_From
(Name : in Asis.Defining_Name;
Point : in Asis.Element) return Boolean;
-- Check if name is visible from given point
function End_Of_Package
(The_Package : Asis.Declaration)
return Asis.Element;
-- Return special element used to mark end of package declaration
-- view point in call to Visible_From function.
-- For now defining_name of the package is chosen as such element.
function Is_Declared (Name : in Asis.Defining_Name) return Boolean;
-- Check if name was declared
procedure Set_Not_Declared (Name : in Asis.Defining_Name);
-- Mark name as not declared
type Region_Item_Access is private;
function Unique_Name (Name : in Asis.Defining_Name) return Wide_String;
-- Return unique name of region where Name declared and unique name of
-- defining name in this region
private
type Region_Node;
type Part_Node;
type Region_Item;
type Region_Access is access all Region_Node;
type Part_Access is access all Part_Node;
type Region_Item_Access is access all Region_Item;
type Item_Kinds is
(Definition,
Char, Wide_Char, Wide_Wide_Char,
Use_Package, Use_Type, Dummy);
type Region_Item (Kind : Item_Kinds := Definition) is record
Part : Part_Access;
Next : Region_Item_Access;
case Kind is
when Definition | Char | Wide_Char | Wide_Wide_Char =>
Defining_Name : Asis.Defining_Name;
-- List of equal names in the same region:
Prev : Region_Item_Access;
-- List of equal names in the upper regions:
Up : Region_Item_Access;
-- Count of equal names in this and upper regions (plus one):
Count : Asis.ASIS_Natural;
case Kind is
when Definition =>
Still_Hidden : Boolean;
Library_Unit : Boolean;
when others =>
null;
end case;
when Use_Package =>
Declaration : Asis.Declaration;
when Use_Type =>
Tipe : Asis.Gela.Classes.Type_Info;
when Dummy =>
null;
end case;
end record;
type Part_Kinds is
(A_Public_Limited_View_Part,
A_Private_Limited_View_Part, -- where names of private children go
A_Visible_Part,
A_Private_Part,
A_Public_Children_Part,
A_Private_Children_Part,
A_Body_Part);
subtype A_Children_Part is Part_Kinds range
A_Public_Children_Part .. A_Private_Children_Part;
subtype A_Limited_View_Part is Part_Kinds range
A_Public_Limited_View_Part .. A_Private_Limited_View_Part;
Is_Visible : constant array (Part_Kinds) of Boolean :=
(A_Public_Limited_View_Part |
A_Visible_Part |
A_Public_Children_Part => True,
others => False);
type Part_Node is record
Dummy_Item : aliased Region_Item (Dummy);
Kind : Part_Kinds;
Region : Region_Access;
Next : Part_Access;
Parent_Item : Region_Item_Access;
Last_Item : Region_Item_Access;
Element : Asis.Element;
end record;
type Region_Node is record
First_Part : aliased Part_Node;
Last_Part : Part_Access;
Next : Region_Access;
First_Child : Region_Access;
Library_Unit : Boolean := False;
Public_Child : Boolean := True;
Depth : Positive := 1;
end record;
-- function Parent (Object : Region) return Region;
type Point is record
Item : Region_Item_Access;
end record;
Null_Point : constant Point := (Item => null);
end Asis.Gela.Visibility;
------------------------------------------------------------------------------
-- Copyright (c) 2006-2013, <NAME>
-- 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 <NAME>, 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 OWNER OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
|
30,455
|
ada
| 2,662
|
nehalem501/gendev
|
tools/files/applib/contrib/ada/aplib.ads
|
<gh_stars>1000+
--
-- aPLib compression library - the smaller the better :)
--
-- Ada binding for aplib.a
--
-- Copyright (c) 1998-2009 by <NAME> / Jibz
-- All Rights Reserved
--
-- http://www.ibsensoftware.com/
--
-- Ada binding by <NAME> - <EMAIL>, <EMAIL>
--
package aPLib is
-- Give the maximum "packed" size possible - it can be more than
-- the unpacked size in case of uncompressible data:
function Evaluate_max_packed_space( unpacked_size: Integer ) return Integer;
pragma Import(C, Evaluate_max_packed_space, "aP_max_packed_size");
-- Was, before v0.34 b4: (((unpacked_size * 9) / 8) + 16)
-- A template for packing data:
generic
type packed_data is private;
type unpacked_data is private;
with procedure Call_back( unpacked_bytes, packed_bytes: in integer;
continue : out boolean );
procedure Pack( source : in unpacked_data;
destination : out packed_data;
packed_length: out integer );
-- A template for unpacking data:
generic
type packed_data is private;
type unpacked_data is private;
procedure Depack( source : in packed_data;
destination: out unpacked_data );
-- Exceptions for errors that could occur:
pack_failed, unpack_failed: exception;
-- Just for information
function aP_workmem_size(inputsize: integer) return integer;
pragma Import(C, aP_workmem_size, "aP_workmem_size");
end aPLib;
|
30,456
|
ada
| 0
|
Tim-Tom/scratch
|
random-art/ada/inc/Expressions.ads
|
<reponame>Tim-Tom/scratch<filename>random-art/ada/inc/Expressions.ads
with Ada.Numerics.Float_Random;
package Expressions is
package Rand renames Ada.Numerics.Float_Random;
type Expression_Type is (Terminal, Single, Double);
subtype Expression_Value is Float range -1.0 .. 1.0;
type Expression_Terminal_Function is access function (x, y : Expression_Value) return Expression_Value;
type Expression_Single_Function is access function(e : Expression_Value) return Expression_Value;
type Expression_Double_Function is access function(e1, e2 : Expression_Value) return Expression_Value;
type Expression_Node(arguments : Expression_Type) is private;
type Expression_Node_Access is access all Expression_Node;
function Build_Expression_Tree(depth : Positive; gen : Rand.Generator) return Expression_Node_Access;
function Evaluate_Expression(node : not null Expression_Node_Access; x,y : Expression_Value) return Expression_Value;
private
type Expression_Node(arguments : Expression_Type) is record
case arguments is
when Terminal =>
expr_t : Expression_Terminal_Function;
when Single =>
e : Expression_Node_Access;
expr_s : Expression_Single_Function;
when Double =>
e1, e2 : Expression_Node_Access;
expr_d : Expression_Double_Function;
end case;
end record;
end Expressions;
|
30,457
|
ada
| 20
|
charlie5/lace
|
3-mid/opengl/source/lean/text/private/opengl-glyphimpl.adb
|
with
freetype_c.Binding,
freetype_c.FT_BBox,
freetype_c.FT_Vector;
package body openGL.GlyphImpl
is
-----------
-- Utility
--
function Bounds_of (glyth_Slot : in freetype_c.FT_GlyphSlot.item) return Bounds
is
use freetype_c.Binding;
bBox : aliased freetype_c.FT_BBox.item;
the_Bounds : Bounds;
begin
FT_Outline_Get_CBox (FT_GlyphSlot_Get_Outline (glyth_Slot).all'unchecked_Access,
bBox'unchecked_Access);
the_Bounds := (Ball => <>,
Box => (Lower => (1 => Real (bbox.xMin) / 64.0,
2 => Real (bbox.yMin) / 64.0,
3 => 0.0),
Upper => (1 => Real (bbox.xMax) / 64.0,
2 => Real (bbox.yMax) / 64.0,
3 => 0.0)));
set_Ball_from_Box (the_Bounds);
return the_Bounds;
end Bounds_of;
---------
-- Forge
--
procedure define (Self : in out Item; glyth_Slot : in freetype_c.FT_GlyphSlot.item)
is
use type freetype_c.FT_GlyphSlot.item;
begin
Self.Err := no_Error;
if glyth_Slot /= null
then
Self.bBox := Bounds_of (glyth_Slot);
declare
use freetype_c.Binding;
the_Advance : constant freetype_c.FT_Vector.item := FT_GlyphSlot_Get_Advance (glyth_Slot);
begin
Self.Advance := (Real (the_Advance.x) / 64.0,
Real (the_Advance.y) / 64.0,
0.0);
end;
end if;
end define;
procedure destruct (Self : in out Item)
is
begin
null;
end destruct;
--------------
-- Attributes
--
function Advance (Self : in Item) return Real
is
begin
return Self.Advance (1);
end Advance;
function BBox (Self : in Item) return Bounds
is
begin
return Self.bBox;
end BBox;
function Error (Self : in Item) return error_Kind
is
begin
return Self.Err;
end Error;
end openGL.GlyphImpl;
|
30,458
|
ada
| 488
|
ouankou/rose
|
tests/nonsmoke/functional/CompileTests/experimental_ada_tests/tests/variable_variant_record.adb
|
procedure Variant2 is
type POWER is (GAS, STEAM, DIESEL, NONE);
type VEHICLE (Engine : POWER := NONE) is
record
Model_Year : INTEGER range 1888..1992;
Wheels : INTEGER range 2..18;
case Engine is
when GAS => Cylinders : INTEGER range 1..16;
when STEAM => Boiler_Size : INTEGER range 5..22;
Coal_Burner : BOOLEAN;
when DIESEL => Fuel_Inject : BOOLEAN;
when NONE => Speeds : INTEGER range 1..15;
end case;
end record;
Ford, Truck, Schwinn : VEHICLE;
Stanley : VEHICLE(STEAM);
begin
Ford := (GAS, 1956, 4, 8);
Ford := (DIESEL, 1985, Fuel_Inject => TRUE, Wheels => 8);
Truck := (DIESEL, 1966, 18, TRUE);
Truck.Model_Year := 1968;
Truck.Fuel_Inject := FALSE;
Stanley.Model_Year := 1908; -- This is constant as STEAM
Stanley.Wheels := 4;
Stanley.Boiler_Size := 21;
Stanley.Coal_Burner := FALSE;
Schwinn.Speeds := 10; -- This defaults to NONE
Schwinn.Wheels := 2;
Schwinn.Model_Year := 1985;
end Variant2;
|
30,459
|
ada
| 0
|
antholuo/Blob_Traffic
|
Blob_Lib/assimp-5.2.3/assimp/contrib/zlib/contrib/ada/zlib-thin.ads
|
<gh_stars>0
version https://git-lfs.github.com/spec/v1
oid sha256:631ef170bde16c3ca8d412b54a0e519815b80197d208f8f393e6fe017bb0968e
size 15819
|
30,460
|
ada
| 60
|
Letractively/ada-util
|
src/util-beans-objects-datasets.adb
|
-----------------------------------------------------------------------
-- Util.Beans.Objects.Datasets -- Datasets
-- Copyright (C) 2013 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
package body Util.Beans.Objects.Datasets is
procedure Free is
new Ada.Unchecked_Deallocation (Object => Object_Array,
Name => Object_Array_Access);
procedure Free is
new Ada.Unchecked_Deallocation (Object => Dataset_Array,
Name => Dataset_Array_Access);
-- ------------------------------
-- Get the number of elements in the list.
-- ------------------------------
overriding
function Get_Count (From : in Dataset) return Natural is
begin
return From.Count;
end Get_Count;
-- ------------------------------
-- Set the current row index. Valid row indexes start at 1.
-- ------------------------------
overriding
procedure Set_Row_Index (From : in out Dataset;
Index : in Natural) is
begin
From.Current_Pos := Index;
From.Current.Data := From.Data (Index);
end Set_Row_Index;
-- ------------------------------
-- Get the element at the current row index.
-- ------------------------------
overriding
function Get_Row (From : in Dataset) return Util.Beans.Objects.Object is
begin
return From.Row;
end Get_Row;
-- ------------------------------
-- Get the value identified by the name.
-- If the name cannot be found, the method should return the Null object.
-- ------------------------------
overriding
function Get_Value (From : in Dataset;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "count" then
return Util.Beans.Objects.To_Object (From.Count);
elsif Name = "rowIndex" then
return Util.Beans.Objects.To_Object (From.Current_Pos);
else
return Util.Beans.Objects.Null_Object;
end if;
end Get_Value;
-- ------------------------------
-- Append a row in the dataset and call the fill procedure to populate
-- the row content.
-- ------------------------------
procedure Append (Into : in out Dataset;
Fill : not null access procedure (Data : in out Object_Array)) is
Data : constant Object_Array_Access := new Object_Array (1 .. Into.Columns);
begin
if Into.Data = null then
Into.Data := new Dataset_Array (1 .. 10);
elsif Into.Count >= Into.Data'Length then
declare
-- Sun's Java ArrayList use a 2/3 grow factor.
-- Python's array use 8/9.
Grow : constant Positive := Into.Count + (Into.Count * 2) / 3;
Set : constant Dataset_Array_Access := new Dataset_Array (1 .. Grow);
begin
Set (Into.Data'Range) := Into.Data.all;
Free (Into.Data);
Into.Data := Set;
end;
end if;
Into.Count := Into.Count + 1;
Into.Data (Into.Count) := Data;
Fill (Data.all);
end Append;
-- ------------------------------
-- Add a column to the dataset. If the position is not specified,
-- the column count is incremented and the name associated with the last column.
-- Raises Invalid_State exception if the dataset contains some rows,
-- ------------------------------
procedure Add_Column (Into : in out Dataset;
Name : in String;
Pos : in Natural := 0) is
Col : Positive;
begin
if Into.Count /= 0 then
raise Invalid_State with "The dataset contains some rows.";
end if;
if Pos = 0 then
Col := Into.Columns + 1;
else
Col := Pos;
end if;
Into.Map.Insert (Name, Col);
if Into.Columns < Col then
Into.Columns := Col;
end if;
end Add_Column;
-- ------------------------------
-- Clear the content of the dataset.
-- ------------------------------
procedure Clear (Set : in out Dataset) is
begin
for I in 1 .. Set.Count loop
Free (Set.Data (I));
end loop;
Set.Count := 0;
Set.Current_Pos := 0;
Set.Current.Data := null;
end Clear;
-- ------------------------------
-- Get the value identified by the name.
-- If the name cannot be found, the method should return the Null object.
-- ------------------------------
overriding
function Get_Value (From : in Row;
Name : in String) return Util.Beans.Objects.Object is
Pos : constant Dataset_Map.Cursor := From.Map.Find (Name);
begin
if From.Data /= null and then Dataset_Map.Has_Element (Pos) then
return From.Data (Dataset_Map.Element (Pos));
else
return Null_Object;
end if;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name.
-- If the name cannot be found, the method should raise the No_Value
-- exception.
-- ------------------------------
overriding
procedure Set_Value (From : in out Row;
Name : in String;
Value : in Util.Beans.Objects.Object) is
Pos : constant Dataset_Map.Cursor := From.Map.Find (Name);
begin
if From.Data /= null and then Dataset_Map.Has_Element (Pos) then
From.Data (Dataset_Map.Element (Pos)) := Value;
end if;
end Set_Value;
-- ------------------------------
-- Initialize the dataset and the row bean instance.
-- ------------------------------
overriding
procedure Initialize (Set : in out Dataset) is
begin
Set.Row := To_Object (Value => Set.Current'Unchecked_Access,
Storage => STATIC);
Set.Current.Map := Set.Map'Unchecked_Access;
end Initialize;
-- ------------------------------
-- Release the dataset storage.
-- ------------------------------
overriding
procedure Finalize (Set : in out Dataset) is
begin
Set.Clear;
Free (Set.Data);
end Finalize;
end Util.Beans.Objects.Datasets;
|
30,461
|
ada
| 1
|
LaudateCorpus1/RosettaCodeData
|
Task/Arbitrary-precision-integers--included-/Ada/arbitrary-precision-integers--included-.ada
|
<gh_stars>1-10
with Ada.Text_IO; use Ada.Text_IO;
with GNATCOLL.GMP; use GNATCOLL.GMP;
with GNATCOLL.GMP.Integers; use GNATCOLL.GMP.Integers;
procedure ArbitraryInt is
type stracc is access String;
BigInt : Big_Integer;
len : Natural;
str : stracc;
begin
Set (BigInt, 5);
Raise_To_N (BigInt, Unsigned_Long (4**(3**2)));
str := new String'(Image (BigInt));
len := str'Length;
Put_Line ("Size is:"& Natural'Image (len));
Put_Line (str (1 .. 20) & "....." & str (len - 19 .. len));
end ArbitraryInt;
|
30,462
|
ada
| 0
|
JCGobbi/Nucleo-STM32G474RE
|
bb-runtimes/src/s-textio__zynqmp.adb
|
<filename>bb-runtimes/src/s-textio__zynqmp.adb
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . T E X T _ I O --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2017, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This is the Xilinx Ultrascale+ MPSoC version of this package
with System;
with Interfaces;
package body System.Text_IO is
use Interfaces;
Base : constant := 16#FF00_0000#;
-- UART-1
CR : Unsigned_32 with Address => Base + 16#00#, Import, Volatile;
MR : Unsigned_32 with Address => Base + 16#00#, Import, Volatile;
IER : Unsigned_32 with Address => Base + 16#08#, Import, Volatile;
IDR : Unsigned_32 with Address => Base + 16#0C#, Import, Volatile;
ISR : Unsigned_32 with Address => Base + 16#14#, Import, Volatile;
SR : Unsigned_32 with Address => Base + 16#2c#, Import, Volatile;
Fifo : Unsigned_32 with Address => Base + 16#30#, Import, Volatile;
CR_RX_RST : constant := 16#00000001#;
CR_TX_RST : constant := 16#00000002#;
CR_RX_EN : constant := 16#00000004#;
CR_RX_DIS : constant := 16#00000008#;
CR_TX_EN : constant := 16#00000010#;
CR_TX_DIS : constant := 16#00000020#;
-- CR bits
MR_MODE_NORMAL : constant := 0;
MR_MODE_MASK : constant := 16#0000_0300#;
Tx_Full : constant Unsigned_32 := 2#0001_0000#;
Rx_Empty : constant Unsigned_32 := 2#0000_0010#;
-- SR bits
---------
-- Get --
---------
function Get return Character is
begin
return Character'Val (Fifo and 16#ff#);
end Get;
----------------
-- Initialize --
----------------
procedure Initialize is
Dead : Character with Unreferenced;
begin
Initialized := True;
-- Reset RX and TX
CR := CR or (CR_TX_RST or CR_RX_RST);
loop
exit when (CR and (CR_TX_RST or CR_RX_RST)) = 0;
end loop;
-- Disable the EN bits while clearing the DIS bits
CR := CR and not (CR_TX_DIS or CR_RX_DIS or CR_TX_EN or CR_RX_EN);
-- Enable RX and TX
CR := CR or (CR_TX_EN or CR_RX_EN);
-- Operating mode: normal
MR := (MR and not MR_MODE_MASK) or MR_MODE_NORMAL;
-- Disable interrupts
IDR := 16#3FFF#;
end Initialize;
-----------------
-- Is_Rx_Ready --
-----------------
function Is_Rx_Ready return Boolean is
begin
return (SR and Rx_Empty) = 0;
end Is_Rx_Ready;
-----------------
-- Is_Tx_Ready --
-----------------
function Is_Tx_Ready return Boolean is
begin
return (SR and Tx_Full) = 0;
end Is_Tx_Ready;
---------
-- Put --
---------
procedure Put (C : Character) is
begin
-- Send the character
Fifo := Character'Pos (C);
end Put;
----------------------------
-- Use_Cr_Lf_For_New_Line --
----------------------------
function Use_Cr_Lf_For_New_Line return Boolean is
begin
return True;
end Use_Cr_Lf_For_New_Line;
end System.Text_IO;
|
30,463
|
ada
| 4
|
jorge-real/Ball-On-Beam
|
src/bb-adc.adb
|
<filename>src/bb-adc.adb
--------------------------------------------------------------------------------
-- --
-- B A L L _ O N _ B E A M _ A D C --
-- --
-- Body --
-- --
-- This package implements an A/D converter interface with a position sensor --
-- sensor of package Ball_On_Beam_Simulator, instead of the "ideal" results --
-- produced by function Ball_Position of that BB.Ideal. --
-- The ADC converter transforms the result of Ball_Position into a 12-bit --
-- conversion. The conversion has some random noise added, with gaussian --
-- distribution to better emulate reality and to motivate the need for using --
-- some form of filtering. --
--
-- --
-- Author: <NAME> --
-- Universitat Politecnica de Valencia --
-- December, 2020 - Version 1 --
-- February, 2021 - Version 2 --
-- --
-- --
-- This package implements an A/D converter interface with the position --
-- sensor of package Ball_On_Beam_Simulator, instead of the "ideal" results --
-- produced by function Ball_Position of that package. --
-- The ADC converter transforms the result of Ball_Position into a 12-bit --
-- conversion. The conversion has some random noise added, with gaussian --
-- distribution to better emulate reality and to motivate the need for using --
-- some form of filtering. --
-- --
-- This is free software in the ample sense: --
-- you can use it freely, provided you preserve --
-- this comment at the header of source files --
-- and you clearly indicate the changes made to --
-- the original file, if any. --
-- --
--------------------------------------------------------------------------------
with Ada.Real_Time; use Ada.Real_Time;
with Ada.Real_Time.Timing_Events; use Ada.Real_Time.Timing_Events;
with Ada.Numerics; use Ada.Numerics;
with Ada.Numerics.Float_Random; use Ada.Numerics.Float_Random;
with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions;
package body BB.ADC is
-- The following procedures just call the implementation in package
-- Ball_On_Beam_Simulator. Ball_On_Beam_ADC only modifies the interface
-- with the position sensor, emulating an A/D converter
procedure Set_Beam_Angle (Inclination : Angle) renames
BB.Set_Beam_Angle;
procedure Set_Simulation_Mode (Mode : Simulation_Mode) renames
BB.Set_Simulation_Mode;
-- Move system to a solar system object
procedure Move_BB_To (Where : in Solar_System_Object) renames
BB.Move_BB_To;
-- ADC implementation
-- Latency of conversion
Conversion_Delay : Time_Span := Milliseconds (2);
-- To simulate gaussian noise in the ADC
Noise : Generator;
-- Standard deviation of noise
Sigma : constant := 4.0;
-- Protected object for ADC interrupt simulation
protected ADC is
pragma Interrupt_Priority;
procedure Set_User_Handler (UH : ADC_Handler_Access);
function Conversion_Result return ADC_Register;
procedure Write_CR (Value : ADC_Register);
private
ADC_Interrupt : Timing_Event;
procedure ADC_Int_Handler (TE : in out Timing_Event);
Interrupt_Enabled : Boolean := False;
User_Handler : ADC_Handler_Access;
User_Handler_Is_Set : Boolean := False;
Conversion : ADC_Register := 0;
end ADC;
protected body ADC is
function Conversion_Result return ADC_Register is (Conversion);
procedure Set_User_Handler (UH : ADC_Handler_Access) is
begin
User_Handler := UH;
User_Handler_Is_Set := True;
end Set_User_Handler;
procedure Write_CR (Value : ADC_Register) is
IE : constant Boolean := ((Value / 4) mod 2) /= 0; -- bit 2
TRG : constant Boolean := (Value mod 2) /= 0; -- bit 0
begin
if IE then
Interrupt_Enabled := True;
else
Interrupt_Enabled := False;
end if;
if TRG then
-- Set TE for end-of-conversion interrupt
Set_Handler (Event => ADC_Interrupt,
At_Time => Clock + Conversion_Delay,
Handler => ADC_Int_Handler'Access);
-- Clear EOC bit
Conversion := Conversion and 16#7FFF#;
end if;
end Write_CR;
procedure ADC_Int_Handler (TE : in out Timing_Event) is
-- Simulated ball position, with gaussian random noise added
-- Gaussian random obtained using the Box-Muller method
Simulated_Position : constant Float := Ball_Position +
(Sigma * Sqrt (-2.0 * Log (Random (Noise), Ada.Numerics.e)) *
Cos (2.0 * Pi * Random (Noise)));
-- Aux is assigned the Simulated_Position scaled to an ADC value. The
-- Simulated_Position could over/underflow the range of Position,
-- due to the addition of noise. Hence the convenience of this Aux
-- variable before we saturate the conversion to fall within the
-- range (0..4095), first thing we do in the body of this handler.
Aux : Integer :=
Integer (( (Simulated_Position - Position'First) * 4096.0) /
(Position'Last - Position'First));
begin
-- Saturate Aux to a range representable with 12 bits in NBC. Needed
-- because the addition of noise may over/underflow that range
Aux := Integer'Max (0, Aux);
Aux := Integer'Min (Aux, 4095);
-- Set the EOC bit in the Data register
Conversion := ADC_Register (Aux) or 16#8000#;
-- Execute user handler if interrupts are enabled and a handler is set
if Interrupt_Enabled and then User_Handler_Is_Set then
User_Handler.all;
end if;
end ADC_Int_Handler;
end ADC;
------------------------
-- Attach_ADC_Handler --
------------------------
procedure Attach_ADC_Handler (Handler : ADC_Handler_Access) is
begin
ADC.Set_User_Handler (Handler);
end Attach_ADC_Handler;
--------------
-- Write_CR --
--------------
procedure Write_CR (Value : ADC_Register) is
begin
ADC.Write_CR (Value);
end Write_CR;
-------------
-- Read_DR --
-------------
function Read_DR return ADC_Register is (ADC.Conversion_Result);
begin
Reset (Noise);
end BB.ADC;
|
30,464
|
ada
| 2
|
thindil/tashy2
|
tests/tk-ttklabelframe-test_data-tests.ads
|
<reponame>thindil/tashy2
package Tk.TtkLabelFrame.Test_Data.Tests is
end Tk.TtkLabelFrame.Test_Data.Tests;
|
30,465
|
ada
| 33
|
ytomino/drake
|
source/required/s-ststop.ads
|
pragma License (Unrestricted);
-- implementation unit required by compiler
with Ada.Streams.Block_Transmission.Strings;
with Ada.Streams.Block_Transmission.Wide_Strings;
with Ada.Streams.Block_Transmission.Wide_Wide_Strings;
with System.Storage_Elements;
package System.Strings.Stream_Ops is
pragma Pure;
pragma Suppress (All_Checks); -- for instantiation
-- required for String'Read by compiler (s-ststop.ads)
procedure String_Read_Blk_IO (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : out String)
renames Ada.Streams.Block_Transmission.Strings.Read;
-- required for String'Write by compiler (s-ststop.ads)
procedure String_Write_Blk_IO (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : String)
renames Ada.Streams.Block_Transmission.Strings.Write;
-- required for String'Input by compiler (s-ststop.ads)
function String_Input_Blk_IO is
new Ada.Streams.Block_Transmission.Input (
Positive,
Character,
String,
String_Read_Blk_IO);
-- required for String'Output by compiler (s-ststop.ads)
procedure String_Output_Blk_IO is
new Ada.Streams.Block_Transmission.Output (
Positive,
Character,
String,
String_Write_Blk_IO);
-- required for Wide_String'Read by compiler (s-ststop.ads)
procedure Wide_String_Read_Blk_IO (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : out Wide_String)
renames Ada.Streams.Block_Transmission.Wide_Strings.Read;
-- required for Wide_String'Write by compiler (s-ststop.ads)
procedure Wide_String_Write_Blk_IO (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : Wide_String)
renames Ada.Streams.Block_Transmission.Wide_Strings.Write;
-- required for Wide_String'Input by compiler (s-ststop.ads)
function Wide_String_Input_Blk_IO is
new Ada.Streams.Block_Transmission.Input (
Positive,
Wide_Character,
Wide_String,
Wide_String_Read_Blk_IO);
-- required for Wide_String'Output by compiler (s-ststop.ads)
procedure Wide_String_Output_Blk_IO is
new Ada.Streams.Block_Transmission.Output (
Positive,
Wide_Character,
Wide_String,
Wide_String_Write_Blk_IO);
-- required for Wide_Wide_String'Read by compiler (s-ststop.ads)
procedure Wide_Wide_String_Read_Blk_IO (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : out Wide_Wide_String)
renames Ada.Streams.Block_Transmission.Wide_Wide_Strings.Read;
-- required for Wide_Wide_String'Write by compiler (s-ststop.ads)
procedure Wide_Wide_String_Write_Blk_IO (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : Wide_Wide_String)
renames Ada.Streams.Block_Transmission.Wide_Wide_Strings.Write;
-- required for Wide_Wide_String'Input by compiler (s-ststop.ads)
function Wide_Wide_String_Input_Blk_IO is
new Ada.Streams.Block_Transmission.Input (
Positive,
Wide_Wide_Character,
Wide_Wide_String,
Wide_Wide_String_Read_Blk_IO);
-- required for Wide_Wide_String'Output by compiler (s-ststop.ads)
procedure Wide_Wide_String_Output_Blk_IO is
new Ada.Streams.Block_Transmission.Output (
Positive,
Wide_Wide_Character,
Wide_Wide_String,
Wide_Wide_String_Write_Blk_IO);
-- required for System.Storage_Elements.Storage_Array'Read (s-ststop.ads)
procedure Storage_Array_Read_Blk_IO is
new Ada.Streams.Block_Transmission.Read (
Storage_Elements.Storage_Offset,
Storage_Elements.Storage_Element,
Storage_Elements.Storage_Array);
-- required for System.Storage_Elements.Storage_Array'Write (s-ststop.ads)
procedure Storage_Array_Write_Blk_IO is
new Ada.Streams.Block_Transmission.Write (
Storage_Elements.Storage_Offset,
Storage_Elements.Storage_Element,
Storage_Elements.Storage_Array);
-- required for System.Storage_Elements.Storage_Array'Input (s-ststop.ads)
function Storage_Array_Input_Blk_IO is
new Ada.Streams.Block_Transmission.Input (
Storage_Elements.Storage_Offset,
Storage_Elements.Storage_Element,
Storage_Elements.Storage_Array,
Storage_Array_Read_Blk_IO);
-- required for System.Storage_Elements.Storage_Array'Output (s-ststop.ads)
procedure Storage_Array_Output_Blk_IO is
new Ada.Streams.Block_Transmission.Output (
Storage_Elements.Storage_Offset,
Storage_Elements.Storage_Element,
Storage_Elements.Storage_Array,
Storage_Array_Write_Blk_IO);
-- required for Ada.Streams.Stream_Element_Array'Read (s-ststop.ads)
procedure Stream_Element_Array_Read_Blk_IO (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : out Ada.Streams.Stream_Element_Array)
renames Ada.Streams.Block_Transmission.Stream_Element_Arrays.Read;
-- required for Ada.Streams.Stream_Element_Array'Write (s-ststop.ads)
procedure Stream_Element_Array_Write_Blk_IO (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : Ada.Streams.Stream_Element_Array)
renames Ada.Streams.Block_Transmission.Stream_Element_Arrays.Write;
-- required for Ada.Streams.Stream_Element_Array'Input (s-ststop.ads)
function Stream_Element_Array_Input_Blk_IO is
new Ada.Streams.Block_Transmission.Input (
Ada.Streams.Stream_Element_Offset,
Ada.Streams.Stream_Element,
Ada.Streams.Stream_Element_Array,
Stream_Element_Array_Read_Blk_IO);
-- required for Ada.Streams.Stream_Element_Array'Output (s-ststop.ads)
procedure Stream_Element_Array_Output_Blk_IO is
new Ada.Streams.Block_Transmission.Output (
Ada.Streams.Stream_Element_Offset,
Ada.Streams.Stream_Element,
Ada.Streams.Stream_Element_Array,
Stream_Element_Array_Write_Blk_IO);
end System.Strings.Stream_Ops;
|
30,466
|
ada
| 2
|
charlie5/cBound
|
tier-1/xcb/source/thin/xcb-xcb_client_message_data_t.ads
|
<reponame>charlie5/cBound
-- This file is generated by SWIG. Please do not modify by hand.
--
with swig;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_client_message_data_t is
-- Item
--
type Item_variant is (data8_variant, data16_variant, data32_variant);
type Item (union_Variant : Item_variant := Item_variant'First) is record
case union_Variant is
when data8_variant =>
data8 : aliased swig.int8_t_Array (0 .. 19);
when data16_variant =>
data16 : aliased swig.uint16_t_Array (0 .. 9);
when data32_variant =>
data32 : aliased swig.uint32_t_Array (0 .. 4);
end case;
end record;
pragma Unchecked_Union (Item);
-- Item_Array
--
type Item_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_client_message_data_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_client_message_data_t.Item,
Element_Array => xcb.xcb_client_message_data_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_client_message_data_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_client_message_data_t.Pointer,
Element_Array => xcb.xcb_client_message_data_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_client_message_data_t;
|
30,467
|
ada
| 0
|
melwyncarlo/ProjectEuler
|
problems/039/a039.adb
|
<reponame>melwyncarlo/ProjectEuler
with Ada.Integer_Text_IO;
-- Copyright 2021 <NAME>
procedure A039 is
use Ada.Integer_Text_IO;
P_Max_Solutions : Integer := 0;
N_Max_Solutions : Integer := 0;
B, N : Integer;
A, B2, P2 : Float;
begin
for P in reverse 500 .. 1000 loop
B := 1;
N := 0;
loop
if B = Integer (Float (P) / 2.0) then
exit;
end if;
P2 := Float (P);
B2 := Float (B);
A := ((P2 * P2) - (2.0 * P2 * B2)) / ((2.0 * P2) - (2.0 * B2));
if Float'Floor (A) = A then
N := N + 1;
end if;
B := B + 1;
end loop;
if N > N_Max_Solutions then
N_Max_Solutions := N;
P_Max_Solutions := P;
end if;
end loop;
Put (P_Max_Solutions, Width => 0);
end A039;
|
30,468
|
ada
| 0
|
rtoal/enhanced-dining-philosophers
|
ada/meals.adb
|
<reponame>rtoal/enhanced-dining-philosophers<filename>ada/meals.adb
------------------------------------------------------------------------------
-- meals.adb
--
-- Implementation of the Meals package.
------------------------------------------------------------------------------
with Ada.Strings.Unbounded;
use Ada.Strings.Unbounded;
package body Meals is
-- Store the prices of each individual meal component in tables for
-- efficient lookup.
E_Price: constant array (Entree_Selection) of Float := (
13.25, 10.00, 11.25, 6.50, 12.95, 14.95
);
S_Price: constant array (Soup_Selection) of Float := (0.00, 3.00);
D_Price: constant array (Dessert_Selection) of Float := (0.00, 3.50);
-- The price of a meal is found simply by looking up the prices of each of
-- the three components of the meal in the price tables and adding them up.
function Price (M: Meal) return Float is
begin
return E_Price(M.Entree) + S_Price(M.Soup) + D_Price(M.Dessert);
end Price;
-- To compute a random meal we pick a random entree selection, a random
-- soup selection, and a random dessert selection. Generators for
-- random selections are constructed by instantiating the generic
-- function Random_Discrete.
function Random_Entree is new Random_Discrete (Entree_Selection);
function Random_Soup is new Random_Discrete (Soup_Selection);
function Random_Dessert is new Random_Discrete (Dessert_Selection);
function Random_Meal return Meal is
begin
return (Random_Entree, Random_Soup, Random_Dessert);
end Random_Meal;
-- This is the function which gives the text describing a meal. The
-- string takes one of four forms, depending on the presence/abscence
-- of soup and dessert:
--
-- 1. <entree>
-- 2. <entree> with <soup>
-- 3. <entree> with <dessert>
-- 4. <entree> with <soup> and <dessert>
function "&" (S: Unbounded_String; M: Meal) return Unbounded_String is
Result: Unbounded_String := S;
begin
Append (Result, Entree_Selection'Image(M.Entree));
if M.Soup /= No_Soup or else M.Dessert /= No_Dessert then
Append (Result, " WITH ");
if M.Soup /= No_Soup then
Append (Result, Soup_Selection'Image(M.Soup));
if M.Dessert /= No_Dessert then
Append (Result, " AND ");
end if;
end if;
if M.Dessert /= No_Dessert then
Append (Result, Dessert_Selection'Image(M.Dessert));
end if;
end if;
return Result;
end "&";
end Meals;
|
30,469
|
ada
| 7
|
Fabien-Chouteau/Giza
|
src/hershey_fonts/giza-hershey_fonts.ads
|
<filename>src/hershey_fonts/giza-hershey_fonts.ads
------------------------------------------------------------------------------
-- --
-- Giza --
-- --
-- Copyright (C) 2016 <NAME> (<EMAIL>) --
-- --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Interfaces;
with Giza.Context; use Giza.Context;
with Giza.Font; use Giza.Font;
package Giza.Hershey_Fonts is
subtype Parent is Font.Instance;
type Hershey_Font (Number_Of_Glyphs : Natural) is new Parent with private;
overriding
procedure Glyph_Box (This : Hershey_Font;
C : Character;
Width, Height, X_Advance : out Natural;
X_Offset, Y_Offset : out Integer);
overriding
procedure Print_Glyph (This : Hershey_Font;
Ctx : in out Context.Class;
C : Character);
overriding
function Y_Advance (This : Hershey_Font) return Integer;
private
type Coord is new Interfaces.Integer_8 with Size => 8;
type Vect is record
X, Y : Coord;
end record with Pack;
Raise_Pen : constant Vect := (Coord'Last, Coord'Last);
type Vect_Array is array (Natural range <>) of Vect with Pack;
type Glyph (Number_Of_Vectors : Natural) is record
Width, Height, Y_Offset, X_Offset : Coord;
Vects : Vect_Array (1 .. Number_Of_Vectors);
end record;
type Glyph_Access is not null access constant Glyph;
subtype Glyph_Index is Positive;
type Glyph_Access_Array is array (Positive range <>) of Glyph_Access;
type Hershey_Font (Number_Of_Glyphs : Natural) is new Parent with record
Glyphs : Glyph_Access_Array (1 .. Number_Of_Glyphs);
Y_Advance : Coord;
end record;
Empty_Glyph : aliased constant Glyph :=
(Number_Of_Vectors => 0,
Width => 0,
Height => 0,
Y_Offset => 0,
X_Offset => 0,
Vects => (others => (Raise_Pen)));
end Giza.Hershey_Fonts;
|
30,470
|
ada
| 17
|
WinterAlexander/Ada-IntelliJ
|
src/test/resources/ada-sources/folding-test-data.ads
|
<fold text='with Play_Control, Record_Control, Ada.Text_IO, Sequencer; ...' expand='false'>with Play_Control, Record_Control, Ada.Text_IO, Sequencer;
with Ada.Text_IO;
with Pattern_Control;</fold>
<fold text='package Bens_New_Packge is ...' expand='true'>package Bens_New_Packge is
<fold text=' function test_1 return Integer is ...' expand='true'> function test_1 return Integer is
begin
return 1;
End Test_1;</fold>
<fold text=' function test_2 return Integer is ...' expand='true'> function test_2 return Integer is
begin
return 2;
End Test_2;</fold>
end Bens_New_Package</fold>
|
30,471
|
ada
| 4
|
DNSCatcher/DNSCatcher
|
src/dnscatcher/utils/logger/dnscatcher-utils-logger.ads
|
<reponame>DNSCatcher/DNSCatcher<gh_stars>1-10
-- Copyright 2019 <NAME> <<EMAIL>>
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to
-- deal in the Software without restriction, including without limitation the
-- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-- sell copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-- DEALINGS IN THE SOFTWARE.
with Ada.Containers.Vectors; use Ada.Containers;
-- @summary
-- Handles logging functionality for DNSCatcher. This represents a common
-- class of functionality, with individual subclasses defining logging to
-- null, stdout, file, and syslog
--
-- @description
-- DNSCatcher's Logger is designed to work on the basis of message compliation
-- and dispatching. Throughout a given operation, data may be passed through
-- multiple processors, modules, and other components, with other data being
-- handled simulatiously. As such Log messages are contained in a specific
-- queue which is then gathered up, and dispatched as one giant chunk of logs.
--
-- Given that many different component can be used for logging such as syslog
-- on POSIX systems, or perhaps Logstash, this is designed to be abstracted
-- away quickly and easily
--
package DNSCatcher.Utils.Logger is
-- Handles logging operations in a sane and consistent way within the
-- Catcher
-- Represents the type and severity of a log message. This type is directly
-- based on syslog message symatics.
type Log_Levels is
(EMERGERENCY, -- Emergency message; reserved for emergency bail outs
ALERT, -- Alert condition, system admin intervention required
CRITICAL, -- Critical message, something has gone wrong in a component
ERROR, -- Error message, may be fatal or non-fatal
WARNING, -- Warning
NOTICE, -- Information notice
INFO, -- Basic information
DEBUG -- Debug information
);
--!pp off
for Log_Levels use (EMERGERENCY => 0,
ALERT => 1,
CRITICAL => 2,
ERROR => 3,
WARNING => 4,
NOTICE => 5,
INFO => 6,
DEBUG => 7);
--!pp on
-- Logger configuration object
--
-- @value Log_Level
-- Sets the filter level for messages being sent
--
-- @value Use_Color
-- If supported, use color within the log message
type Logger_Configuration is record
Log_Level : Log_Levels;
Use_Color : Boolean;
end record;
-- Component_Vector is a list of Unbounded_Strings that make up the
-- component part of a given log message, creating a hierarchy of log
-- messages based on component and calling path
package Component_Vector is new Vectors (Natural, Unbounded_String);
-- Individual log message, which contains the component
--
-- @value Log_Level
-- The log level of a given message
--
-- @value Component
-- The vector containing the component levels
--
-- @value Message
-- The actual log message as an unbounded string
type Log_Message_Record is record
Log_Level : Log_Levels;
Component : Component_Vector.Vector;
Message : Unbounded_String;
end record;
type Log_Message_Record_Ptr is access Log_Message_Record;
-- Logger Message Queue is used by a task to ensure mesages are delivered in
-- order. One queue exists per task.
package Log_Message_Vector is new Vectors (Natural, Log_Message_Record);
-- Logger Message Component
--
-- This is a protected type that handles all log messages within a given
-- component, and is pushed into the global packet vector
protected type Logger_Message_Packet is
-- Pushes a component name onto the component stack
--
-- @value Component
-- Name of the component
entry Push_Component (Component : String);
-- Pops the latest component on the stack
entry Pop_Component;
-- Logs a message
--
-- @value Level
-- Log level of the message
--
-- @value Msg
-- String of the msg to be added
entry Log_Message
(Level : Log_Levels;
Msg : String);
-- Pops the top message of the internal message stack
--
-- @value Msg
-- Output for Log_Message_Record
entry Get (Msg : out Log_Message_Record);
-- Gets all messages from this component queue, and clears it
--
-- @value Queue
-- Returns a Log_Message_Vector with all the component objects
entry Get_All_And_Empty (Queue : out Log_Message_Vector.Vector);
-- Gets count of all messages in this queue
--
-- @value Count
-- Integer to return the count to
entry Count (Count : out Integer);
-- Empties queue of all messages
entry Empty;
private
Current_Component : Component_Vector.Vector;
Logged_Msgs : Log_Message_Vector.Vector;
end Logger_Message_Packet;
type Logger_Message_Packet_Ptr is access Logger_Message_Packet;
-- Vector containing sets of log messages
package Logger_Message_Packet_Vector is new Vectors (Natural,
Logger_Message_Packet_Ptr);
-- Implements the global logger queue message type; this is used as a global
-- object for taking logger packets and dispatching them to whatever end
-- point is configured by the logger
--
protected type Logger_Queue_Type is
-- Adds a logger message packet to the queue
--
-- @value Queue
-- Pointer to the logger message to add
entry Add_Packet (Queue : Logger_Message_Packet_Ptr);
-- Gets the top of the queue
--
-- @value Queue
-- Variable to write the pointer to
entry Get (Queue : out Logger_Message_Packet_Ptr);
-- Gets a count of the number of logger packets in the queue
--
-- @value Count
-- Count of all message
--
entry Count (Count : out Integer);
-- Empties the logger queue
entry Empty;
private
Queued_Packets : Logger_Message_Packet_Vector.Vector;
end Logger_Queue_Type;
-- Global for logging queues
Logger_Queue : Logger_Queue_Type;
-- Task for handling logger functionality
task type Logger is
-- Initializes the logger task
--
-- @value Cfg
-- Configuration object
entry Initialize (Cfg : Logger_Configuration);
-- Starts the logger thread
entry Start;
-- Stops the logger thread
entry Stop;
end Logger;
private
-- ANSI Color Codes, and Reset message for STDOUT printing on Linux
ANSI_Default : constant String := ASCII.ESC & "[39m";
ANSI_Black : constant String := ASCII.ESC & "[30m";
ANSI_Red : constant String := ASCII.ESC & "[31m";
ANSI_Green : constant String := ASCII.ESC & "[32m";
ANSI_Yellow : constant String := ASCII.ESC & "[33m";
ANSI_Blue : constant String := ASCII.ESC & "[34m";
ANSI_Magenta : constant String := ASCII.ESC & "[35m";
ANSI_Cyan : constant String := ASCII.ESC & "[36m";
ANSI_Light_Gray : constant String := ASCII.ESC & "[37m";
ANSI_Dark_Gray : constant String := ASCII.ESC & "[90m";
ANSI_Light_Red : constant String := ASCII.ESC & "[91m";
ANSI_Light_Green : constant String := ASCII.ESC & "[92m";
ANSI_Light_Yellow : constant String := ASCII.ESC & "[93m";
ANSI_Light_Blue : constant String := ASCII.ESC & "[94m";
ANSI_Light_Magenta : constant String := ASCII.ESC & "[95m";
ANSI_Light_Cyan : constant String := ASCII.ESC & "[96m";
ANSI_Reset : constant String := ASCII.ESC & "[0m";
end DNSCatcher.Utils.Logger;
|
30,472
|
ada
| 33
|
ytomino/drake
|
source/required/s-expint.ads
|
<reponame>ytomino/drake
pragma License (Unrestricted);
-- implementation unit required by compiler
with System.Exponentiations;
package System.Exp_Int is
pragma Pure;
-- required for "**" with checking by compiler (s-expint.ads)
function Exp_Integer is new Exponentiations.Generic_Exp_Integer (Integer);
end System.Exp_Int;
|
30,473
|
ada
| 33
|
ytomino/drake
|
source/interfaces/i-cstrin.ads
|
pragma License (Unrestricted);
with Interfaces.C.Char_Pointers;
with Interfaces.C.Generic_Strings;
package Interfaces.C.Strings is
new Generic_Strings (
Character_Type => Character,
String_Type => String,
Element => char,
Element_Array => char_array,
Pointers => Char_Pointers,
To_C => To_char_array,
To_Ada => To_String);
pragma Preelaborate (Interfaces.C.Strings);
|
30,474
|
ada
| 0
|
ytomino/gnat4drake
|
g-dirope.ads
|
pragma License (Unrestricted);
with Ada.Directories;
with Ada.Hierarchical_File_Names;
package GNAT.Directory_Operations is
subtype Dir_Name_Str is String;
subtype Dir_Type is Ada.Directories.Search_Type;
Directory_Error : exception;
-- Basic Directory operations
procedure Change_Dir (Dir_Name : Dir_Name_Str)
renames Ada.Directories.Set_Directory;
procedure Make_Dir (Dir_Name : Dir_Name_Str);
procedure Remove_Dir (
Dir_Name : Dir_Name_Str;
Recursive : Boolean := False);
function Get_Current_Dir return Dir_Name_Str
renames Ada.Directories.Current_Directory;
-- Pathname Operations
subtype Path_Name is String;
function Dir_Name (Path : Path_Name) return Dir_Name_Str
renames Ada.Hierarchical_File_Names.Containing_Directory;
function Base_Name (Path : Path_Name; Suffix : String := "")
return String;
function File_Extension (Path : Path_Name) return String
renames Ada.Hierarchical_File_Names.Extension;
type Path_Style is (System_Default);
function Format_Pathname (
Path : Path_Name;
Style : Path_Style := System_Default)
return Path_Name;
-- Iterators
procedure Open (Dir : in out Dir_Type; Dir_Name : Dir_Name_Str);
procedure Close (Dir : in out Dir_Type)
renames Ada.Directories.End_Search;
procedure Read (
Dir : in out Dir_Type;
Str : out String;
Last : out Natural);
end GNAT.Directory_Operations;
|
30,475
|
ada
| 1
|
ekoeppen/STM32_Generic_Ada_Drivers
|
stm32l0/stm32l0x1/svd/stm32_svd-firewall.ads
|
-- This spec has been automatically generated from STM32L0x1.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package STM32_SVD.Firewall is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Code segment start address
type FIREWALL_CSSA_Register is record
-- unspecified
Reserved_0_7 : STM32_SVD.Byte;
-- code segment start address
ADD : STM32_SVD.UInt16;
-- unspecified
Reserved_24_31 : STM32_SVD.Byte;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FIREWALL_CSSA_Register use record
Reserved_0_7 at 0 range 0 .. 7;
ADD at 0 range 8 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
-- Code segment length
type FIREWALL_CSL_Register is record
-- unspecified
Reserved_0_7 : STM32_SVD.Byte;
-- code segment length
LENG : STM32_SVD.UInt14;
-- unspecified
Reserved_22_31 : STM32_SVD.UInt10;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FIREWALL_CSL_Register use record
Reserved_0_7 at 0 range 0 .. 7;
LENG at 0 range 8 .. 21;
Reserved_22_31 at 0 range 22 .. 31;
end record;
-- Non-volatile data segment start address
type FIREWALL_NVDSSA_Register is record
-- unspecified
Reserved_0_7 : STM32_SVD.Byte;
-- Non-volatile data segment start address
ADD : STM32_SVD.UInt16;
-- unspecified
Reserved_24_31 : STM32_SVD.Byte;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FIREWALL_NVDSSA_Register use record
Reserved_0_7 at 0 range 0 .. 7;
ADD at 0 range 8 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
-- Non-volatile data segment length
type FIREWALL_NVDSL_Register is record
-- unspecified
Reserved_0_7 : STM32_SVD.Byte;
-- Non-volatile data segment length
LENG : STM32_SVD.UInt14;
-- unspecified
Reserved_22_31 : STM32_SVD.UInt10;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FIREWALL_NVDSL_Register use record
Reserved_0_7 at 0 range 0 .. 7;
LENG at 0 range 8 .. 21;
Reserved_22_31 at 0 range 22 .. 31;
end record;
-- Volatile data segment start address
type FIREWALL_VDSSA_Register is record
-- unspecified
Reserved_0_5 : STM32_SVD.UInt6;
-- Volatile data segment start address
ADD : STM32_SVD.UInt10;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FIREWALL_VDSSA_Register use record
Reserved_0_5 at 0 range 0 .. 5;
ADD at 0 range 6 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- Volatile data segment length
type FIREWALL_VDSL_Register is record
-- unspecified
Reserved_0_5 : STM32_SVD.UInt6;
-- Non-volatile data segment length
LENG : STM32_SVD.UInt10;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FIREWALL_VDSL_Register use record
Reserved_0_5 at 0 range 0 .. 5;
LENG at 0 range 6 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- Configuration register
type FIREWALL_CR_Register is record
-- Firewall pre alarm
FPA : STM32_SVD.Bit;
-- Volatile data shared
VDS : STM32_SVD.Bit;
-- Volatile data execution
VDE : STM32_SVD.Bit;
-- unspecified
Reserved_3_31 : STM32_SVD.UInt29;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for FIREWALL_CR_Register use record
FPA at 0 range 0 .. 0;
VDS at 0 range 1 .. 1;
VDE at 0 range 2 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Firewall
type Firewall_Peripheral is record
-- Code segment start address
FIREWALL_CSSA : aliased FIREWALL_CSSA_Register;
-- Code segment length
FIREWALL_CSL : aliased FIREWALL_CSL_Register;
-- Non-volatile data segment start address
FIREWALL_NVDSSA : aliased FIREWALL_NVDSSA_Register;
-- Non-volatile data segment length
FIREWALL_NVDSL : aliased FIREWALL_NVDSL_Register;
-- Volatile data segment start address
FIREWALL_VDSSA : aliased FIREWALL_VDSSA_Register;
-- Volatile data segment length
FIREWALL_VDSL : aliased FIREWALL_VDSL_Register;
-- Configuration register
FIREWALL_CR : aliased FIREWALL_CR_Register;
end record
with Volatile;
for Firewall_Peripheral use record
FIREWALL_CSSA at 16#0# range 0 .. 31;
FIREWALL_CSL at 16#4# range 0 .. 31;
FIREWALL_NVDSSA at 16#8# range 0 .. 31;
FIREWALL_NVDSL at 16#C# range 0 .. 31;
FIREWALL_VDSSA at 16#10# range 0 .. 31;
FIREWALL_VDSL at 16#14# range 0 .. 31;
FIREWALL_CR at 16#20# range 0 .. 31;
end record;
-- Firewall
Firewall_Periph : aliased Firewall_Peripheral
with Import, Address => Firewall_Base;
end STM32_SVD.Firewall;
|
30,476
|
ada
| 12
|
jquorning/ada-asf
|
src/asf-beans-injections.ads
|
<gh_stars>10-100
-----------------------------------------------------------------------
-- asf-beans-injections -- Injection of parameters, headers, cookies in beans
-- Copyright (C) 2015 <NAME>
-- Written by <NAME> (<EMAIL>)
--
-- 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.Strings;
with ASF.Requests;
package ASF.Beans.Injections is
type Inject_Type;
-- The injection handler is a procedure that extracts the information from a request
-- object and injects the value in the Ada bean instance.
type Injection_Handler is not null access
procedure (Bean : in out Util.Beans.Basic.Bean'Class;
Descriptor : in Inject_Type;
Request : in ASF.Requests.Request'Class);
-- Define and control the injection of a value in some Ada bean.
type Inject_Type is record
-- The handler that retrieves the value from the request object and injects it in the bean.
Handler : Injection_Handler;
-- The bean property name in the Ada bean.
Name : Util.Strings.Name_Access;
-- The HTTP header name, the query parameter name or the cookie name to inject.
Param : Util.Strings.Name_Access;
-- The path component to inject.
Pos : Natural := 0;
end record;
type Inject_Array_Type is array (Positive) of Inject_Type;
-- Inject the request header whose name is defined by Descriptor.Param.
procedure Header (Bean : in out Util.Beans.Basic.Bean'Class;
Descriptor : in Inject_Type;
Request : in ASF.Requests.Request'Class);
-- Inject the request query string parameter whose name is defined by Descriptor.Param.
procedure Query_Param (Bean : in out Util.Beans.Basic.Bean'Class;
Descriptor : in Inject_Type;
Request : in ASF.Requests.Request'Class);
-- Inject the request cookie whose name is defined by Descriptor.Param.
procedure Cookie (Bean : in out Util.Beans.Basic.Bean'Class;
Descriptor : in Inject_Type;
Request : in ASF.Requests.Request'Class);
-- Inject the request URI path component whose position is defined by Descriptor.Pos.
procedure Path_Param (Bean : in out Util.Beans.Basic.Bean'Class;
Descriptor : in Inject_Type;
Request : in ASF.Requests.Request'Class);
-- Inject into the Ada bean a set of information extracted from the request object.
-- The value is obtained from a request header, a cookie, a query string parameter or
-- from a URI path component. The value is injected by using the bean operation
-- <tt>Set_Value</tt>.
procedure Inject (Into : in out Util.Beans.Basic.Bean'Class;
List : in Inject_Array_Type;
Request : in ASF.Requests.Request'Class);
end ASF.Beans.Injections;
|
30,477
|
ada
| 1
|
Okasu/Byron
|
src/plugins/plugin.adb
|
<reponame>Okasu/Byron<filename>src/plugins/plugin.adb<gh_stars>1-10
package body Plugin
is
function Words (Str : Unbounded_String) return Vector
is
Result : Vector;
Word : Unbounded_String;
begin
for I in 1 .. Length (Str) loop
if Element (Str, I) /= ' ' and I /= Length (Str) then
Append (Word, Element (Str, I));
else
if I = Length (Str) then
Append (Word, Element (Str, I));
end if;
Append (Result, Word);
Delete (Word, 1, Length (Word));
end if;
end loop;
return Result;
end Words;
function Unwords (Words : Vector) return Unbounded_String
is
Result : Unbounded_String;
begin
for C in Iterate (Words) loop
Append (Result, Element (C) & " ");
end loop;
return Result;
end Unwords;
function Bold (Input : String) return String is
(Character'Val (8#02#) & Input & Character'Val (8#02#));
function Link (Input : Unbounded_String) return Boolean
is
begin
if Length (Input) > 7 then
declare
Maybe_Link : constant String := To_String (Input) (1 .. 7);
begin
if Maybe_Link = "http://" or Maybe_Link = "https:/" then
return True;
end if;
end;
end if;
return False;
exception
when others =>
return False;
end Link;
function GSub (Str : Unbounded_String;
From : String;
To : String) return Unbounded_String
is
Result : Unbounded_String := Str;
Start_Pos : Integer := Index (Result, From (From'First) & "");
End_Pos : Natural := Index (Result, From (From'Last) & "");
begin
loop
if Start_Pos /= 0 then
Replace_Slice (Result, Start_Pos, End_Pos, To);
Start_Pos := Index (Result, From (From'First) & "");
End_Pos := Index (Result, From (From'Last) & "");
else
exit;
end if;
end loop;
return Result;
end GSub;
end Plugin;
|
30,478
|
ada
| 7
|
Fabien-Chouteau/Giza
|
src/giza-image-dma2d.adb
|
------------------------------------------------------------------------------
-- --
-- Giza --
-- --
-- Copyright (C) 2016 <NAME> (<EMAIL>) --
-- --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with Giza.Colors; use Giza.Colors;
package body Giza.Image.DMA2D is
----------
-- Size --
----------
overriding function Size
(This : Instance)
return Size_T
is
begin
return (This.W, This.H);
end Size;
-------------------
-- To_Giza_Color --
-------------------
function To_Giza_Color (C : DMA2D_Color) return Giza.Colors.Color is
(R => RGB_Component (C.R),
G => RGB_Component (C.G),
B => RGB_Component (C.B));
---------------
-- Get_Pixel --
---------------
function Get_Pixel (This : Instance; Pt : Point_T) return DMA2D_Color is
begin
case This.Mode is
when RGB888 => null;
return This.RGB888_Data
((Pt.X + This.RGB888_Data'First) + (Pt.Y * This.W));
when L4 => null;
declare
Index : constant Natural :=
(Pt.X + This.L4_Data'First) + Pt.Y * This.W;
B : constant Unsigned_8 :=
This.L4_Data (Index / 2);
begin
if Index mod 2 = 0 then
return This.L4_CLUT (Unsigned_4 (B and 16#0F#));
else
return This.L4_CLUT (Unsigned_4 ((B and 16#F0#) / 2**4));
end if;
end;
when L8 =>
return This.L8_CLUT
(This.L8_Data ((Pt.X + This.L8_Data'First) + Pt.Y * This.W));
end case;
end Get_Pixel;
---------------
-- Get_Pixel --
---------------
function Get_Pixel (This : Instance; Pt : Point_T) return Giza.Colors.Color
is (To_Giza_Color (Get_Pixel (This, Pt)));
end Giza.Image.DMA2D;
|
30,479
|
ada
| 36
|
rewriting/tom
|
src/tom/library/sl/ada/sequencestrategy.ads
|
with ObjectPack, AbstractStrategyCombinatorPackage, IntrospectorPackage, StrategyPackage;
use ObjectPack, AbstractStrategyCombinatorPackage, IntrospectorPackage, StrategyPackage;
package SequenceStrategy is
FIRST : constant Integer := 0;
SECOND : constant Integer := 1;
type Sequence is new AbstractStrategyCombinator and Object with null record;
----------------------------------------------------------------------------
-- Object implementation
----------------------------------------------------------------------------
function toString(o: Sequence) return String;
----------------------------------------------------------------------------
-- Strategy implementation
----------------------------------------------------------------------------
function visitLight(str:access Sequence; any: ObjectPtr; i: access Introspector'Class) return ObjectPtr;
function visit(str: access Sequence; i: access Introspector'Class) return Integer;
----------------------------------------------------------------------------
procedure makeSequence(s : in out Sequence; str1, str2 : StrategyPtr);
function make(str1, str2: StrategyPtr) return StrategyPtr;
function newSequence(str1, str2: StrategyPtr) return StrategyPtr;
----------------------------------------------------------------------------
end SequenceStrategy;
|
30,480
|
ada
| 7
|
best08618/asylo
|
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c5/c58004d.ada
|
-- C58004D.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT A RETURN STATEMENT TERMINATES EXECUTION
-- OF THE INNERMOST ENCLOSING SUBPROGRAM.
-- CHECKS GENERIC SUBPROGRAMS.
-- SPS 3/7/83
-- JRK 1/31/84
WITH REPORT;
PROCEDURE C58004D IS
USE REPORT;
I1, I2 : INTEGER;
GENERIC
PROCEDURE ADDM (IA1 : IN OUT INTEGER; IA2 : IN INTEGER);
PROCEDURE ADDM (IA1 : IN OUT INTEGER; IA2 : IN INTEGER) IS
GENERIC
PROCEDURE MULT (IM1 : IN OUT INTEGER; IM2 : IN INTEGER);
PROCEDURE MULT (IM1 : IN OUT INTEGER; IM2 : IN INTEGER) IS
BEGIN
IM1 := IM1 * IM2;
IF IM1 > 0 THEN RETURN;
END IF;
IM1 := 0;
END MULT;
PROCEDURE MLT IS NEW MULT;
BEGIN
MLT (IA1, IA2);
IA1 := IA1 + IA2;
IF IA1 > 0 THEN RETURN;
END IF;
IA1 := 0;
END ADDM;
PROCEDURE ADM IS NEW ADDM;
BEGIN
TEST ("C58004D","CHECK THAT RETURN TERMINATES EXECUTION OF ONLY" &
" THE INNERMOST ENCLOSING GENERIC SUBPROGRAM");
I1 := 2;
I2 := 3;
ADM (I1,I2); -- SAME AS I1 := (I1 * I2) + I2
IF I1 = 0 THEN
FAILED ("RETURN DOES NOT TERMINATE SUBPROGRAM");
ELSIF I1 = 6 THEN
FAILED
("RETURN TERMINATES ALL SUBPROGRAMS NOT JUST INNERMOST");
ELSIF I1 /= 9 THEN
FAILED ("RETURN STATEMENT NOT WORKING CORRECTLY");
END IF;
RESULT;
END C58004D;
|
30,481
|
ada
| 0
|
sebsgit/textproc
|
src/tests/shapedatabasetest.ads
|
<filename>src/tests/shapedatabasetest.ads
with AUnit; use AUnit;
with AUnit.Test_Cases; use AUnit.Test_Cases;
--TODO: add tests for histogram data
--TODO: add importing the training_set data
package ShapeDatabaseTest is
type TestCase is new AUnit.Test_Cases.Test_Case with null record;
procedure Register_Tests(T: in out TestCase);
function Name(T: TestCase) return Message_String;
procedure testHistogramDescriptors(T : in out Test_Cases.Test_Case'Class);
procedure testLearningData(T : in out Test_Cases.Test_Case'Class);
end ShapeDatabaseTest;
|
30,482
|
ada
| 7
|
best08618/asylo
|
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/discr46.adb
|
<reponame>best08618/asylo
-- { dg-do compile }
package body Discr46 is
function F (Id : Enum) return Integer is
Node : Integer := 0;
begin
if A (Id).R.D = True then
Node := A (Id).R.T;
end if;
return Node;
end;
end Discr46;
|
30,483
|
ada
| 204
|
spr93/whitakers-words
|
src/tools/invstems.adb
|
-- WORDS, a Latin dictionary, by <NAME> (USAF, Retired)
--
-- Copyright <NAME> (1936–2010)
--
-- This is a free program, which means it is proper to copy it and pass
-- it on to your friends. Consider it a developmental item for which
-- there is no charge. However, just for form, it is Copyrighted
-- (c). Permission is hereby freely given for any and all use of program
-- and data. You can sell it as your own, but at least tell me.
--
-- This version is distributed without obligation, but the developer
-- would appreciate comments and suggestions.
--
-- All parts of the WORDS system, source code and data files, are made freely
-- available to anyone who wishes to use them, for whatever purpose.
with Text_IO; use Text_IO;
with Latin_Utils.Strings_Package; use Latin_Utils.Strings_Package;
procedure Invstems is
Line : String (1 .. 250);
Ll : Integer;
subtype Stem is String (1 .. 18);
Blank_Stem : constant Stem := (others => ' ');
Sts : array (1 .. 4) of Stem;
Input, Output : File_Type;
function Invert (S : String) return String is
T : String (S'First .. S'Last);
begin
if S (S'First) = ' ' then
return Blank_Stem;
else
for I in S'Range loop
T (I) := S (S'Last - I + 1);
end loop;
return Head (Trim (T), 18);
end if;
end Invert;
begin
Put_Line ("Inverts the 4 stems of a DICTLINE form file " &
"INVERT_S.IN -> INVERT_S.OUT");
Create (Output, Out_File, "INVERT_S.OUT");
Open (Input, In_File, "INVERT_S.IN");
while not End_Of_File (Input) loop
Get_Line (Input, Line, Ll);
Sts (1) := Line (1 .. 18);
Sts (2) := Line (20 .. 37);
Sts (3) := Line (39 .. 56);
Sts (4) := Line (58 .. 75);
for I in 1 .. 4 loop
Sts (I) := Invert (Sts (I));
end loop;
Line (1 .. 18) := Sts (1);
Line (20 .. 37) := Sts (2);
Line (39 .. 56) := Sts (3);
Line (58 .. 75) := Sts (4);
Put_Line (Output, Line (1 .. Ll));
end loop;
Close (Output);
end Invstems;
|
30,484
|
ada
| 24
|
svn2github/matreshka
|
source/amf/mofext/amf-internals-tables-mofext_reflection.adb
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, <NAME> <<EMAIL>> --
-- 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.Holders.Elements;
with AMF.Internals.Helpers;
with AMF.Internals.Holders.UML_Holders;
with AMF.Internals.Tables.MOFEXT_Element_Table;
with AMF.Internals.Tables.MOFEXT_Types;
with AMF.Internals.Tables.MOF_Metamodel;
with AMF.Internals.Tables.UML_Metamodel;
with AMF.MOF.Tags;
with AMF.UML.Comments.Collections;
with AMF.UML.Elements.Collections;
with League.Holders;
package body AMF.Internals.Tables.MOFEXT_Reflection is
---------
-- Get --
---------
function Get
(Self : AMF.Internals.AMF_Element;
Property : CMOF_Element) return League.Holders.Holder
is
function MOF_Tag_Get return League.Holders.Holder;
-- Returns attribute's value of instance of Tag class.
-----------------
-- MOF_Tag_Get --
-----------------
function MOF_Tag_Get return League.Holders.Holder is
begin
if Property = AMF.Internals.Tables.MOF_Metamodel.MP_MOF_Tag_Element_A_Tag then
-- Tag::element : Element
return
AMF.UML.Elements.Collections.UML_Element_Collections.Internals.To_Holder
(AMF.MOF.Tags.MOF_Tag_Access
(AMF.Internals.Helpers.To_Element (Self)).Get_Element);
elsif Property = AMF.Internals.Tables.MOF_Metamodel.MP_MOF_Tag_Name then
-- Tag::name : String
return
League.Holders.To_Holder
(AMF.MOF.Tags.MOF_Tag_Access
(AMF.Internals.Helpers.To_Element (Self)).Get_Name);
elsif Property = AMF.Internals.Tables.UML_Metamodel.MP_UML_Element_Owned_Comment_A_Owning_Element then
-- Element::ownedComment : Comment
return
AMF.UML.Comments.Collections.UML_Comment_Collections.Internals.To_Holder
(AMF.MOF.Tags.MOF_Tag_Access
(AMF.Internals.Helpers.To_Element (Self)).Get_Owned_Comment);
elsif Property = AMF.Internals.Tables.UML_Metamodel.MP_UML_Element_Owned_Element_Element_Owner then
-- Element::ownedElement : Element
return
AMF.UML.Elements.Collections.UML_Element_Collections.Internals.To_Holder
(AMF.MOF.Tags.MOF_Tag_Access
(AMF.Internals.Helpers.To_Element (Self)).Get_Owned_Element);
elsif Property = AMF.Internals.Tables.UML_Metamodel.MP_UML_Element_Owner_Element_Owned_Element then
-- Element::owner : Element
return
AMF.Internals.Holders.UML_Holders.To_Holder
(AMF.UML.Elements.UML_Element_Access'
(AMF.MOF.Tags.MOF_Tag_Access
(AMF.Internals.Helpers.To_Element (Self)).Get_Owner));
elsif Property = AMF.Internals.Tables.MOF_Metamodel.MP_MOF_Tag_Tag_Owner_A_Owned_Tag then
-- Tag::tagOwner : Element
return
AMF.Internals.Holders.UML_Holders.To_Holder
(AMF.UML.Elements.UML_Element_Access'
(AMF.MOF.Tags.MOF_Tag_Access
(AMF.Internals.Helpers.To_Element (Self)).Get_Tag_Owner));
elsif Property = AMF.Internals.Tables.MOF_Metamodel.MP_MOF_Tag_Value then
-- Tag::value : String
return
League.Holders.To_Holder
(AMF.MOF.Tags.MOF_Tag_Access
(AMF.Internals.Helpers.To_Element (Self)).Get_Value);
else
raise Program_Error;
end if;
end MOF_Tag_Get;
begin
case AMF.Internals.Tables.MOFEXT_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.MOFEXT_Types.E_None =>
raise Program_Error;
when AMF.Internals.Tables.MOFEXT_Types.E_MOF_Tag =>
return MOF_Tag_Get;
end case;
end Get;
--------------------
-- Get_Meta_Class --
--------------------
function Get_Meta_Class
(Self : AMF.Internals.AMF_Element) return CMOF_Element is
begin
case MOFEXT_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.MOFEXT_Types.E_None =>
return 0;
when AMF.Internals.Tables.MOFEXT_Types.E_MOF_Tag =>
return AMF.Internals.Tables.MOF_Metamodel.MC_MOF_Tag;
end case;
end Get_Meta_Class;
---------
-- Set --
---------
procedure Set
(Self : AMF.Internals.AMF_Element;
Property : CMOF_Element;
Value : League.Holders.Holder)
is
procedure MOF_Tag_Set;
-- Sets attribute's value of instance of Tag class.
-----------------
-- MOF_Tag_Set --
-----------------
procedure MOF_Tag_Set is
begin
if Property = AMF.Internals.Tables.MOF_Metamodel.MP_MOF_Tag_Name then
-- Tag::name : String
AMF.MOF.Tags.MOF_Tag_Access
(AMF.Internals.Helpers.To_Element (Self)).Set_Name
(League.Holders.Element (Value));
elsif Property = AMF.Internals.Tables.MOF_Metamodel.MP_MOF_Tag_Tag_Owner_A_Owned_Tag then
-- Tag::tagOwner : Element
AMF.MOF.Tags.MOF_Tag_Access
(AMF.Internals.Helpers.To_Element (Self)).Set_Tag_Owner
(AMF.UML.Elements.UML_Element_Access (AMF.Holders.Elements.Element (Value)));
elsif Property = AMF.Internals.Tables.MOF_Metamodel.MP_MOF_Tag_Value then
-- Tag::value : String
AMF.MOF.Tags.MOF_Tag_Access
(AMF.Internals.Helpers.To_Element (Self)).Set_Value
(League.Holders.Element (Value));
else
raise Program_Error;
end if;
end MOF_Tag_Set;
begin
case MOFEXT_Element_Table.Table (Self).Kind is
when AMF.Internals.Tables.MOFEXT_Types.E_None =>
raise Program_Error;
when AMF.Internals.Tables.MOFEXT_Types.E_MOF_Tag =>
MOF_Tag_Set;
end case;
end Set;
end AMF.Internals.Tables.MOFEXT_Reflection;
|
30,485
|
ada
| 24
|
svn2github/matreshka
|
source/amf/uml/amf-uml-state_invariants.ads
|
<filename>source/amf/uml/amf-uml-state_invariants.ads
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, <NAME> <<EMAIL>> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
-- A state invariant is a runtime constraint on the participants of the
-- interaction. It may be used to specify a variety of different kinds of
-- constraints, such as values of attributes or variables, internal or
-- external states, and so on. A state invariant is an interaction fragment
-- and it is placed on a lifeline.
------------------------------------------------------------------------------
limited with AMF.UML.Constraints;
with AMF.UML.Interaction_Fragments;
limited with AMF.UML.Lifelines;
package AMF.UML.State_Invariants is
pragma Preelaborate;
type UML_State_Invariant is limited interface
and AMF.UML.Interaction_Fragments.UML_Interaction_Fragment;
type UML_State_Invariant_Access is
access all UML_State_Invariant'Class;
for UML_State_Invariant_Access'Storage_Size use 0;
not overriding function Get_Covered
(Self : not null access constant UML_State_Invariant)
return AMF.UML.Lifelines.UML_Lifeline_Access is abstract;
-- Getter of StateInvariant::covered.
--
-- References the Lifeline on which the StateInvariant appears.
not overriding procedure Set_Covered
(Self : not null access UML_State_Invariant;
To : AMF.UML.Lifelines.UML_Lifeline_Access) is abstract;
-- Setter of StateInvariant::covered.
--
-- References the Lifeline on which the StateInvariant appears.
not overriding function Get_Invariant
(Self : not null access constant UML_State_Invariant)
return AMF.UML.Constraints.UML_Constraint_Access is abstract;
-- Getter of StateInvariant::invariant.
--
-- A Constraint that should hold at runtime for this StateInvariant
not overriding procedure Set_Invariant
(Self : not null access UML_State_Invariant;
To : AMF.UML.Constraints.UML_Constraint_Access) is abstract;
-- Setter of StateInvariant::invariant.
--
-- A Constraint that should hold at runtime for this StateInvariant
end AMF.UML.State_Invariants;
|
30,486
|
ada
| 0
|
SKNZ/BoiteMaker
|
src/halfbox.ads
|
<reponame>SKNZ/BoiteMaker<gh_stars>0
with halfbox_panel;
use halfbox_panel;
with halfbox_info;
use halfbox_info;
package halfbox is
type halfbox_t is
record
-- mesures de la demi-boite
info : halfbox_info_t;
-- face inférieure
panel_bottom : halfbox_panel_t;
-- face arrière
panel_back : halfbox_panel_t;
-- face avant
panel_front : halfbox_panel_t;
-- face gauche
panel_left : halfbox_panel_t;
-- face droite
panel_right : halfbox_panel_t;
end record;
-- Obtient une demi-boite avec les mesures données
function get_halfbox(width, length, height, thickness, queue_length : integer) return halfbox_t;
-- Detruit la demi boite
procedure destroy(halfbox : in out halfbox_t);
-- Obtient une description texte de la demiboite
function to_string(halfbox : halfbox_t) return string;
end halfbox;
|
30,487
|
ada
| 0
|
mstewartgallus/linted
|
src/ada-core/src/linted-channels.adb
|
<filename>src/ada-core/src/linted-channels.adb
-- Copyright 2016,2017 <NAME>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-- implied. See the License for the specific language governing
-- permissions and limitations under the License.
package body Linted.Channels is
procedure Push (This : in out Channel; Element : Element_T) is
begin
This.Push (Element);
end Push;
procedure Pop (This : in out Channel; Element : out Element_T) is
begin
This.Pop_Impl (Element);
end Pop;
procedure Poll
(This : in out Channel;
Element : out Element_T;
Success : out Boolean)
is
begin
This.Poll (Element, Success);
end Poll;
protected body Channel is
procedure Push (Element : Element_T) is
begin
Current := Element;
Full := True;
end Push;
entry Pop_Impl (Element : out Element_T) when Full is
begin
Element := Current;
Full := False;
end Pop_Impl;
procedure Poll (Element : out Element_T; Success : out Boolean) is
begin
if Full then
Full := False;
Element := Current;
Success := True;
else
declare
Dummy : Element_T;
begin
Element := Dummy;
end;
Success := False;
end if;
end Poll;
end Channel;
end Linted.Channels;
|
30,488
|
ada
| 15
|
AdaCore/training_material
|
extern/gnat_sdl/gnat_sdl2/src/sdl_clipboard_h.ads
|
pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings;
with SDL_stdinc_h;
package SDL_clipboard_h is
-- Simple DirectMedia Layer
-- Copyright (C) 1997-2018 <NAME> <<EMAIL>>
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
-- 3. This notice may not be removed or altered from any source distribution.
--
--*
-- * \file SDL_clipboard.h
-- *
-- * Include file for SDL clipboard handling
--
-- Set up for C function definitions, even when using C++
-- Function prototypes
--*
-- * \brief Put UTF-8 text into the clipboard
-- *
-- * \sa SDL_GetClipboardText()
--
function SDL_SetClipboardText (text : Interfaces.C.Strings.chars_ptr) return int; -- ..\SDL2_tmp\SDL_clipboard.h:46
pragma Import (C, SDL_SetClipboardText, "SDL_SetClipboardText");
--*
-- * \brief Get UTF-8 text from the clipboard, which must be freed with SDL_free()
-- *
-- * \sa SDL_SetClipboardText()
--
function SDL_GetClipboardText return Interfaces.C.Strings.chars_ptr; -- ..\SDL2_tmp\SDL_clipboard.h:53
pragma Import (C, SDL_GetClipboardText, "SDL_GetClipboardText");
--*
-- * \brief Returns a flag indicating whether the clipboard exists and contains a text string that is non-empty
-- *
-- * \sa SDL_GetClipboardText()
--
function SDL_HasClipboardText return SDL_stdinc_h.SDL_bool; -- ..\SDL2_tmp\SDL_clipboard.h:60
pragma Import (C, SDL_HasClipboardText, "SDL_HasClipboardText");
-- Ends C function definitions when using C++
-- vi: set ts=4 sw=4 expandtab:
end SDL_clipboard_h;
|
30,489
|
ada
| 0
|
annexi-strayline/ASAP-INET
|
ip_lookup/unix/inet-ip-lookup.adb
|
------------------------------------------------------------------------------
-- --
-- Internet Protocol Suite Package --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * <NAME> (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with System.Storage_Elements;
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Pointers;
with Ada.Unchecked_Conversion;
with INET.IP.OS_Address_Info;
with INET.Internal.OS_Constants; use INET.Internal.OS_Constants;
pragma External_With ("inet-ip-lookup-sys.c");
package body INET.IP.Lookup is
IPv4_addrlen: constant socklen_t with Import => True, Convention => C,
External_Name => "__inet_ip_lookup_sys_addrlen4";
IPv6_addrlen: constant socklen_t with Import => True, Convention => C,
External_Name => "__inet_ip_lookup_sys_addrlen6";
package SSE renames System.Storage_Elements;
use type SSE.Integer_Address;
type addrinfo is new INET.IP.OS_Address_Info.struct_addrinfo with
Convention => C;
-- ^ Taft amendment completion
-----------------------
-- Assert_Constraint --
-----------------------
procedure Assert_Constraint (Check : in Boolean; Message: in String) with
Inline is
begin
if not Check then
raise Constraint_Error with Message;
end if;
end Assert_Constraint;
------------
-- Lookup --
------------
procedure Lookup_Actual (List : in out IP_Lookup;
Host_Name : in String;
Protocol : in IP_Protocols := Proto_Any;
Version : in IP_Version;
Any_Version: in Boolean)
with Inline is
use Interfaces.C.Strings;
-- Any_Version ignores the value of Version
function getaddrinfo (hostname: in char_array;
servname: in chars_ptr := Null_Chars_Ptr;
hints : in addrinfo;
res : out Entry_Pointer)
return int
with Import => True, Convention => C, External_Name => "getaddrinfo";
hints: addrinfo;
Retval: int;
begin
if Host_Name'Length = 0 then
raise Constraint_Error with "Host_Name is an empty String";
end if;
List.Finalize; -- Ensure any previous lookups are freed
-- Set-up hints
hints.ai_flags := AI_CANONNAME;
if Any_Version then
hints.ai_flags := hints.ai_flags + AI_ADDRCONFIG;
hints.ai_family := AF_UNSPEC;
else
hints.ai_family := (case Version is
when IPv4 => AF_INET,
when IPv6 => AF_INET6);
end if;
case Protocol is
when Proto_Any =>
null; -- defaults are correct
when Proto_TCP =>
hints.ai_socktype := SOCK_STREAM;
hints.ai_protocol := IPPROTO_TCP;
when Proto_UDP =>
hints.ai_socktype := SOCK_DGRAM;
hints.ai_protocol := IPPROTO_UDP;
when Proto_SCTP =>
hints.ai_socktype := SOCK_SEQPACKET;
hints.ai_protocol := IPPROTO_SCTP;
end case;
Retval := getaddrinfo (hostname => To_C (Host_Name),
hints => hints,
res => List.List_Head);
if Retval /= 0 then
List.Finalize;
return;
end if;
List.Next_Pop := List.List_Head;
List.Canonname := List.List_Head.ai_canonname;
end Lookup_Actual;
----------------------------------------------------------------------
procedure Lookup (List : in out IP_Lookup;
Host_Name: in String;
Protocol : in IP_Protocols := Proto_Any)
is begin
Lookup_Actual (List, Host_Name, Protocol,
Version => IPv6, -- This is arbitrary (ignored)
Any_Version => True);
end Lookup;
----------------------------------------------------------------------
procedure Lookup (List : in out IP_Lookup;
Host_Name: in String;
Protocol : in IP_Protocols := Proto_Any;
Version : in IP_Version)
is begin
Lookup_Actual (List, Host_Name, Protocol, Version,
Any_Version => False);
end Lookup;
----------------------
-- Has_More_Entries --
----------------------
function Has_More_Entries (List: IP_Lookup) return Boolean is
(List.Next_Pop /= null);
--------------------
-- Canonical_Name --
--------------------
function Canonical_Name (List: IP_Lookup) return String is
use Interfaces.C.Strings;
begin
if List.Canonname = Null_Chars_Ptr then
return "";
else
return Value (List.Canonname);
end if;
end Canonical_Name;
---------
-- Pop --
---------
procedure Pop (List: in out IP_Lookup; Item: out IP_Lookup_Entry) is
subtype Void_Pointer is OS_Address_Info.Void_Pointer;
procedure extract4 (src: in Void_Pointer; addr: out IPv4_Address) with
Import => True, Convention => C,
External_Name => "__inet_ip_lookup_sys_extract4";
procedure extract6 (src: in Void_Pointer; addr: out IPv6_Address) with
Import => True, Convention => C,
External_Name => "__inet_ip_lookup_sys_extract6";
procedure Advance_List with Inline is
function To_Entry_Pointer is new Ada.Unchecked_Conversion
(Source => OS_Address_Info.addrinfo_ptr,
Target => Entry_Pointer);
-- This is always safe since Entry_Pointer points at a addrinfo
-- record, which is a struct_addrinfo
begin
List.Next_Pop := To_Entry_Pointer (List.Next_Pop.ai_next);
end;
begin
Assert_Constraint
(List.Has_More_Entries, "List has no more entires to pop.");
pragma Assert (List.Next_Pop /= null);
-- Would have been nice to use case statements here, but unfortunately
-- we needed to import the C macros as run-time elaborated constants,
-- and hence they are not static.
if List.Next_Pop.ai_protocol = IPPROTO_TCP then
Item.Protocol := Proto_TCP;
elsif List.Next_Pop.ai_protocol = IPPROTO_UDP then
Item.Protocol := Proto_UDP;
elsif List.Next_Pop.ai_protocol = IPPROTO_SCTP then
Item.Protocol := Proto_SCTP;
else
-- Ignore unsupported protocols, since the use won't be
-- able to used them anyways..
Advance_List;
return;
end if;
if List.Next_Pop.ai_family = AF_INET6 then
Assert_Constraint (List.Next_Pop.ai_addrlen = IPv6_addrlen,
"List item address not the exepected size");
Item.Address := (Version => IPv6, others => <>);
extract6 (src => List.Next_Pop.ai_addr,
addr => Item.Address.v6_Address);
elsif List.Next_Pop.ai_family = AF_INET then
-- getaddrinfo often mkaes the underlying ai_addr large enough for an
-- IPv6 address, even if it holds an IPv4 address, so notice how the
-- check is slightly different
Assert_Constraint (List.Next_Pop.ai_addrlen = IPv4_addrlen,
"List item address not the exepected size");
Item.Address := (Version => IPv4, others => <>);
extract4 (src => List.Next_Pop.ai_addr,
addr => Item.Address.v4_Address);
else
-- Throw out this item first
Advance_List;
raise Constraint_Error with
"List item address family not recognized";
end if;
Advance_List;
end Pop;
----------------------------------------------------------------------
function Pop (List: in out IP_Lookup) return IP_Lookup_Entry is
begin
return Item: IP_Lookup_Entry do
List.Pop (Item);
end return;
end Pop;
-------------
-- Iterate --
-------------
procedure Iterate
(List : in out IP_Lookup;
Action: not null access procedure (Item: in IP_Lookup_Entry))
is
Item: IP_Lookup_Entry;
begin
while List.Next_Pop /= null loop
List.Pop (Item);
Action (Item);
end loop;
end Iterate;
--------------
-- Finalize --
--------------
procedure Finalize (List: in out IP_Lookup) is
procedure freeaddrinfo (ai: Entry_Pointer) with
Import => True, Convention => C, External_Name => "freeaddrinfo";
begin
if List.List_Head /= null then
freeaddrinfo (List.List_Head);
end if;
List.List_Head := null;
List.Next_Pop := null;
List.Canonname := Null_Chars_Ptr;
end Finalize;
end INET.IP.Lookup;
|
30,490
|
ada
| 0
|
Maxelweb/concurrency-sandbox
|
Resource_Control_Protocol/src/rcp-user.adb
|
with Ada.Text_IO;
with RCP.Control;
package body RCP.User is
task body User_T is
use Ada.Text_IO, RCP.Control;
-- all users will want the same type of item
-- but in different quantities
-- (note that the object components will take their default value
-- unless overridden by the instantiation)
My_Allocation : Resource_T :=
Resource_T'(Item => Extent, Granted => Request_T'First);
begin
loop
Put_Line (" " & Positive'Image (Id)
& " | "
& Request_T'Image (Demand)
& " | |");
--------------------------------------------------------
-- a user requests the allocation of "demand" resources
Controller.Demand (My_Allocation, Demand);
--------------------------------------------------------
Put_Line (" " & Positive'Image (Id)
& " | | "
& Request_T'Image (My_Allocation.Granted)
& " |");
--------------------------------------------------------
-- fakes some work once the request has been satisfied
delay Duration (Interval);
-- then returns all of the resources in its possession
Controller.Release (My_Allocation);
--------------------------------------------------------
Put_Line (" " & Positive'Image (Id)
& " | | | "
& Request_T'Image (My_Allocation.Granted));
-- and finally happily rests a little while after a job well done
delay Duration (Interval);
end loop;
end User_T;
end RCP.User;
|
30,491
|
ada
| 1
|
LaudateCorpus1/RosettaCodeData
|
Task/Range-extraction/Ada/range-extraction-1.ada
|
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
procedure Range_Extraction is
type Sequence is array (Positive range <>) of Integer;
function Image (S : Sequence) return String is
Result : Unbounded_String;
From : Integer;
procedure Flush (To : Integer) is
begin
if Length (Result) > 0 then
Append (Result, ',');
end if;
Append (Result, Trim (Integer'Image (From), Ada.Strings.Left));
if From < To then
if From+1 = To then
Append (Result, ',');
else
Append (Result, '-');
end if;
Append (Result, Trim (Integer'Image (To), Ada.Strings.Left));
end if;
end Flush;
begin
if S'Length > 0 then
From := S (S'First);
for I in S'First + 1..S'Last loop
if S (I - 1) + 1 /= S (I) then
Flush (S (I - 1));
From := S (I);
end if;
end loop;
Flush (S (S'Last));
end if;
return To_String (Result);
end Image;
begin
Put_Line
( Image
( ( 0, 1, 2, 4, 6, 7, 8, 11, 12, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 27, 28, 29, 30, 31, 32, 33, 35, 36,
37, 38, 39
) ) );
end Range_Extraction;
|
30,492
|
ada
| 1
|
LaudateCorpus1/RosettaCodeData
|
Task/Multiplicative-order/Ada/multiplicative-order-2.ada
|
package body Multiplicative_Order is
function Find_Order(Element, Modulus: Positive) return Positive is
function Power(Exp, Pow, M: Positive) return Positive is
-- computes Exp**Pow mod M;
-- note that Ada's native integer exponentiation "**" may overflow on
-- computing Exp**Pow before ever computing the "mod M" part
Result: Positive := 1;
E: Positive := Exp;
P: Natural := Pow;
begin
while P > 0 loop
if P mod 2 = 1 then
Result := (Result * E) mod M;
end if;
E := (E * E) mod M;
P := P / 2;
end loop;
return Result;
end Power;
begin -- Find_Order(Element, Modulus)
for I in 1 .. Modulus loop
if Power(Element, I, Modulus) = 1 then
return Positive(I);
end if;
end loop;
raise Program_Error with
Positive'Image(Element) &" is not coprime to" &Positive'Image(Modulus);
end Find_Order;
function Find_Order(Element: Positive;
Coprime_Factors: Positive_Array) return Positive is
function GCD (A, B : Positive) return Integer is
M : Natural := A;
N : Natural := B;
T : Natural;
begin
while N /= 0 loop
T := M;
M := N;
N ;:= T mod N;
end loop;
return M;
end GCD; -- from http://rosettacode.org/wiki/Least_common_multiple#Ada
function LCM (A, B : Natural) return Integer is
begin
if A = 0 or B = 0 then
return 0;
end if;
return abs (A * B) / Gcd (A, B);
end LCM; -- from http://rosettacode.org/wiki/Least_common_multiple#Ada
Result : Positive := 1;
begin -- Find_Order(Element, Coprime_Factors)
for I in Coprime_Factors'Range loop
Result := LCM(Result, Find_Order(Element, Coprime_Factors(I)));
end loop;
return Result;
end Find_Order;
end Multiplicative_Order;
|
30,493
|
ada
| 3
|
albinjal/ada_basic
|
Lab0/lab0.adb
|
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Float_Text_IO; use Ada.Float_Text_IO;
procedure Lab0 is
I: Integer;
F: Float;
C: Character;
S: String(1..5);
begin
Put("Skriv in ett heltal: "); Get(I);
Put("Du skrev in talet: "); Put(I,2);
New_Line(1);
Skip_Line;
Put("Skriv in fem heltal: "); Get(I); Get(C);
Put("Du skrev in talen: "); Put(I,2); Put(C); Get(I); Put(I,2); Put(C);
Get(I); Put(I,2); Put(C); Get(I); Put(I,2); Put(C); Get(I); Put(I,2);
New_Line(1);
Skip_Line;
Put("Skriv in ett flyttal: "); Get(F);
Put("Du skrev in flyttalet: "); Put(F,2,3,0);
New_Line(1);
Skip_Line;
Put("Skriv in ett heltal och ett flyttal: "); Get(I);
Put("Du skrev in heltalet: "); Put(I,9);
New_Line(1);
Put("Du skrev in flyttalet: "); Get(F); Put(F,3,4,0);
New_Line(1);
Skip_Line;
Put("Skriv in ett tecken: "); Get(C);
Put("Du skrev in tecknet: "); Put(C);
New_Line(1);
Skip_Line;
Put("Skriv in en sträng med 5 tecken: "); Get(S);
Put("Du skrev in strängen: "); Put(S);
New_Line(1);
Skip_Line;
Put("Skriv in en sträng med 3 tecken: ");
Get_Line(S,I);
Put("Du skrev in strängen: "); Put(S(1..3));
New_Line(1);
Put("Skriv in ett heltal och en sträng med 5 tecken: ");
Get(I);
Put("Du skrev in talet |"); Put(I,1); Put("| och strängen |");
Get(C);
Get_Line(S, I);
Put(S(1..5));
Put("|.");
New_Line(1);
Skip_Line;
Put("Skriv in en sträng med 3 tecken och ett flyttal: ");
Get(S(1..3));
Get(F);
Put("Du skrev in """); Put(F, 2, 3, 0); Put(""" och """); Put(S(1..3)); Put("""");
Skip_Line;
New_Line;
Put("Skriv in en sträng som är maximalt 5 tecken: "); Get_Line(S,I);
Put("Du skrev in strängen: ");
if I = 5 then
Put(S(1..5));
Skip_Line;
else
Put(S(1..I));
end if;
New_Line;
Put("Skriv in en sträng som är maximalt 5 tecken: "); Get_Line(S,I);
Put("Du skrev in strängen: ");
if I > 5 then
Put(S(1..5));
else
Put(S(1..I));
end if;
New_Line(1);
end Lab0;
|
30,494
|
ada
| 0
|
bkold/RISC-CPU-Assembler
|
Source/improved_trie.ads
|
with Ada.Containers.Multiway_Trees;
package Improved_Trie is
type Element_Type is record
A : Character;
B : Integer;
end record;
function "=" (Left, Right : Element_Type) return Boolean is
(Left.A = Right.A);
--the Ada Multiway tree package backend to be used
package Trie is new Ada.Containers.Multiway_Trees (Element_Type=>Element_Type, "="=>"=");
use Trie;
--searches the Trie for the input string.
--returns the associated integer, returns -1 if not found
function Find_String (T : Tree; Input : String) return Integer;
--adds the input string into the Trie
--returns whether it is successful or not
function Add_String (T : in out Tree; Input : String; Address : Integer) return Boolean;
private
--finds the child of a node
--returns the found child node, No_Element if not found
function Find_Immediate_Child (Parent : Cursor; Element : Element_Type) return Cursor;
--moves the input node to the found child node
--returns if found or not.
--if not found, Parent is not changed
function Find_Move_Immediate_Child (Parent : in out Cursor; Element : Element_Type) return Boolean;
end Improved_Trie;
|
30,495
|
ada
| 80
|
thindil/steamsky
|
tests/bases-test_data-tests-basecargo_container.ads
|
package Bases.Test_Data.Tests.BaseCargo_Container is
end Bases.Test_Data.Tests.BaseCargo_Container;
|
30,496
|
ada
| 7
|
best08618/asylo
|
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c8/c87b14b.ada
|
<gh_stars>1-10
-- C87B14B.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT OVERLOADING RESOLUTION USES THE RULE THAT:
--
-- IN SUBTYPE INDICATIONS WITH INDEX CONSTRAINTS, THE LOWER AND UPPER
-- BOUNDS MUST BE OF THE INDEX BASE TYPE.
--
-- TEST (B): INDEX CONSTRAINTS WITH OVERLOADED OPERATOR SYMBOLS.
-- TRH 30 JUNE 82
WITH REPORT; USE REPORT;
PROCEDURE C87B14B IS
SUBTYPE CHAR IS CHARACTER;
SUBTYPE VAR IS CHAR RANGE 'X' .. 'Z';
SUBTYPE NOTE IS CHAR RANGE 'A' .. 'G';
TYPE LIST IS ARRAY (CHAR RANGE <>) OF CHAR;
TYPE GRID IS ARRAY (CHAR RANGE <>, CHAR RANGE <>) OF CHAR;
FUNCTION "*" (X, Y : INTEGER) RETURN VAR IS
BEGIN
RETURN 'X';
END "*";
FUNCTION "*" (X, Y : INTEGER) RETURN BOOLEAN IS
BEGIN
FAILED ("RESOLUTION INCORRECT - INDEX CONSTRAINTS " &
" IN SUBTYPE INDICATIONS");
RETURN TRUE;
END "*";
FUNCTION "+" (X, Y : INTEGER) RETURN NOTE IS
BEGIN
RETURN 'A';
END "+";
FUNCTION "+" (X, Y : INTEGER) RETURN FLOAT IS
BEGIN
FAILED ("RESOLUTION INCORRECT - INDEX CONSTRAINTS " &
" IN SUBTYPE INDICATIONS");
RETURN 2.0;
END "+";
BEGIN
TEST ("C87B14B","OVERLOADED OPERATOR SYMBOLS IN INDEX " &
"CONSTRAINTS OF SUBTYPE INDICATIONS");
DECLARE
SUBTYPE LIST1 IS LIST ('W' .. "*" (0, 0));
SUBTYPE LIST2 IS LIST ("+" (0, 0) .. 'C');
SUBTYPE LIST3 IS LIST ("+" (0, 0) .. "*" (0, 0));
SUBTYPE LIST4 IS LIST ("*" (0, 0) .. "*" (0, 0));
SUBTYPE GRID1 IS GRID ('V' .. "*" (0, 0), "*" (0, 0) .. 'Y');
SUBTYPE GRID2 IS GRID ("*" (0, 0) .. 'W', 'H' .. "+" (0, 0));
SUBTYPE GRID3 IS GRID
("*" (0, 0) .. "*" (0, 0), "+" (0, 0) .. "+" (0, 0));
SUBTYPE GRID4 IS GRID ("+" (0, 0) .. "*" (0, 0),'L' .. 'N');
BEGIN
NULL;
END;
RESULT;
END C87B14B;
|
30,497
|
ada
| 80
|
thindil/steamsky
|
tests/game-test_data-tests-positive_container-test_data-tests.ads
|
<filename>tests/game-test_data-tests-positive_container-test_data-tests.ads
-- This package has been generated automatically by GNATtest.
-- Do not edit any part of it, see GNATtest documentation for more details.
-- begin read only
with Gnattest_Generated;
package Game.Test_Data.Tests.Positive_Container.Test_Data.Tests is
type Test is new GNATtest_Generated.GNATtest_Standard.Game.Test_Data.Tests
.Positive_Container
.Test_Data
.New_Test with
null record;
end Game.Test_Data.Tests.Positive_Container.Test_Data.Tests;
-- end read only
|
30,498
|
ada
| 52
|
onox/orka
|
orka/src/orka/implementation/orka-algorithms-prefix_sums.adb
|
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2018 onox <<EMAIL>>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with GL.Barriers;
with GL.Compute;
with GL.Types.Compute;
with Orka.Rendering.Programs.Modules;
package body Orka.Algorithms.Prefix_Sums is
function Create_Factory
(Location : Resources.Locations.Location_Ptr) return Factory
is
use Rendering.Programs;
begin
return
(Program_Prefix_Sum => Create_Program (Modules.Create_Module
(Location, CS => "algorithms/prefix-sum.comp")),
Program_Add => Create_Program (Modules.Create_Module
(Location, CS => "algorithms/prefix-sum-add.comp")));
end Create_Factory;
function Create_Prefix_Sum
(Object : Factory;
Length : Positive) return Prefix_Sum'Class
is
use Rendering.Buffers;
use all type Types.Numeric_Type;
Work_Group_Count : constant GL.Types.Compute.Dimension_Size_Array
:= GL.Compute.Max_Compute_Work_Group_Count;
Max_Group_Count : constant Natural := Natural (Work_Group_Count (X));
Work_Group_Size : constant GL.Types.Compute.Dimension_Size_Array
:= Object.Program_Prefix_Sum.Compute_Work_Group_Size;
-- Multiply by 4 because the shader processes 4 numbers per invocation
Local_Size : constant Natural := 4 * Natural (Work_Group_Size (X));
Padding : constant Boolean := Length rem Local_Size /= 0;
Work_Groups : constant Natural
:= Length / Local_Size + (if Padding then 1 else 0);
Sum_Padding : constant Boolean := Work_Groups rem Local_Size /= 0;
Sum_Work_Groups : constant Natural
:= Work_Groups / Local_Size + (if Sum_Padding then 1 else 0);
pragma Assert (Work_Groups <= Max_Group_Count);
pragma Assert (Sum_Work_Groups <= Max_Group_Count);
pragma Assert (Sum_Work_Groups <= Local_Size);
-- Support prefix sum of work group totals without recursion
begin
return
Prefix_Sum'(Programs => Object,
Length => Length,
Work_Groups => Work_Groups,
Sum_Work_Groups => Sum_Work_Groups,
-- Buffer_1 is the buffer given as a parameter to Compute_Prefix_Sum
-- and contains the initial/final values
Buffer_2 => Create_Buffer
(Flags => (others => False),
Kind => UInt_Type,
Length => Work_Groups),
Buffer_3 => Create_Buffer
(Flags => (others => False),
Kind => UInt_Type,
Length => Sum_Work_Groups),
Buffer_4 => Create_Buffer
(Flags => (others => False),
Kind => UInt_Type,
Length => 1));
end Create_Prefix_Sum;
procedure Compute_Prefix_Sum
(Object : in out Prefix_Sum;
Buffer : Rendering.Buffers.Buffer)
is
use GL.Types;
use all type Rendering.Buffers.Indexed_Buffer_Target;
procedure Compute_Sum
(Buffer_1, Buffer_2 : Rendering.Buffers.Buffer; Work_Groups : Natural) is
begin
Buffer_1.Bind (Shader_Storage, 0);
Buffer_2.Bind (Shader_Storage, 1);
GL.Barriers.Memory_Barrier ((Shader_Storage => True, others => False));
GL.Compute.Dispatch_Compute (X => UInt (Work_Groups));
end Compute_Sum;
procedure Add
(Buffer_1, Buffer_2 : Rendering.Buffers.Buffer; Work_Groups : Natural) is
begin
Buffer_1.Bind (Shader_Storage, 0);
Buffer_2.Bind (Shader_Storage, 1);
GL.Barriers.Memory_Barrier ((Shader_Storage => True, others => False));
GL.Compute.Dispatch_Compute (X => UInt (Work_Groups));
end Add;
begin
-- Phase 1a: Compute prefix sum
Object.Programs.Program_Prefix_Sum.Use_Program;
Compute_Sum (Buffer, Object.Buffer_2, Object.Work_Groups);
-- A prefix sum has been computed per work group. If we have multiple
-- groups, then we need to compute offsets and add them to the individual
-- prefix sums
if Object.Work_Groups > 1 then
-- Phase 2a: Apply prefix sum to buffer containing total of each work group
-- This will be an exclusive sum, so the first element will be set to zero
Compute_Sum (Object.Buffer_2, Object.Buffer_3, Object.Sum_Work_Groups);
if Object.Sum_Work_Groups > 1 then
-- Phase 3a
Compute_Sum (Object.Buffer_3, Object.Buffer_4, 1);
-- Buffer_4 is always unused because of the assumption that
-- Sum_Work_Groups <= Local_Size so that we only need one work group
-- (otherwise we would need to apply the algorithm to Buffer_4 as well)
-- Phase 3b: There is no phase 3b because there is only one work group
-- Phase 2b: Add offsets to the prefix sums of the totals
Object.Programs.Program_Add.Use_Program;
Add (Object.Buffer_2, Object.Buffer_3, Object.Work_Groups);
else
-- Buffer_3 is unused, we can directly use Buffer_2 for the
-- offsets (since it's an exclusive sum)
Object.Programs.Program_Add.Use_Program;
end if;
-- Phase 1b: Add offsets to the prefix sums
Add (Buffer, Object.Buffer_2, Object.Work_Groups);
else
-- Buffer_2 is unused, we can directly use Buffer as the final result
null;
end if;
end Compute_Prefix_Sum;
end Orka.Algorithms.Prefix_Sums;
|
30,499
|
ada
| 26
|
damaki/libkeccak
|
src/common/keccak-keccak_1600-rounds_14.ads
|
<reponame>damaki/libkeccak<filename>src/common/keccak-keccak_1600-rounds_14.ads<gh_stars>10-100
-------------------------------------------------------------------------------
-- Copyright (c) 2019, <NAME>
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
-- * Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * The name of the copyright holder may not be used to endorse or promote
-- Products derived from this software without specific prior written
-- permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
with Keccak.Generic_Duplex;
with Keccak.Generic_Sponge;
pragma Elaborate_All (Keccak.Generic_Duplex);
pragma Elaborate_All (Keccak.Generic_Sponge);
-- @summary
-- Instantiation of Keccak-p[1600,14], with a Sponge and Duplex built on top of it.
package Keccak.Keccak_1600.Rounds_14
with SPARK_Mode => On
is
procedure Permute is new KeccakF_1600_Permutation.Permute
(Num_Rounds => 14);
package Sponge is new Keccak.Generic_Sponge
(State_Size_Bits => KeccakF_1600.State_Size_Bits,
State_Type => State,
Init_State => KeccakF_1600.Init,
Permute => Permute,
XOR_Bits_Into_State => KeccakF_1600_Lanes.XOR_Bits_Into_State,
Extract_Data => KeccakF_1600_Lanes.Extract_Bytes,
Pad => Keccak.Padding.Pad101_Multi_Blocks);
package Duplex is new Keccak.Generic_Duplex
(State_Size_Bits => KeccakF_1600.State_Size_Bits,
State_Type => State,
Init_State => KeccakF_1600.Init,
Permute => Permute,
XOR_Bits_Into_State => KeccakF_1600_Lanes.XOR_Bits_Into_State,
Extract_Bits => KeccakF_1600_Lanes.Extract_Bits,
Pad => Keccak.Padding.Pad101_Single_Block,
Min_Padding_Bits => Keccak.Padding.Pad101_Min_Bits);
end Keccak.Keccak_1600.Rounds_14;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.