repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
riccardo-bernardini/eugen | Ada | 3,703 | adb | with Ada.Finalization; use Ada.Finalization;
package body EU_Projects.Nodes.Action_Nodes.Tasks is
------------
-- Create --
------------
function Create
(Label : Task_Label;
Name : String;
Short_Name : String;
Leader : Partners.Partner_Label;
Parent_WP : Node_Access;
Description : String;
Active_When : Action_Time;
Depends_On : Nodes.Node_Label_Lists.Vector;
Intensity : Task_Intensity;
Node_Dir : in out Node_Tables.Node_Table)
return Project_Task_Access
is
Result : Project_Task_Access;
begin
Result := new
Project_Task'(Controlled with
Label => Node_Label (Label),
Raw_Time => Active_When,
Class => Task_Node,
Name => To_Unbounded_String (Name),
Short_Name => Make_Short_Name (Short_Name, Name),
Index => No_Index,
Description => To_Unbounded_String (Description),
Attributes => Attribute_Maps.Empty_Map,
Parent => Parent_WP,
Leader => Leader,
Partner_Effort => Efforts.Effort_Maps.Empty_Map,
Depend_On => Depends_On,
Start_Symbolic => <>,
Stop_Symbolic => <>,
Duration_Symbolic => <>,
Start_At => <>,
Stop_At => <>,
Elapsed_Time => <>,
Intensity => Intensity,
Start_Fixed => False,
Stop_Fixed => False
);
Node_Dir.Insert (ID => Node_Label (Label),
Item => Node_Access (Result));
Result.Initialize_Efforts (Node_Dir);
return Result;
end Create;
function Value (X : String) return Task_Intensity
is
use Ada.Strings.Fixed;
use Ada.Strings;
function Basic_Value (S : String) return Float
is
Tmp : constant String := Trim (S, Both);
Dot : constant Natural := Index (S, ".");
begin
if Tmp'Length = 0 then
raise Constraint_Error;
end if;
if not (for all Idx in Tmp'Range => (Tmp (Idx) in '0' .. '9') or (Idx = Dot)) then
raise Constraint_Error;
end if;
if Dot = 0 then
return Float (Integer'Value (Tmp));
else
return Float'Value (Tmp);
end if;
end Basic_Value;
Pos : constant Natural := Index (Source => X,
Pattern => "%");
begin
if Pos = 0 then
return Basic_Value (X);
else
if not (for all Idx in Pos + 1 .. X'Last => X (Idx) = ' ') then
raise Constraint_Error;
end if;
return Basic_Value (X (X'First .. Pos - 1)) / 100.0;
end if;
end Value;
---------------
-- Set_Index --
---------------
procedure Set_Index (Tsk : in out Project_Task;
Idx : Task_Index)
is
begin
Tsk.Index := Node_Index (Idx);
end Set_Index;
--------------------
-- Add_Dependence --
--------------------
procedure Add_Dependence
(Item : in out Project_Task;
Dep : in Task_Label)
is
begin
Item.Depend_On.Append (Node_Label (Dep));
end Add_Dependence;
end EU_Projects.Nodes.Action_Nodes.Tasks;
|
reznikmm/matreshka | Ada | 3,969 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Draw_Stroke_Attributes;
package Matreshka.ODF_Draw.Stroke_Attributes is
type Draw_Stroke_Attribute_Node is
new Matreshka.ODF_Draw.Abstract_Draw_Attribute_Node
and ODF.DOM.Draw_Stroke_Attributes.ODF_Draw_Stroke_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Draw_Stroke_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Draw_Stroke_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Draw.Stroke_Attributes;
|
reznikmm/matreshka | Ada | 3,794 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Presentation_Background_Visible_Attributes is
pragma Preelaborate;
type ODF_Presentation_Background_Visible_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Presentation_Background_Visible_Attribute_Access is
access all ODF_Presentation_Background_Visible_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Presentation_Background_Visible_Attributes;
|
AdaCore/Ada_Drivers_Library | Ada | 4,073 | ads | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of 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. --
-- --
------------------------------------------------------------------------------
pragma Restrictions (No_Elaboration_Code);
package STM32.RCC is
-- type RCC_System_Clocks is record
-- SYSCLK : UInt32;
-- HCLK : UInt32;
-- PCLK1 : UInt32;
-- PCLK2 : UInt32;
-- TIMCLK1 : UInt32;
-- TIMCLK2 : UInt32;
-- end record;
--
-- function System_Clock_Frequencies return RCC_System_Clocks;
-- Part below is obsolete and should be moved to the corresponding driver.
procedure CRC_Clock_Enable with Inline;
procedure BKPSRAM_Clock_Enable with Inline;
-- procedure CCMDATARAMEN_Clock_Enable with Inline;
-- procedure DMA2D_Clock_Enable with Inline;
procedure WWDG_Clock_Enable with Inline;
-- procedure SDIO_Clock_Enable with Inline;
procedure SYSCFG_Clock_Enable with Inline;
procedure AHB1_Force_Reset with Inline;
procedure AHB1_Release_Reset with Inline;
procedure AHB2_Force_Reset with Inline;
procedure AHB2_Release_Reset with Inline;
procedure APB1_Force_Reset with Inline;
procedure APB1_Release_Reset with Inline;
procedure APB2_Force_Reset with Inline;
procedure APB2_Release_Reset with Inline;
procedure CRC_Force_Reset with Inline;
procedure CRC_Release_Reset with Inline;
-- procedure DMA2D_Force_Reset with Inline;
-- procedure DMA2D_Release_Reset with Inline;
procedure OTGFS_Force_Reset with Inline;
procedure OTGFS_Release_Reset with Inline;
procedure WWDG_Force_Reset with Inline;
procedure WWDG_Release_Reset with Inline;
-- procedure SDIO_Force_Reset with Inline;
-- procedure SDIO_Release_Reset with Inline;
procedure SYSCFG_Force_Reset with Inline;
procedure SYSCFG_Release_Reset with Inline;
end STM32.RCC;
|
osannolik/ada-canopen | Ada | 594 | ads | with Ada.Finalization;
with ACO.Messages;
with ACO.OD;
package ACO.Protocols is
type Protocol
(Od : not null access ACO.OD.Object_Dictionary'Class)
is abstract new Ada.Finalization.Limited_Controlled with private;
type Protocol_Access is access all Protocol'Class;
function Is_Valid
(This : in out Protocol;
Msg : in ACO.Messages.Message)
return Boolean is abstract;
private
type Protocol
(Od : not null access ACO.OD.Object_Dictionary'Class)
is abstract new Ada.Finalization.Limited_Controlled with null record;
end ACO.Protocols;
|
ZinebZaad/ENSEEIHT | Ada | 2,190 | ads | -- Spécification d'un module Dates très simplifié.
--
-- Attention : Bien gérer les dates est compliqué. Les dates et opérations
-- associées sont disponibles dans les bibliothèques des langages de
-- programmation. Par exemple dans le paquetage Ada.Calendar pour Ada.
package Dates is
type T_Mois is (JANVIER, FEVRIER, MARS, AVRIL, MAI, JUIN, JUILLET,
AOUT, SEPTEMBRE, OCTOBRE, NOVEMBRE, DECEMBRE);
type T_Date is private;
-- Initialiser une date à partir du jour, du mois et de l'année.
--
-- Paramètres :
-- Date : la date à initialiser
-- Jour : la valeur du jour
-- Mois : la valeur du mois
-- Annee : la valeur de l'année
--
-- Nécessite :
-- Jour/Mois/Annee constituent une date valide
--
-- Assure
-- Le_Jour (Date) = Jour
-- Le_Mois (Date) = Mois
-- L_Annee (Date) = Annee
--
procedure Initialiser ( Date : out T_Date ;
Jour : in Integer ;
Mois : in T_Mois ;
Annee : in Integer )
with
Pre => Annee >= 0 and Jour >= 1 and Jour <= 31, -- simplifiée !
Post => Le_Jour (Date) = Jour and Le_Mois (Date) = Mois and L_Annee (Date) = Annee;
-- Afficher une date sous la forme jj/mm/aaaa
procedure Afficher (Date : in T_Date);
-- Obtenir le mois d'une date.
-- Paramètres
-- Date : la date dont on veut obtenir le moi
function Le_Mois (Date : in T_Date) return T_Mois;
-- Obtenir le jour d'une date.
-- Paramètres
-- Date : la date dont on veut obtenir le jour
function Le_Jour (Date : in T_Date) return Integer;
-- Obtenir l'année d'une date.
-- Paramètres
-- Date : la date dont on veut obtenir l'année
function L_Annee (Date : in T_Date) return Integer;
private
type T_Date is
record
Jour : Integer;
Mois : T_Mois;
Annee : Integer;
-- Invariant
-- Annee > 0
-- Jour >= 1
-- Jour <= Nombre_Jours (Mois, Annee)
end record;
end Dates;
|
reznikmm/matreshka | Ada | 4,121 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.DOM.Presentation_Preset_Sub_Type_Attributes;
package Matreshka.ODF_Presentation.Preset_Sub_Type_Attributes is
type Presentation_Preset_Sub_Type_Attribute_Node is
new Matreshka.ODF_Presentation.Abstract_Presentation_Attribute_Node
and ODF.DOM.Presentation_Preset_Sub_Type_Attributes.ODF_Presentation_Preset_Sub_Type_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Presentation_Preset_Sub_Type_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Presentation_Preset_Sub_Type_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Presentation.Preset_Sub_Type_Attributes;
|
reznikmm/matreshka | Ada | 3,714 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Smil_KeySplines_Attributes is
pragma Preelaborate;
type ODF_Smil_KeySplines_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Smil_KeySplines_Attribute_Access is
access all ODF_Smil_KeySplines_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Smil_KeySplines_Attributes;
|
mmarx/lovelace | Ada | 6,524 | ads | with Interfaces.C; use Interfaces.C;
with x86_64_linux_gnu_bits_types_h;
with x86_64_linux_gnu_bits_time_h;
package x86_64_linux_gnu_bits_resource_h is
-- unsupported macro: RLIMIT_CPU RLIMIT_CPU
-- unsupported macro: RLIMIT_FSIZE RLIMIT_FSIZE
-- unsupported macro: RLIMIT_DATA RLIMIT_DATA
-- unsupported macro: RLIMIT_STACK RLIMIT_STACK
-- unsupported macro: RLIMIT_CORE RLIMIT_CORE
-- unsupported macro: RLIMIT_RSS __RLIMIT_RSS
-- unsupported macro: RLIMIT_NOFILE RLIMIT_NOFILE
-- unsupported macro: RLIMIT_OFILE __RLIMIT_OFILE
-- unsupported macro: RLIMIT_AS RLIMIT_AS
-- unsupported macro: RLIMIT_NPROC __RLIMIT_NPROC
-- unsupported macro: RLIMIT_MEMLOCK __RLIMIT_MEMLOCK
-- unsupported macro: RLIMIT_LOCKS __RLIMIT_LOCKS
-- unsupported macro: RLIMIT_SIGPENDING __RLIMIT_SIGPENDING
-- unsupported macro: RLIMIT_MSGQUEUE __RLIMIT_MSGQUEUE
-- unsupported macro: RLIMIT_NICE __RLIMIT_NICE
-- unsupported macro: RLIMIT_RTPRIO __RLIMIT_RTPRIO
-- unsupported macro: RLIMIT_RTTIME __RLIMIT_RTTIME
-- unsupported macro: RLIMIT_NLIMITS __RLIMIT_NLIMITS
-- unsupported macro: RLIM_NLIMITS __RLIM_NLIMITS
-- unsupported macro: RLIM_INFINITY ((unsigned long int)(~0UL))
-- unsupported macro: RLIM64_INFINITY 0xffffffffffffffffuLL
-- unsupported macro: RLIM_SAVED_MAX RLIM_INFINITY
-- unsupported macro: RLIM_SAVED_CUR RLIM_INFINITY
-- unsupported macro: RUSAGE_SELF RUSAGE_SELF
-- unsupported macro: RUSAGE_CHILDREN RUSAGE_CHILDREN
-- unsupported macro: RUSAGE_THREAD RUSAGE_THREAD
-- unsupported macro: RUSAGE_LWP RUSAGE_THREAD
-- unsupported macro: PRIO_MIN -20
-- unsupported macro: PRIO_MAX 20
-- unsupported macro: PRIO_PROCESS PRIO_PROCESS
-- unsupported macro: PRIO_PGRP PRIO_PGRP
-- unsupported macro: PRIO_USER PRIO_USER
subtype uu_rlimit_resource is unsigned;
RLIMIT_CPU : constant uu_rlimit_resource := 0;
RLIMIT_FSIZE : constant uu_rlimit_resource := 1;
RLIMIT_DATA : constant uu_rlimit_resource := 2;
RLIMIT_STACK : constant uu_rlimit_resource := 3;
RLIMIT_CORE : constant uu_rlimit_resource := 4;
uu_RLIMIT_RSS : constant uu_rlimit_resource := 5;
RLIMIT_NOFILE : constant uu_rlimit_resource := 7;
uu_RLIMIT_OFILE : constant uu_rlimit_resource := 7;
RLIMIT_AS : constant uu_rlimit_resource := 9;
uu_RLIMIT_NPROC : constant uu_rlimit_resource := 6;
uu_RLIMIT_MEMLOCK : constant uu_rlimit_resource := 8;
uu_RLIMIT_LOCKS : constant uu_rlimit_resource := 10;
uu_RLIMIT_SIGPENDING : constant uu_rlimit_resource := 11;
uu_RLIMIT_MSGQUEUE : constant uu_rlimit_resource := 12;
uu_RLIMIT_NICE : constant uu_rlimit_resource := 13;
uu_RLIMIT_RTPRIO : constant uu_rlimit_resource := 14;
uu_RLIMIT_RTTIME : constant uu_rlimit_resource := 15;
uu_RLIMIT_NLIMITS : constant uu_rlimit_resource := 16;
uu_RLIM_NLIMITS : constant uu_rlimit_resource := 16; -- /usr/include/x86_64-linux-gnu/bits/resource.h:33
subtype rlim_t is x86_64_linux_gnu_bits_types_h.uu_rlim_t; -- /usr/include/x86_64-linux-gnu/bits/resource.h:133
subtype rlim64_t is x86_64_linux_gnu_bits_types_h.uu_rlim64_t; -- /usr/include/x86_64-linux-gnu/bits/resource.h:138
type rlimit is record
rlim_cur : aliased rlim_t; -- /usr/include/x86_64-linux-gnu/bits/resource.h:144
rlim_max : aliased rlim_t; -- /usr/include/x86_64-linux-gnu/bits/resource.h:146
end record;
pragma Convention (C_Pass_By_Copy, rlimit); -- /usr/include/x86_64-linux-gnu/bits/resource.h:141
type rlimit64 is record
rlim_cur : aliased rlim64_t; -- /usr/include/x86_64-linux-gnu/bits/resource.h:153
rlim_max : aliased rlim64_t; -- /usr/include/x86_64-linux-gnu/bits/resource.h:155
end record;
pragma Convention (C_Pass_By_Copy, rlimit64); -- /usr/include/x86_64-linux-gnu/bits/resource.h:150
subtype uu_rusage_who is unsigned;
RUSAGE_SELF : constant uu_rusage_who := 0;
RUSAGE_CHILDREN : constant uu_rusage_who := -1;
RUSAGE_THREAD : constant uu_rusage_who := 1; -- /usr/include/x86_64-linux-gnu/bits/resource.h:160
type rusage is record
ru_utime : aliased x86_64_linux_gnu_bits_time_h.timeval; -- /usr/include/x86_64-linux-gnu/bits/resource.h:187
ru_stime : aliased x86_64_linux_gnu_bits_time_h.timeval; -- /usr/include/x86_64-linux-gnu/bits/resource.h:189
ru_maxrss : aliased long; -- /usr/include/x86_64-linux-gnu/bits/resource.h:191
ru_ixrss : aliased long; -- /usr/include/x86_64-linux-gnu/bits/resource.h:194
ru_idrss : aliased long; -- /usr/include/x86_64-linux-gnu/bits/resource.h:196
ru_isrss : aliased long; -- /usr/include/x86_64-linux-gnu/bits/resource.h:198
ru_minflt : aliased long; -- /usr/include/x86_64-linux-gnu/bits/resource.h:201
ru_majflt : aliased long; -- /usr/include/x86_64-linux-gnu/bits/resource.h:203
ru_nswap : aliased long; -- /usr/include/x86_64-linux-gnu/bits/resource.h:205
ru_inblock : aliased long; -- /usr/include/x86_64-linux-gnu/bits/resource.h:208
ru_oublock : aliased long; -- /usr/include/x86_64-linux-gnu/bits/resource.h:210
ru_msgsnd : aliased long; -- /usr/include/x86_64-linux-gnu/bits/resource.h:212
ru_msgrcv : aliased long; -- /usr/include/x86_64-linux-gnu/bits/resource.h:214
ru_nsignals : aliased long; -- /usr/include/x86_64-linux-gnu/bits/resource.h:216
ru_nvcsw : aliased long; -- /usr/include/x86_64-linux-gnu/bits/resource.h:220
ru_nivcsw : aliased long; -- /usr/include/x86_64-linux-gnu/bits/resource.h:223
end record;
pragma Convention (C_Pass_By_Copy, rusage); -- /usr/include/x86_64-linux-gnu/bits/resource.h:184
type uu_priority_which is
(PRIO_PROCESS,
PRIO_PGRP,
PRIO_USER);
pragma Convention (C, uu_priority_which); -- /usr/include/x86_64-linux-gnu/bits/resource.h:232
function prlimit
(uu_pid : x86_64_linux_gnu_bits_types_h.uu_pid_t;
uu_resource : uu_rlimit_resource;
uu_new_limit : access constant rlimit;
uu_old_limit : access rlimit) return int; -- /usr/include/x86_64-linux-gnu/bits/resource.h:248
pragma Import (C, prlimit, "prlimit");
function prlimit64
(uu_pid : x86_64_linux_gnu_bits_types_h.uu_pid_t;
uu_resource : uu_rlimit_resource;
uu_new_limit : access constant rlimit64;
uu_old_limit : access rlimit64) return int; -- /usr/include/x86_64-linux-gnu/bits/resource.h:262
pragma Import (C, prlimit64, "prlimit64");
end x86_64_linux_gnu_bits_resource_h;
|
AdaCore/libadalang | Ada | 301 | adb | procedure Test is
type A is tagged null record;
type B is new A with record
X : Integer;
end record;
function Foo return A is (null record);
Value : Natural;
begin
Value := (case B'(Foo with X => 2).X is
when others => 42);
pragma Test_Statement;
end Test;
|
annexi-strayline/AURA | Ada | 5,480 | adb | ------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- ANNEXI-STRAYLINE Reference Implementation --
-- --
-- Command Line Interface --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (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 Workers;
with Repositories;
with Registrar.Queries;
with Registrar.Subsystems;
package body Validation is
package VSD_Orders is
type Validate_Subsystem_Dependencies_Order is
new Workers.Work_Order with
record
Target: Registrar.Subsystems.Subsystem;
end record;
overriding function Image (Order: Validate_Subsystem_Dependencies_Order)
return String;
overriding procedure Execute
(Order: in out Validate_Subsystem_Dependencies_Order);
end VSD_Orders;
package body VSD_Orders is separate;
-------------------------------------
-- Validate_Subsystem_Dependencies --
-------------------------------------
procedure Validate_Subsystem_Dependencies is
use VSD_Orders;
use Repositories;
use Registrar.Subsystems;
Avail_Subsys: constant Subsystem_Sets.Set
:= Registrar.Queries.Available_Subsystems;
Order: Validate_Subsystem_Dependencies_Order;
begin
-- Note that if we get to validation, there should be no subsystems that
-- are not "Available"
-- Find all the subsystems we need to check now so that we can set the
-- tracker appropriately
for SS of Avail_Subsys loop
if Extract_Repository (SS.Source_Repository).Format = System then
Check_Subset.Insert (SS);
end if;
end loop;
if Check_Subset.Is_Empty then return; end if;
Validate_Subsystem_Dependencies_Progress.Increase_Total_Items_By
(Natural (Check_Subset.Length));
for SS of Check_Subset loop
Order.Target := SS;
Workers.Enqueue_Order (Order);
end loop;
-- Not much point in freeing Avail_Subsys if we get an exception, since
-- getting an exception here will definately end the program shortly
-- after
end Validate_Subsystem_Dependencies;
end Validation;
|
zrmyers/VulkanAda | Ada | 2,223 | adb | --------------------------------------------------------------------------------
-- MIT License
--
-- Copyright (c) 2021 Zane Myers
--
-- 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 Vulkan.Math.Mat2x2.Test;
with Vulkan.Math.Mat2x3.Test;
with Vulkan.Math.Mat2x4.Test;
with Vulkan.Math.Mat3x2.Test;
with Vulkan.Math.Mat3x3.Test;
with Vulkan.Math.Mat3x4.Test;
with Vulkan.Math.Mat4x2.Test;
with Vulkan.Math.Mat4x3.Test;
with Vulkan.Math.Mat4x4.Test;
use Vulkan.Math.Mat2x2.Test;
use Vulkan.Math.Mat2x3.Test;
use Vulkan.Math.Mat2x4.Test;
use Vulkan.Math.Mat3x2.Test;
use Vulkan.Math.Mat3x3.Test;
use Vulkan.Math.Mat3x4.Test;
use Vulkan.Math.Mat4x2.Test;
use Vulkan.Math.Mat4x3.Test;
use Vulkan.Math.Mat4x4.Test;
package body Vulkan.Math.Test_Mat is
-- Test Harness for single precision floating point matrices.
procedure Test_Mat is
begin
Test_Mat2x2;
Test_Mat2x3;
Test_Mat2x4;
Test_Mat3x2;
Test_Mat3x3;
Test_Mat3x4;
Test_Mat4x2;
Test_Mat4x3;
Test_Mat4x4;
end Test_Mat;
end Vulkan.Math.Test_Mat;
|
osannolik/ada-canopen | Ada | 1,706 | adb | with Ada.Unchecked_Conversion;
with ACO.Utils.Byte_Order;
package body ACO.Generic_Entry_Types is
use ACO.Utils.Byte_Order;
function Swap (X : Byte_Array) return Byte_Array is
(Byte_Array (Swap_Bus (Octets (X))))
with Inline;
function Read (This : Entry_Type) return Item_Type is
(This.Data);
function Read (This : Entry_Type) return Byte_Array is
(Swap (Convert (This.Data)));
function Data_Length (This : Entry_Type) return Natural is
(Item_Type'Size / 8);
procedure Write (This : in out Entry_Type;
Data : in Item_Type)
is
begin
This.Data := Data;
end Write;
procedure Write (This : in out Entry_Type;
Bytes : in Byte_Array)
is
begin
This.Data := Convert (Swap (Bytes));
end Write;
function Create
(Accessability : Access_Mode;
Data : Item_Type) return Entry_Type
is ((Accessability, Data));
function Convert (Data : Item_Type) return Byte_Array
is
Bytes : constant Byte_Array (0 .. Data'Size / 8 - 1);
for Bytes'Address use Data'Address;
pragma Import (Convention => Ada, Entity => Bytes);
begin
return Bytes;
end Convert;
function Convert (Bytes : Byte_Array) return Item_Type is
-- Might get alignment issues?
function To_Item is new Ada.Unchecked_Conversion
(Source => Byte_Array,
Target => Item_Type);
begin
return To_Item (Bytes);
end Convert;
function "=" (L : Entry_Type; R : Item_Type) return Boolean is
(L.Data = R);
function "=" (L : Item_Type; R : Entry_Type) return Boolean is
(L = R.Data);
end ACO.Generic_Entry_Types;
|
reznikmm/matreshka | Ada | 3,975 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- Components are direct children of 'description' element.
------------------------------------------------------------------------------
package WSDL.AST.Components is
pragma Preelaborate;
type Component_Node is abstract new Abstract_Node with record
Parent : WSDL.AST.Description_Access;
-- Parent description element.
Local_Name : League.Strings.Universal_String;
-- Name of the component.
end record;
not overriding function Name
(Self : not null access Component_Node) return Qualified_Name;
-- Returns value of {name} property of the component.
end WSDL.AST.Components;
|
reznikmm/matreshka | Ada | 4,991 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Internals.Utp_Elements;
with AMF.UML.Send_Object_Actions;
with AMF.Utp.Log_Actions;
with AMF.Visitors;
package AMF.Internals.Utp_Log_Actions is
type Utp_Log_Action_Proxy is
limited new AMF.Internals.Utp_Elements.Utp_Element_Proxy
and AMF.Utp.Log_Actions.Utp_Log_Action with null record;
overriding function Get_Base_Send_Object_Action
(Self : not null access constant Utp_Log_Action_Proxy)
return AMF.UML.Send_Object_Actions.UML_Send_Object_Action_Access;
-- Getter of LogAction::base_SendObjectAction.
--
overriding procedure Set_Base_Send_Object_Action
(Self : not null access Utp_Log_Action_Proxy;
To : AMF.UML.Send_Object_Actions.UML_Send_Object_Action_Access);
-- Setter of LogAction::base_SendObjectAction.
--
overriding procedure Enter_Element
(Self : not null access constant Utp_Log_Action_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
overriding procedure Leave_Element
(Self : not null access constant Utp_Log_Action_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
overriding procedure Visit_Element
(Self : not null access constant Utp_Log_Action_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
end AMF.Internals.Utp_Log_Actions;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 91,730 | ads | -- This spec has been automatically generated from STM32F411xx.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package STM32_SVD.USB_OTG_FS is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype FS_DCFG_DSPD_Field is STM32_SVD.UInt2;
subtype FS_DCFG_NZLSOHSK_Field is STM32_SVD.Bit;
subtype FS_DCFG_DAD_Field is STM32_SVD.UInt7;
subtype FS_DCFG_PFIVL_Field is STM32_SVD.UInt2;
-- OTG_FS device configuration register (OTG_FS_DCFG)
type FS_DCFG_Register is record
-- Device speed
DSPD : FS_DCFG_DSPD_Field := 16#0#;
-- Non-zero-length status OUT handshake
NZLSOHSK : FS_DCFG_NZLSOHSK_Field := 16#0#;
-- unspecified
Reserved_3_3 : STM32_SVD.Bit := 16#0#;
-- Device address
DAD : FS_DCFG_DAD_Field := 16#0#;
-- Periodic frame interval
PFIVL : FS_DCFG_PFIVL_Field := 16#0#;
-- unspecified
Reserved_13_31 : STM32_SVD.UInt19 := 16#1100#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_DCFG_Register use record
DSPD at 0 range 0 .. 1;
NZLSOHSK at 0 range 2 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
DAD at 0 range 4 .. 10;
PFIVL at 0 range 11 .. 12;
Reserved_13_31 at 0 range 13 .. 31;
end record;
subtype FS_DCTL_RWUSIG_Field is STM32_SVD.Bit;
subtype FS_DCTL_SDIS_Field is STM32_SVD.Bit;
subtype FS_DCTL_GINSTS_Field is STM32_SVD.Bit;
subtype FS_DCTL_GONSTS_Field is STM32_SVD.Bit;
subtype FS_DCTL_TCTL_Field is STM32_SVD.UInt3;
subtype FS_DCTL_SGINAK_Field is STM32_SVD.Bit;
subtype FS_DCTL_CGINAK_Field is STM32_SVD.Bit;
subtype FS_DCTL_SGONAK_Field is STM32_SVD.Bit;
subtype FS_DCTL_CGONAK_Field is STM32_SVD.Bit;
subtype FS_DCTL_POPRGDNE_Field is STM32_SVD.Bit;
-- OTG_FS device control register (OTG_FS_DCTL)
type FS_DCTL_Register is record
-- Remote wakeup signaling
RWUSIG : FS_DCTL_RWUSIG_Field := 16#0#;
-- Soft disconnect
SDIS : FS_DCTL_SDIS_Field := 16#0#;
-- Read-only. Global IN NAK status
GINSTS : FS_DCTL_GINSTS_Field := 16#0#;
-- Read-only. Global OUT NAK status
GONSTS : FS_DCTL_GONSTS_Field := 16#0#;
-- Test control
TCTL : FS_DCTL_TCTL_Field := 16#0#;
-- Set global IN NAK
SGINAK : FS_DCTL_SGINAK_Field := 16#0#;
-- Clear global IN NAK
CGINAK : FS_DCTL_CGINAK_Field := 16#0#;
-- Set global OUT NAK
SGONAK : FS_DCTL_SGONAK_Field := 16#0#;
-- Clear global OUT NAK
CGONAK : FS_DCTL_CGONAK_Field := 16#0#;
-- Power-on programming done
POPRGDNE : FS_DCTL_POPRGDNE_Field := 16#0#;
-- unspecified
Reserved_12_31 : STM32_SVD.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_DCTL_Register use record
RWUSIG at 0 range 0 .. 0;
SDIS at 0 range 1 .. 1;
GINSTS at 0 range 2 .. 2;
GONSTS at 0 range 3 .. 3;
TCTL at 0 range 4 .. 6;
SGINAK at 0 range 7 .. 7;
CGINAK at 0 range 8 .. 8;
SGONAK at 0 range 9 .. 9;
CGONAK at 0 range 10 .. 10;
POPRGDNE at 0 range 11 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype FS_DSTS_SUSPSTS_Field is STM32_SVD.Bit;
subtype FS_DSTS_ENUMSPD_Field is STM32_SVD.UInt2;
subtype FS_DSTS_EERR_Field is STM32_SVD.Bit;
subtype FS_DSTS_FNSOF_Field is STM32_SVD.UInt14;
-- OTG_FS device status register (OTG_FS_DSTS)
type FS_DSTS_Register is record
-- Read-only. Suspend status
SUSPSTS : FS_DSTS_SUSPSTS_Field;
-- Read-only. Enumerated speed
ENUMSPD : FS_DSTS_ENUMSPD_Field;
-- Read-only. Erratic error
EERR : FS_DSTS_EERR_Field;
-- unspecified
Reserved_4_7 : STM32_SVD.UInt4;
-- Read-only. Frame number of the received SOF
FNSOF : FS_DSTS_FNSOF_Field;
-- unspecified
Reserved_22_31 : STM32_SVD.UInt10;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_DSTS_Register use record
SUSPSTS at 0 range 0 .. 0;
ENUMSPD at 0 range 1 .. 2;
EERR at 0 range 3 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
FNSOF at 0 range 8 .. 21;
Reserved_22_31 at 0 range 22 .. 31;
end record;
subtype FS_DIEPMSK_XFRCM_Field is STM32_SVD.Bit;
subtype FS_DIEPMSK_EPDM_Field is STM32_SVD.Bit;
subtype FS_DIEPMSK_TOM_Field is STM32_SVD.Bit;
subtype FS_DIEPMSK_ITTXFEMSK_Field is STM32_SVD.Bit;
subtype FS_DIEPMSK_INEPNMM_Field is STM32_SVD.Bit;
subtype FS_DIEPMSK_INEPNEM_Field is STM32_SVD.Bit;
-- OTG_FS device IN endpoint common interrupt mask register
-- (OTG_FS_DIEPMSK)
type FS_DIEPMSK_Register is record
-- Transfer completed interrupt mask
XFRCM : FS_DIEPMSK_XFRCM_Field := 16#0#;
-- Endpoint disabled interrupt mask
EPDM : FS_DIEPMSK_EPDM_Field := 16#0#;
-- unspecified
Reserved_2_2 : STM32_SVD.Bit := 16#0#;
-- Timeout condition mask (Non-isochronous endpoints)
TOM : FS_DIEPMSK_TOM_Field := 16#0#;
-- IN token received when TxFIFO empty mask
ITTXFEMSK : FS_DIEPMSK_ITTXFEMSK_Field := 16#0#;
-- IN token received with EP mismatch mask
INEPNMM : FS_DIEPMSK_INEPNMM_Field := 16#0#;
-- IN endpoint NAK effective mask
INEPNEM : FS_DIEPMSK_INEPNEM_Field := 16#0#;
-- unspecified
Reserved_7_31 : STM32_SVD.UInt25 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_DIEPMSK_Register use record
XFRCM at 0 range 0 .. 0;
EPDM at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
TOM at 0 range 3 .. 3;
ITTXFEMSK at 0 range 4 .. 4;
INEPNMM at 0 range 5 .. 5;
INEPNEM at 0 range 6 .. 6;
Reserved_7_31 at 0 range 7 .. 31;
end record;
subtype FS_DOEPMSK_XFRCM_Field is STM32_SVD.Bit;
subtype FS_DOEPMSK_EPDM_Field is STM32_SVD.Bit;
subtype FS_DOEPMSK_STUPM_Field is STM32_SVD.Bit;
subtype FS_DOEPMSK_OTEPDM_Field is STM32_SVD.Bit;
-- OTG_FS device OUT endpoint common interrupt mask register
-- (OTG_FS_DOEPMSK)
type FS_DOEPMSK_Register is record
-- Transfer completed interrupt mask
XFRCM : FS_DOEPMSK_XFRCM_Field := 16#0#;
-- Endpoint disabled interrupt mask
EPDM : FS_DOEPMSK_EPDM_Field := 16#0#;
-- unspecified
Reserved_2_2 : STM32_SVD.Bit := 16#0#;
-- SETUP phase done mask
STUPM : FS_DOEPMSK_STUPM_Field := 16#0#;
-- OUT token received when endpoint disabled mask
OTEPDM : FS_DOEPMSK_OTEPDM_Field := 16#0#;
-- unspecified
Reserved_5_31 : STM32_SVD.UInt27 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_DOEPMSK_Register use record
XFRCM at 0 range 0 .. 0;
EPDM at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
STUPM at 0 range 3 .. 3;
OTEPDM at 0 range 4 .. 4;
Reserved_5_31 at 0 range 5 .. 31;
end record;
subtype FS_DAINT_IEPINT_Field is STM32_SVD.UInt16;
subtype FS_DAINT_OEPINT_Field is STM32_SVD.UInt16;
-- OTG_FS device all endpoints interrupt register (OTG_FS_DAINT)
type FS_DAINT_Register is record
-- Read-only. IN endpoint interrupt bits
IEPINT : FS_DAINT_IEPINT_Field;
-- Read-only. OUT endpoint interrupt bits
OEPINT : FS_DAINT_OEPINT_Field;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_DAINT_Register use record
IEPINT at 0 range 0 .. 15;
OEPINT at 0 range 16 .. 31;
end record;
subtype FS_DAINTMSK_IEPM_Field is STM32_SVD.UInt16;
subtype FS_DAINTMSK_OEPINT_Field is STM32_SVD.UInt16;
-- OTG_FS all endpoints interrupt mask register (OTG_FS_DAINTMSK)
type FS_DAINTMSK_Register is record
-- IN EP interrupt mask bits
IEPM : FS_DAINTMSK_IEPM_Field := 16#0#;
-- OUT endpoint interrupt bits
OEPINT : FS_DAINTMSK_OEPINT_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_DAINTMSK_Register use record
IEPM at 0 range 0 .. 15;
OEPINT at 0 range 16 .. 31;
end record;
subtype DVBUSDIS_VBUSDT_Field is STM32_SVD.UInt16;
-- OTG_FS device VBUS discharge time register
type DVBUSDIS_Register is record
-- Device VBUS discharge time
VBUSDT : DVBUSDIS_VBUSDT_Field := 16#17D7#;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DVBUSDIS_Register use record
VBUSDT at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype DVBUSPULSE_DVBUSP_Field is STM32_SVD.UInt12;
-- OTG_FS device VBUS pulsing time register
type DVBUSPULSE_Register is record
-- Device VBUS pulsing time
DVBUSP : DVBUSPULSE_DVBUSP_Field := 16#5B8#;
-- unspecified
Reserved_12_31 : STM32_SVD.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DVBUSPULSE_Register use record
DVBUSP at 0 range 0 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype DIEPEMPMSK_INEPTXFEM_Field is STM32_SVD.UInt16;
-- OTG_FS device IN endpoint FIFO empty interrupt mask register
type DIEPEMPMSK_Register is record
-- IN EP Tx FIFO empty interrupt mask bits
INEPTXFEM : DIEPEMPMSK_INEPTXFEM_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DIEPEMPMSK_Register use record
INEPTXFEM at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype FS_DIEPCTL0_MPSIZ_Field is STM32_SVD.UInt2;
subtype FS_DIEPCTL0_USBAEP_Field is STM32_SVD.Bit;
subtype FS_DIEPCTL0_NAKSTS_Field is STM32_SVD.Bit;
subtype FS_DIEPCTL0_EPTYP_Field is STM32_SVD.UInt2;
subtype FS_DIEPCTL0_STALL_Field is STM32_SVD.Bit;
subtype FS_DIEPCTL0_TXFNUM_Field is STM32_SVD.UInt4;
subtype FS_DIEPCTL0_CNAK_Field is STM32_SVD.Bit;
subtype FS_DIEPCTL0_SNAK_Field is STM32_SVD.Bit;
subtype FS_DIEPCTL0_EPDIS_Field is STM32_SVD.Bit;
subtype FS_DIEPCTL0_EPENA_Field is STM32_SVD.Bit;
-- OTG_FS device control IN endpoint 0 control register (OTG_FS_DIEPCTL0)
type FS_DIEPCTL0_Register is record
-- Maximum packet size
MPSIZ : FS_DIEPCTL0_MPSIZ_Field := 16#0#;
-- unspecified
Reserved_2_14 : STM32_SVD.UInt13 := 16#0#;
-- Read-only. USB active endpoint
USBAEP : FS_DIEPCTL0_USBAEP_Field := 16#0#;
-- unspecified
Reserved_16_16 : STM32_SVD.Bit := 16#0#;
-- Read-only. NAK status
NAKSTS : FS_DIEPCTL0_NAKSTS_Field := 16#0#;
-- Read-only. Endpoint type
EPTYP : FS_DIEPCTL0_EPTYP_Field := 16#0#;
-- unspecified
Reserved_20_20 : STM32_SVD.Bit := 16#0#;
-- STALL handshake
STALL : FS_DIEPCTL0_STALL_Field := 16#0#;
-- TxFIFO number
TXFNUM : FS_DIEPCTL0_TXFNUM_Field := 16#0#;
-- Write-only. Clear NAK
CNAK : FS_DIEPCTL0_CNAK_Field := 16#0#;
-- Write-only. Set NAK
SNAK : FS_DIEPCTL0_SNAK_Field := 16#0#;
-- unspecified
Reserved_28_29 : STM32_SVD.UInt2 := 16#0#;
-- Read-only. Endpoint disable
EPDIS : FS_DIEPCTL0_EPDIS_Field := 16#0#;
-- Read-only. Endpoint enable
EPENA : FS_DIEPCTL0_EPENA_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_DIEPCTL0_Register use record
MPSIZ at 0 range 0 .. 1;
Reserved_2_14 at 0 range 2 .. 14;
USBAEP at 0 range 15 .. 15;
Reserved_16_16 at 0 range 16 .. 16;
NAKSTS at 0 range 17 .. 17;
EPTYP at 0 range 18 .. 19;
Reserved_20_20 at 0 range 20 .. 20;
STALL at 0 range 21 .. 21;
TXFNUM at 0 range 22 .. 25;
CNAK at 0 range 26 .. 26;
SNAK at 0 range 27 .. 27;
Reserved_28_29 at 0 range 28 .. 29;
EPDIS at 0 range 30 .. 30;
EPENA at 0 range 31 .. 31;
end record;
subtype DIEPINT_XFRC_Field is STM32_SVD.Bit;
subtype DIEPINT_EPDISD_Field is STM32_SVD.Bit;
subtype DIEPINT_TOC_Field is STM32_SVD.Bit;
subtype DIEPINT_ITTXFE_Field is STM32_SVD.Bit;
subtype DIEPINT_INEPNE_Field is STM32_SVD.Bit;
subtype DIEPINT_TXFE_Field is STM32_SVD.Bit;
-- device endpoint-x interrupt register
type DIEPINT_Register is record
-- XFRC
XFRC : DIEPINT_XFRC_Field := 16#0#;
-- EPDISD
EPDISD : DIEPINT_EPDISD_Field := 16#0#;
-- unspecified
Reserved_2_2 : STM32_SVD.Bit := 16#0#;
-- TOC
TOC : DIEPINT_TOC_Field := 16#0#;
-- ITTXFE
ITTXFE : DIEPINT_ITTXFE_Field := 16#0#;
-- unspecified
Reserved_5_5 : STM32_SVD.Bit := 16#0#;
-- INEPNE
INEPNE : DIEPINT_INEPNE_Field := 16#0#;
-- Read-only. TXFE
TXFE : DIEPINT_TXFE_Field := 16#1#;
-- unspecified
Reserved_8_31 : STM32_SVD.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DIEPINT_Register use record
XFRC at 0 range 0 .. 0;
EPDISD at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
TOC at 0 range 3 .. 3;
ITTXFE at 0 range 4 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
INEPNE at 0 range 6 .. 6;
TXFE at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype DIEPTSIZ0_XFRSIZ_Field is STM32_SVD.UInt7;
subtype DIEPTSIZ0_PKTCNT_Field is STM32_SVD.UInt2;
-- device endpoint-0 transfer size register
type DIEPTSIZ0_Register is record
-- Transfer size
XFRSIZ : DIEPTSIZ0_XFRSIZ_Field := 16#0#;
-- unspecified
Reserved_7_18 : STM32_SVD.UInt12 := 16#0#;
-- Packet count
PKTCNT : DIEPTSIZ0_PKTCNT_Field := 16#0#;
-- unspecified
Reserved_21_31 : STM32_SVD.UInt11 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DIEPTSIZ0_Register use record
XFRSIZ at 0 range 0 .. 6;
Reserved_7_18 at 0 range 7 .. 18;
PKTCNT at 0 range 19 .. 20;
Reserved_21_31 at 0 range 21 .. 31;
end record;
subtype DTXFSTS_INEPTFSAV_Field is STM32_SVD.UInt16;
-- OTG_FS device IN endpoint transmit FIFO status register
type DTXFSTS_Register is record
-- Read-only. IN endpoint TxFIFO space available
INEPTFSAV : DTXFSTS_INEPTFSAV_Field;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DTXFSTS_Register use record
INEPTFSAV at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype DIEPCTL1_MPSIZ_Field is STM32_SVD.UInt11;
subtype DIEPCTL1_USBAEP_Field is STM32_SVD.Bit;
subtype DIEPCTL1_EONUM_DPID_Field is STM32_SVD.Bit;
subtype DIEPCTL1_NAKSTS_Field is STM32_SVD.Bit;
subtype DIEPCTL1_EPTYP_Field is STM32_SVD.UInt2;
subtype DIEPCTL1_Stall_Field is STM32_SVD.Bit;
subtype DIEPCTL1_TXFNUM_Field is STM32_SVD.UInt4;
subtype DIEPCTL1_CNAK_Field is STM32_SVD.Bit;
subtype DIEPCTL1_SNAK_Field is STM32_SVD.Bit;
subtype DIEPCTL1_SD0PID_SEVNFRM_Field is STM32_SVD.Bit;
subtype DIEPCTL1_SODDFRM_SD1PID_Field is STM32_SVD.Bit;
subtype DIEPCTL1_EPDIS_Field is STM32_SVD.Bit;
subtype DIEPCTL1_EPENA_Field is STM32_SVD.Bit;
-- OTG device endpoint-1 control register
type DIEPCTL1_Register is record
-- MPSIZ
MPSIZ : DIEPCTL1_MPSIZ_Field := 16#0#;
-- unspecified
Reserved_11_14 : STM32_SVD.UInt4 := 16#0#;
-- USBAEP
USBAEP : DIEPCTL1_USBAEP_Field := 16#0#;
-- Read-only. EONUM/DPID
EONUM_DPID : DIEPCTL1_EONUM_DPID_Field := 16#0#;
-- Read-only. NAKSTS
NAKSTS : DIEPCTL1_NAKSTS_Field := 16#0#;
-- EPTYP
EPTYP : DIEPCTL1_EPTYP_Field := 16#0#;
-- unspecified
Reserved_20_20 : STM32_SVD.Bit := 16#0#;
-- Stall
Stall : DIEPCTL1_Stall_Field := 16#0#;
-- TXFNUM
TXFNUM : DIEPCTL1_TXFNUM_Field := 16#0#;
-- Write-only. CNAK
CNAK : DIEPCTL1_CNAK_Field := 16#0#;
-- Write-only. SNAK
SNAK : DIEPCTL1_SNAK_Field := 16#0#;
-- Write-only. SD0PID/SEVNFRM
SD0PID_SEVNFRM : DIEPCTL1_SD0PID_SEVNFRM_Field := 16#0#;
-- Write-only. SODDFRM/SD1PID
SODDFRM_SD1PID : DIEPCTL1_SODDFRM_SD1PID_Field := 16#0#;
-- EPDIS
EPDIS : DIEPCTL1_EPDIS_Field := 16#0#;
-- EPENA
EPENA : DIEPCTL1_EPENA_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DIEPCTL1_Register use record
MPSIZ at 0 range 0 .. 10;
Reserved_11_14 at 0 range 11 .. 14;
USBAEP at 0 range 15 .. 15;
EONUM_DPID at 0 range 16 .. 16;
NAKSTS at 0 range 17 .. 17;
EPTYP at 0 range 18 .. 19;
Reserved_20_20 at 0 range 20 .. 20;
Stall at 0 range 21 .. 21;
TXFNUM at 0 range 22 .. 25;
CNAK at 0 range 26 .. 26;
SNAK at 0 range 27 .. 27;
SD0PID_SEVNFRM at 0 range 28 .. 28;
SODDFRM_SD1PID at 0 range 29 .. 29;
EPDIS at 0 range 30 .. 30;
EPENA at 0 range 31 .. 31;
end record;
subtype DIEPTSIZ_XFRSIZ_Field is STM32_SVD.UInt19;
subtype DIEPTSIZ_PKTCNT_Field is STM32_SVD.UInt10;
subtype DIEPTSIZ_MCNT_Field is STM32_SVD.UInt2;
-- device endpoint-1 transfer size register
type DIEPTSIZ_Register is record
-- Transfer size
XFRSIZ : DIEPTSIZ_XFRSIZ_Field := 16#0#;
-- Packet count
PKTCNT : DIEPTSIZ_PKTCNT_Field := 16#0#;
-- Multi count
MCNT : DIEPTSIZ_MCNT_Field := 16#0#;
-- unspecified
Reserved_31_31 : STM32_SVD.Bit := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DIEPTSIZ_Register use record
XFRSIZ at 0 range 0 .. 18;
PKTCNT at 0 range 19 .. 28;
MCNT at 0 range 29 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
subtype DIEPCTL_MPSIZ_Field is STM32_SVD.UInt11;
subtype DIEPCTL_USBAEP_Field is STM32_SVD.Bit;
subtype DIEPCTL_EONUM_DPID_Field is STM32_SVD.Bit;
subtype DIEPCTL_NAKSTS_Field is STM32_SVD.Bit;
subtype DIEPCTL_EPTYP_Field is STM32_SVD.UInt2;
subtype DIEPCTL_Stall_Field is STM32_SVD.Bit;
subtype DIEPCTL_TXFNUM_Field is STM32_SVD.UInt4;
subtype DIEPCTL_CNAK_Field is STM32_SVD.Bit;
subtype DIEPCTL_SNAK_Field is STM32_SVD.Bit;
subtype DIEPCTL_SD0PID_SEVNFRM_Field is STM32_SVD.Bit;
subtype DIEPCTL_SODDFRM_Field is STM32_SVD.Bit;
subtype DIEPCTL_EPDIS_Field is STM32_SVD.Bit;
subtype DIEPCTL_EPENA_Field is STM32_SVD.Bit;
-- OTG device endpoint-2 control register
type DIEPCTL_Register is record
-- MPSIZ
MPSIZ : DIEPCTL_MPSIZ_Field := 16#0#;
-- unspecified
Reserved_11_14 : STM32_SVD.UInt4 := 16#0#;
-- USBAEP
USBAEP : DIEPCTL_USBAEP_Field := 16#0#;
-- Read-only. EONUM/DPID
EONUM_DPID : DIEPCTL_EONUM_DPID_Field := 16#0#;
-- Read-only. NAKSTS
NAKSTS : DIEPCTL_NAKSTS_Field := 16#0#;
-- EPTYP
EPTYP : DIEPCTL_EPTYP_Field := 16#0#;
-- unspecified
Reserved_20_20 : STM32_SVD.Bit := 16#0#;
-- Stall
Stall : DIEPCTL_Stall_Field := 16#0#;
-- TXFNUM
TXFNUM : DIEPCTL_TXFNUM_Field := 16#0#;
-- Write-only. CNAK
CNAK : DIEPCTL_CNAK_Field := 16#0#;
-- Write-only. SNAK
SNAK : DIEPCTL_SNAK_Field := 16#0#;
-- Write-only. SD0PID/SEVNFRM
SD0PID_SEVNFRM : DIEPCTL_SD0PID_SEVNFRM_Field := 16#0#;
-- Write-only. SODDFRM
SODDFRM : DIEPCTL_SODDFRM_Field := 16#0#;
-- EPDIS
EPDIS : DIEPCTL_EPDIS_Field := 16#0#;
-- EPENA
EPENA : DIEPCTL_EPENA_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DIEPCTL_Register use record
MPSIZ at 0 range 0 .. 10;
Reserved_11_14 at 0 range 11 .. 14;
USBAEP at 0 range 15 .. 15;
EONUM_DPID at 0 range 16 .. 16;
NAKSTS at 0 range 17 .. 17;
EPTYP at 0 range 18 .. 19;
Reserved_20_20 at 0 range 20 .. 20;
Stall at 0 range 21 .. 21;
TXFNUM at 0 range 22 .. 25;
CNAK at 0 range 26 .. 26;
SNAK at 0 range 27 .. 27;
SD0PID_SEVNFRM at 0 range 28 .. 28;
SODDFRM at 0 range 29 .. 29;
EPDIS at 0 range 30 .. 30;
EPENA at 0 range 31 .. 31;
end record;
subtype DOEPCTL0_MPSIZ_Field is STM32_SVD.UInt2;
subtype DOEPCTL0_USBAEP_Field is STM32_SVD.Bit;
subtype DOEPCTL0_NAKSTS_Field is STM32_SVD.Bit;
subtype DOEPCTL0_EPTYP_Field is STM32_SVD.UInt2;
subtype DOEPCTL0_SNPM_Field is STM32_SVD.Bit;
subtype DOEPCTL0_Stall_Field is STM32_SVD.Bit;
subtype DOEPCTL0_CNAK_Field is STM32_SVD.Bit;
subtype DOEPCTL0_SNAK_Field is STM32_SVD.Bit;
subtype DOEPCTL0_EPDIS_Field is STM32_SVD.Bit;
subtype DOEPCTL0_EPENA_Field is STM32_SVD.Bit;
-- device endpoint-0 control register
type DOEPCTL0_Register is record
-- Read-only. MPSIZ
MPSIZ : DOEPCTL0_MPSIZ_Field := 16#0#;
-- unspecified
Reserved_2_14 : STM32_SVD.UInt13 := 16#0#;
-- Read-only. USBAEP
USBAEP : DOEPCTL0_USBAEP_Field := 16#1#;
-- unspecified
Reserved_16_16 : STM32_SVD.Bit := 16#0#;
-- Read-only. NAKSTS
NAKSTS : DOEPCTL0_NAKSTS_Field := 16#0#;
-- Read-only. EPTYP
EPTYP : DOEPCTL0_EPTYP_Field := 16#0#;
-- SNPM
SNPM : DOEPCTL0_SNPM_Field := 16#0#;
-- Stall
Stall : DOEPCTL0_Stall_Field := 16#0#;
-- unspecified
Reserved_22_25 : STM32_SVD.UInt4 := 16#0#;
-- Write-only. CNAK
CNAK : DOEPCTL0_CNAK_Field := 16#0#;
-- Write-only. SNAK
SNAK : DOEPCTL0_SNAK_Field := 16#0#;
-- unspecified
Reserved_28_29 : STM32_SVD.UInt2 := 16#0#;
-- Read-only. EPDIS
EPDIS : DOEPCTL0_EPDIS_Field := 16#0#;
-- Write-only. EPENA
EPENA : DOEPCTL0_EPENA_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DOEPCTL0_Register use record
MPSIZ at 0 range 0 .. 1;
Reserved_2_14 at 0 range 2 .. 14;
USBAEP at 0 range 15 .. 15;
Reserved_16_16 at 0 range 16 .. 16;
NAKSTS at 0 range 17 .. 17;
EPTYP at 0 range 18 .. 19;
SNPM at 0 range 20 .. 20;
Stall at 0 range 21 .. 21;
Reserved_22_25 at 0 range 22 .. 25;
CNAK at 0 range 26 .. 26;
SNAK at 0 range 27 .. 27;
Reserved_28_29 at 0 range 28 .. 29;
EPDIS at 0 range 30 .. 30;
EPENA at 0 range 31 .. 31;
end record;
subtype DOEPINT_XFRC_Field is STM32_SVD.Bit;
subtype DOEPINT_EPDISD_Field is STM32_SVD.Bit;
subtype DOEPINT_STUP_Field is STM32_SVD.Bit;
subtype DOEPINT_OTEPDIS_Field is STM32_SVD.Bit;
subtype DOEPINT_B2BSTUP_Field is STM32_SVD.Bit;
-- device endpoint-0 interrupt register
type DOEPINT_Register is record
-- XFRC
XFRC : DOEPINT_XFRC_Field := 16#0#;
-- EPDISD
EPDISD : DOEPINT_EPDISD_Field := 16#0#;
-- unspecified
Reserved_2_2 : STM32_SVD.Bit := 16#0#;
-- STUP
STUP : DOEPINT_STUP_Field := 16#0#;
-- OTEPDIS
OTEPDIS : DOEPINT_OTEPDIS_Field := 16#0#;
-- unspecified
Reserved_5_5 : STM32_SVD.Bit := 16#0#;
-- B2BSTUP
B2BSTUP : DOEPINT_B2BSTUP_Field := 16#0#;
-- unspecified
Reserved_7_31 : STM32_SVD.UInt25 := 16#1#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DOEPINT_Register use record
XFRC at 0 range 0 .. 0;
EPDISD at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
STUP at 0 range 3 .. 3;
OTEPDIS at 0 range 4 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
B2BSTUP at 0 range 6 .. 6;
Reserved_7_31 at 0 range 7 .. 31;
end record;
subtype DOEPTSIZ0_XFRSIZ_Field is STM32_SVD.UInt7;
subtype DOEPTSIZ0_PKTCNT_Field is STM32_SVD.Bit;
subtype DOEPTSIZ0_STUPCNT_Field is STM32_SVD.UInt2;
-- device OUT endpoint-0 transfer size register
type DOEPTSIZ0_Register is record
-- Transfer size
XFRSIZ : DOEPTSIZ0_XFRSIZ_Field := 16#0#;
-- unspecified
Reserved_7_18 : STM32_SVD.UInt12 := 16#0#;
-- Packet count
PKTCNT : DOEPTSIZ0_PKTCNT_Field := 16#0#;
-- unspecified
Reserved_20_28 : STM32_SVD.UInt9 := 16#0#;
-- SETUP packet count
STUPCNT : DOEPTSIZ0_STUPCNT_Field := 16#0#;
-- unspecified
Reserved_31_31 : STM32_SVD.Bit := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DOEPTSIZ0_Register use record
XFRSIZ at 0 range 0 .. 6;
Reserved_7_18 at 0 range 7 .. 18;
PKTCNT at 0 range 19 .. 19;
Reserved_20_28 at 0 range 20 .. 28;
STUPCNT at 0 range 29 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
subtype DOEPCTL_MPSIZ_Field is STM32_SVD.UInt11;
subtype DOEPCTL_USBAEP_Field is STM32_SVD.Bit;
subtype DOEPCTL_EONUM_DPID_Field is STM32_SVD.Bit;
subtype DOEPCTL_NAKSTS_Field is STM32_SVD.Bit;
subtype DOEPCTL_EPTYP_Field is STM32_SVD.UInt2;
subtype DOEPCTL_SNPM_Field is STM32_SVD.Bit;
subtype DOEPCTL_Stall_Field is STM32_SVD.Bit;
subtype DOEPCTL_CNAK_Field is STM32_SVD.Bit;
subtype DOEPCTL_SNAK_Field is STM32_SVD.Bit;
subtype DOEPCTL_SD0PID_SEVNFRM_Field is STM32_SVD.Bit;
subtype DOEPCTL_SODDFRM_Field is STM32_SVD.Bit;
subtype DOEPCTL_EPDIS_Field is STM32_SVD.Bit;
subtype DOEPCTL_EPENA_Field is STM32_SVD.Bit;
-- device endpoint-1 control register
type DOEPCTL_Register is record
-- MPSIZ
MPSIZ : DOEPCTL_MPSIZ_Field := 16#0#;
-- unspecified
Reserved_11_14 : STM32_SVD.UInt4 := 16#0#;
-- USBAEP
USBAEP : DOEPCTL_USBAEP_Field := 16#0#;
-- Read-only. EONUM/DPID
EONUM_DPID : DOEPCTL_EONUM_DPID_Field := 16#0#;
-- Read-only. NAKSTS
NAKSTS : DOEPCTL_NAKSTS_Field := 16#0#;
-- EPTYP
EPTYP : DOEPCTL_EPTYP_Field := 16#0#;
-- SNPM
SNPM : DOEPCTL_SNPM_Field := 16#0#;
-- Stall
Stall : DOEPCTL_Stall_Field := 16#0#;
-- unspecified
Reserved_22_25 : STM32_SVD.UInt4 := 16#0#;
-- Write-only. CNAK
CNAK : DOEPCTL_CNAK_Field := 16#0#;
-- Write-only. SNAK
SNAK : DOEPCTL_SNAK_Field := 16#0#;
-- Write-only. SD0PID/SEVNFRM
SD0PID_SEVNFRM : DOEPCTL_SD0PID_SEVNFRM_Field := 16#0#;
-- Write-only. SODDFRM
SODDFRM : DOEPCTL_SODDFRM_Field := 16#0#;
-- EPDIS
EPDIS : DOEPCTL_EPDIS_Field := 16#0#;
-- EPENA
EPENA : DOEPCTL_EPENA_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DOEPCTL_Register use record
MPSIZ at 0 range 0 .. 10;
Reserved_11_14 at 0 range 11 .. 14;
USBAEP at 0 range 15 .. 15;
EONUM_DPID at 0 range 16 .. 16;
NAKSTS at 0 range 17 .. 17;
EPTYP at 0 range 18 .. 19;
SNPM at 0 range 20 .. 20;
Stall at 0 range 21 .. 21;
Reserved_22_25 at 0 range 22 .. 25;
CNAK at 0 range 26 .. 26;
SNAK at 0 range 27 .. 27;
SD0PID_SEVNFRM at 0 range 28 .. 28;
SODDFRM at 0 range 29 .. 29;
EPDIS at 0 range 30 .. 30;
EPENA at 0 range 31 .. 31;
end record;
subtype DOEPTSIZ_XFRSIZ_Field is STM32_SVD.UInt19;
subtype DOEPTSIZ_PKTCNT_Field is STM32_SVD.UInt10;
subtype DOEPTSIZ_RXDPID_STUPCNT_Field is STM32_SVD.UInt2;
-- device OUT endpoint-1 transfer size register
type DOEPTSIZ_Register is record
-- Transfer size
XFRSIZ : DOEPTSIZ_XFRSIZ_Field := 16#0#;
-- Packet count
PKTCNT : DOEPTSIZ_PKTCNT_Field := 16#0#;
-- Received data PID/SETUP packet count
RXDPID_STUPCNT : DOEPTSIZ_RXDPID_STUPCNT_Field := 16#0#;
-- unspecified
Reserved_31_31 : STM32_SVD.Bit := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DOEPTSIZ_Register use record
XFRSIZ at 0 range 0 .. 18;
PKTCNT at 0 range 19 .. 28;
RXDPID_STUPCNT at 0 range 29 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
subtype FS_GOTGCTL_SRQSCS_Field is STM32_SVD.Bit;
subtype FS_GOTGCTL_SRQ_Field is STM32_SVD.Bit;
subtype FS_GOTGCTL_HNGSCS_Field is STM32_SVD.Bit;
subtype FS_GOTGCTL_HNPRQ_Field is STM32_SVD.Bit;
subtype FS_GOTGCTL_HSHNPEN_Field is STM32_SVD.Bit;
subtype FS_GOTGCTL_DHNPEN_Field is STM32_SVD.Bit;
subtype FS_GOTGCTL_CIDSTS_Field is STM32_SVD.Bit;
subtype FS_GOTGCTL_DBCT_Field is STM32_SVD.Bit;
subtype FS_GOTGCTL_ASVLD_Field is STM32_SVD.Bit;
subtype FS_GOTGCTL_BSVLD_Field is STM32_SVD.Bit;
-- OTG_FS control and status register (OTG_FS_GOTGCTL)
type FS_GOTGCTL_Register is record
-- Read-only. Session request success
SRQSCS : FS_GOTGCTL_SRQSCS_Field := 16#0#;
-- Session request
SRQ : FS_GOTGCTL_SRQ_Field := 16#0#;
-- unspecified
Reserved_2_7 : STM32_SVD.UInt6 := 16#0#;
-- Read-only. Host negotiation success
HNGSCS : FS_GOTGCTL_HNGSCS_Field := 16#0#;
-- HNP request
HNPRQ : FS_GOTGCTL_HNPRQ_Field := 16#0#;
-- Host set HNP enable
HSHNPEN : FS_GOTGCTL_HSHNPEN_Field := 16#0#;
-- Device HNP enabled
DHNPEN : FS_GOTGCTL_DHNPEN_Field := 16#1#;
-- unspecified
Reserved_12_15 : STM32_SVD.UInt4 := 16#0#;
-- Read-only. Connector ID status
CIDSTS : FS_GOTGCTL_CIDSTS_Field := 16#0#;
-- Read-only. Long/short debounce time
DBCT : FS_GOTGCTL_DBCT_Field := 16#0#;
-- Read-only. A-session valid
ASVLD : FS_GOTGCTL_ASVLD_Field := 16#0#;
-- Read-only. B-session valid
BSVLD : FS_GOTGCTL_BSVLD_Field := 16#0#;
-- unspecified
Reserved_20_31 : STM32_SVD.UInt12 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_GOTGCTL_Register use record
SRQSCS at 0 range 0 .. 0;
SRQ at 0 range 1 .. 1;
Reserved_2_7 at 0 range 2 .. 7;
HNGSCS at 0 range 8 .. 8;
HNPRQ at 0 range 9 .. 9;
HSHNPEN at 0 range 10 .. 10;
DHNPEN at 0 range 11 .. 11;
Reserved_12_15 at 0 range 12 .. 15;
CIDSTS at 0 range 16 .. 16;
DBCT at 0 range 17 .. 17;
ASVLD at 0 range 18 .. 18;
BSVLD at 0 range 19 .. 19;
Reserved_20_31 at 0 range 20 .. 31;
end record;
subtype FS_GOTGINT_SEDET_Field is STM32_SVD.Bit;
subtype FS_GOTGINT_SRSSCHG_Field is STM32_SVD.Bit;
subtype FS_GOTGINT_HNSSCHG_Field is STM32_SVD.Bit;
subtype FS_GOTGINT_HNGDET_Field is STM32_SVD.Bit;
subtype FS_GOTGINT_ADTOCHG_Field is STM32_SVD.Bit;
subtype FS_GOTGINT_DBCDNE_Field is STM32_SVD.Bit;
-- OTG_FS interrupt register (OTG_FS_GOTGINT)
type FS_GOTGINT_Register is record
-- unspecified
Reserved_0_1 : STM32_SVD.UInt2 := 16#0#;
-- Session end detected
SEDET : FS_GOTGINT_SEDET_Field := 16#0#;
-- unspecified
Reserved_3_7 : STM32_SVD.UInt5 := 16#0#;
-- Session request success status change
SRSSCHG : FS_GOTGINT_SRSSCHG_Field := 16#0#;
-- Host negotiation success status change
HNSSCHG : FS_GOTGINT_HNSSCHG_Field := 16#0#;
-- unspecified
Reserved_10_16 : STM32_SVD.UInt7 := 16#0#;
-- Host negotiation detected
HNGDET : FS_GOTGINT_HNGDET_Field := 16#0#;
-- A-device timeout change
ADTOCHG : FS_GOTGINT_ADTOCHG_Field := 16#0#;
-- Debounce done
DBCDNE : FS_GOTGINT_DBCDNE_Field := 16#0#;
-- unspecified
Reserved_20_31 : STM32_SVD.UInt12 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_GOTGINT_Register use record
Reserved_0_1 at 0 range 0 .. 1;
SEDET at 0 range 2 .. 2;
Reserved_3_7 at 0 range 3 .. 7;
SRSSCHG at 0 range 8 .. 8;
HNSSCHG at 0 range 9 .. 9;
Reserved_10_16 at 0 range 10 .. 16;
HNGDET at 0 range 17 .. 17;
ADTOCHG at 0 range 18 .. 18;
DBCDNE at 0 range 19 .. 19;
Reserved_20_31 at 0 range 20 .. 31;
end record;
subtype FS_GAHBCFG_GINT_Field is STM32_SVD.Bit;
subtype FS_GAHBCFG_TXFELVL_Field is STM32_SVD.Bit;
subtype FS_GAHBCFG_PTXFELVL_Field is STM32_SVD.Bit;
-- OTG_FS AHB configuration register (OTG_FS_GAHBCFG)
type FS_GAHBCFG_Register is record
-- Global interrupt mask
GINT : FS_GAHBCFG_GINT_Field := 16#0#;
-- unspecified
Reserved_1_6 : STM32_SVD.UInt6 := 16#0#;
-- TxFIFO empty level
TXFELVL : FS_GAHBCFG_TXFELVL_Field := 16#0#;
-- Periodic TxFIFO empty level
PTXFELVL : FS_GAHBCFG_PTXFELVL_Field := 16#0#;
-- unspecified
Reserved_9_31 : STM32_SVD.UInt23 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_GAHBCFG_Register use record
GINT at 0 range 0 .. 0;
Reserved_1_6 at 0 range 1 .. 6;
TXFELVL at 0 range 7 .. 7;
PTXFELVL at 0 range 8 .. 8;
Reserved_9_31 at 0 range 9 .. 31;
end record;
subtype FS_GUSBCFG_TOCAL_Field is STM32_SVD.UInt3;
subtype FS_GUSBCFG_PHYSEL_Field is STM32_SVD.Bit;
subtype FS_GUSBCFG_SRPCAP_Field is STM32_SVD.Bit;
subtype FS_GUSBCFG_HNPCAP_Field is STM32_SVD.Bit;
subtype FS_GUSBCFG_TRDT_Field is STM32_SVD.UInt4;
subtype FS_GUSBCFG_FHMOD_Field is STM32_SVD.Bit;
subtype FS_GUSBCFG_FDMOD_Field is STM32_SVD.Bit;
subtype FS_GUSBCFG_CTXPKT_Field is STM32_SVD.Bit;
-- OTG_FS USB configuration register (OTG_FS_GUSBCFG)
type FS_GUSBCFG_Register is record
-- FS timeout calibration
TOCAL : FS_GUSBCFG_TOCAL_Field := 16#0#;
-- unspecified
Reserved_3_5 : STM32_SVD.UInt3 := 16#0#;
-- Write-only. Full Speed serial transceiver select
PHYSEL : FS_GUSBCFG_PHYSEL_Field := 16#0#;
-- unspecified
Reserved_7_7 : STM32_SVD.Bit := 16#0#;
-- SRP-capable
SRPCAP : FS_GUSBCFG_SRPCAP_Field := 16#0#;
-- HNP-capable
HNPCAP : FS_GUSBCFG_HNPCAP_Field := 16#1#;
-- USB turnaround time
TRDT : FS_GUSBCFG_TRDT_Field := 16#2#;
-- unspecified
Reserved_14_28 : STM32_SVD.UInt15 := 16#0#;
-- Force host mode
FHMOD : FS_GUSBCFG_FHMOD_Field := 16#0#;
-- Force device mode
FDMOD : FS_GUSBCFG_FDMOD_Field := 16#0#;
-- Corrupt Tx packet
CTXPKT : FS_GUSBCFG_CTXPKT_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_GUSBCFG_Register use record
TOCAL at 0 range 0 .. 2;
Reserved_3_5 at 0 range 3 .. 5;
PHYSEL at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
SRPCAP at 0 range 8 .. 8;
HNPCAP at 0 range 9 .. 9;
TRDT at 0 range 10 .. 13;
Reserved_14_28 at 0 range 14 .. 28;
FHMOD at 0 range 29 .. 29;
FDMOD at 0 range 30 .. 30;
CTXPKT at 0 range 31 .. 31;
end record;
subtype FS_GRSTCTL_CSRST_Field is STM32_SVD.Bit;
subtype FS_GRSTCTL_HSRST_Field is STM32_SVD.Bit;
subtype FS_GRSTCTL_FCRST_Field is STM32_SVD.Bit;
subtype FS_GRSTCTL_RXFFLSH_Field is STM32_SVD.Bit;
subtype FS_GRSTCTL_TXFFLSH_Field is STM32_SVD.Bit;
subtype FS_GRSTCTL_TXFNUM_Field is STM32_SVD.UInt5;
subtype FS_GRSTCTL_AHBIDL_Field is STM32_SVD.Bit;
-- OTG_FS reset register (OTG_FS_GRSTCTL)
type FS_GRSTCTL_Register is record
-- Core soft reset
CSRST : FS_GRSTCTL_CSRST_Field := 16#0#;
-- HCLK soft reset
HSRST : FS_GRSTCTL_HSRST_Field := 16#0#;
-- Host frame counter reset
FCRST : FS_GRSTCTL_FCRST_Field := 16#0#;
-- unspecified
Reserved_3_3 : STM32_SVD.Bit := 16#0#;
-- RxFIFO flush
RXFFLSH : FS_GRSTCTL_RXFFLSH_Field := 16#0#;
-- TxFIFO flush
TXFFLSH : FS_GRSTCTL_TXFFLSH_Field := 16#0#;
-- TxFIFO number
TXFNUM : FS_GRSTCTL_TXFNUM_Field := 16#0#;
-- unspecified
Reserved_11_30 : STM32_SVD.UInt20 := 16#40000#;
-- Read-only. AHB master idle
AHBIDL : FS_GRSTCTL_AHBIDL_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_GRSTCTL_Register use record
CSRST at 0 range 0 .. 0;
HSRST at 0 range 1 .. 1;
FCRST at 0 range 2 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
RXFFLSH at 0 range 4 .. 4;
TXFFLSH at 0 range 5 .. 5;
TXFNUM at 0 range 6 .. 10;
Reserved_11_30 at 0 range 11 .. 30;
AHBIDL at 0 range 31 .. 31;
end record;
subtype FS_GINTSTS_CMOD_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_MMIS_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_OTGINT_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_SOF_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_RXFLVL_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_NPTXFE_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_GINAKEFF_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_GOUTNAKEFF_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_ESUSP_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_USBSUSP_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_USBRST_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_ENUMDNE_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_ISOODRP_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_EOPF_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_IEPINT_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_OEPINT_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_IISOIXFR_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_IPXFR_INCOMPISOOUT_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_HPRTINT_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_HCINT_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_PTXFE_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_CIDSCHG_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_DISCINT_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_SRQINT_Field is STM32_SVD.Bit;
subtype FS_GINTSTS_WKUPINT_Field is STM32_SVD.Bit;
-- OTG_FS core interrupt register (OTG_FS_GINTSTS)
type FS_GINTSTS_Register is record
-- Read-only. Current mode of operation
CMOD : FS_GINTSTS_CMOD_Field := 16#0#;
-- Mode mismatch interrupt
MMIS : FS_GINTSTS_MMIS_Field := 16#0#;
-- Read-only. OTG interrupt
OTGINT : FS_GINTSTS_OTGINT_Field := 16#0#;
-- Start of frame
SOF : FS_GINTSTS_SOF_Field := 16#0#;
-- Read-only. RxFIFO non-empty
RXFLVL : FS_GINTSTS_RXFLVL_Field := 16#0#;
-- Read-only. Non-periodic TxFIFO empty
NPTXFE : FS_GINTSTS_NPTXFE_Field := 16#1#;
-- Read-only. Global IN non-periodic NAK effective
GINAKEFF : FS_GINTSTS_GINAKEFF_Field := 16#0#;
-- Read-only. Global OUT NAK effective
GOUTNAKEFF : FS_GINTSTS_GOUTNAKEFF_Field := 16#0#;
-- unspecified
Reserved_8_9 : STM32_SVD.UInt2 := 16#0#;
-- Early suspend
ESUSP : FS_GINTSTS_ESUSP_Field := 16#0#;
-- USB suspend
USBSUSP : FS_GINTSTS_USBSUSP_Field := 16#0#;
-- USB reset
USBRST : FS_GINTSTS_USBRST_Field := 16#0#;
-- Enumeration done
ENUMDNE : FS_GINTSTS_ENUMDNE_Field := 16#0#;
-- Isochronous OUT packet dropped interrupt
ISOODRP : FS_GINTSTS_ISOODRP_Field := 16#0#;
-- End of periodic frame interrupt
EOPF : FS_GINTSTS_EOPF_Field := 16#0#;
-- unspecified
Reserved_16_17 : STM32_SVD.UInt2 := 16#0#;
-- Read-only. IN endpoint interrupt
IEPINT : FS_GINTSTS_IEPINT_Field := 16#0#;
-- Read-only. OUT endpoint interrupt
OEPINT : FS_GINTSTS_OEPINT_Field := 16#0#;
-- Incomplete isochronous IN transfer
IISOIXFR : FS_GINTSTS_IISOIXFR_Field := 16#0#;
-- Incomplete periodic transfer(Host mode)/Incomplete isochronous OUT
-- transfer(Device mode)
IPXFR_INCOMPISOOUT : FS_GINTSTS_IPXFR_INCOMPISOOUT_Field := 16#0#;
-- unspecified
Reserved_22_23 : STM32_SVD.UInt2 := 16#0#;
-- Read-only. Host port interrupt
HPRTINT : FS_GINTSTS_HPRTINT_Field := 16#0#;
-- Read-only. Host channels interrupt
HCINT : FS_GINTSTS_HCINT_Field := 16#0#;
-- Read-only. Periodic TxFIFO empty
PTXFE : FS_GINTSTS_PTXFE_Field := 16#1#;
-- unspecified
Reserved_27_27 : STM32_SVD.Bit := 16#0#;
-- Connector ID status change
CIDSCHG : FS_GINTSTS_CIDSCHG_Field := 16#0#;
-- Disconnect detected interrupt
DISCINT : FS_GINTSTS_DISCINT_Field := 16#0#;
-- Session request/new session detected interrupt
SRQINT : FS_GINTSTS_SRQINT_Field := 16#0#;
-- Resume/remote wakeup detected interrupt
WKUPINT : FS_GINTSTS_WKUPINT_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_GINTSTS_Register use record
CMOD at 0 range 0 .. 0;
MMIS at 0 range 1 .. 1;
OTGINT at 0 range 2 .. 2;
SOF at 0 range 3 .. 3;
RXFLVL at 0 range 4 .. 4;
NPTXFE at 0 range 5 .. 5;
GINAKEFF at 0 range 6 .. 6;
GOUTNAKEFF at 0 range 7 .. 7;
Reserved_8_9 at 0 range 8 .. 9;
ESUSP at 0 range 10 .. 10;
USBSUSP at 0 range 11 .. 11;
USBRST at 0 range 12 .. 12;
ENUMDNE at 0 range 13 .. 13;
ISOODRP at 0 range 14 .. 14;
EOPF at 0 range 15 .. 15;
Reserved_16_17 at 0 range 16 .. 17;
IEPINT at 0 range 18 .. 18;
OEPINT at 0 range 19 .. 19;
IISOIXFR at 0 range 20 .. 20;
IPXFR_INCOMPISOOUT at 0 range 21 .. 21;
Reserved_22_23 at 0 range 22 .. 23;
HPRTINT at 0 range 24 .. 24;
HCINT at 0 range 25 .. 25;
PTXFE at 0 range 26 .. 26;
Reserved_27_27 at 0 range 27 .. 27;
CIDSCHG at 0 range 28 .. 28;
DISCINT at 0 range 29 .. 29;
SRQINT at 0 range 30 .. 30;
WKUPINT at 0 range 31 .. 31;
end record;
subtype FS_GINTMSK_MMISM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_OTGINT_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_SOFM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_RXFLVLM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_NPTXFEM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_GINAKEFFM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_GONAKEFFM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_ESUSPM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_USBSUSPM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_USBRST_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_ENUMDNEM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_ISOODRPM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_EOPFM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_EPMISM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_IEPINT_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_OEPINT_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_IISOIXFRM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_IPXFRM_IISOOXFRM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_PRTIM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_HCIM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_PTXFEM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_CIDSCHGM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_DISCINT_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_SRQIM_Field is STM32_SVD.Bit;
subtype FS_GINTMSK_WUIM_Field is STM32_SVD.Bit;
-- OTG_FS interrupt mask register (OTG_FS_GINTMSK)
type FS_GINTMSK_Register is record
-- unspecified
Reserved_0_0 : STM32_SVD.Bit := 16#0#;
-- Mode mismatch interrupt mask
MMISM : FS_GINTMSK_MMISM_Field := 16#0#;
-- OTG interrupt mask
OTGINT : FS_GINTMSK_OTGINT_Field := 16#0#;
-- Start of frame mask
SOFM : FS_GINTMSK_SOFM_Field := 16#0#;
-- Receive FIFO non-empty mask
RXFLVLM : FS_GINTMSK_RXFLVLM_Field := 16#0#;
-- Non-periodic TxFIFO empty mask
NPTXFEM : FS_GINTMSK_NPTXFEM_Field := 16#0#;
-- Global non-periodic IN NAK effective mask
GINAKEFFM : FS_GINTMSK_GINAKEFFM_Field := 16#0#;
-- Global OUT NAK effective mask
GONAKEFFM : FS_GINTMSK_GONAKEFFM_Field := 16#0#;
-- unspecified
Reserved_8_9 : STM32_SVD.UInt2 := 16#0#;
-- Early suspend mask
ESUSPM : FS_GINTMSK_ESUSPM_Field := 16#0#;
-- USB suspend mask
USBSUSPM : FS_GINTMSK_USBSUSPM_Field := 16#0#;
-- USB reset mask
USBRST : FS_GINTMSK_USBRST_Field := 16#0#;
-- Enumeration done mask
ENUMDNEM : FS_GINTMSK_ENUMDNEM_Field := 16#0#;
-- Isochronous OUT packet dropped interrupt mask
ISOODRPM : FS_GINTMSK_ISOODRPM_Field := 16#0#;
-- End of periodic frame interrupt mask
EOPFM : FS_GINTMSK_EOPFM_Field := 16#0#;
-- unspecified
Reserved_16_16 : STM32_SVD.Bit := 16#0#;
-- Endpoint mismatch interrupt mask
EPMISM : FS_GINTMSK_EPMISM_Field := 16#0#;
-- IN endpoints interrupt mask
IEPINT : FS_GINTMSK_IEPINT_Field := 16#0#;
-- OUT endpoints interrupt mask
OEPINT : FS_GINTMSK_OEPINT_Field := 16#0#;
-- Incomplete isochronous IN transfer mask
IISOIXFRM : FS_GINTMSK_IISOIXFRM_Field := 16#0#;
-- Incomplete periodic transfer mask(Host mode)/Incomplete isochronous
-- OUT transfer mask(Device mode)
IPXFRM_IISOOXFRM : FS_GINTMSK_IPXFRM_IISOOXFRM_Field := 16#0#;
-- unspecified
Reserved_22_23 : STM32_SVD.UInt2 := 16#0#;
-- Read-only. Host port interrupt mask
PRTIM : FS_GINTMSK_PRTIM_Field := 16#0#;
-- Host channels interrupt mask
HCIM : FS_GINTMSK_HCIM_Field := 16#0#;
-- Periodic TxFIFO empty mask
PTXFEM : FS_GINTMSK_PTXFEM_Field := 16#0#;
-- unspecified
Reserved_27_27 : STM32_SVD.Bit := 16#0#;
-- Connector ID status change mask
CIDSCHGM : FS_GINTMSK_CIDSCHGM_Field := 16#0#;
-- Disconnect detected interrupt mask
DISCINT : FS_GINTMSK_DISCINT_Field := 16#0#;
-- Session request/new session detected interrupt mask
SRQIM : FS_GINTMSK_SRQIM_Field := 16#0#;
-- Resume/remote wakeup detected interrupt mask
WUIM : FS_GINTMSK_WUIM_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_GINTMSK_Register use record
Reserved_0_0 at 0 range 0 .. 0;
MMISM at 0 range 1 .. 1;
OTGINT at 0 range 2 .. 2;
SOFM at 0 range 3 .. 3;
RXFLVLM at 0 range 4 .. 4;
NPTXFEM at 0 range 5 .. 5;
GINAKEFFM at 0 range 6 .. 6;
GONAKEFFM at 0 range 7 .. 7;
Reserved_8_9 at 0 range 8 .. 9;
ESUSPM at 0 range 10 .. 10;
USBSUSPM at 0 range 11 .. 11;
USBRST at 0 range 12 .. 12;
ENUMDNEM at 0 range 13 .. 13;
ISOODRPM at 0 range 14 .. 14;
EOPFM at 0 range 15 .. 15;
Reserved_16_16 at 0 range 16 .. 16;
EPMISM at 0 range 17 .. 17;
IEPINT at 0 range 18 .. 18;
OEPINT at 0 range 19 .. 19;
IISOIXFRM at 0 range 20 .. 20;
IPXFRM_IISOOXFRM at 0 range 21 .. 21;
Reserved_22_23 at 0 range 22 .. 23;
PRTIM at 0 range 24 .. 24;
HCIM at 0 range 25 .. 25;
PTXFEM at 0 range 26 .. 26;
Reserved_27_27 at 0 range 27 .. 27;
CIDSCHGM at 0 range 28 .. 28;
DISCINT at 0 range 29 .. 29;
SRQIM at 0 range 30 .. 30;
WUIM at 0 range 31 .. 31;
end record;
subtype FS_GRXSTSR_Device_EPNUM_Field is STM32_SVD.UInt4;
subtype FS_GRXSTSR_Device_BCNT_Field is STM32_SVD.UInt11;
subtype FS_GRXSTSR_Device_DPID_Field is STM32_SVD.UInt2;
subtype FS_GRXSTSR_Device_PKTSTS_Field is STM32_SVD.UInt4;
subtype FS_GRXSTSR_Device_FRMNUM_Field is STM32_SVD.UInt4;
-- OTG_FS Receive status debug read(Device mode)
type FS_GRXSTSR_Device_Register is record
-- Read-only. Endpoint number
EPNUM : FS_GRXSTSR_Device_EPNUM_Field;
-- Read-only. Byte count
BCNT : FS_GRXSTSR_Device_BCNT_Field;
-- Read-only. Data PID
DPID : FS_GRXSTSR_Device_DPID_Field;
-- Read-only. Packet status
PKTSTS : FS_GRXSTSR_Device_PKTSTS_Field;
-- Read-only. Frame number
FRMNUM : FS_GRXSTSR_Device_FRMNUM_Field;
-- unspecified
Reserved_25_31 : STM32_SVD.UInt7;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_GRXSTSR_Device_Register use record
EPNUM at 0 range 0 .. 3;
BCNT at 0 range 4 .. 14;
DPID at 0 range 15 .. 16;
PKTSTS at 0 range 17 .. 20;
FRMNUM at 0 range 21 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
subtype FS_GRXSTSR_Host_EPNUM_Field is STM32_SVD.UInt4;
subtype FS_GRXSTSR_Host_BCNT_Field is STM32_SVD.UInt11;
subtype FS_GRXSTSR_Host_DPID_Field is STM32_SVD.UInt2;
subtype FS_GRXSTSR_Host_PKTSTS_Field is STM32_SVD.UInt4;
subtype FS_GRXSTSR_Host_FRMNUM_Field is STM32_SVD.UInt4;
-- OTG_FS Receive status debug read(Host mode)
type FS_GRXSTSR_Host_Register is record
-- Read-only. Endpoint number
EPNUM : FS_GRXSTSR_Host_EPNUM_Field;
-- Read-only. Byte count
BCNT : FS_GRXSTSR_Host_BCNT_Field;
-- Read-only. Data PID
DPID : FS_GRXSTSR_Host_DPID_Field;
-- Read-only. Packet status
PKTSTS : FS_GRXSTSR_Host_PKTSTS_Field;
-- Read-only. Frame number
FRMNUM : FS_GRXSTSR_Host_FRMNUM_Field;
-- unspecified
Reserved_25_31 : STM32_SVD.UInt7;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_GRXSTSR_Host_Register use record
EPNUM at 0 range 0 .. 3;
BCNT at 0 range 4 .. 14;
DPID at 0 range 15 .. 16;
PKTSTS at 0 range 17 .. 20;
FRMNUM at 0 range 21 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
subtype FS_GRXFSIZ_RXFD_Field is STM32_SVD.UInt16;
-- OTG_FS Receive FIFO size register (OTG_FS_GRXFSIZ)
type FS_GRXFSIZ_Register is record
-- RxFIFO depth
RXFD : FS_GRXFSIZ_RXFD_Field := 16#200#;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_GRXFSIZ_Register use record
RXFD at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype FS_GNPTXFSIZ_Device_TX0FSA_Field is STM32_SVD.UInt16;
subtype FS_GNPTXFSIZ_Device_TX0FD_Field is STM32_SVD.UInt16;
-- OTG_FS non-periodic transmit FIFO size register (Device mode)
type FS_GNPTXFSIZ_Device_Register is record
-- Endpoint 0 transmit RAM start address
TX0FSA : FS_GNPTXFSIZ_Device_TX0FSA_Field := 16#200#;
-- Endpoint 0 TxFIFO depth
TX0FD : FS_GNPTXFSIZ_Device_TX0FD_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_GNPTXFSIZ_Device_Register use record
TX0FSA at 0 range 0 .. 15;
TX0FD at 0 range 16 .. 31;
end record;
subtype FS_GNPTXFSIZ_Host_NPTXFSA_Field is STM32_SVD.UInt16;
subtype FS_GNPTXFSIZ_Host_NPTXFD_Field is STM32_SVD.UInt16;
-- OTG_FS non-periodic transmit FIFO size register (Host mode)
type FS_GNPTXFSIZ_Host_Register is record
-- Non-periodic transmit RAM start address
NPTXFSA : FS_GNPTXFSIZ_Host_NPTXFSA_Field := 16#200#;
-- Non-periodic TxFIFO depth
NPTXFD : FS_GNPTXFSIZ_Host_NPTXFD_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_GNPTXFSIZ_Host_Register use record
NPTXFSA at 0 range 0 .. 15;
NPTXFD at 0 range 16 .. 31;
end record;
subtype FS_GNPTXSTS_NPTXFSAV_Field is STM32_SVD.UInt16;
subtype FS_GNPTXSTS_NPTQXSAV_Field is STM32_SVD.Byte;
subtype FS_GNPTXSTS_NPTXQTOP_Field is STM32_SVD.UInt7;
-- OTG_FS non-periodic transmit FIFO/queue status register
-- (OTG_FS_GNPTXSTS)
type FS_GNPTXSTS_Register is record
-- Read-only. Non-periodic TxFIFO space available
NPTXFSAV : FS_GNPTXSTS_NPTXFSAV_Field;
-- Read-only. Non-periodic transmit request queue space available
NPTQXSAV : FS_GNPTXSTS_NPTQXSAV_Field;
-- Read-only. Top of the non-periodic transmit request queue
NPTXQTOP : FS_GNPTXSTS_NPTXQTOP_Field;
-- unspecified
Reserved_31_31 : STM32_SVD.Bit;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_GNPTXSTS_Register use record
NPTXFSAV at 0 range 0 .. 15;
NPTQXSAV at 0 range 16 .. 23;
NPTXQTOP at 0 range 24 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
subtype FS_GCCFG_PWRDWN_Field is STM32_SVD.Bit;
subtype FS_GCCFG_VBUSASEN_Field is STM32_SVD.Bit;
subtype FS_GCCFG_VBUSBSEN_Field is STM32_SVD.Bit;
subtype FS_GCCFG_SOFOUTEN_Field is STM32_SVD.Bit;
-- OTG_FS general core configuration register (OTG_FS_GCCFG)
type FS_GCCFG_Register is record
-- unspecified
Reserved_0_15 : STM32_SVD.UInt16 := 16#0#;
-- Power down
PWRDWN : FS_GCCFG_PWRDWN_Field := 16#0#;
-- unspecified
Reserved_17_17 : STM32_SVD.Bit := 16#0#;
-- Enable the VBUS sensing device
VBUSASEN : FS_GCCFG_VBUSASEN_Field := 16#0#;
-- Enable the VBUS sensing device
VBUSBSEN : FS_GCCFG_VBUSBSEN_Field := 16#0#;
-- SOF output enable
SOFOUTEN : FS_GCCFG_SOFOUTEN_Field := 16#0#;
-- unspecified
Reserved_21_31 : STM32_SVD.UInt11 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_GCCFG_Register use record
Reserved_0_15 at 0 range 0 .. 15;
PWRDWN at 0 range 16 .. 16;
Reserved_17_17 at 0 range 17 .. 17;
VBUSASEN at 0 range 18 .. 18;
VBUSBSEN at 0 range 19 .. 19;
SOFOUTEN at 0 range 20 .. 20;
Reserved_21_31 at 0 range 21 .. 31;
end record;
subtype FS_HPTXFSIZ_PTXSA_Field is STM32_SVD.UInt16;
subtype FS_HPTXFSIZ_PTXFSIZ_Field is STM32_SVD.UInt16;
-- OTG_FS Host periodic transmit FIFO size register (OTG_FS_HPTXFSIZ)
type FS_HPTXFSIZ_Register is record
-- Host periodic TxFIFO start address
PTXSA : FS_HPTXFSIZ_PTXSA_Field := 16#600#;
-- Host periodic TxFIFO depth
PTXFSIZ : FS_HPTXFSIZ_PTXFSIZ_Field := 16#200#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_HPTXFSIZ_Register use record
PTXSA at 0 range 0 .. 15;
PTXFSIZ at 0 range 16 .. 31;
end record;
subtype FS_DIEPTXF_INEPTXSA_Field is STM32_SVD.UInt16;
subtype FS_DIEPTXF_INEPTXFD_Field is STM32_SVD.UInt16;
-- OTG_FS device IN endpoint transmit FIFO size register (OTG_FS_DIEPTXF2)
type FS_DIEPTXF_Register is record
-- IN endpoint FIFO2 transmit RAM start address
INEPTXSA : FS_DIEPTXF_INEPTXSA_Field := 16#400#;
-- IN endpoint TxFIFO depth
INEPTXFD : FS_DIEPTXF_INEPTXFD_Field := 16#200#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_DIEPTXF_Register use record
INEPTXSA at 0 range 0 .. 15;
INEPTXFD at 0 range 16 .. 31;
end record;
subtype FS_HCFG_FSLSPCS_Field is STM32_SVD.UInt2;
subtype FS_HCFG_FSLSS_Field is STM32_SVD.Bit;
-- OTG_FS host configuration register (OTG_FS_HCFG)
type FS_HCFG_Register is record
-- FS/LS PHY clock select
FSLSPCS : FS_HCFG_FSLSPCS_Field := 16#0#;
-- Read-only. FS- and LS-only support
FSLSS : FS_HCFG_FSLSS_Field := 16#0#;
-- unspecified
Reserved_3_31 : STM32_SVD.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_HCFG_Register use record
FSLSPCS at 0 range 0 .. 1;
FSLSS at 0 range 2 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
subtype HFIR_FRIVL_Field is STM32_SVD.UInt16;
-- OTG_FS Host frame interval register
type HFIR_Register is record
-- Frame interval
FRIVL : HFIR_FRIVL_Field := 16#EA60#;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for HFIR_Register use record
FRIVL at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype FS_HFNUM_FRNUM_Field is STM32_SVD.UInt16;
subtype FS_HFNUM_FTREM_Field is STM32_SVD.UInt16;
-- OTG_FS host frame number/frame time remaining register (OTG_FS_HFNUM)
type FS_HFNUM_Register is record
-- Read-only. Frame number
FRNUM : FS_HFNUM_FRNUM_Field;
-- Read-only. Frame time remaining
FTREM : FS_HFNUM_FTREM_Field;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_HFNUM_Register use record
FRNUM at 0 range 0 .. 15;
FTREM at 0 range 16 .. 31;
end record;
subtype FS_HPTXSTS_PTXFSAVL_Field is STM32_SVD.UInt16;
subtype FS_HPTXSTS_PTXQSAV_Field is STM32_SVD.Byte;
subtype FS_HPTXSTS_PTXQTOP_Field is STM32_SVD.Byte;
-- OTG_FS_Host periodic transmit FIFO/queue status register
-- (OTG_FS_HPTXSTS)
type FS_HPTXSTS_Register is record
-- Periodic transmit data FIFO space available
PTXFSAVL : FS_HPTXSTS_PTXFSAVL_Field := 16#100#;
-- Read-only. Periodic transmit request queue space available
PTXQSAV : FS_HPTXSTS_PTXQSAV_Field := 16#8#;
-- Read-only. Top of the periodic transmit request queue
PTXQTOP : FS_HPTXSTS_PTXQTOP_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_HPTXSTS_Register use record
PTXFSAVL at 0 range 0 .. 15;
PTXQSAV at 0 range 16 .. 23;
PTXQTOP at 0 range 24 .. 31;
end record;
subtype HAINT_HAINT_Field is STM32_SVD.UInt16;
-- OTG_FS Host all channels interrupt register
type HAINT_Register is record
-- Read-only. Channel interrupts
HAINT : HAINT_HAINT_Field;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for HAINT_Register use record
HAINT at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype HAINTMSK_HAINTM_Field is STM32_SVD.UInt16;
-- OTG_FS host all channels interrupt mask register
type HAINTMSK_Register is record
-- Channel interrupt mask
HAINTM : HAINTMSK_HAINTM_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for HAINTMSK_Register use record
HAINTM at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype FS_HPRT_PCSTS_Field is STM32_SVD.Bit;
subtype FS_HPRT_PCDET_Field is STM32_SVD.Bit;
subtype FS_HPRT_PENA_Field is STM32_SVD.Bit;
subtype FS_HPRT_PENCHNG_Field is STM32_SVD.Bit;
subtype FS_HPRT_POCA_Field is STM32_SVD.Bit;
subtype FS_HPRT_POCCHNG_Field is STM32_SVD.Bit;
subtype FS_HPRT_PRES_Field is STM32_SVD.Bit;
subtype FS_HPRT_PSUSP_Field is STM32_SVD.Bit;
subtype FS_HPRT_PRST_Field is STM32_SVD.Bit;
subtype FS_HPRT_PLSTS_Field is STM32_SVD.UInt2;
subtype FS_HPRT_PPWR_Field is STM32_SVD.Bit;
subtype FS_HPRT_PTCTL_Field is STM32_SVD.UInt4;
subtype FS_HPRT_PSPD_Field is STM32_SVD.UInt2;
-- OTG_FS host port control and status register (OTG_FS_HPRT)
type FS_HPRT_Register is record
-- Read-only. Port connect status
PCSTS : FS_HPRT_PCSTS_Field := 16#0#;
-- Port connect detected
PCDET : FS_HPRT_PCDET_Field := 16#0#;
-- Port enable
PENA : FS_HPRT_PENA_Field := 16#0#;
-- Port enable/disable change
PENCHNG : FS_HPRT_PENCHNG_Field := 16#0#;
-- Read-only. Port overcurrent active
POCA : FS_HPRT_POCA_Field := 16#0#;
-- Port overcurrent change
POCCHNG : FS_HPRT_POCCHNG_Field := 16#0#;
-- Port resume
PRES : FS_HPRT_PRES_Field := 16#0#;
-- Port suspend
PSUSP : FS_HPRT_PSUSP_Field := 16#0#;
-- Port reset
PRST : FS_HPRT_PRST_Field := 16#0#;
-- unspecified
Reserved_9_9 : STM32_SVD.Bit := 16#0#;
-- Read-only. Port line status
PLSTS : FS_HPRT_PLSTS_Field := 16#0#;
-- Port power
PPWR : FS_HPRT_PPWR_Field := 16#0#;
-- Port test control
PTCTL : FS_HPRT_PTCTL_Field := 16#0#;
-- Read-only. Port speed
PSPD : FS_HPRT_PSPD_Field := 16#0#;
-- unspecified
Reserved_19_31 : STM32_SVD.UInt13 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_HPRT_Register use record
PCSTS at 0 range 0 .. 0;
PCDET at 0 range 1 .. 1;
PENA at 0 range 2 .. 2;
PENCHNG at 0 range 3 .. 3;
POCA at 0 range 4 .. 4;
POCCHNG at 0 range 5 .. 5;
PRES at 0 range 6 .. 6;
PSUSP at 0 range 7 .. 7;
PRST at 0 range 8 .. 8;
Reserved_9_9 at 0 range 9 .. 9;
PLSTS at 0 range 10 .. 11;
PPWR at 0 range 12 .. 12;
PTCTL at 0 range 13 .. 16;
PSPD at 0 range 17 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
subtype FS_HCCHAR_MPSIZ_Field is STM32_SVD.UInt11;
subtype FS_HCCHAR_EPNUM_Field is STM32_SVD.UInt4;
subtype FS_HCCHAR_EPDIR_Field is STM32_SVD.Bit;
subtype FS_HCCHAR_LSDEV_Field is STM32_SVD.Bit;
subtype FS_HCCHAR_EPTYP_Field is STM32_SVD.UInt2;
subtype FS_HCCHAR_MCNT_Field is STM32_SVD.UInt2;
subtype FS_HCCHAR_DAD_Field is STM32_SVD.UInt7;
subtype FS_HCCHAR_ODDFRM_Field is STM32_SVD.Bit;
subtype FS_HCCHAR_CHDIS_Field is STM32_SVD.Bit;
subtype FS_HCCHAR_CHENA_Field is STM32_SVD.Bit;
-- OTG_FS host channel-0 characteristics register (OTG_FS_HCCHAR0)
type FS_HCCHAR_Register is record
-- Maximum packet size
MPSIZ : FS_HCCHAR_MPSIZ_Field := 16#0#;
-- Endpoint number
EPNUM : FS_HCCHAR_EPNUM_Field := 16#0#;
-- Endpoint direction
EPDIR : FS_HCCHAR_EPDIR_Field := 16#0#;
-- unspecified
Reserved_16_16 : STM32_SVD.Bit := 16#0#;
-- Low-speed device
LSDEV : FS_HCCHAR_LSDEV_Field := 16#0#;
-- Endpoint type
EPTYP : FS_HCCHAR_EPTYP_Field := 16#0#;
-- Multicount
MCNT : FS_HCCHAR_MCNT_Field := 16#0#;
-- Device address
DAD : FS_HCCHAR_DAD_Field := 16#0#;
-- Odd frame
ODDFRM : FS_HCCHAR_ODDFRM_Field := 16#0#;
-- Channel disable
CHDIS : FS_HCCHAR_CHDIS_Field := 16#0#;
-- Channel enable
CHENA : FS_HCCHAR_CHENA_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_HCCHAR_Register use record
MPSIZ at 0 range 0 .. 10;
EPNUM at 0 range 11 .. 14;
EPDIR at 0 range 15 .. 15;
Reserved_16_16 at 0 range 16 .. 16;
LSDEV at 0 range 17 .. 17;
EPTYP at 0 range 18 .. 19;
MCNT at 0 range 20 .. 21;
DAD at 0 range 22 .. 28;
ODDFRM at 0 range 29 .. 29;
CHDIS at 0 range 30 .. 30;
CHENA at 0 range 31 .. 31;
end record;
subtype FS_HCINT_XFRC_Field is STM32_SVD.Bit;
subtype FS_HCINT_CHH_Field is STM32_SVD.Bit;
subtype FS_HCINT_STALL_Field is STM32_SVD.Bit;
subtype FS_HCINT_NAK_Field is STM32_SVD.Bit;
subtype FS_HCINT_ACK_Field is STM32_SVD.Bit;
subtype FS_HCINT_TXERR_Field is STM32_SVD.Bit;
subtype FS_HCINT_BBERR_Field is STM32_SVD.Bit;
subtype FS_HCINT_FRMOR_Field is STM32_SVD.Bit;
subtype FS_HCINT_DTERR_Field is STM32_SVD.Bit;
-- OTG_FS host channel-0 interrupt register (OTG_FS_HCINT0)
type FS_HCINT_Register is record
-- Transfer completed
XFRC : FS_HCINT_XFRC_Field := 16#0#;
-- Channel halted
CHH : FS_HCINT_CHH_Field := 16#0#;
-- unspecified
Reserved_2_2 : STM32_SVD.Bit := 16#0#;
-- STALL response received interrupt
STALL : FS_HCINT_STALL_Field := 16#0#;
-- NAK response received interrupt
NAK : FS_HCINT_NAK_Field := 16#0#;
-- ACK response received/transmitted interrupt
ACK : FS_HCINT_ACK_Field := 16#0#;
-- unspecified
Reserved_6_6 : STM32_SVD.Bit := 16#0#;
-- Transaction error
TXERR : FS_HCINT_TXERR_Field := 16#0#;
-- Babble error
BBERR : FS_HCINT_BBERR_Field := 16#0#;
-- Frame overrun
FRMOR : FS_HCINT_FRMOR_Field := 16#0#;
-- Data toggle error
DTERR : FS_HCINT_DTERR_Field := 16#0#;
-- unspecified
Reserved_11_31 : STM32_SVD.UInt21 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_HCINT_Register use record
XFRC at 0 range 0 .. 0;
CHH at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
STALL at 0 range 3 .. 3;
NAK at 0 range 4 .. 4;
ACK at 0 range 5 .. 5;
Reserved_6_6 at 0 range 6 .. 6;
TXERR at 0 range 7 .. 7;
BBERR at 0 range 8 .. 8;
FRMOR at 0 range 9 .. 9;
DTERR at 0 range 10 .. 10;
Reserved_11_31 at 0 range 11 .. 31;
end record;
subtype FS_HCINTMSK_XFRCM_Field is STM32_SVD.Bit;
subtype FS_HCINTMSK_CHHM_Field is STM32_SVD.Bit;
subtype FS_HCINTMSK_STALLM_Field is STM32_SVD.Bit;
subtype FS_HCINTMSK_NAKM_Field is STM32_SVD.Bit;
subtype FS_HCINTMSK_ACKM_Field is STM32_SVD.Bit;
subtype FS_HCINTMSK_NYET_Field is STM32_SVD.Bit;
subtype FS_HCINTMSK_TXERRM_Field is STM32_SVD.Bit;
subtype FS_HCINTMSK_BBERRM_Field is STM32_SVD.Bit;
subtype FS_HCINTMSK_FRMORM_Field is STM32_SVD.Bit;
subtype FS_HCINTMSK_DTERRM_Field is STM32_SVD.Bit;
-- OTG_FS host channel-0 mask register (OTG_FS_HCINTMSK0)
type FS_HCINTMSK_Register is record
-- Transfer completed mask
XFRCM : FS_HCINTMSK_XFRCM_Field := 16#0#;
-- Channel halted mask
CHHM : FS_HCINTMSK_CHHM_Field := 16#0#;
-- unspecified
Reserved_2_2 : STM32_SVD.Bit := 16#0#;
-- STALL response received interrupt mask
STALLM : FS_HCINTMSK_STALLM_Field := 16#0#;
-- NAK response received interrupt mask
NAKM : FS_HCINTMSK_NAKM_Field := 16#0#;
-- ACK response received/transmitted interrupt mask
ACKM : FS_HCINTMSK_ACKM_Field := 16#0#;
-- response received interrupt mask
NYET : FS_HCINTMSK_NYET_Field := 16#0#;
-- Transaction error mask
TXERRM : FS_HCINTMSK_TXERRM_Field := 16#0#;
-- Babble error mask
BBERRM : FS_HCINTMSK_BBERRM_Field := 16#0#;
-- Frame overrun mask
FRMORM : FS_HCINTMSK_FRMORM_Field := 16#0#;
-- Data toggle error mask
DTERRM : FS_HCINTMSK_DTERRM_Field := 16#0#;
-- unspecified
Reserved_11_31 : STM32_SVD.UInt21 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_HCINTMSK_Register use record
XFRCM at 0 range 0 .. 0;
CHHM at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
STALLM at 0 range 3 .. 3;
NAKM at 0 range 4 .. 4;
ACKM at 0 range 5 .. 5;
NYET at 0 range 6 .. 6;
TXERRM at 0 range 7 .. 7;
BBERRM at 0 range 8 .. 8;
FRMORM at 0 range 9 .. 9;
DTERRM at 0 range 10 .. 10;
Reserved_11_31 at 0 range 11 .. 31;
end record;
subtype FS_HCTSIZ_XFRSIZ_Field is STM32_SVD.UInt19;
subtype FS_HCTSIZ_PKTCNT_Field is STM32_SVD.UInt10;
subtype FS_HCTSIZ_DPID_Field is STM32_SVD.UInt2;
-- OTG_FS host channel-0 transfer size register
type FS_HCTSIZ_Register is record
-- Transfer size
XFRSIZ : FS_HCTSIZ_XFRSIZ_Field := 16#0#;
-- Packet count
PKTCNT : FS_HCTSIZ_PKTCNT_Field := 16#0#;
-- Data PID
DPID : FS_HCTSIZ_DPID_Field := 16#0#;
-- unspecified
Reserved_31_31 : STM32_SVD.Bit := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_HCTSIZ_Register use record
XFRSIZ at 0 range 0 .. 18;
PKTCNT at 0 range 19 .. 28;
DPID at 0 range 29 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
subtype FS_PCGCCTL_STPPCLK_Field is STM32_SVD.Bit;
subtype FS_PCGCCTL_GATEHCLK_Field is STM32_SVD.Bit;
subtype FS_PCGCCTL_PHYSUSP_Field is STM32_SVD.Bit;
-- OTG_FS power and clock gating control register
type FS_PCGCCTL_Register is record
-- Stop PHY clock
STPPCLK : FS_PCGCCTL_STPPCLK_Field := 16#0#;
-- Gate HCLK
GATEHCLK : FS_PCGCCTL_GATEHCLK_Field := 16#0#;
-- unspecified
Reserved_2_3 : STM32_SVD.UInt2 := 16#0#;
-- PHY Suspended
PHYSUSP : FS_PCGCCTL_PHYSUSP_Field := 16#0#;
-- unspecified
Reserved_5_31 : STM32_SVD.UInt27 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for FS_PCGCCTL_Register use record
STPPCLK at 0 range 0 .. 0;
GATEHCLK at 0 range 1 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
PHYSUSP at 0 range 4 .. 4;
Reserved_5_31 at 0 range 5 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- USB on the go full speed
type OTG_FS_DEVICE_Peripheral is record
-- OTG_FS device configuration register (OTG_FS_DCFG)
FS_DCFG : aliased FS_DCFG_Register;
-- OTG_FS device control register (OTG_FS_DCTL)
FS_DCTL : aliased FS_DCTL_Register;
-- OTG_FS device status register (OTG_FS_DSTS)
FS_DSTS : aliased FS_DSTS_Register;
-- OTG_FS device IN endpoint common interrupt mask register
-- (OTG_FS_DIEPMSK)
FS_DIEPMSK : aliased FS_DIEPMSK_Register;
-- OTG_FS device OUT endpoint common interrupt mask register
-- (OTG_FS_DOEPMSK)
FS_DOEPMSK : aliased FS_DOEPMSK_Register;
-- OTG_FS device all endpoints interrupt register (OTG_FS_DAINT)
FS_DAINT : aliased FS_DAINT_Register;
-- OTG_FS all endpoints interrupt mask register (OTG_FS_DAINTMSK)
FS_DAINTMSK : aliased FS_DAINTMSK_Register;
-- OTG_FS device VBUS discharge time register
DVBUSDIS : aliased DVBUSDIS_Register;
-- OTG_FS device VBUS pulsing time register
DVBUSPULSE : aliased DVBUSPULSE_Register;
-- OTG_FS device IN endpoint FIFO empty interrupt mask register
DIEPEMPMSK : aliased DIEPEMPMSK_Register;
-- OTG_FS device control IN endpoint 0 control register
-- (OTG_FS_DIEPCTL0)
FS_DIEPCTL0 : aliased FS_DIEPCTL0_Register;
-- device endpoint-x interrupt register
DIEPINT0 : aliased DIEPINT_Register;
-- device endpoint-0 transfer size register
DIEPTSIZ0 : aliased DIEPTSIZ0_Register;
-- OTG_FS device IN endpoint transmit FIFO status register
DTXFSTS0 : aliased DTXFSTS_Register;
-- OTG device endpoint-1 control register
DIEPCTL1 : aliased DIEPCTL1_Register;
-- device endpoint-1 interrupt register
DIEPINT1 : aliased DIEPINT_Register;
-- device endpoint-1 transfer size register
DIEPTSIZ1 : aliased DIEPTSIZ_Register;
-- OTG_FS device IN endpoint transmit FIFO status register
DTXFSTS1 : aliased DTXFSTS_Register;
-- OTG device endpoint-2 control register
DIEPCTL2 : aliased DIEPCTL_Register;
-- device endpoint-2 interrupt register
DIEPINT2 : aliased DIEPINT_Register;
-- device endpoint-2 transfer size register
DIEPTSIZ2 : aliased DIEPTSIZ_Register;
-- OTG_FS device IN endpoint transmit FIFO status register
DTXFSTS2 : aliased DTXFSTS_Register;
-- OTG device endpoint-3 control register
DIEPCTL3 : aliased DIEPCTL_Register;
-- device endpoint-3 interrupt register
DIEPINT3 : aliased DIEPINT_Register;
-- device endpoint-3 transfer size register
DIEPTSIZ3 : aliased DIEPTSIZ_Register;
-- OTG_FS device IN endpoint transmit FIFO status register
DTXFSTS3 : aliased DTXFSTS_Register;
-- device endpoint-0 control register
DOEPCTL0 : aliased DOEPCTL0_Register;
-- device endpoint-0 interrupt register
DOEPINT0 : aliased DOEPINT_Register;
-- device OUT endpoint-0 transfer size register
DOEPTSIZ0 : aliased DOEPTSIZ0_Register;
-- device endpoint-1 control register
DOEPCTL1 : aliased DOEPCTL_Register;
-- device endpoint-1 interrupt register
DOEPINT1 : aliased DOEPINT_Register;
-- device OUT endpoint-1 transfer size register
DOEPTSIZ1 : aliased DOEPTSIZ_Register;
-- device endpoint-2 control register
DOEPCTL2 : aliased DOEPCTL_Register;
-- device endpoint-2 interrupt register
DOEPINT2 : aliased DOEPINT_Register;
-- device OUT endpoint-2 transfer size register
DOEPTSIZ2 : aliased DOEPTSIZ_Register;
-- device endpoint-3 control register
DOEPCTL3 : aliased DOEPCTL_Register;
-- device endpoint-3 interrupt register
DOEPINT3 : aliased DOEPINT_Register;
-- device OUT endpoint-3 transfer size register
DOEPTSIZ3 : aliased DOEPTSIZ_Register;
end record
with Volatile;
for OTG_FS_DEVICE_Peripheral use record
FS_DCFG at 16#0# range 0 .. 31;
FS_DCTL at 16#4# range 0 .. 31;
FS_DSTS at 16#8# range 0 .. 31;
FS_DIEPMSK at 16#10# range 0 .. 31;
FS_DOEPMSK at 16#14# range 0 .. 31;
FS_DAINT at 16#18# range 0 .. 31;
FS_DAINTMSK at 16#1C# range 0 .. 31;
DVBUSDIS at 16#28# range 0 .. 31;
DVBUSPULSE at 16#2C# range 0 .. 31;
DIEPEMPMSK at 16#34# range 0 .. 31;
FS_DIEPCTL0 at 16#100# range 0 .. 31;
DIEPINT0 at 16#108# range 0 .. 31;
DIEPTSIZ0 at 16#110# range 0 .. 31;
DTXFSTS0 at 16#118# range 0 .. 31;
DIEPCTL1 at 16#120# range 0 .. 31;
DIEPINT1 at 16#128# range 0 .. 31;
DIEPTSIZ1 at 16#130# range 0 .. 31;
DTXFSTS1 at 16#138# range 0 .. 31;
DIEPCTL2 at 16#140# range 0 .. 31;
DIEPINT2 at 16#148# range 0 .. 31;
DIEPTSIZ2 at 16#150# range 0 .. 31;
DTXFSTS2 at 16#158# range 0 .. 31;
DIEPCTL3 at 16#160# range 0 .. 31;
DIEPINT3 at 16#168# range 0 .. 31;
DIEPTSIZ3 at 16#170# range 0 .. 31;
DTXFSTS3 at 16#178# range 0 .. 31;
DOEPCTL0 at 16#300# range 0 .. 31;
DOEPINT0 at 16#308# range 0 .. 31;
DOEPTSIZ0 at 16#310# range 0 .. 31;
DOEPCTL1 at 16#320# range 0 .. 31;
DOEPINT1 at 16#328# range 0 .. 31;
DOEPTSIZ1 at 16#330# range 0 .. 31;
DOEPCTL2 at 16#340# range 0 .. 31;
DOEPINT2 at 16#348# range 0 .. 31;
DOEPTSIZ2 at 16#350# range 0 .. 31;
DOEPCTL3 at 16#360# range 0 .. 31;
DOEPINT3 at 16#368# range 0 .. 31;
DOEPTSIZ3 at 16#370# range 0 .. 31;
end record;
-- USB on the go full speed
OTG_FS_DEVICE_Periph : aliased OTG_FS_DEVICE_Peripheral
with Import, Address => System'To_Address (16#50000800#);
type OTG_FS_GLOBAL_Disc is
(
Device,
Host);
-- USB on the go full speed
type OTG_FS_GLOBAL_Peripheral
(Discriminent : OTG_FS_GLOBAL_Disc := Device)
is record
-- OTG_FS control and status register (OTG_FS_GOTGCTL)
FS_GOTGCTL : aliased FS_GOTGCTL_Register;
-- OTG_FS interrupt register (OTG_FS_GOTGINT)
FS_GOTGINT : aliased FS_GOTGINT_Register;
-- OTG_FS AHB configuration register (OTG_FS_GAHBCFG)
FS_GAHBCFG : aliased FS_GAHBCFG_Register;
-- OTG_FS USB configuration register (OTG_FS_GUSBCFG)
FS_GUSBCFG : aliased FS_GUSBCFG_Register;
-- OTG_FS reset register (OTG_FS_GRSTCTL)
FS_GRSTCTL : aliased FS_GRSTCTL_Register;
-- OTG_FS core interrupt register (OTG_FS_GINTSTS)
FS_GINTSTS : aliased FS_GINTSTS_Register;
-- OTG_FS interrupt mask register (OTG_FS_GINTMSK)
FS_GINTMSK : aliased FS_GINTMSK_Register;
-- OTG_FS Receive FIFO size register (OTG_FS_GRXFSIZ)
FS_GRXFSIZ : aliased FS_GRXFSIZ_Register;
-- OTG_FS non-periodic transmit FIFO/queue status register
-- (OTG_FS_GNPTXSTS)
FS_GNPTXSTS : aliased FS_GNPTXSTS_Register;
-- OTG_FS general core configuration register (OTG_FS_GCCFG)
FS_GCCFG : aliased FS_GCCFG_Register;
-- core ID register
FS_CID : aliased STM32_SVD.UInt32;
-- OTG_FS Host periodic transmit FIFO size register (OTG_FS_HPTXFSIZ)
FS_HPTXFSIZ : aliased FS_HPTXFSIZ_Register;
-- OTG_FS device IN endpoint transmit FIFO size register
-- (OTG_FS_DIEPTXF2)
FS_DIEPTXF1 : aliased FS_DIEPTXF_Register;
-- OTG_FS device IN endpoint transmit FIFO size register
-- (OTG_FS_DIEPTXF3)
FS_DIEPTXF2 : aliased FS_DIEPTXF_Register;
-- OTG_FS device IN endpoint transmit FIFO size register
-- (OTG_FS_DIEPTXF4)
FS_DIEPTXF3 : aliased FS_DIEPTXF_Register;
case Discriminent is
when Device =>
-- OTG_FS Receive status debug read(Device mode)
FS_GRXSTSR_Device : aliased FS_GRXSTSR_Device_Register;
-- OTG_FS non-periodic transmit FIFO size register (Device mode)
FS_GNPTXFSIZ_Device : aliased FS_GNPTXFSIZ_Device_Register;
when Host =>
-- OTG_FS Receive status debug read(Host mode)
FS_GRXSTSR_Host : aliased FS_GRXSTSR_Host_Register;
-- OTG_FS non-periodic transmit FIFO size register (Host mode)
FS_GNPTXFSIZ_Host : aliased FS_GNPTXFSIZ_Host_Register;
end case;
end record
with Unchecked_Union, Volatile;
for OTG_FS_GLOBAL_Peripheral use record
FS_GOTGCTL at 16#0# range 0 .. 31;
FS_GOTGINT at 16#4# range 0 .. 31;
FS_GAHBCFG at 16#8# range 0 .. 31;
FS_GUSBCFG at 16#C# range 0 .. 31;
FS_GRSTCTL at 16#10# range 0 .. 31;
FS_GINTSTS at 16#14# range 0 .. 31;
FS_GINTMSK at 16#18# range 0 .. 31;
FS_GRXFSIZ at 16#24# range 0 .. 31;
FS_GNPTXSTS at 16#2C# range 0 .. 31;
FS_GCCFG at 16#38# range 0 .. 31;
FS_CID at 16#3C# range 0 .. 31;
FS_HPTXFSIZ at 16#100# range 0 .. 31;
FS_DIEPTXF1 at 16#104# range 0 .. 31;
FS_DIEPTXF2 at 16#108# range 0 .. 31;
FS_DIEPTXF3 at 16#10C# range 0 .. 31;
FS_GRXSTSR_Device at 16#1C# range 0 .. 31;
FS_GNPTXFSIZ_Device at 16#28# range 0 .. 31;
FS_GRXSTSR_Host at 16#1C# range 0 .. 31;
FS_GNPTXFSIZ_Host at 16#28# range 0 .. 31;
end record;
-- USB on the go full speed
OTG_FS_GLOBAL_Periph : aliased OTG_FS_GLOBAL_Peripheral
with Import, Address => System'To_Address (16#50000000#);
-- USB on the go full speed
type OTG_FS_HOST_Peripheral is record
-- OTG_FS host configuration register (OTG_FS_HCFG)
FS_HCFG : aliased FS_HCFG_Register;
-- OTG_FS Host frame interval register
HFIR : aliased HFIR_Register;
-- OTG_FS host frame number/frame time remaining register (OTG_FS_HFNUM)
FS_HFNUM : aliased FS_HFNUM_Register;
-- OTG_FS_Host periodic transmit FIFO/queue status register
-- (OTG_FS_HPTXSTS)
FS_HPTXSTS : aliased FS_HPTXSTS_Register;
-- OTG_FS Host all channels interrupt register
HAINT : aliased HAINT_Register;
-- OTG_FS host all channels interrupt mask register
HAINTMSK : aliased HAINTMSK_Register;
-- OTG_FS host port control and status register (OTG_FS_HPRT)
FS_HPRT : aliased FS_HPRT_Register;
-- OTG_FS host channel-0 characteristics register (OTG_FS_HCCHAR0)
FS_HCCHAR0 : aliased FS_HCCHAR_Register;
-- OTG_FS host channel-0 interrupt register (OTG_FS_HCINT0)
FS_HCINT0 : aliased FS_HCINT_Register;
-- OTG_FS host channel-0 mask register (OTG_FS_HCINTMSK0)
FS_HCINTMSK0 : aliased FS_HCINTMSK_Register;
-- OTG_FS host channel-0 transfer size register
FS_HCTSIZ0 : aliased FS_HCTSIZ_Register;
-- OTG_FS host channel-1 characteristics register (OTG_FS_HCCHAR1)
FS_HCCHAR1 : aliased FS_HCCHAR_Register;
-- OTG_FS host channel-1 interrupt register (OTG_FS_HCINT1)
FS_HCINT1 : aliased FS_HCINT_Register;
-- OTG_FS host channel-1 mask register (OTG_FS_HCINTMSK1)
FS_HCINTMSK1 : aliased FS_HCINTMSK_Register;
-- OTG_FS host channel-1 transfer size register
FS_HCTSIZ1 : aliased FS_HCTSIZ_Register;
-- OTG_FS host channel-2 characteristics register (OTG_FS_HCCHAR2)
FS_HCCHAR2 : aliased FS_HCCHAR_Register;
-- OTG_FS host channel-2 interrupt register (OTG_FS_HCINT2)
FS_HCINT2 : aliased FS_HCINT_Register;
-- OTG_FS host channel-2 mask register (OTG_FS_HCINTMSK2)
FS_HCINTMSK2 : aliased FS_HCINTMSK_Register;
-- OTG_FS host channel-2 transfer size register
FS_HCTSIZ2 : aliased FS_HCTSIZ_Register;
-- OTG_FS host channel-3 characteristics register (OTG_FS_HCCHAR3)
FS_HCCHAR3 : aliased FS_HCCHAR_Register;
-- OTG_FS host channel-3 interrupt register (OTG_FS_HCINT3)
FS_HCINT3 : aliased FS_HCINT_Register;
-- OTG_FS host channel-3 mask register (OTG_FS_HCINTMSK3)
FS_HCINTMSK3 : aliased FS_HCINTMSK_Register;
-- OTG_FS host channel-3 transfer size register
FS_HCTSIZ3 : aliased FS_HCTSIZ_Register;
-- OTG_FS host channel-4 characteristics register (OTG_FS_HCCHAR4)
FS_HCCHAR4 : aliased FS_HCCHAR_Register;
-- OTG_FS host channel-4 interrupt register (OTG_FS_HCINT4)
FS_HCINT4 : aliased FS_HCINT_Register;
-- OTG_FS host channel-4 mask register (OTG_FS_HCINTMSK4)
FS_HCINTMSK4 : aliased FS_HCINTMSK_Register;
-- OTG_FS host channel-x transfer size register
FS_HCTSIZ4 : aliased FS_HCTSIZ_Register;
-- OTG_FS host channel-5 characteristics register (OTG_FS_HCCHAR5)
FS_HCCHAR5 : aliased FS_HCCHAR_Register;
-- OTG_FS host channel-5 interrupt register (OTG_FS_HCINT5)
FS_HCINT5 : aliased FS_HCINT_Register;
-- OTG_FS host channel-5 mask register (OTG_FS_HCINTMSK5)
FS_HCINTMSK5 : aliased FS_HCINTMSK_Register;
-- OTG_FS host channel-5 transfer size register
FS_HCTSIZ5 : aliased FS_HCTSIZ_Register;
-- OTG_FS host channel-6 characteristics register (OTG_FS_HCCHAR6)
FS_HCCHAR6 : aliased FS_HCCHAR_Register;
-- OTG_FS host channel-6 interrupt register (OTG_FS_HCINT6)
FS_HCINT6 : aliased FS_HCINT_Register;
-- OTG_FS host channel-6 mask register (OTG_FS_HCINTMSK6)
FS_HCINTMSK6 : aliased FS_HCINTMSK_Register;
-- OTG_FS host channel-6 transfer size register
FS_HCTSIZ6 : aliased FS_HCTSIZ_Register;
-- OTG_FS host channel-7 characteristics register (OTG_FS_HCCHAR7)
FS_HCCHAR7 : aliased FS_HCCHAR_Register;
-- OTG_FS host channel-7 interrupt register (OTG_FS_HCINT7)
FS_HCINT7 : aliased FS_HCINT_Register;
-- OTG_FS host channel-7 mask register (OTG_FS_HCINTMSK7)
FS_HCINTMSK7 : aliased FS_HCINTMSK_Register;
-- OTG_FS host channel-7 transfer size register
FS_HCTSIZ7 : aliased FS_HCTSIZ_Register;
end record
with Volatile;
for OTG_FS_HOST_Peripheral use record
FS_HCFG at 16#0# range 0 .. 31;
HFIR at 16#4# range 0 .. 31;
FS_HFNUM at 16#8# range 0 .. 31;
FS_HPTXSTS at 16#10# range 0 .. 31;
HAINT at 16#14# range 0 .. 31;
HAINTMSK at 16#18# range 0 .. 31;
FS_HPRT at 16#40# range 0 .. 31;
FS_HCCHAR0 at 16#100# range 0 .. 31;
FS_HCINT0 at 16#108# range 0 .. 31;
FS_HCINTMSK0 at 16#10C# range 0 .. 31;
FS_HCTSIZ0 at 16#110# range 0 .. 31;
FS_HCCHAR1 at 16#120# range 0 .. 31;
FS_HCINT1 at 16#128# range 0 .. 31;
FS_HCINTMSK1 at 16#12C# range 0 .. 31;
FS_HCTSIZ1 at 16#130# range 0 .. 31;
FS_HCCHAR2 at 16#140# range 0 .. 31;
FS_HCINT2 at 16#148# range 0 .. 31;
FS_HCINTMSK2 at 16#14C# range 0 .. 31;
FS_HCTSIZ2 at 16#150# range 0 .. 31;
FS_HCCHAR3 at 16#160# range 0 .. 31;
FS_HCINT3 at 16#168# range 0 .. 31;
FS_HCINTMSK3 at 16#16C# range 0 .. 31;
FS_HCTSIZ3 at 16#170# range 0 .. 31;
FS_HCCHAR4 at 16#180# range 0 .. 31;
FS_HCINT4 at 16#188# range 0 .. 31;
FS_HCINTMSK4 at 16#18C# range 0 .. 31;
FS_HCTSIZ4 at 16#190# range 0 .. 31;
FS_HCCHAR5 at 16#1A0# range 0 .. 31;
FS_HCINT5 at 16#1A8# range 0 .. 31;
FS_HCINTMSK5 at 16#1AC# range 0 .. 31;
FS_HCTSIZ5 at 16#1B0# range 0 .. 31;
FS_HCCHAR6 at 16#1C0# range 0 .. 31;
FS_HCINT6 at 16#1C8# range 0 .. 31;
FS_HCINTMSK6 at 16#1CC# range 0 .. 31;
FS_HCTSIZ6 at 16#1D0# range 0 .. 31;
FS_HCCHAR7 at 16#1E0# range 0 .. 31;
FS_HCINT7 at 16#1E8# range 0 .. 31;
FS_HCINTMSK7 at 16#1EC# range 0 .. 31;
FS_HCTSIZ7 at 16#1F0# range 0 .. 31;
end record;
-- USB on the go full speed
OTG_FS_HOST_Periph : aliased OTG_FS_HOST_Peripheral
with Import, Address => System'To_Address (16#50000400#);
-- USB on the go full speed
type OTG_FS_PWRCLK_Peripheral is record
-- OTG_FS power and clock gating control register
FS_PCGCCTL : aliased FS_PCGCCTL_Register;
end record
with Volatile;
for OTG_FS_PWRCLK_Peripheral use record
FS_PCGCCTL at 0 range 0 .. 31;
end record;
-- USB on the go full speed
OTG_FS_PWRCLK_Periph : aliased OTG_FS_PWRCLK_Peripheral
with Import, Address => System'To_Address (16#50000E00#);
end STM32_SVD.USB_OTG_FS;
|
stcarrez/hyperion | Ada | 890 | ads | -----------------------------------------------------------------------
-- hyperion-hosts -- Module hosts
-- Copyright (C) 2017 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package Hyperion.Hosts is
end Hyperion.Hosts;
|
veyselharun/ABench2020 | Ada | 2,476 | adb | --
-- ABench2020 Benchmark Suite
--
-- Matrix Multiplication Program
--
-- Licensed under the MIT License. See LICENSE file in the ABench root
-- directory for license information.
--
-- Uncomment the line below to print the result.
-- with Ada.Text_IO; use Ada.Text_IO;
procedure Matrix_Multiplication is
type MMatrix is array (Positive range<>, Positive range<>) of Integer;
procedure Multiply (First_Matrix, Second_Matrix : in MMatrix; Third_Matrix : out MMatrix) is
Product : Integer := 0;
begin
for T in 1 .. First_Matrix'Last (1) loop
for Y in 1 .. Second_Matrix'Last (2) loop
Product := 0;
for U in 1 .. First_Matrix'Last (2) loop
Product := Product + First_Matrix (T, U) * Second_Matrix (U, Y);
end loop;
Third_Matrix (T, Y) := Product;
end loop;
end loop;
end;
First_Matrix : constant MMatrix :=
( (1, 1, 22, 83, 98, 1, 10, 2, 9, 11),
(5, 1, 14, 8, 9, 10, 7, 2, 10, 30),
(6, 5, 32, 0, 1, 60, 10, 0, 2, 0),
(22, 9, 23, 4, 1, 9, 3, 1, 4, 1),
(8, 1, 82, 3, 5, 6, 3, 4, 7, 2),
(9, 0, 17, 4, 4, 99, 9, 0, 1, 10),
(2, 5, 27, 2, 1, 40, 7, 1, 0, 20),
(0, 7, 12, 1, 1, 13, 4, 8, 2, 75),
(21, 33, 1, 1, 7, 8, 2, 0, 9, 3),
(5, 98, 0, 2, 0, 9, 1, 1, 5, 12)
);
Second_Matrix : constant MMatrix :=
( (1, 1, 22, 83, 98, 1, 10, 2, 9, 11),
(5, 1, 14, 8, 9, 10, 7, 2, 10, 30),
(6, 5, 32, 0, 1, 60, 10, 0, 2, 0),
(22, 9, 23, 4, 1, 9, 3, 1, 4, 1),
(8, 1, 82, 3, 5, 6, 3, 4, 7, 2),
(9, 0, 17, 4, 4, 99, 9, 0, 1, 10),
(2, 5, 27, 2, 1, 40, 7, 1, 0, 20),
(0, 7, 12, 1, 1, 13, 4, 8, 2, 75),
(21, 33, 1, 1, 7, 8, 2, 0, 9, 3),
(5, 98, 0, 2, 0, 9, 1, 1, 5, 12)
);
Third_Matrix : MMatrix (1 .. 10, 1 .. 10);
begin
Multiply (First_Matrix, Second_Matrix, Third_Matrix);
-- Uncomment the lines below to print the result.
-- for I in 1 .. Third_Matrix'Last (1) loop
-- for J in 1 .. Third_Matrix'Last (2) loop
-- Put (Integer'Image (Third_Matrix (I, J)));
-- end loop;
-- New_Line;
-- end loop;
end;
|
AdaCore/gpr | Ada | 790 | ads |
with InDash;
package Gauge is
type Percent is delta 0.01 digits 5 range 0.0 .. 100.0;
type Numeric_Gauge is new InDash.Instrument with private;
type Numeric_Gauge_Reference is access all Numeric_Gauge;
procedure Display (G : access Numeric_Gauge);
procedure Update (G : access Numeric_Gauge; Millisec : Integer);
type Graphic_Gauge is new Numeric_Gauge with private;
type Graphic_Gauge_Reference is access all Graphic_Gauge;
procedure Display (G : access Graphic_Gauge);
private
type Numeric_Gauge is new InDash.Instrument with record
Value : Percent;
Rate : Float;
end record;
type Graphic_Gauge is new Numeric_Gauge with record
Size : Integer;
Fill : Character;
Empty : Character;
end record;
end Gauge;
|
kontena/ruby-packer | Ada | 3,034 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- Sample.Curses_Demo.Mouse --
-- --
-- S P E C --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 1998,2003 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer, 1996
-- Version Control
-- $Revision: 1.10 $
-- Binding Version 01.00
------------------------------------------------------------------------------
package Sample.Curses_Demo.Mouse is
procedure Demo;
end Sample.Curses_Demo.Mouse;
|
stcarrez/stm32-ui | Ada | 4,722 | adb | -----------------------------------------------------------------------
-- graphs-display -- Main display view manager for the graphs
-- Copyright (C) 2018 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with UI.Texts;
package body Graphs.Display is
use Ada.Real_Time;
task body Idle_Task is
Deadline : Ada.Real_Time.Time;
Max : Natural := 0;
Value : Natural;
begin
Int_Graph.Initialize (Graph_Data, GRAPH_RATE);
loop
-- We have up to the deadline to increment the counter to compute the idle time.
Deadline := Int_Graph.Get_Deadline (Graph_Data);
Value := 0;
while Ada.Real_Time.Clock < Deadline loop
Value := Value + 1;
end loop;
if Value > Max then
Max := Value;
end if;
-- Convert the counter into a percentage over the max value we have found.
Value := 100 - ((100 * Value) / Max);
-- Add the new sample.
Int_Graph.Add_Sample (Graph_Data, Graph_Value_Type (Value), Ada.Real_Time.Clock);
end loop;
end Idle_Task;
-- ------------------------------
-- Draw the layout presentation frame.
-- ------------------------------
overriding
procedure On_Restore (Display : in out Display_Type;
Buffer : in out HAL.Bitmap.Bitmap_Buffer'Class) is
W : constant Natural := Buffer.Width;
H : constant Natural := Buffer.Height;
TMARGIN : constant Natural := 10;
LMARGIN : constant Natural := 40;
RMARGIN : constant Natural := 10;
begin
-- Next button (right bar).
Display.Next_Button.Pos := (W - 80, 0);
Display.Next_Button.Width := 80;
Display.Next_Button.Height := H;
Display.Next_Button.Len := 3;
-- Previous button (left bar).
Display.Prev_Button.Pos := (0, 0);
Display.Prev_Button.Width := 30;
Display.Prev_Button.Height := H;
Display.Prev_Button.Len := 3;
-- Info button (middle of image).
Display.Info_Button.Pos := ((W / 2) - 80, 0);
Display.Info_Button.Width := 160;
Display.Info_Button.Height := H;
Display.Info_Button.Len := 3;
Buffer.Set_Source (HAL.Bitmap.Green);
Buffer.Draw_Rect (Area => (Position => (LMARGIN - 1, TMARGIN - 1),
Width => W - LMARGIN - RMARGIN + 2,
Height => H - TMARGIN - TMARGIN + 2));
Int_Graph.Initialize (Display.Graph, LMARGIN, TMARGIN, W - LMARGIN - RMARGIN,
H - TMARGIN - TMARGIN);
-- Disable auto scaling: use a fixed scale.
Int_Graph.Set_Range (Display.Graph, 0, 100);
UI.Texts.Draw_String (Buffer => Buffer,
Start => (0, TMARGIN - 6),
Width => 250,
Msg => "100");
UI.Texts.Draw_String (Buffer => Buffer,
Start => (20, H - TMARGIN - TMARGIN),
Width => 250,
Msg => "0");
end On_Restore;
-- ------------------------------
-- Refresh the current display.
-- ------------------------------
overriding
procedure On_Refresh (Display : in out Display_Type;
Buffer : in out HAL.Bitmap.Bitmap_Buffer'Class;
Deadline : out Ada.Real_Time.Time) is
begin
Int_Graph.Draw (Buffer, Display.Graph, Graph_Data);
Deadline := Ada.Real_Time.Clock + DISPLAY_TIME;
end On_Refresh;
-- ------------------------------
-- Handle refresh timeout event.
-- ------------------------------
overriding
procedure On_Timeout (Display : in out Display_Type;
Buffer : in out HAL.Bitmap.Bitmap_Buffer'Class;
Deadline : out Ada.Real_Time.Time) is
begin
Display.Refresh (Buffer, UI.Displays.REFRESH_BOTH);
Deadline := Ada.Real_Time.Clock + DISPLAY_TIME;
end On_Timeout;
end Graphs.Display;
|
mirror/ncurses | Ada | 3,608 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding --
-- --
-- Terminal_Interface.Curses.Text_IO.Fixed_IO --
-- --
-- S P E C --
-- --
------------------------------------------------------------------------------
-- Copyright 2020 Thomas E. Dickey --
-- Copyright 1999-2003,2009 Free Software Foundation, Inc. --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, distribute with modifications, sublicense, and/or sell --
-- copies of the Software, and to permit persons to whom the Software is --
-- furnished to do so, subject to the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, --
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR --
-- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR --
-- THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Juergen Pfeifer, 1996
-- Version Control:
-- $Revision: 1.13 $
-- Binding Version 01.00
------------------------------------------------------------------------------
generic
type Num is delta <>;
package Terminal_Interface.Curses.Text_IO.Fixed_IO is
Default_Fore : Field := Num'Fore;
Default_Aft : Field := Num'Aft;
Default_Exp : Field := 0;
procedure Put
(Win : Window;
Item : Num;
Fore : Field := Default_Fore;
Aft : Field := Default_Aft;
Exp : Field := Default_Exp);
procedure Put
(Item : Num;
Fore : Field := Default_Fore;
Aft : Field := Default_Aft;
Exp : Field := Default_Exp);
private
pragma Inline (Put);
end Terminal_Interface.Curses.Text_IO.Fixed_IO;
|
reznikmm/matreshka | Ada | 6,981 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Style.Ruby_Properties_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Style_Ruby_Properties_Element_Node is
begin
return Self : Style_Ruby_Properties_Element_Node do
Matreshka.ODF_Style.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Style_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Style_Ruby_Properties_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Style_Ruby_Properties
(ODF.DOM.Style_Ruby_Properties_Elements.ODF_Style_Ruby_Properties_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Style_Ruby_Properties_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Ruby_Properties_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Style_Ruby_Properties_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Style_Ruby_Properties
(ODF.DOM.Style_Ruby_Properties_Elements.ODF_Style_Ruby_Properties_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Style_Ruby_Properties_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Style_Ruby_Properties
(Visitor,
ODF.DOM.Style_Ruby_Properties_Elements.ODF_Style_Ruby_Properties_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Style_URI,
Matreshka.ODF_String_Constants.Ruby_Properties_Element,
Style_Ruby_Properties_Element_Node'Tag);
end Matreshka.ODF_Style.Ruby_Properties_Elements;
|
AdaCore/gpr | Ada | 751 | adb |
--
-- Copyright (C) 2019-2023, AdaCore
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
with Gpr_Parser.Implementation;
use Gpr_Parser.Implementation;
with Gpr_Parser.Public_Converters; use Gpr_Parser.Public_Converters;
with Gpr_Parser.Unparsing_Implementation;
use Gpr_Parser.Unparsing_Implementation;
package body Gpr_Parser.Unparsing is
-------------
-- Unparse --
-------------
function Unparse (Node : Gpr_Node'Class) return String is
N : constant Bare_Gpr_Node := Unwrap_Node (Node);
begin
return Unparse
(Create_Abstract_Node (N),
Unwrap_Node (Node).Unit,
Preserve_Formatting => False,
As_Unit => False);
end Unparse;
end Gpr_Parser.Unparsing;
|
reznikmm/matreshka | Ada | 3,699 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Text_Display_Attributes is
pragma Preelaborate;
type ODF_Text_Display_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Text_Display_Attribute_Access is
access all ODF_Text_Display_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Text_Display_Attributes;
|
reznikmm/matreshka | Ada | 4,767 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.CMOF.Tags.Collections is
pragma Preelaborate;
package CMOF_Tag_Collections is
new AMF.Generic_Collections
(CMOF_Tag,
CMOF_Tag_Access);
type Set_Of_CMOF_Tag is
new CMOF_Tag_Collections.Set with null record;
Empty_Set_Of_CMOF_Tag : constant Set_Of_CMOF_Tag;
type Ordered_Set_Of_CMOF_Tag is
new CMOF_Tag_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_CMOF_Tag : constant Ordered_Set_Of_CMOF_Tag;
type Bag_Of_CMOF_Tag is
new CMOF_Tag_Collections.Bag with null record;
Empty_Bag_Of_CMOF_Tag : constant Bag_Of_CMOF_Tag;
type Sequence_Of_CMOF_Tag is
new CMOF_Tag_Collections.Sequence with null record;
Empty_Sequence_Of_CMOF_Tag : constant Sequence_Of_CMOF_Tag;
private
Empty_Set_Of_CMOF_Tag : constant Set_Of_CMOF_Tag
:= (CMOF_Tag_Collections.Set with null record);
Empty_Ordered_Set_Of_CMOF_Tag : constant Ordered_Set_Of_CMOF_Tag
:= (CMOF_Tag_Collections.Ordered_Set with null record);
Empty_Bag_Of_CMOF_Tag : constant Bag_Of_CMOF_Tag
:= (CMOF_Tag_Collections.Bag with null record);
Empty_Sequence_Of_CMOF_Tag : constant Sequence_Of_CMOF_Tag
:= (CMOF_Tag_Collections.Sequence with null record);
end AMF.CMOF.Tags.Collections;
|
zhmu/ananas | Ada | 259 | adb | -- { dg-do compile }
package body Bip_Export is
function F return T is
begin
return Result : constant T := G do
null;
end return;
end F;
function G return T is
begin
return (null record);
end G;
end Bip_Export;
|
zhmu/ananas | Ada | 7,834 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M --
-- --
-- S p e c --
-- (VxWorks 6 Kernel Version E500) --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
package System is
pragma Pure;
-- Note that we take advantage of the implementation permission to make
-- this unit Pure instead of Preelaborable; see RM 13.7.1(15). In Ada
-- 2005, this is Pure in any case (AI-362).
pragma No_Elaboration_Code_All;
-- Allow the use of that restriction in units that WITH this unit
type Name is (SYSTEM_NAME_GNAT);
System_Name : constant Name := SYSTEM_NAME_GNAT;
-- System-Dependent Named Numbers
Min_Int : constant := -2 ** (Standard'Max_Integer_Size - 1);
Max_Int : constant := 2 ** (Standard'Max_Integer_Size - 1) - 1;
Max_Binary_Modulus : constant := 2 ** Standard'Max_Integer_Size;
Max_Nonbinary_Modulus : constant := 2 ** Integer'Size - 1;
Max_Base_Digits : constant := Long_Long_Float'Digits;
Max_Digits : constant := Long_Long_Float'Digits;
Max_Mantissa : constant := Standard'Max_Integer_Size - 1;
Fine_Delta : constant := 2.0 ** (-Max_Mantissa);
Tick : constant := 1.0 / 60.0;
-- Storage-related Declarations
type Address is private;
pragma Preelaborable_Initialization (Address);
Null_Address : constant Address;
Storage_Unit : constant := 8;
Word_Size : constant := 32;
Memory_Size : constant := 2 ** 32;
-- Address comparison
function "<" (Left, Right : Address) return Boolean;
function "<=" (Left, Right : Address) return Boolean;
function ">" (Left, Right : Address) return Boolean;
function ">=" (Left, Right : Address) return Boolean;
function "=" (Left, Right : Address) return Boolean;
pragma Import (Intrinsic, "<");
pragma Import (Intrinsic, "<=");
pragma Import (Intrinsic, ">");
pragma Import (Intrinsic, ">=");
pragma Import (Intrinsic, "=");
-- Other System-Dependent Declarations
type Bit_Order is (High_Order_First, Low_Order_First);
Default_Bit_Order : constant Bit_Order := High_Order_First;
pragma Warnings (Off, Default_Bit_Order); -- kill constant condition warning
-- Priority-related Declarations (RM D.1)
-- Ada priorities are mapped to VxWorks priorities using the following
-- transformation: 255 - Ada Priority
-- Ada priorities are used as follows:
-- 256 is reserved for the VxWorks kernel
-- 248 - 255 correspond to hardware interrupt levels 0 .. 7
-- 247 is a catchall default "interrupt" priority for signals,
-- allowing higher priority than normal tasks, but lower than
-- hardware priority levels. Protected Object ceilings can
-- override these values.
-- 246 is used by the Interrupt_Manager task
Max_Priority : constant Positive := 245;
Max_Interrupt_Priority : constant Positive := 255;
subtype Any_Priority is Integer range 0 .. 255;
subtype Priority is Any_Priority range 0 .. 245;
subtype Interrupt_Priority is Any_Priority range 246 .. 255;
Default_Priority : constant Priority := 122;
private
type Address is mod Memory_Size;
Null_Address : constant Address := 0;
--------------------------------------
-- System Implementation Parameters --
--------------------------------------
-- These parameters provide information about the target that is used
-- by the compiler. They are in the private part of System, where they
-- can be accessed using the special circuitry in the Targparm unit
-- whose source should be consulted for more detailed descriptions
-- of the individual switch values.
Backend_Divide_Checks : constant Boolean := False;
Backend_Overflow_Checks : constant Boolean := True;
Command_Line_Args : constant Boolean := False;
Configurable_Run_Time : constant Boolean := False;
Denorm : constant Boolean := True;
Duration_32_Bits : constant Boolean := False;
Exit_Status_Supported : constant Boolean := True;
Machine_Overflows : constant Boolean := False;
Machine_Rounds : constant Boolean := True;
Preallocated_Stacks : constant Boolean := False;
-- MPC8548ECE Chip Errata Rev 8: signed zero not reliable
Signed_Zeros : constant Boolean := False;
Stack_Check_Default : constant Boolean := False;
Stack_Check_Probes : constant Boolean := True;
Stack_Check_Limits : constant Boolean := False;
Support_Aggregates : constant Boolean := True;
Support_Composite_Assign : constant Boolean := True;
Support_Composite_Compare : constant Boolean := True;
Support_Long_Shifts : constant Boolean := True;
Always_Compatible_Rep : constant Boolean := False;
Suppress_Standard_Library : constant Boolean := False;
Use_Ada_Main_Program_Name : constant Boolean := True;
Frontend_Exceptions : constant Boolean := False;
ZCX_By_Default : constant Boolean := True;
Executable_Extension : constant String := ".out";
end System;
|
GPUWorks/lumen2 | Ada | 11,217 | ads |
-- Lumen.Window -- Create and destroy native windows and associated OpenGL
-- rendering contexts
--
-- Chip Richards, NiEstu, Phoenix AZ, Spring 2010
-- This code is covered by the ISC License:
--
-- Copyright © 2010, NiEstu
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- The software is provided "as is" and the author disclaims all warranties
-- with regard to this software including all implied warranties of
-- merchantability and fitness. In no event shall the author be liable for any
-- special, direct, indirect, or consequential damages or any damages
-- whatsoever resulting from loss of use, data or profits, whether in an
-- action of contract, negligence or other tortious action, arising out of or
-- in connection with the use or performance of this software.
with Lumen.Events; use Lumen.Events;
with Ada.Calendar;
package Lumen.Window is
-- A time that won't ever happen during the execution of a Lumen app
Never : constant Ada.Calendar.Time :=
Ada.Calendar.Time_Of (Year => Ada.Calendar.Year_Number'First,
Month => Ada.Calendar.Month_Number'First,
Day => Ada.Calendar.Day_Number'First);
-- Exceptions defined by this package
FailedToCreateContext : exception;
-- The types of events that can be reported
type Event_Type is (Unknown_Event,
Key_Press, Key_Release,
Button_Press, Button_Release, Pointer_Motion,
Enter_Window, Leave_Window, Focus_In, Focus_Out,
Exposed, Hidden, Resized, Close_Window);
-- Raw keycode, not much use except at the very lowest level
type Raw_Keycode is mod 2 ** Integer'Size;
-- Rendering context's color depth
type Color_Depth is (Pseudo_Color, True_Color);
type Button_Enum is (Button_1, Button_2, Button_3, Button_4,
Button_5, Button_6, Button_7, Button_8, Button_9);
type Button_Set is array(Button_Enum) of Boolean;
NoButtons : constant Button_Set := (others => False);
type Event_Mouse_Down is
access procedure
(X : Integer;
Y : Integer;
Button : Button_Enum;
Modifiers : Modifier_Set);
type Event_Mouse_Up is
access procedure
(X : Integer;
Y : Integer;
Button : Button_Enum;
Modifiers : Modifier_Set);
type Event_Mouse_Move is
access procedure
(X : Integer;
Y : Integer;
Modifiers : Modifier_Set);
type Event_Key_Press is
access procedure
(Category : Key_Category;
Symbol : Key_Symbol;
Modifiers : Modifier_Set);
type Event_Key_Release is
access procedure
(Category : Key_Category;
Symbol : Key_Symbol;
Modifiers : Modifier_Set);
type Event_Character is
access procedure
(Char : String;
Modifiers : Modifier_Set);
type Event_Exposed is
access procedure
(Top : Integer;
Left : Integer;
Height : Natural;
Width : Natural);
type Event_Resize is
access procedure
(Height : Integer;
Width : Integer);
type Window_Public is tagged
record
-- Public for Lumen-Events-Animate
Prior_Frame : Ada.Calendar.Time := Never;
SPF : Duration := 0.0;
App_Frames : Long_Integer := 0;
Last_Frames : Long_Integer := 0;
Looping : Boolean := True;
App_Start : Ada.Calendar.Time := Never;
Last_Start : Ada.Calendar.Time := Never;
-- Really Public
Mouse_Down : Event_Mouse_Down := null;
Mouse_Up : Event_Mouse_Up := null;
Mouse_Move : Event_Mouse_Move := null;
Key_Press : Event_Key_Press := null;
Key_Release : Event_Key_Release := null;
Character : Event_Character := null;
Exposed : Event_Exposed := null;
Resize : Event_Resize := null;
end record;
type Window_Type is new Window_Public with private;
type Window_Handle is access all Window_Type'Class;
-- Null window; in X, this means the root window is the parent
No_Window : constant Window_Handle := null;
-- Local exceptions raised by these procedures
Connection_Failed : exception; -- can't connect to X server
Context_Failed : exception; -- can't create or attach OpenGL context
Not_Available : exception; -- can't find a visual with given attributes
-- format of explicit visual ID (LUMEN_VISUAL_ID) is invalid
Invalid_ID : exception;
type Context_Attributes is
record
Red_Size : Integer;
Green_Size : Integer;
Blue_Size : Integer;
Alpha_Size : Integer;
Depth_Size : Integer;
Stencil_Size : Integer;
end record;
Default_Context_Attributes : constant Context_Attributes:=
(Red_Size => 8,
Green_Size => 8,
Blue_Size => 8,
Alpha_Size => 8,
Depth_Size => 24,
Stencil_Size => 8);
-- Create a native window, with defaults for configuration intended to
-- create a "usable" window. Details about the parameters are:
--
-- Win: Object into which the new window's handle will be stored.
--
-- Parent: Handle of an existing window that will act as the new window's
-- parent, or No_Window, meaning an independent top-level window.
--
-- Width, Height: Window dimensions in pixels.
--
-- Events: Set of events this window wishes to receive.
--
-- Name: Name associated with new window, often displayed in the window's
-- title bar. If blank, the executable's filename is used.
--
-- Icon_Name: Name associated with the window's icon. If blank, the
-- executable's filename is used.
--
-- Class_Name, Instance_Name: Together these make up the window's "class".
-- If blank, the class name is set to the executable's filename with
-- initial capitalization; the instance name is set to the executable's
-- filename.
--
-- Context: An existing GL rendering context to be used in the new window,
-- or No_Context, meaning a new context is created for the window.
--
-- Depth: The color depth of the GL rendering context, either true-color or
-- indexed/pseudo-color.
--
-- Direct: Whether you want direct rendering or server-based rendering.
--
-- Animated: Whether the GL rendering context will be double-buffered, thus
-- allowing smooth animation.
--
-- Attributes: The various graphic display ("visual") attributes which can
-- be set. The defaults work for most modern systems.
procedure Create (Win : in out Window_Handle;
Parent : in Window_Handle := No_Window;
Width : in Natural := 400;
Height : in Natural := 400;
Name : in String := "";
Icon_Name : in String := "";
Class_Name : in String := "";
Instance_Name : in String := "";
Depth : in Color_Depth := True_Color;
Direct : in Boolean := True;
Animated : in Boolean := True;
Attributes : in Context_Attributes :=
Default_Context_Attributes);
-- Destroy a native window, including its current rendering context.
procedure Destroy (Win : in out Window_Handle);
-- Set various textual names associated with a window. Null string means
-- leave the current value unchanged;
procedure Set_Names (Win : in Window_Handle;
Name : in String := "";
Icon_Name : in String := "";
Class_Name : in String := "";
Instance_Name : in String := "");
-- Select a window to use for subsequent OpenGL calls
procedure Make_Current (Win : in Window_Handle);
-- Promotes the back buffer to front; only valid if the window is double
-- buffered, meaning Animated was true when the window was created. Useful
-- for smooth animation.
procedure Swap (Win : in Window_Handle);
-- Return current window width
function Width (Win : in Window_Handle) return Natural;
-- Return current window width
function Height (Win : in Window_Handle) return Natural;
-- Resize given window to particular size.
procedure Resize (Win : in Window_Handle;
Width : in Positive;
Height : in Positive);
-- Move mouse pointer to given position in given window.
-- Doesn't expose window. NOTE: Should be said window exposed or not?
-- If coordinate is outside said window then pointer will be moved to
-- the edge of window.
-- Point of origin (0, 0) is in lower-left corner (just like in OpenGL).
procedure Warp_Pointer (Win : in Window_Handle;
X : in Natural;
Y : in Natural);
-- Get current coordinates of mouse pointer relative to point of origin
-- of given window.
-- Point of origin (0, 0) is in lower-left corner (just like in OpenGL).
procedure Get_Pointer (Win : in Window_Handle;
X : out Integer;
Y : out Integer;
Modifiers : out Modifier_Set);
-- Move window to specified position on screen.
-- Point of origin is in top-left due to most of windowing systems placing
-- it there - and this one procedure is working in the context of windowing
-- system.
procedure Move_Window (Win : in Window_Handle;
X : in Natural;
Y : in Natural);
-- Raise or Lower window. NOTE: This is not minimize/maximize - just makes
-- given window on top/bottom of window stack (thus if Win is on layer over
-- some other window it will be on bottom layer after Lower_Window. Inverse
-- happens for Raise_Window).
procedure Raise_Window (Win : in Window_Handle);
procedure Lower_Window (Win : in Window_Handle);
-- All event processing is done in this call
-- Events are reported by CallBacks (see Window_Type in lumen.ads)
function Process_Events (Win : in Window_Handle)
return Boolean;
---------------------------------------------------------------------------
private
type Window_Type is new Window_Public with
record
Height : Natural;
Width : Natural;
end record;
end Lumen.Window;
|
shintakezou/langkit | Ada | 6,097 | adb | with Ada.Text_IO; use Ada.Text_IO;
with Langkit_Support.Text; use Langkit_Support.Text;
with Libfoolang.Analysis; use Libfoolang.Analysis;
with Libfoolang.Common; use Libfoolang.Common;
with Libfoolang.Introspection; use Libfoolang.Introspection;
with Libfoolang.Rewriting; use Libfoolang.Rewriting;
with Process_Apply;
procedure Rewrite is
Buffer : constant String :=
("def a = 1" & ASCII.LF
& "def b = (2 + a) + 3" & ASCII.LF
& "def c = a + b" & ASCII.LF
& "def d = 4" & ASCII.LF
& "def e = 5" & ASCII.LF);
procedure Try (Label : String; Proc : access procedure);
function Create_Def
(Name : Text_Type;
Expr : Node_Rewriting_Handle)
return Node_Rewriting_Handle;
procedure Check_Diagnostics (U : Analysis_Unit);
---------
-- Try --
---------
procedure Try (Label : String; Proc : access procedure) is
begin
Put_Line (Label & "...");
Proc.all;
Put_Line (" Done with no precondition failure");
exception
when Libfoolang.Common.Precondition_Failure =>
Put_Line (" Got a precondition failure");
end Try;
-----------------------
-- Check_Diagnostics --
-----------------------
procedure Check_Diagnostics (U : Analysis_Unit) is
begin
if Has_Diagnostics (U) then
Put_Line ("Errors in " & Get_Filename (U) & ":");
for D of Diagnostics (U) loop
Put_Line (Format_GNU_Diagnostic (U, D));
end loop;
return;
end if;
end Check_Diagnostics;
Ctx : constant Analysis_Context := Create_Context;
U1 : constant Analysis_Unit := Get_From_Buffer
(Ctx, "u1.txt", Buffer => Buffer);
U2 : constant Analysis_Unit := Get_From_Buffer
(Ctx, "u2.txt", Buffer => "def z = 100");
RH : Rewriting_Handle;
N : Node_Rewriting_Handle;
----------------
-- Create_Def --
----------------
function Create_Def
(Name : Text_Type;
Expr : Node_Rewriting_Handle)
return Node_Rewriting_Handle
is
Name_Node : constant Node_Rewriting_Handle :=
Create_Token_Node (RH, Foo_Name, Name);
begin
return Create_Def (RH, Name_Node, No_Node_Rewriting_Handle, Expr);
end Create_Def;
begin
Check_Diagnostics (U1);
Check_Diagnostics (U2);
RH := Start_Rewriting (Ctx);
N := Handle (Root (U1));
declare
procedure Set_Tied_Child;
procedure Create_Error_Node;
procedure Create_Regular_Error_Node;
----------
-- Proc --
----------
procedure Set_Tied_Child is
begin
Set_Child (N, 2, Child (N, 3));
end Set_Tied_Child;
-----------------------
-- Create_Error_Node --
-----------------------
procedure Create_Error_Node is
begin
N := Create_Node (RH, Foo_Error_Def);
end Create_Error_Node;
-------------------------------
-- Create_Regular_Error_Node --
-------------------------------
procedure Create_Regular_Error_Node is
begin
N := Create_Regular_Node (RH, Foo_Error_Def, (1 .. 0 => <>));
end Create_Regular_Error_Node;
begin
Try ("Try assigning a child that is already tied to a tree",
Set_Tied_Child'Access);
Try ("Try creating an error node (Create_Node)",
Create_Error_Node'Access);
Try ("Try creating an error node (Create_Regular_Node)",
Create_Regular_Error_Node'Access);
New_Line;
Put_Line ("Replace the middle definition (b) with a clone of the last"
& " definition (c)");
Set_Child (N, 2, Clone (Child (N, 3)));
end;
New_Line;
Put_Line ("Swap first and fourth defs");
declare
N1 : constant Node_Rewriting_Handle := Child (N, 1);
N4 : constant Node_Rewriting_Handle := Child (N, 4);
begin
if not Tied (N1) then
raise Program_Error;
end if;
if not Tied (N4) then
raise Program_Error;
end if;
Set_Child (N, 1, No_Node_Rewriting_Handle);
Set_Child (N, 4, No_Node_Rewriting_Handle);
if Tied (N1) then
raise Program_Error;
end if;
if Tied (N4) then
raise Program_Error;
end if;
Set_Child (N, 1, N4);
Set_Child (N, 4, N1);
if not Tied (N1) then
raise Program_Error;
end if;
if not Tied (N4) then
raise Program_Error;
end if;
end;
New_Line;
Put_Line ("Replace the expression of the fifth definition");
declare
Nested_Expr : constant Node_Rewriting_Handle := Create_Paren_Expr
(RH, Create_Plus
(RH,
Create_Token_Node (RH, Foo_Literal, "5"),
Create_Ref (RH, Create_Token_Node (RH, Foo_Name, "c"))));
Top_Expr : constant Node_Rewriting_Handle := Create_Paren_Expr
(RH, Create_Plus
(RH,
Create_Ref (RH, Create_Token_Node (RH, Foo_Name, "d")),
Nested_Expr));
Fifth_Child : constant Node_Rewriting_Handle := Child (N, 5);
begin
Set_Child
(Fifth_Child,
Index (Kind (Fifth_Child), Def_F_Expr),
Top_Expr);
end;
New_Line;
Put_Line ("Replace the root of unit 2");
declare
New_Root : constant Node_Rewriting_Handle :=
Create_Node (RH, Foo_Foo_Node_List);
Expr_1 : constant Node_Rewriting_Handle :=
Create_Token_Node (RH, Foo_Literal, "111");
Expr_2 : constant Node_Rewriting_Handle :=
Create_Token_Node (RH, Foo_Literal, "222");
begin
Append_Child (New_Root, Create_Def ("zz", Expr_1));
Append_Child (New_Root, Create_Def ("yy", Expr_2));
Replace (Expr_2, Create_Token_Node (RH, Foo_Literal, "333"));
Replace (Handle (Root (U2)), New_Root);
end;
New_Line;
Put_Line ("Applying the diff...");
Process_Apply (RH);
New_Line;
Put_Line ("u1.txt:");
Root (U1).Print (Show_Slocs => False);
New_Line;
Put_Line ("u2.txt:");
Root (U2).Print (Show_Slocs => False);
Put_Line ("rewrite.adb: Done.");
end Rewrite;
|
reznikmm/matreshka | Ada | 3,764 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with ODF.Constants;
package body Matreshka.ODF_Attributes.FO.Border_Right is
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant FO_Border_Right_Node)
return League.Strings.Universal_String is
begin
return ODF.Constants.Border_Right_Name;
end Get_Local_Name;
end Matreshka.ODF_Attributes.FO.Border_Right;
|
gshrikant/bbqueue-spark | Ada | 4,466 | adb | with Ada.Text_IO; use Ada.Text_IO;
with System.Storage_Elements; use System.Storage_Elements;
with BBqueue;
with BBqueue.Buffers;
with System; use System;
procedure Main_Buffer
with SPARK_Mode
is
use type BBqueue.Result_Kind;
Q : aliased BBqueue.Buffers.Buffer (35);
procedure Fill (WG : BBqueue.Buffers.Write_Grant;
Val : Storage_Element)
with Pre => BBqueue.Buffers.State (WG) = BBqueue.Valid;
procedure Fill_With_CB (Size : BBqueue.Count;
Val : Storage_Element);
procedure Print_Content (RG : BBqueue.Buffers.Read_Grant)
with Pre => BBqueue.Buffers.State (RG) = BBqueue.Valid;
procedure Print_Content_With_CB;
----------
-- Fill --
----------
procedure Fill (WG : BBqueue.Buffers.Write_Grant;
Val : Storage_Element)
is
pragma SPARK_Mode (Off);
S : constant BBqueue.Buffers.Slice_Rec := BBqueue.Buffers.Slice (WG);
Arr : Storage_Array (1 .. S.Length) with Address => S.Addr;
begin
Put_Line ("Fill" & S.Length'Img & " bytes.");
Arr := (others => Val);
end Fill;
------------------
-- Fill_With_CB --
------------------
procedure Fill_With_CB (Size : BBqueue.Count; Val : Storage_Element) is
pragma SPARK_Mode (Off);
procedure Process_Write (Data : out Storage_Array; To_Commit : out BBqueue.Count);
procedure Process_Write (Data : out Storage_Array; To_Commit : out BBqueue.Count) is
begin
Put_Line ("Fill" & Data'Length'Img & " bytes.");
Data := (others => Val);
To_Commit := Data'Length;
end Process_Write;
procedure Write is new BBqueue.Buffers.Write_CB (Process_Write);
Result : BBqueue.Result_Kind;
begin
Write (Q, Size, Result);
if Result /= BBqueue.Valid then
Put_Line ("Write failed: " & Result'Img);
end if;
end Fill_With_CB;
-------------------
-- Print_Content --
-------------------
procedure Print_Content (RG : BBqueue.Buffers.Read_Grant) is
pragma SPARK_Mode (Off);
S : constant BBqueue.Buffers.Slice_Rec := BBqueue.Buffers.Slice (RG);
Arr : Storage_Array (1 .. S.Length) with Address => S.Addr;
begin
Put ("Print" & S.Length'Img & " bytes -> ");
for Elt of Arr loop
Put (Elt'Img);
end loop;
New_Line;
end Print_Content;
---------------------------
-- Print_Content_With_CB --
---------------------------
procedure Print_Content_With_CB is
procedure Process_Read (Data : Storage_Array; To_Release : out BBqueue.Count);
procedure Process_Read (Data : Storage_Array; To_Release : out BBqueue.Count) is
begin
Put ("Print" & Data'Length'Img & " bytes -> ");
for Elt of Data loop
Put (Elt'Img);
end loop;
New_Line;
To_Release := Data'Length;
end Process_Read;
procedure Read is new BBqueue.Buffers.Read_CB (Process_Read);
Result : BBqueue.Result_Kind;
begin
Read (Q, Result);
if Result /= BBqueue.Valid then
Put_Line ("Read failed: " & Result'Img);
end if;
end Print_Content_With_CB;
WG : BBqueue.Buffers.Write_Grant := BBqueue.Buffers.Empty;
RG : BBqueue.Buffers.Read_Grant := BBqueue.Buffers.Empty;
V : Storage_Element := 1;
begin
for X in 1 .. 4 loop
Put_Line ("-- Loop" & X'Img & " --");
BBqueue.Buffers.Grant (Q, WG, 10);
if BBqueue.Buffers.State (WG) /= BBqueue.Valid then
exit;
end if;
Put_Line ("BBqueue.Buffers.Grant (Q, 10) -> ");
Put_Line ("Fill (WG, " & V'Img & ")");
Fill (WG, V);
V := V + 1;
BBqueue.Buffers.Commit (Q, WG, 10);
Put_Line ("BBqueue.Buffers.Commit (WG, 10); ->");
BBqueue.Buffers.Read (Q, RG);
if BBqueue.Buffers.State (RG) /= BBqueue.Valid then
exit;
end if;
Put ("BBqueue.Buffers.Read (Q, RG); -> ");
Print_Content (RG);
BBqueue.Buffers.Release (Q, RG);
Put_Line ("BBqueue.Buffers.Release (Q, RG); -> ");
pragma Assert (BBqueue.Buffers.State (WG) = BBqueue.Empty);
pragma Assert (BBqueue.Buffers.State (RG) = BBqueue.Empty);
end loop;
for X in 5 .. 7 loop
Put_Line ("-- Loop" & X'Img & " with callbacks --");
Fill_With_CB (5, V);
Fill_With_CB (5, V + 1);
V := V + 1;
Print_Content_With_CB;
Print_Content_With_CB;
end loop;
end Main_Buffer;
|
RREE/build-avr-ada-toolchain | Ada | 8,449 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . U N S I G N E D _ T Y P E S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2007, 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. --
-- --
-- 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 was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package contains definitions of standard unsigned types that
-- correspond in size to the standard signed types declared in Standard.
-- and (unlike the types in Interfaces) have corresponding names. It
-- also contains some related definitions for other specialized types
-- used by the compiler in connection with packed array types.
package System.Unsigned_Types is
pragma Pure;
type Short_Short_Unsigned is mod 2 ** Short_Short_Integer'Size;
type Short_Unsigned is mod 2 ** Short_Integer'Size;
type Unsigned is mod 2 ** Integer'Size;
type Long_Unsigned is mod 2 ** Long_Integer'Size;
type Long_Long_Unsigned is mod 2 ** Long_Long_Integer'Size;
type Float_Unsigned is mod 2 ** Float'Size;
-- Used in the implementation of Is_Negative intrinsic (see Exp_Intr)
type Packed_Byte is mod 2 ** 8;
for Packed_Byte'Size use 8;
-- Component type for Packed_Bytes array
type Packed_Bytes1 is array (Natural range <>) of Packed_Byte;
for Packed_Bytes1'Alignment use 1;
for Packed_Bytes1'Component_Size use Packed_Byte'Size;
-- This is the type used to implement packed arrays where no alignment
-- is required. This includes the cases of 1,2,4 (where we use direct
-- masking operations), and all odd component sizes (where the clusters
-- are not aligned anyway, see, e.g. System.Pack_07 in file s-pack07
-- for details.
type Packed_Bytes2 is new Packed_Bytes1;
-- for Packed_Bytes2'Alignment use 2;
for Packed_Bytes2'Alignment use 1; -- AVR has max alignment = 1
-- This is the type used to implement packed arrays where an alignment
-- of 2 (is possible) is helpful for maximum efficiency of the get and
-- set routines in the corresponding library unit. This is true of all
-- component sizes that are even but not divisible by 4 (other than 2 for
-- which we use direct masking operations). In such cases, the clusters
-- can be assumed to be 2-byte aligned if the array is aligned. See for
-- example System.Pack_10 in file s-pack10).
type Packed_Bytes4 is new Packed_Bytes1;
for Packed_Bytes4'Alignment use Integer'Min (4, Standard'Maximum_Alignment);
-- This is the type used to implement packed arrays where an alignment
-- of 4 (if possible) is helpful for maximum efficiency of the get and
-- set routines in the corresponding library unit. This is true of all
-- component sizes that are divisible by 4 (other than powers of 2, which
-- are either handled by direct masking or not packed at all). In such
-- cases the clusters can be assumed to be 4-byte aligned if the array
-- is aligned (see System.Pack_12 in file s-pack12 as an example).
type Bits_1 is mod 2**1;
type Bits_2 is mod 2**2;
type Bits_4 is mod 2**4;
-- Types used for packed array conversions
subtype Bytes_F is Packed_Bytes4 (1 .. Float'Size / 8);
-- Type used in implementation of Is_Negative intrinsic (see Exp_Intr)
function Shift_Left
(Value : Short_Short_Unsigned;
Amount : Natural) return Short_Short_Unsigned;
function Shift_Right
(Value : Short_Short_Unsigned;
Amount : Natural) return Short_Short_Unsigned;
function Shift_Right_Arithmetic
(Value : Short_Short_Unsigned;
Amount : Natural) return Short_Short_Unsigned;
function Rotate_Left
(Value : Short_Short_Unsigned;
Amount : Natural) return Short_Short_Unsigned;
function Rotate_Right
(Value : Short_Short_Unsigned;
Amount : Natural) return Short_Short_Unsigned;
function Shift_Left
(Value : Short_Unsigned;
Amount : Natural) return Short_Unsigned;
function Shift_Right
(Value : Short_Unsigned;
Amount : Natural) return Short_Unsigned;
function Shift_Right_Arithmetic
(Value : Short_Unsigned;
Amount : Natural) return Short_Unsigned;
function Rotate_Left
(Value : Short_Unsigned;
Amount : Natural) return Short_Unsigned;
function Rotate_Right
(Value : Short_Unsigned;
Amount : Natural) return Short_Unsigned;
function Shift_Left
(Value : Unsigned;
Amount : Natural) return Unsigned;
function Shift_Right
(Value : Unsigned;
Amount : Natural) return Unsigned;
function Shift_Right_Arithmetic
(Value : Unsigned;
Amount : Natural) return Unsigned;
function Rotate_Left
(Value : Unsigned;
Amount : Natural) return Unsigned;
function Rotate_Right
(Value : Unsigned;
Amount : Natural) return Unsigned;
function Shift_Left
(Value : Long_Unsigned;
Amount : Natural) return Long_Unsigned;
function Shift_Right
(Value : Long_Unsigned;
Amount : Natural) return Long_Unsigned;
function Shift_Right_Arithmetic
(Value : Long_Unsigned;
Amount : Natural) return Long_Unsigned;
function Rotate_Left
(Value : Long_Unsigned;
Amount : Natural) return Long_Unsigned;
function Rotate_Right
(Value : Long_Unsigned;
Amount : Natural) return Long_Unsigned;
function Shift_Left
(Value : Long_Long_Unsigned;
Amount : Natural) return Long_Long_Unsigned;
function Shift_Right
(Value : Long_Long_Unsigned;
Amount : Natural) return Long_Long_Unsigned;
function Shift_Right_Arithmetic
(Value : Long_Long_Unsigned;
Amount : Natural) return Long_Long_Unsigned;
function Rotate_Left
(Value : Long_Long_Unsigned;
Amount : Natural) return Long_Long_Unsigned;
function Rotate_Right
(Value : Long_Long_Unsigned;
Amount : Natural) return Long_Long_Unsigned;
pragma Import (Intrinsic, Shift_Left);
pragma Import (Intrinsic, Shift_Right);
pragma Import (Intrinsic, Shift_Right_Arithmetic);
pragma Import (Intrinsic, Rotate_Left);
pragma Import (Intrinsic, Rotate_Right);
end System.Unsigned_Types;
|
reznikmm/matreshka | Ada | 3,729 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Table_Cell_Address_Attributes is
pragma Preelaborate;
type ODF_Table_Cell_Address_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Table_Cell_Address_Attribute_Access is
access all ODF_Table_Cell_Address_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Table_Cell_Address_Attributes;
|
sungyeon/drake | Ada | 818 | ads | pragma License (Unrestricted);
-- implementation unit specialized for Windows
with C.windef;
package System.Native_Time is
pragma Preelaborate;
-- representation
type Nanosecond_Number is
range -(2 ** (Duration'Size - 1)) .. 2 ** (Duration'Size - 1) - 1;
for Nanosecond_Number'Size use Duration'Size;
-- convert time span
function To_Duration (D : C.windef.FILETIME) return Duration;
pragma Pure_Function (To_Duration);
-- for delay
procedure Simple_Delay_For (D : Duration);
type Delay_For_Handler is access procedure (D : Duration);
pragma Favor_Top_Level (Delay_For_Handler);
-- equivalent to Timed_Delay (s-soflin.ads)
Delay_For_Hook : not null Delay_For_Handler := Simple_Delay_For'Access;
procedure Delay_For (D : Duration);
end System.Native_Time;
|
AdaCore/libadalang | Ada | 50 | ads | package Pkg is
type T is new Boolean;
end Pkg;
|
stcarrez/ada-util | Ada | 2,549 | adb | -----------------------------------------------------------------------
-- util-blobs -- Binary data content with reference counting
-- Copyright (C) 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package body Util.Blobs is
use Ada.Streams;
-- ------------------------------
-- Create a blob with an allocated buffer of <b>Size</b> bytes.
-- ------------------------------
function Create_Blob (Size : in Natural) return Blob_Ref is
B : constant Blob_Access := new Blob '(Refs.Ref_Entity with
Len => Stream_Element_Offset (Size),
others => <>);
begin
return Blob_References.Create (B);
end Create_Blob;
-- ------------------------------
-- Create a blob initialized with the given data buffer.
-- ------------------------------
function Create_Blob (Data : in Ada.Streams.Stream_Element_Array) return Blob_Ref is
B : constant Blob_Access := new Blob '(Refs.Ref_Entity with
Len => Data'Length,
Data => Data);
begin
return Blob_References.Create (B);
end Create_Blob;
-- ------------------------------
-- Create a blob initialized with the given data buffer.
-- ------------------------------
function Create_Blob (Content : in String) return Blob_Ref is
Data : Ada.Streams.Stream_Element_Array (1 .. Content'Length);
for Data'Address use Content'Address;
begin
return Create_Blob (Data);
end Create_Blob;
-- ------------------------------
-- Return a null blob.
-- ------------------------------
function Null_Blob return Blob_Ref is
Null_Blob_Instance : Blob_Ref;
begin
return Null_Blob_Instance;
end Null_Blob;
end Util.Blobs;
|
tum-ei-rcs/StratoX | Ada | 6,099 | adb | -- Institution: Technische Universitaet Muenchen
-- Department: Realtime Computer Systems (RCS)
-- Project: StratoX
--
-- Authors: Martin Becker ([email protected])
with HIL.Buzzer;
with Ada.Real_Time; use Ada.Real_Time;
with Types;
-- @summary
-- Interface to use a buzzer/beeper.
package body Buzzer_Manager with SPARK_Mode is
type state is (BOFF, BINIT, BDUTY, BWAIT);
--------------------
-- internal state
--------------------
cur_state : state := BOFF;
cur_length_ms : Natural := 100;
cur_pause_ms : Natural := 1900;
cur_freq : Frequency_Type := 1000.0 * Hertz;
cur_reps : Natural := 0;
infinite : Boolean := False;
t_next : Ada.Real_Time.Time;
is_configured : Boolean := False;
--------------
-- specs
--------------
procedure Change_State (newstate : state; now : Ada.Real_Time.Time);
procedure Set_Freq (f : in Frequency_Type) with Pre => Valid_Frequency (f);
procedure Enable_Statemachine;
procedure Disable_Statemachine;
-------------------------
-- Enable_Statemachine --
-------------------------
procedure Enable_Statemachine is
begin
if is_configured and cur_state = BOFF then
cur_state := BINIT;
t_next := Ada.Real_Time.Clock;
end if;
end Enable_Statemachine;
------------------
-- Change_State --
------------------
procedure Change_State (newstate : state; now : Ada.Real_Time.Time) is
cand_newstate : state := newstate;
begin
if cur_state /= newstate then
case newstate is
when BDUTY =>
if not infinite then
-- finite mode...countdown
if cur_reps > 0 then
cur_reps := cur_reps - 1;
HIL.Buzzer.Enable;
else
HIL.Buzzer.Disable;
cand_newstate := BOFF;
end if;
else
-- infinite mode
HIL.Buzzer.Enable;
end if;
t_next := now + Milliseconds (cur_length_ms);
when others =>
HIL.Buzzer.Disable;
t_next := now + Milliseconds (cur_pause_ms);
end case;
cur_state := cand_newstate;
end if;
end Change_State;
----------
-- Tick --
----------
procedure Tick is
next_state : state;
now : Ada.Real_Time.Time;
begin
if cur_state /= BOFF then
now := Ada.Real_Time.Clock;
if now >= t_next then
case cur_state is
when BWAIT => next_state := BDUTY;
when BDUTY => next_state := BWAIT;
when others => next_state := BDUTY;
end case;
Change_State (next_state, now);
end if;
end if;
end Tick;
----------------
-- Initialize --
----------------
procedure Initialize is
begin
HIL.Buzzer.Initialize;
Reconfigure_Buzzer; -- apply defaults
HIL.Buzzer.Disable;
end Initialize;
--------------------------
-- Disable_Statemachine --
--------------------------
procedure Disable_Statemachine is
now : constant Ada.Real_Time.Time := Ada.Real_Time.Clock;
begin
infinite := False;
Change_State (BOFF, now);
end Disable_Statemachine;
------------------------
-- Reconfigure_Buzzer --
------------------------
procedure Reconfigure_Buzzer is
begin
if HIL.Buzzer.Valid_Frequency (cur_freq) then
HIL.Buzzer.Set_Frequency (cur_freq);
is_configured := True;
end if;
end Reconfigure_Buzzer;
-- function Tone_To_Frequency (tone : Tone_Type) return Frequency_Type is
-- f : Frequency_Type;
-- subtype octave_modifier is Unit_Type;
-- o : constant octave_modifier := octave_modifier (tone.octave - 2);
-- begin
-- -- frequencies for octave 3 (small octave)
-- case tone.name is
-- when 'c' => f := 130.813 * Hertz;
-- when 'd' => f := 146.832 * Hertz;
-- when 'e' => f := 164.814 * Hertz;
-- when 'f' => f := 174.614 * Hertz;
-- when 'g' => f := 195.998 * Hertz;
-- when 'a' => f := 220.000 * Hertz;
-- when 'b' => f := 246.942 * Hertz;
-- end case;
-- -- now multiply with octave above 3
-- f := f * o;
-- return f;
-- end Tone_To_Frequency;
--
-- procedure Set_Tone (t : Tone_Type) is
-- f : constant Frequency_Type := Tone_To_Frequency (t);
-- begin
-- Set_Freq (f);
-- end Set_Tone;
--------------
-- Set_Freq --
--------------
procedure Set_Freq (f : in Frequency_Type) is
begin
cur_freq := f;
Reconfigure_Buzzer;
end Set_Freq;
----------
-- Beep --
----------
procedure Beep
(f : in Frequency_Type;
Reps : Natural;
Period : Time_Type;
Length : in Time_Type)
is
function Sat_Sub_Time is new
Units.Saturated_Subtraction (Time_Type);
function To_Millisec (t : Time_Type) return Natural;
function To_Millisec (t : Time_Type) return Natural is
ms : Float;
begin
if abs (Float (t)) >= Float'Last / 1000.0 then
ms := Float'Last;
else
ms := Float (t) * 1000.0;
end if;
return Types.Sat_Cast_Natural (ms);
end To_Millisec;
begin
if not Valid_Frequency (f) or
Period <= Length or
Period = 0.0 * Second or
Length = 0.0 * Second
then
Disable_Statemachine;
return;
end if;
cur_reps := Reps;
infinite := (Reps = 0);
declare
cur_pause : constant Time_Type := Sat_Sub_Time (Period, Length);
cur_length : constant Time_Type := Length;
begin
cur_pause_ms := To_Millisec (cur_pause);
cur_length_ms := To_Millisec (cur_length);
end;
if f /= cur_freq then
Set_Freq (f);
end if;
Enable_Statemachine;
end Beep;
end Buzzer_Manager;
|
vpodzime/ada-util | Ada | 10,958 | adb | -----------------------------------------------------------------------
-- util-processes-tests - Test for processes
-- Copyright (C) 2011, 2012, 2016 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Log.Loggers;
with Util.Test_Caller;
with Util.Files;
with Util.Streams.Pipes;
with Util.Streams.Buffered;
with Util.Streams.Texts;
with Util.Systems.Os;
package body Util.Processes.Tests is
use Util.Log;
-- The logger
Log : constant Loggers.Logger := Loggers.Create ("Util.Processes.Tests");
package Caller is new Util.Test_Caller (Test, "Processes");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test Util.Processes.Is_Running",
Test_No_Process'Access);
Caller.Add_Test (Suite, "Test Util.Processes.Spawn/Wait/Get_Exit_Status",
Test_Spawn'Access);
Caller.Add_Test (Suite, "Test Util.Processes.Spawn(READ pipe)",
Test_Output_Pipe'Access);
Caller.Add_Test (Suite, "Test Util.Processes.Spawn(WRITE pipe)",
Test_Input_Pipe'Access);
Caller.Add_Test (Suite, "Test Util.Processes.Spawn/Shell(WRITE pipe)",
Test_Shell_Splitting_Pipe'Access);
pragma Warnings (Off);
if Util.Systems.Os.Directory_Separator /= '\' then
Caller.Add_Test (Suite, "Test Util.Processes.Spawn(OUTPUT redirect)",
Test_Output_Redirect'Access);
end if;
pragma Warnings (On);
Caller.Add_Test (Suite, "Test Util.Streams.Pipes.Open/Read/Close (Multi spawn)",
Test_Multi_Spawn'Access);
end Add_Tests;
-- ------------------------------
-- Tests when the process is not launched
-- ------------------------------
procedure Test_No_Process (T : in out Test) is
P : Process;
begin
T.Assert (not P.Is_Running, "Process should not be running");
T.Assert (P.Get_Pid < 0, "Invalid process id");
end Test_No_Process;
-- ------------------------------
-- Test executing a process
-- ------------------------------
procedure Test_Spawn (T : in out Test) is
P : Process;
begin
-- Launch the test process => exit code 2
P.Spawn ("bin/util_test_process");
T.Assert (P.Is_Running, "Process is running");
P.Wait;
T.Assert (not P.Is_Running, "Process has stopped");
T.Assert (P.Get_Pid > 0, "Invalid process id");
Util.Tests.Assert_Equals (T, 2, P.Get_Exit_Status, "Invalid exit status");
-- Launch the test process => exit code 0
P.Spawn ("bin/util_test_process 0 write b c d e f");
T.Assert (P.Is_Running, "Process is running");
P.Wait;
T.Assert (not P.Is_Running, "Process has stopped");
T.Assert (P.Get_Pid > 0, "Invalid process id");
Util.Tests.Assert_Equals (T, 0, P.Get_Exit_Status, "Invalid exit status");
end Test_Spawn;
-- ------------------------------
-- Test output pipe redirection: read the process standard output
-- ------------------------------
procedure Test_Output_Pipe (T : in out Test) is
P : aliased Util.Streams.Pipes.Pipe_Stream;
begin
P.Open ("bin/util_test_process 0 write b c d e f test_marker");
declare
Buffer : Util.Streams.Buffered.Buffered_Stream;
Content : Ada.Strings.Unbounded.Unbounded_String;
begin
Buffer.Initialize (null, P'Unchecked_Access, 19);
Buffer.Read (Content);
P.Close;
Util.Tests.Assert_Matches (T, "b\s+c\s+d\s+e\s+f\s+test_marker\s+", Content,
"Invalid content");
end;
T.Assert (not P.Is_Running, "Process has stopped");
Util.Tests.Assert_Equals (T, 0, P.Get_Exit_Status, "Invalid exit status");
end Test_Output_Pipe;
-- ------------------------------
-- Test shell splitting.
-- ------------------------------
procedure Test_Shell_Splitting_Pipe (T : in out Test) is
P : aliased Util.Streams.Pipes.Pipe_Stream;
begin
P.Open ("bin/util_test_process 0 write 'b c d e f' test_marker");
declare
Buffer : Util.Streams.Buffered.Buffered_Stream;
Content : Ada.Strings.Unbounded.Unbounded_String;
begin
Buffer.Initialize (null, P'Unchecked_Access, 19);
Buffer.Read (Content);
P.Close;
Util.Tests.Assert_Matches (T, "b c d e f\s+test_marker\s+", Content,
"Invalid content");
end;
T.Assert (not P.Is_Running, "Process has stopped");
Util.Tests.Assert_Equals (T, 0, P.Get_Exit_Status, "Invalid exit status");
end Test_Shell_Splitting_Pipe;
-- ------------------------------
-- Test input pipe redirection: write the process standard input
-- At the same time, read the process standard output.
-- ------------------------------
procedure Test_Input_Pipe (T : in out Test) is
P : aliased Util.Streams.Pipes.Pipe_Stream;
begin
P.Open ("bin/util_test_process 0 read -", READ_WRITE);
declare
Buffer : Util.Streams.Buffered.Buffered_Stream;
Content : Ada.Strings.Unbounded.Unbounded_String;
Print : Util.Streams.Texts.Print_Stream;
begin
-- Write on the process input stream.
Print.Initialize (P'Unchecked_Access);
Print.Write ("Write test on the input pipe");
Print.Close;
-- Read the output.
Buffer.Initialize (null, P'Unchecked_Access, 19);
Buffer.Read (Content);
-- Wait for the process to finish.
P.Close;
Util.Tests.Assert_Matches (T, "Write test on the input pipe-\s", Content,
"Invalid content");
end;
T.Assert (not P.Is_Running, "Process has stopped");
Util.Tests.Assert_Equals (T, 0, P.Get_Exit_Status, "Invalid exit status");
end Test_Input_Pipe;
-- ------------------------------
-- Test launching several processes through pipes in several threads.
-- ------------------------------
procedure Test_Multi_Spawn (T : in out Test) is
Task_Count : constant Natural := 8;
Count_By_Task : constant Natural := 10;
type State_Array is array (1 .. Task_Count) of Boolean;
States : State_Array;
begin
declare
task type Worker is
entry Start (Count : in Natural);
entry Result (Status : out Boolean);
end Worker;
task body Worker is
Cnt : Natural;
State : Boolean := True;
begin
accept Start (Count : in Natural) do
Cnt := Count;
end Start;
declare
type Pipe_Array is array (1 .. Cnt) of aliased Util.Streams.Pipes.Pipe_Stream;
Pipes : Pipe_Array;
begin
-- Launch the processes.
-- They will print their arguments on stdout, one by one on each line.
-- The expected exit status is the first argument.
for I in 1 .. Cnt loop
Pipes (I).Open ("bin/util_test_process 0 write b c d e f test_marker");
end loop;
-- Read their output
for I in 1 .. Cnt loop
declare
Buffer : Util.Streams.Buffered.Buffered_Stream;
Content : Ada.Strings.Unbounded.Unbounded_String;
begin
Buffer.Initialize (null, Pipes (I)'Unchecked_Access, 19);
Buffer.Read (Content);
Pipes (I).Close;
-- Check status and output.
State := State and Pipes (I).Get_Exit_Status = 0;
State := State and Ada.Strings.Unbounded.Index (Content, "test_marker") > 0;
end;
end loop;
exception
when E : others =>
Log.Error ("Exception raised", E);
State := False;
end;
accept Result (Status : out Boolean) do
Status := State;
end Result;
end Worker;
type Worker_Array is array (1 .. Task_Count) of Worker;
Tasks : Worker_Array;
begin
for I in Tasks'Range loop
Tasks (I).Start (Count_By_Task);
end loop;
-- Get the results (do not raise any assertion here because we have to call
-- 'Result' to ensure the thread terminates.
for I in Tasks'Range loop
Tasks (I).Result (States (I));
end loop;
-- Leaving the Worker task scope means we are waiting for our tasks to finish.
end;
for I in States'Range loop
T.Assert (States (I), "Task " & Natural'Image (I) & " failed");
end loop;
end Test_Multi_Spawn;
-- ------------------------------
-- Test output file redirection.
-- ------------------------------
procedure Test_Output_Redirect (T : in out Test) is
P : Process;
Path : constant String := Util.Tests.Get_Test_Path ("proc-output.txt");
Content : Ada.Strings.Unbounded.Unbounded_String;
begin
Util.Processes.Set_Output_Stream (P, Path);
Util.Processes.Spawn (P, "bin/util_test_process 0 write b c d e f test_marker");
Util.Processes.Wait (P);
T.Assert (not P.Is_Running, "Process has stopped");
Util.Tests.Assert_Equals (T, 0, P.Get_Exit_Status, "Process failed");
Util.Files.Read_File (Path, Content);
Util.Tests.Assert_Matches (T, ".*test_marker", Content,
"Invalid content");
Util.Processes.Set_Output_Stream (P, Path, True);
Util.Processes.Spawn (P, "bin/util_test_process 0 write appended_text");
Util.Processes.Wait (P);
Content := Ada.Strings.Unbounded.Null_Unbounded_String;
Util.Files.Read_File (Path, Content);
Util.Tests.Assert_Matches (T, ".*appended_text", Content,
"Invalid content");
Util.Tests.Assert_Matches (T, ".*test_marker.*", Content,
"Invalid content");
end Test_Output_Redirect;
end Util.Processes.Tests;
|
zhmu/ananas | Ada | 93,361 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . S O C K E T S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2001-2022, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Containers.Generic_Array_Sort;
with Ada.Exceptions; use Ada.Exceptions;
with Ada.Finalization;
with Ada.Streams; use Ada.Streams;
with Ada.Unchecked_Conversion;
with GNAT.Sockets.Thin; use GNAT.Sockets.Thin;
with GNAT.Sockets.Thin_Common; use GNAT.Sockets.Thin_Common;
with GNAT.Sockets.Linker_Options;
pragma Warnings (Off, GNAT.Sockets.Linker_Options);
-- Need to include pragma Linker_Options which is platform dependent
with GNAT.Sockets.Poll;
with System; use System;
with System.Communication; use System.Communication;
with System.CRTL; use System.CRTL;
with System.Task_Lock;
package body GNAT.Sockets is
package C renames Interfaces.C;
type IPV6_Mreq is record
ipv6mr_multiaddr : In6_Addr;
ipv6mr_interface : C.unsigned;
end record with Convention => C;
-- Record to Add/Drop_Membership for multicast in IPv6
ENOERROR : constant := 0;
Netdb_Buffer_Size : constant := SOSC.Need_Netdb_Buffer * 1024;
Need_Netdb_Lock : constant Boolean := SOSC.Need_Netdb_Lock /= 0;
-- The network database functions gethostbyname, gethostbyaddr,
-- getservbyname and getservbyport can either be guaranteed task safe by
-- the operating system, or else return data through a user-provided buffer
-- to ensure concurrent uses do not interfere.
-- Correspondence tables
Levels : constant array (Level_Type) of C.int :=
[Socket_Level => SOSC.SOL_SOCKET,
IP_Protocol_For_IP_Level => SOSC.IPPROTO_IP,
IP_Protocol_For_IPv6_Level => SOSC.IPPROTO_IPV6,
IP_Protocol_For_UDP_Level => SOSC.IPPROTO_UDP,
IP_Protocol_For_TCP_Level => SOSC.IPPROTO_TCP,
IP_Protocol_For_ICMP_Level => SOSC.IPPROTO_ICMP,
IP_Protocol_For_IGMP_Level => SOSC.IPPROTO_IGMP,
IP_Protocol_For_RAW_Level => SOSC.IPPROTO_RAW];
Modes : constant array (Mode_Type) of C.int :=
[Socket_Stream => SOSC.SOCK_STREAM,
Socket_Datagram => SOSC.SOCK_DGRAM,
Socket_Raw => SOSC.SOCK_RAW];
Shutmodes : constant array (Shutmode_Type) of C.int :=
[Shut_Read => SOSC.SHUT_RD,
Shut_Write => SOSC.SHUT_WR,
Shut_Read_Write => SOSC.SHUT_RDWR];
Requests : constant array (Request_Name) of SOSC.IOCTL_Req_T :=
[Non_Blocking_IO => SOSC.FIONBIO,
N_Bytes_To_Read => SOSC.FIONREAD];
Options : constant array (Specific_Option_Name) of C.int :=
[Keep_Alive => SOSC.SO_KEEPALIVE,
Keep_Alive_Count => SOSC.TCP_KEEPCNT,
Keep_Alive_Idle => SOSC.TCP_KEEPIDLE,
Keep_Alive_Interval => SOSC.TCP_KEEPINTVL,
Reuse_Address => SOSC.SO_REUSEADDR,
Broadcast => SOSC.SO_BROADCAST,
Send_Buffer => SOSC.SO_SNDBUF,
Receive_Buffer => SOSC.SO_RCVBUF,
Linger => SOSC.SO_LINGER,
Error => SOSC.SO_ERROR,
No_Delay => SOSC.TCP_NODELAY,
Add_Membership_V4 => SOSC.IP_ADD_MEMBERSHIP,
Drop_Membership_V4 => SOSC.IP_DROP_MEMBERSHIP,
Multicast_If_V4 => SOSC.IP_MULTICAST_IF,
Multicast_Loop_V4 => SOSC.IP_MULTICAST_LOOP,
Receive_Packet_Info => SOSC.IP_PKTINFO,
Multicast_TTL => SOSC.IP_MULTICAST_TTL,
Add_Membership_V6 => SOSC.IPV6_ADD_MEMBERSHIP,
Drop_Membership_V6 => SOSC.IPV6_DROP_MEMBERSHIP,
Multicast_If_V6 => SOSC.IPV6_MULTICAST_IF,
Multicast_Loop_V6 => SOSC.IPV6_MULTICAST_LOOP,
Multicast_Hops => SOSC.IPV6_MULTICAST_HOPS,
IPv6_Only => SOSC.IPV6_V6ONLY,
Send_Timeout => SOSC.SO_SNDTIMEO,
Receive_Timeout => SOSC.SO_RCVTIMEO,
Busy_Polling => SOSC.SO_BUSY_POLL];
-- ??? Note: for OpenSolaris, Receive_Packet_Info should be IP_RECVPKTINFO,
-- but for Linux compatibility this constant is the same as IP_PKTINFO.
Flags : constant array (0 .. 3) of C.int :=
[0 => SOSC.MSG_OOB, -- Process_Out_Of_Band_Data
1 => SOSC.MSG_PEEK, -- Peek_At_Incoming_Data
2 => SOSC.MSG_WAITALL, -- Wait_For_A_Full_Reception
3 => SOSC.MSG_EOR]; -- Send_End_Of_Record
Socket_Error_Id : constant Exception_Id := Socket_Error'Identity;
Host_Error_Id : constant Exception_Id := Host_Error'Identity;
type In_Addr_Union (Family : Family_Inet_4_6) is record
case Family is
when Family_Inet =>
In4 : In_Addr;
when Family_Inet6 =>
In6 : In6_Addr;
end case;
end record with Unchecked_Union;
-----------------------
-- Local subprograms --
-----------------------
function Resolve_Error
(Error_Value : Integer;
From_Errno : Boolean := True) return Error_Type;
-- Associate an enumeration value (error_type) to an error value (errno).
-- From_Errno prevents from mixing h_errno with errno.
function To_Name (N : String) return Name_Type;
function To_String (HN : Name_Type) return String;
-- Conversion functions
function To_Int (F : Request_Flag_Type) return C.int;
-- Return the int value corresponding to the specified flags combination
function Set_Forced_Flags (F : C.int) return C.int;
-- Return F with the bits from SOSC.MSG_Forced_Flags forced set
procedure Netdb_Lock;
pragma Inline (Netdb_Lock);
procedure Netdb_Unlock;
pragma Inline (Netdb_Unlock);
-- Lock/unlock operation used to protect netdb access for platforms that
-- require such protection.
function To_Host_Entry (E : Hostent_Access) return Host_Entry_Type;
-- Conversion function
function To_Service_Entry (E : Servent_Access) return Service_Entry_Type;
-- Conversion function
function Value (S : System.Address) return String;
-- Same as Interfaces.C.Strings.Value but taking a System.Address
function To_Timeval (Val : Timeval_Duration) return Timeval;
-- Separate Val in seconds and microseconds
function To_Duration (Val : Timeval) return Timeval_Duration;
-- Reconstruct a Duration value from a Timeval record (seconds and
-- microseconds).
function Dedot (Value : String) return String
is (if Value /= "" and then Value (Value'Last) = '.'
then Value (Value'First .. Value'Last - 1)
else Value);
-- Removes dot at the end of error message
procedure Raise_Host_Error (H_Error : Integer; Name : String);
-- Raise Host_Error exception with message describing error code (note
-- hstrerror seems to be obsolete) from h_errno. Name is the name
-- or address that was being looked up.
procedure Raise_GAI_Error (RC : C.int; Name : String);
-- Raise Host_Error with exception message in case of errors in
-- getaddrinfo and getnameinfo.
function Is_Windows return Boolean with Inline;
-- Returns True on Windows platform
procedure Narrow (Item : in out Socket_Set_Type);
-- Update Last as it may be greater than the real last socket
procedure Check_For_Fd_Set (Fd : Socket_Type);
pragma Inline (Check_For_Fd_Set);
-- Raise Constraint_Error if Fd is less than 0 or greater than or equal to
-- FD_SETSIZE, on platforms where fd_set is a bitmap.
function Connect_Socket
(Socket : Socket_Type;
Server : Sock_Addr_Type) return C.int;
pragma Inline (Connect_Socket);
-- Underlying implementation for the Connect_Socket procedures
-- Types needed for Datagram_Socket_Stream_Type
type Datagram_Socket_Stream_Type is new Root_Stream_Type with record
Socket : Socket_Type;
To : Sock_Addr_Type;
From : Sock_Addr_Type;
end record;
type Datagram_Socket_Stream_Access is
access all Datagram_Socket_Stream_Type;
procedure Read
(Stream : in out Datagram_Socket_Stream_Type;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
procedure Write
(Stream : in out Datagram_Socket_Stream_Type;
Item : Ada.Streams.Stream_Element_Array);
-- Types needed for Stream_Socket_Stream_Type
type Stream_Socket_Stream_Type is new Root_Stream_Type with record
Socket : Socket_Type;
end record;
type Stream_Socket_Stream_Access is
access all Stream_Socket_Stream_Type;
procedure Read
(Stream : in out Stream_Socket_Stream_Type;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
procedure Write
(Stream : in out Stream_Socket_Stream_Type;
Item : Ada.Streams.Stream_Element_Array);
procedure Wait_On_Socket
(Socket : Socket_Type;
Event : Poll.Wait_Event_Set;
Timeout : Selector_Duration;
Selector : access Selector_Type := null;
Status : out Selector_Status);
-- Common code for variants of socket operations supporting a timeout:
-- block in Poll.Wait on Socket for at most the indicated timeout.
-- Event parameter defines what the Poll.Wait is waiting for.
type Sockets_Library_Controller is new Ada.Finalization.Limited_Controlled
with null record;
-- This type is used to generate automatic calls to Initialize and Finalize
-- during the elaboration and finalization of this package. A single object
-- of this type must exist at library level.
function Err_Code_Image (E : Integer) return String;
-- Return the value of E surrounded with brackets
procedure Initialize (X : in out Sockets_Library_Controller);
procedure Finalize (X : in out Sockets_Library_Controller);
procedure Normalize_Empty_Socket_Set (S : in out Socket_Set_Type);
-- If S is the empty set (detected by Last = No_Socket), make sure its
-- fd_set component is actually cleared. Note that the case where it is
-- not can occur for an uninitialized Socket_Set_Type object.
function Is_Open (S : Selector_Type) return Boolean;
-- Return True for an "open" Selector_Type object, i.e. one for which
-- Create_Selector has been called and Close_Selector has not been called,
-- or the null selector.
function Create_Address
(Family : Family_Inet_4_6; Bytes : Inet_Addr_Bytes) return Inet_Addr_Type
with Inline;
-- Creates address from family and Inet_Addr_Bytes array
function Get_Bytes (Addr : Inet_Addr_Type) return Inet_Addr_Bytes
with Inline;
-- Extract bytes from address
---------
-- "+" --
---------
function "+" (L, R : Request_Flag_Type) return Request_Flag_Type is
begin
return L or R;
end "+";
--------------------
-- Abort_Selector --
--------------------
procedure Abort_Selector (Selector : Selector_Type) is
Res : C.int;
begin
if not Is_Open (Selector) then
raise Program_Error with "closed selector";
elsif Selector.Is_Null then
raise Program_Error with "null selector";
end if;
-- Send one byte to unblock select system call
Res := Signalling_Fds.Write (C.int (Selector.W_Sig_Socket));
if Res = Failure then
Raise_Socket_Error (Socket_Errno);
end if;
end Abort_Selector;
-------------------
-- Accept_Socket --
-------------------
procedure Accept_Socket
(Server : Socket_Type;
Socket : out Socket_Type;
Address : out Sock_Addr_Type)
is
Res : C.int;
Sin : aliased Sockaddr;
Len : aliased C.int := Sin'Size / 8;
begin
Res := C_Accept (C.int (Server), Sin'Address, Len'Access);
if Res = Failure then
Raise_Socket_Error (Socket_Errno);
end if;
Socket := Socket_Type (Res);
Address := Get_Address (Sin, Len);
end Accept_Socket;
-------------------
-- Accept_Socket --
-------------------
procedure Accept_Socket
(Server : Socket_Type;
Socket : out Socket_Type;
Address : out Sock_Addr_Type;
Timeout : Selector_Duration;
Selector : access Selector_Type := null;
Status : out Selector_Status)
is
begin
if Selector /= null and then not Is_Open (Selector.all) then
raise Program_Error with "closed selector";
end if;
-- Wait for socket to become available for reading
Wait_On_Socket
(Socket => Server,
Event => Poll.Input_Event,
Timeout => Timeout,
Selector => Selector,
Status => Status);
-- Accept connection if available
if Status = Completed then
Accept_Socket (Server, Socket, Address);
else
Socket := No_Socket;
end if;
end Accept_Socket;
---------------
-- Addresses --
---------------
function Addresses
(E : Host_Entry_Type;
N : Positive := 1) return Inet_Addr_Type
is
begin
return E.Addresses (N);
end Addresses;
----------------------
-- Addresses_Length --
----------------------
function Addresses_Length (E : Host_Entry_Type) return Natural is
begin
return E.Addresses_Length;
end Addresses_Length;
-------------
-- Aliases --
-------------
function Aliases
(E : Host_Entry_Type;
N : Positive := 1) return String
is
begin
return To_String (E.Aliases (N));
end Aliases;
-------------
-- Aliases --
-------------
function Aliases
(S : Service_Entry_Type;
N : Positive := 1) return String
is
begin
return To_String (S.Aliases (N));
end Aliases;
--------------------
-- Aliases_Length --
--------------------
function Aliases_Length (E : Host_Entry_Type) return Natural is
begin
return E.Aliases_Length;
end Aliases_Length;
--------------------
-- Aliases_Length --
--------------------
function Aliases_Length (S : Service_Entry_Type) return Natural is
begin
return S.Aliases_Length;
end Aliases_Length;
-----------------
-- Bind_Socket --
-----------------
procedure Bind_Socket
(Socket : Socket_Type;
Address : Sock_Addr_Type)
is
Res : C.int;
Sin : aliased Sockaddr;
Len : C.int;
begin
Set_Address (Sin'Unchecked_Access, Address, Len);
Res := C_Bind (C.int (Socket), Sin'Address, Len);
if Res = Failure then
Raise_Socket_Error (Socket_Errno);
end if;
end Bind_Socket;
----------------------
-- Check_For_Fd_Set --
----------------------
procedure Check_For_Fd_Set (Fd : Socket_Type) is
begin
-- On Windows, fd_set is a FD_SETSIZE array of socket ids:
-- no check required. Warnings suppressed because condition
-- is known at compile time.
if Is_Windows then
return;
-- On other platforms, fd_set is an FD_SETSIZE bitmap: check
-- that Fd is within range (otherwise behavior is undefined).
elsif Fd < 0 or else Fd >= SOSC.FD_SETSIZE then
raise Constraint_Error
with "invalid value for socket set: " & Image (Fd);
end if;
end Check_For_Fd_Set;
--------------------
-- Check_Selector --
--------------------
procedure Check_Selector
(Selector : Selector_Type;
R_Socket_Set : in out Socket_Set_Type;
W_Socket_Set : in out Socket_Set_Type;
Status : out Selector_Status;
Timeout : Selector_Duration := Forever)
is
E_Socket_Set : Socket_Set_Type;
begin
Check_Selector
(Selector, R_Socket_Set, W_Socket_Set, E_Socket_Set, Status, Timeout);
end Check_Selector;
procedure Check_Selector
(Selector : Selector_Type;
R_Socket_Set : in out Socket_Set_Type;
W_Socket_Set : in out Socket_Set_Type;
E_Socket_Set : in out Socket_Set_Type;
Status : out Selector_Status;
Timeout : Selector_Duration := Forever)
is
Res : C.int;
Last : C.int;
RSig : Socket_Type := No_Socket;
TVal : aliased Timeval;
TPtr : Timeval_Access;
begin
if not Is_Open (Selector) then
raise Program_Error with "closed selector";
end if;
Status := Completed;
-- No timeout or Forever is indicated by a null timeval pointer
if Timeout = Forever then
TPtr := null;
else
TVal := To_Timeval (Timeout);
TPtr := TVal'Unchecked_Access;
end if;
-- Add read signalling socket, if present
if not Selector.Is_Null then
RSig := Selector.R_Sig_Socket;
Set (R_Socket_Set, RSig);
end if;
Last := C.int'Max (C.int'Max (C.int (R_Socket_Set.Last),
C.int (W_Socket_Set.Last)),
C.int (E_Socket_Set.Last));
-- Zero out fd_set for empty Socket_Set_Type objects
Normalize_Empty_Socket_Set (R_Socket_Set);
Normalize_Empty_Socket_Set (W_Socket_Set);
Normalize_Empty_Socket_Set (E_Socket_Set);
Res :=
C_Select
(Last + 1,
R_Socket_Set.Set'Access,
W_Socket_Set.Set'Access,
E_Socket_Set.Set'Access,
TPtr);
if Res = Failure then
Raise_Socket_Error (Socket_Errno);
end if;
-- If Select was resumed because of read signalling socket, read this
-- data and remove socket from set.
if RSig /= No_Socket and then Is_Set (R_Socket_Set, RSig) then
Clear (R_Socket_Set, RSig);
Res := Signalling_Fds.Read (C.int (RSig));
if Res = Failure then
Raise_Socket_Error (Socket_Errno);
end if;
Status := Aborted;
elsif Res = 0 then
Status := Expired;
end if;
-- Update socket sets in regard to their new contents
Narrow (R_Socket_Set);
Narrow (W_Socket_Set);
Narrow (E_Socket_Set);
end Check_Selector;
-----------
-- Clear --
-----------
procedure Clear
(Item : in out Socket_Set_Type;
Socket : Socket_Type)
is
Last : aliased C.int := C.int (Item.Last);
begin
Check_For_Fd_Set (Socket);
if Item.Last /= No_Socket then
Remove_Socket_From_Set (Item.Set'Access, C.int (Socket));
Last_Socket_In_Set (Item.Set'Access, Last'Unchecked_Access);
Item.Last := Socket_Type (Last);
end if;
end Clear;
--------------------
-- Close_Selector --
--------------------
procedure Close_Selector (Selector : in out Selector_Type) is
begin
-- Nothing to do if selector already in closed state
if Selector.Is_Null or else not Is_Open (Selector) then
return;
end if;
-- Close the signalling file descriptors used internally for the
-- implementation of Abort_Selector.
Signalling_Fds.Close (C.int (Selector.R_Sig_Socket));
Signalling_Fds.Close (C.int (Selector.W_Sig_Socket));
-- Reset R_Sig_Socket and W_Sig_Socket to No_Socket to ensure that any
-- (erroneous) subsequent attempt to use this selector properly fails.
Selector.R_Sig_Socket := No_Socket;
Selector.W_Sig_Socket := No_Socket;
end Close_Selector;
------------------
-- Close_Socket --
------------------
procedure Close_Socket (Socket : Socket_Type) is
Res : C.int;
begin
Res := C_Close (C.int (Socket));
if Res = Failure then
Raise_Socket_Error (Socket_Errno);
end if;
end Close_Socket;
--------------------
-- Connect_Socket --
--------------------
function Connect_Socket
(Socket : Socket_Type;
Server : Sock_Addr_Type) return C.int
is
Sin : aliased Sockaddr;
Len : C.int;
begin
Set_Address (Sin'Unchecked_Access, Server, Len);
return C_Connect (C.int (Socket), Sin'Address, Len);
end Connect_Socket;
procedure Connect_Socket
(Socket : Socket_Type;
Server : Sock_Addr_Type)
is
begin
if Connect_Socket (Socket, Server) = Failure then
Raise_Socket_Error (Socket_Errno);
end if;
end Connect_Socket;
procedure Connect_Socket
(Socket : Socket_Type;
Server : Sock_Addr_Type;
Timeout : Selector_Duration;
Selector : access Selector_Type := null;
Status : out Selector_Status)
is
Req : Request_Type;
-- Used to set Socket to non-blocking I/O
Conn_Err : aliased Integer;
-- Error status of the socket after completion of select(2)
Res : C.int;
Conn_Err_Size : aliased C.int := Conn_Err'Size / 8;
-- For getsockopt(2) call
begin
if Selector /= null and then not Is_Open (Selector.all) then
raise Program_Error with "closed selector";
end if;
-- Set the socket to non-blocking I/O
Req := (Name => Non_Blocking_IO, Enabled => True);
Control_Socket (Socket, Request => Req);
-- Start operation (non-blocking), will return Failure with errno set
-- to EINPROGRESS.
Res := Connect_Socket (Socket, Server);
if Res = Failure then
Conn_Err := Socket_Errno;
if Conn_Err /= SOSC.EINPROGRESS then
Raise_Socket_Error (Conn_Err);
end if;
end if;
-- Wait for socket to become available for writing (unless the Timeout
-- is zero, in which case we consider that it has already expired, and
-- we do not need to wait at all).
if Timeout = 0.0 then
Status := Expired;
else
Wait_On_Socket
(Socket => Socket,
Event => Poll.Output_Event,
Timeout => Timeout,
Selector => Selector,
Status => Status);
end if;
-- Check error condition (the asynchronous connect may have terminated
-- with an error, e.g. ECONNREFUSED) if select(2) completed.
if Status = Completed then
Res := C_Getsockopt
(C.int (Socket), SOSC.SOL_SOCKET, SOSC.SO_ERROR,
Conn_Err'Address, Conn_Err_Size'Access);
if Res /= 0 then
Conn_Err := Socket_Errno;
end if;
else
Conn_Err := 0;
end if;
-- Reset the socket to blocking I/O
Req := (Name => Non_Blocking_IO, Enabled => False);
Control_Socket (Socket, Request => Req);
-- Report error condition if any
if Conn_Err /= 0 then
Raise_Socket_Error (Conn_Err);
end if;
end Connect_Socket;
--------------------
-- Control_Socket --
--------------------
procedure Control_Socket
(Socket : Socket_Type;
Request : in out Request_Type)
is
Arg : aliased C.int;
Res : C.int;
begin
case Request.Name is
when Non_Blocking_IO =>
Arg := C.int (Boolean'Pos (Request.Enabled));
when N_Bytes_To_Read =>
null;
end case;
Res := Socket_Ioctl
(C.int (Socket), Requests (Request.Name), Arg'Unchecked_Access);
if Res = Failure then
Raise_Socket_Error (Socket_Errno);
end if;
case Request.Name is
when Non_Blocking_IO =>
null;
when N_Bytes_To_Read =>
Request.Size := Natural (Arg);
end case;
end Control_Socket;
----------
-- Copy --
----------
procedure Copy
(Source : Socket_Set_Type;
Target : out Socket_Set_Type)
is
begin
Target := Source;
end Copy;
---------------------
-- Create_Selector --
---------------------
procedure Create_Selector (Selector : out Selector_Type) is
Two_Fds : aliased Fd_Pair;
Res : C.int;
begin
if Is_Open (Selector) then
-- Raise exception to prevent socket descriptor leak
raise Program_Error with "selector already open";
end if;
-- We open two signalling file descriptors. One of them is used to send
-- data to the other, which is included in a C_Select socket set. The
-- communication is used to force a call to C_Select to complete, and
-- the waiting task to resume its execution.
Res := Signalling_Fds.Create (Two_Fds'Access);
pragma Annotate (CodePeer, Modified, Two_Fds);
if Res = Failure then
Raise_Socket_Error (Socket_Errno);
end if;
Selector.R_Sig_Socket := Socket_Type (Two_Fds (Read_End));
Selector.W_Sig_Socket := Socket_Type (Two_Fds (Write_End));
end Create_Selector;
-------------------
-- Create_Socket --
-------------------
procedure Create_Socket
(Socket : out Socket_Type;
Family : Family_Type := Family_Inet;
Mode : Mode_Type := Socket_Stream;
Level : Level_Type := IP_Protocol_For_IP_Level)
is
Res : C.int;
begin
Res := C_Socket (Families (Family), Modes (Mode), Levels (Level));
if Res = Failure then
Raise_Socket_Error (Socket_Errno);
end if;
Socket := Socket_Type (Res);
end Create_Socket;
------------------------
-- Create_Socket_Pair --
------------------------
procedure Create_Socket_Pair
(Left : out Socket_Type;
Right : out Socket_Type;
Family : Family_Type := Family_Unspec;
Mode : Mode_Type := Socket_Stream;
Level : Level_Type := IP_Protocol_For_IP_Level)
is
Res : C.int;
Pair : aliased Thin_Common.Fd_Pair;
begin
Res := C_Socketpair
((if Family = Family_Unspec then Default_Socket_Pair_Family
else Families (Family)),
Modes (Mode), Levels (Level), Pair'Access);
pragma Annotate (CodePeer, Modified, Pair);
if Res = Failure then
Raise_Socket_Error (Socket_Errno);
end if;
Left := Socket_Type (Pair (Pair'First));
Right := Socket_Type (Pair (Pair'Last));
end Create_Socket_Pair;
-----------
-- Empty --
-----------
procedure Empty (Item : out Socket_Set_Type) is
begin
Reset_Socket_Set (Item.Set'Access);
Item.Last := No_Socket;
end Empty;
--------------------
-- Err_Code_Image --
--------------------
function Err_Code_Image (E : Integer) return String is
Msg : String := E'Img & "] ";
begin
Msg (Msg'First) := '[';
return Msg;
end Err_Code_Image;
--------------
-- Finalize --
--------------
procedure Finalize (X : in out Sockets_Library_Controller) is
pragma Unreferenced (X);
begin
-- Finalization operation for the GNAT.Sockets package
Thin.Finalize;
end Finalize;
--------------
-- Finalize --
--------------
procedure Finalize is
begin
-- This is a dummy placeholder for an obsolete API.
-- The real finalization actions are in Initialize primitive operation
-- of Sockets_Library_Controller.
null;
end Finalize;
---------
-- Get --
---------
procedure Get
(Item : in out Socket_Set_Type;
Socket : out Socket_Type)
is
S : aliased C.int;
L : aliased C.int := C.int (Item.Last);
begin
if Item.Last /= No_Socket then
Get_Socket_From_Set
(Item.Set'Access, Last => L'Access, Socket => S'Access);
pragma Annotate (CodePeer, Modified, L);
pragma Annotate (CodePeer, Modified, S);
Item.Last := Socket_Type (L);
Socket := Socket_Type (S);
else
Socket := No_Socket;
end if;
end Get;
-----------------
-- Get_Address --
-----------------
function Get_Address
(Stream : not null Stream_Access) return Sock_Addr_Type
is
begin
if Stream.all in Datagram_Socket_Stream_Type then
return Datagram_Socket_Stream_Type (Stream.all).From;
else
return Get_Peer_Name (Stream_Socket_Stream_Type (Stream.all).Socket);
end if;
end Get_Address;
---------------------
-- Raise_GAI_Error --
---------------------
procedure Raise_GAI_Error (RC : C.int; Name : String) is
begin
if RC = SOSC.EAI_SYSTEM then
declare
Errcode : constant Integer := Socket_Errno;
begin
raise Host_Error with Err_Code_Image (Errcode)
& Dedot (Socket_Error_Message (Errcode)) & ": " & Name;
end;
else
raise Host_Error with Err_Code_Image (Integer (RC))
& Dedot (CS.Value (C_GAI_Strerror (RC))) & ": " & Name;
end if;
end Raise_GAI_Error;
----------------------
-- Get_Address_Info --
----------------------
function Get_Address_Info
(Host : String;
Service : String;
Family : Family_Type := Family_Unspec;
Mode : Mode_Type := Socket_Stream;
Level : Level_Type := IP_Protocol_For_IP_Level;
Numeric_Host : Boolean := False;
Passive : Boolean := False;
Unknown : access procedure
(Family, Mode, Level, Length : Integer) := null)
return Address_Info_Array
is
A : aliased Addrinfo_Access;
N : aliased C.char_array := C.To_C (Host);
S : aliased C.char_array := C.To_C (if Service = "" then "0"
else Service);
Hints : aliased constant Addrinfo :=
(ai_family => Families (Family),
ai_socktype => Modes (Mode),
ai_protocol => Levels (Level),
ai_flags => (if Numeric_Host then SOSC.AI_NUMERICHOST else 0) +
(if Passive then SOSC.AI_PASSIVE else 0),
ai_addrlen => 0,
others => <>);
R : C.int;
Iter : Addrinfo_Access;
Found : Boolean;
function To_Array return Address_Info_Array;
-- Convert taken from OS addrinfo list A into Address_Info_Array
--------------
-- To_Array --
--------------
function To_Array return Address_Info_Array is
Result : Address_Info_Array (1 .. 8);
procedure Unsupported;
-- Calls Unknown callback if defiend
-----------------
-- Unsupported --
-----------------
procedure Unsupported is
begin
if Unknown /= null then
Unknown
(Integer (Iter.ai_family),
Integer (Iter.ai_socktype),
Integer (Iter.ai_protocol),
Integer (Iter.ai_addrlen));
end if;
end Unsupported;
-- Start of processing for To_Array
begin
for J in Result'Range loop
Look_For_Supported : loop
if Iter = null then
pragma Warnings
(Off, "may be referenced before it has a value");
return Result (1 .. J - 1);
pragma Warnings
(On, "may be referenced before it has a value");
end if;
Result (J).Addr :=
Get_Address (Iter.ai_addr.all, C.int (Iter.ai_addrlen));
if Result (J).Addr.Family = Family_Unspec then
Unsupported;
else
for M in Modes'Range loop
Found := False;
if Modes (M) = Iter.ai_socktype then
Result (J).Mode := M;
Found := True;
exit;
end if;
end loop;
if Found then
for L in Levels'Range loop
if Levels (L) = Iter.ai_protocol then
Result (J).Level := L;
exit;
end if;
end loop;
exit Look_For_Supported;
else
Unsupported;
end if;
end if;
Iter := Iter.ai_next;
end loop Look_For_Supported;
Iter := Iter.ai_next;
end loop;
return Result & To_Array;
end To_Array;
-- Start of processing for Get_Address_Info
begin
R := C_Getaddrinfo
(Node => (if Host = "" then null else N'Unchecked_Access),
Service => S'Unchecked_Access,
Hints => Hints'Unchecked_Access,
Res => A'Access);
if R /= 0 then
Raise_GAI_Error
(R, Host & (if Service = "" then "" else ':' & Service));
end if;
Iter := A;
return Result : constant Address_Info_Array := To_Array do
C_Freeaddrinfo (A);
end return;
end Get_Address_Info;
----------
-- Sort --
----------
procedure Sort
(Addr_Info : in out Address_Info_Array;
Compare : access function (Left, Right : Address_Info) return Boolean)
is
function Comp (Left, Right : Address_Info) return Boolean is
(Compare (Left, Right));
procedure Sorter is new Ada.Containers.Generic_Array_Sort
(Positive, Address_Info, Address_Info_Array, Comp);
begin
Sorter (Addr_Info);
end Sort;
------------------------
-- IPv6_TCP_Preferred --
------------------------
function IPv6_TCP_Preferred (Left, Right : Address_Info) return Boolean is
begin
pragma Assert (Family_Inet < Family_Inet6);
-- To be sure that Family_Type enumeration has appropriate elements
-- order
if Left.Addr.Family /= Right.Addr.Family then
return Left.Addr.Family > Right.Addr.Family;
end if;
pragma Assert (Socket_Stream < Socket_Datagram);
-- To be sure that Mode_Type enumeration has appropriate elements order
return Left.Mode < Right.Mode;
end IPv6_TCP_Preferred;
-------------------
-- Get_Name_Info --
-------------------
function Get_Name_Info
(Addr : Sock_Addr_Type;
Numeric_Host : Boolean := False;
Numeric_Serv : Boolean := False) return Host_Service
is
SA : aliased Sockaddr;
H : aliased C.char_array := [1 .. SOSC.NI_MAXHOST => C.nul];
S : aliased C.char_array := [1 .. SOSC.NI_MAXSERV => C.nul];
RC : C.int;
Len : C.int;
begin
Set_Address (SA'Unchecked_Access, Addr, Len);
RC := C_Getnameinfo
(SA'Unchecked_Access, socklen_t (Len),
H'Unchecked_Access, H'Length,
S'Unchecked_Access, S'Length,
(if Numeric_Host then SOSC.NI_NUMERICHOST else 0) +
(if Numeric_Serv then SOSC.NI_NUMERICSERV else 0));
if RC /= 0 then
Raise_GAI_Error (RC, Image (Addr));
end if;
declare
HR : constant String := C.To_Ada (H);
SR : constant String := C.To_Ada (S);
begin
return (HR'Length, SR'Length, HR, SR);
end;
end Get_Name_Info;
-------------------------
-- Get_Host_By_Address --
-------------------------
function Get_Host_By_Address
(Address : Inet_Addr_Type;
Family : Family_Type := Family_Inet) return Host_Entry_Type
is
pragma Unreferenced (Family);
HA : aliased In_Addr_Union (Address.Family);
Buflen : constant C.size_t := Netdb_Buffer_Size;
Buf : aliased C.char_array (1 .. Netdb_Buffer_Size);
Res : aliased Hostent;
Err : aliased C.int;
begin
case Address.Family is
when Family_Inet =>
HA.In4 := To_In_Addr (Address);
when Family_Inet6 =>
HA.In6 := To_In6_Addr (Address);
end case;
Netdb_Lock;
if C_Gethostbyaddr
(HA'Address,
(case Address.Family is
when Family_Inet => HA.In4'Size,
when Family_Inet6 => HA.In6'Size) / 8,
Families (Address.Family),
Res'Access, Buf'Address, Buflen, Err'Access) /= 0
then
Netdb_Unlock;
Raise_Host_Error (Integer (Err), Image (Address));
end if;
begin
return H : constant Host_Entry_Type :=
To_Host_Entry (Res'Unchecked_Access)
do
Netdb_Unlock;
end return;
exception
when others =>
Netdb_Unlock;
raise;
end;
end Get_Host_By_Address;
----------------------
-- Get_Host_By_Name --
----------------------
function Get_Host_By_Name (Name : String) return Host_Entry_Type is
begin
-- If the given name actually is the string representation of
-- an IP address, use Get_Host_By_Address instead.
if Is_IPv4_Address (Name) or else Is_IPv6_Address (Name) then
return Get_Host_By_Address (Inet_Addr (Name));
end if;
declare
HN : constant C.char_array := C.To_C (Name);
Buflen : constant C.size_t := Netdb_Buffer_Size;
Buf : aliased C.char_array (1 .. Netdb_Buffer_Size);
Res : aliased Hostent;
Err : aliased C.int;
begin
Netdb_Lock;
if C_Gethostbyname
(HN, Res'Access, Buf'Address, Buflen, Err'Access) /= 0
then
Netdb_Unlock;
Raise_Host_Error (Integer (Err), Name);
end if;
return H : constant Host_Entry_Type :=
To_Host_Entry (Res'Unchecked_Access)
do
Netdb_Unlock;
end return;
end;
end Get_Host_By_Name;
-------------------
-- Get_Peer_Name --
-------------------
function Get_Peer_Name (Socket : Socket_Type) return Sock_Addr_Type is
Sin : aliased Sockaddr;
Len : aliased C.int := Sin'Size / 8;
begin
if C_Getpeername (C.int (Socket), Sin'Address, Len'Access) = Failure then
Raise_Socket_Error (Socket_Errno);
end if;
return Get_Address (Sin, Len);
end Get_Peer_Name;
-------------------------
-- Get_Service_By_Name --
-------------------------
function Get_Service_By_Name
(Name : String;
Protocol : String) return Service_Entry_Type
is
SN : constant C.char_array := C.To_C (Name);
SP : constant C.char_array := C.To_C (Protocol);
Buflen : constant C.size_t := Netdb_Buffer_Size;
Buf : aliased C.char_array (1 .. Netdb_Buffer_Size);
Res : aliased Servent;
begin
Netdb_Lock;
if C_Getservbyname (SN, SP, Res'Access, Buf'Address, Buflen) /= 0 then
Netdb_Unlock;
raise Service_Error with "Service not found";
end if;
-- Translate from the C format to the API format
return S : constant Service_Entry_Type :=
To_Service_Entry (Res'Unchecked_Access)
do
Netdb_Unlock;
end return;
end Get_Service_By_Name;
-------------------------
-- Get_Service_By_Port --
-------------------------
function Get_Service_By_Port
(Port : Port_Type;
Protocol : String) return Service_Entry_Type
is
SP : constant C.char_array := C.To_C (Protocol);
Buflen : constant C.size_t := Netdb_Buffer_Size;
Buf : aliased C.char_array (1 .. Netdb_Buffer_Size);
Res : aliased Servent;
begin
Netdb_Lock;
if C_Getservbyport
(C.int (Short_To_Network (C.unsigned_short (Port))), SP,
Res'Access, Buf'Address, Buflen) /= 0
then
Netdb_Unlock;
raise Service_Error with "Service not found";
end if;
-- Translate from the C format to the API format
return S : constant Service_Entry_Type :=
To_Service_Entry (Res'Unchecked_Access)
do
Netdb_Unlock;
end return;
end Get_Service_By_Port;
---------------------
-- Get_Socket_Name --
---------------------
function Get_Socket_Name
(Socket : Socket_Type) return Sock_Addr_Type
is
Sin : aliased Sockaddr;
Len : aliased C.int := Sin'Size / 8;
Res : C.int;
begin
Res := C_Getsockname (C.int (Socket), Sin'Address, Len'Access);
if Res = Failure then
return No_Sock_Addr;
end if;
return Get_Address (Sin, Len);
end Get_Socket_Name;
-----------------------
-- Get_Socket_Option --
-----------------------
function Get_Socket_Option
(Socket : Socket_Type;
Level : Level_Type;
Name : Option_Name;
Optname : Interfaces.C.int := -1) return Option_Type
is
use type C.unsigned;
use type C.unsigned_char;
V8 : aliased Two_Ints;
V4 : aliased C.int;
U4 : aliased C.unsigned;
V1 : aliased C.unsigned_char;
VT : aliased Timeval;
Len : aliased C.int;
Add : System.Address;
Res : C.int;
Opt : Option_Type (Name);
Onm : Interfaces.C.int;
begin
if Name in Specific_Option_Name then
Onm := Options (Name);
elsif Optname = -1 then
raise Socket_Error with "optname must be specified";
else
Onm := Optname;
end if;
case Name is
when Multicast_TTL
| Receive_Packet_Info
=>
Len := V1'Size / 8;
Add := V1'Address;
when Broadcast
| Busy_Polling
| Error
| Generic_Option
| Keep_Alive
| Keep_Alive_Count
| Keep_Alive_Idle
| Keep_Alive_Interval
| Multicast_If_V4
| Multicast_If_V6
| Multicast_Loop_V4
| Multicast_Loop_V6
| Multicast_Hops
| No_Delay
| Receive_Buffer
| Reuse_Address
| Send_Buffer
| IPv6_Only
=>
Len := V4'Size / 8;
Add := V4'Address;
when Receive_Timeout
| Send_Timeout
=>
-- The standard argument for SO_RCVTIMEO and SO_SNDTIMEO is a
-- struct timeval, but on Windows it is a milliseconds count in
-- a DWORD.
if Is_Windows then
Len := U4'Size / 8;
Add := U4'Address;
else
Len := VT'Size / 8;
Add := VT'Address;
end if;
when Add_Membership_V4
| Add_Membership_V6
| Drop_Membership_V4
| Drop_Membership_V6
=>
raise Socket_Error with
"Add/Drop membership valid only for Set_Socket_Option";
when Linger
=>
Len := V8'Size / 8;
Add := V8'Address;
end case;
Res :=
C_Getsockopt
(C.int (Socket),
Levels (Level),
Onm,
Add, Len'Access);
if Res = Failure then
Raise_Socket_Error (Socket_Errno);
end if;
case Name is
when Generic_Option =>
Opt.Optname := Onm;
Opt.Optval := V4;
when Broadcast
| Keep_Alive
| No_Delay
| Reuse_Address
| Multicast_Loop_V4
| Multicast_Loop_V6
| IPv6_Only
=>
Opt.Enabled := (V4 /= 0);
when Keep_Alive_Count =>
Opt.Count := Natural (V4);
when Keep_Alive_Idle =>
Opt.Idle_Seconds := Natural (V4);
when Keep_Alive_Interval =>
Opt.Interval_Seconds := Natural (V4);
when Busy_Polling =>
Opt.Microseconds := Natural (V4);
when Linger =>
Opt.Enabled := (V8 (V8'First) /= 0);
Opt.Seconds := Natural (V8 (V8'Last));
when Receive_Buffer
| Send_Buffer
=>
Opt.Size := Natural (V4);
when Error =>
Opt.Error := Resolve_Error (Integer (V4));
when Add_Membership_V4
| Add_Membership_V6
| Drop_Membership_V4
| Drop_Membership_V6
=>
-- No way to be here. Exception raised in the first case Name
-- expression.
null;
when Multicast_If_V4 =>
To_Inet_Addr (To_In_Addr (V4), Opt.Outgoing_If);
when Multicast_If_V6 =>
Opt.Outgoing_If_Index := Natural (V4);
when Multicast_TTL =>
Opt.Time_To_Live := Integer (V1);
when Multicast_Hops =>
Opt.Hop_Limit := Integer (V4);
when Receive_Packet_Info
=>
Opt.Enabled := (V1 /= 0);
when Receive_Timeout
| Send_Timeout
=>
if Is_Windows then
if U4 = 0 then
Opt.Timeout := 0.0;
else
if Minus_500ms_Windows_Timeout then
-- Timeout is in milliseconds, actual value is 500 ms +
-- returned value (unless it is 0).
U4 := U4 + 500;
end if;
Opt.Timeout := Duration (U4) / 1000;
end if;
else
Opt.Timeout := To_Duration (VT);
end if;
end case;
return Opt;
end Get_Socket_Option;
---------------
-- Host_Name --
---------------
function Host_Name return String is
Name : aliased C.char_array (1 .. 64);
Res : C.int;
begin
Res := C_Gethostname (Name'Address, Name'Length);
if Res = Failure then
Raise_Socket_Error (Socket_Errno);
end if;
return C.To_Ada (Name);
end Host_Name;
-----------
-- Image --
-----------
function Image (Value : Inet_Addr_Type) return String is
use type CS.char_array_access;
Size : constant socklen_t :=
(case Value.Family is
when Family_Inet => 4 * Value.Sin_V4'Length,
when Family_Inet6 => 6 * 5 + 4 * 4);
-- 1234:1234:1234:1234:1234:1234:123.123.123.123
Dst : aliased C.char_array := [1 .. C.size_t (Size) => C.nul];
Ia : aliased In_Addr_Union (Value.Family);
begin
case Value.Family is
when Family_Inet6 =>
Ia.In6 := To_In6_Addr (Value);
when Family_Inet =>
Ia.In4 := To_In_Addr (Value);
end case;
if Inet_Ntop
(Families (Value.Family), Ia'Address,
Dst'Unchecked_Access, Size) = null
then
Raise_Socket_Error (Socket_Errno);
end if;
return C.To_Ada (Dst);
end Image;
-----------
-- Image --
-----------
function Image (Value : Sock_Addr_Type) return String is
function Ipv6_Brackets (S : String) return String is
(if Value.Family = Family_Inet6 then "[" & S & "]" else S);
begin
case Value.Family is
when Family_Unix =>
if ASU.Length (Value.Name) > 0
and then ASU.Element (Value.Name, 1) = ASCII.NUL
then
return '@' & ASU.Slice (Value.Name, 2, ASU.Length (Value.Name));
else
return ASU.To_String (Value.Name);
end if;
when Family_Inet_4_6 =>
declare
Port : constant String := Value.Port'Img;
begin
return Ipv6_Brackets (Image (Value.Addr)) & ':'
& Port (2 .. Port'Last);
end;
when Family_Unspec =>
return "";
end case;
end Image;
-----------
-- Image --
-----------
function Image (Socket : Socket_Type) return String is
begin
return Socket'Img;
end Image;
-----------
-- Image --
-----------
function Image (Item : Socket_Set_Type) return String is
Socket_Set : Socket_Set_Type := Item;
begin
declare
Last_Img : constant String := Socket_Set.Last'Img;
Buffer : String
(1 .. (Integer (Socket_Set.Last) + 1) * Last_Img'Length);
Index : Positive := 1;
Socket : Socket_Type;
begin
while not Is_Empty (Socket_Set) loop
Get (Socket_Set, Socket);
declare
Socket_Img : constant String := Socket'Img;
begin
Buffer (Index .. Index + Socket_Img'Length - 1) := Socket_Img;
Index := Index + Socket_Img'Length;
end;
end loop;
return "[" & Last_Img & "]" & Buffer (1 .. Index - 1);
end;
end Image;
---------------
-- Inet_Addr --
---------------
function Inet_Addr (Image : String) return Inet_Addr_Type is
use Interfaces.C;
Img : aliased char_array := To_C (Image);
Res : C.int;
Result : Inet_Addr_Type;
IPv6 : constant Boolean := Is_IPv6_Address (Image);
Ia : aliased In_Addr_Union
(if IPv6 then Family_Inet6 else Family_Inet);
begin
-- Special case for an empty Image as on some platforms (e.g. Windows)
-- calling Inet_Addr("") will not return an error.
if Image = "" then
Raise_Socket_Error (SOSC.EINVAL);
end if;
Res := Inet_Pton
((if IPv6 then SOSC.AF_INET6 else SOSC.AF_INET), Img'Address,
Ia'Address);
if Res < 0 then
Raise_Socket_Error (Socket_Errno);
elsif Res = 0 then
Raise_Socket_Error (SOSC.EINVAL);
end if;
if IPv6 then
To_Inet_Addr (Ia.In6, Result);
else
To_Inet_Addr (Ia.In4, Result);
end if;
return Result;
end Inet_Addr;
----------------
-- Initialize --
----------------
procedure Initialize (X : in out Sockets_Library_Controller) is
pragma Unreferenced (X);
begin
Thin.Initialize;
end Initialize;
----------------
-- Initialize --
----------------
procedure Initialize (Process_Blocking_IO : Boolean) is
Expected : constant Boolean := not SOSC.Thread_Blocking_IO;
begin
if Process_Blocking_IO /= Expected then
raise Socket_Error with
"incorrect Process_Blocking_IO setting, expected " & Expected'Img;
end if;
-- This is a dummy placeholder for an obsolete API
-- Real initialization actions are in Initialize primitive operation
-- of Sockets_Library_Controller.
null;
end Initialize;
----------------
-- Initialize --
----------------
procedure Initialize is
begin
-- This is a dummy placeholder for an obsolete API
-- Real initialization actions are in Initialize primitive operation
-- of Sockets_Library_Controller.
null;
end Initialize;
----------------
-- Is_Windows --
----------------
function Is_Windows return Boolean is
use SOSC;
begin
return Target_OS = Windows;
end Is_Windows;
--------------
-- Is_Empty --
--------------
function Is_Empty (Item : Socket_Set_Type) return Boolean is
begin
return Item.Last = No_Socket;
end Is_Empty;
---------------------
-- Is_IPv6_Address --
---------------------
function Is_IPv6_Address (Name : String) return Boolean is
Prev_Colon : Natural := 0;
Double_Colon : Boolean := False;
Colons : Natural := 0;
begin
for J in Name'Range loop
if Name (J) = ':' then
Colons := Colons + 1;
if Prev_Colon > 0 and then J = Prev_Colon + 1 then
if Double_Colon then
-- Only one double colon allowed
return False;
end if;
Double_Colon := True;
elsif J = Name'Last then
-- Single colon at the end is not allowed
return False;
end if;
Prev_Colon := J;
elsif Prev_Colon = Name'First then
-- Single colon at start is not allowed
return False;
elsif Name (J) = '.' then
return Prev_Colon > 0
and then Is_IPv4_Address (Name (Prev_Colon + 1 .. Name'Last));
elsif Name (J) not in '0' .. '9' | 'A' .. 'F' | 'a' .. 'f' then
return False;
end if;
end loop;
return Colons in 2 .. 8;
end Is_IPv6_Address;
---------------------
-- Is_IPv4_Address --
---------------------
function Is_IPv4_Address (Name : String) return Boolean is
Dots : Natural := 0;
begin
-- Perform a cursory check for a dotted quad: we must have 1 to 3 dots,
-- and there must be at least one digit around each.
for J in Name'Range loop
if Name (J) = '.' then
-- Check that the dot is not in first or last position, and that
-- it is followed by a digit. Note that we already know that it is
-- preceded by a digit, or we would have returned earlier on.
if J in Name'First + 1 .. Name'Last - 1
and then Name (J + 1) in '0' .. '9'
then
Dots := Dots + 1;
-- Definitely not a proper dotted quad
else
return False;
end if;
elsif Name (J) not in '0' .. '9' then
return False;
end if;
end loop;
return Dots in 1 .. 3;
end Is_IPv4_Address;
-------------
-- Is_Open --
-------------
function Is_Open (S : Selector_Type) return Boolean is
begin
if S.Is_Null then
return True;
else
-- Either both controlling socket descriptors are valid (case of an
-- open selector) or neither (case of a closed selector).
pragma Assert ((S.R_Sig_Socket /= No_Socket)
=
(S.W_Sig_Socket /= No_Socket));
return S.R_Sig_Socket /= No_Socket;
end if;
end Is_Open;
------------
-- Is_Set --
------------
function Is_Set
(Item : Socket_Set_Type;
Socket : Socket_Type) return Boolean
is
begin
Check_For_Fd_Set (Socket);
return Item.Last /= No_Socket
and then Socket <= Item.Last
and then Is_Socket_In_Set (Item.Set'Access, C.int (Socket)) /= 0;
end Is_Set;
-------------------
-- Listen_Socket --
-------------------
procedure Listen_Socket
(Socket : Socket_Type;
Length : Natural := 15)
is
Res : constant C.int := C_Listen (C.int (Socket), C.int (Length));
begin
if Res = Failure then
Raise_Socket_Error (Socket_Errno);
end if;
end Listen_Socket;
------------
-- Narrow --
------------
procedure Narrow (Item : in out Socket_Set_Type) is
Last : aliased C.int := C.int (Item.Last);
begin
if Item.Last /= No_Socket then
Last_Socket_In_Set (Item.Set'Access, Last'Unchecked_Access);
Item.Last := Socket_Type (Last);
end if;
end Narrow;
----------------
-- Netdb_Lock --
----------------
procedure Netdb_Lock is
begin
if Need_Netdb_Lock then
System.Task_Lock.Lock;
end if;
end Netdb_Lock;
------------------
-- Netdb_Unlock --
------------------
procedure Netdb_Unlock is
begin
if Need_Netdb_Lock then
System.Task_Lock.Unlock;
end if;
end Netdb_Unlock;
----------------------------
-- Network_Socket_Address --
----------------------------
function Network_Socket_Address
(Addr : Inet_Addr_Type; Port : Port_Type) return Sock_Addr_Type is
begin
return Result : Sock_Addr_Type (Addr.Family) do
Result.Addr := Addr;
Result.Port := Port;
end return;
end Network_Socket_Address;
--------------------------------
-- Normalize_Empty_Socket_Set --
--------------------------------
procedure Normalize_Empty_Socket_Set (S : in out Socket_Set_Type) is
begin
if S.Last = No_Socket then
Reset_Socket_Set (S.Set'Access);
end if;
end Normalize_Empty_Socket_Set;
-------------------
-- Official_Name --
-------------------
function Official_Name (E : Host_Entry_Type) return String is
begin
return To_String (E.Official);
end Official_Name;
-------------------
-- Official_Name --
-------------------
function Official_Name (S : Service_Entry_Type) return String is
begin
return To_String (S.Official);
end Official_Name;
--------------------
-- Wait_On_Socket --
--------------------
procedure Wait_On_Socket
(Socket : Socket_Type;
Event : Poll.Wait_Event_Set;
Timeout : Selector_Duration;
Selector : access Selector_Type := null;
Status : out Selector_Status)
is
Fd_Set : Poll.Set := Poll.To_Set (Socket, Event, 2);
-- Socket itself and second place for signaling socket if necessary
Count : Natural;
Index : Natural := 0;
begin
-- Add signaling socket if selector defined
if Selector /= null then
Poll.Append (Fd_Set, Selector.R_Sig_Socket, Poll.Input_Event);
end if;
Poll.Wait (Fd_Set, Timeout, Count);
if Count = 0 then
Status := Expired;
else
Poll.Next (Fd_Set, Index);
Status := (if Index = 1 then Completed else Aborted);
end if;
end Wait_On_Socket;
-----------------
-- Port_Number --
-----------------
function Port_Number (S : Service_Entry_Type) return Port_Type is
begin
return S.Port;
end Port_Number;
-------------------
-- Protocol_Name --
-------------------
function Protocol_Name (S : Service_Entry_Type) return String is
begin
return To_String (S.Protocol);
end Protocol_Name;
----------------------
-- Raise_Host_Error --
----------------------
procedure Raise_Host_Error (H_Error : Integer; Name : String) is
begin
raise Host_Error with
Err_Code_Image (H_Error)
& Dedot (Host_Error_Messages.Host_Error_Message (H_Error))
& ": " & Name;
end Raise_Host_Error;
------------------------
-- Raise_Socket_Error --
------------------------
procedure Raise_Socket_Error (Error : Integer) is
begin
raise Socket_Error with
Err_Code_Image (Error) & Socket_Error_Message (Error);
end Raise_Socket_Error;
----------
-- Read --
----------
procedure Read
(Stream : in out Datagram_Socket_Stream_Type;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset)
is
begin
Receive_Socket
(Stream.Socket,
Item,
Last,
Stream.From);
end Read;
----------
-- Read --
----------
procedure Read
(Stream : in out Stream_Socket_Stream_Type;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset)
is
First : Ada.Streams.Stream_Element_Offset := Item'First;
Index : Ada.Streams.Stream_Element_Offset := First - 1;
Max : constant Ada.Streams.Stream_Element_Offset := Item'Last;
begin
loop
Receive_Socket (Stream.Socket, Item (First .. Max), Index);
Last := Index;
-- Exit when all or zero data received. Zero means that the socket
-- peer is closed.
exit when Index < First or else Index = Max;
First := Index + 1;
end loop;
end Read;
--------------------
-- Receive_Socket --
--------------------
procedure Receive_Socket
(Socket : Socket_Type;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Flags : Request_Flag_Type := No_Request_Flag)
is
Res : C.int;
begin
Res :=
C_Recv (C.int (Socket), Item'Address, Item'Length, To_Int (Flags));
if Res = Failure then
Raise_Socket_Error (Socket_Errno);
end if;
Last := Last_Index (First => Item'First, Count => size_t (Res));
end Receive_Socket;
--------------------
-- Receive_Socket --
--------------------
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;
Flags : Request_Flag_Type := No_Request_Flag)
is
Res : C.int;
Sin : aliased Sockaddr;
Len : aliased C.int := Sin'Size / 8;
begin
Res :=
C_Recvfrom
(C.int (Socket),
Item'Address,
Item'Length,
To_Int (Flags),
Sin'Address,
Len'Access);
if Res = Failure then
Raise_Socket_Error (Socket_Errno);
end if;
Last := Last_Index (First => Item'First, Count => size_t (Res));
From := Get_Address (Sin, Len);
end Receive_Socket;
--------------------
-- Receive_Vector --
--------------------
procedure Receive_Vector
(Socket : Socket_Type;
Vector : Vector_Type;
Count : out Ada.Streams.Stream_Element_Count;
Flags : Request_Flag_Type := No_Request_Flag)
is
Res : ssize_t;
Msg : Msghdr :=
(Msg_Name => System.Null_Address,
Msg_Namelen => 0,
Msg_Iov => Vector'Address,
-- recvmsg(2) returns EMSGSIZE on Linux (and probably on other
-- platforms) when the supplied vector is longer than IOV_MAX,
-- so use minimum of the two lengths.
Msg_Iovlen => SOSC.Msg_Iovlen_T'Min
(Vector'Length, SOSC.IOV_MAX),
Msg_Control => System.Null_Address,
Msg_Controllen => 0,
Msg_Flags => 0);
begin
Res :=
C_Recvmsg
(C.int (Socket),
Msg'Address,
To_Int (Flags));
if Res = ssize_t (Failure) then
Raise_Socket_Error (Socket_Errno);
end if;
Count := Ada.Streams.Stream_Element_Count (Res);
end Receive_Vector;
-------------------
-- Resolve_Error --
-------------------
function Resolve_Error
(Error_Value : Integer;
From_Errno : Boolean := True) return Error_Type
is
use GNAT.Sockets.SOSC;
begin
if not From_Errno then
case Error_Value is
when SOSC.HOST_NOT_FOUND => return Unknown_Host;
when SOSC.TRY_AGAIN => return Host_Name_Lookup_Failure;
when SOSC.NO_RECOVERY => return Non_Recoverable_Error;
when SOSC.NO_DATA => return Unknown_Server_Error;
when others => return Cannot_Resolve_Error;
end case;
end if;
-- Special case: EAGAIN may be the same value as EWOULDBLOCK, so we
-- can't include it in the case statement below.
pragma Warnings (Off);
-- Condition "EAGAIN /= EWOULDBLOCK" is known at compile time
if EAGAIN /= EWOULDBLOCK and then Error_Value = EAGAIN then
return Resource_Temporarily_Unavailable;
end if;
-- This is not a case statement because if a particular error
-- number constant is not defined, s-oscons-tmplt.c defines
-- it to -1. If multiple constants are not defined, they
-- would each be -1 and result in a "duplicate value in case" error.
--
-- But we have to leave warnings off because the compiler is also
-- smart enough to note that when two errnos have the same value,
-- the second if condition is useless.
if Error_Value = ENOERROR then
return Success;
elsif Error_Value = EACCES then
return Permission_Denied;
elsif Error_Value = EADDRINUSE then
return Address_Already_In_Use;
elsif Error_Value = EADDRNOTAVAIL then
return Cannot_Assign_Requested_Address;
elsif Error_Value = EAFNOSUPPORT then
return Address_Family_Not_Supported_By_Protocol;
elsif Error_Value = EALREADY then
return Operation_Already_In_Progress;
elsif Error_Value = EBADF then
return Bad_File_Descriptor;
elsif Error_Value = ECONNABORTED then
return Software_Caused_Connection_Abort;
elsif Error_Value = ECONNREFUSED then
return Connection_Refused;
elsif Error_Value = ECONNRESET then
return Connection_Reset_By_Peer;
elsif Error_Value = EDESTADDRREQ then
return Destination_Address_Required;
elsif Error_Value = EFAULT then
return Bad_Address;
elsif Error_Value = EHOSTDOWN then
return Host_Is_Down;
elsif Error_Value = EHOSTUNREACH then
return No_Route_To_Host;
elsif Error_Value = EINPROGRESS then
return Operation_Now_In_Progress;
elsif Error_Value = EINTR then
return Interrupted_System_Call;
elsif Error_Value = EINVAL then
return Invalid_Argument;
elsif Error_Value = EIO then
return Input_Output_Error;
elsif Error_Value = EISCONN then
return Transport_Endpoint_Already_Connected;
elsif Error_Value = ELOOP then
return Too_Many_Symbolic_Links;
elsif Error_Value = EMFILE then
return Too_Many_Open_Files;
elsif Error_Value = EMSGSIZE then
return Message_Too_Long;
elsif Error_Value = ENAMETOOLONG then
return File_Name_Too_Long;
elsif Error_Value = ENETDOWN then
return Network_Is_Down;
elsif Error_Value = ENETRESET then
return Network_Dropped_Connection_Because_Of_Reset;
elsif Error_Value = ENETUNREACH then
return Network_Is_Unreachable;
elsif Error_Value = ENOBUFS then
return No_Buffer_Space_Available;
elsif Error_Value = ENOPROTOOPT then
return Protocol_Not_Available;
elsif Error_Value = ENOTCONN then
return Transport_Endpoint_Not_Connected;
elsif Error_Value = ENOTSOCK then
return Socket_Operation_On_Non_Socket;
elsif Error_Value = EOPNOTSUPP then
return Operation_Not_Supported;
elsif Error_Value = EPFNOSUPPORT then
return Protocol_Family_Not_Supported;
elsif Error_Value = EPIPE then
return Broken_Pipe;
elsif Error_Value = EPROTONOSUPPORT then
return Protocol_Not_Supported;
elsif Error_Value = EPROTOTYPE then
return Protocol_Wrong_Type_For_Socket;
elsif Error_Value = ESHUTDOWN then
return Cannot_Send_After_Transport_Endpoint_Shutdown;
elsif Error_Value = ESOCKTNOSUPPORT then
return Socket_Type_Not_Supported;
elsif Error_Value = ETIMEDOUT then
return Connection_Timed_Out;
elsif Error_Value = ETOOMANYREFS then
return Too_Many_References;
elsif Error_Value = EWOULDBLOCK then
return Resource_Temporarily_Unavailable;
else
return Cannot_Resolve_Error;
end if;
pragma Warnings (On);
end Resolve_Error;
-----------------------
-- Resolve_Exception --
-----------------------
function Resolve_Exception
(Occurrence : Exception_Occurrence) return Error_Type
is
Id : constant Exception_Id := Exception_Identity (Occurrence);
Msg : constant String := Exception_Message (Occurrence);
First : Natural;
Last : Natural;
Val : Integer;
begin
First := Msg'First;
while First <= Msg'Last
and then Msg (First) not in '0' .. '9'
loop
First := First + 1;
end loop;
if First > Msg'Last then
return Cannot_Resolve_Error;
end if;
Last := First;
while Last < Msg'Last
and then Msg (Last + 1) in '0' .. '9'
loop
Last := Last + 1;
end loop;
Val := Integer'Value (Msg (First .. Last));
if Id = Socket_Error_Id then
return Resolve_Error (Val);
elsif Id = Host_Error_Id then
return Resolve_Error (Val, False);
else
return Cannot_Resolve_Error;
end if;
end Resolve_Exception;
-----------------
-- Send_Socket --
-----------------
procedure Send_Socket
(Socket : Socket_Type;
Item : Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Flags : Request_Flag_Type := No_Request_Flag)
is
begin
Send_Socket (Socket, Item, Last, To => null, Flags => Flags);
end Send_Socket;
-----------------
-- Send_Socket --
-----------------
procedure Send_Socket
(Socket : Socket_Type;
Item : Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
To : Sock_Addr_Type;
Flags : Request_Flag_Type := No_Request_Flag)
is
begin
Send_Socket
(Socket, Item, Last, To => To'Unrestricted_Access, Flags => Flags);
end Send_Socket;
-----------------
-- Send_Socket --
-----------------
procedure Send_Socket
(Socket : Socket_Type;
Item : Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
To : access Sock_Addr_Type;
Flags : Request_Flag_Type := No_Request_Flag)
is
Res : C.int;
Sin : aliased Sockaddr;
C_To : System.Address;
Len : C.int;
begin
if To /= null then
Set_Address (Sin'Unchecked_Access, To.all, Len);
C_To := Sin'Address;
else
C_To := System.Null_Address;
Len := 0;
end if;
Res := C_Sendto
(C.int (Socket),
Item'Address,
Item'Length,
Set_Forced_Flags (To_Int (Flags)),
C_To,
Len);
if Res = Failure then
Raise_Socket_Error (Socket_Errno);
end if;
Last := Last_Index (First => Item'First, Count => size_t (Res));
end Send_Socket;
-----------------
-- Send_Vector --
-----------------
procedure Send_Vector
(Socket : Socket_Type;
Vector : Vector_Type;
Count : out Ada.Streams.Stream_Element_Count;
Flags : Request_Flag_Type := No_Request_Flag)
is
use Interfaces.C;
Res : ssize_t;
Iov_Count : SOSC.Msg_Iovlen_T;
This_Iov_Count : SOSC.Msg_Iovlen_T;
Msg : Msghdr;
begin
Count := 0;
Iov_Count := 0;
while Iov_Count < Vector'Length loop
pragma Warnings (Off);
-- Following test may be compile time known on some targets
This_Iov_Count :=
(if Vector'Length - Iov_Count > SOSC.IOV_MAX
then SOSC.IOV_MAX
else Vector'Length - Iov_Count);
pragma Warnings (On);
Msg :=
(Msg_Name => System.Null_Address,
Msg_Namelen => 0,
Msg_Iov => Vector
(Vector'First + Integer (Iov_Count))'Address,
Msg_Iovlen => This_Iov_Count,
Msg_Control => System.Null_Address,
Msg_Controllen => 0,
Msg_Flags => 0);
Res :=
C_Sendmsg
(C.int (Socket),
Msg'Address,
Set_Forced_Flags (To_Int (Flags)));
if Res = ssize_t (Failure) then
Raise_Socket_Error (Socket_Errno);
end if;
Count := Count + Ada.Streams.Stream_Element_Count (Res);
Iov_Count := Iov_Count + This_Iov_Count;
end loop;
end Send_Vector;
---------
-- Set --
---------
procedure Set (Item : in out Socket_Set_Type; Socket : Socket_Type) is
begin
Check_For_Fd_Set (Socket);
if Item.Last = No_Socket then
-- Uninitialized socket set, make sure it is properly zeroed out
Reset_Socket_Set (Item.Set'Access);
Item.Last := Socket;
elsif Item.Last < Socket then
Item.Last := Socket;
end if;
Insert_Socket_In_Set (Item.Set'Access, C.int (Socket));
end Set;
-----------------------
-- Set_Close_On_Exec --
-----------------------
procedure Set_Close_On_Exec
(Socket : Socket_Type;
Close_On_Exec : Boolean;
Status : out Boolean)
is
function C_Set_Close_On_Exec
(Socket : Socket_Type; Close_On_Exec : C.int) return C.int;
pragma Import (C, C_Set_Close_On_Exec, "__gnat_set_close_on_exec");
begin
Status := C_Set_Close_On_Exec (Socket, Boolean'Pos (Close_On_Exec)) = 0;
end Set_Close_On_Exec;
----------------------
-- Set_Forced_Flags --
----------------------
function Set_Forced_Flags (F : C.int) return C.int is
use type C.unsigned;
function To_unsigned is
new Ada.Unchecked_Conversion (C.int, C.unsigned);
function To_int is
new Ada.Unchecked_Conversion (C.unsigned, C.int);
begin
return To_int (To_unsigned (F) or SOSC.MSG_Forced_Flags);
end Set_Forced_Flags;
-----------------------
-- Set_Socket_Option --
-----------------------
procedure Set_Socket_Option
(Socket : Socket_Type;
Level : Level_Type;
Option : Option_Type)
is
use type C.unsigned;
MR : aliased IPV6_Mreq;
V8 : aliased Two_Ints;
V4 : aliased C.int;
U4 : aliased C.unsigned;
V1 : aliased C.unsigned_char;
VT : aliased Timeval;
Len : C.int;
Add : System.Address := Null_Address;
Res : C.int;
Onm : C.int;
begin
case Option.Name is
when Generic_Option =>
V4 := Option.Optval;
Len := V4'Size / 8;
Add := V4'Address;
when Broadcast
| Keep_Alive
| No_Delay
| Reuse_Address
| Multicast_Loop_V4
| Multicast_Loop_V6
| IPv6_Only
=>
V4 := C.int (Boolean'Pos (Option.Enabled));
Len := V4'Size / 8;
Add := V4'Address;
when Keep_Alive_Count =>
V4 := C.int (Option.Count);
Len := V4'Size / 8;
Add := V4'Address;
when Keep_Alive_Idle =>
V4 := C.int (Option.Idle_Seconds);
Len := V4'Size / 8;
Add := V4'Address;
when Keep_Alive_Interval =>
V4 := C.int (Option.Interval_Seconds);
Len := V4'Size / 8;
Add := V4'Address;
when Busy_Polling =>
V4 := C.int (Option.Microseconds);
Len := V4'Size / 8;
Add := V4'Address;
when Linger =>
V8 (V8'First) := C.int (Boolean'Pos (Option.Enabled));
V8 (V8'Last) := C.int (Option.Seconds);
Len := V8'Size / 8;
Add := V8'Address;
when Receive_Buffer
| Send_Buffer
=>
V4 := C.int (Option.Size);
Len := V4'Size / 8;
Add := V4'Address;
when Error =>
V4 := C.int (Boolean'Pos (True));
Len := V4'Size / 8;
Add := V4'Address;
when Add_Membership_V4
| Drop_Membership_V4
=>
V8 (V8'First) := To_Int (To_In_Addr (Option.Multicast_Address));
V8 (V8'Last) := To_Int (To_In_Addr (Option.Local_Interface));
Len := V8'Size / 8;
Add := V8'Address;
when Add_Membership_V6
| Drop_Membership_V6 =>
MR.ipv6mr_multiaddr := To_In6_Addr (Option.Multicast_Address);
MR.ipv6mr_interface := C.unsigned (Option.Interface_Index);
Len := MR'Size / 8;
Add := MR'Address;
when Multicast_If_V4 =>
V4 := To_Int (To_In_Addr (Option.Outgoing_If));
Len := V4'Size / 8;
Add := V4'Address;
when Multicast_If_V6 =>
V4 := C.int (Option.Outgoing_If_Index);
Len := V4'Size / 8;
Add := V4'Address;
when Multicast_TTL =>
V1 := C.unsigned_char (Option.Time_To_Live);
Len := V1'Size / 8;
Add := V1'Address;
when Multicast_Hops =>
V4 := C.int (Option.Hop_Limit);
Len := V4'Size / 8;
Add := V4'Address;
when Receive_Packet_Info
=>
V1 := C.unsigned_char (Boolean'Pos (Option.Enabled));
Len := V1'Size / 8;
Add := V1'Address;
when Receive_Timeout
| Send_Timeout
=>
if Is_Windows then
-- On Windows, the timeout is a DWORD in milliseconds
Len := U4'Size / 8;
Add := U4'Address;
U4 := C.unsigned (Option.Timeout * 1000);
if Option.Timeout > 0.0 and then U4 = 0 then
-- Avoid round to zero. Zero timeout mean unlimited
U4 := 1;
end if;
-- Old windows versions actual timeout is 500 ms + the given
-- value (unless it is 0).
if Minus_500ms_Windows_Timeout then
if U4 > 500 then
U4 := U4 - 500;
elsif U4 > 0 then
U4 := 1;
end if;
end if;
else
VT := To_Timeval (Option.Timeout);
Len := VT'Size / 8;
Add := VT'Address;
end if;
end case;
if Option.Name in Specific_Option_Name then
Onm := Options (Option.Name);
elsif Option.Optname = -1 then
raise Socket_Error with "optname must be specified";
else
Onm := Option.Optname;
end if;
Res := C_Setsockopt
(C.int (Socket),
Levels (Level),
Onm,
Add, Len);
if Res = Failure then
Raise_Socket_Error (Socket_Errno);
end if;
end Set_Socket_Option;
---------------------
-- Shutdown_Socket --
---------------------
procedure Shutdown_Socket
(Socket : Socket_Type;
How : Shutmode_Type := Shut_Read_Write)
is
Res : C.int;
begin
Res := C_Shutdown (C.int (Socket), Shutmodes (How));
if Res = Failure then
Raise_Socket_Error (Socket_Errno);
end if;
end Shutdown_Socket;
------------
-- Stream --
------------
function Stream
(Socket : Socket_Type;
Send_To : Sock_Addr_Type) return Stream_Access
is
S : Datagram_Socket_Stream_Access;
begin
S := new Datagram_Socket_Stream_Type;
S.Socket := Socket;
S.To := Send_To;
S.From := Get_Socket_Name (Socket);
return Stream_Access (S);
end Stream;
------------
-- Stream --
------------
function Stream (Socket : Socket_Type) return Stream_Access is
S : Stream_Socket_Stream_Access;
begin
S := new Stream_Socket_Stream_Type;
S.Socket := Socket;
return Stream_Access (S);
end Stream;
------------
-- To_Ada --
------------
function To_Ada (Fd : Integer) return Socket_Type is
begin
return Socket_Type (Fd);
end To_Ada;
----------
-- To_C --
----------
function To_C (Socket : Socket_Type) return Integer is
begin
return Integer (Socket);
end To_C;
-----------------
-- To_Duration --
-----------------
function To_Duration (Val : Timeval) return Timeval_Duration is
Max_D : constant Long_Long_Integer := Long_Long_Integer (Forever - 0.5);
Tv_sec_64 : constant Boolean := SOSC.SIZEOF_tv_sec = 8;
-- Need to separate this condition into the constant declaration to
-- avoid GNAT warning about "always true" or "always false".
begin
if Tv_sec_64 then
-- Check for possible Duration overflow when Tv_Sec field is 64 bit
-- integer.
if Val.Tv_Sec > time_t (Max_D)
or else
(Val.Tv_Sec = time_t (Max_D)
and then
Val.Tv_Usec > suseconds_t ((Forever - Duration (Max_D)) * 1E6))
then
return Forever;
end if;
end if;
return Duration (Val.Tv_Sec) + Duration (Val.Tv_Usec) * 1.0E-6;
end To_Duration;
-------------------
-- To_Host_Entry --
-------------------
function To_Host_Entry (E : Hostent_Access) return Host_Entry_Type is
Aliases_Count, Addresses_Count : Natural;
Family : constant Family_Type :=
(case Hostent_H_Addrtype (E) is
when SOSC.AF_INET => Family_Inet,
when SOSC.AF_INET6 => Family_Inet6,
when others => Family_Unspec);
Addr_Len : constant C.size_t := C.size_t (Hostent_H_Length (E));
begin
if Family = Family_Unspec then
Raise_Socket_Error (SOSC.EPFNOSUPPORT);
end if;
Aliases_Count := 0;
while Hostent_H_Alias (E, C.int (Aliases_Count)) /= Null_Address loop
Aliases_Count := Aliases_Count + 1;
end loop;
Addresses_Count := 0;
while Hostent_H_Addr (E, C.int (Addresses_Count)) /= Null_Address loop
Addresses_Count := Addresses_Count + 1;
end loop;
return Result : Host_Entry_Type
(Aliases_Length => Aliases_Count,
Addresses_Length => Addresses_Count)
do
Result.Official := To_Name (Value (Hostent_H_Name (E)));
for J in Result.Aliases'Range loop
Result.Aliases (J) :=
To_Name (Value (Hostent_H_Alias
(E, C.int (J - Result.Aliases'First))));
end loop;
for J in Result.Addresses'Range loop
declare
Ia : In_Addr_Union (Family);
-- Hostent_H_Addr (E, <index>) may return an address that is
-- not correctly aligned for In_Addr, so we need to use
-- an intermediate copy operation on a type with an alignment
-- of 1 to recover the value.
subtype Addr_Buf_T is C.char_array (1 .. Addr_Len);
Unaligned_Addr : Addr_Buf_T;
for Unaligned_Addr'Address
use Hostent_H_Addr (E, C.int (J - Result.Addresses'First));
pragma Import (Ada, Unaligned_Addr);
Aligned_Addr : Addr_Buf_T;
for Aligned_Addr'Address use Ia'Address;
pragma Import (Ada, Aligned_Addr);
begin
Aligned_Addr := Unaligned_Addr;
if Family = Family_Inet6 then
To_Inet_Addr (Ia.In6, Result.Addresses (J));
else
To_Inet_Addr (Ia.In4, Result.Addresses (J));
end if;
end;
end loop;
end return;
end To_Host_Entry;
------------
-- To_Int --
------------
function To_Int (F : Request_Flag_Type) return C.int is
Current : Request_Flag_Type := F;
Result : C.int := 0;
begin
for J in Flags'Range loop
exit when Current = 0;
if Current mod 2 /= 0 then
if Flags (J) = -1 then
pragma Annotate
(CodePeer, False_Positive,
"test always false", "self fulfilling prophecy");
Raise_Socket_Error (SOSC.EOPNOTSUPP);
end if;
Result := Result + Flags (J);
end if;
Current := Current / 2;
end loop;
return Result;
end To_Int;
-------------
-- To_Name --
-------------
function To_Name (N : String) return Name_Type is
begin
return Name_Type'(N'Length, N);
end To_Name;
----------------------
-- To_Service_Entry --
----------------------
function To_Service_Entry (E : Servent_Access) return Service_Entry_Type is
Aliases_Count : Natural;
begin
Aliases_Count := 0;
while Servent_S_Alias (E, C.int (Aliases_Count)) /= Null_Address loop
Aliases_Count := Aliases_Count + 1;
end loop;
return Result : Service_Entry_Type (Aliases_Length => Aliases_Count) do
Result.Official := To_Name (Value (Servent_S_Name (E)));
for J in Result.Aliases'Range loop
Result.Aliases (J) :=
To_Name (Value (Servent_S_Alias
(E, C.int (J - Result.Aliases'First))));
end loop;
Result.Protocol := To_Name (Value (Servent_S_Proto (E)));
Result.Port :=
Port_Type (Network_To_Short (Servent_S_Port (E)));
end return;
end To_Service_Entry;
---------------
-- To_String --
---------------
function To_String (HN : Name_Type) return String is
begin
return HN.Name (1 .. HN.Length);
end To_String;
----------------
-- To_Timeval --
----------------
function To_Timeval (Val : Timeval_Duration) return Timeval is
S : time_t;
uS : suseconds_t;
begin
-- If zero, set result as zero (otherwise it gets rounded down to -1)
if Val = 0.0 then
S := 0;
uS := 0;
-- Normal case where we do round down
else
S := time_t (Val - 0.5);
uS := suseconds_t (1_000_000 * (Val - Selector_Duration (S)) - 0.5);
if uS = -1 then
-- It happen on integer duration
uS := 0;
end if;
end if;
return (S, uS);
end To_Timeval;
-----------
-- Value --
-----------
function Value (S : System.Address) return String is
Str : String (1 .. Positive'Last);
for Str'Address use S;
pragma Import (Ada, Str);
Terminator : Positive := Str'First;
begin
while Str (Terminator) /= ASCII.NUL loop
Terminator := Terminator + 1;
end loop;
return Str (1 .. Terminator - 1);
end Value;
-----------
-- Write --
-----------
procedure Write
(Stream : in out Datagram_Socket_Stream_Type;
Item : Ada.Streams.Stream_Element_Array)
is
Last : Stream_Element_Offset;
begin
Send_Socket
(Stream.Socket,
Item,
Last,
Stream.To);
-- It is an error if not all of the data has been sent
if Last /= Item'Last then
Raise_Socket_Error (Socket_Errno);
end if;
end Write;
-----------
-- Write --
-----------
procedure Write
(Stream : in out Stream_Socket_Stream_Type;
Item : Ada.Streams.Stream_Element_Array)
is
First : Ada.Streams.Stream_Element_Offset;
Index : Ada.Streams.Stream_Element_Offset;
Max : constant Ada.Streams.Stream_Element_Offset := Item'Last;
begin
First := Item'First;
Index := First - 1;
while First <= Max loop
Send_Socket (Stream.Socket, Item (First .. Max), Index, null);
-- Exit when all or zero data sent. Zero means that the socket has
-- been closed by peer.
exit when Index < First or else Index = Max;
First := Index + 1;
end loop;
-- For an empty array, we have First > Max, and hence Index >= Max (no
-- error, the loop above is never executed). After a successful send,
-- Index = Max. The only remaining case, Index < Max, is therefore
-- always an actual send failure.
if Index < Max then
Raise_Socket_Error (Socket_Errno);
end if;
end Write;
Sockets_Library_Controller_Object : Sockets_Library_Controller;
pragma Unreferenced (Sockets_Library_Controller_Object);
-- The elaboration and finalization of this object perform the required
-- initialization and cleanup actions for the sockets library.
--------------------
-- Create_Address --
--------------------
function Create_Address
(Family : Family_Inet_4_6; Bytes : Inet_Addr_Bytes) return Inet_Addr_Type
is
(case Family is
when Family_Inet => (Family_Inet, Bytes),
when Family_Inet6 => (Family_Inet6, Bytes));
---------------
-- Get_Bytes --
---------------
function Get_Bytes (Addr : Inet_Addr_Type) return Inet_Addr_Bytes is
(case Addr.Family is
when Family_Inet => Addr.Sin_V4,
when Family_Inet6 => Addr.Sin_V6);
----------
-- Mask --
----------
function Mask
(Family : Family_Inet_4_6;
Length : Natural;
Host : Boolean := False) return Inet_Addr_Type
is
Addr_Len : constant Natural := Inet_Addr_Bytes_Length (Family);
begin
if Length > 8 * Addr_Len then
raise Constraint_Error with
"invalid mask length for address family " & Family'Img;
end if;
declare
B : Inet_Addr_Bytes (1 .. Addr_Len);
Part : Inet_Addr_Comp_Type;
begin
for J in 1 .. Length / 8 loop
B (J) := (if Host then 0 else 255);
end loop;
if Length < 8 * Addr_Len then
Part := 2 ** (8 - Length mod 8) - 1;
B (Length / 8 + 1) := (if Host then Part else not Part);
for J in Length / 8 + 2 .. B'Last loop
B (J) := (if Host then 255 else 0);
end loop;
end if;
return Create_Address (Family, B);
end;
end Mask;
-------------------------
-- Unix_Socket_Address --
-------------------------
function Unix_Socket_Address (Addr : String) return Sock_Addr_Type is
begin
return Sock_Addr_Type'(Family_Unix, ASU.To_Unbounded_String (Addr));
end Unix_Socket_Address;
-----------
-- "and" --
-----------
function "and" (Addr, Mask : Inet_Addr_Type) return Inet_Addr_Type is
begin
if Addr.Family /= Mask.Family then
raise Constraint_Error with "incompatible address families";
end if;
declare
A : constant Inet_Addr_Bytes := Get_Bytes (Addr);
M : constant Inet_Addr_Bytes := Get_Bytes (Mask);
R : Inet_Addr_Bytes (A'Range);
begin
for J in A'Range loop
R (J) := A (J) and M (J);
end loop;
return Create_Address (Addr.Family, R);
end;
end "and";
----------
-- "or" --
----------
function "or" (Net, Host : Inet_Addr_Type) return Inet_Addr_Type is
begin
if Net.Family /= Host.Family then
raise Constraint_Error with "incompatible address families";
end if;
declare
N : constant Inet_Addr_Bytes := Get_Bytes (Net);
H : constant Inet_Addr_Bytes := Get_Bytes (Host);
R : Inet_Addr_Bytes (N'Range);
begin
for J in N'Range loop
R (J) := N (J) or H (J);
end loop;
return Create_Address (Net.Family, R);
end;
end "or";
-----------
-- "not" --
-----------
function "not" (Mask : Inet_Addr_Type) return Inet_Addr_Type is
M : constant Inet_Addr_Bytes := Get_Bytes (Mask);
R : Inet_Addr_Bytes (M'Range);
begin
for J in R'Range loop
R (J) := not M (J);
end loop;
return Create_Address (Mask.Family, R);
end "not";
end GNAT.Sockets;
|
reznikmm/matreshka | Ada | 12,225 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.DC;
with AMF.DG.Clip_Paths;
with AMF.DG.Groups;
with AMF.DG.Markers;
with AMF.DG.Styles.Collections;
with AMF.Elements;
with AMF.Internals.Element_Collections;
with AMF.Internals.Helpers;
with AMF.Internals.Tables.DD_Attributes;
with AMF.Visitors.DG_Iterators;
with AMF.Visitors.DG_Visitors;
package body AMF.Internals.DG_Lines is
---------------
-- Get_Start --
---------------
overriding function Get_Start
(Self : not null access constant DG_Line_Proxy)
return AMF.DC.DC_Point is
begin
return
AMF.Internals.Tables.DD_Attributes.Internal_Get_Start
(Self.Element);
end Get_Start;
---------------
-- Set_Start --
---------------
overriding procedure Set_Start
(Self : not null access DG_Line_Proxy;
To : AMF.DC.DC_Point) is
begin
AMF.Internals.Tables.DD_Attributes.Internal_Set_Start
(Self.Element, To);
end Set_Start;
-------------
-- Get_End --
-------------
overriding function Get_End
(Self : not null access constant DG_Line_Proxy)
return AMF.DC.DC_Point is
begin
return
AMF.Internals.Tables.DD_Attributes.Internal_Get_End
(Self.Element);
end Get_End;
-------------
-- Set_End --
-------------
overriding procedure Set_End
(Self : not null access DG_Line_Proxy;
To : AMF.DC.DC_Point) is
begin
AMF.Internals.Tables.DD_Attributes.Internal_Set_End
(Self.Element, To);
end Set_End;
----------------------
-- Get_Start_Marker --
----------------------
overriding function Get_Start_Marker
(Self : not null access constant DG_Line_Proxy)
return AMF.DG.Markers.DG_Marker_Access is
begin
return
AMF.DG.Markers.DG_Marker_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.DD_Attributes.Internal_Get_Start_Marker
(Self.Element)));
end Get_Start_Marker;
----------------------
-- Set_Start_Marker --
----------------------
overriding procedure Set_Start_Marker
(Self : not null access DG_Line_Proxy;
To : AMF.DG.Markers.DG_Marker_Access) is
begin
AMF.Internals.Tables.DD_Attributes.Internal_Set_Start_Marker
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Start_Marker;
--------------------
-- Get_End_Marker --
--------------------
overriding function Get_End_Marker
(Self : not null access constant DG_Line_Proxy)
return AMF.DG.Markers.DG_Marker_Access is
begin
return
AMF.DG.Markers.DG_Marker_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.DD_Attributes.Internal_Get_End_Marker
(Self.Element)));
end Get_End_Marker;
--------------------
-- Set_End_Marker --
--------------------
overriding procedure Set_End_Marker
(Self : not null access DG_Line_Proxy;
To : AMF.DG.Markers.DG_Marker_Access) is
begin
AMF.Internals.Tables.DD_Attributes.Internal_Set_End_Marker
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_End_Marker;
--------------------
-- Get_Mid_Marker --
--------------------
overriding function Get_Mid_Marker
(Self : not null access constant DG_Line_Proxy)
return AMF.DG.Markers.DG_Marker_Access is
begin
return
AMF.DG.Markers.DG_Marker_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.DD_Attributes.Internal_Get_Mid_Marker
(Self.Element)));
end Get_Mid_Marker;
--------------------
-- Set_Mid_Marker --
--------------------
overriding procedure Set_Mid_Marker
(Self : not null access DG_Line_Proxy;
To : AMF.DG.Markers.DG_Marker_Access) is
begin
AMF.Internals.Tables.DD_Attributes.Internal_Set_Mid_Marker
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Mid_Marker;
---------------
-- Get_Group --
---------------
overriding function Get_Group
(Self : not null access constant DG_Line_Proxy)
return AMF.DG.Groups.DG_Group_Access is
begin
return
AMF.DG.Groups.DG_Group_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.DD_Attributes.Internal_Get_Group
(Self.Element)));
end Get_Group;
---------------
-- Set_Group --
---------------
overriding procedure Set_Group
(Self : not null access DG_Line_Proxy;
To : AMF.DG.Groups.DG_Group_Access) is
begin
AMF.Internals.Tables.DD_Attributes.Internal_Set_Group
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Group;
---------------------
-- Get_Local_Style --
---------------------
overriding function Get_Local_Style
(Self : not null access constant DG_Line_Proxy)
return AMF.DG.Styles.Collections.Ordered_Set_Of_DG_Style is
begin
return
AMF.DG.Styles.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.DD_Attributes.Internal_Get_Local_Style
(Self.Element)));
end Get_Local_Style;
----------------------
-- Get_Shared_Style --
----------------------
overriding function Get_Shared_Style
(Self : not null access constant DG_Line_Proxy)
return AMF.DG.Styles.Collections.Ordered_Set_Of_DG_Style is
begin
return
AMF.DG.Styles.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.DD_Attributes.Internal_Get_Shared_Style
(Self.Element)));
end Get_Shared_Style;
-------------------
-- Get_Transform --
-------------------
overriding function Get_Transform
(Self : not null access constant DG_Line_Proxy)
return AMF.DG.Sequence_Of_DG_Transform is
begin
return
AMF.Internals.Tables.DD_Attributes.Internal_Get_Transform
(Self.Element);
end Get_Transform;
-------------------
-- Get_Clip_Path --
-------------------
overriding function Get_Clip_Path
(Self : not null access constant DG_Line_Proxy)
return AMF.DG.Clip_Paths.DG_Clip_Path_Access is
begin
return
AMF.DG.Clip_Paths.DG_Clip_Path_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.DD_Attributes.Internal_Get_Clip_Path
(Self.Element)));
end Get_Clip_Path;
-------------------
-- Set_Clip_Path --
-------------------
overriding procedure Set_Clip_Path
(Self : not null access DG_Line_Proxy;
To : AMF.DG.Clip_Paths.DG_Clip_Path_Access) is
begin
AMF.Internals.Tables.DD_Attributes.Internal_Set_Clip_Path
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Clip_Path;
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant DG_Line_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.DG_Visitors.DG_Visitor'Class then
AMF.Visitors.DG_Visitors.DG_Visitor'Class
(Visitor).Enter_Line
(AMF.DG.Lines.DG_Line_Access (Self),
Control);
end if;
end Enter_Element;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant DG_Line_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.DG_Visitors.DG_Visitor'Class then
AMF.Visitors.DG_Visitors.DG_Visitor'Class
(Visitor).Leave_Line
(AMF.DG.Lines.DG_Line_Access (Self),
Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant DG_Line_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Iterator in AMF.Visitors.DG_Iterators.DG_Iterator'Class then
AMF.Visitors.DG_Iterators.DG_Iterator'Class
(Iterator).Visit_Line
(Visitor,
AMF.DG.Lines.DG_Line_Access (Self),
Control);
end if;
end Visit_Element;
end AMF.Internals.DG_Lines;
|
stcarrez/ada-mail | Ada | 971 | ads | -----------------------------------------------------------------------
-- mail-testsuite -- Testsuite for mail
-- Copyright (C) 2020 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Tests;
package Mail.Testsuite is
function Suite return Util.Tests.Access_Test_Suite;
end Mail.Testsuite;
|
faelys/natools | Ada | 2,251 | ads | ------------------------------------------------------------------------------
-- Copyright (c) 2014, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Natools.Time_IO is a minimal parent for children packages which provide --
-- subprograms to serialize and deserialize times to and from various --
-- String representations. --
------------------------------------------------------------------------------
package Natools.Time_IO is
pragma Pure;
private
subtype Digit_Character is Character range '0' .. '9';
subtype Digit_Number is Integer range 0 .. 9;
function Image (N : Digit_Number) return Digit_Character
is (Character'Val (N + Character'Pos (Digit_Character'First)));
function Value (C : Digit_Character) return Digit_Number
is (Character'Pos (C) - Character'Pos (Digit_Character'First));
function Trim_Image (Raw_Image : String) return String
is (if Raw_Image'Length > 0 and then Raw_Image (Raw_Image'First) = ' '
then Raw_Image (Raw_Image'First + 1 .. Raw_Image'Last)
else Raw_Image);
end Natools.Time_IO;
|
reznikmm/matreshka | Ada | 4,673 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Visitors;
with ODF.DOM.Draw_Marker_Elements;
package Matreshka.ODF_Draw.Marker_Elements is
type Draw_Marker_Element_Node is
new Matreshka.ODF_Draw.Abstract_Draw_Element_Node
and ODF.DOM.Draw_Marker_Elements.ODF_Draw_Marker
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Draw_Marker_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Draw_Marker_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Draw_Marker_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Leave_Node
(Self : not null access Draw_Marker_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Visit_Node
(Self : not null access Draw_Marker_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
end Matreshka.ODF_Draw.Marker_Elements;
|
AdaCore/training_material | Ada | 25,637 | adb | -----------------------------------------------------------------------
-- Ada Labs --
-- --
-- Copyright (C) 2008-2013, AdaCore --
-- --
-- Labs is free software; you can redistribute it and/or modify it --
-- under the terms of the GNU General Public License as published by --
-- the Free Software Foundation; either version 2 of the License, or --
-- (at your option) any later version. --
-- --
-- This program is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. You should have received --
-- a copy of the GNU General Public License along with this program; --
-- if not, write to the Free Software Foundation, Inc., 59 Temple --
-- Place - Suite 330, Boston, MA 02111-1307, USA. --
-----------------------------------------------------------------------
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings; use Interfaces.C.Strings;
with SDL_stdinc_h; use SDL_stdinc_h;
with SDL_video_h; use SDL_video_h;
with System;
with Ada.Text_IO; use Ada.Text_IO;
with SDL_error_h; use SDL_error_h;
with SDL_h; use SDL_h;
with System.Storage_Elements;
with System.Address_To_Access_Conversions;
with Interfaces; use Interfaces;
with SDL_events_h; use SDL_events_h;
with Ada.Real_Time; use Ada.Real_Time;
with Display.Basic.Fonts; use Display.Basic.Fonts;
with Display.Basic.Utils; use Display.Basic.Utils;
with SDL_surface_h; use SDL_surface_h;
with SDL_pixels_h; use SDL_pixels_h;
package body Display.Basic is
---------------
-- SDL STATE --
---------------
--Surface : access SDL_Surface;
-- Vid_Info : access SDL_VideoInfo;
-- Sdl_Width : constant Integer := 800;
-- Sdl_Height : constant Integer := 800;
-- BPP : constant Interfaces.C.int := 32;
-- Sdl_Flags : constant Interfaces.C.unsigned :=
-- SDL_HWSURFACE + SDL_RESIZABLE + SDL_DOUBLEBUF;
Initialized : boolean := False with Atomic, Volatile;
type Cart_Point is record
X, Y : Float;
end record;
-- function "+" (P : Cart_Point; S : SDL_Surface) return Screen_Point
-- is ((X => Integer (C.Zoom_Factor * P.X) + Integer(C.Surface.w / 2) + C.Center.X,
--Y => Integer(C.Surface.h / 2) - C.Center.Y - Integer (C.Zoom_Factor * P.Y)));
-- ((X => Integer (Zoom_Factor * P.X) + Integer(S.w / 2),
-- Y => Integer(S.h / 2) - Integer (Zoom_Factor * P.Y)));
function To_Screen_Point (C : T_Internal_Canvas; P : Cart_Point) return Screen_Point
is
((X => Integer (C.Zoom_Factor * P.X) + Integer(C.Surface.w / 2) - C.Center.X,
Y => Integer(C.Surface.h / 2) + C.Center.Y - Integer (C.Zoom_Factor * P.Y)));
function To_Point3d (Canvas : Canvas_ID; P : Screen_Point) return Point_3d is
C : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
return (Float(P.X - Integer(C.Surface.w / 2) - C.Center.X),
Float(Integer(C.Surface.h / 2) - C.Center.Y - P.Y),
0.0);
end To_Point3d;
function Get_Zoom_Factor(Canvas : Canvas_ID) return Float is (Get_Internal_Canvas(Canvas).Zoom_Factor);
procedure Set_Zoom_Factor (Canvas : Canvas_ID; ZF : Float) is
begin
Display.Basic.Utils.Set_Zoom_Factor(Canvas, ZF);
end Set_Zoom_Factor;
function To_Screen_Point (Canvas : Canvas_ID; P : Point_3d) return Screen_Point is
C : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
return To_Screen_Point(C, (P.X, P.Y));
end To_Screen_Point;
function Scale (Canvas: T_Internal_Canvas; L : Float) return Integer is (Integer (L * Canvas.Zoom_Factor));
procedure Set_Center (Canvas : Canvas_ID; Position : Point_3d) is
C : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
Display.Basic.Utils.Set_Center(Canvas, (Scale(C, Position.X), Scale(C, Position.Y)));
end Set_Center;
procedure Set_Center (Canvas : Canvas_ID; Position : Screen_Point) is
begin
Display.Basic.Utils.Set_Center(Canvas, Position);
end Set_Center;
function Get_Center (Canvas : Canvas_ID) return Screen_Point is
begin
return Display.Basic.Utils.Get_Center(Canvas);
end Get_Center;
-----------------
-- Draw_Circle --
-----------------
procedure Draw_Circle (Surface : access SDL_Surface; P : Screen_Point; Radius : Integer; Color : RGBA_T)
is
CX, CY, Radius_Error : Integer;
UC : Uint32 := RGBA_To_Uint32(Surface, Color);
begin
if SDL_LockSurface (Surface) < 0 then
raise Display_Error;
end if;
CX := Radius;
CY := 0;
Radius_Error := 1 - CX;
while CX >= CY loop
Put_Pixel (Surface, CX + P.X, CY + P.Y, UC);
Put_Pixel (Surface, CY + P.X, CX + P.Y, UC);
Put_Pixel (Surface, -CX + P.X, CY + P.Y, UC);
Put_Pixel (Surface, -CY + P.X, CX + P.Y, UC);
Put_Pixel (Surface, -CX + P.X, -CY + P.Y, UC);
Put_Pixel (Surface, -CY + P.X, -CX + P.Y, UC);
Put_Pixel (Surface, CX + P.X, -CY + P.Y, UC);
Put_Pixel (Surface, CY + P.X, -CX + P.Y, UC);
CY := CY + 1;
if Radius_Error < 0 then
Radius_Error := Radius_Error + (2 * CY + 1);
else
CX := CX - 1;
Radius_Error := Radius_Error + (2 * (CY - CX) + 1);
end if;
end loop;
SDL_UnlockSurface (Surface);
end Draw_Circle;
procedure Draw_Circle (Canvas : Canvas_ID; Position: Point_3d; Radius : Float; Color: RGBA_T) is
C : T_Internal_Canvas := Get_Internal_Canvas (Canvas);
begin
Draw_Circle(C.Surface,
To_Screen_Point(C, (Position.X, Position.Y)),
Scale (C, Radius),
Color);
end Draw_Circle;
procedure Draw_Circle (Canvas : Canvas_ID; Position: Screen_Point; Radius : Integer; Color: RGBA_T) is
C : T_Internal_Canvas := Get_Internal_Canvas (Canvas);
begin
Draw_Circle(C.Surface,
Position,
Radius,
Color);
end Draw_Circle; ---------------
-- Draw_Line --
---------------
-- procedure Draw_Line
-- (Surface : access SDL_Surface; P_Start, P_End : Screen_Point; Color : RGBA_Color)
-- is
-- DX : Integer := P_End.X - P_Start.X;
-- DY : Integer := P_End.Y - P_Start.Y;
-- D : Integer := 2 * DY - DX;
-- Y : Integer := P_Start.Y;
-- begin
-- Put_Pixel (Surface, P_Start.X, P_Start.Y, Color);
-- for X in P_Start.X +1 .. P_End.X loop
-- if D > 0 then
-- Y := Y + 1;
-- Put_Pixel (Surface, X, Y, Color);
-- D := D + (2 * DY - 2 * DX);
-- else
-- Put_Pixel (Surface, X, Y, Color);
-- D := D + (2 * DY);
-- end if;
-- end loop;
-- end Draw_Line;
procedure Draw_Line (Surface : access SDL_Surface; P0 : Screen_Point; P1 : Screen_Point; Color : Uint32) is
dx : constant Integer := abs (P1.X - P0.X);
sx : constant Integer := (if P0.X < P1.X then 1 else -1);
dy : constant Integer := abs (P1.Y - P0.Y);
sy : constant Integer := (if P0.Y < P1.Y then 1 else -1);
err : Integer := (if dx > dy then dx else - dy) / 2;
e2 : Integer;
X : Integer := P0.X;
Y : Integer := P0.Y;
begin
loop
Put_Pixel (Surface, X, Y, Color);
if X = P1.X and then Y = P1.Y then
return;
end if;
e2 := err;
if e2 > -dx then
err := err - dy;
X := X + sx;
end if;
if e2 < dy then
err := err + dx;
Y := Y + sy;
end if;
end loop;
end Draw_Line;
procedure Draw_Line (Surface : access SDL_Surface; P0 : Screen_Point; P1 : Screen_Point; Color : RGBA_T) is
begin
Draw_Line(Surface, P0, P1, RGBA_To_Uint32(Surface, Color));
end Draw_Line;
procedure Draw_Line (Canvas : Canvas_ID; P1: Point_3d; P2 : Point_3d; Color: RGBA_T) is
C : T_Internal_Canvas := Get_Internal_Canvas (Canvas);
begin
Draw_Line (C.Surface,
To_Screen_Point(C, (P1.X, P1.Y)),
To_Screen_Point(C, (P2.X, P2.Y)),
Color);
end Draw_Line;
procedure Draw_Line (Canvas : Canvas_ID; P1: Screen_Point; P2 : Screen_Point; Color: RGBA_T) is
C : T_Internal_Canvas := Get_Internal_Canvas (Canvas);
begin
Draw_Line (C.Surface,
P1,
P2,
Color);
end Draw_Line;
procedure Draw_Rect
(Surface: access SDL_Surface; P : Screen_Point; Width, Height : Integer; Color : RGBA_T)
is
UC : Uint32 := RGBA_To_Uint32(Surface, Color);
begin
Draw_Line(Surface, P, (P.x + Width - 1, P.Y), UC);
Draw_Line(Surface, P, (P.x, P.Y + Height - 1), UC);
Draw_Line(Surface, (P.x + Width - 1, P.Y), (P.x + Width - 1, P.Y + Height - 1), UC);
Draw_Line(Surface, (P.x, P.Y + Height - 1), (P.x + Width - 1, P.Y + Height - 1), UC);
end Draw_Rect;
procedure Draw_Fill_Rect
(Surface: access SDL_Surface; P : Screen_Point; Width, Height : Integer; Color : RGBA_T)
is
UC : Uint32 := RGBA_To_Uint32(Surface, Color);
begin
for I in 0 .. Width - 1 loop
for J in 0 .. Height - 1 loop
Put_Pixel (Surface, P.X + I, P.Y + J, UC);
end loop;
end loop;
end Draw_Fill_Rect;
procedure Draw_Rect(Canvas : Canvas_ID; Position : Point_3d; Width, Height : Float; Color : RGBA_T) is
IC : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
Draw_Rect(IC.Surface,
To_Screen_Point(IC, (Position.X, Position.Y)),
Scale(IC, Width),
Scale (IC, Height),
Color);
end Draw_Rect;
procedure Draw_Rect(Canvas : Canvas_ID; Position : Screen_Point; Width, Height : Integer; Color : RGBA_T) is
IC : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
Draw_Rect(IC.Surface,
Position,
Width,
Height,
Color);
end Draw_Rect;
procedure Draw_Fill_Rect (Canvas : Canvas_ID; Position : Point_3d; Width, Height : Float; Color : RGBA_T) is
IC : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
Draw_Fill_Rect(IC.Surface,
To_Screen_Point(IC, (Position.X, Position.Y)),
Scale(IC, Width),
Scale (IC, Height),
Color);
end Draw_Fill_Rect;
procedure Draw_Fill_Rect (Canvas : Canvas_ID; Position : Screen_Point; Width, Height : Integer; Color : RGBA_T) is
IC : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
Draw_Fill_Rect(IC.Surface,
Position,
Width,
Height,
Color);
end Draw_Fill_Rect;
---------------
------------------------
-- Draw_Filled_Circle --
------------------------
-- procedure Draw_Filled_Circle
-- (Surface : access SDL_Surface; P : Screen_Point; Radius : Integer; Color : RGBA_Color)
-- is
-- begin
-- if SDL_LockSurface (Surface) < 0 then
-- raise Display_Error;
-- end if;
--
-- for Y in -Radius .. Radius loop
-- for X in -Radius .. Radius loop
-- if X * X + Y * Y < Radius * Radius then
-- Put_Pixel (Surface, P.X + X, P.Y + Y, Color);
-- end if;
-- end loop;
-- end loop;
-- SDL_UnlockSurface (Surface);
--
-- end Draw_Filled_Circle;
procedure Draw_Filled_Circle (Surface : access SDL_Surface; P : Screen_Point; Radius : Integer; Color : RGBA_T) is
r : Integer := Radius;
x : Integer := -r;
y : Integer := 0;
err : Integer := 2 - 2 * r; --/ * II. Quadrant * /
UC : Uint32 := RGBA_To_Uint32(Surface, Color);
begin
if SDL_LockSurface (Surface) < 0 then
raise Display_Error;
end if;
if Radius <= 1 then
Put_Pixel (Surface, P.X, P.Y, UC);
else
while x < 0 loop
Draw_Line (Surface, (P.X - x, P.Y - y), (P.X + x, P.Y - y), UC);
Draw_Line (Surface, (P.X - x, P.Y + y), (P.X + x, P.Y + y), UC);
r := err;
if r <= y then
y := y + 1;
err := err + y * 2 + 1; -- / * e_xy + e_y < 0 * /
end if;
if r > x or else err > y then
x := x + 1;
err := err + x * 2 + 1; --/ * e_xy + e_x > 0 or no 2nd y - step * /
end if;
if x >= 0 then
return;
end if;
end loop;
end if;
SDL_UnlockSurface (Surface);
end Draw_Filled_Circle;
procedure Draw_Sphere (Canvas : Canvas_ID; Position: Screen_Point; Radius : Integer; Color: RGBA_T)is
C : T_Internal_Canvas := Get_Internal_Canvas (Canvas);
begin
Draw_Filled_Circle(C.Surface,
Position,
Radius,
Color);
end Draw_Sphere;
procedure Draw_Sphere (Canvas : Canvas_ID; Position: Point_3d; Radius : Float; Color: RGBA_T) is
C : T_Internal_Canvas := Get_Internal_Canvas (Canvas);
begin
Draw_Filled_Circle(C.Surface,
To_Screen_Point(C, (Position.X, Position.Y)),
Scale (C, Radius),
Color);
end Draw_Sphere;
---------------
-- Draw_Ring --
---------------
procedure Draw_Ring
(Surface : access SDL_Surface; P : Screen_Point; Radius, Inner_Radius : Integer; Color : RGBA_T) is
UC : Uint32 := RGBA_To_Uint32(Surface, Color);
begin
for Y in -Radius .. Radius loop
for X in -Radius .. Radius loop
declare
T : Integer := X * X + Y * Y;
begin
if T < Radius * Radius and then T >= Inner_Radius * Inner_Radius
then
Put_Pixel (Surface, P.X + X, P.Y + Y, UC);
end if;
end;
end loop;
end loop;
end Draw_Ring;
-- ----------
-- -- Draw --
-- ----------
--
-- procedure Draw (Canvas: T_Internal_Canvas; Inst : Shape) is
-- begin
-- case Inst.Kind is
-- when Circle =>
-- Draw_Filled_Circle
-- (Canvas.Surface,
-- To_Screen_Point(Canvas, (Inst.X, Inst.Y)),
-- Scale (Canvas, Inst.Radius),
-- Color_Map (Inst.Color));
-- when Torus =>
-- Draw_Ring
-- (Canvas.Surface,
-- To_Screen_Point(Canvas, (Inst.X, Inst.Y)), Scale (Canvas, Inst.Outer),
-- Scale (Canvas, Inst.Inner),
-- Color_Map (Inst.Color));
-- when Box =>
-- Draw_Box
-- (Canvas.Surface,
-- To_Screen_Point (Canvas, (Inst.X, Inst.Y)),
-- Scale (Canvas, Inst.Width),
-- Scale (Canvas, Inst.Height),
-- Color_Map (Inst.Color));
-- when Line =>
-- Draw_Line (Canvas.Surface,
-- To_Screen_Point(Canvas, (Inst.X, Inst.Y)),
-- To_Screen_Point(Canvas, (Inst.End_X, Inst.End_Y)),
-- Color_Map (Inst.Color));
-- when others => null;
-- end case;
-- end Draw;
-----------
-- Check --
-----------
procedure Check (Ret : Int) is
begin
if Ret /= 0 then
raise Display_Error;
end if;
end Check;
procedure Poll_Events;
Internal_Cursor : Cursor_T := ((0,0), False);
Killed : Boolean := False;
function Is_Killed return Boolean is
begin
return Killed;
end Is_Killed;
procedure Poll_Events is
E : aliased SDL_Event;
begin
while SDL_PollEvent (E'Access) /= 0 loop
case unsigned (E.c_type) is
when SDL_events_h.SDL_QUIT_Evt =>
Killed := True;
SDL_h.SDL_Quit;
when SDL_events_h.SDL_MOUSEBUTTONDOWN =>
Internal_Cursor.Position := (Integer(E.motion.x), Integer(E.motion.y));
Internal_Cursor.Pressed := True;
when SDL_events_h.SDL_MOUSEBUTTONUP =>
Internal_Cursor.Position := (Integer(E.motion.x), Integer(E.motion.y));
Internal_Cursor.Pressed := False;
when others =>
null;
end case;
end loop;
end Poll_Events;
function Get_Cursor_Status return Cursor_T is
begin
Poll_Events;
return Internal_Cursor;
end Get_Cursor_Status;
procedure Draw_Text (Canvas : Canvas_ID; Position: Point_3d; Text : String; Color: RGBA_T; Bg_Color : RGBA_T := Black; Wrap: Boolean := True) is
IC : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
Draw_String(IC,
P => To_Screen_Point(IC, (Position.X, Position.Y)),
Str => Text,
Font => Font8x8,
FG => Color,
BG => Bg_Color,
Wrap => Wrap);
end Draw_Text;
procedure Draw_Text (Canvas : Canvas_ID; Position: Screen_Point; Text : String; Color: RGBA_T; Bg_Color : RGBA_T := Black; Wrap: Boolean := True) is
IC : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
Draw_String(IC,
P => Position,
Str => Text,
Font => Font8x8,
FG => Color,
BG => Bg_Color,
Wrap => Wrap);
end Draw_Text;
function Get_Text_Size(Text : String) return Screen_Point is
begin
return String_Size (Font8x8, Text);
end Get_Text_Size;
procedure Set_Pixel (Canvas : Canvas_ID; Position : Screen_Point; Color : RGBA_T) is
IC : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
begin
Display.Basic.Utils.Put_Pixel_Slow(Screen => IC.Surface,
X => Position.X,
Y => Position.Y,
Color => Color);
end Set_Pixel;
-------------------
-- Set_SDL_Video --
-------------------
type SDL_Window_Surface is record
surface : Canvas_ID;
window : access SDL_Window;
w : Integer := 400;
h : Integer := 400;
bpp : Interfaces.C.int := 32;
-- flags : Interfaces.C.unsigned := SDL_HWSURFACE + SDL_RESIZABLE + SDL_DOUBLEBUF;
end record;
type Windows_Array is array (Window_ID) of SDL_Window_Surface;
Nb_Windows : Integer := 0;
Stored_Windows : Windows_Array;
function Create_SDL_Window (Width : Integer; Height : Integer; Name : String) return SDL_Window_Surface;
function Create_Window (Width : Integer; Height : Integer; Name : String) return Window_ID is
Current_Id : Window_ID;
begin
if Nb_Windows = Windows_Array'Length then
raise Too_Many_Windows;
end if;
Current_Id := Window_ID (Integer (Window_ID'First) + Nb_Windows);
Stored_Windows(Current_Id) := Create_SDL_Window (Width, Height, Name);
Nb_Windows := Nb_Windows + 1;
return Current_Id;
end Create_Window;
SDL_S : access SDL_Surface;
function Create_SDL_Window (Width : Integer; Height : Integer; Name : String) return SDL_Window_Surface is
S : SDL_Window_Surface;
PF : Uint32;
CP : Interfaces.C.Strings.chars_ptr;
begin
if not Initialized then
raise Graphical_Context_Not_Initialized;
end if;
-- To center a non-fullscreen window we need to set an environment
-- variable
S.window := SDL_CreateWindow(New_String(Name), SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
Interfaces.C.int(Width),
Interfaces.C.int(Height),
SDL_WINDOW_SHOWN);
PF := SDL_GetWindowPixelFormat(S.window);
CP := SDL_GetPixelFormatName(PF);
-- Ada.Text_IO.Put_Line ("screen pixel format = " & Integer'Image(Integer(PF)) & " : " & Value (CP));
-- the setVideoMode function returns the current frame buffer as an
-- SDL_Surface. Again, we grab a pointer to it, then place its
-- content into the non pointery surface variable. I say 'non-pointery',
-- but this SDL variable must have a pointer in it because it can
-- access the current pixels in the framebuffer.
S.w := Width;
S.h := Height;
SDL_S := SDL_GetWindowSurface(S.window);
if SDL_S = null then
Put_Line ("Error setting the video mode");
Put_Line(Value (SDL_GetError));
SDL_h.SDL_Quit;
raise Graphical_Context_Not_Initialized;
end if;
S.surface := Register_SDL_Surface(SDL_S);
return S;
end Create_SDL_Window;
function Get_Canvas(Window : Window_ID) return Canvas_ID is
begin
return Stored_Windows(Window).surface;
end Get_Canvas;
function Get_Canvas_Size(Canvas : Canvas_ID) return Screen_Point is
IC : T_Internal_Canvas := Get_Internal_Canvas (Canvas);
begin
return Screen_Point'(Integer(IC.Surface.w), Integer(IC.Surface.h));
end Get_Canvas_Size;
----------
-- Draw --
----------
procedure Swap_Buffers (Window : Window_ID; Erase : Boolean := True) is
Canvas : T_Internal_Canvas := Get_Internal_Canvas(Get_Canvas(Window));
begin
-- if SDL_LockSurface (Canvas.Surface) < 0 then
-- raise Display_Error;
-- end if;
--
--
-- for Id in Shapes'First .. Max_Shape_Id loop
-- Draw (Canvas, Shapes (Id));
-- end loop;
-- SDL_UnlockSurface (Canvas.Surface);
if SDL_UpdateWindowSurface (Stored_Windows(Window).window) < 0 then
raise Display_Error;
end if;
if Erase then
if SDL_FillRect (Canvas.Surface, null, 0) < 0 then
raise Display_Error;
end if;
end if;
Poll_Events;
end Swap_Buffers;
procedure Swap_Copy_Buffers (Window : Window_ID) is
begin
Swap_Buffers(Window, False);
end Swap_Copy_Buffers;
procedure Fill(Canvas : Canvas_ID; Color: RGBA_T) is
IC : T_Internal_Canvas := Get_Internal_Canvas(Canvas);
UC : Uint32 := RGBA_To_Uint32(IC.Surface, Color);
begin
if SDL_FillRect (IC.Surface, null, UC) < 0 then
raise Display_Error;
end if;
end Fill;
procedure Init is
begin
-- SDL is comprised of 8 subsystems. Here we initialize the video
if SDL_Init(SDL_INIT_VIDEO) < 0 then
Put_Line ("Error initializing SDL");
Put_Line(Value (SDL_GetError));
SDL_h.SDL_Quit;
raise Graphical_Context_Not_Initialized;
end if;
Initialized := True;
end Init;
procedure Enable_3d_Light (Canvas : Canvas_ID) is
begin
-- does not do anything without opengl
null;
end Enable_3d_Light;
procedure Disable_3d_Light (Canvas : Canvas_ID) is
begin
-- does not do anything without opengl
null;
end Disable_3d_Light;
procedure Set_3d_Light (Canvas : Canvas_ID;
Position : Point_3d;
Diffuse_Color : RGBA_T;
Ambient_Color : RGBA_T) is
begin
-- does not do anything without opengl
null;
end Set_3d_Light;
-------------------------
-- NOT YET IMPLEMENTED --
-------------------------
-- function New_Text
-- (X : Float;
-- Y : Float;
-- Text : String;
-- Color : Color_Type)
-- return Shape_Id is (Null_Shape_Id);
-- procedure Set_Text (V : in out Shape_Id; Text : String) is null;
-- function Get_Text (V : Shape_Id) return String is ("");
-- function Current_Key_Press return Key_Type is (0);
-- function To_Character (Key : Key_Type) return Character is (' ');
-- function To_Special (Key : Key_Type) return Special_Key is (KEY_NONE);
-- function Is_Special_Key (Key : Key_Type) return Boolean is (False);
-- function Is_Control_Key (Key : Key_Type) return Boolean is (False);
-- function Is_Shift_Key (Key : Key_Type) return Boolean is (False);
-- function Is_Alt_Key (Key : Key_Type) return Boolean is (False);
-- function Read_Last_Mouse_Position return Mouse_Position
-- is (No_Mouse_Position);
-- function At_End return Boolean is (False);
begin
Init;
end Display.Basic;
|
smola/language-dataset | Ada | 837 | adb | package body Commands is
function Construct_Date_Time (D : Day; H : Hour; M : Minute) return Comm_Rec
is
SData : Comm_Rec (Set_Day_Time);
begin
SData.Dy := Day'Pos (D);
SData.Hr := H;
SData.Min := M;
return SData;
end Construct_Date_Time;
function Construct_Drive_Special (Special : Drive_Special;
V : Velocity)
return Comm_Rec
is
SData : Comm_Rec (Drive);
begin
case Special is
when Straight =>
SData.Rad.Value := 32767;
when CW =>
SData.Rad.Value := -1;
when CCW =>
SData.Rad.Value := 1;
end case;
SData.Vel.Value := V;
return SData;
end Construct_Drive_Special;
end Commands;
|
vpodzime/ada-util | Ada | 12,300 | ads | -----------------------------------------------------------------------
-- util-encoders-base64 -- Encode/Decode a stream in Base64
-- Copyright (C) 2009, 2010, 2011, 2012, 2016 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Streams;
with Interfaces;
-- The <b>Util.Encodes.Base64</b> packages encodes and decodes streams
-- in Base64 (See rfc4648: The Base16, Base32, and Base64 Data Encodings).
package Util.Encoders.Base64 is
pragma Preelaborate;
-- Encode the 64-bit value to LEB128 and then base64url.
function Encode (Value : in Interfaces.Unsigned_64) return String;
-- Decode the base64url string and then the LEB128 integer.
-- Raise the Encoding_Error if the string is invalid and cannot be decoded.
function Decode (Value : in String) return Interfaces.Unsigned_64;
-- ------------------------------
-- Base64 encoder
-- ------------------------------
-- This <b>Encoder</b> translates the (binary) input stream into
-- a Base64 ascii stream.
type Encoder is new Util.Encoders.Transformer with private;
-- Encodes the binary input stream represented by <b>Data</b> into
-- the a base64 output stream <b>Into</b>.
--
-- If the transformer does not have enough room to write the result,
-- it must return in <b>Encoded</b> the index of the last encoded
-- position in the <b>Data</b> stream.
--
-- The transformer returns in <b>Last</b> the last valid position
-- in the output stream <b>Into</b>.
--
-- The <b>Encoding_Error</b> exception is raised if the input
-- stream cannot be transformed.
overriding
procedure Transform (E : in Encoder;
Data : in Ada.Streams.Stream_Element_Array;
Into : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Encoded : out Ada.Streams.Stream_Element_Offset);
-- Set the encoder to use the base64 URL alphabet when <b>Mode</b> is True.
-- The URL alphabet uses the '-' and '_' instead of the '+' and '/' characters.
procedure Set_URL_Mode (E : in out Encoder;
Mode : in Boolean);
-- Create a base64 encoder using the URL alphabet.
-- The URL alphabet uses the '-' and '_' instead of the '+' and '/' characters.
function Create_URL_Encoder return Transformer_Access;
-- ------------------------------
-- Base64 decoder
-- ------------------------------
-- The <b>Decoder</b> decodes a Base64 ascii stream into a binary stream.
type Decoder is new Util.Encoders.Transformer with private;
-- Decodes the base64 input stream represented by <b>Data</b> into
-- the binary output stream <b>Into</b>.
--
-- If the transformer does not have enough room to write the result,
-- it must return in <b>Encoded</b> the index of the last encoded
-- position in the <b>Data</b> stream.
--
-- The transformer returns in <b>Last</b> the last valid position
-- in the output stream <b>Into</b>.
--
-- The <b>Encoding_Error</b> exception is raised if the input
-- stream cannot be transformed.
overriding
procedure Transform (E : in Decoder;
Data : in Ada.Streams.Stream_Element_Array;
Into : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Encoded : out Ada.Streams.Stream_Element_Offset);
-- Set the decoder to use the base64 URL alphabet when <b>Mode</b> is True.
-- The URL alphabet uses the '-' and '_' instead of the '+' and '/' characters.
procedure Set_URL_Mode (E : in out Decoder;
Mode : in Boolean);
-- Create a base64 decoder using the URL alphabet.
-- The URL alphabet uses the '-' and '_' instead of the '+' and '/' characters.
function Create_URL_Decoder return Transformer_Access;
private
type Alphabet is
array (Interfaces.Unsigned_8 range 0 .. 63) of Ada.Streams.Stream_Element;
type Alphabet_Access is not null access constant Alphabet;
BASE64_ALPHABET : aliased constant Alphabet :=
(Character'Pos ('A'), Character'Pos ('B'), Character'Pos ('C'), Character'Pos ('D'),
Character'Pos ('E'), Character'Pos ('F'), Character'Pos ('G'), Character'Pos ('H'),
Character'Pos ('I'), Character'Pos ('J'), Character'Pos ('K'), Character'Pos ('L'),
Character'Pos ('M'), Character'Pos ('N'), Character'Pos ('O'), Character'Pos ('P'),
Character'Pos ('Q'), Character'Pos ('R'), Character'Pos ('S'), Character'Pos ('T'),
Character'Pos ('U'), Character'Pos ('V'), Character'Pos ('W'), Character'Pos ('X'),
Character'Pos ('Y'), Character'Pos ('Z'), Character'Pos ('a'), Character'Pos ('b'),
Character'Pos ('c'), Character'Pos ('d'), Character'Pos ('e'), Character'Pos ('f'),
Character'Pos ('g'), Character'Pos ('h'), Character'Pos ('i'), Character'Pos ('j'),
Character'Pos ('k'), Character'Pos ('l'), Character'Pos ('m'), Character'Pos ('n'),
Character'Pos ('o'), Character'Pos ('p'), Character'Pos ('q'), Character'Pos ('r'),
Character'Pos ('s'), Character'Pos ('t'), Character'Pos ('u'), Character'Pos ('v'),
Character'Pos ('w'), Character'Pos ('x'), Character'Pos ('y'), Character'Pos ('z'),
Character'Pos ('0'), Character'Pos ('1'), Character'Pos ('2'), Character'Pos ('3'),
Character'Pos ('4'), Character'Pos ('5'), Character'Pos ('6'), Character'Pos ('7'),
Character'Pos ('8'), Character'Pos ('9'), Character'Pos ('+'), Character'Pos ('/'));
BASE64_URL_ALPHABET : aliased constant Alphabet :=
(Character'Pos ('A'), Character'Pos ('B'), Character'Pos ('C'), Character'Pos ('D'),
Character'Pos ('E'), Character'Pos ('F'), Character'Pos ('G'), Character'Pos ('H'),
Character'Pos ('I'), Character'Pos ('J'), Character'Pos ('K'), Character'Pos ('L'),
Character'Pos ('M'), Character'Pos ('N'), Character'Pos ('O'), Character'Pos ('P'),
Character'Pos ('Q'), Character'Pos ('R'), Character'Pos ('S'), Character'Pos ('T'),
Character'Pos ('U'), Character'Pos ('V'), Character'Pos ('W'), Character'Pos ('X'),
Character'Pos ('Y'), Character'Pos ('Z'), Character'Pos ('a'), Character'Pos ('b'),
Character'Pos ('c'), Character'Pos ('d'), Character'Pos ('e'), Character'Pos ('f'),
Character'Pos ('g'), Character'Pos ('h'), Character'Pos ('i'), Character'Pos ('j'),
Character'Pos ('k'), Character'Pos ('l'), Character'Pos ('m'), Character'Pos ('n'),
Character'Pos ('o'), Character'Pos ('p'), Character'Pos ('q'), Character'Pos ('r'),
Character'Pos ('s'), Character'Pos ('t'), Character'Pos ('u'), Character'Pos ('v'),
Character'Pos ('w'), Character'Pos ('x'), Character'Pos ('y'), Character'Pos ('z'),
Character'Pos ('0'), Character'Pos ('1'), Character'Pos ('2'), Character'Pos ('3'),
Character'Pos ('4'), Character'Pos ('5'), Character'Pos ('6'), Character'Pos ('7'),
Character'Pos ('8'), Character'Pos ('9'), Character'Pos ('-'), Character'Pos ('_'));
type Encoder is new Util.Encoders.Transformer with record
Alphabet : Alphabet_Access := BASE64_ALPHABET'Access;
end record;
type Alphabet_Values is array (Ada.Streams.Stream_Element) of Interfaces.Unsigned_8;
type Alphabet_Values_Access is not null access constant Alphabet_Values;
BASE64_VALUES : aliased constant Alphabet_Values :=
(Character'Pos ('A') => 0, Character'Pos ('B') => 1,
Character'Pos ('C') => 2, Character'Pos ('D') => 3,
Character'Pos ('E') => 4, Character'Pos ('F') => 5,
Character'Pos ('G') => 6, Character'Pos ('H') => 7,
Character'Pos ('I') => 8, Character'Pos ('J') => 9,
Character'Pos ('K') => 10, Character'Pos ('L') => 11,
Character'Pos ('M') => 12, Character'Pos ('N') => 13,
Character'Pos ('O') => 14, Character'Pos ('P') => 15,
Character'Pos ('Q') => 16, Character'Pos ('R') => 17,
Character'Pos ('S') => 18, Character'Pos ('T') => 19,
Character'Pos ('U') => 20, Character'Pos ('V') => 21,
Character'Pos ('W') => 22, Character'Pos ('X') => 23,
Character'Pos ('Y') => 24, Character'Pos ('Z') => 25,
Character'Pos ('a') => 26, Character'Pos ('b') => 27,
Character'Pos ('c') => 28, Character'Pos ('d') => 29,
Character'Pos ('e') => 30, Character'Pos ('f') => 31,
Character'Pos ('g') => 32, Character'Pos ('h') => 33,
Character'Pos ('i') => 34, Character'Pos ('j') => 35,
Character'Pos ('k') => 36, Character'Pos ('l') => 37,
Character'Pos ('m') => 38, Character'Pos ('n') => 39,
Character'Pos ('o') => 40, Character'Pos ('p') => 41,
Character'Pos ('q') => 42, Character'Pos ('r') => 43,
Character'Pos ('s') => 44, Character'Pos ('t') => 45,
Character'Pos ('u') => 46, Character'Pos ('v') => 47,
Character'Pos ('w') => 48, Character'Pos ('x') => 49,
Character'Pos ('y') => 50, Character'Pos ('z') => 51,
Character'Pos ('0') => 52, Character'Pos ('1') => 53,
Character'Pos ('2') => 54, Character'Pos ('3') => 55,
Character'Pos ('4') => 56, Character'Pos ('5') => 57,
Character'Pos ('6') => 58, Character'Pos ('7') => 59,
Character'Pos ('8') => 60, Character'Pos ('9') => 61,
Character'Pos ('+') => 62, Character'Pos ('/') => 63,
others => 16#FF#);
BASE64_URL_VALUES : aliased constant Alphabet_Values :=
(Character'Pos ('A') => 0, Character'Pos ('B') => 1,
Character'Pos ('C') => 2, Character'Pos ('D') => 3,
Character'Pos ('E') => 4, Character'Pos ('F') => 5,
Character'Pos ('G') => 6, Character'Pos ('H') => 7,
Character'Pos ('I') => 8, Character'Pos ('J') => 9,
Character'Pos ('K') => 10, Character'Pos ('L') => 11,
Character'Pos ('M') => 12, Character'Pos ('N') => 13,
Character'Pos ('O') => 14, Character'Pos ('P') => 15,
Character'Pos ('Q') => 16, Character'Pos ('R') => 17,
Character'Pos ('S') => 18, Character'Pos ('T') => 19,
Character'Pos ('U') => 20, Character'Pos ('V') => 21,
Character'Pos ('W') => 22, Character'Pos ('X') => 23,
Character'Pos ('Y') => 24, Character'Pos ('Z') => 25,
Character'Pos ('a') => 26, Character'Pos ('b') => 27,
Character'Pos ('c') => 28, Character'Pos ('d') => 29,
Character'Pos ('e') => 30, Character'Pos ('f') => 31,
Character'Pos ('g') => 32, Character'Pos ('h') => 33,
Character'Pos ('i') => 34, Character'Pos ('j') => 35,
Character'Pos ('k') => 36, Character'Pos ('l') => 37,
Character'Pos ('m') => 38, Character'Pos ('n') => 39,
Character'Pos ('o') => 40, Character'Pos ('p') => 41,
Character'Pos ('q') => 42, Character'Pos ('r') => 43,
Character'Pos ('s') => 44, Character'Pos ('t') => 45,
Character'Pos ('u') => 46, Character'Pos ('v') => 47,
Character'Pos ('w') => 48, Character'Pos ('x') => 49,
Character'Pos ('y') => 50, Character'Pos ('z') => 51,
Character'Pos ('0') => 52, Character'Pos ('1') => 53,
Character'Pos ('2') => 54, Character'Pos ('3') => 55,
Character'Pos ('4') => 56, Character'Pos ('5') => 57,
Character'Pos ('6') => 58, Character'Pos ('7') => 59,
Character'Pos ('8') => 60, Character'Pos ('9') => 61,
Character'Pos ('-') => 62, Character'Pos ('_') => 63,
others => 16#FF#);
type Decoder is new Util.Encoders.Transformer with record
Values : Alphabet_Values_Access := BASE64_VALUES'Access;
end record;
end Util.Encoders.Base64;
|
reznikmm/matreshka | Ada | 4,711 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Text.Bibliography_Data_Field_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_Bibliography_Data_Field_Attribute_Node is
begin
return Self : Text_Bibliography_Data_Field_Attribute_Node do
Matreshka.ODF_Text.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Text_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Text_Bibliography_Data_Field_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Bibliography_Data_Field_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Bibliography_Data_Field_Attribute,
Text_Bibliography_Data_Field_Attribute_Node'Tag);
end Matreshka.ODF_Text.Bibliography_Data_Field_Attributes;
|
persan/AdaYaml | Ada | 175 | ads | -- part of AdaYaml, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
package Yaml.Loading_Tests is
end Yaml.Loading_Tests;
|
jscparker/math_packages | Ada | 3,288 | adb |
-------------------------------------------------------------------------------
-- package body Disorderly.Basic_Rand.Clock_Entropy, Random Number Initialization
-- Copyright (C) 1995-2018 Jonathan S. Parker
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-------------------------------------------------------------------------------
with Ada.Calendar;
with System; -- for Tick : Duration;
package body Disorderly.Basic_Rand.Clock_Entropy is
-------------------------
-- Get_Seed_From_Clock --
-------------------------
-- Clock sets initial seed.
-- Seconds (T) is <= 86_400.0.
-- Day (T) is <= 31.0.
--
procedure Get_Seed_From_Clock
(Initiator : out Seed_Random_Int)
is
type Real is digits 15;
Fake_Ticks_per_Second : constant Real := 777_777_777.0;
Seconds_per_Day : constant Real := 86_400.0;
Fake_Ticks_per_Day : constant Real := Fake_Ticks_per_Second * Seconds_per_Day;
Min_Delay : constant Duration := System.Tick;
T : Ada.Calendar.Time;
Seed : Parent_Random_Int;
begin
delay Min_Delay * 3.0;
T := Ada.Calendar.Clock;
Seed := Random_Int (Real (Ada.Calendar.Seconds (T)) * Fake_Ticks_per_Second +
Real (Ada.Calendar.Day (T)) * Fake_Ticks_per_Day);
-- So Seed is the number of elapsed fake ticks in present month.
--
-- Even if Seconds (T) = 0.0000123 we want
-- Seconds (T)) * Fake_Ticks_per_Second to be big integer, so make
-- Fake_Ticks_per_Second very large.
--
-- Max val of Seed ~ 0.83 * 2^51.
Initiator := Seed + 777_777; -- 0 < Seed <= Random_Int'Last
delay Min_Delay * (7.0 + Duration (Initiator mod 77));
-- Minimize likelihood that next call to Reset_with_Calendar produces
-- the same Initiator1, and hence the same state S.
-- Doesn't guarantee that there is no relationship between successive
-- seeds, but such a relationship would be difficult to see.
-- All we need is 1 bit of difference between the outputs of two
-- successive calls to Ada.Calendar.Clock, and the two 256 bit
-- states generated by the successive calls will have no apparent
-- similarities.
end Get_Seed_From_Clock;
-----------
-- Reset --
-----------
procedure Reset
(S : out State)
is
Initiator1, Initiator2 : Seed_Random_Int;
begin
Get_Seed_From_Clock (Initiator1);
Get_Seed_From_Clock (Initiator2);
Disorderly.Basic_Rand.Reset (S, Initiator1, Initiator2);
end Reset;
end Disorderly.Basic_Rand.Clock_Entropy;
|
reznikmm/matreshka | Ada | 6,919 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Svg.Definition_Src_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Svg_Definition_Src_Element_Node is
begin
return Self : Svg_Definition_Src_Element_Node do
Matreshka.ODF_Svg.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Svg_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Svg_Definition_Src_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Svg_Definition_Src
(ODF.DOM.Svg_Definition_Src_Elements.ODF_Svg_Definition_Src_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Svg_Definition_Src_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Definition_Src_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Svg_Definition_Src_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Svg_Definition_Src
(ODF.DOM.Svg_Definition_Src_Elements.ODF_Svg_Definition_Src_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Svg_Definition_Src_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Svg_Definition_Src
(Visitor,
ODF.DOM.Svg_Definition_Src_Elements.ODF_Svg_Definition_Src_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Svg_URI,
Matreshka.ODF_String_Constants.Definition_Src_Element,
Svg_Definition_Src_Element_Node'Tag);
end Matreshka.ODF_Svg.Definition_Src_Elements;
|
reznikmm/matreshka | Ada | 4,983 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
pragma Restrictions (No_Elaboration_Code);
-- GNAT: enforce generation of preinitialized data section instead of
-- generation of elaboration code.
package Matreshka.Internals.Unicode.Ucd.Core_0102 is
pragma Preelaborate;
Group_0102 : aliased constant Core_Second_Stage
:= (16#80# .. 16#9C# => -- 010280 .. 01029C
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#A0# .. 16#D0# => -- 0102A0 .. 0102D0
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)),
16#E0# => -- 0102E0
(Nonspacing_Mark, Neutral,
Extend, Extend, Extend, Combining_Mark,
(Diacritic
| Case_Ignorable
| Grapheme_Extend
| ID_Continue
| XID_Continue => True,
others => False)),
16#E1# .. 16#FB# => -- 0102E1 .. 0102FB
(Other_Number, Neutral,
Other, Other, Other, Alphabetic,
(Grapheme_Base => True,
others => False)),
others =>
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)));
end Matreshka.Internals.Unicode.Ucd.Core_0102;
|
onox/orka | Ada | 1,148 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2017 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with GL.API;
with GL.Enums.Getter;
package body GL.Shading is
procedure Set_Minimum_Sample_Shading (Value : Normalized_Single) is
begin
API.Min_Sample_Shading.Ref (Value);
end Set_Minimum_Sample_Shading;
function Minimum_Sample_Shading return Normalized_Single is
Result : Single := 0.0;
begin
API.Get_Single.Ref (Enums.Getter.Min_Sample_Shading_Value, Result);
return Normalized_Single (Result);
end Minimum_Sample_Shading;
end GL.Shading;
|
gspu/synth | Ada | 2,539 | ads | -- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
package Replicant.Platform is
-- returns platform-specific df command
function df_command return String;
-- platform-specific version of file command
function file_type_command return String;
-- Calculate both types of package ABI as a function of platform
function determine_package_architecture return package_abi;
-- Return platform-specific command for swapinfo
function swapinfo_command return String;
-- Return load averages (platform specific)
function get_instant_load return Float;
function get_5_minute_load return Float;
-- Return value of ncpu (from syctl query)
function get_number_cpus return Positive;
-- Return true if file is executable (platform-specific)
function file_is_executable (filename : String) return Boolean;
-- Return true if file is dynamically linked (platform-specific)
function dynamically_linked (base, filename : String) return Boolean;
-- In order to do scanning in a clean environment prior to the true build
-- Returns True on success
function standalone_pkg8_install (id : builders) return Boolean;
-- Required for building first pkg(8) and bmake(8) for pkgsrc
-- They are just copies of hosts versions
function host_pkgsrc_mk_install (id : builders) return Boolean;
function host_pkgsrc_bmake_install (id : builders) return Boolean;
function host_pkgsrc_digest_install (id : builders) return Boolean;
function host_pkgsrc_pkg8_install (id : builders) return Boolean;
-- Cache variables that spawn to get populated to extended make.conf
procedure cache_port_variables (path_to_mm : String);
-- Shell for interactive use
function interactive_shell return String;
private
function isolate_arch_from_file_type (fileinfo : String) return filearch;
-- Derived from /usr/bin/file -b <slave>/bin/sh
function get_arch_from_bourne_shell return String;
-- Get OSVERSION from <sys/param.h>
function get_osversion_from_param_header return String;
-- common logic for instant and 5-minute load average
function load_core (instant_load : Boolean) return Float;
-- equivalent to chmod 755 <fullpath>
procedure set_file_as_executable (fullpath : String);
-- Call when arch narrowed down to ARM (not aarch64) architecture
-- Returns true if ARMv7 detected, otherwise returns false
function ARM_version_7 return Boolean;
end Replicant.Platform;
|
burratoo/Acton | Ada | 1,141 | ads | ------------------------------------------------------------------------------------------
-- --
-- ACTON PROCESSOR SUPPORT PACKAGE --
-- ST STM32F4 --
-- --
-- GNAT_EXCEPTION --
-- --
-- Copyright (C) 2014-2021, Patrick Bernardi --
-- --
------------------------------------------------------------------------------------------
with System;
package GNAT_Exception with Pure is
procedure Last_Chance_Handler (Msg : System.Address; Line : Integer)
with Export, Convention => C,
External_Name => "__gnat_last_chance_handler";
end GNAT_Exception;
|
stcarrez/ada-keystore | Ada | 3,349 | adb | -----------------------------------------------------------------------
-- keystore-logs -- Log support for the keystore
-- Copyright (C) 2019, 2020 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Encoders.Base16;
with Keystore.Buffers;
package body Keystore.Logs is
procedure Dump (Log : in Util.Log.Loggers.Logger;
Content : in Ada.Streams.Stream_Element_Array) is
use type Ada.Streams.Stream_Element_Offset;
begin
if Log.Get_Level >= Util.Log.DEBUG_LEVEL then
declare
Encoder : Util.Encoders.Base16.Encoder;
Start : Ada.Streams.Stream_Element_Offset := Content'First;
Last : Ada.Streams.Stream_Element_Offset;
begin
while Start <= Content'Last loop
Last := Start + 31;
if Last > Content'Last then
Last := Content'Last;
end if;
Log.Debug (" {0}", Encoder.Transform (Content (Start .. Last)));
Start := Last + 1;
end loop;
end;
end if;
end Dump;
procedure Error (Log : in Util.Log.Loggers.Logger;
Message : in String;
Block : in IO.Storage_Block) is
begin
if Log.Get_Level >= Util.Log.ERROR_LEVEL then
Log.Error (Message, Buffers.To_String (Block));
end if;
end Error;
procedure Warn (Log : in Util.Log.Loggers.Logger;
Message : in String;
Block : in IO.Storage_Block) is
begin
if Log.Get_Level >= Util.Log.WARN_LEVEL then
Log.Warn (Message, Buffers.To_String (Block));
end if;
end Warn;
procedure Info (Log : in Util.Log.Loggers.Logger;
Message : in String;
Block : in IO.Storage_Block) is
begin
if Log.Get_Level >= Util.Log.INFO_LEVEL then
Log.Info (Message, Buffers.To_String (Block));
end if;
end Info;
procedure Debug (Log : in Util.Log.Loggers.Logger;
Message : in String;
Block : in IO.Storage_Block) is
begin
if Log.Get_Level >= Util.Log.DEBUG_LEVEL then
Log.Debug (Message, Buffers.To_String (Block));
end if;
end Debug;
procedure Debug (Log : in Util.Log.Loggers.Logger;
Message : in String;
Block1 : in IO.Storage_Block;
Block2 : in IO.Storage_Block) is
begin
if Log.Get_Level >= Util.Log.DEBUG_LEVEL then
Log.Debug (Message, Buffers.To_String (Block1), Buffers.To_String (Block2));
end if;
end Debug;
end Keystore.Logs;
|
reznikmm/matreshka | Ada | 4,237 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package body FastCGI.Field_Names is
---------
-- "=" --
---------
function "=" (Left : Field_Name; Right : Field_Name) return Boolean is
use type League.Strings.Universal_String;
begin
return
League.Strings.Universal_String (Left)
= League.Strings.Universal_String (Right);
end "=";
-------------------
-- To_Field_Name --
-------------------
function To_Field_Name
(Item : League.Strings.Universal_String) return Field_Name is
begin
return (Item.To_Simple_Uppercase with null record);
end To_Field_Name;
-------------------------
-- To_Universal_String --
-------------------------
function To_Universal_String
(Self : Field_Name'Class) return League.Strings.Universal_String is
begin
return League.Strings.Universal_String (Self);
end To_Universal_String;
end FastCGI.Field_Names;
|
optikos/oasis | Ada | 4,402 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Lexical_Elements;
with Program.Elements.Expressions;
with Program.Elements.Elsif_Expression_Paths;
with Program.Element_Visitors;
package Program.Nodes.Elsif_Expression_Paths is
pragma Preelaborate;
type Elsif_Expression_Path is
new Program.Nodes.Node
and Program.Elements.Elsif_Expression_Paths.Elsif_Expression_Path
and Program.Elements.Elsif_Expression_Paths.Elsif_Expression_Path_Text
with private;
function Create
(Elsif_Token : not null Program.Lexical_Elements.Lexical_Element_Access;
Condition : not null Program.Elements.Expressions.Expression_Access;
Then_Token : not null Program.Lexical_Elements.Lexical_Element_Access;
Expression : not null Program.Elements.Expressions.Expression_Access)
return Elsif_Expression_Path;
type Implicit_Elsif_Expression_Path is
new Program.Nodes.Node
and Program.Elements.Elsif_Expression_Paths.Elsif_Expression_Path
with private;
function Create
(Condition : not null Program.Elements.Expressions
.Expression_Access;
Expression : not null Program.Elements.Expressions
.Expression_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False)
return Implicit_Elsif_Expression_Path
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Elsif_Expression_Path is
abstract new Program.Nodes.Node
and Program.Elements.Elsif_Expression_Paths.Elsif_Expression_Path
with record
Condition : not null Program.Elements.Expressions.Expression_Access;
Expression : not null Program.Elements.Expressions.Expression_Access;
end record;
procedure Initialize
(Self : aliased in out Base_Elsif_Expression_Path'Class);
overriding procedure Visit
(Self : not null access Base_Elsif_Expression_Path;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Condition
(Self : Base_Elsif_Expression_Path)
return not null Program.Elements.Expressions.Expression_Access;
overriding function Expression
(Self : Base_Elsif_Expression_Path)
return not null Program.Elements.Expressions.Expression_Access;
overriding function Is_Elsif_Expression_Path_Element
(Self : Base_Elsif_Expression_Path)
return Boolean;
overriding function Is_Path_Element
(Self : Base_Elsif_Expression_Path)
return Boolean;
type Elsif_Expression_Path is
new Base_Elsif_Expression_Path
and Program.Elements.Elsif_Expression_Paths.Elsif_Expression_Path_Text
with record
Elsif_Token : not null Program.Lexical_Elements.Lexical_Element_Access;
Then_Token : not null Program.Lexical_Elements.Lexical_Element_Access;
end record;
overriding function To_Elsif_Expression_Path_Text
(Self : aliased in out Elsif_Expression_Path)
return Program.Elements.Elsif_Expression_Paths
.Elsif_Expression_Path_Text_Access;
overriding function Elsif_Token
(Self : Elsif_Expression_Path)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Then_Token
(Self : Elsif_Expression_Path)
return not null Program.Lexical_Elements.Lexical_Element_Access;
type Implicit_Elsif_Expression_Path is
new Base_Elsif_Expression_Path
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
end record;
overriding function To_Elsif_Expression_Path_Text
(Self : aliased in out Implicit_Elsif_Expression_Path)
return Program.Elements.Elsif_Expression_Paths
.Elsif_Expression_Path_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Elsif_Expression_Path)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Elsif_Expression_Path)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Elsif_Expression_Path)
return Boolean;
end Program.Nodes.Elsif_Expression_Paths;
|
stcarrez/mat | Ada | 6,951 | ads | -----------------------------------------------------------------------
-- mat-events-targets - Events received and collected from a target
-- Copyright (C) 2014, 2015, 2019 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Containers.Ordered_Maps;
with Ada.Finalization;
with Util.Concurrent.Counters;
with MAT.Events.Tools;
package MAT.Events.Targets is
type Target_Events is tagged limited private;
type Target_Events_Access is access all Target_Events'Class;
-- Add the event in the list of events and increment the event counter.
-- Update the event instance to allocate the event Id.
procedure Insert (Target : in out Target_Events;
Event : in out Target_Event_Type);
-- Update the Size and Prev_Id information in the event identified by <tt>Id</tt>.
-- Update the event represented by <tt>Prev_Id</tt> so that its Next_Id refers
-- to the <tt>Id</tt> event.
procedure Update_Event (Target : in out Target_Events;
Id : in Event_Id_Type;
Size : in MAT.Types.Target_Size;
Prev_Id : in Event_Id_Type);
procedure Get_Events (Target : in out Target_Events;
Start : in MAT.Types.Target_Time;
Finish : in MAT.Types.Target_Time;
Into : in out MAT.Events.Tools.Target_Event_Vector);
-- Get the start and finish time for the events that have been received.
procedure Get_Time_Range (Target : in out Target_Events;
Start : out MAT.Types.Target_Time;
Finish : out MAT.Types.Target_Time);
-- Get the probe event with the given allocated unique id.
function Get_Event (Target : in Target_Events;
Id : in Event_Id_Type) return Target_Event_Type;
-- Get the first and last event that have been received.
procedure Get_Limits (Target : in out Target_Events;
First : out Target_Event_Type;
Last : out Target_Event_Type);
-- Get the current event counter.
function Get_Event_Counter (Target : in Target_Events) return Integer;
-- Iterate over the events starting from the <tt>Start</tt> event and until the
-- <tt>Finish</tt> event is found (inclusive). Execute the <tt>Process</tt> procedure
-- with each event instance.
procedure Iterate (Target : in out Target_Events;
Start : in Event_Id_Type;
Finish : in Event_Id_Type;
Process : access procedure (Event : in Target_Event_Type));
-- Iterate over the events starting from first first event up to the last event collected.
-- Execute the <tt>Process</tt> procedure with each event instance.
procedure Iterate (Target : in out Target_Events;
Process : access procedure (Event : in Target_Event_Type));
private
EVENT_BLOCK_SIZE : constant Event_Id_Type := 1024;
type Probe_Event_Array is array (1 .. EVENT_BLOCK_SIZE) of Target_Event_Type;
type Event_Block is record
Start : MAT.Types.Target_Time;
Finish : MAT.Types.Target_Time;
Count : Event_Id_Type := 0;
Events : Probe_Event_Array;
end record;
type Event_Block_Access is access all Event_Block;
use type MAT.Types.Target_Time;
package Event_Maps is
new Ada.Containers.Ordered_Maps (Key_Type => MAT.Types.Target_Time,
Element_Type => Event_Block_Access);
subtype Event_Map is Event_Maps.Map;
subtype Event_Cursor is Event_Maps.Cursor;
package Event_Id_Maps is
new Ada.Containers.Ordered_Maps (Key_Type => Event_Id_Type,
Element_Type => Event_Block_Access);
subtype Event_Id_Map is Event_Id_Maps.Map;
subtype Event_Id_Cursor is Event_Id_Maps.Cursor;
protected type Event_Collector is
-- Update the Size and Prev_Id information in the event identified by <tt>Id</tt>.
-- Update the event represented by <tt>Prev_Id</tt> so that its Next_Id refers
-- to the <tt>Id</tt> event.
procedure Update_Event (Id : in Event_Id_Type;
Size : in MAT.Types.Target_Size;
Prev_Id : in Event_Id_Type);
-- Add the event in the list of events.
-- Update the event instance to allocate the event Id.
procedure Insert (Event : in out Target_Event_Type);
procedure Get_Events (Start : in MAT.Types.Target_Time;
Finish : in MAT.Types.Target_Time;
Into : in out MAT.Events.Tools.Target_Event_Vector);
-- Get the first and last event that have been received.
procedure Get_Limits (First : out Target_Event_Type;
Last : out Target_Event_Type);
-- Get the start and finish time for the events that have been received.
procedure Get_Time_Range (Start : out MAT.Types.Target_Time;
Finish : out MAT.Types.Target_Time);
-- Get the probe event with the given allocated unique id.
function Get_Event (Id : in Event_Id_Type) return Target_Event_Type;
-- Iterate over the events starting from the <tt>Start</tt> event and until the
-- <tt>Finish</tt> event is found (inclusive). Execute the <tt>Process</tt> procedure
-- with each event instance.
procedure Iterate (Start : in Event_Id_Type;
Finish : in Event_Id_Type;
Process : access procedure (Event : in Target_Event_Type));
-- Clear the events.
procedure Clear;
private
Current : Event_Block_Access := null;
Events : Event_Map;
Ids : Event_Id_Map;
Last_Id : Event_Id_Type := 0;
end Event_Collector;
type Target_Events is new Ada.Finalization.Limited_Controlled with record
Events : Event_Collector;
Event_Count : Util.Concurrent.Counters.Counter;
end record;
-- Release the storage allocated for the events.
overriding
procedure Finalize (Target : in out Target_Events);
end MAT.Events.Targets;
|
Rodeo-McCabe/orka | Ada | 4,493 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2017 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
with GL.API;
with GL.Types;
package body GL.Fences is
overriding procedure Initialize (Object : in out Fence) is
begin
Object.Reference := new Sync_Object_Reference'(Sync_ID => 0,
Reference_Count => 1,
Status => Unset);
end Initialize;
overriding procedure Adjust (Object : in out Fence) is
begin
if Object.Reference /= null then
Object.Reference.Reference_Count := Object.Reference.Reference_Count + 1;
end if;
end Adjust;
overriding procedure Finalize (Object : in out Fence) is
use type Low_Level.Sync;
procedure Free is new Ada.Unchecked_Deallocation
(Object => Sync_Object_Reference, Name => Sync_Object_Reference_Access);
begin
if Object.Reference /= null then
Object.Reference.Reference_Count := Object.Reference.Reference_Count - 1;
if Object.Reference.Reference_Count = 0 then
if Object.Reference.Sync_ID /= 0 then
Fence'Class (Object).Delete;
end if;
Free (Object.Reference);
end if;
end if;
end Finalize;
procedure Set_Fence (Object : in out Fence) is
GPU_Commands_Complete : constant Low_Level.Enum := 16#9117#;
begin
if Object.Initialized then
Object.Delete;
end if;
Object.Reference.Sync_ID := API.Fence_Sync.Ref (GPU_Commands_Complete, 0);
Object.Reference.Status := (if Object.Initialized then Set else Unset);
end Set_Fence;
procedure Delete (Object : in out Fence) is
begin
API.Delete_Sync.Ref (Object.Reference.Sync_ID);
Object.Reference.Sync_ID := 0;
Object.Reference.Status := Unset;
end Delete;
function Initialized (Object : Fence) return Boolean is
use type Low_Level.Sync;
begin
return Object.Reference.Sync_ID /= 0;
end Initialized;
function Status (Object : Fence) return Signaled_Status is
(Object.Reference.Status);
function Signaled (Object : Fence) return Boolean is
use GL.Types;
Sync_Status : constant := 16#9114#;
type Signaled_Type is (Unsignaled, Signaled);
for Signaled_Type use
(Unsignaled => 16#9118#,
Signaled => 16#9119#);
for Signaled_Type'Size use Low_Level.Enum'Size;
function Convert is new Ada.Unchecked_Conversion
(Source => Int, Target => Signaled_Type);
begin
if Object.Status = Signaled then
return True;
end if;
declare
Value : constant Int_Array := API.Get_Sync.Ref
(Object.Reference.Sync_ID, Sync_Status, 1);
begin
return Convert (Value (1)) = Signaled;
end;
end Signaled;
function Client_Wait (Object : Fence; Timeout : Duration) return Wait_Status is
use GL.Types;
Flush_Commands_Bit : constant := 16#0000_0001#;
Timeout_Nanoseconds : constant UInt64 := UInt64 (Timeout * 1e9);
Result : Wait_Status;
begin
Result := API.Client_Wait_Sync.Ref
(Object.Reference.Sync_ID, Flush_Commands_Bit, Timeout_Nanoseconds);
if Result in Already_Signaled | Condition_Satisfied then
Object.Reference.Status := Signaled;
end if;
return Result;
end Client_Wait;
procedure Server_Wait (Object : Fence) is
Timeout_Ignored : constant := 16#FFF_FFFFF_FFFF_FFFF#;
begin
-- Flush the pipeline to ensure that the fence has been sent to the GPU
API.Flush.Ref.all;
API.Wait_Sync.Ref (Object.Reference.Sync_ID, 0, Timeout_Ignored);
end Server_Wait;
overriding
function "=" (Left, Right : Fence) return Boolean is
(Left.Reference = Right.Reference);
end GL.Fences;
|
MinimSecure/unum-sdk | Ada | 1,226 | adb | -- Copyright 2013-2019 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with Pck; use Pck;
procedure Foo is
type Multi is array (1 .. 1, 2 .. 3, 4 .. 6) of Integer;
M : Multi := (others => (others => (others => 0)));
-- Use a fake type for importing our C multi-dimensional array.
-- It's only to make sure the C unit gets linked in, regardless
-- of possible optimizations.
type Void_Star is access integer;
E : Void_Star;
pragma Import (C, E, "global_3dim_for_gdb_testing");
begin
Do_Nothing (M'Address); -- STOP
Do_Nothing (E'Address);
end Foo;
|
xiashuangxi/codecount | Ada | 1,976 | ads | with Ada.Text_IO;
with Ada.Integer_Text_IO;
package Code_Count is
type CodeMate is private;
type TotalCodeMate is private;
-- Code_Count/Skip_Space
-- FUNCTION
-- 跳过空格
-- PARAMETERS
-- Line - 字符串
-- Offset - 偏移量
procedure Skip_Space
(Line : String;
Offset : in out Integer);
-- Code_Count/Print_Core_Count
-- FUNCTION
-- 打印行数信息
-- PARAMETERS
-- Count_Ident - 说明
-- Count - 行数
-- Number_Of_New_Lines - 换行数
procedure Print_Core_Count
(Count_Ident : String;
Count : Integer;
Number_Of_New_Lines : Ada.Text_IO.Count );
-- Code_Count/Read
-- FUNCTION
-- 开始读取源码
-- PARAMETERS
-- FileName - 文件名
-- CM - 当前文件的行数信息
-- TM - 所有文件的行数信息
procedure Read
(FileName : String;
CM: in out CodeMate;
TM: in out TotalCodeMate);
-- Code_Count/Print_To_File_Info
-- FUNCTION
-- 打印一个文件的信息
-- PARAMETERS
-- CM - 当前文件的行数信息
procedure Print_To_File_Info(CM: in CodeMate);
-- Code_Count/Print_To_File_Info
-- FUNCTION
-- 打印所有文件的信息
-- PARAMETERS
-- TM - 所有文件的行数信息
procedure Print_To_AllFile_Info(TM: in TotalCodeMate);
private
-- 文件操作对象
File_Handle : Ada.Text_IO.File_Type;
type CodeCountMate is
record
Line_Count : Integer := 0;
Code_Count : Integer := 0;
Comment_Count : Integer := 0;
Null_Count : Integer := 0;
end record;
type CodeMate is access all CodeCountMate;
type TotalCodeMate is access all CodeCountMate;
TCM : TotalCodeMate := new CodeCountMate'(0,0,0,0);
end Code_Count; |
reznikmm/matreshka | Ada | 22,734 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Elements;
with AMF.Internals.Element_Collections;
with AMF.Internals.Helpers;
with AMF.Internals.Tables.UML_Attributes;
with AMF.Visitors.UML_Iterators;
with AMF.Visitors.UML_Visitors;
with League.Strings.Internals;
with Matreshka.Internals.Strings;
package body AMF.Internals.UML_Data_Store_Nodes is
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant UML_Data_Store_Node_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then
AMF.Visitors.UML_Visitors.UML_Visitor'Class
(Visitor).Enter_Data_Store_Node
(AMF.UML.Data_Store_Nodes.UML_Data_Store_Node_Access (Self),
Control);
end if;
end Enter_Element;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant UML_Data_Store_Node_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then
AMF.Visitors.UML_Visitors.UML_Visitor'Class
(Visitor).Leave_Data_Store_Node
(AMF.UML.Data_Store_Nodes.UML_Data_Store_Node_Access (Self),
Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant UML_Data_Store_Node_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Iterator in AMF.Visitors.UML_Iterators.UML_Iterator'Class then
AMF.Visitors.UML_Iterators.UML_Iterator'Class
(Iterator).Visit_Data_Store_Node
(Visitor,
AMF.UML.Data_Store_Nodes.UML_Data_Store_Node_Access (Self),
Control);
end if;
end Visit_Element;
------------------
-- Get_In_State --
------------------
overriding function Get_In_State
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.States.Collections.Set_Of_UML_State is
begin
return
AMF.UML.States.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_In_State
(Self.Element)));
end Get_In_State;
-------------------------
-- Get_Is_Control_Type --
-------------------------
overriding function Get_Is_Control_Type
(Self : not null access constant UML_Data_Store_Node_Proxy)
return Boolean is
begin
return
AMF.Internals.Tables.UML_Attributes.Internal_Get_Is_Control_Type
(Self.Element);
end Get_Is_Control_Type;
-------------------------
-- Set_Is_Control_Type --
-------------------------
overriding procedure Set_Is_Control_Type
(Self : not null access UML_Data_Store_Node_Proxy;
To : Boolean) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Control_Type
(Self.Element, To);
end Set_Is_Control_Type;
------------------
-- Get_Ordering --
------------------
overriding function Get_Ordering
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.UML_Object_Node_Ordering_Kind is
begin
return
AMF.Internals.Tables.UML_Attributes.Internal_Get_Ordering
(Self.Element);
end Get_Ordering;
------------------
-- Set_Ordering --
------------------
overriding procedure Set_Ordering
(Self : not null access UML_Data_Store_Node_Proxy;
To : AMF.UML.UML_Object_Node_Ordering_Kind) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Ordering
(Self.Element, To);
end Set_Ordering;
-------------------
-- Get_Selection --
-------------------
overriding function Get_Selection
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.Behaviors.UML_Behavior_Access is
begin
return
AMF.UML.Behaviors.UML_Behavior_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Selection
(Self.Element)));
end Get_Selection;
-------------------
-- Set_Selection --
-------------------
overriding procedure Set_Selection
(Self : not null access UML_Data_Store_Node_Proxy;
To : AMF.UML.Behaviors.UML_Behavior_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Selection
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Selection;
---------------------
-- Get_Upper_Bound --
---------------------
overriding function Get_Upper_Bound
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.Value_Specifications.UML_Value_Specification_Access is
begin
return
AMF.UML.Value_Specifications.UML_Value_Specification_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Upper_Bound
(Self.Element)));
end Get_Upper_Bound;
---------------------
-- Set_Upper_Bound --
---------------------
overriding procedure Set_Upper_Bound
(Self : not null access UML_Data_Store_Node_Proxy;
To : AMF.UML.Value_Specifications.UML_Value_Specification_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Upper_Bound
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Upper_Bound;
------------------
-- Get_Activity --
------------------
overriding function Get_Activity
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.Activities.UML_Activity_Access is
begin
return
AMF.UML.Activities.UML_Activity_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Activity
(Self.Element)));
end Get_Activity;
------------------
-- Set_Activity --
------------------
overriding procedure Set_Activity
(Self : not null access UML_Data_Store_Node_Proxy;
To : AMF.UML.Activities.UML_Activity_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Activity
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Activity;
------------------
-- Get_In_Group --
------------------
overriding function Get_In_Group
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.Activity_Groups.Collections.Set_Of_UML_Activity_Group is
begin
return
AMF.UML.Activity_Groups.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_In_Group
(Self.Element)));
end Get_In_Group;
---------------------------------
-- Get_In_Interruptible_Region --
---------------------------------
overriding function Get_In_Interruptible_Region
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.Interruptible_Activity_Regions.Collections.Set_Of_UML_Interruptible_Activity_Region is
begin
return
AMF.UML.Interruptible_Activity_Regions.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_In_Interruptible_Region
(Self.Element)));
end Get_In_Interruptible_Region;
----------------------
-- Get_In_Partition --
----------------------
overriding function Get_In_Partition
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.Activity_Partitions.Collections.Set_Of_UML_Activity_Partition is
begin
return
AMF.UML.Activity_Partitions.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_In_Partition
(Self.Element)));
end Get_In_Partition;
----------------------------
-- Get_In_Structured_Node --
----------------------------
overriding function Get_In_Structured_Node
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access is
begin
return
AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_In_Structured_Node
(Self.Element)));
end Get_In_Structured_Node;
----------------------------
-- Set_In_Structured_Node --
----------------------------
overriding procedure Set_In_Structured_Node
(Self : not null access UML_Data_Store_Node_Proxy;
To : AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_In_Structured_Node
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_In_Structured_Node;
------------------
-- Get_Incoming --
------------------
overriding function Get_Incoming
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge is
begin
return
AMF.UML.Activity_Edges.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Incoming
(Self.Element)));
end Get_Incoming;
------------------
-- Get_Outgoing --
------------------
overriding function Get_Outgoing
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge is
begin
return
AMF.UML.Activity_Edges.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Outgoing
(Self.Element)));
end Get_Outgoing;
------------------------
-- Get_Redefined_Node --
------------------------
overriding function Get_Redefined_Node
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.Activity_Nodes.Collections.Set_Of_UML_Activity_Node is
begin
return
AMF.UML.Activity_Nodes.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Redefined_Node
(Self.Element)));
end Get_Redefined_Node;
-----------------
-- Get_Is_Leaf --
-----------------
overriding function Get_Is_Leaf
(Self : not null access constant UML_Data_Store_Node_Proxy)
return Boolean is
begin
return
AMF.Internals.Tables.UML_Attributes.Internal_Get_Is_Leaf
(Self.Element);
end Get_Is_Leaf;
-----------------
-- Set_Is_Leaf --
-----------------
overriding procedure Set_Is_Leaf
(Self : not null access UML_Data_Store_Node_Proxy;
To : Boolean) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Leaf
(Self.Element, To);
end Set_Is_Leaf;
---------------------------
-- Get_Redefined_Element --
---------------------------
overriding function Get_Redefined_Element
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element is
begin
return
AMF.UML.Redefinable_Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Redefined_Element
(Self.Element)));
end Get_Redefined_Element;
------------------------------
-- Get_Redefinition_Context --
------------------------------
overriding function Get_Redefinition_Context
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is
begin
return
AMF.UML.Classifiers.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Redefinition_Context
(Self.Element)));
end Get_Redefinition_Context;
---------------------------
-- Get_Client_Dependency --
---------------------------
overriding function Get_Client_Dependency
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency is
begin
return
AMF.UML.Dependencies.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Client_Dependency
(Self.Element)));
end Get_Client_Dependency;
-------------------------
-- Get_Name_Expression --
-------------------------
overriding function Get_Name_Expression
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.String_Expressions.UML_String_Expression_Access is
begin
return
AMF.UML.String_Expressions.UML_String_Expression_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Name_Expression
(Self.Element)));
end Get_Name_Expression;
-------------------------
-- Set_Name_Expression --
-------------------------
overriding procedure Set_Name_Expression
(Self : not null access UML_Data_Store_Node_Proxy;
To : AMF.UML.String_Expressions.UML_String_Expression_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Name_Expression
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Name_Expression;
-------------------
-- Get_Namespace --
-------------------
overriding function Get_Namespace
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access is
begin
return
AMF.UML.Namespaces.UML_Namespace_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Namespace
(Self.Element)));
end Get_Namespace;
------------------------
-- Get_Qualified_Name --
------------------------
overriding function Get_Qualified_Name
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.Optional_String is
begin
declare
use type Matreshka.Internals.Strings.Shared_String_Access;
Aux : constant Matreshka.Internals.Strings.Shared_String_Access
:= AMF.Internals.Tables.UML_Attributes.Internal_Get_Qualified_Name (Self.Element);
begin
if Aux = null then
return (Is_Empty => True);
else
return (False, League.Strings.Internals.Create (Aux));
end if;
end;
end Get_Qualified_Name;
--------------
-- Get_Type --
--------------
overriding function Get_Type
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.Types.UML_Type_Access is
begin
return
AMF.UML.Types.UML_Type_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Type
(Self.Element)));
end Get_Type;
--------------
-- Set_Type --
--------------
overriding procedure Set_Type
(Self : not null access UML_Data_Store_Node_Proxy;
To : AMF.UML.Types.UML_Type_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Type
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Type;
------------------------
-- Is_Consistent_With --
------------------------
overriding function Is_Consistent_With
(Self : not null access constant UML_Data_Store_Node_Proxy;
Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Consistent_With unimplemented");
raise Program_Error with "Unimplemented procedure UML_Data_Store_Node_Proxy.Is_Consistent_With";
return Is_Consistent_With (Self, Redefinee);
end Is_Consistent_With;
-----------------------------------
-- Is_Redefinition_Context_Valid --
-----------------------------------
overriding function Is_Redefinition_Context_Valid
(Self : not null access constant UML_Data_Store_Node_Proxy;
Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Redefinition_Context_Valid unimplemented");
raise Program_Error with "Unimplemented procedure UML_Data_Store_Node_Proxy.Is_Redefinition_Context_Valid";
return Is_Redefinition_Context_Valid (Self, Redefined);
end Is_Redefinition_Context_Valid;
-------------------------
-- All_Owning_Packages --
-------------------------
overriding function All_Owning_Packages
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.Packages.Collections.Set_Of_UML_Package is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "All_Owning_Packages unimplemented");
raise Program_Error with "Unimplemented procedure UML_Data_Store_Node_Proxy.All_Owning_Packages";
return All_Owning_Packages (Self);
end All_Owning_Packages;
-----------------------------
-- Is_Distinguishable_From --
-----------------------------
overriding function Is_Distinguishable_From
(Self : not null access constant UML_Data_Store_Node_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access;
Ns : AMF.UML.Namespaces.UML_Namespace_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented");
raise Program_Error with "Unimplemented procedure UML_Data_Store_Node_Proxy.Is_Distinguishable_From";
return Is_Distinguishable_From (Self, N, Ns);
end Is_Distinguishable_From;
---------------
-- Namespace --
---------------
overriding function Namespace
(Self : not null access constant UML_Data_Store_Node_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Namespace unimplemented");
raise Program_Error with "Unimplemented procedure UML_Data_Store_Node_Proxy.Namespace";
return Namespace (Self);
end Namespace;
end AMF.Internals.UML_Data_Store_Nodes;
|
MinimSecure/unum-sdk | Ada | 924 | adb | -- Copyright 2008-2019 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package body Pck is
function Ident (I : Integer) return Integer is
begin
return I;
end Ident;
procedure Do_Nothing (A : System.Address) is
begin
null;
end Do_Nothing;
end Pck;
|
reznikmm/matreshka | Ada | 3,844 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package Matreshka.ODF_Attributes.Style.Default_Outline_Level is
type Style_Default_Outline_Level_Node is
new Matreshka.ODF_Attributes.Style.Style_Node_Base with null record;
type Style_Default_Outline_Level_Access is
access all Style_Default_Outline_Level_Node'Class;
overriding function Get_Local_Name
(Self : not null access constant Style_Default_Outline_Level_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Attributes.Style.Default_Outline_Level;
|
burratoo/Acton | Ada | 8,744 | ads | ------------------------------------------------------------------------------------------
-- --
-- OAK PROCESSOR SUPPORT PACKAGE --
-- ATMEL ATMEGA128P --
-- --
-- AVR.TIMERS --
-- --
-- Copyright (C) 2012-2021, Patrick Bernardi --
-- --
------------------------------------------------------------------------------------------
with Interfaces; use Interfaces;
with System.Storage_Elements; use System.Storage_Elements;
package AVR.Timers with Preelaborate is
----------------------------------------------------------------------------
-- Memory Address
----------------------------------------------------------------------------
TCCR2A_Address : constant Integer_Address := 16#B0#;
TCCR2B_Address : constant Integer_Address := 16#B1#;
TCNT2_Address : constant Integer_Address := 16#B2#;
OCR2A_Address : constant Integer_Address := 16#B3#;
OCR2B_Address : constant Integer_Address := 16#B4#;
ASSR_Address : constant Integer_Address := 16#B6#;
TIMSK2_Address : constant Integer_Address := 16#70#;
TIFR2_Address : constant Integer_Address := 16#17#;
GTCCR_Address : constant Integer_Address := 16#23#;
----------------------------------------------------------------------------
-- Timer Types
----------------------------------------------------------------------------
type General_Timer_Counter_Control_Type is record
Timer_Counter_Synchronization_Mode : Enable_Type;
Prescaler_Reset_Timer_Counter_2 : Boolean;
Prescaler_Reset : Boolean;
end record;
type COM_Type is (Normal, Toggle, Clear, Set);
-- Compare Output Mode, non-PWM mode
-- Normal => Normal port operation OC0x disconnected.
-- Toggle => Toggle OCxy on compare match
-- Clear => Clear OCxy on compare match
-- Set => Set OCxy on compare match
--
-- Compare Output Mode, fast PWM mode
-- Normal => Normal port operation OC0x disconnected.
-- Toggle => WGMx2 = 0: Normal port operation OC0x disconnected.
-- => WGMx2 = 1: Toggle OC2x on compare match
-- Clear => Clear OCxy on compare match, set OCxy at BOTTOM
-- Set => Set OCxy on compare match, clear OCxy at BOTTOM
--
-- Compare Output Mode, phase corrent PWM mode
-- Normal => Normal port operation OC0x disconnected.
-- Toggle => WGMx2 = 0: Normal port operation OC0x disconnected.
-- => WGMx2 = 1: Toggle OCxy on compare match
-- Clear => Clear OCxy on compare match when counting up,
-- => Set OCxy on compare match when counting down.
-- Set => Set OCxy on compare match when counting up,
-- => Clear OCxy on compare match when counting down.
type Timer_Counter_Control_A_Type is record
Compare_Match_Output_A_Mode : COM_Type;
Compare_Match_Output_B_Mode : COM_Type;
Waveform_Generation_Mode_1 : Boolean;
Waveform_Generation_Mode_0 : Boolean;
end record;
type Clock_Select_Bits is
(No_Source,
No_Scaling,
Divide_8,
Divide_32,
Divide_64,
Divide_128,
Divide_256,
Divide_1024);
type Timer_Counter_Control_B_Type is record
Force_Output_Compare_A : Boolean;
Force_Output_Compare_B : Boolean;
Waveform_Generation_Mode_2 : Boolean;
Clock_Select : Clock_Select_Bits;
end record;
type Asynchronous_Status_Type is record
External_Clock_Input : Enable_Type;
Async_Timer_Counter_2 : Enable_Type;
Async_Timer_Counter_2_Update_Busy : Boolean;
Output_Compare_Register_2A_Update_Busy : Boolean;
Output_Compare_Register_2B_Update_Busy : Boolean;
TC_Control_Register_2A_Update_Busy : Boolean;
TC_Control_Register_2B_Update_Busy : Boolean;
end record;
type Timer_Counter_Interrupt_Mask_Type is record
Output_Compare_Match_B_Interrupt : Enable_Type;
Output_Compare_Match_A_Interrupt : Enable_Type;
Overflow_Interrupt : Enable_Type;
end record;
type Timer_Counter_Flag_Type is record
Output_Compare_B : Interrupt_Flag;
Output_Compare_A : Interrupt_Flag;
Overflow : Interrupt_Flag;
end record;
----------------------------------------------------------------------------
-- Hardware Respresentations
----------------------------------------------------------------------------
for General_Timer_Counter_Control_Type use record
Timer_Counter_Synchronization_Mode at 0 range 7 .. 7;
Prescaler_Reset_Timer_Counter_2 at 0 range 1 .. 1;
Prescaler_Reset at 0 range 0 .. 0;
end record;
for COM_Type use (Normal => 2#00#, Toggle => 2#01#,
Clear => 2#10#, Set => 2#11#);
for Timer_Counter_Control_A_Type use record
Compare_Match_Output_A_Mode at 0 range 6 .. 7;
Compare_Match_Output_B_Mode at 0 range 4 .. 5;
Waveform_Generation_Mode_1 at 0 range 1 .. 1;
Waveform_Generation_Mode_0 at 0 range 0 .. 0;
end record;
for Clock_Select_Bits use
(No_Source => 2#000#,
No_Scaling => 2#001#,
Divide_8 => 2#010#,
Divide_32 => 2#011#,
Divide_64 => 2#100#,
Divide_128 => 2#101#,
Divide_256 => 2#110#,
Divide_1024 => 2#111#);
for Timer_Counter_Control_B_Type use record
Force_Output_Compare_A at 0 range 7 .. 7;
Force_Output_Compare_B at 0 range 6 .. 6;
Waveform_Generation_Mode_2 at 0 range 3 .. 3;
Clock_Select at 0 range 0 .. 2;
end record;
for Asynchronous_Status_Type use record
External_Clock_Input at 0 range 6 .. 6;
Async_Timer_Counter_2 at 0 range 5 .. 5;
Async_Timer_Counter_2_Update_Busy at 0 range 4 .. 4;
Output_Compare_Register_2A_Update_Busy at 0 range 3 .. 3;
Output_Compare_Register_2B_Update_Busy at 0 range 2 .. 2;
TC_Control_Register_2A_Update_Busy at 0 range 1 .. 1;
TC_Control_Register_2B_Update_Busy at 0 range 0 .. 0;
end record;
for Timer_Counter_Interrupt_Mask_Type use record
Output_Compare_Match_B_Interrupt at 0 range 2 .. 2;
Output_Compare_Match_A_Interrupt at 0 range 1 .. 1;
Overflow_Interrupt at 0 range 0 .. 0;
end record;
for Timer_Counter_Flag_Type use record
Output_Compare_B at 0 range 2 .. 2;
Output_Compare_A at 0 range 1 .. 1;
Overflow at 0 range 0 .. 0;
end record;
----------------------------------------------------------------------------
-- Timer Registers
----------------------------------------------------------------------------
General_Timer_Counter_Control_Register : General_Timer_Counter_Control_Type;
for General_Timer_Counter_Control_Register'Address use
System'To_Address (GTCCR_Address);
Timer_Counter2_Control_Register_A : Timer_Counter_Control_A_Type;
for Timer_Counter2_Control_Register_A'Address use
System'To_Address (TCCR2A_Address);
Timer_Counter2_Control_Register_B : Timer_Counter_Control_B_Type;
for Timer_Counter2_Control_Register_B'Address use
System'To_Address (TCCR2B_Address);
Timer_Counter2_Register : Unsigned_8;
for Timer_Counter2_Register'Address use System'To_Address (TCNT2_Address);
Output_Compare2_Register_A : Unsigned_8;
for Output_Compare2_Register_A'Address use
System'To_Address (OCR2A_Address);
Output_Compare2_Register_B : Unsigned_8;
for Output_Compare2_Register_B'Address use
System'To_Address (OCR2B_Address);
Asynchronous_Status_Register : Asynchronous_Status_Type;
for Asynchronous_Status_Register'Address use
System'To_Address (ASSR_Address);
Timer_Counter2_Interrupt_Mask_Register : Timer_Counter_Interrupt_Mask_Type;
for Timer_Counter2_Interrupt_Mask_Register'Address use
System'To_Address (TIMSK2_Address);
Timer_Counter2_Interrupt_Flag_Register : Timer_Counter_Flag_Type;
for Timer_Counter2_Interrupt_Flag_Register'Address use
System'To_Address (TIFR2_Address);
end AVR.Timers;
|
monwarez/synth | Ada | 12,199 | adb | -- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
package body PortScan.Buildcycle.Ports is
---------------------
-- build_package --
---------------------
function build_package (id : builders;
sequence_id : port_id;
interactive : Boolean := False;
interphase : String := "") return Boolean
is
R : Boolean;
break_phase : constant phases := valid_test_phase (interphase);
run_selftest : constant Boolean := Unix.env_variable_defined (selftest);
begin
trackers (id).seq_id := sequence_id;
trackers (id).loglines := 0;
if uselog then
if not initialize_log (id) then
finalize_log (id);
return False;
end if;
end if;
for phase in phases'Range loop
phase_trackers (id) := phase;
case phase is
when check_sanity | fetch | checksum | extract | patch |
pkg_package =>
R := exec_phase_generic (id, phase);
when pkg_depends | fetch_depends | extract_depends |
patch_depends | build_depends | lib_depends | run_depends =>
R := exec_phase_depends (id, phase);
when configure =>
if testing then
if lock_localbase then
set_localbase_protection (id, True);
end if;
mark_file_system (id, "preconfig");
end if;
R := exec_phase_generic (id, phase);
when build =>
R := exec_phase_build (id);
when test =>
if testing and run_selftest then
R := exec_phase_generic (id, phase);
end if;
when stage =>
if testing then
mark_file_system (id, "prestage");
end if;
R := exec_phase_generic (id, phase);
when install_mtree | install | check_plist =>
if testing then
R := exec_phase_generic (id, phase);
end if;
when deinstall =>
if testing then
R := exec_phase_deinstall (id);
end if;
end case;
exit when R = False;
exit when interactive and then phase = break_phase;
end loop;
if uselog then
finalize_log (id);
end if;
if interactive then
interact_with_builder (id);
end if;
return R;
end build_package;
---------------------------
-- valid_test_phase #1 --
---------------------------
function valid_test_phase (afterphase : String) return phases is
begin
if afterphase = "extract" then
return extract;
elsif afterphase = "patch" then
return patch;
elsif afterphase = "configure" then
return configure;
elsif afterphase = "build" then
return build;
elsif afterphase = "stage" then
return check_plist;
elsif afterphase = "install" then
return install;
elsif afterphase = "deinstall" then
return deinstall;
else
return check_sanity;
end if;
end valid_test_phase;
-----------------
-- phase2str --
-----------------
function phase2str (phase : phases) return String is
begin
case phase is
when check_sanity => return "check-sanity";
when pkg_depends => return "pkg-depends";
when fetch_depends => return "fetch-depends";
when fetch => return "fetch";
when checksum => return "checksum";
when extract_depends => return "extract-depends";
when extract => return "extract";
when patch_depends => return "patch-depends";
when patch => return "patch";
when build_depends => return "build-depends";
when lib_depends => return "lib-depends";
when configure => return "configure";
when build => return "build";
when run_depends => return "run-depends";
when stage => return "stage";
when test => return "test";
when pkg_package => return "package";
when install_mtree => return "install-mtree";
when install => return "install";
when deinstall => return "deinstall";
when check_plist => return "check-plist";
end case;
end phase2str;
-------------------------------
-- max_time_without_output --
-------------------------------
function max_time_without_output (phase : phases) return execution_limit
is
base : Integer;
begin
case phase is
when check_sanity => base := 1;
when pkg_depends => base := 3;
when fetch_depends => base := 3;
when fetch | checksum => return 480; -- 8 hours
when extract_depends => base := 3;
when extract => base := 20;
when patch_depends => base := 3;
when patch => base := 3;
when build_depends => base := 5;
when lib_depends => base := 5;
when configure => base := 15;
when build => base := 25; -- for gcc linking, tex
when run_depends => base := 15; -- octave-forge is driver
when stage => base := 20; -- desire 15 but too many rogue builders-in-stage
when test => base := 25;
when check_plist => base := 10; -- For packages with thousands of files
when pkg_package => base := 80;
when install_mtree => base := 3;
when install => base := 10;
when deinstall => base := 10;
end case;
declare
multiplier_x10 : constant Positive := timeout_multiplier_x10;
begin
return execution_limit (base * multiplier_x10 / 10);
end;
end max_time_without_output;
--------------------------
-- exec_phase_generic --
--------------------------
function exec_phase_generic (id : builders; phase : phases) return Boolean
is
time_limit : execution_limit := max_time_without_output (phase);
begin
return exec_phase (id => id, phase => phase, time_limit => time_limit);
end exec_phase_generic;
--------------------------
-- exec_phase_depends --
--------------------------
function exec_phase_depends (id : builders; phase : phases) return Boolean
is
time_limit : execution_limit := max_time_without_output (phase);
phaseenv : String := "USE_PACKAGE_DEPENDS_ONLY=1";
begin
return exec_phase (id => id, phase => phase, phaseenv => phaseenv,
time_limit => time_limit,
depends_phase => True);
end exec_phase_depends;
------------------
-- exec_phase --
------------------
function exec_phase (id : builders; phase : phases;
time_limit : execution_limit;
phaseenv : String := "";
depends_phase : Boolean := False;
skip_header : Boolean := False;
skip_footer : Boolean := False)
return Boolean
is
root : constant String := get_root (id);
port_flags : String := " NO_DEPENDS=yes ";
pid : port_id := trackers (id).seq_id;
catport : constant String := get_catport (all_ports (pid));
result : Boolean;
timed_out : Boolean;
begin
if testing or else depends_phase
then
port_flags := (others => LAT.Space);
end if;
-- Nasty, we have to switch open and close the log file for each
-- phase because we have to switch between File_Type and File
-- Descriptors. I can't find a safe way to get the File Descriptor
-- out of the File type.
if uselog then
if not skip_header then
log_phase_begin (phase2str (phase), id);
end if;
TIO.Close (trackers (id).log_handle);
end if;
declare
command : constant String := chroot & root & environment_override &
phaseenv & port_flags & chroot_make_program & " -C " & dir_ports &
"/" & catport & " " & phase2str (phase);
begin
result := generic_execute (id, command, timed_out, time_limit);
end;
-- Reopen the log. I guess we can leave off the exception check
-- since it's been passing before
if uselog then
TIO.Open (File => trackers (id).log_handle,
Mode => TIO.Append_File,
Name => log_name (trackers (id).seq_id));
if timed_out then
TIO.Put_Line (trackers (id).log_handle,
"### Watchdog killed runaway process! (no activity for" &
time_limit'Img & " minutes) ###");
end if;
if not skip_footer then
log_phase_end (id);
end if;
end if;
return result;
end exec_phase;
------------------------
-- exec_phase_build --
------------------------
function exec_phase_build (id : builders) return Boolean
is
time_limit : execution_limit := max_time_without_output (build);
passed : Boolean;
begin
passed := exec_phase (id => id,
phase => build,
time_limit => time_limit,
skip_header => False,
skip_footer => True);
if testing and then passed then
if lock_localbase then
set_localbase_protection (id, False);
end if;
passed := detect_leftovers_and_MIA
(id, "preconfig", "between port configure and build");
end if;
if uselog then
log_phase_end (id);
end if;
return passed;
end exec_phase_build;
----------------------------
-- exec_phase_deinstall --
----------------------------
function exec_phase_deinstall (id : builders) return Boolean
is
time_limit : execution_limit := max_time_without_output (deinstall);
result : Boolean;
begin
-- This is only run during "testing" so assume that.
if uselog then
log_phase_begin (phase2str (deinstall), id);
log_linked_libraries (id);
end if;
result := exec_phase (id => id,
phase => deinstall,
time_limit => time_limit,
skip_header => True,
skip_footer => True);
if not result then
if uselog then
log_phase_end (id);
end if;
return False;
end if;
if uselog then
result := detect_leftovers_and_MIA
(id, "prestage", "between staging and package deinstallation");
log_phase_end (id);
end if;
return result;
end exec_phase_deinstall;
----------------------
-- builder_status --
----------------------
function builder_status (id : builders;
shutdown : Boolean := False;
idle : Boolean := False)
return Display.builder_rec
is
phasestr : constant String := phase2str (phase_trackers (id));
begin
return builder_status_core (id => id,
shutdown => shutdown,
idle => idle,
phasestr => phasestr);
end builder_status;
------------------------
-- last_build_phase --
------------------------
function last_build_phase (id : builders) return String is
begin
return phase2str (phase => phase_trackers (id));
end last_build_phase;
end PortScan.Buildcycle.Ports;
|
reznikmm/matreshka | Ada | 4,750 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Visitors;
with ODF.DOM.Text_Execute_Macro_Elements;
package Matreshka.ODF_Text.Execute_Macro_Elements is
type Text_Execute_Macro_Element_Node is
new Matreshka.ODF_Text.Abstract_Text_Element_Node
and ODF.DOM.Text_Execute_Macro_Elements.ODF_Text_Execute_Macro
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Text_Execute_Macro_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Text_Execute_Macro_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Text_Execute_Macro_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Leave_Node
(Self : not null access Text_Execute_Macro_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Visit_Node
(Self : not null access Text_Execute_Macro_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
end Matreshka.ODF_Text.Execute_Macro_Elements;
|
reznikmm/matreshka | Ada | 3,734 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Table_Database_Name_Attributes is
pragma Preelaborate;
type ODF_Table_Database_Name_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Table_Database_Name_Attribute_Access is
access all ODF_Table_Database_Name_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Table_Database_Name_Attributes;
|
BrickBot/Bound-T-H8-300 | Ada | 2,813 | ads | -- Loops.Cells.Opt (decl)
--
-- Command-line and other options for the analysis of cells used in
-- or defined by loops.
--
-- Author: Niklas Holsti, Tidorum Ltd
--
-- A component of the Bound-T Worst-Case Execution Time Tool.
--
-------------------------------------------------------------------------------
-- Copyright (c) 1999 .. 2015 Tidorum Ltd
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
-- 2. Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
-- and/or other materials provided with the distribution.
--
-- This software is provided by the copyright holders and contributors "as is" and
-- any express or implied warranties, including, but not limited to, the implied
-- warranties of merchantability and fitness for a particular purpose are
-- disclaimed. In no event shall the copyright owner or contributors be liable for
-- any direct, indirect, incidental, special, exemplary, or consequential damages
-- (including, but not limited to, procurement of substitute goods or services;
-- loss of use, data, or profits; or business interruption) however caused and
-- on any theory of liability, whether in contract, strict liability, or tort
-- (including negligence or otherwise) arising in any way out of the use of this
-- software, even if advised of the possibility of such damage.
--
-- Other modules (files) of this software composition should contain their
-- own copyright statements, which may have different copyright and usage
-- conditions. The above conditions apply to this file.
-------------------------------------------------------------------------------
--
-- $Revision: 1.3 $
-- $Date: 2015/10/24 19:36:50 $
--
-- $Log: loops-cells-opt.ads,v $
-- Revision 1.3 2015/10/24 19:36:50 niklas
-- Moved to free licence.
--
-- Revision 1.2 2011-08-31 04:23:34 niklas
-- BT-CH-0222: Option registry. Option -dump. External help files.
--
-- Revision 1.1 2007/10/05 20:03:24 niklas
-- First version, for BT-CH-0086.
--
with Options.Bool;
package Loops.Cells.Opt is
pragma Elaborate_Body;
--
-- To register the options.
Include_Primitive_Opt : aliased Options.Bool.Option_T (Default => True);
--
-- Whether to include cells used/defined in the "primitive"
-- arithmetic model (the Flow.Graph), in addition to the cells
-- used/defined in the given (refined) computation model.
--
Include_Primitive : Boolean renames Include_Primitive_Opt.Value;
end Loops.Cells.Opt;
|
reznikmm/matreshka | Ada | 10,681 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.CMOF;
with AMF.Internals.Tables.CMOF_Attributes;
with AMF.Internals.Tables.Standard_Profile_L3_String_Data_00;
package body AMF.Internals.Tables.Standard_Profile_L3_Metamodel.Properties is
----------------
-- Initialize --
----------------
procedure Initialize is
begin
Initialize_1;
Initialize_2;
Initialize_3;
Initialize_4;
Initialize_5;
Initialize_6;
Initialize_7;
Initialize_8;
Initialize_9;
Initialize_10;
Initialize_11;
Initialize_12;
Initialize_13;
Initialize_14;
Initialize_15;
end Initialize;
------------------
-- Initialize_1 --
------------------
procedure Initialize_1 is
begin
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Name
(Base + 1,
AMF.Internals.Tables.Standard_Profile_L3_String_Data_00.MS_0003'Access);
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Visibility (Base + 1, (Is_Empty => True));
end Initialize_1;
------------------
-- Initialize_2 --
------------------
procedure Initialize_2 is
begin
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Name
(Base + 2,
AMF.Internals.Tables.Standard_Profile_L3_String_Data_00.MS_000D'Access);
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Visibility (Base + 2, (Is_Empty => True));
end Initialize_2;
------------------
-- Initialize_3 --
------------------
procedure Initialize_3 is
begin
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Name
(Base + 3,
AMF.Internals.Tables.Standard_Profile_L3_String_Data_00.MS_0007'Access);
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Visibility (Base + 3, (Is_Empty => True));
end Initialize_3;
------------------
-- Initialize_4 --
------------------
procedure Initialize_4 is
begin
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Name
(Base + 4,
AMF.Internals.Tables.Standard_Profile_L3_String_Data_00.MS_0006'Access);
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Visibility (Base + 4, (False, AMF.CMOF.Public_Visibility));
end Initialize_4;
------------------
-- Initialize_5 --
------------------
procedure Initialize_5 is
begin
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Name
(Base + 5,
AMF.Internals.Tables.Standard_Profile_L3_String_Data_00.MS_0005'Access);
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Visibility (Base + 5, (False, AMF.CMOF.Public_Visibility));
end Initialize_5;
------------------
-- Initialize_6 --
------------------
procedure Initialize_6 is
begin
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Name
(Base + 6,
AMF.Internals.Tables.Standard_Profile_L3_String_Data_00.MS_0005'Access);
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Visibility (Base + 6, (False, AMF.CMOF.Public_Visibility));
end Initialize_6;
------------------
-- Initialize_7 --
------------------
procedure Initialize_7 is
begin
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Name
(Base + 7,
AMF.Internals.Tables.Standard_Profile_L3_String_Data_00.MS_0001'Access);
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Visibility (Base + 7, (Is_Empty => True));
end Initialize_7;
------------------
-- Initialize_8 --
------------------
procedure Initialize_8 is
begin
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Name
(Base + 8,
AMF.Internals.Tables.Standard_Profile_L3_String_Data_00.MS_000B'Access);
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Visibility (Base + 8, (Is_Empty => True));
end Initialize_8;
------------------
-- Initialize_9 --
------------------
procedure Initialize_9 is
begin
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Name
(Base + 9,
AMF.Internals.Tables.Standard_Profile_L3_String_Data_00.MS_0009'Access);
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Visibility (Base + 9, (Is_Empty => True));
end Initialize_9;
-------------------
-- Initialize_10 --
-------------------
procedure Initialize_10 is
begin
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Name
(Base + 10,
AMF.Internals.Tables.Standard_Profile_L3_String_Data_00.MS_0008'Access);
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Uri
(Base + 10,
AMF.Internals.Tables.Standard_Profile_L3_String_Data_00.MS_0004'Access);
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Visibility (Base + 10, (Is_Empty => True));
end Initialize_10;
-------------------
-- Initialize_11 --
-------------------
procedure Initialize_11 is
begin
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Visibility (Base + 11, AMF.CMOF.Public_Visibility);
end Initialize_11;
-------------------
-- Initialize_12 --
-------------------
procedure Initialize_12 is
begin
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Is_Composite (Base + 12, True);
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Lower (Base + 12, (False, 0));
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Name
(Base + 12,
AMF.Internals.Tables.Standard_Profile_L3_String_Data_00.MS_000C'Access);
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Visibility (Base + 12, (False, AMF.CMOF.Public_Visibility));
end Initialize_12;
-------------------
-- Initialize_13 --
-------------------
procedure Initialize_13 is
begin
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Is_Composite (Base + 13, True);
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Lower (Base + 13, (False, 0));
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Name
(Base + 13,
AMF.Internals.Tables.Standard_Profile_L3_String_Data_00.MS_0000'Access);
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Visibility (Base + 13, (False, AMF.CMOF.Public_Visibility));
end Initialize_13;
-------------------
-- Initialize_14 --
-------------------
procedure Initialize_14 is
begin
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Is_Composite (Base + 14, True);
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Lower (Base + 14, (False, 0));
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Name
(Base + 14,
AMF.Internals.Tables.Standard_Profile_L3_String_Data_00.MS_0002'Access);
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Visibility (Base + 14, (False, AMF.CMOF.Public_Visibility));
end Initialize_14;
-------------------
-- Initialize_15 --
-------------------
procedure Initialize_15 is
begin
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Name
(Base + 15,
AMF.Internals.Tables.Standard_Profile_L3_String_Data_00.MS_000A'Access);
AMF.Internals.Tables.CMOF_Attributes.Internal_Set_Value
(Base + 15,
AMF.Internals.Tables.Standard_Profile_L3_String_Data_00.MS_0008'Access);
end Initialize_15;
end AMF.Internals.Tables.Standard_Profile_L3_Metamodel.Properties;
|
1Crazymoney/LearnAda | Ada | 923 | adb | package body Vermek is
procedure Push( V: in out Verem; E: in Elem ) is
begin
V.Veremtető := new Csúcs'(E,V.Veremtető);
V.Méret := V.Méret + 1;
end;
procedure Pop( V: in out Verem; E: out Elem ) is
begin
E := Top(V);
V.Veremtető := V.Veremtető.Következő;
V.Méret := V.Méret - 1;
end;
function Top( V: Verem ) return Elem is
begin
return V.Veremtető.Adat;
exception
when Constraint_Error => raise Üres_A_Verem;
end;
function Is_Empty( V: Verem ) return Boolean is
begin
return V.Méret = 0;
end;
function Is_Full( V: Verem ) return Boolean is
begin
return False;
end;
function Size( V: Verem ) return Natural is
begin
return V.Méret;
end;
end Vermek;
|
reznikmm/matreshka | Ada | 15,649 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Internals.UML_Named_Elements;
with AMF.UML.Activities;
with AMF.UML.Activity_Edges.Collections;
with AMF.UML.Activity_Groups.Collections;
with AMF.UML.Activity_Nodes.Collections;
with AMF.UML.Activity_Partitions.Collections;
with AMF.UML.Behaviors;
with AMF.UML.Classifiers.Collections;
with AMF.UML.Decision_Nodes;
with AMF.UML.Dependencies.Collections;
with AMF.UML.Interruptible_Activity_Regions.Collections;
with AMF.UML.Named_Elements;
with AMF.UML.Namespaces;
with AMF.UML.Object_Flows;
with AMF.UML.Packages.Collections;
with AMF.UML.Redefinable_Elements.Collections;
with AMF.UML.String_Expressions;
with AMF.UML.Structured_Activity_Nodes;
with AMF.Visitors;
package AMF.Internals.UML_Decision_Nodes is
type UML_Decision_Node_Proxy is
limited new AMF.Internals.UML_Named_Elements.UML_Named_Element_Proxy
and AMF.UML.Decision_Nodes.UML_Decision_Node with null record;
overriding function Get_Decision_Input
(Self : not null access constant UML_Decision_Node_Proxy)
return AMF.UML.Behaviors.UML_Behavior_Access;
-- Getter of DecisionNode::decisionInput.
--
-- Provides input to guard specifications on edges outgoing from the
-- decision node.
overriding procedure Set_Decision_Input
(Self : not null access UML_Decision_Node_Proxy;
To : AMF.UML.Behaviors.UML_Behavior_Access);
-- Setter of DecisionNode::decisionInput.
--
-- Provides input to guard specifications on edges outgoing from the
-- decision node.
overriding function Get_Decision_Input_Flow
(Self : not null access constant UML_Decision_Node_Proxy)
return AMF.UML.Object_Flows.UML_Object_Flow_Access;
-- Getter of DecisionNode::decisionInputFlow.
--
-- An additional edge incoming to the decision node that provides a
-- decision input value.
overriding procedure Set_Decision_Input_Flow
(Self : not null access UML_Decision_Node_Proxy;
To : AMF.UML.Object_Flows.UML_Object_Flow_Access);
-- Setter of DecisionNode::decisionInputFlow.
--
-- An additional edge incoming to the decision node that provides a
-- decision input value.
overriding function Get_Activity
(Self : not null access constant UML_Decision_Node_Proxy)
return AMF.UML.Activities.UML_Activity_Access;
-- Getter of ActivityNode::activity.
--
-- Activity containing the node.
overriding procedure Set_Activity
(Self : not null access UML_Decision_Node_Proxy;
To : AMF.UML.Activities.UML_Activity_Access);
-- Setter of ActivityNode::activity.
--
-- Activity containing the node.
overriding function Get_In_Group
(Self : not null access constant UML_Decision_Node_Proxy)
return AMF.UML.Activity_Groups.Collections.Set_Of_UML_Activity_Group;
-- Getter of ActivityNode::inGroup.
--
-- Groups containing the node.
overriding function Get_In_Interruptible_Region
(Self : not null access constant UML_Decision_Node_Proxy)
return AMF.UML.Interruptible_Activity_Regions.Collections.Set_Of_UML_Interruptible_Activity_Region;
-- Getter of ActivityNode::inInterruptibleRegion.
--
-- Interruptible regions containing the node.
overriding function Get_In_Partition
(Self : not null access constant UML_Decision_Node_Proxy)
return AMF.UML.Activity_Partitions.Collections.Set_Of_UML_Activity_Partition;
-- Getter of ActivityNode::inPartition.
--
-- Partitions containing the node.
overriding function Get_In_Structured_Node
(Self : not null access constant UML_Decision_Node_Proxy)
return AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access;
-- Getter of ActivityNode::inStructuredNode.
--
-- Structured activity node containing the node.
overriding procedure Set_In_Structured_Node
(Self : not null access UML_Decision_Node_Proxy;
To : AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access);
-- Setter of ActivityNode::inStructuredNode.
--
-- Structured activity node containing the node.
overriding function Get_Incoming
(Self : not null access constant UML_Decision_Node_Proxy)
return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge;
-- Getter of ActivityNode::incoming.
--
-- Edges that have the node as target.
overriding function Get_Outgoing
(Self : not null access constant UML_Decision_Node_Proxy)
return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge;
-- Getter of ActivityNode::outgoing.
--
-- Edges that have the node as source.
overriding function Get_Redefined_Node
(Self : not null access constant UML_Decision_Node_Proxy)
return AMF.UML.Activity_Nodes.Collections.Set_Of_UML_Activity_Node;
-- Getter of ActivityNode::redefinedNode.
--
-- Inherited nodes replaced by this node in a specialization of the
-- activity.
overriding function Get_Is_Leaf
(Self : not null access constant UML_Decision_Node_Proxy)
return Boolean;
-- Getter of RedefinableElement::isLeaf.
--
-- Indicates whether it is possible to further redefine a
-- RedefinableElement. If the value is true, then it is not possible to
-- further redefine the RedefinableElement. Note that this property is
-- preserved through package merge operations; that is, the capability to
-- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in
-- the resulting RedefinableElement of a package merge operation where a
-- RedefinableElement with isLeaf=false is merged with a matching
-- RedefinableElement with isLeaf=true: the resulting RedefinableElement
-- will have isLeaf=false. Default value is false.
overriding procedure Set_Is_Leaf
(Self : not null access UML_Decision_Node_Proxy;
To : Boolean);
-- Setter of RedefinableElement::isLeaf.
--
-- Indicates whether it is possible to further redefine a
-- RedefinableElement. If the value is true, then it is not possible to
-- further redefine the RedefinableElement. Note that this property is
-- preserved through package merge operations; that is, the capability to
-- redefine a RedefinableElement (i.e., isLeaf=false) must be preserved in
-- the resulting RedefinableElement of a package merge operation where a
-- RedefinableElement with isLeaf=false is merged with a matching
-- RedefinableElement with isLeaf=true: the resulting RedefinableElement
-- will have isLeaf=false. Default value is false.
overriding function Get_Redefined_Element
(Self : not null access constant UML_Decision_Node_Proxy)
return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element;
-- Getter of RedefinableElement::redefinedElement.
--
-- The redefinable element that is being redefined by this element.
overriding function Get_Redefinition_Context
(Self : not null access constant UML_Decision_Node_Proxy)
return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier;
-- Getter of RedefinableElement::redefinitionContext.
--
-- References the contexts that this element may be redefined from.
overriding function Get_Client_Dependency
(Self : not null access constant UML_Decision_Node_Proxy)
return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency;
-- Getter of NamedElement::clientDependency.
--
-- Indicates the dependencies that reference the client.
overriding function Get_Name_Expression
(Self : not null access constant UML_Decision_Node_Proxy)
return AMF.UML.String_Expressions.UML_String_Expression_Access;
-- Getter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding procedure Set_Name_Expression
(Self : not null access UML_Decision_Node_Proxy;
To : AMF.UML.String_Expressions.UML_String_Expression_Access);
-- Setter of NamedElement::nameExpression.
--
-- The string expression used to define the name of this named element.
overriding function Get_Namespace
(Self : not null access constant UML_Decision_Node_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Getter of NamedElement::namespace.
--
-- Specifies the namespace that owns the NamedElement.
overriding function Get_Qualified_Name
(Self : not null access constant UML_Decision_Node_Proxy)
return AMF.Optional_String;
-- Getter of NamedElement::qualifiedName.
--
-- A name which allows the NamedElement to be identified within a
-- hierarchy of nested Namespaces. It is constructed from the names of the
-- containing namespaces starting at the root of the hierarchy and ending
-- with the name of the NamedElement itself.
overriding function Is_Consistent_With
(Self : not null access constant UML_Decision_Node_Proxy;
Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean;
-- Operation RedefinableElement::isConsistentWith.
--
-- The query isConsistentWith() specifies, for any two RedefinableElements
-- in a context in which redefinition is possible, whether redefinition
-- would be logically consistent. By default, this is false; this
-- operation must be overridden for subclasses of RedefinableElement to
-- define the consistency conditions.
overriding function Is_Redefinition_Context_Valid
(Self : not null access constant UML_Decision_Node_Proxy;
Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
return Boolean;
-- Operation RedefinableElement::isRedefinitionContextValid.
--
-- The query isRedefinitionContextValid() specifies whether the
-- redefinition contexts of this RedefinableElement are properly related
-- to the redefinition contexts of the specified RedefinableElement to
-- allow this element to redefine the other. By default at least one of
-- the redefinition contexts of this element must be a specialization of
-- at least one of the redefinition contexts of the specified element.
overriding function All_Owning_Packages
(Self : not null access constant UML_Decision_Node_Proxy)
return AMF.UML.Packages.Collections.Set_Of_UML_Package;
-- Operation NamedElement::allOwningPackages.
--
-- The query allOwningPackages() returns all the directly or indirectly
-- owning packages.
overriding function Is_Distinguishable_From
(Self : not null access constant UML_Decision_Node_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access;
Ns : AMF.UML.Namespaces.UML_Namespace_Access)
return Boolean;
-- Operation NamedElement::isDistinguishableFrom.
--
-- The query isDistinguishableFrom() determines whether two NamedElements
-- may logically co-exist within a Namespace. By default, two named
-- elements are distinguishable if (a) they have unrelated types or (b)
-- they have related types but different names.
overriding function Namespace
(Self : not null access constant UML_Decision_Node_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access;
-- Operation NamedElement::namespace.
--
-- Missing derivation for NamedElement::/namespace : Namespace
overriding procedure Enter_Element
(Self : not null access constant UML_Decision_Node_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Leave_Element
(Self : not null access constant UML_Decision_Node_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of visitor interface.
overriding procedure Visit_Element
(Self : not null access constant UML_Decision_Node_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
-- Dispatch call to corresponding subprogram of iterator interface.
end AMF.Internals.UML_Decision_Nodes;
|
AdaCore/langkit | Ada | 486 | adb | with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Text_IO; use Ada.Text_IO;
with Libfoolang.Analysis; use Libfoolang.Analysis;
procedure Main is
Buffer : constant Unbounded_String := To_Unbounded_String ("example");
U : constant Analysis_Unit := Create_Context.Get_From_Buffer
(Filename => "main.txt", Buffer => Buffer);
begin
if U.Has_Diagnostics then
raise Program_Error;
end if;
U.Root.Print;
Put_Line ("Done.");
end Main;
|
reznikmm/matreshka | Ada | 5,499 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Internals.Utp_Elements;
with AMF.UML.Invocation_Actions;
with AMF.UML.Opaque_Actions;
with AMF.Utp.Finish_Actions;
with AMF.Visitors;
package AMF.Internals.Utp_Finish_Actions is
type Utp_Finish_Action_Proxy is
limited new AMF.Internals.Utp_Elements.Utp_Element_Proxy
and AMF.Utp.Finish_Actions.Utp_Finish_Action with null record;
overriding function Get_Base_Opaque_Action
(Self : not null access constant Utp_Finish_Action_Proxy)
return AMF.UML.Opaque_Actions.UML_Opaque_Action_Access;
-- Getter of FinishAction::base_OpaqueAction.
--
overriding procedure Set_Base_Opaque_Action
(Self : not null access Utp_Finish_Action_Proxy;
To : AMF.UML.Opaque_Actions.UML_Opaque_Action_Access);
-- Setter of FinishAction::base_OpaqueAction.
--
overriding function Get_Base_Invocation_Action
(Self : not null access constant Utp_Finish_Action_Proxy)
return AMF.UML.Invocation_Actions.UML_Invocation_Action_Access;
-- Getter of FinishAction::base_InvocationAction.
--
overriding procedure Set_Base_Invocation_Action
(Self : not null access Utp_Finish_Action_Proxy;
To : AMF.UML.Invocation_Actions.UML_Invocation_Action_Access);
-- Setter of FinishAction::base_InvocationAction.
--
overriding procedure Enter_Element
(Self : not null access constant Utp_Finish_Action_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
overriding procedure Leave_Element
(Self : not null access constant Utp_Finish_Action_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
overriding procedure Visit_Element
(Self : not null access constant Utp_Finish_Action_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
end AMF.Internals.Utp_Finish_Actions;
|
reznikmm/matreshka | Ada | 4,679 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Text.Use_Keys_As_Entries_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_Use_Keys_As_Entries_Attribute_Node is
begin
return Self : Text_Use_Keys_As_Entries_Attribute_Node do
Matreshka.ODF_Text.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Text_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Text_Use_Keys_As_Entries_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Use_Keys_As_Entries_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Use_Keys_As_Entries_Attribute,
Text_Use_Keys_As_Entries_Attribute_Node'Tag);
end Matreshka.ODF_Text.Use_Keys_As_Entries_Attributes;
|
optikos/oasis | Ada | 4,235 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Elements.Defining_Identifiers;
with Program.Lexical_Elements;
with Program.Elements.Choice_Parameter_Specifications;
with Program.Element_Visitors;
package Program.Nodes.Choice_Parameter_Specifications is
pragma Preelaborate;
type Choice_Parameter_Specification is
new Program.Nodes.Node
and Program.Elements.Choice_Parameter_Specifications
.Choice_Parameter_Specification
and Program.Elements.Choice_Parameter_Specifications
.Choice_Parameter_Specification_Text
with private;
function Create
(Name : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access;
Colon_Token : not null Program.Lexical_Elements.Lexical_Element_Access)
return Choice_Parameter_Specification;
type Implicit_Choice_Parameter_Specification is
new Program.Nodes.Node
and Program.Elements.Choice_Parameter_Specifications
.Choice_Parameter_Specification
with private;
function Create
(Name : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False)
return Implicit_Choice_Parameter_Specification
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Choice_Parameter_Specification is
abstract new Program.Nodes.Node
and Program.Elements.Choice_Parameter_Specifications
.Choice_Parameter_Specification
with record
Name : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access;
end record;
procedure Initialize
(Self : aliased in out Base_Choice_Parameter_Specification'Class);
overriding procedure Visit
(Self : not null access Base_Choice_Parameter_Specification;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Name
(Self : Base_Choice_Parameter_Specification)
return not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access;
overriding function Is_Choice_Parameter_Specification_Element
(Self : Base_Choice_Parameter_Specification)
return Boolean;
overriding function Is_Declaration_Element
(Self : Base_Choice_Parameter_Specification)
return Boolean;
type Choice_Parameter_Specification is
new Base_Choice_Parameter_Specification
and Program.Elements.Choice_Parameter_Specifications
.Choice_Parameter_Specification_Text
with record
Colon_Token : not null Program.Lexical_Elements.Lexical_Element_Access;
end record;
overriding function To_Choice_Parameter_Specification_Text
(Self : aliased in out Choice_Parameter_Specification)
return Program.Elements.Choice_Parameter_Specifications
.Choice_Parameter_Specification_Text_Access;
overriding function Colon_Token
(Self : Choice_Parameter_Specification)
return not null Program.Lexical_Elements.Lexical_Element_Access;
type Implicit_Choice_Parameter_Specification is
new Base_Choice_Parameter_Specification
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
end record;
overriding function To_Choice_Parameter_Specification_Text
(Self : aliased in out Implicit_Choice_Parameter_Specification)
return Program.Elements.Choice_Parameter_Specifications
.Choice_Parameter_Specification_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Choice_Parameter_Specification)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Choice_Parameter_Specification)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Choice_Parameter_Specification)
return Boolean;
end Program.Nodes.Choice_Parameter_Specifications;
|
burratoo/Acton | Ada | 1,343 | adb | ------------------------------------------------------------------------------------------
-- --
-- OAK COMPONENTS --
-- --
-- OAK.INTERRUPTS --
-- --
-- Copyright (C) 2012-2021, Patrick Bernardi --
-- --
------------------------------------------------------------------------------------------
with Oak.Brokers.Protected_Objects; use Oak.Brokers.Protected_Objects;
package body Oak.Interrupts is
procedure Attach_Handler (Handler : in Interrupt_Handler_Pair) is
begin
Oak.Processor_Support_Package.Interrupts.Attach_Handler
(Interrupt => Handler.Interrupt,
Handler => Handler.Handler,
Priority =>
Ceiling_Priority
(Protected_Object_From_Access
(Parameterless_Access (Handler.Handler))));
end Attach_Handler;
end Oak.Interrupts;
|
reznikmm/matreshka | Ada | 4,246 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision: 2342 $ $Date: 2011-12-06 17:15:51 +0200 (Втр, 06 Дек 2011) $
------------------------------------------------------------------------------
with Matreshka.Internals.Code_Point_Sets;
with Matreshka.Internals.Regexps;
with Matreshka.Internals.Unicode.Ucd;
package League.Character_Sets.Internals is
pragma Preelaborate;
use Matreshka.Internals;
function To_Set
(Flags : Matreshka.Internals.Regexps.General_Category_Flags)
return Universal_Character_Set;
function To_Set
(Property : Matreshka.Internals.Unicode.Ucd.Boolean_Properties)
return Universal_Character_Set;
function Wrap
(Data : not null Code_Point_Sets.Shared_Code_Point_Set_Access)
return Universal_Character_Set;
-- Creates instance of Universal_Character_Set as wrapper for the specified
-- shared data. Reference counter is untouched, thus once instance will
-- be finalized it will be decremented and shared data freed.
end League.Character_Sets.Internals;
|
DrenfongWong/tkm-rpc | Ada | 1,662 | ads | with Tkmrpc.Types;
with Tkmrpc.Operations.Ike;
package Tkmrpc.Request.Ike.Cc_Add_Certificate is
Data_Size : constant := 1520;
type Data_Type is record
Cc_Id : Types.Cc_Id_Type;
Autha_Id : Types.Autha_Id_Type;
Certificate : Types.Certificate_Type;
end record;
for Data_Type use record
Cc_Id at 0 range 0 .. (8 * 8) - 1;
Autha_Id at 8 range 0 .. (8 * 8) - 1;
Certificate at 16 range 0 .. (1504 * 8) - 1;
end record;
for Data_Type'Size use Data_Size * 8;
Padding_Size : constant := Request.Body_Size - Data_Size;
subtype Padding_Range is Natural range 1 .. Padding_Size;
subtype Padding_Type is Types.Byte_Sequence (Padding_Range);
type Request_Type is record
Header : Request.Header_Type;
Data : Data_Type;
Padding : Padding_Type;
end record;
for Request_Type use record
Header at 0 range 0 .. (Request.Header_Size * 8) - 1;
Data at Request.Header_Size range 0 .. (Data_Size * 8) - 1;
Padding at Request.Header_Size + Data_Size range
0 .. (Padding_Size * 8) - 1;
end record;
for Request_Type'Size use Request.Request_Size * 8;
Null_Request : constant Request_Type :=
Request_Type'
(Header =>
Request.Header_Type'(Operation => Operations.Ike.Cc_Add_Certificate,
Request_Id => 0),
Data =>
Data_Type'(Cc_Id => Types.Cc_Id_Type'First,
Autha_Id => Types.Autha_Id_Type'First,
Certificate => Types.Null_Certificate_Type),
Padding => Padding_Type'(others => 0));
end Tkmrpc.Request.Ike.Cc_Add_Certificate;
|
reznikmm/matreshka | Ada | 4,456 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
-- The most general class for UML elements that may have contents shown in
-- separated portions inside the shape.
------------------------------------------------------------------------------
limited with AMF.UMLDI.UML_Compartments.Collections;
with AMF.UMLDI.UML_Shapes;
package AMF.UMLDI.UML_Compartmentable_Shapes is
pragma Preelaborate;
type UMLDI_UML_Compartmentable_Shape is limited interface
and AMF.UMLDI.UML_Shapes.UMLDI_UML_Shape;
type UMLDI_UML_Compartmentable_Shape_Access is
access all UMLDI_UML_Compartmentable_Shape'Class;
for UMLDI_UML_Compartmentable_Shape_Access'Storage_Size use 0;
not overriding function Get_Compartment
(Self : not null access constant UMLDI_UML_Compartmentable_Shape)
return AMF.UMLDI.UML_Compartments.Collections.Ordered_Set_Of_UMLDI_UML_Compartment is abstract;
-- Getter of UMLCompartmentableShape::compartment.
--
-- Separated portions of the shape.
end AMF.UMLDI.UML_Compartmentable_Shapes;
|
reznikmm/matreshka | Ada | 6,980 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Anim.AnimateTransform_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Anim_AnimateTransform_Element_Node is
begin
return Self : Anim_AnimateTransform_Element_Node do
Matreshka.ODF_Anim.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Anim_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Anim_AnimateTransform_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Anim_AnimateTransform
(ODF.DOM.Anim_AnimateTransform_Elements.ODF_Anim_AnimateTransform_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Anim_AnimateTransform_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.AnimateTransform_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Anim_AnimateTransform_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Anim_AnimateTransform
(ODF.DOM.Anim_AnimateTransform_Elements.ODF_Anim_AnimateTransform_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Anim_AnimateTransform_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Anim_AnimateTransform
(Visitor,
ODF.DOM.Anim_AnimateTransform_Elements.ODF_Anim_AnimateTransform_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Anim_URI,
Matreshka.ODF_String_Constants.AnimateTransform_Element,
Anim_AnimateTransform_Element_Node'Tag);
end Matreshka.ODF_Anim.AnimateTransform_Elements;
|
stcarrez/bbox-ada-api | Ada | 6,387 | adb | -----------------------------------------------------------------------
-- druss-commands-devices -- Print information about the devices
-- Copyright (C) 2017, 2018, 2019, 2021, 2023 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Util.Properties;
with Bbox.API;
with Druss.Gateways;
package body Druss.Commands.Devices is
use Ada.Strings.Unbounded;
-- ------------------------------
-- Execute the wifi 'status' command to print the Wifi current status.
-- ------------------------------
procedure Do_List (Command : in Command_Type;
Args : in Argument_List'Class;
Selector : in Device_Selector_Type;
Context : in out Context_Type) is
pragma Unreferenced (Command, Args);
procedure Box_Status (Gateway : in out Druss.Gateways.Gateway_Type);
Console : constant Druss.Commands.Consoles.Console_Access := Context.Console;
procedure Box_Status (Gateway : in out Druss.Gateways.Gateway_Type) is
procedure Print_Device (Manager : in Util.Properties.Manager;
Name : in String);
procedure Print_Device (Manager : in Util.Properties.Manager;
Name : in String) is
Link : constant String := Manager.Get (Name & ".link", "");
Kind : constant String := Manager.Get (Name & ".devicetype", "");
begin
case Selector is
when DEVICE_ALL =>
null;
when DEVICE_ACTIVE =>
if Manager.Get (Name & ".active", "") = "0" then
return;
end if;
when DEVICE_INACTIVE =>
if Manager.Get (Name & ".active", "") = "1" then
return;
end if;
end case;
Console.Start_Row;
Console.Print_Field (F_BBOX_IP_ADDR, To_String (Gateway.Ip));
Console.Print_Field (F_IP_ADDR, Manager.Get (Name & ".ipaddress", ""));
Console.Print_Field (F_ETHERNET, Manager.Get (Name & ".macaddress", ""));
Console.Print_Field (F_HOSTNAME, Manager.Get (Name & ".hostname", ""));
-- Console.Print_Field (F_ACTIVE, Manager.Get (Name & ".active", ""));
Console.Print_Field (F_DEVTYPE, (if Kind = "STB" then "STB" else ""));
if Link = "Ethernet" then
Console.Print_Field (F_LINK, Link & " port "
& Manager.Get (Name & ".ethernet.logicalport", ""));
else
Console.Print_Field (F_LINK, Link & " RSSI "
& Manager.Get (Name & ".wireless.rssi0", ""));
end if;
Console.End_Row;
end Print_Device;
begin
Gateway.Refresh;
Bbox.API.Iterate (Gateway.Hosts, "hosts.list", Print_Device'Access);
end Box_Status;
begin
Console.Start_Title;
Console.Print_Title (F_BBOX_IP_ADDR, "Bbox IP", 16);
Console.Print_Title (F_IP_ADDR, "Device IP", 16);
Console.Print_Title (F_ETHERNET, "Ethernet", 20);
Console.Print_Title (F_HOSTNAME, "Hostname", 28);
Console.Print_Title (F_DEVTYPE, "Type", 6);
-- Console.Print_Title (F_ACTIVE, "Active", 8);
Console.Print_Title (F_LINK, "Link", 18);
Console.End_Title;
Druss.Gateways.Iterate (Context.Gateways, Gateways.ITER_ENABLE, Box_Status'Access);
end Do_List;
-- ------------------------------
-- Execute a status command to report information about the Bbox.
-- ------------------------------
overriding
procedure Execute (Command : in out Command_Type;
Name : in String;
Args : in Argument_List'Class;
Context : in out Context_Type) is
pragma Unreferenced (Name);
begin
if Args.Get_Count > 1 then
Context.Console.Notice (N_USAGE, "Too many arguments to the command");
Druss.Commands.Driver.Usage (Args, Context);
elsif Args.Get_Count = 0 then
Command.Do_List (Args, DEVICE_ACTIVE, Context);
elsif Args.Get_Argument (1) = "all" then
Command.Do_List (Args, DEVICE_ALL, Context);
elsif Args.Get_Argument (1) = "active" then
Command.Do_List (Args, DEVICE_ACTIVE, Context);
elsif Args.Get_Argument (1) = "inactive" then
Command.Do_List (Args, DEVICE_INACTIVE, Context);
else
Context.Console.Notice (N_USAGE, "Invalid argument: " & Args.Get_Argument (1));
Druss.Commands.Driver.Usage (Args, Context);
end if;
end Execute;
-- ------------------------------
-- Write the help associated with the command.
-- ------------------------------
overriding
procedure Help (Command : in out Command_Type;
Name : in String;
Context : in out Context_Type) is
pragma Unreferenced (Command);
Console : constant Druss.Commands.Consoles.Console_Access := Context.Console;
begin
Console.Notice (N_HELP, "devices: Print information about the devices");
Console.Notice (N_HELP, "Usage: devices [all | active | inactive]");
Console.Notice (N_HELP, "");
Console.Notice (N_HELP, " List the devices that are known by the Bbox.");
Console.Notice (N_HELP, "");
Console.Notice (N_HELP, " all List all the devices");
Console.Notice (N_HELP, " active List the active devices (the default)");
Console.Notice (N_HELP, " inative List the inactive devices");
end Help;
end Druss.Commands.Devices;
|
riccardo-bernardini/eugen | Ada | 2,821 | adb | pragma Ada_2012;
package body EU_Projects.Times.Time_Expressions.Solving is
------------------
-- Add_Equation --
------------------
procedure Add_Equation (Equations : in out Time_Equation_System;
Left : Dotted_Identifier;
Right : Symbolic_Duration)
is
begin
if Contains_Left_Term (Equations, Left) then
raise Constraint_Error;
end if;
Equations.M.Insert (Key => Left,
New_Item => (Duration_Value, Right.D));
end Add_Equation;
------------------
-- Add_Equation --
------------------
procedure Add_Equation (Equations : in out Time_Equation_System;
Left : Dotted_Identifier;
Right : Symbolic_Instant)
is
begin
if Contains_Left_Term (Equations, Left) then
raise Constraint_Error;
end if;
-- Put_Line ("ADD(" & To_String (Left) & "," & Time_Expr.Dump (Right.T) & ")");
Equations.M.Insert (Key => Left,
New_Item => (Instant_value, Right.T));
end Add_Equation;
-----------
-- Solve --
-----------
function Solve (Equations : Time_Equation_System) return Variable_Map
is
Eq : Time_Equations.Equation_Tables.Map;
R : Time_Expr.Variable_Tables.Map;
Success : Boolean;
begin
for C in Equations.M.Iterate loop
Eq.Insert (Key => Equation_Maps.Key (C),
New_Item => Equation_Maps.Element (C).Val);
end loop;
Time_Equations.Triangular_Solve (What => Eq,
Result => R,
Success => Success);
if not Success then
raise Unsolvable;
end if;
declare
Result : Variable_Map;
begin
for C in R.Iterate loop
declare
use Time_Expr.Variable_Tables;
ID : constant Dotted_Identifier := Key (C);
Val : constant Scalar_Type := Element (C);
begin
case Equations.M.Element (ID).Class is
when Instant_Value =>
Result.M.Insert (Key => ID,
New_Item => (Class => Instant_Value,
I => Instant (Val)));
when Duration_Value =>
Result.M.Insert (Key => ID,
New_Item => (Class => Duration_Value,
D => Duration (Val)));
end case;
end;
end loop;
return Result;
end;
end Solve;
end EU_Projects.Times.Time_Expressions.Solving;
|
reznikmm/gela | Ada | 10,991 | ads | ------------------------------------------------------------------------------
-- G E L A A S I S --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- --
-- This specification is derived from the Ada Semantic Interface --
-- Specification Standard (ISO/IEC 15291) and ASIS 1999 Issues. --
-- --
-- The copyright notice and the license provisions that follow apply to the --
-- part following the private keyword. --
-- --
-- Read copyright and license at the end of this file --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- 19 package Asis.Clauses
------------------------------------------------------------------------------
------------------------------------------------------------------------------
package Asis.Clauses is
pragma Preelaborate;
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Asis.Clauses
--
-- This package encapsulates a set of queries that operate on A_Clause
-- elements.
--
-- |ER-----------------------------------------------------------------------
-- |ER A_Use_Package_Clause - 8.4
-- |ER A_Use_Type_Clause - 8.4
-- |ER A_With_Clause - 10.1.2
-- |CR
-- |CR Child elements returned by:
-- |CR function Clause_Names
-- |CR
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- 19.1 function Clause_Names
------------------------------------------------------------------------------
function Clause_Names (Clause : in Asis.Element)
return Asis.Name_List;
------------------------------------------------------------------------------
-- Clause - Specifies the with_clause or use_clause to query
--
-- Returns a list of the names that appear in the given clause.
-- The names in the list should be in their order of appearance in the
-- original clauses from the compilation text.
--
-- Results of this query may vary across ASIS implementations. Some
-- implementations normalize all clauses containing multiple names
-- into an equivalent sequence of corresponding single clauses.
-- Similarly, an implementation may keep a name only once even though that
-- name can appear more than once in a clause.
--
-- Appropriate Element_Kinds:
-- A_Use_Package_Clause
-- A_Use_Type_Clause
-- A_With_Clause
--
-- Returns Expression_Kinds:
-- An_Identifier
-- A_Selected_Component
-- An_Attribute_Reference
--
-- |ER-----------------------------------------------------------------------
-- |ER A_Representation_Clause - 13.1
-- |ER-----------------------------------------------------------------------
-- |ER An_Attribute_Definition_Clause - 13.3
-- |ER An_Enumeration_Representation_Clause - 13.4
-- |ER An_At_Clause - J.7
-- |CR
-- |CR Child elements returned by:
-- |CR function Representation_Clause_Name
-- |CR function Representation_Clause_Expression
--
------------------------------------------------------------------------------
-- 19.2 function Representation_Clause_Name
------------------------------------------------------------------------------
function Representation_Clause_Name (Clause : in Asis.Clause)
return Asis.Name;
------------------------------------------------------------------------------
-- Clause - Specifies the representation_clause to query
--
-- Returns the direct_name expression following the reserved word "for".
--
-- Appropriate Clause_Kinds:
-- A_Representation_Clause
-- A_Component_Clause
--
-- Returns Expression_Kinds:
-- An_Identifier
-- An_Attribute_Reference
--
------------------------------------------------------------------------------
-- 19.3 function Representation_Clause_Expression
------------------------------------------------------------------------------
function Representation_Clause_Expression
(Clause : in Asis.Representation_Clause)
return Asis.Expression;
------------------------------------------------------------------------------
-- Clause - Specifies the representation_clause to query
--
-- Returns the expression following the reserved word "use" or the reserved
-- words "use at".
--
-- Appropriate Representation_Clause_Kinds:
-- An_Attribute_Definition_Clause
-- An_Enumeration_Representation_Clause
-- An_At_Clause
--
-- Returns Element_Kinds:
-- An_Expression
--
-- |ER-----------------------------------------------------------------------
-- |ER A_Record_Representation_Clause - 13.5.1
-- |CR
-- |CR Child elements returned by:
-- |CR function Representation_Clause_Name
-- |CR function Mod_Clause_Expression
-- |CR function Component_Clauses
--
------------------------------------------------------------------------------
-- 19.4 function Mod_Clause_Expression
------------------------------------------------------------------------------
function Mod_Clause_Expression (Clause : in Asis.Representation_Clause)
return Asis.Expression;
------------------------------------------------------------------------------
-- Clause - Specifies the record representation clause to query
--
-- Returns the static_expression appearing after the reserved words "at mod".
--
-- Returns a Nil_Element if a mod_clause is not present.
--
-- Appropriate Representation_Clause_Kinds:
-- A_Record_Representation_Clause
--
-- Returns Element_Kinds:
-- Not_An_Element
-- An_Expression
--
------------------------------------------------------------------------------
-- 19.5 function Component_Clauses
------------------------------------------------------------------------------
function Component_Clauses (Clause : in Asis.Representation_Clause;
Include_Pragmas : in Boolean := False)
return Asis.Component_Clause_List;
------------------------------------------------------------------------------
-- Clause - Specifies the record representation clause to query
-- Include_Pragmas - Specifies whether pragmas are to be returned
--
-- Returns the component_clause and pragma elements from the
-- record_representation_clause, in their order of appearance.
--
-- Returns a Nil_Element_List if the record_representation_clause has no
-- component_clause or pragma elements.
--
-- Appropriate Representation_Clause_Kinds:
-- A_Record_Representation_Clause
--
-- Returns Element_Kinds:
-- A_Clause
-- A_Pragma
--
-- Returns Clause_Kinds:
-- A_Component_Clause
--
-- |ER-----------------------------------------------------------------------
-- |ER A_Component_Clause - 13.5.1
-- |CR
-- |CR Child elements returned by:
-- |CR function Representation_Clause_Name
-- |CR function Component_Clause_Position
-- |CR function Component_Clause_Range
--
------------------------------------------------------------------------------
-- 19.6 function Component_Clause_Position
------------------------------------------------------------------------------
function Component_Clause_Position (Clause : in Asis.Component_Clause)
return Asis.Expression;
------------------------------------------------------------------------------
-- Clause - Specifies the component_clause to query
--
-- Returns the position expression for the component_clause.
--
-- Appropriate Clause_Kinds:
-- A_Component_Clause
--
-- Returns Element_Kinds:
-- An_Expression
--
------------------------------------------------------------------------------
-- 19.7 function Component_Clause_Range
------------------------------------------------------------------------------
function Component_Clause_Range (Clause : in Asis.Component_Clause)
return Asis.Discrete_Range;
------------------------------------------------------------------------------
-- Clause - Specifies the component_clause to query
--
-- Returns the first_bit .. last_bit range for the component_clause.
--
-- Appropriate Clause_Kinds:
-- A_Component_Clause
--
-- Returns Discrete_Range_Kinds:
-- A_Discrete_Simple_Expression_Range
--
------------------------------------------------------------------------------
end Asis.Clauses;
------------------------------------------------------------------------------
-- Copyright (c) 2006-2013, Maxim Reznik
-- 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 Maxim Reznik, 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.
------------------------------------------------------------------------------
|
nerilex/ada-util | Ada | 11,182 | adb | -----------------------------------------------------------------------
-- util-texts-builders_tests -- Unit tests for text builders
-- Copyright (C) 2013, 2016 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Ada.Text_IO;
with Util.Test_Caller;
with Util.Texts.Builders;
with Util.Measures;
package body Util.Texts.Builders_Tests is
package String_Builder is new Util.Texts.Builders (Element_Type => Character,
Input => String,
Chunk_Size => 100);
package Caller is new Util.Test_Caller (Test, "Texts.Builders");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test Util.Texts.Builders.Length",
Test_Length'Access);
Caller.Add_Test (Suite, "Test Util.Texts.Builders.Append",
Test_Append'Access);
Caller.Add_Test (Suite, "Test Util.Texts.Builders.Clear",
Test_Clear'Access);
Caller.Add_Test (Suite, "Test Util.Texts.Builders.Iterate",
Test_Iterate'Access);
Caller.Add_Test (Suite, "Test Util.Texts.Builders.Tail",
Test_Tail'Access);
Caller.Add_Test (Suite, "Test Util.Texts.Builders.Perf",
Test_Perf'Access);
end Add_Tests;
-- ------------------------------
-- Test the length operation.
-- ------------------------------
procedure Test_Length (T : in out Test) is
B : String_Builder.Builder (10);
begin
Util.Tests.Assert_Equals (T, 0, String_Builder.Length (B), "Invalid length");
Util.Tests.Assert_Equals (T, 10, String_Builder.Capacity (B), "Invalid capacity");
end Test_Length;
-- ------------------------------
-- Test the append operation.
-- ------------------------------
procedure Test_Append (T : in out Test) is
S : constant String := "0123456789";
B : String_Builder.Builder (3);
begin
String_Builder.Append (B, "a string");
Util.Tests.Assert_Equals (T, 8, String_Builder.Length (B), "Invalid length");
Util.Tests.Assert_Equals (T, "a string", String_Builder.To_Array (B), "Invalid content");
Util.Tests.Assert_Equals (T, 100 + 3, String_Builder.Capacity (B), "Invalid capacity");
-- Append new string and check content.
String_Builder.Append (B, " b string");
Util.Tests.Assert_Equals (T, 17, String_Builder.Length (B), "Invalid length");
Util.Tests.Assert_Equals (T, "a string b string", String_Builder.To_Array (B),
"Invalid content");
Util.Tests.Assert_Equals (T, 100 + 3, String_Builder.Capacity (B), "Invalid capacity");
String_Builder.Clear (B);
for I in S'Range loop
String_Builder.Append (B, S (I));
end loop;
Util.Tests.Assert_Equals (T, 10, String_Builder.Length (B), "Invalid length");
Util.Tests.Assert_Equals (T, S, String_Builder.To_Array (B), "Invalid append");
end Test_Append;
-- ------------------------------
-- Test the clear operation.
-- ------------------------------
procedure Test_Clear (T : in out Test) is
B : String_Builder.Builder (7);
begin
for I in 1 .. 10 loop
String_Builder.Append (B, "a string");
end loop;
Util.Tests.Assert_Equals (T, 8 * 10, String_Builder.Length (B), "Invalid length");
Util.Tests.Assert_Equals (T, 100 + 7, String_Builder.Capacity (B), "Invalid capacity");
String_Builder.Clear (B);
Util.Tests.Assert_Equals (T, 0, String_Builder.Length (B), "Invalid length after clear");
Util.Tests.Assert_Equals (T, 7, String_Builder.Capacity (B), "Invalid capacity after clear");
end Test_Clear;
-- ------------------------------
-- Test the tail operation.
-- ------------------------------
procedure Test_Tail (T : in out Test) is
procedure Check_Tail (Min : in Positive;
Max : in Positive;
L : in Natural);
procedure Check_Tail (Min : in Positive;
Max : in Positive;
L : in Natural) is
P : constant String := "0123456789";
B : String_Builder.Builder (Min);
begin
for I in 1 .. Max loop
String_Builder.Append (B, P (1 + (I mod 10)));
end loop;
declare
S : constant String := String_Builder.Tail (B, L);
S2 : constant String := String_Builder.To_Array (B);
begin
Util.Tests.Assert_Equals (T, Max, S2'Length, "Invalid length");
if L >= Max then
Util.Tests.Assert_Equals (T, S2, S, "Invalid Tail result");
else
Util.Tests.Assert_Equals (T, S2 (S2'Last - L + 1.. S2'Last), S,
"Invalid Tail result {"
& Positive'Image (Min) & ","
& Positive'Image (Max) & ","
& Positive'Image (L) & "]");
end if;
end;
end Check_Tail;
begin
for I in 1 .. 100 loop
for J in 1 .. 8 loop
for K in 1 .. I + 3 loop
Check_Tail (J, I, K);
end loop;
end loop;
end loop;
end Test_Tail;
-- ------------------------------
-- Test the iterate operation.
-- ------------------------------
procedure Test_Iterate (T : in out Test) is
procedure Process (S : in String);
B : String_Builder.Builder (13);
R : Ada.Strings.Unbounded.Unbounded_String;
procedure Process (S : in String) is
begin
Ada.Strings.Unbounded.Append (R, S);
end Process;
begin
for I in 1 .. 100 loop
String_Builder.Append (B, "The Iterate procedure avoids the string copy "
& "on the secondary stack");
end loop;
String_Builder.Iterate (B, Process'Access);
Util.Tests.Assert_Equals (T, String_Builder.Length (B), Ada.Strings.Unbounded.Length (R),
"Invalid length in iterate string");
Util.Tests.Assert_Equals (T, String_Builder.To_Array (B),
Ada.Strings.Unbounded.To_String (R), "Invalid Iterate");
end Test_Iterate;
-- ------------------------------
-- Test the append and iterate performance.
-- ------------------------------
procedure Test_Perf (T : in out Test) is
Perf : Ada.Text_IO.File_Type;
begin
Ada.Text_IO.Create (File => Perf,
Name => Util.Tests.Get_Test_Path ("string-append.csv"));
Ada.Text_IO.Put_Line (Perf, "Block_Size,Append Time,To_Array Time,Iterate Time");
for Block_Size in 1 .. 300 loop
declare
B : String_Builder.Builder (10);
N : constant String := Natural'Image (Block_Size * 10) & ",";
begin
String_Builder.Set_Block_Size (B, Block_Size * 10);
declare
S : Util.Measures.Stamp;
begin
for I in 1 .. 1000 loop
String_Builder.Append (B, "some item");
end loop;
Util.Measures.Report (S, Perf, N, Util.Measures.Microseconds);
end;
declare
S : Util.Measures.Stamp;
R : constant String := String_Builder.To_Array (B);
begin
Util.Measures.Report (S, Perf, ",", Util.Measures.Microseconds);
T.Assert (R'Length > 0, "Invalid string length");
end;
declare
Count : Natural := 0;
procedure Process (Item : in String);
procedure Process (Item : in String) is
pragma Unreferenced (Item);
begin
Count := Count + 1;
end Process;
S : Util.Measures.Stamp;
begin
String_Builder.Iterate (B, Process'Access);
Util.Measures.Report (S, Perf, ",", Util.Measures.Microseconds);
T.Assert (Count > 0, "The string builder was empty");
end;
end;
Ada.Text_IO.New_Line (Perf);
end loop;
Ada.Text_IO.Close (Perf);
Ada.Text_IO.Create (File => Perf,
Name => Util.Tests.Get_Test_Path ("string.csv"));
Ada.Text_IO.Put_Line (Perf, "Size,Append (100),Append (512),"
& "Append (1024),Unbounded,Iterate Time");
for I in 1 .. 4000 loop
declare
N : constant String := Natural'Image (I) & ",";
B : String_Builder.Builder (10);
B2 : String_Builder.Builder (10);
B3 : String_Builder.Builder (10);
U : Ada.Strings.Unbounded.Unbounded_String;
S : Util.Measures.Stamp;
begin
for J in 1 .. I loop
String_Builder.Append (B, "some item");
end loop;
Util.Measures.Report (S, Perf, N, Util.Measures.Microseconds);
String_Builder.Set_Block_Size (B2, 512);
for J in 1 .. I loop
String_Builder.Append (B2, "some item");
end loop;
Util.Measures.Report (S, Perf, ",", Util.Measures.Microseconds);
String_Builder.Set_Block_Size (B3, 1024);
for J in 1 .. I loop
String_Builder.Append (B3, "some item");
end loop;
Util.Measures.Report (S, Perf, ",", Util.Measures.Microseconds);
for J in 1 .. I loop
Ada.Strings.Unbounded.Append (U, "some item");
end loop;
Util.Measures.Report (S, Perf, ",", Util.Measures.Microseconds);
declare
R : constant String := String_Builder.To_Array (B);
pragma Unreferenced (R);
begin
Util.Measures.Report (S, Perf, ",", Util.Measures.Microseconds);
end;
declare
R : constant String := Ada.Strings.Unbounded.To_String (U);
pragma Unreferenced (R);
begin
Util.Measures.Report (S, Perf, ",", Util.Measures.Microseconds);
end;
end;
Ada.Text_IO.New_Line (Perf);
end loop;
end Test_Perf;
end Util.Texts.Builders_Tests;
|
reznikmm/matreshka | Ada | 4,859 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package AMF.Internals.OCL_Scanners is
type OCL_Token is
(T_Error,
T_String_Char, -- #x27 StringChar* #x27
T_Simple_Name_A, -- NameStartChar NameChar*
T_Simple_Name_B, -- '_' #x27 StringChar* #x27
T_Double_Colon, -- '::'
-- Keywords.
T_And,
T_Body,
T_Context,
T_Def,
T_Derive,
T_Else,
T_End_If,
T_End_Package,
T_False,
T_If,
T_Implies,
T_In,
T_Init,
T_Inv,
T_Invalid,
T_Let,
T_Not,
T_Null,
T_Or,
T_Package,
T_Post,
T_Pre,
T_Self,
T_Static,
T_Then,
T_True,
T_Xor,
-- Restricted words.
T_Bag,
T_Boolean,
T_Collection,
T_Integer,
T_Ocl_Any,
T_Ocl_Invalid,
T_Ocl_Message,
T_Ocl_Void,
T_Ordered_Set,
T_Real,
T_Sequence,
T_Set,
T_String,
T_Tuple,
T_Unlimited_Natural);
type OCL_Scanner is tagged limited private;
type OCL_Scanner_State is private;
function Save (Self : in out OCL_Scanner) return OCL_Scanner_State;
procedure Restore
(Self : in out OCL_Scanner; State : OCL_Scanner_State);
function Token (Self : in out OCL_Scanner) return OCL_Token;
function Get_String_Char
(Self : OCL_Scanner) return League.Strings.Universal_String;
procedure Forward (Self : in out OCL_Scanner);
private
type OCL_Scanner is tagged limited null record;
type OCL_Scanner_State is null record;
end AMF.Internals.OCL_Scanners;
|
zhmu/ananas | Ada | 145 | adb | -- { dg-do compile }
-- { dg-options "-O -gnatn -Winline" }
with Inline11_Pkg; use Inline11_Pkg;
procedure Inline11 is
begin
Trace (0);
end;
|
Tim-Tom/project-euler | Ada | 583 | adb | with Ada.Integer_Text_IO;
with Ada.Text_IO;
with BigInteger; use BigInteger;
package body Problem_16 is
package IO renames Ada.Text_IO;
package I_IO renames Ada.Integer_Text_IO;
procedure Solve is
Big : constant BigInteger.BigInt := BigInteger.Create(2)**1_000;
Str : constant String := BigInteger.ToString(Big);
Digit_Sum : Natural := 0;
begin
for index in Str'Range loop
Digit_Sum := Digit_Sum + Character'Pos(Str(index)) - Character'Pos('0');
end loop;
I_IO.Put(Digit_Sum);
IO.New_Line;
end Solve;
end Problem_16;
|
reznikmm/matreshka | Ada | 16,899 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Elements;
with AMF.Internals.Element_Collections;
with AMF.Internals.Helpers;
with AMF.Internals.Tables.UML_Attributes;
with AMF.Visitors.UML_Iterators;
with AMF.Visitors.UML_Visitors;
with League.Strings.Internals;
with Matreshka.Internals.Strings;
package body AMF.Internals.UML_Literal_Unlimited_Naturals is
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then
AMF.Visitors.UML_Visitors.UML_Visitor'Class
(Visitor).Enter_Literal_Unlimited_Natural
(AMF.UML.Literal_Unlimited_Naturals.UML_Literal_Unlimited_Natural_Access (Self),
Control);
end if;
end Enter_Element;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then
AMF.Visitors.UML_Visitors.UML_Visitor'Class
(Visitor).Leave_Literal_Unlimited_Natural
(AMF.UML.Literal_Unlimited_Naturals.UML_Literal_Unlimited_Natural_Access (Self),
Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Iterator in AMF.Visitors.UML_Iterators.UML_Iterator'Class then
AMF.Visitors.UML_Iterators.UML_Iterator'Class
(Iterator).Visit_Literal_Unlimited_Natural
(Visitor,
AMF.UML.Literal_Unlimited_Naturals.UML_Literal_Unlimited_Natural_Access (Self),
Control);
end if;
end Visit_Element;
---------------------------
-- Get_Client_Dependency --
---------------------------
overriding function Get_Client_Dependency
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy)
return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency is
begin
return
AMF.UML.Dependencies.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Client_Dependency
(Self.Element)));
end Get_Client_Dependency;
-------------------------
-- Get_Name_Expression --
-------------------------
overriding function Get_Name_Expression
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy)
return AMF.UML.String_Expressions.UML_String_Expression_Access is
begin
return
AMF.UML.String_Expressions.UML_String_Expression_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Name_Expression
(Self.Element)));
end Get_Name_Expression;
-------------------
-- Get_Namespace --
-------------------
overriding function Get_Namespace
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access is
begin
return
AMF.UML.Namespaces.UML_Namespace_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Namespace
(Self.Element)));
end Get_Namespace;
-----------------------------------
-- Get_Owning_Template_Parameter --
-----------------------------------
overriding function Get_Owning_Template_Parameter
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is
begin
return
AMF.UML.Template_Parameters.UML_Template_Parameter_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Owning_Template_Parameter
(Self.Element)));
end Get_Owning_Template_Parameter;
------------------------
-- Get_Qualified_Name --
------------------------
overriding function Get_Qualified_Name
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy)
return AMF.Optional_String is
begin
declare
use type Matreshka.Internals.Strings.Shared_String_Access;
Aux : constant Matreshka.Internals.Strings.Shared_String_Access
:= AMF.Internals.Tables.UML_Attributes.Internal_Get_Qualified_Name (Self.Element);
begin
if Aux = null then
return (Is_Empty => True);
else
return (False, League.Strings.Internals.Create (Aux));
end if;
end;
end Get_Qualified_Name;
----------------------------
-- Get_Template_Parameter --
----------------------------
overriding function Get_Template_Parameter
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is
begin
return
AMF.UML.Template_Parameters.UML_Template_Parameter_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Template_Parameter
(Self.Element)));
end Get_Template_Parameter;
--------------
-- Get_Type --
--------------
overriding function Get_Type
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy)
return AMF.UML.Types.UML_Type_Access is
begin
return
AMF.UML.Types.UML_Type_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Type
(Self.Element)));
end Get_Type;
---------------
-- Get_Value --
---------------
overriding function Get_Value
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy)
return AMF.Unlimited_Natural is
begin
return
AMF.Internals.Tables.UML_Attributes.Internal_Get_Value
(Self.Element);
end Get_Value;
-------------------------
-- Set_Name_Expression --
-------------------------
overriding procedure Set_Name_Expression
(Self : not null access UML_Literal_Unlimited_Natural_Proxy;
To : AMF.UML.String_Expressions.UML_String_Expression_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Name_Expression
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Name_Expression;
-----------------------------------
-- Set_Owning_Template_Parameter --
-----------------------------------
overriding procedure Set_Owning_Template_Parameter
(Self : not null access UML_Literal_Unlimited_Natural_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Owning_Template_Parameter
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Owning_Template_Parameter;
----------------------------
-- Set_Template_Parameter --
----------------------------
overriding procedure Set_Template_Parameter
(Self : not null access UML_Literal_Unlimited_Natural_Proxy;
To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Template_Parameter
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Template_Parameter;
--------------
-- Set_Type --
--------------
overriding procedure Set_Type
(Self : not null access UML_Literal_Unlimited_Natural_Proxy;
To : AMF.UML.Types.UML_Type_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Type
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Type;
---------------
-- Set_Value --
---------------
overriding procedure Set_Value
(Self : not null access UML_Literal_Unlimited_Natural_Proxy;
To : AMF.Unlimited_Natural) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Value
(Self.Element, To);
end Set_Value;
---------------------
-- Unlimited_Value --
---------------------
overriding function Unlimited_Value
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy)
return AMF.Unlimited_Natural
is
-- 7.3.32 LiteralUnlimitedNatural (from Kernel)
--
-- [2] The query unlimitedValue() gives the value.
--
-- LiteralUnlimitedNatural::unlimitedValue() : [UnlimitedNatural];
-- unlimitedValue = value
begin
return UML_Literal_Unlimited_Natural_Proxy'Class (Self.all).Get_Value;
end Unlimited_Value;
---------------------
-- Unlimited_Value --
---------------------
overriding function Unlimited_Value
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy)
return AMF.Optional_Unlimited_Natural
is
-- 7.3.32 LiteralUnlimitedNatural (from Kernel)
--
-- [2] The query unlimitedValue() gives the value.
--
-- LiteralUnlimitedNatural::unlimitedValue() : [UnlimitedNatural];
-- unlimitedValue = value
begin
return
(False, UML_Literal_Unlimited_Natural_Proxy'Class (Self.all).Get_Value);
end Unlimited_Value;
-------------------
-- Is_Computable --
-------------------
overriding function Is_Computable
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Computable unimplemented");
raise Program_Error with "Unimplemented procedure UML_Literal_Unlimited_Natural_Proxy.Is_Computable";
return Is_Computable (Self);
end Is_Computable;
------------------------
-- Is_Compatible_With --
------------------------
overriding function Is_Compatible_With
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy;
P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Compatible_With unimplemented");
raise Program_Error with "Unimplemented procedure UML_Literal_Unlimited_Natural_Proxy.Is_Compatible_With";
return Is_Compatible_With (Self, P);
end Is_Compatible_With;
-------------------------
-- All_Owning_Packages --
-------------------------
overriding function All_Owning_Packages
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy)
return AMF.UML.Packages.Collections.Set_Of_UML_Package is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "All_Owning_Packages unimplemented");
raise Program_Error with "Unimplemented procedure UML_Literal_Unlimited_Natural_Proxy.All_Owning_Packages";
return All_Owning_Packages (Self);
end All_Owning_Packages;
-----------------------------
-- Is_Distinguishable_From --
-----------------------------
overriding function Is_Distinguishable_From
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access;
Ns : AMF.UML.Namespaces.UML_Namespace_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented");
raise Program_Error with "Unimplemented procedure UML_Literal_Unlimited_Natural_Proxy.Is_Distinguishable_From";
return Is_Distinguishable_From (Self, N, Ns);
end Is_Distinguishable_From;
---------------
-- Namespace --
---------------
overriding function Namespace
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Namespace unimplemented");
raise Program_Error with "Unimplemented procedure UML_Literal_Unlimited_Natural_Proxy.Namespace";
return Namespace (Self);
end Namespace;
---------------------------
-- Is_Template_Parameter --
---------------------------
overriding function Is_Template_Parameter
(Self : not null access constant UML_Literal_Unlimited_Natural_Proxy)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Template_Parameter unimplemented");
raise Program_Error with "Unimplemented procedure UML_Literal_Unlimited_Natural_Proxy.Is_Template_Parameter";
return Is_Template_Parameter (Self);
end Is_Template_Parameter;
end AMF.Internals.UML_Literal_Unlimited_Naturals;
|
zhmu/ananas | Ada | 5,898 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- ADA.CONTAINERS.BOUNDED_PRIORITY_QUEUES --
-- --
-- S p e c --
-- --
-- Copyright (C) 2011-2022, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- This unit was originally developed by Matthew J Heaney. --
------------------------------------------------------------------------------
with System;
with Ada.Containers.Synchronized_Queue_Interfaces;
with Ada.Containers.Bounded_Doubly_Linked_Lists;
generic
with package Queue_Interfaces is
new Ada.Containers.Synchronized_Queue_Interfaces (<>);
type Queue_Priority is private;
with function Get_Priority
(Element : Queue_Interfaces.Element_Type) return Queue_Priority is <>;
with function Before
(Left, Right : Queue_Priority) return Boolean is <>;
Default_Capacity : Count_Type;
Default_Ceiling : System.Any_Priority := System.Priority'Last;
package Ada.Containers.Bounded_Priority_Queues with
SPARK_Mode => Off
is
pragma Annotate (CodePeer, Skip_Analysis);
pragma Preelaborate;
package Implementation is
-- All identifiers in this unit are implementation defined
pragma Implementation_Defined;
type List_Type (Capacity : Count_Type) is tagged limited private;
procedure Enqueue
(List : in out List_Type;
New_Item : Queue_Interfaces.Element_Type);
procedure Dequeue
(List : in out List_Type;
Element : out Queue_Interfaces.Element_Type);
procedure Dequeue
(List : in out List_Type;
At_Least : Queue_Priority;
Element : in out Queue_Interfaces.Element_Type;
Success : out Boolean);
function First_Element
(List : List_Type) return Queue_Interfaces.Element_Type;
function Length (List : List_Type) return Count_Type;
function Max_Length (List : List_Type) return Count_Type;
private
-- We need a better data structure here, such as a proper heap. ???
pragma Warnings (Off);
-- Otherwise, we get warnings for the uninitialized variable in Insert
-- in Ada.Containers.Bounded_Doubly_Linked_Lists.
package List_Types is new Bounded_Doubly_Linked_Lists
(Element_Type => Queue_Interfaces.Element_Type,
"=" => Queue_Interfaces."=");
pragma Warnings (On);
type List_Type (Capacity : Count_Type) is tagged limited record
Container : List_Types.List (Capacity);
Max_Length : Count_Type := 0;
end record;
end Implementation;
protected type Queue
(Capacity : Count_Type := Default_Capacity;
Ceiling : System.Any_Priority := Default_Ceiling)
with
Priority => Ceiling
is new Queue_Interfaces.Queue with
overriding entry Enqueue (New_Item : Queue_Interfaces.Element_Type);
overriding entry Dequeue (Element : out Queue_Interfaces.Element_Type);
-- The priority queue operation Dequeue_Only_High_Priority had been a
-- protected entry in early drafts of AI05-0159, but it was discovered
-- that that operation as specified was not in fact implementable. The
-- operation was changed from an entry to a protected procedure per the
-- ARG meeting in Edinburgh (June 2011), with a different signature and
-- semantics.
procedure Dequeue_Only_High_Priority
(At_Least : Queue_Priority;
Element : in out Queue_Interfaces.Element_Type;
Success : out Boolean);
overriding function Current_Use return Count_Type;
overriding function Peak_Use return Count_Type;
private
List : Implementation.List_Type (Capacity);
end Queue;
end Ada.Containers.Bounded_Priority_Queues;
|
melwyncarlo/ProjectEuler | Ada | 303 | adb | with Ada.Text_IO;
with Ada.Integer_Text_IO;
-- Copyright 2021 Melwyn Francis Carlo
procedure A085 is
use Ada.Text_IO;
use Ada.Integer_Text_IO;
Str : constant String (1 .. 12) := "Hello World ";
Num : constant Integer := 2021;
begin
Put (Str);
Put (Num, Width => 0);
end A085;
|
Letractively/ada-ado | Ada | 3,743 | adb | -----------------------------------------------------------------------
-- ADO Dialects -- Driver support for basic SQL Generation
-- Copyright (C) 2010, 2011, 2012 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package body ADO.Drivers.Dialects is
-- --------------------
-- Check if the string is a reserved keyword.
-- --------------------
function Is_Reserved (D : in Dialect;
Name : in String) return Boolean is
begin
return D.Keywords.Contains (Name'Unrestricted_Access);
end Is_Reserved;
-- --------------------
-- Add a set of keywords to be escaped.
-- --------------------
procedure Add_Keywords (D : in out Dialect;
Keywords : in Keyword_Array) is
begin
for I in Keywords'Range loop
D.Keywords.Insert (Keywords (I));
end loop;
end Add_Keywords;
-- --------------------
-- Get the quote character to escape an identifier.
-- --------------------
function Get_Identifier_Quote (D : in Dialect) return Character is
pragma Unreferenced (D);
begin
return '`';
end Get_Identifier_Quote;
-- ------------------------------
-- Append the item in the buffer escaping some characters if necessary.
-- The default implementation only escapes the single quote ' by doubling them.
-- ------------------------------
procedure Escape_Sql (D : in Dialect;
Buffer : in out Unbounded_String;
Item : in String) is
pragma Unreferenced (D);
C : Character;
begin
for I in Item'Range loop
C := Item (I);
if C = ''' then
Append (Buffer, ''');
end if;
Append (Buffer, C);
end loop;
end Escape_Sql;
-- ------------------------------
-- Append the item in the buffer escaping some characters if necessary
-- ------------------------------
procedure Escape_Sql (D : in Dialect;
Buffer : in out Unbounded_String;
Item : in ADO.Blob_Ref) is
pragma Unreferenced (D);
use type Ada.Streams.Stream_Element;
C : Ada.Streams.Stream_Element;
Blob : constant ADO.Blob_Access := Item.Value;
begin
for I in Blob.Data'Range loop
C := Blob.Data (I);
case C is
when Character'Pos (ASCII.NUL) =>
Append (Buffer, '\');
Append (Buffer, '0');
when Character'Pos (ASCII.CR) =>
Append (Buffer, '\');
Append (Buffer, 'r');
when Character'Pos (ASCII.LF) =>
Append (Buffer, '\');
Append (Buffer, 'n');
when Character'Pos ('\') | Character'Pos (''') | Character'Pos ('"') =>
Append (Buffer, '\');
Append (Buffer, Character'Val (C));
when others =>
Append (Buffer, Character'Val (C));
end case;
end loop;
end Escape_Sql;
end ADO.Drivers.Dialects;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 1,958 | adb | with System; use System;
with STM32GD;
with STM32_SVD; use STM32_SVD;
with STM32_SVD.Flash; use STM32_SVD.Flash;
with STM32_SVD.RCC; use STM32_SVD.RCC;
with STM32_SVD.PWR; use STM32_SVD.PWR;
with STM32_SVD.GPIO; use STM32_SVD.GPIO;
with STM32_SVD.RTC; use STM32_SVD.RTC;
with STM32GD.Board; use STM32GD.Board;
with STM32GD.GPIO;
package body Power is
procedure Deactivate_Peripherals is
begin
RCC_Periph.AHBENR.IOPAEN := 1;
RCC_Periph.AHBENR.IOPBEN := 1;
RCC_Periph.AHBENR.IOPCEN := 1;
RCC_Periph.AHBENR.IOPDEN := 1;
RCC_Periph.AHBENR.IOPFEN := 1;
GPIOA_Periph.MODER.Val := 16#FFFF_FFFF#;
GPIOB_Periph.MODER.Val := 16#FFFF_FFFF#;
GPIOC_Periph.MODER.Val := 16#FFFF_FFFF#;
GPIOD_Periph.MODER.Val := 16#FFFF_FFFF#;
GPIOF_Periph.MODER.Val := 16#FFFF_FFFF#;
MOSI.Set_Mode (STM32GD.GPIO.Mode_In);
MOSI.Set_Pull_Resistor (STM32GD.GPIO.Pull_Down);
MISO.Set_Mode (STM32GD.GPIO.Mode_In);
MISO.Set_Pull_Resistor (STM32GD.GPIO.Pull_Down);
SCLK.Set_Mode (STM32GD.GPIO.Mode_In);
SCLK.Set_Pull_Resistor (STM32GD.GPIO.Pull_Up);
CSN.Set_Mode (STM32GD.GPIO.Mode_In);
CSN.Set_Pull_Resistor (STM32GD.GPIO.Pull_Up);
RCC_Periph.AHBENR.IOPAEN := 0;
RCC_Periph.AHBENR.IOPBEN := 0;
RCC_Periph.AHBENR.IOPCEN := 0;
RCC_Periph.AHBENR.IOPDEN := 0;
RCC_Periph.AHBENR.IOPFEN := 0;
RCC_Periph.APB2ENR.USART1EN := 0;
RCC_Periph.APB2ENR.SPI1EN := 0;
RCC_Periph.APB1ENR.I2C1EN := 0;
RCC_Periph.AHBENR.DMAEN := 0;
RCC_Periph.APB2ENR.ADCEN := 0;
end Deactivate_Peripherals;
procedure Stop is
SCB_SCR : aliased STM32_SVD.UInt32
with Address => System'To_Address (16#E000ED10#);
SCR : UInt32;
begin
PWR_Periph.CR.CWUF := 1;
PWR_Periph.CR.LPDS := 1;
PWR_Periph.CR.PDDS := 0;
SCR := SCB_SCR or 2#100#;
SCB_SCR := SCR;
STM32GD.WFE;
end Stop;
end Power;
|
godunko/adawebpack | Ada | 3,190 | ads | ------------------------------------------------------------------------------
-- --
-- AdaWebPack --
-- --
------------------------------------------------------------------------------
-- Copyright © 2020, Vadim Godunko --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- 3. Neither the name of the copyright 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 Web.DOM.Event_Listeners;
with Web.Strings;
package Web.DOM.Event_Targets is
pragma Preelaborate;
type Event_Target is limited interface;
not overriding procedure Add_Event_Listener
(Self : in out Event_Target;
Name : Web.Strings.Web_String;
Callback : not null Web.DOM.Event_Listeners.Event_Listener_Access;
Capture : Boolean := False) is abstract;
end Web.DOM.Event_Targets;
|
reznikmm/matreshka | Ada | 4,639 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Presentation.Pages_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Presentation_Pages_Attribute_Node is
begin
return Self : Presentation_Pages_Attribute_Node do
Matreshka.ODF_Presentation.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Presentation_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Presentation_Pages_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Pages_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Presentation_URI,
Matreshka.ODF_String_Constants.Pages_Attribute,
Presentation_Pages_Attribute_Node'Tag);
end Matreshka.ODF_Presentation.Pages_Attributes;
|
charlie5/cBound | Ada | 1,777 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_glx_get_histogram_parameterfv_request_t is
-- Item
--
type Item is record
major_opcode : aliased Interfaces.Unsigned_8;
minor_opcode : aliased Interfaces.Unsigned_8;
length : aliased Interfaces.Unsigned_16;
context_tag : aliased xcb.xcb_glx_context_tag_t;
target : aliased Interfaces.Unsigned_32;
pname : aliased Interfaces.Unsigned_32;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb
.xcb_glx_get_histogram_parameterfv_request_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_get_histogram_parameterfv_request_t.Item,
Element_Array =>
xcb.xcb_glx_get_histogram_parameterfv_request_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C
.size_t range <>) of aliased xcb
.xcb_glx_get_histogram_parameterfv_request_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_get_histogram_parameterfv_request_t.Pointer,
Element_Array =>
xcb.xcb_glx_get_histogram_parameterfv_request_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_glx_get_histogram_parameterfv_request_t;
|
AdaCore/training_material | Ada | 416 | ads | package Solar_System.Graphics is
protected Graphic_Context is
procedure Set_Window (W : Window_ID);
entry Get_Window (W : out Window_ID; C : out Canvas_ID);
private
Window : Window_ID;
Canvas : Canvas_ID;
Is_Set : Boolean := False;
end Graphic_Context;
task T_Display;
private
procedure Draw_Body (Object : Body_Type; Canvas : Canvas_ID);
end Solar_System.Graphics;
|
Gabriel-Degret/adalib | Ada | 572 | ads | -- Standard Ada library specification
-- Copyright (c) 2003-2018 Maxim Reznik <[email protected]>
-- Copyright (c) 2004-2016 AXE Consultants
-- Copyright (c) 2004, 2005, 2006 Ada-Europe
-- Copyright (c) 2000 The MITRE Corporation, Inc.
-- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc.
-- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual
---------------------------------------------------------------------------
with Ada.Wide_Text_IO;
package Ada.Float_Wide_Text_IO is new Ada.Wide_Text_IO.Float_IO (Float);
|
reznikmm/matreshka | Ada | 4,591 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Draw.Shape_Id_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Draw_Shape_Id_Attribute_Node is
begin
return Self : Draw_Shape_Id_Attribute_Node do
Matreshka.ODF_Draw.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Draw_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Draw_Shape_Id_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Shape_Id_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Draw_URI,
Matreshka.ODF_String_Constants.Shape_Id_Attribute,
Draw_Shape_Id_Attribute_Node'Tag);
end Matreshka.ODF_Draw.Shape_Id_Attributes;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.